Repository navigation
fix: decode ASTC on the CPU when the GPU lacks support - #16
Merged
Merged
Conversation
Desktop NVIDIA and AMD drivers don't expose GL_KHR_texture_compression_astc_ldr, so creating storage with an ASTC internal format fails with GL_INVALID_ENUM. The texture ends up with no storage and every material using it renders black, which broke mobile games such as Super String (UE4.25, Android ASTC paks). ASTC levels are now decoded to RGBA8 before the upload when the driver has no ASTC support. Drivers with support still receive the blocks as-is. ASTC 8x5, 8x6 and 10x8 have no GL format mapping here, so they are always decoded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
These formats had no GL mapping, so they went through the CPU decoder. For BC6H signed, that path also wrote absolute values into 8 bits, which dropped the sign and the HDR range. The GL formats for all of them are core and decode the same data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
Mobile games with ASTC textures render black in the 3D viewer on desktop NVIDIA and AMD GPUs. This was reported on Discord for Super String (UE4.25,
pakchunk*-Android_ASTC.pak): characters and maps showed as black silhouettes, and the material inspector previews were noise. The game files date from 2022 and the old viewer showed them fine, so this is a regression from the new viewer.Cause
GetCompressedFormatmaps ASTC to GL'sCompressedRgbaAstc*formats and uploads the blocks directly. Desktop NVIDIA and AMD drivers don't exposeGL_KHR_texture_compression_astc_ldr. On an RTX 3060 Ti (driver 621.01),InternalformatSupportedreports 0 for ASTC 6x6, andTextureStorage2Dfails withGL_INVALID_ENUM. The texture is left without storage, so every sample is black.Change
ExtensionSupport/DeviceInfo: record whether the driver hasGL_KHR_texture_compression_astc_ldrasDeviceInfo.HasAstc. This is read on the GL thread, becauseTexture2D.Preparecan run on a worker thread with no context.TextureExtensions.IsDecodedOnCpu/DecodeOnCpu: when ASTC isn't supported,Texture2D.Preparedecodes every level it read to RGBA8 with CUE4Parse'sASTCDecoderand uploads it uncompressed. Drivers with ASTC support (Intel, mobile-class GPUs) still get the compressed blocks.GetCompressedFormatand used to throw. They now always take the CPU path.Normal maps need no blue-channel restore, because
SampleLayerNormalalready rebuilds Z from RG.Validation
HasAstc=False) with Super String's paks. It passed four textures from the report (ASTC 6x6 and 8x8, 64² to 1024²) throughTexture2D.Prepare/Generate, then read mip 0 back withGetTextureImage. There were no GL errors, the mip chain was complete, and the readback matched CUE4Parse's CPU decode byte for byte.master(f7c4cf08).SS/Content/Character/Pc/AikawaArise/001/AikawaArise_001_body_01_A_AskorSS/Content/BattleMap/BattleMap_Airport/SS_Airport_bg.umapwith theGAME_UE4_25preset on an NVIDIA or AMD GPU.Tradeoff
ASTCDecoderis the older managed decoder and allocates for each block, so ASTC-heavy maps load more slowly on these GPUs than BC textures do. The AssetRipper decoder that CUE4Parse already references would be faster if load times become a problem.🤖 Generated by Opus 5.5 with Claude Code in T3 Code