Fix OpenGL ES depth&stencil format querying.
This commit is contained in:
parent
d539f3425f
commit
e1b3fe6d75
@ -1813,6 +1813,16 @@ namespace bgfx { namespace gl
|
||||
m_version = getGLString(GL_VERSION);
|
||||
m_glslVersion = getGLString(GL_SHADING_LANGUAGE_VERSION);
|
||||
|
||||
int glVersion;
|
||||
int majorGlVersion = 0;
|
||||
int minorGlVersion = 0;
|
||||
const char *version = m_version;
|
||||
while(*version && (*version < '0' || *version > '9'))
|
||||
++version;
|
||||
majorGlVersion = atoi(version);
|
||||
minorGlVersion = atoi(version + 2);
|
||||
glVersion = majorGlVersion*10 + minorGlVersion;
|
||||
|
||||
for (uint32_t ii = 0; ii < BX_COUNTOF(s_vendorIds); ++ii)
|
||||
{
|
||||
const VendorId& vendorId = s_vendorIds[ii];
|
||||
@ -2048,8 +2058,6 @@ namespace bgfx { namespace gl
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
|
||||
{
|
||||
setTextureFormat(TextureFormat::D32, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES < 30) )
|
||||
{
|
||||
setTextureFormat(TextureFormat::RGBA16F, GL_RGBA, GL_RGBA, GL_HALF_FLOAT);
|
||||
@ -2083,12 +2091,30 @@ namespace bgfx { namespace gl
|
||||
s_textureFilter[TextureFormat::RG32F] = linear32F;
|
||||
s_textureFilter[TextureFormat::RGBA32F] = linear32F;
|
||||
}
|
||||
}
|
||||
|
||||
if (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN))
|
||||
{
|
||||
setTextureFormat(TextureFormat::D16, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT);
|
||||
setTextureFormat(TextureFormat::D24S8, GL_DEPTH_STENCIL, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
|
||||
}
|
||||
if (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN)
|
||||
&& (s_extension[Extension::WEBGL_depth_texture].m_supported
|
||||
|| s_extension[Extension::MOZ_WEBGL_depth_texture].m_supported
|
||||
|| s_extension[Extension::WEBKIT_WEBGL_depth_texture].m_supported))
|
||||
{
|
||||
setTextureFormat(TextureFormat::D16, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT);
|
||||
setTextureFormat(TextureFormat::D24, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT); // N.b. OpenGL ES does not guarantee that there are 24 bits available here, could be 16. See https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/
|
||||
setTextureFormat(TextureFormat::D32, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT); // N.b. same as above.
|
||||
setTextureFormat(TextureFormat::D24S8, GL_DEPTH_STENCIL, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
|
||||
}
|
||||
|
||||
// OpenGL ES 3.0 depth formats.
|
||||
if (glVersion >= 30)
|
||||
{
|
||||
setTextureFormat(TextureFormat::D16, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT);
|
||||
setTextureFormat(TextureFormat::D24, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
|
||||
setTextureFormat(TextureFormat::D32, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
|
||||
setTextureFormat(TextureFormat::D24S8, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
|
||||
setTextureFormat(TextureFormat::D16F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT); // GLES 3.0 does not have D16F, overshoot to D32F
|
||||
setTextureFormat(TextureFormat::D24F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT); // GLES 3.0 does not have D24F, overshoot to D32F
|
||||
setTextureFormat(TextureFormat::D32F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT);
|
||||
setTextureFormat(TextureFormat::D0S8, GL_STENCIL_INDEX8, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE); // Only works as renderbuffer, not as texture
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user