@@ -1321,10 +1321,37 @@ static void LogFrameBufferError(GLenum status)
13211321 {
13221322 GLint *pCompressedFormats = new GLint[iNumCompressedFormats];
13231323 glGetIntegerv (GL_COMPRESSED_TEXTURE_FORMATS, pCompressedFormats);
1324+ bool isPagedASTCSupported = true ;
1325+ #if defined (__EMSCRIPTEN__)
1326+ // Workaround for some old phones which don't work with ASTC in glCompressedTexImage3D
1327+ // see https://github.com/defold/defold/issues/8030
1328+ // and https://github.com/defold/defold/issues/11009
1329+ if (context->m_IsGles3Version && OpenGLIsTextureFormatSupported (context, TEXTURE_FORMAT_RGBA_ASTC_4X4)) {
1330+ unsigned char fakeZeroBuffer[] = {
1331+ 0xFC , 0xFD , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF ,
1332+ 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF ,
1333+
1334+ 0xFC , 0xFD , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF ,
1335+ 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF
1336+
1337+ };
1338+ GLuint texture;
1339+ glGenTextures (1 , &texture);
1340+ glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
1341+ DMGRAPHICS_COMPRESSED_TEX_IMAGE_3D (GL_TEXTURE_2D_ARRAY, 0 , DMGRAPHICS_TEXTURE_FORMAT_RGBA_ASTC_4x4_KHR, 4 , 4 , 2 , 0 , 32 , &fakeZeroBuffer);
1342+ GLint err = glGetError ();
1343+ if (err != 0 )
1344+ {
1345+ context->m_ASTCSupport = 0 ;
1346+ isPagedASTCSupported = false ;
1347+ }
1348+ glDeleteTextures (1 , &texture);
1349+ }
1350+ #endif
13241351 for (int i = 0 ; i < iNumCompressedFormats; i++)
13251352 {
13261353 // If 4x4 is supported, all ASTC formats should be supported.
1327- if (pCompressedFormats[i] == DMGRAPHICS_TEXTURE_FORMAT_RGBA_ASTC_4x4_KHR)
1354+ if (isPagedASTCSupported && pCompressedFormats[i] == DMGRAPHICS_TEXTURE_FORMAT_RGBA_ASTC_4x4_KHR)
13281355 {
13291356 context->m_ASTCSupport = 1 ;
13301357 }
@@ -1346,27 +1373,6 @@ static void LogFrameBufferError(GLenum status)
13461373
13471374
13481375#if defined (__EMSCRIPTEN__)
1349- // Workaround for some old phones which don't work with ASTC in glCompressedTexImage3D
1350- // see https://github.com/defold/defold/issues/8030
1351- if (context->m_IsGles3Version && OpenGLIsTextureFormatSupported (context, TEXTURE_FORMAT_RGBA_ASTC_4X4)) {
1352- unsigned char fakeZeroBuffer[] = {
1353- 0x63 , 0xae , 0x88 , 0xc8 , 0xa6 , 0x0b , 0x45 , 0x35 , 0x8d , 0x27 , 0x7c , 0xb5 ,0x63 ,
1354- 0x2a , 0xcc , 0x90 , 0x01 , 0x04 , 0x04 , 0x01 , 0x04 , 0x04 , 0x01 , 0x04 , 0x04 , 0x01 ,
1355- 0x63 , 0xae , 0x88 , 0xc8 , 0xa6 , 0x0b , 0x45 , 0x35 , 0x8d , 0x27 , 0x7c , 0xb5 ,0x63 ,
1356- 0x2a , 0xcc , 0x90 , 0x01 , 0x04 , 0x04 , 0x01 , 0x04 , 0x04 , 0x01 , 0x04 , 0x04 , 0x01
1357- };
1358- GLuint texture;
1359- glGenTextures (1 , &texture);
1360- glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
1361- DMGRAPHICS_COMPRESSED_TEX_IMAGE_3D (GL_TEXTURE_2D_ARRAY, 0 , DMGRAPHICS_TEXTURE_FORMAT_RGBA_ASTC_4x4_KHR, 4 , 4 , 2 , 0 , 32 , &fakeZeroBuffer);
1362- GLint err = glGetError ();
1363- if (err != 0 )
1364- {
1365- context->m_TextureFormatSupport &= ~(1 << TEXTURE_FORMAT_RGBA_ASTC_4X4);
1366- }
1367- glDeleteTextures (1 , &texture);
1368- }
1369-
13701376 // webgl GL_DEPTH_STENCIL_ATTACHMENT for stenciling and GL_DEPTH_COMPONENT16 for depth only by specifications, even though it reports 24-bit depth and no packed depth stencil extensions.
13711377 context->m_PackedDepthStencilSupport = 1 ;
13721378 context->m_DepthBufferBits = 16 ;
0 commit comments