Repository navigation
mesa-ios: expose S3TC/RGTC/BPTC through Mesa's CPU fallback in OSMesa (fixes Mewgenics black textures, #566) - #574
Merged
125hz merged 1 commit intoNov 5, 2026
Conversation
…willfaust#566) Metal on A-series iPhones and iPads has no BC texture sampling, so MoltenVK and KosmicKrisp report no BC formats to Zink. Mesa still exposes GL_EXT_texture_compression_s3tc, _s3tc_srgb, ARB_texture_compression_rgtc, EXT_texture_compression_latc and ARB_texture_compression_bptc, and decodes those uploads to RGBA8 on the CPU, but only with allow_compressed_fallback. The DRI frontends read it from driconf, where it defaults to true. OSMesa memsets its context attribs and never reads driconf, so it stayed false. Games that upload DXT data without checking (Mewgenics) then got GL_INVALID_ENUM and drew those textures as opaque black. Patch 0009 turns the option on in OSMesa (MADEIRA_GL_COMPRESSED_FALLBACK=0 turns it off). tests/x64/gls3tc-x64.c checks a DXT1 and a DXT5 upload. Confirmed on an iPhone 12 Pro Max (A14) by forcing the same extensions on with MESA_EXTENSION_OVERRIDE: Mewgenics' textures draw correctly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: ABTOPEMOHT <163136224+ABTOPEMOHT@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #566 (Mewgenics: about half of the textures draw as black rectangles under Zink).
Cause
Metal on A-series iPhones and iPads has no BC texture sampling (
supportsBCTextureCompression = NO, asmadeira-d3d12/src/pe/mad_bcn.cppalready notes for the A16). So MoltenVK and KosmicKrisp report no BC formats, and Zink'sis_format_supported(PIPE_FORMAT_DXT5_RGBA)is false.Mesa can cover for this: with
allow_compressed_fallbackit still exposesGL_EXT_texture_compression_s3tc,_s3tc_srgb,ARB_texture_compression_rgtc,EXT_texture_compression_latcandARB_texture_compression_bptc, and decodes those uploads to RGBA8 on the CPU (st_compressed_format_fallback,st_UnmapTextureImage). The DRI frontends read that option from driconf, where it defaults to true (DRI_CONF_ALLOW_COMPRESSED_FALLBACK(true)indriinfo_gallium.h). OSMesa never reads driconf:OSMesaCreateContextAttribsmemsetsattribs, so the option stayed false and the extensions were missing.A game that uploads DXT data without checking for the extension (every desktop GPU has it) then gets
GL_INVALID_ENUMfromglCompressedTexImage2D. The texture stays incomplete and samples as opaque black. That is why switchinggl-vulkanto KosmicKrisp did not help: both drivers run on the same Metal GPU without BC.Confirmation
On the device from #566 (iPhone 12 Pro Max, A14, Madeira 0.2.0, Zink on MoltenVK), this line in Mewgenics' own config makes every texture draw correctly:
It turns on the same extensions that this patch exposes, and the same CPU decode then runs.
Change
build/mesa-ios/patches/0009-osmesa-allow-compressed-fallback.patch: OSMesa setsattribs.options.allow_compressed_fallbackto true, the same default the DRI frontends use.MADEIRA_GL_COMPRESSED_FALLBACK=0turns it off. A GPU that has BC keeps the native formats, because the fallback applies only whenst->has_s3tc(orhas_rgtc,has_bptc, ...) is false. This covers the MoltenVK and KosmicKrisp backends alike, because both go through OSMesa + Zink.build/mesa-ios/patches/README.md: entry for 0009.tests/x64/gls3tc-x64.c: uploads a solid-green 4x4 block as DXT1 and as DXT5, draws it, and reads a pixel back. Expected on an A14 to A16 device: fails before the patch (extension missing, pixel blue) and passes after it.Testing
patch -p1 --forward). It touches onlysrc/gallium/frontends/osmesa/osmesa.c, which no other patch in the set changes.gls3tc-x64.cbuilds with clang (x86_64) and passes on a desktop GPU (NVIDIA, native S3TC), so the test logic itself is right.build/mesa-ios/build.shneeds macOS and Xcode) or run the patched build on the device. The fix is confirmed only through theMESA_EXTENSION_OVERRIDEworkaround above.🤖 Generated with Claude Code