From bb70aac7242a0eff9bce86a8703f96b98805837c Mon Sep 17 00:00:00 2001 From: Forrest Keller Date: Fri, 9 Jan 2026 22:57:25 -0600 Subject: [PATCH] Fixed ASTC GPU shader --- src/video_core/host_shaders/astc_decoder.comp | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/video_core/host_shaders/astc_decoder.comp b/src/video_core/host_shaders/astc_decoder.comp index ef3f407c33..e850d63c03 100644 --- a/src/video_core/host_shaders/astc_decoder.comp +++ b/src/video_core/host_shaders/astc_decoder.comp @@ -731,18 +731,46 @@ uint UnquantizeTexelWeight(EncodingData val) { const uint bitlen = NumBits(val); const uint bitval = BitValue(val); + // I probably added this wrong, brain empty atm if (encoding == JUST_BITS) { uint z = bitval; + uint x = bitlen; switch (bitlen) { - case 1: return z * 64; - case 2: return uint(floor(float(z) * 21.5f)); - case 3: return uint(floor(float(z) * 9.25f)); - case 4: return uint(floor(float(z) * 4.125f)); - case 5: return uint(floor(float(z) * 2.0625f)); - default: return FastReplicateTo6(z, bitlen); + case 1: + return z * 64; + case 2: + case 3: + case 4: + case 5: + return uint(floor(0.5f + float(z) * 64.0f / float((1 << x) - 1))); + default: + return FastReplicateTo6(z, bitlen); } } + // Brain screaming at me that division is expensive, probably ultra wrong so have this here incase + /*if (encoding == JUST_BITS) { + uint z = bitval; + switch (bitlen) { + case 1: return z * 64; + + case 2: // (z * 64 + 1) / 3 + return ((z * 64 + 1) * 43691) >> 17; + + case 3: // (z * 64 + 3) / 7 + return ((z * 64 + 3) * 37449) >> 18; + + case 4: // (z * 64 + 7) / 15 + return ((z * 64 + 7) * 34953) >> 19; + + case 5: // (z * 64 + 15) / 31 + return ((z * 64 + 15) * 33826) >> 20; + + default: + return FastReplicateTo6(z, bitlen); + } + }*/ + const uint A = ReplicateBitTo7((bitval & 1)); uint B = 0, C = 0, D = 0; uint result = 0;