mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
Added depth stencil texture formats.
This commit is contained in:
parent
7d61b3eafa
commit
046449395b
8 changed files with 281 additions and 60 deletions
|
@ -252,11 +252,30 @@
|
|||
#define BGFX_CAPS_TEXTURE_FORMAT_PTC12A UINT64_C(0x0000000000001000)
|
||||
#define BGFX_CAPS_TEXTURE_FORMAT_PTC22 UINT64_C(0x0000000000002000)
|
||||
#define BGFX_CAPS_TEXTURE_FORMAT_PTC24 UINT64_C(0x0000000000004000)
|
||||
#define BGFX_CAPS_TEXTURE_3D UINT64_C(0x0000000000010000)
|
||||
#define BGFX_CAPS_VERTEX_ATTRIB_HALF UINT64_C(0x0000000000020000)
|
||||
#define BGFX_CAPS_INSTANCING UINT64_C(0x0000000000040000)
|
||||
#define BGFX_CAPS_RENDERER_MULTITHREADED UINT64_C(0x0000000000080000)
|
||||
#define BGFX_CAPS_FRAGMENT_DEPTH UINT64_C(0x0000000000100000)
|
||||
#define BGFX_CAPS_TEXTURE_FORMAT_D16 UINT64_C(0x0000000000008000)
|
||||
#define BGFX_CAPS_TEXTURE_FORMAT_D24 UINT64_C(0x0000000000010000)
|
||||
#define BGFX_CAPS_TEXTURE_FORMAT_D24S8 UINT64_C(0x0000000000020000)
|
||||
#define BGFX_CAPS_TEXTURE_FORMAT_D32 UINT64_C(0x0000000000040000)
|
||||
#define BGFX_CAPS_TEXTURE_FORMAT_D16F UINT64_C(0x0000000000080000)
|
||||
#define BGFX_CAPS_TEXTURE_FORMAT_D24F UINT64_C(0x0000000000100000)
|
||||
#define BGFX_CAPS_TEXTURE_FORMAT_D32F UINT64_C(0x0000000000200000)
|
||||
#define BGFX_CAPS_TEXTURE_FORMAT_D0S8 UINT64_C(0x0000000000400000)
|
||||
#define BGFX_CAPS_TEXTURE_3D UINT64_C(0x0000000001000000)
|
||||
#define BGFX_CAPS_VERTEX_ATTRIB_HALF UINT64_C(0x0000000004000000)
|
||||
#define BGFX_CAPS_INSTANCING UINT64_C(0x0000000008000000)
|
||||
#define BGFX_CAPS_RENDERER_MULTITHREADED UINT64_C(0x0000000010000000)
|
||||
#define BGFX_CAPS_FRAGMENT_DEPTH UINT64_C(0x0000000020000000)
|
||||
|
||||
#define BGFX_CAPS_TEXTURE_DEPTH_MASK (0 \
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_D16 \
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_D24 \
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_D24S8 \
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_D32 \
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_D16F \
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_D24F \
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_D32F \
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_D0S8 \
|
||||
)
|
||||
|
||||
///
|
||||
#define BGFX_HANDLE(_name) \
|
||||
|
@ -355,7 +374,9 @@ namespace bgfx
|
|||
PTC12A, // PVRTC1 RGBA 2BPP
|
||||
PTC22, // PVRTC2 RGBA 2BPP
|
||||
PTC24, // PVRTC2 RGBA 4BPP
|
||||
Unknown,
|
||||
|
||||
Unknown, // compressed formats above
|
||||
|
||||
L8,
|
||||
BGRA8,
|
||||
RGBA16,
|
||||
|
@ -364,6 +385,17 @@ namespace bgfx
|
|||
RGBA4,
|
||||
RGB5A1,
|
||||
RGB10A2,
|
||||
|
||||
UnknownDepth, // depth formats below
|
||||
|
||||
D16,
|
||||
D24,
|
||||
D24S8,
|
||||
D32,
|
||||
D16F,
|
||||
D24F,
|
||||
D32F,
|
||||
D0S8,
|
||||
|
||||
Count
|
||||
};
|
||||
|
|
86
src/bgfx.cpp
86
src/bgfx.cpp
|
@ -657,6 +657,48 @@ namespace bgfx
|
|||
#endif // BGFX_CONFIG_RENDERER_
|
||||
}
|
||||
|
||||
struct CapsFlags
|
||||
{
|
||||
uint64_t m_flag;
|
||||
const char* m_str;
|
||||
};
|
||||
|
||||
static const CapsFlags s_capsFlags[] =
|
||||
{
|
||||
#define CAPS_FLAGS(_x) { _x, #_x }
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_BC1),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_BC2),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_BC3),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_BC4),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_BC5),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_ETC1),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_ETC2),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_ETC2A),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_ETC2A1),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_PTC12),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_PTC14),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_PTC14A),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_PTC12A),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_PTC22),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_PTC24),
|
||||
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D16),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D24),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D24S8),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D32),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D16F),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D24F),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D32F),
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_FORMAT_D0S8),
|
||||
|
||||
CAPS_FLAGS(BGFX_CAPS_TEXTURE_3D),
|
||||
CAPS_FLAGS(BGFX_CAPS_VERTEX_ATTRIB_HALF),
|
||||
CAPS_FLAGS(BGFX_CAPS_INSTANCING),
|
||||
CAPS_FLAGS(BGFX_CAPS_RENDERER_MULTITHREADED),
|
||||
CAPS_FLAGS(BGFX_CAPS_FRAGMENT_DEPTH),
|
||||
#undef CAPS_FLAGS
|
||||
};
|
||||
|
||||
void init(CallbackI* _callback, bx::ReallocatorI* _allocator)
|
||||
{
|
||||
BX_TRACE("Init...");
|
||||
|
@ -666,17 +708,7 @@ namespace bgfx
|
|||
g_caps.supported = 0
|
||||
| (BGFX_CONFIG_MULTITHREADED ? BGFX_CAPS_RENDERER_MULTITHREADED : 0)
|
||||
;
|
||||
g_caps.emulated = 0
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC1
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC2
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC3
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC4
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC5
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_ETC1
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_ETC2
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_ETC2A
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_ETC2A1
|
||||
;
|
||||
g_caps.emulated = 0;
|
||||
g_caps.maxDrawCalls = BGFX_CONFIG_MAX_DRAW_CALLS;
|
||||
|
||||
if (NULL != _allocator)
|
||||
|
@ -707,6 +739,38 @@ namespace bgfx
|
|||
// On NaCl and iOS renderer is on the main thread.
|
||||
s_ctx->init(!BX_PLATFORM_NACL && !BX_PLATFORM_IOS && !BX_PLATFORM_OSX);
|
||||
|
||||
const uint64_t emulatedCaps = 0
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC1
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC2
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC3
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC4
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC5
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_ETC1
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_ETC2
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_ETC2A
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_ETC2A1
|
||||
;
|
||||
|
||||
g_caps.emulated |= emulatedCaps ^ (g_caps.supported & emulatedCaps);
|
||||
|
||||
BX_TRACE("Supported capabilities:");
|
||||
for (uint32_t ii = 0; ii < BX_COUNTOF(s_capsFlags); ++ii)
|
||||
{
|
||||
if (0 != (g_caps.supported & s_capsFlags[ii].m_flag) )
|
||||
{
|
||||
BX_TRACE("\t%s", s_capsFlags[ii].m_str);
|
||||
}
|
||||
}
|
||||
|
||||
BX_TRACE("Emulated capabilities:");
|
||||
for (uint32_t ii = 0; ii < BX_COUNTOF(s_capsFlags); ++ii)
|
||||
{
|
||||
if (0 != (g_caps.emulated & s_capsFlags[ii].m_flag) )
|
||||
{
|
||||
BX_TRACE("\t%s", s_capsFlags[ii].m_str);
|
||||
}
|
||||
}
|
||||
|
||||
BX_TRACE("Init complete.");
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,36 @@ namespace bgfx
|
|||
16, // RGBA4
|
||||
16, // RGB5A1
|
||||
32, // RGB10A2
|
||||
0, // UnknownDepth
|
||||
16, // D16
|
||||
24, // D24
|
||||
32, // D24S8
|
||||
32, // D32
|
||||
16, // D16F
|
||||
24, // D24F
|
||||
32, // D32F
|
||||
8, // D0S8
|
||||
};
|
||||
|
||||
bool isCompressed(TextureFormat::Enum _format)
|
||||
{
|
||||
return _format < TextureFormat::Unknown;
|
||||
}
|
||||
|
||||
bool isColor(TextureFormat::Enum _format)
|
||||
{
|
||||
return _format > TextureFormat::Unknown
|
||||
&& _format < TextureFormat::UnknownDepth
|
||||
;
|
||||
}
|
||||
|
||||
bool isDepth(TextureFormat::Enum _format)
|
||||
{
|
||||
return _format > TextureFormat::UnknownDepth
|
||||
&& _format < TextureFormat::Count
|
||||
;
|
||||
}
|
||||
|
||||
uint32_t getBitsPerPixel(TextureFormat::Enum _format)
|
||||
{
|
||||
return s_bitsPerPixel[_format];
|
||||
|
|
|
@ -39,6 +39,15 @@ namespace bgfx
|
|||
const uint8_t* m_data;
|
||||
};
|
||||
|
||||
///
|
||||
bool isCompressed(TextureFormat::Enum _format);
|
||||
|
||||
///
|
||||
bool isColor(TextureFormat::Enum _format);
|
||||
|
||||
///
|
||||
bool isDepth(TextureFormat::Enum _format);
|
||||
|
||||
///
|
||||
uint32_t getBitsPerPixel(TextureFormat::Enum _format);
|
||||
|
||||
|
|
|
@ -214,6 +214,15 @@ namespace bgfx
|
|||
{ DXGI_FORMAT_B4G4R4A4_UNORM }, // RGBA4
|
||||
{ DXGI_FORMAT_B5G5R5A1_UNORM }, // RGB5A1
|
||||
{ DXGI_FORMAT_R10G10B10A2_UNORM }, // RGB10A2
|
||||
{ DXGI_FORMAT_UNKNOWN }, // UnknownDepth
|
||||
{ DXGI_FORMAT_D16_UNORM }, // D16
|
||||
{ DXGI_FORMAT_D24_UNORM_S8_UINT }, // D24
|
||||
{ DXGI_FORMAT_D24_UNORM_S8_UINT }, // D24S8
|
||||
{ DXGI_FORMAT_D24_UNORM_S8_UINT }, // D32
|
||||
{ DXGI_FORMAT_D32_FLOAT, }, // D16F
|
||||
{ DXGI_FORMAT_D32_FLOAT, }, // D24F
|
||||
{ DXGI_FORMAT_D32_FLOAT, }, // D32F
|
||||
{ DXGI_FORMAT_D24_UNORM_S8_UINT }, // D0S8
|
||||
};
|
||||
|
||||
static const D3D11_INPUT_ELEMENT_DESC s_attrib[Attrib::Count] =
|
||||
|
@ -488,15 +497,15 @@ namespace bgfx
|
|||
m_uniformReg.add(getPredefinedUniformName(PredefinedUniform::Enum(ii) ), &m_predefinedUniforms[ii]);
|
||||
}
|
||||
|
||||
g_caps.emulated &= ~( 0
|
||||
g_caps.supported |= ( 0
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC1
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC2
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC3
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC4
|
||||
);
|
||||
g_caps.supported |= ( 0
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC5
|
||||
| BGFX_CAPS_INSTANCING
|
||||
| BGFX_CAPS_TEXTURE_3D
|
||||
| BGFX_CAPS_TEXTURE_DEPTH_MASK
|
||||
| BGFX_CAPS_VERTEX_ATTRIB_HALF
|
||||
| BGFX_CAPS_FRAGMENT_DEPTH
|
||||
);
|
||||
|
|
|
@ -222,6 +222,19 @@ namespace bgfx
|
|||
{ D3DFMT_A4R4G4B4 }, // RGBA4
|
||||
{ D3DFMT_A1R5G5B5 }, // RGB5A1
|
||||
{ D3DFMT_A2B10G10R10 }, // RGB10A2
|
||||
{ D3DFMT_UNKNOWN }, // UnknownDepth
|
||||
{ D3DFMT_D16 }, // D16
|
||||
{ D3DFMT_D24X8 }, // D24
|
||||
{ D3DFMT_D24S8 }, // D24S8
|
||||
{ D3DFMT_D32 }, // D32
|
||||
{ D3DFMT_DF16 }, // D16F
|
||||
{ D3DFMT_DF24 }, // D24F
|
||||
{ D3DFMT_D32F_LOCKABLE }, // D32F
|
||||
#if defined(D3D_DISABLE_9EX)
|
||||
{ D3DFMT_UNKNOWN }, // D0S8
|
||||
#else
|
||||
{ D3DFMT_S8_LOCKABLE }, // D0S8
|
||||
#endif // defined(D3D_DISABLE_9EX)
|
||||
};
|
||||
|
||||
static ExtendedFormat s_extendedFormats[ExtendedFormat::Count] =
|
||||
|
@ -413,13 +426,12 @@ namespace bgfx
|
|||
BX_TRACE("Max fragment shader 2.0 instr. slots: %d", m_caps.PS20Caps.NumInstructionSlots);
|
||||
BX_TRACE("Max fragment shader 3.0 instr. slots: %d", m_caps.MaxPixelShader30InstructionSlots);
|
||||
|
||||
g_caps.emulated &= ~( 0
|
||||
g_caps.supported |= ( 0
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC1
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC2
|
||||
| BGFX_CAPS_TEXTURE_FORMAT_BC3
|
||||
);
|
||||
g_caps.supported |= ( 0
|
||||
| BGFX_CAPS_TEXTURE_3D
|
||||
| BGFX_CAPS_TEXTURE_DEPTH_MASK
|
||||
| BGFX_CAPS_VERTEX_ATTRIB_HALF
|
||||
| BGFX_CAPS_FRAGMENT_DEPTH
|
||||
);
|
||||
|
@ -451,10 +463,10 @@ namespace bgfx
|
|||
s_textureFormat[TextureFormat::BC4].m_fmt = s_extendedFormats[ExtendedFormat::Ati1].m_supported ? D3DFMT_ATI1 : D3DFMT_UNKNOWN;
|
||||
s_textureFormat[TextureFormat::BC5].m_fmt = s_extendedFormats[ExtendedFormat::Ati2].m_supported ? D3DFMT_ATI2 : D3DFMT_UNKNOWN;
|
||||
|
||||
g_caps.emulated &= ~( 0
|
||||
| (D3DFMT_UNKNOWN != s_textureFormat[TextureFormat::BC4].m_fmt ? BGFX_CAPS_TEXTURE_FORMAT_BC4 : 0)
|
||||
| (D3DFMT_UNKNOWN != s_textureFormat[TextureFormat::BC5].m_fmt ? BGFX_CAPS_TEXTURE_FORMAT_BC5 : 0)
|
||||
);
|
||||
g_caps.supported |= 0
|
||||
| (D3DFMT_UNKNOWN != s_textureFormat[TextureFormat::BC4].m_fmt ? BGFX_CAPS_TEXTURE_FORMAT_BC4 : 0)
|
||||
| (D3DFMT_UNKNOWN != s_textureFormat[TextureFormat::BC5].m_fmt ? BGFX_CAPS_TEXTURE_FORMAT_BC5 : 0)
|
||||
;
|
||||
g_caps.supported |= m_instancing ? BGFX_CAPS_INSTANCING : 0;
|
||||
#endif // BGFX_CONFIG_RENDERER_USE_EXTENSIONS
|
||||
|
||||
|
|
|
@ -231,6 +231,15 @@ namespace bgfx
|
|||
{ GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, true }, // RGBA4
|
||||
{ GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, true }, // RGB5A1
|
||||
{ GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, true }, // RGB10A2
|
||||
{ GL_ZERO, GL_ZERO, GL_ZERO, true }, // UnknownDepth
|
||||
{ GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_SHORT, false }, // D16
|
||||
{ GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, false }, // D24
|
||||
{ GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, false }, // D24S8
|
||||
{ GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, false }, // D32
|
||||
{ GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, false }, // D16F
|
||||
{ GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, false }, // D24F
|
||||
{ GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, false }, // D32F
|
||||
{ GL_STENCIL_INDEX8, GL_DEPTH_STENCIL, GL_UNSIGNED_BYTE, false }, // D0S8
|
||||
};
|
||||
|
||||
struct Extension
|
||||
|
@ -251,6 +260,7 @@ namespace bgfx
|
|||
ARB_multisample,
|
||||
ARB_sampler_objects,
|
||||
ARB_seamless_cube_map,
|
||||
ARB_texture_compression_rgtc,
|
||||
ARB_texture_float,
|
||||
ARB_texture_multisample,
|
||||
ARB_texture_swizzle,
|
||||
|
@ -258,6 +268,7 @@ namespace bgfx
|
|||
ARB_vertex_array_object,
|
||||
ARB_vertex_type_2_10_10_10_rev,
|
||||
ATI_meminfo,
|
||||
CHROMIUM_depth_texture,
|
||||
CHROMIUM_framebuffer_multisample,
|
||||
CHROMIUM_texture_compression_dxt3,
|
||||
CHROMIUM_texture_compression_dxt5,
|
||||
|
@ -282,6 +293,7 @@ namespace bgfx
|
|||
EXT_texture_type_2_10_10_10_REV,
|
||||
EXT_timer_query,
|
||||
EXT_unpack_subimage,
|
||||
GOOGLE_depth_texture,
|
||||
IMG_multisampled_render_to_texture,
|
||||
IMG_read_format,
|
||||
IMG_shader_binary,
|
||||
|
@ -334,6 +346,7 @@ namespace bgfx
|
|||
{ "GL_ARB_multisample", false, true },
|
||||
{ "GL_ARB_sampler_objects", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
|
||||
{ "GL_ARB_seamless_cube_map", BGFX_CONFIG_RENDERER_OPENGL >= 32, true },
|
||||
{ "GL_ARB_texture_compression_rgtc", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
||||
{ "GL_ARB_texture_float", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
||||
{ "GL_ARB_texture_multisample", BGFX_CONFIG_RENDERER_OPENGL >= 32, true },
|
||||
{ "GL_ARB_texture_swizzle", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
|
||||
|
@ -341,6 +354,7 @@ namespace bgfx
|
|||
{ "GL_ARB_vertex_array_object", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
||||
{ "GL_ARB_vertex_type_2_10_10_10_rev", false, true },
|
||||
{ "GL_ATI_meminfo", false, true },
|
||||
{ "GL_CHROMIUM_depth_texture", false, true },
|
||||
{ "GL_CHROMIUM_framebuffer_multisample", false, true },
|
||||
{ "GL_CHROMIUM_texture_compression_dxt3", false, true },
|
||||
{ "GL_CHROMIUM_texture_compression_dxt5", false, true },
|
||||
|
@ -365,6 +379,7 @@ namespace bgfx
|
|||
{ "GL_EXT_texture_type_2_10_10_10_REV", false, true },
|
||||
{ "GL_EXT_timer_query", false, true },
|
||||
{ "GL_EXT_unpack_subimage", false, true },
|
||||
{ "GL_GOOGLE_depth_texture", false, true },
|
||||
{ "GL_IMG_multisampled_render_to_texture", false, true },
|
||||
{ "GL_IMG_read_format", false, true },
|
||||
{ "GL_IMG_shader_binary", false, true },
|
||||
|
@ -550,6 +565,7 @@ namespace bgfx
|
|||
, m_vaoSupport(BGFX_CONFIG_RENDERER_OPENGL >= 31)
|
||||
, m_programBinarySupport(false)
|
||||
, m_textureSwizzleSupport(false)
|
||||
, m_depthTextureSupport(false)
|
||||
, m_useClearQuad(true)
|
||||
, m_flip(false)
|
||||
, m_hash( (BX_PLATFORM_WINDOWS<<1) | BX_ARCH_64BIT)
|
||||
|
@ -911,6 +927,7 @@ namespace bgfx
|
|||
bool m_samplerObjectSupport;
|
||||
bool m_programBinarySupport;
|
||||
bool m_textureSwizzleSupport;
|
||||
bool m_depthTextureSupport;
|
||||
bool m_useClearQuad;
|
||||
bool m_flip;
|
||||
|
||||
|
@ -1617,7 +1634,6 @@ namespace bgfx
|
|||
GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) );
|
||||
GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) );
|
||||
|
||||
// OpenGL ES 2.0 doesn't support GL_DEPTH_COMPONENT... this will fail.
|
||||
GL_CHECK(glTexImage2D(m_target
|
||||
, 0
|
||||
, GL_DEPTH_COMPONENT
|
||||
|
@ -2011,9 +2027,10 @@ namespace bgfx
|
|||
{
|
||||
m_color.createColor(colorFormat, _width, _height, minFilter, magFilter);
|
||||
}
|
||||
|
||||
|
||||
#if 0 // GLES can't create texture with depth texture format...
|
||||
if (0 < depthFormat)
|
||||
if (s_renderCtx->m_depthTextureSupport
|
||||
&& 0 < depthFormat)
|
||||
{
|
||||
m_depth.createDepth(_width, _height);
|
||||
}
|
||||
|
@ -2472,14 +2489,18 @@ namespace bgfx
|
|||
s_renderCtx = BX_NEW(g_allocator, RendererContext);
|
||||
s_renderCtx->init();
|
||||
|
||||
#if BGFX_CONFIG_DEBUG
|
||||
GLint numCmpFormats;
|
||||
GL_CHECK(glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numCmpFormats) );
|
||||
|
||||
BX_TRACE("GL_NUM_COMPRESSED_TEXTURE_FORMATS %d", numCmpFormats);
|
||||
|
||||
GLint* cmpFormat = NULL;
|
||||
|
||||
if (0 < numCmpFormats)
|
||||
{
|
||||
cmpFormat = (GLint*)alloca(sizeof(GLint)*numCmpFormats);
|
||||
GL_CHECK(glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, cmpFormat) );
|
||||
|
||||
#if BGFX_CONFIG_DEBUG
|
||||
static const char* s_textureFormatName[TextureFormat::Unknown+1] =
|
||||
{
|
||||
"BC1",
|
||||
|
@ -2500,18 +2521,17 @@ namespace bgfx
|
|||
"",
|
||||
// TextureFormat::Count
|
||||
};
|
||||
|
||||
GLint* formats = (GLint*)alloca(sizeof(GLint)*numCmpFormats);
|
||||
GL_CHECK(glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats) );
|
||||
#endif // BGFX_CONFIG_DEBUG
|
||||
|
||||
for (GLint ii = 0; ii < numCmpFormats; ++ii)
|
||||
{
|
||||
GLint internalFmt = formats[ii];
|
||||
GLint internalFmt = cmpFormat[ii];
|
||||
uint32_t fmt = uint32_t(TextureFormat::Unknown);
|
||||
for (uint32_t jj = 0; jj < fmt; ++jj)
|
||||
{
|
||||
if (s_textureFormat[jj].m_internalFmt == (GLenum)internalFmt)
|
||||
{
|
||||
s_textureFormat[jj].m_supported = true;
|
||||
fmt = jj;
|
||||
}
|
||||
}
|
||||
|
@ -2520,6 +2540,7 @@ namespace bgfx
|
|||
}
|
||||
}
|
||||
|
||||
#if BGFX_CONFIG_DEBUG
|
||||
# define GL_GET(_pname, _min) BX_TRACE(" " #_pname " %d (min: %d)", glGet(_pname), _min)
|
||||
|
||||
BX_TRACE("Defaults:");
|
||||
|
@ -2613,28 +2634,46 @@ namespace bgfx
|
|||
#endif // BGFX_CONFIG_RENDERER_OPENGL_USE_EXTENSIONS
|
||||
|
||||
bool bc123Supported = s_extension[Extension::EXT_texture_compression_s3tc].m_supported;
|
||||
s_textureFormat[TextureFormat::BC1].m_supported = bc123Supported || s_extension[Extension::EXT_texture_compression_dxt1].m_supported;
|
||||
s_textureFormat[TextureFormat::BC2].m_supported = bc123Supported || s_extension[Extension::CHROMIUM_texture_compression_dxt3].m_supported;
|
||||
s_textureFormat[TextureFormat::BC3].m_supported = bc123Supported || s_extension[Extension::CHROMIUM_texture_compression_dxt5].m_supported;
|
||||
s_textureFormat[TextureFormat::BC1].m_supported |= bc123Supported || s_extension[Extension::EXT_texture_compression_dxt1].m_supported;
|
||||
|
||||
if (!s_textureFormat[TextureFormat::BC1].m_supported
|
||||
&& (s_textureFormat[TextureFormat::BC2].m_supported || s_textureFormat[TextureFormat::BC3].m_supported) )
|
||||
{
|
||||
// If RGBA_S3TC_DXT1 is not supported, maybe RGB_S3TC_DXT1 is?
|
||||
for (GLint ii = 0; ii < numCmpFormats; ++ii)
|
||||
{
|
||||
if (GL_COMPRESSED_RGB_S3TC_DXT1_EXT == cmpFormat[ii])
|
||||
{
|
||||
s_textureFormat[TextureFormat::BC1].m_internalFmt = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
||||
s_textureFormat[TextureFormat::BC1].m_fmt = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
||||
s_textureFormat[TextureFormat::BC1].m_supported = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s_textureFormat[TextureFormat::BC2].m_supported |= bc123Supported || s_extension[Extension::CHROMIUM_texture_compression_dxt3].m_supported;
|
||||
s_textureFormat[TextureFormat::BC3].m_supported |= bc123Supported || s_extension[Extension::CHROMIUM_texture_compression_dxt5].m_supported;
|
||||
|
||||
bool bc45Supported = s_extension[Extension::EXT_texture_compression_latc].m_supported
|
||||
|| s_extension[Extension::ARB_texture_compression_rgtc].m_supported
|
||||
|| s_extension[Extension::EXT_texture_compression_rgtc].m_supported
|
||||
;
|
||||
s_textureFormat[TextureFormat::BC4].m_supported = bc45Supported;
|
||||
s_textureFormat[TextureFormat::BC5].m_supported = bc45Supported;
|
||||
s_textureFormat[TextureFormat::BC4].m_supported |= bc45Supported;
|
||||
s_textureFormat[TextureFormat::BC5].m_supported |= bc45Supported;
|
||||
|
||||
bool etc1Supported = s_extension[Extension::OES_compressed_ETC1_RGB8_texture].m_supported;
|
||||
s_textureFormat[TextureFormat::ETC1].m_supported = etc1Supported;
|
||||
s_textureFormat[TextureFormat::ETC1].m_supported |= etc1Supported;
|
||||
|
||||
bool etc2Supported = !!BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
|| s_extension[Extension::ARB_ES3_compatibility].m_supported
|
||||
;
|
||||
s_textureFormat[TextureFormat::ETC2 ].m_supported = etc2Supported;
|
||||
s_textureFormat[TextureFormat::ETC2A ].m_supported = etc2Supported;
|
||||
s_textureFormat[TextureFormat::ETC2A1].m_supported = etc2Supported;
|
||||
s_textureFormat[TextureFormat::ETC2 ].m_supported |= etc2Supported;
|
||||
s_textureFormat[TextureFormat::ETC2A ].m_supported |= etc2Supported;
|
||||
s_textureFormat[TextureFormat::ETC2A1].m_supported |= etc2Supported;
|
||||
|
||||
if (!s_textureFormat[TextureFormat::ETC1].m_supported
|
||||
&& etc2Supported)
|
||||
&& s_textureFormat[TextureFormat::ETC2].m_supported)
|
||||
{
|
||||
// When ETC2 is supported override ETC1 texture format settings.
|
||||
s_textureFormat[TextureFormat::ETC1].m_internalFmt = GL_COMPRESSED_RGB8_ETC2;
|
||||
|
@ -2643,23 +2682,35 @@ namespace bgfx
|
|||
}
|
||||
|
||||
bool ptc1Supported = s_extension[Extension::IMG_texture_compression_pvrtc ].m_supported;
|
||||
s_textureFormat[TextureFormat::PTC12].m_supported = ptc1Supported;
|
||||
s_textureFormat[TextureFormat::PTC14].m_supported = ptc1Supported;
|
||||
s_textureFormat[TextureFormat::PTC12A].m_supported = ptc1Supported;
|
||||
s_textureFormat[TextureFormat::PTC14A].m_supported = ptc1Supported;
|
||||
s_textureFormat[TextureFormat::PTC12 ].m_supported |= ptc1Supported;
|
||||
s_textureFormat[TextureFormat::PTC14 ].m_supported |= ptc1Supported;
|
||||
s_textureFormat[TextureFormat::PTC12A].m_supported |= ptc1Supported;
|
||||
s_textureFormat[TextureFormat::PTC14A].m_supported |= ptc1Supported;
|
||||
|
||||
bool ptc2Supported = s_extension[Extension::IMG_texture_compression_pvrtc2].m_supported;
|
||||
s_textureFormat[TextureFormat::PTC22].m_supported = ptc2Supported;
|
||||
s_textureFormat[TextureFormat::PTC24].m_supported = ptc2Supported;
|
||||
s_textureFormat[TextureFormat::PTC22].m_supported |= ptc2Supported;
|
||||
s_textureFormat[TextureFormat::PTC24].m_supported |= ptc2Supported;
|
||||
|
||||
uint64_t supportedCompressedFormats = 0
|
||||
| (s_textureFormat[TextureFormat::BC1 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_BC1 : 0)
|
||||
| (s_textureFormat[TextureFormat::BC2 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_BC2 : 0)
|
||||
| (s_textureFormat[TextureFormat::BC3 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_BC3 : 0)
|
||||
| (s_textureFormat[TextureFormat::BC4 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_BC4 : 0)
|
||||
| (s_textureFormat[TextureFormat::BC5 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_BC5 : 0)
|
||||
| (s_textureFormat[TextureFormat::ETC1 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_ETC1 : 0)
|
||||
| (s_textureFormat[TextureFormat::ETC2 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_ETC2 : 0)
|
||||
| (s_textureFormat[TextureFormat::ETC2A ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_ETC2A : 0)
|
||||
| (s_textureFormat[TextureFormat::ETC2A1].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_ETC2A1 : 0)
|
||||
| (s_textureFormat[TextureFormat::PTC12 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_PTC12 : 0)
|
||||
| (s_textureFormat[TextureFormat::PTC14 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_PTC14 : 0)
|
||||
| (s_textureFormat[TextureFormat::PTC14A].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_PTC14A : 0)
|
||||
| (s_textureFormat[TextureFormat::PTC12A].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_PTC12A : 0)
|
||||
| (s_textureFormat[TextureFormat::PTC22 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_PTC22 : 0)
|
||||
| (s_textureFormat[TextureFormat::PTC24 ].m_supported ? BGFX_CAPS_TEXTURE_FORMAT_PTC24 : 0)
|
||||
;
|
||||
|
||||
g_caps.supported |= supportedCompressedFormats;
|
||||
|
||||
g_caps.emulated &= ~( 0
|
||||
| bc123Supported ? BGFX_CAPS_TEXTURE_FORMAT_BC1|BGFX_CAPS_TEXTURE_FORMAT_BC2|BGFX_CAPS_TEXTURE_FORMAT_BC3 : 0
|
||||
| bc45Supported ? BGFX_CAPS_TEXTURE_FORMAT_BC4|BGFX_CAPS_TEXTURE_FORMAT_BC5 : 0
|
||||
| etc1Supported ? BGFX_CAPS_TEXTURE_FORMAT_ETC1 : 0
|
||||
| etc2Supported ? BGFX_CAPS_TEXTURE_FORMAT_ETC2|BGFX_CAPS_TEXTURE_FORMAT_ETC2A|BGFX_CAPS_TEXTURE_FORMAT_ETC2A1 : 0
|
||||
| ptc1Supported ? BGFX_CAPS_TEXTURE_FORMAT_PTC12|BGFX_CAPS_TEXTURE_FORMAT_PTC14|BGFX_CAPS_TEXTURE_FORMAT_PTC14A|BGFX_CAPS_TEXTURE_FORMAT_PTC12A : 0
|
||||
| ptc2Supported ? BGFX_CAPS_TEXTURE_FORMAT_PTC22|BGFX_CAPS_TEXTURE_FORMAT_PTC24 : 0
|
||||
);
|
||||
g_caps.supported |= !!(BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES3)|s_extension[Extension::OES_texture_3D].m_supported
|
||||
? BGFX_CAPS_TEXTURE_3D
|
||||
: 0
|
||||
|
@ -2706,6 +2757,14 @@ namespace bgfx
|
|||
|| s_extension[Extension::EXT_texture_swizzle].m_supported
|
||||
;
|
||||
|
||||
s_renderCtx->m_depthTextureSupport = !!(BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES3)
|
||||
|| s_extension[Extension::CHROMIUM_depth_texture].m_supported
|
||||
|| s_extension[Extension::GOOGLE_depth_texture].m_supported
|
||||
|| s_extension[Extension::OES_depth_texture].m_supported
|
||||
;
|
||||
|
||||
g_caps.supported |= s_renderCtx->m_depthTextureSupport ? BGFX_CAPS_TEXTURE_DEPTH_MASK : 0;
|
||||
|
||||
if (s_extension[Extension::EXT_texture_filter_anisotropic].m_supported)
|
||||
{
|
||||
GL_CHECK(glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &s_renderCtx->m_maxAnisotropy) );
|
||||
|
|
|
@ -148,6 +148,10 @@ typedef void (*PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)(GLuint shader, GLsizei b
|
|||
# define GL_RGBA16F 0x881A
|
||||
#endif // GL_RGBA16F
|
||||
|
||||
#ifndef GL_COMPRESSED_RGB_S3TC_DXT1_EXT
|
||||
# define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
|
||||
#endif // GL_COMPRESSED_RGB_S3TC_DXT1_EXT
|
||||
|
||||
#ifndef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
|
||||
# define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
|
||||
#endif // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
|
||||
|
@ -265,6 +269,10 @@ typedef void (*PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)(GLuint shader, GLsizei b
|
|||
# define GL_UNPACK_ROW_LENGTH 0x0CF2
|
||||
#endif // GL_UNPACK_ROW_LENGTH
|
||||
|
||||
#ifndef GL_DEPTH_STENCIL
|
||||
# define GL_DEPTH_STENCIL 0x84F9
|
||||
#endif // GL_DEPTH_STENCIL
|
||||
|
||||
#ifndef GL_DEPTH_COMPONENT32
|
||||
# define GL_DEPTH_COMPONENT32 0x81A7
|
||||
#endif // GL_DEPTH_COMPONENT32
|
||||
|
|
Loading…
Reference in a new issue