From a687873d32beb8a47ace86cfc926e5b6b692019f Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Sun, 2 Aug 2026 04:18:20 -0400 Subject: [PATCH] [Fix] (DirectGLES): probe format capabilities on the target ES stores them on 1D, 1D-array and rectangle textures are emulated on ES 2D and 2D-array targets, but the capability probe kept asking the driver about the desktop-only target itself. glTexImage2D(GL_TEXTURE_1D, ...) is not something an ES driver has ever accepted, so those rows of the cache stayed empty - and an empty row reads as "nothing is known", not as "the format needs help", so no fallback format was ever selected for them. GL_DEPTH_COMPONENT32 on a 1D texture therefore went to the driver unchanged instead of as GL_DEPTH_COMPONENT24, and the texture ended up with no storage (KHR-GL33.texture_swizzle format_idx_65 on both 1D targets read the wrong value for every pixel). Probe the ES target the texture will actually live on, while still recording the capabilities against the target the frontend asked for. --- .../DirectGLES/BackendObject_DirectGLES.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/MobileGL/MG_Backend/DirectGLES/BackendObject_DirectGLES.cpp b/MobileGL/MG_Backend/DirectGLES/BackendObject_DirectGLES.cpp index 11344c46..490b5ebe 100644 --- a/MobileGL/MG_Backend/DirectGLES/BackendObject_DirectGLES.cpp +++ b/MobileGL/MG_Backend/DirectGLES/BackendObject_DirectGLES.cpp @@ -588,11 +588,18 @@ namespace MobileGL::MG_Backend::DirectGLES { } } + // 1D, 1D-array and rectangle textures live on an ES target (see + // TextureImpl::MapToBackendTextureTarget), so they have to be probed there too - + // probing the desktop-only target itself always failed, which left those slots + // of the cache empty and stopped any fallback format from being selected for + // them (a GL_DEPTH_COMPONENT32 1D texture then got no storage at all). + const TextureTarget probeTarget = TextureImpl::MapToBackendTextureTarget(target); + Bool shouldProbeFallback = hasForcedFallback; if (!hasForcedFallback) { Bool nativeRenderable = false; const Bool nativeCreated = - ProbeTexture(gl, target, nativeInfo.InternalFormat, nativeInfo.ImageFormat, + ProbeTexture(gl, probeTarget, nativeInfo.InternalFormat, nativeInfo.ImageFormat, nativeInfo.ImageType, logicalFormat, &nativeRenderable); if (nativeCreated) { AddFullFormatCaps(cache, targetIndex, formatIndex, @@ -607,7 +614,7 @@ namespace MobileGL::MG_Backend::DirectGLES { if (shouldProbeFallback && fallbackInfo.InternalFormat != GL_UNKNOWN_MGL) { Bool fallbackRenderable = false; const Bool fallbackCreated = - ProbeTexture(gl, target, fallbackInfo.InternalFormat, fallbackInfo.ImageFormat, + ProbeTexture(gl, probeTarget, fallbackInfo.InternalFormat, fallbackInfo.ImageFormat, fallbackInfo.ImageType, logicalFormat, &fallbackRenderable); if (fallbackCreated) { if (AddCaveatFormatCaps(cache, targetIndex, formatIndex,