diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 8bb7b9a4..e3337ea1 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -654,15 +654,16 @@ namespace bgfx return 0 == err ? result : 0; } - void checkCmpFormat(GLint* _cmp, uint32_t _num, TextureFormat::Enum _fmt) + static void checkCmpFormat(GLint* _cmp, uint32_t _num, TextureFormat::Enum _fmt, GLint _glfmt) { - GLint glfmt = s_textureFormat[_fmt].m_fmt; for (uint32_t ii = 0; ii < _num; ++ii) { - if (glfmt == _cmp[ii]) + if (_glfmt == _cmp[ii]) { - s_textureFormat[_fmt].m_supported = true; - break; + s_textureFormat[_fmt].m_fmt = _glfmt; + s_textureFormat[_fmt].m_internalFmt = _glfmt; + s_textureFormat[_fmt].m_supported = true; + return; } } } @@ -1175,12 +1176,24 @@ namespace bgfx || s_extension[Extension::CHROMIUM_texture_compression_dxt5].m_supported ; - if (s_extension[Extension::EXT_texture_compression_latc].m_supported - || s_extension[Extension::ARB_texture_compression_rgtc].m_supported + if (s_extension[Extension::EXT_texture_compression_latc].m_supported) + { + checkCmpFormat(cmpFormat, numCmpFormats, TextureFormat::BC4, GL_COMPRESSED_LUMINANCE_LATC1_EXT); + checkCmpFormat(cmpFormat, numCmpFormats, TextureFormat::BC5, GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT); + } + + if (s_extension[Extension::ARB_texture_compression_rgtc].m_supported || s_extension[Extension::EXT_texture_compression_rgtc].m_supported) { - checkCmpFormat(cmpFormat, numCmpFormats, TextureFormat::BC4); - checkCmpFormat(cmpFormat, numCmpFormats, TextureFormat::BC5); + s_textureFormat[TextureFormat::BC4].m_fmt = GL_COMPRESSED_RED_RGTC1; + s_textureFormat[TextureFormat::BC4].m_internalFmt = GL_COMPRESSED_RED_RGTC1; + s_textureFormat[TextureFormat::BC4].m_supported = true; + s_textureFormat[TextureFormat::BC5].m_fmt = GL_COMPRESSED_RG_RGTC2; + s_textureFormat[TextureFormat::BC5].m_internalFmt = GL_COMPRESSED_RG_RGTC2; + s_textureFormat[TextureFormat::BC5].m_supported = true; + +// checkCmpFormat(cmpFormat, numCmpFormats, TextureFormat::BC4, GL_COMPRESSED_RED_RGTC1); +// checkCmpFormat(cmpFormat, numCmpFormats, TextureFormat::BC5, GL_COMPRESSED_RG_RGTC2); } bool etc1Supported = s_extension[Extension::OES_compressed_ETC1_RGB8_texture].m_supported; @@ -1360,14 +1373,6 @@ namespace bgfx } } - if (s_extension[Extension::EXT_texture_compression_rgtc].m_supported) - { - s_textureFormat[TextureFormat::BC4].m_fmt = GL_COMPRESSED_RED_RGTC1_EXT; - s_textureFormat[TextureFormat::BC4].m_internalFmt = GL_COMPRESSED_RED_RGTC1_EXT; - s_textureFormat[TextureFormat::BC5].m_fmt = GL_COMPRESSED_RED_GREEN_RGTC2_EXT; - s_textureFormat[TextureFormat::BC5].m_internalFmt = GL_COMPRESSED_RED_GREEN_RGTC2_EXT; - } - if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 30) ) { g_caps.supported |= BGFX_CAPS_INSTANCING; diff --git a/src/renderer_gl.h b/src/renderer_gl.h index d46d8c17..96923faa 100644 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -159,13 +159,13 @@ typedef uint64_t GLuint64; # define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 #endif // GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT -#ifndef GL_COMPRESSED_RED_RGTC1_EXT -# define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#endif // GL_COMPRESSED_RED_RGTC1_EXT +#ifndef GL_COMPRESSED_RED_RGTC1 +# define GL_COMPRESSED_RED_RGTC1 0x8DBB +#endif // GL_COMPRESSED_RED_RGTC1 -#ifndef GL_COMPRESSED_RED_GREEN_RGTC2_EXT -# define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#endif // GL_COMPRESSED_RED_GREEN_RGTC2_EXT +#ifndef GL_COMPRESSED_RG_RGTC2 +# define GL_COMPRESSED_RG_RGTC2 0x8DBD +#endif // GL_COMPRESSED_RG_RGTC2 #ifndef GL_ETC1_RGB8_OES # define GL_ETC1_RGB8_OES 0x8D64