From 6b2a2b5e0043f3a59b0f33fec34fb433bb81df5d Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Sat, 1 Aug 2026 14:59:19 -0400 Subject: [PATCH] [Fix] (MG_Util): emulate GL_DEPTH_COMPONENT32 with the 24-bit sized format GL_DEPTH_COMPONENT32 has no ES equivalent. The previous commit routed it to GL_DEPTH_COMPONENT32F, which gives the attachment storage but changes the encoding: the transfer type has to become GL_FLOAT for ES to accept the store, and the upload path hands over the caller's fixed-point GL_UNSIGNED_INT bytes unchanged, so the texels came out as garbage. GL_DEPTH_COMPONENT24 is the nearest sized ES format that keeps the same fixed-point encoding, so GL_UNSIGNED_INT still describes the data and no conversion is needed. Fixes KHR-GL33.texture_swizzle's GL_DEPTH_COMPONENT32 cases on the 2D and 2D-array targets; framebuffer_blit's GL_DEPTH_COMPONENT32 config still passes, since the depth values it compares are exactly representable in 24 bits. (The 1D and 1D-array targets still fail, but for the separate desktop-1D-on-ES emulation reason that also holds back texture_size_promotion.) --- MobileGL/MG_Util/Texture/TextureFormatProcessor.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/MobileGL/MG_Util/Texture/TextureFormatProcessor.cpp b/MobileGL/MG_Util/Texture/TextureFormatProcessor.cpp index c8b3db71..f58c5a06 100644 --- a/MobileGL/MG_Util/Texture/TextureFormatProcessor.cpp +++ b/MobileGL/MG_Util/Texture/TextureFormatProcessor.cpp @@ -70,9 +70,11 @@ namespace MobileGL::MG_Util::TextureFormatProcessor { // glTexStorage/glRenderbufferStorage internal format on ES, which left // the attachment with no storage at all (KHR-GL3x.framebuffer_blit's // GL_DEPTH_COMPONENT32 config then read an incomplete framebuffer). - // GL_DEPTH_COMPONENT32F is the sized ES format that keeps the requested - // 32-bit depth footprint. - *outInternalFormat = GL_DEPTH_COMPONENT32F; + // GL_DEPTH_COMPONENT24 is the nearest sized ES format that keeps the + // same fixed-point encoding, so the GL_UNSIGNED_INT transfer type below + // still describes the data; GL_DEPTH_COMPONENT32F would need a float + // conversion the upload path does not apply. + *outInternalFormat = GL_DEPTH_COMPONENT24; break; } *outInternalFormat = internalFormat; @@ -560,7 +562,7 @@ namespace MobileGL::MG_Util::TextureFormatProcessor { case GL_DEPTH_COMPONENT32: // Follows the internal-format normalization above: ES only accepts // GL_FLOAT data for a GL_DEPTH_COMPONENT32F store. - *outType = (options & PixelFormatNormalizeOptionBit::NoDepthComponent32) ? GL_FLOAT : GL_UNSIGNED_INT; + *outType = GL_UNSIGNED_INT; break; case GL_DEPTH_COMPONENT32F: *outType = GL_FLOAT;