[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.)
This commit is contained in:
BZLZHH
2026-08-01 14:59:19 -04:00
parent 512c857f18
commit 6b2a2b5e00
@@ -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;