fix(vk): the GPU ASTC decoder decodes exactly as astcenc does: 8-bit conversion, sRGB mode and four decoding faults #2314

Merged
HumanBean merged 8 commits from TrashPanda/Longshot:fix/astc-gpu-exact into main 2026-11-23 16:12:49 +00:00
Contributor

Summary

Stacked on #2307 (the texdecode CPU decoder), because its test uses that decoder, which equals ARM's astcenc 6.0.0 on 28 million fuzzed blocks, as the reference. It builds on #2194's decoder (gpu/vk/host_shaders/astc_decoder.comp) and keeps its structure and speed; it does not rewrite it.

The GPU ASTC decoder is fast but not exact. Read back in the game against texdecode on 1,119,311,811 texels in 22 formats, linear formats were 82.24% equal, 17.57% one step off and 0.193% more than one step off (largest 113); sRGB formats 81.13% / 18.82% / 0.051% against the specification's sRGB mode. Three kinds of cause, found with a game-free test over astcenc's block vectors:

  1. The 8-bit conversion. astcenc's 8-bit decode takes the top byte of the 16-bit result; the shader divided by 65535.0 and stored a float to an R8G8B8A8_UNORM image, which rounds. That was all the one-step differences in linear mode (2,031 of 2,114 legal vector blocks). The shader now stores the bytes through an R8G8B8A8_UINT view (rgba8ui), which keeps the bits as they are on every driver; a UNORM store of n/255 is exact only where the driver rounds to nearest.
  2. No sRGB decode mode. For sRGB formats (NVN 0x87..0x94) the specification widens endpoints as (v << 8) | 0x80, not v * 257. A push constant srgb, set from the texture's NVN format, selects it.
  3. Real decoding faults (the 0.193%), four of them, each found from the per-class table and each its own commit:
    • 4- and 5-bit weights (16 and 32 levels) were unquantized with floor(0.5 + v * 64 / (2^n - 1)); the specification's table is the bits replicated to six, plus 1 above 32. Value 7 of 4 bits gave 30 where the table has 29.
    • The last partial trit or quint group of the colour values read the block's spare bits (bits left over after the sequence, which an encoder may set to anything) instead of zero for its empty slots, so the last colour values came out wrong (one block: 255 and 0 became 209 and 46). Four values in trits of five is the single-partition luminance+alpha (mode 4) case that dominated the analysis of the in-game faults.
    • Illegal blocks decoded as legal: more than 18 colour values, fewer than 6 colour levels, void extents whose bounds are not ordered (311 of 1,680 illegal vector blocks were wrong, steps up to 255).
    • A partition with an HDR endpoint mode was decoded as clamped HDR colour; texdecode and astcenc's LDR decode make it opaque magenta. Done the same; this removes about 400 lines of HDR decode the LDR path never ran.

Illegal blocks and HDR void extents stay transparent black (the renderer's colour, as texdecode's renderer call writes them); the shader now agrees with that call on every vector block.

How to see it on main: python -I -B tests/test_astc_decoder_gpu.py --headers <Vulkan headers> --device llvmpipe (lavapipe, validation on) fails with 3,888 of 9,388 vector decodes differing and a table of the classes that differ. Files to read first: gpu/vk/host_shaders/astc_decoder.comp (small hunks: UnquantizeTexelWeight, DecodeColorValues, ComputeEndpoints, the store at the end of DecompressBlock), tests/astc_decoder_gpu.cpp, and the view changes in gpu/vk/vk_texture.cpp (astc_target_view, astc_level_view, bc_scratch_make).

What a player can see: textures decoded as the specification says. About 18% of texels change by one step (of 255), 0.19% by more, and sRGB textures by the sRGB mode's difference; most of this is invisible, the larger differences are the rare wrong blocks.

Renderer side of the 8-bit change: the decoded textures are MUTABLE_FORMAT already and their level views are R8G8B8A8_UINT; the BC scratch images (big and small) are made MUTABLE_FORMAT and get UINT twins of their views, which the decoder writes, while the BC encoders still read the UNORM views. R8G8B8A8_UINT storage is mandatory in Vulkan, so no feature or format check is needed, and the shader no longer needs StorageImageWriteWithoutFormat.

Testing

Tested: Linux, RTX 4070 Ti (NVIDIA 595.99.02), the AMD integrated GPU of a Ryzen 7 9800X3D (RADV), and lavapipe (LLVM 21.1.8) with Khronos validation, glslangValidator 16.6.0 for the headers (scripts/shaders.py host reproduces them).

  • tests/test_astc_decoder_gpu.py (replaces #2194's comparison with suyu and its one-step tolerance; keeps its hand-built cases): on lavapipe 100% of the 9,388 astcenc vector decodes (4,694 blocks, linear and sRGB), 58 whole levels (layers, clipped edge blocks, GOB tiles of 1, 2 and 4 GOBs, a short binding) and 56 hand-built levels equal texdecode, no validation error. On main: 3,888 of 9,388 differ. Undoing any one of the eight shader changes makes it fail again (weights 551, partial group 14, more than 18 values 18, fewer than 6 levels 102, void bounds 532, HDR magenta 492, top 8 bits 4,223, sRGB mode 2,115 vector decodes differ). Both g++ and clang++ build it.
  • In the game with a read-back harness on a scratch branch (never committed here: RX_VK_TEXDECODE_CHECK=3 reads every decoded level back and compares it with texdecode, in the renderer's error colour and the format's sRGB mode): RTX, route house, Kokiri Forest twice, Hyrule Field twice: 22 formats, 8,159 level-layers, 1,392,369,615 texels, all equal, largest difference 0 (main: 82.2%/81.1% equal, largest 113); the BC re-encoder's input equal too. Integrated GPU (RX_VK_DEVICE=1, 1280x720, RX_VK_AUTO_TUNE=0): house to Kokiri 617,680,800 texels in 20 formats and house to Hyrule 704,151,971 texels in 22 formats, all equal. No device loss or Vulkan error.
  • gamerun kokiri-interior, kokiri-forest, hyrule-field, branch against base: all ok, clean stop, 0 warning lines; logdiff --levels problem: no new kinds; shots of Kokiri Forest and Hyrule Field read: no corrupted or magenta textures.
  • suite.py compare against #2307's head: 934 passed, 3 failed, 26 skipped on both sides, nothing fails only here, no checks added or removed. Three checks that read vk_texture.cpp (test_astc_cpu_call, test_astc_upload_chunking, test_bc_small_scratch) needed their cut or stand-ins updated for the UINT views and the srgb field; they were updated, not weakened. The translator stamp (nx2/translator_files.stamp(gpu/vk)) is unchanged.
  • Compiled with the real flags: gpu/vk/vk_texture.cpp (objcmp build).

Still to test:

  • Windows (llvm-mingw build, NVIDIA and AMD drivers): run tests/run_vulkan_fixtures.py and a house-to-Kokiri read-back, expecting every texel equal (@Beanstalk run the ASTC decoder test and a texture check on Windows with an NVIDIA and an AMD card).
  • Other vendors and drivers (Intel, NVIDIA on Windows, AMD Windows driver): the integer rgba8ui store and the UINT views of the BC scratch, expecting no change in the picture (by hand or a Test Farm tag).

Measurements

Verdict: no measurable cost: the decoder is within 3% of #2194's at every footprint on the RTX (worst 1.019) and 5 to 8% faster on the integrated GPU; in the game one round a side shows nothing outside the run-to-run spread. One round only, not a repeated measurement.

Setup: Linux, RTX 4070 Ti and the AMD integrated GPU (RADV), queue timing mode (alone on the GPU); decoder microbenchmark: one 2048x2048 level of astcenc-legal vector blocks per footprint, block-linear tile_h 4, GPU timestamps around one dispatch, median of 20 dispatches, three runs, the median of the runs; the game: drive.py route house, Kokiri Forest 45 s, Hyrule Field 45 s on the RTX; house to Kokiri Forest and house to Hyrule Field separately on the integrated GPU (RX_VK_DEVICE=1, 1280x720, RX_VK_AUTO_TUNE=0), the whole run's frame log.

decoder, ms a 2048x2048 level (after/before) Before: main @ 37af5747f (#2194 as merged, in #2307) After: this PR @ d24736a6d
4x4, RTX 4070 Ti 0.425 0.403 (0.948)
5x4, RTX 4070 Ti 0.299 0.278 (0.930)
5x5, RTX 4070 Ti 0.257 0.247 (0.961)
6x5, RTX 4070 Ti 0.274 0.268 (0.978)
6x6, RTX 4070 Ti 0.249 0.251 (1.008)
8x5, RTX 4070 Ti 0.267 0.264 (0.989)
8x6, RTX 4070 Ti 0.244 0.245 (1.004)
8x8, RTX 4070 Ti 0.251 0.253 (1.008)
10x5, RTX 4070 Ti 0.241 0.240 (0.996)
10x6, RTX 4070 Ti 0.248 0.245 (0.988)
10x8, RTX 4070 Ti 0.255 0.254 (0.996)
10x10, RTX 4070 Ti 0.211 0.211 (1.000)
12x10, RTX 4070 Ti 0.215 0.219 (1.019)
12x12, RTX 4070 Ti 0.219 0.221 (1.009)
4x4, RADV integrated GPU 13.736 12.863 (0.936)
5x4, RADV integrated GPU 9.853 9.074 (0.921)
5x5, RADV integrated GPU 9.407 8.722 (0.927)
6x5, RADV integrated GPU 9.803 9.201 (0.939)
6x6, RADV integrated GPU 9.052 8.489 (0.938)
8x5, RADV integrated GPU 8.639 8.116 (0.939)
8x6, RADV integrated GPU 8.223 7.771 (0.945)
8x8, RADV integrated GPU 7.548 7.091 (0.939)
10x5, RADV integrated GPU 7.800 7.297 (0.936)
10x6, RADV integrated GPU 7.008 6.536 (0.933)
10x8, RADV integrated GPU 6.497 6.051 (0.931)
10x10, RADV integrated GPU 6.304 5.853 (0.928)
12x10, RADV integrated GPU 6.373 5.950 (0.934)
12x12, RADV integrated GPU 6.135 5.707 (0.930)

(One of the three RTX runs read 1.195 at 12x10; the median is shown.)

In the game, one round Before: main @ 37af5747f (#2307) After: this PR @ d24736a6d
RTX, whole run: average fps 64.6 64.9
RTX: p99 frame time (ms) 19.4 18.6
RTX: worst frame (ms), frames over 100 ms 568, 7 414, 6
iGPU house to Kokiri: fps, p99 (ms) 34.1, 56.1 34.5, 54.1
iGPU house to Kokiri: worst frame (ms), over 100 ms 1136, 13 1083, 15
iGPU house to Hyrule: fps, p99 (ms) 35.7, 51.0 35.6, 52.7
iGPU house to Hyrule: worst frame (ms), over 100 ms 1094, 11 1188, 13

Risks

What could break: the decoded textures' and the BC scratch images' storage views are now R8G8B8A8_UINT (mandatory storage format, but untested on Windows and on drivers other than NVIDIA and RADV on Linux); a driver that mishandles an integer view of a MUTABLE_FORMAT image would show wrong or black textures. A revert of the commits is enough; there is no switch. A partition with an HDR endpoint mode is magenta where it was a clamped colour, which affects no block the game was seen to use (0 such blocks in the read-backs). Illegal blocks are now error blocks (transparent black) in more cases, as astcenc has them. After updating, textures change by up to one step (most of them) or, in the rare wrong blocks, by more; nothing in saves, options or caches. No speed or memory cost beyond the measurements above (two more image views per BC scratch).

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit. (One topic; the title is one. Stacked on #2307, not on main: it waits for #2307 to merge, then rebases.)
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named). (suite.py compare: 3 checks fail on both sides, unchanged; nothing fails only here.)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def. (n/a: no switch.)
  • A check under tests/ that reads changed source is updated, not weakened.
  • MKWVK_API_VERSION bumped (MkwVkHost or MkwVkRenderer in gpu/vk/vk_api.h changed). (n/a: vk_api.h is not changed.)
  • The SPIR-V headers regenerated (a shader changed).
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Built on Linux only; Windows is under Still to test.)
  • Screenshots of the same spot on main and here, for a change that shows on screen. (Shots of the same spots read, not published; the change is at most a step per texel.)
  • Docs updated. (n/a: no doc describes the decoder's behaviour.)
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

Written with AI agents (Claude) under the owner's direction; the commits carry Co-Authored-By: Claude Sonnet 5.5.

## Summary Stacked on #2307 (the texdecode CPU decoder), because its test uses that decoder, which equals ARM's astcenc 6.0.0 on 28 million fuzzed blocks, as the reference. It builds on #2194's decoder (`gpu/vk/host_shaders/astc_decoder.comp`) and keeps its structure and speed; it does not rewrite it. The GPU ASTC decoder is fast but not exact. Read back in the game against texdecode on 1,119,311,811 texels in 22 formats, linear formats were 82.24% equal, 17.57% one step off and 0.193% more than one step off (largest 113); sRGB formats 81.13% / 18.82% / 0.051% against the specification's sRGB mode. Three kinds of cause, found with a game-free test over astcenc's block vectors: 1. **The 8-bit conversion.** astcenc's 8-bit decode takes the top byte of the 16-bit result; the shader divided by 65535.0 and stored a float to an `R8G8B8A8_UNORM` image, which rounds. That was all the one-step differences in linear mode (2,031 of 2,114 legal vector blocks). The shader now stores the bytes through an `R8G8B8A8_UINT` view (`rgba8ui`), which keeps the bits as they are on every driver; a UNORM store of n/255 is exact only where the driver rounds to nearest. 2. **No sRGB decode mode.** For sRGB formats (NVN 0x87..0x94) the specification widens endpoints as `(v << 8) | 0x80`, not `v * 257`. A push constant `srgb`, set from the texture's NVN format, selects it. 3. **Real decoding faults** (the 0.193%), four of them, each found from the per-class table and each its own commit: - 4- and 5-bit weights (16 and 32 levels) were unquantized with `floor(0.5 + v * 64 / (2^n - 1))`; the specification's table is the bits replicated to six, plus 1 above 32. Value 7 of 4 bits gave 30 where the table has 29. - The last partial trit or quint group of the colour values read the block's spare bits (bits left over after the sequence, which an encoder may set to anything) instead of zero for its empty slots, so the last colour values came out wrong (one block: 255 and 0 became 209 and 46). Four values in trits of five is the single-partition luminance+alpha (mode 4) case that dominated the analysis of the in-game faults. - Illegal blocks decoded as legal: more than 18 colour values, fewer than 6 colour levels, void extents whose bounds are not ordered (311 of 1,680 illegal vector blocks were wrong, steps up to 255). - A partition with an HDR endpoint mode was decoded as clamped HDR colour; texdecode and astcenc's LDR decode make it opaque magenta. Done the same; this removes about 400 lines of HDR decode the LDR path never ran. Illegal blocks and HDR void extents stay transparent black (the renderer's colour, as texdecode's renderer call writes them); the shader now agrees with that call on every vector block. How to see it on main: `python -I -B tests/test_astc_decoder_gpu.py --headers <Vulkan headers> --device llvmpipe` (lavapipe, validation on) fails with 3,888 of 9,388 vector decodes differing and a table of the classes that differ. Files to read first: `gpu/vk/host_shaders/astc_decoder.comp` (small hunks: `UnquantizeTexelWeight`, `DecodeColorValues`, `ComputeEndpoints`, the store at the end of `DecompressBlock`), `tests/astc_decoder_gpu.cpp`, and the view changes in `gpu/vk/vk_texture.cpp` (`astc_target_view`, `astc_level_view`, `bc_scratch_make`). What a player can see: textures decoded as the specification says. About 18% of texels change by one step (of 255), 0.19% by more, and sRGB textures by the sRGB mode's difference; most of this is invisible, the larger differences are the rare wrong blocks. Renderer side of the 8-bit change: the decoded textures are `MUTABLE_FORMAT` already and their level views are `R8G8B8A8_UINT`; the BC scratch images (big and small) are made `MUTABLE_FORMAT` and get UINT twins of their views, which the decoder writes, while the BC encoders still read the UNORM views. `R8G8B8A8_UINT` storage is mandatory in Vulkan, so no feature or format check is needed, and the shader no longer needs `StorageImageWriteWithoutFormat`. ## Testing **Tested:** Linux, RTX 4070 Ti (NVIDIA 595.99.02), the AMD integrated GPU of a Ryzen 7 9800X3D (RADV), and lavapipe (LLVM 21.1.8) with Khronos validation, glslangValidator 16.6.0 for the headers (`scripts/shaders.py host` reproduces them). - `tests/test_astc_decoder_gpu.py` (replaces #2194's comparison with suyu and its one-step tolerance; keeps its hand-built cases): on lavapipe 100% of the 9,388 astcenc vector decodes (4,694 blocks, linear and sRGB), 58 whole levels (layers, clipped edge blocks, GOB tiles of 1, 2 and 4 GOBs, a short binding) and 56 hand-built levels equal texdecode, no validation error. On main: 3,888 of 9,388 differ. Undoing any one of the eight shader changes makes it fail again (weights 551, partial group 14, more than 18 values 18, fewer than 6 levels 102, void bounds 532, HDR magenta 492, top 8 bits 4,223, sRGB mode 2,115 vector decodes differ). Both `g++` and `clang++` build it. - In the game with a read-back harness on a scratch branch (never committed here: `RX_VK_TEXDECODE_CHECK=3` reads every decoded level back and compares it with texdecode, in the renderer's error colour and the format's sRGB mode): RTX, route house, Kokiri Forest twice, Hyrule Field twice: 22 formats, 8,159 level-layers, 1,392,369,615 texels, all equal, largest difference 0 (main: 82.2%/81.1% equal, largest 113); the BC re-encoder's input equal too. Integrated GPU (`RX_VK_DEVICE=1`, 1280x720, `RX_VK_AUTO_TUNE=0`): house to Kokiri 617,680,800 texels in 20 formats and house to Hyrule 704,151,971 texels in 22 formats, all equal. No device loss or Vulkan error. - `gamerun` kokiri-interior, kokiri-forest, hyrule-field, branch against base: all ok, clean stop, 0 warning lines; `logdiff --levels problem`: no new kinds; shots of Kokiri Forest and Hyrule Field read: no corrupted or magenta textures. - `suite.py compare` against #2307's head: 934 passed, 3 failed, 26 skipped on both sides, nothing fails only here, no checks added or removed. Three checks that read `vk_texture.cpp` (`test_astc_cpu_call`, `test_astc_upload_chunking`, `test_bc_small_scratch`) needed their cut or stand-ins updated for the UINT views and the srgb field; they were updated, not weakened. The translator stamp (`nx2/translator_files.stamp(gpu/vk)`) is unchanged. - Compiled with the real flags: `gpu/vk/vk_texture.cpp` (objcmp build). **Still to test:** - Windows (llvm-mingw build, NVIDIA and AMD drivers): run `tests/run_vulkan_fixtures.py` and a house-to-Kokiri read-back, expecting every texel equal (`@Beanstalk run the ASTC decoder test and a texture check on Windows with an NVIDIA and an AMD card`). - Other vendors and drivers (Intel, NVIDIA on Windows, AMD Windows driver): the integer `rgba8ui` store and the UINT views of the BC scratch, expecting no change in the picture (by hand or a Test Farm tag). ## Measurements **Verdict:** no measurable cost: the decoder is within 3% of #2194's at every footprint on the RTX (worst 1.019) and 5 to 8% faster on the integrated GPU; in the game one round a side shows nothing outside the run-to-run spread. One round only, not a repeated measurement. Setup: Linux, RTX 4070 Ti and the AMD integrated GPU (RADV), queue timing mode (alone on the GPU); decoder microbenchmark: one 2048x2048 level of astcenc-legal vector blocks per footprint, block-linear tile_h 4, GPU timestamps around one dispatch, median of 20 dispatches, three runs, the median of the runs; the game: `drive.py` route house, Kokiri Forest 45 s, Hyrule Field 45 s on the RTX; house to Kokiri Forest and house to Hyrule Field separately on the integrated GPU (`RX_VK_DEVICE=1`, 1280x720, `RX_VK_AUTO_TUNE=0`), the whole run's frame log. | decoder, ms a 2048x2048 level (after/before) | Before: main @ 37af5747f (#2194 as merged, in #2307) | After: this PR @ d24736a6d | |---|---|---| | 4x4, RTX 4070 Ti | 0.425 | 0.403 (0.948) | | 5x4, RTX 4070 Ti | 0.299 | 0.278 (0.930) | | 5x5, RTX 4070 Ti | 0.257 | 0.247 (0.961) | | 6x5, RTX 4070 Ti | 0.274 | 0.268 (0.978) | | 6x6, RTX 4070 Ti | 0.249 | 0.251 (1.008) | | 8x5, RTX 4070 Ti | 0.267 | 0.264 (0.989) | | 8x6, RTX 4070 Ti | 0.244 | 0.245 (1.004) | | 8x8, RTX 4070 Ti | 0.251 | 0.253 (1.008) | | 10x5, RTX 4070 Ti | 0.241 | 0.240 (0.996) | | 10x6, RTX 4070 Ti | 0.248 | 0.245 (0.988) | | 10x8, RTX 4070 Ti | 0.255 | 0.254 (0.996) | | 10x10, RTX 4070 Ti | 0.211 | 0.211 (1.000) | | 12x10, RTX 4070 Ti | 0.215 | 0.219 (1.019) | | 12x12, RTX 4070 Ti | 0.219 | 0.221 (1.009) | | 4x4, RADV integrated GPU | 13.736 | 12.863 (0.936) | | 5x4, RADV integrated GPU | 9.853 | 9.074 (0.921) | | 5x5, RADV integrated GPU | 9.407 | 8.722 (0.927) | | 6x5, RADV integrated GPU | 9.803 | 9.201 (0.939) | | 6x6, RADV integrated GPU | 9.052 | 8.489 (0.938) | | 8x5, RADV integrated GPU | 8.639 | 8.116 (0.939) | | 8x6, RADV integrated GPU | 8.223 | 7.771 (0.945) | | 8x8, RADV integrated GPU | 7.548 | 7.091 (0.939) | | 10x5, RADV integrated GPU | 7.800 | 7.297 (0.936) | | 10x6, RADV integrated GPU | 7.008 | 6.536 (0.933) | | 10x8, RADV integrated GPU | 6.497 | 6.051 (0.931) | | 10x10, RADV integrated GPU | 6.304 | 5.853 (0.928) | | 12x10, RADV integrated GPU | 6.373 | 5.950 (0.934) | | 12x12, RADV integrated GPU | 6.135 | 5.707 (0.930) | (One of the three RTX runs read 1.195 at 12x10; the median is shown.) | In the game, one round | Before: main @ 37af5747f (#2307) | After: this PR @ d24736a6d | |---|---|---| | RTX, whole run: average fps | 64.6 | 64.9 | | RTX: p99 frame time (ms) | 19.4 | 18.6 | | RTX: worst frame (ms), frames over 100 ms | 568, 7 | 414, 6 | | iGPU house to Kokiri: fps, p99 (ms) | 34.1, 56.1 | 34.5, 54.1 | | iGPU house to Kokiri: worst frame (ms), over 100 ms | 1136, 13 | 1083, 15 | | iGPU house to Hyrule: fps, p99 (ms) | 35.7, 51.0 | 35.6, 52.7 | | iGPU house to Hyrule: worst frame (ms), over 100 ms | 1094, 11 | 1188, 13 | ## Risks What could break: the decoded textures' and the BC scratch images' storage views are now `R8G8B8A8_UINT` (mandatory storage format, but untested on Windows and on drivers other than NVIDIA and RADV on Linux); a driver that mishandles an integer view of a `MUTABLE_FORMAT` image would show wrong or black textures. A revert of the commits is enough; there is no switch. A partition with an HDR endpoint mode is magenta where it was a clamped colour, which affects no block the game was seen to use (0 such blocks in the read-backs). Illegal blocks are now error blocks (transparent black) in more cases, as astcenc has them. After updating, textures change by up to one step (most of them) or, in the rare wrong blocks, by more; nothing in saves, options or caches. No speed or memory cost beyond the measurements above (two more image views per BC scratch). ## Checklist ### Ready for review - [ ] One topic, on current `main`; the title is a Conventional Commit. (One topic; the title is one. Stacked on #2307, not on `main`: it waits for #2307 to merge, then rebases.) - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). (`suite.py compare`: 3 checks fail on both sides, unchanged; nothing fails only here.) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. (n/a: no switch.) - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] `MKWVK_API_VERSION` bumped (`MkwVkHost` or `MkwVkRenderer` in `gpu/vk/vk_api.h` changed). (n/a: `vk_api.h` is not changed.) - [x] The SPIR-V headers regenerated (a shader changed). - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Built on Linux only; Windows is under Still to test.) - [ ] Screenshots of the same spot on `main` and here, for a change that shows on screen. (Shots of the same spots read, not published; the change is at most a step per texel.) - [x] Docs updated. (n/a: no doc describes the decoder's behaviour.) - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. Written with AI agents (Claude) under the owner's direction; the commits carry `Co-Authored-By: Claude Sonnet 5.5`.
gpu/vk/texdecode/ holds a block-linear (GOB) deswizzle and swizzle and an ASTC LDR decoder (4x4 to 12x12, linear and sRGB
modes, depth slices) whose decoding core is ported from ocarina-recomp's runtime/tex_astc.c and tex_deswizzle.c (MIT, by way of
LAS Recomp and MacNativeGames). PROVENANCE.md says what was taken, what was changed, and what is not settled (a possible
TotK Recomp link) and what is (ocarina-recomp's own additions are GPL-3.0-or-later, as its author told the project owner
on 2026-11-21). LICENSE-MIT carries the notices of every holder named.

The code around the ported core is written here: argument, span and 64-bit overflow checks that refuse instead of wrapping,
size functions and the count of error blocks. The error colour of an illegal block is a parameter (Rgba8 error_color) whose
default is the specification's opaque magenta, which the ported original already wrote; the renderer's call passes its own. The tests compare the
decoder with ARM's astcenc 6.0.0 on 4,694 blocks (3,976 random, 718 built by hand) in both modes (0 differences; the vectors are random numbers, never
game data; scripts/gen_texdecode_astc_vectors.py regenerates them with an astcenc of your own) and round-trip 4,325 swizzle
layouts against offsets worked out by hand, including the cases mutation testing found missing: 3D GOB order with tile height
different from tile depth, void extents with equal coordinates, reserved void-extent bits, the 6x10 and 10x6 grids, and weight
bits 97 to 100.

Nothing calls it yet and the build does not list it: the next commits do.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The ASTC decoder the renderer decodes CPU textures with today (suyu's, gpu/third_party/suyu/video_core/textures/astc.cpp)
decodes some legal multi-partition blocks far from ARM's astcenc: up to 117 of 255 in one channel, 8 of the 8 blocks of the
class here (the 3 controls are one step off, its rounding). Cause: the colour endpoints are an integer sequence in groups of 5
(trits) or 3 (quints) whose high code bits are missing when the last group is not full, and the specification reads the missing
bits as zero; suyu copies the spare bits after the sequence into the buffer it decodes, and its group decoders read them. It
needs nonzero spare bits and more than 8 colour values, so random blocks hit it (about 6% of the blocks with both go wrong)
and an encoder that zeroes the spare bits hides it. Two lines in suyu's file would fix it, and gpu/third_party is not edited.

The test holds 8 such blocks and 3 controls, each with astcenc 6.0.0's answer, and asserts every texel within one step of it and
exact. It calls the decoder texdecode's astc_decode, with the error colour the swap in the next commit passes, and passes with clang++
and g++; --decoder suyu (not in run_all.py) builds suyu's astc.cpp alone and shows the fault. With --decoder suyu it fails on 8 of the 11 blocks (largest difference 117), which is how the fault was shown.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
feat(vk): the renderer's CPU texture decode is texdecode, and suyu's two texture sources leave the build
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 10s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
37af5747ff
The four CPU call sites in vk_texture.cpp now call gpu/vk/texdecode directly: the block-linear unswizzle (unswizzle_upload,
after texture_tiles has declined a level), the ASTC decoder (sRGB formats, NVN 0x87 to 0x94, in the specification's sRGB mode,
which is what their R8G8B8A8_SRGB view samples; the others in linear mode), the one-thread reference of RX_VK_UNSWIZZLE_CHECK,
and the swizzle of a flushed texture. nx2/build.py's vk_sources() lists gpu/vk/texdecode/*.cpp and no longer suyu's
video_core/textures/decoders.cpp and astc.cpp, and the headers' dependency folders no longer include suyu's textures. Nothing
under gpu/third_party is edited or deleted; what is no longer compiled there is those two sources (and workers.h with its
RX_ASTC_THREADS, which only astc.cpp included). The ASTC decode runs on the calling thread, as suyu's DecompressSerial did,
and the unswizzle keeps its strip threads.

No switch: the CPU path is texdecode's, with no way back to suyu's. The GPU ASTC decoder stays the default route for 2D ASTC;
this decoder runs when it declines (3D ASTC, no push descriptors, layout or stride limits, out of staging
memory) and with RX_VK_ASTC_CPU=1, whose switch row now says so (a multisample image never reaches either decoder).

What changes in a texel: ASTC is truncated to 8 bits, as ARM's astcenc does, where suyu rounded (about a fifth of texels one
step apart, towards the specification); blocks suyu decoded wrongly (the previous commit's test) are right. Eden's GPU decoder
rounds, so the CPU and GPU routes now differ by one step on about 18% of texels, where before both rounded. An illegal block
stays transparent black, as suyu's decoder and the GPU shader write it: an all-zero block is an illegal one (texdecode's default,
magenta, gave ff00ffff for it), upload_all_zero skips ASTC, and storage the game has not written yet is decoded. The call passes
that colour to the library's error-colour parameter; the count of illegal blocks is still logged.

Refusals (an argument out of range or a span too short, which no caller can trigger): the unswizzle's and the ASTC decoder's
output is zeroed, never what the staging memory held, and one line says so (at most 5). A refused swizzle is not written back
(that part is skipped and the flush reports not ok; zero would overwrite the game's bytes). An ASTC texture with illegal
blocks logs its count once (the first 16 textures), never a texel value.

Tests that assumed suyu's decoder updated, none weakened: test_texture_tile_upload.py compares unswizzle_upload with texdecode's
deswizzle (which tests/test_texdecode_swizzle.py checks against offsets worked out by hand) and now also checks the refusal;
test_shader_stamp_cache.py's back-end file list names texdecode's files and asserts no gpu/third_party source is built;
test_third_party_objects.py's example moves with them; test_texdecode_build.py asserts the source list, and test_astc_error_blocks_log.py checks the two
log lines above (once per texture, 16 at most, no texel value; a refusal 5 times at most), and test_astc_cpu_call.py compiles
the renderer's astc_decode statement and astc_nvn_srgb as cut from vk_texture.cpp: an all-zero block gives 00000000 with its
count, the format picks the sRGB or linear mode, and the sRGB rule is vk_format()'s. The stale lines in gpu/PROVENANCE.md and
docs/dev/setup.md that named suyu's texture decoders as compiled are corrected.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
tests/astc_decoder_gpu.cpp compared the shader with suyu's CPU decoder and let it differ by one step, so it could not show that the
shader is not astcenc's decode (suyu's decoder is itself wrong on some blocks). It now runs the real shader, as the renderer
dispatches it, over the 4,694 blocks of tests/texdecode_astc_vectors.vec in each footprint in the linear and the sRGB mode, over
whole levels of those blocks (layers, clipped edge blocks, GOB tiles of 1, 2 and 4 GOBs, a short binding) and over the hand-built
blocks of the old test, and demands every texel equal to texdecode's (an illegal block transparent black, as the renderer decodes
it). On a failure it prints how many blocks of each class (footprint, partitions, weight planes, colour modes, weight grid against
the footprint, weight levels) are equal, one step off and further off, and describes the first failing blocks of each kind.

It fails on main: 3,888 of 9,388 vector decodes differ. The test is registered in run_vulkan_fixtures.py (lavapipe, validation on).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
A weight of 4 or 5 bits (16 or 32 levels) was computed as floor(0.5 + v * 64 / (2^n - 1)) in floating point, which rounds
differently from the specification's table (the bits replicated to six, then 1 added above 32) for 7 of the 16 values of a 4-bit
weight and many of the 32: 4-bit value 7 gave 30 where the table has 29, value 8 gave 34 where it has 35. The weight is off by
one in 64, which is up to four steps of an 8-bit channel. Blocks with 16 or 32 weight levels were the most often off by more than
one step. The table form is also fewer instructions than the division.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The colour values are an integer sequence of GetBitLength(n, range) bits, but the shader let the decoder read everything up to
the start of the extra colour-mode and weight bits. When the last trit or quint group holds fewer values than slots (4 values in
trits of 5, 18 in trits of 5, 4 in quints of 3...) the trit or quint bits of the empty slots were read from the bits the block has
left over after the sequence, which an encoder may set to anything. The group then decoded to other trits and the last values
came out wrong (one block: 255 and 0 became 209 and 46, a step of 209). The bits past the sequence's length are now cleared,
as the weights' are, and as texdecode and astcenc read them.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Three kinds of illegal block were decoded as if they were legal, giving whatever the endpoints came to (311 of 1,680 illegal
blocks of the astcenc vectors in each mode, steps of up to 255; an encoder never writes them, but data the game has not written
yet, or that is damaged, can be anything):
- more than 18 colour values (the shader allowed 32; the colour modes of 1 to 4 partitions add up to at most 18 in a legal block);
- too few bits for the colour values to reach 6 levels (the range search ended at index 0, a range with 1 level, and unquantized
  with no table);
- a void extent whose extent bounds are not ordered (low < high on both axes) unless all four are ones.
They are error blocks (transparent black, as the shader writes every error block).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The shader decoded HDR endpoint modes (2, 3, 7, 11, 14, 15) as HDR colour, clamped to 0..1: 246 of 664 such vector blocks were
further than one step from texdecode's answer (mostly black or grey where texdecode and astcenc write opaque magenta). The LDR
profile has no HDR endpoints, astcenc reports them as an error block and writes magenta for the partition (the other partitions of
the block decode as usual), and texdecode's renderer call keeps that colour whatever the error colour is. The shader now does the
same: such a partition has opaque magenta endpoints (its colour values are still consumed). This removes the HDR endpoint
decoders and the HDR interpolation, about 400 lines the LDR path never ran. An HDR void extent was already an error block.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
astcenc turns the interpolated 16-bit value into 8 bits by taking its top byte. The shader divided by 65535.0 and stored the float
to an R8G8B8A8_UNORM image, which rounds, so every texel whose 16-bit value is 128 or more above a multiple of 256 came out one
step high: in the astcenc vectors 2,031 of 2,114 legal blocks and 180 of 252 void extents were one step off in linear mode, and
in the game 17.6% of the linear texels.

The decoder now stores the bytes as integers through an R8G8B8A8_UINT storage view (rgba8ui, uimage2DArray) of the image, which
keeps the bits as they are on every driver: a UNORM store of n/255 is exact only where the driver rounds to nearest, which Vulkan
recommends and does not require. A void extent's colour is the top byte of each UNORM16, an error block is zero.

Renderer side: the decoded textures are MUTABLE_FORMAT already, and their level views (astc_target_view, astc_level_view) are
R8G8B8A8_UINT now; the BC scratch images (big and small) are made MUTABLE_FORMAT and get UINT twins of their views, which the
decoder writes, while the BC encoders still read the UNORM ones. R8G8B8A8_UINT storage is mandatory in Vulkan, so no feature or
format check is needed, and the shader no longer needs StorageImageWriteWithoutFormat.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
fix(vk): the GPU ASTC decoder has the specification's sRGB decode mode, chosen by the texture's NVN format
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 5s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
d24736a6db
For an sRGB ASTC format the specification expands the endpoints to 16 bits as (v << 8) | 0x80, where the linear modes use
v * 257, and astcenc's sRGB decode does the same on all four channels. The shader had only the linear expansion, so sRGB
textures (NVN formats 0x87 to 0x94, which are viewed as R8G8B8A8_SRGB) were decoded as linear ones: in the game 18.8% of their
texels were one step off and 0.05% further.

A push constant `srgb` (a new last field of the push block, 44 bytes) selects the expansion; upload_astc_gpu sets it from the
texture's NVN format with the rule view_format_of and the CPU route use (astc_nvn_srgb). The output stays the top byte of the
16-bit result, and void extents and error blocks do not change.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Author
Contributor

Tested in game: Linux, RTX 4070 Ti (NVIDIA 595.99.02) and the Ryzen integrated GPU on RADV: Link's house, Kokiri Forest and Hyrule Field. A temporary read-back check (not in this branch) compared every decoded level with the CPU decoder: 1,392,369,615 texels in 22 formats on the RTX and 1,321,832,771 on the integrated GPU, all equal, where main's decoder on the same route had 1,895,679 texels more than one step off (largest 113). Three scenes branch against base: clean stops, no new warning or error kinds, shots look right. Decoder benchmark against #2194 as merged: 0.93 to 1.02 of its time on the RTX, 0.92 to 0.95 on the integrated GPU; in-game timing is one round a side and shows no regression.

Tested in game: Linux, RTX 4070 Ti (NVIDIA 595.99.02) and the Ryzen integrated GPU on RADV: Link's house, Kokiri Forest and Hyrule Field. A temporary read-back check (not in this branch) compared every decoded level with the CPU decoder: 1,392,369,615 texels in 22 formats on the RTX and 1,321,832,771 on the integrated GPU, all equal, where main's decoder on the same route had 1,895,679 texels more than one step off (largest 113). Three scenes branch against base: clean stops, no new warning or error kinds, shots look right. Decoder benchmark against #2194 as merged: 0.93 to 1.02 of its time on the RTX, 0.92 to 0.95 on the integrated GPU; in-game timing is one round a side and shows no regression.
TrashPanda force-pushed fix/astc-gpu-exact from d24736a6db
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 5s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to 511dd4049b
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 7s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-23 15:10:05 +00:00
Compare
Owner
@rebase
Member

I rebased this pull request onto main (3e75d518bf): the new head is bb832f2bfe.

Nothing was built or run: read the resolution before merging.


Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

I rebased this pull request onto `main` (3e75d518bf26): the new head is bb832f2bfe02. Nothing was built or run: read the resolution before merging. --- <sub>Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
BeanBot force-pushed fix/astc-gpu-exact from 511dd4049b
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 7s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to bb832f2bfe
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 13s
CI / Conventional Commit title (pull_request) Successful in 14s
CI / Workflow lint (actionlint) (pull_request) Successful in 24s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 24s
Third-party parts / As their notes say (pull_request) Successful in 26s
CI / Website build and checks (pull_request) Has been cancelled
2026-11-23 15:58:26 +00:00
Compare
BeanBot left a comment

Recommendation: Request changes. The decoder’s Linux results show a substantial correctness improvement, but the new fixture cannot open its vector file from some Windows checkout paths. The changed Vulkan image-view path also still needs coverage on supported Tier 1 systems.

The shader now matches the CPU reference’s 8-bit and sRGB decoding and corrects several malformed-block and endpoint cases. It adds integer storage views and replaces the GPU comparison fixture; those views need cross-platform validation.

Blocking (1): must change before merging.

  1. L1 tests/astc_decoder_gpu.cpp:95: The new vector-file input is opened with the narrow Windows file API. (more on the line) Do: Accept and open the vector path with Windows wide-character APIs, while retaining the normal POSIX path on Linux.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L2: The new integer storage views and their BC scratch use have not been exercised on all affected Tier 1 systems. When: Windows NVIDIA or AMD drivers, a discrete AMD card, or Steam Deck could render decoded or re-encoded textures incorrectly; the reported Linux NVIDIA and integrated RADV runs do not cover those drivers and devices. Do: Run the decoder fixture and an in-game texture check on Windows NVIDIA and AMD, Linux discrete AMD, and Steam Deck, recording the results and any validation errors.

@fix can do L1.

Checks: Still running: PR description / Description follows the template (pull_request_target).

More: does it help, other systems, switches, what was read

Does it help: Yes. The reported Linux read-backs match the CPU decoder on 1,392,369,615 RTX texels and 1,321,832,771 integrated-GPU texels; the vector fixture reports 9,388 exact decodes versus 3,888 differing on the base. The reported decoder timings are within 3% on the RTX and 5–8% faster on RADV, while single in-game rounds do not establish a performance difference.

Other systems: The change affects decoded RGBA textures and BC encoder inputs, including scratch-image views and the resized BC path. Linux NVIDIA, RADV integrated graphics and lavapipe were reported tested; Windows drivers, discrete AMD Tier 1 hardware and Steam Deck remain unverified.

Switches: None added, changed or removed.

Reviewed: bb832f2bfe against 3e75d518bf: Read the repository rules, PR template, standards, commit messages, shader changes, renderer view and upload changes, fixture runner and test changes. Skimmed the generated SPIR-V header and portions of the large fixture and renderer files; the full renderer and every changed test file were not read in full. docs/review-checklist.md and the sibling Tooling checkout were absent.; nothing run (a code review).

Checked and fine:

  • Each commit records AI assistance.
  • The change adds no switch and does not change the versioned renderer interface.
  • The reported GPU fixture compares exact texels in linear and sRGB modes, and the author reports that undoing each shader correction makes it fail.
  • The new scratch views are included in the deferred destruction path.

Testing: No code or tests were run, as requested. The review used the author’s reported test and measurement results.

Overlaps and merge order: Stacked on #2307, which must merge first; no other overlap was established from the supplied information.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The decoder’s Linux results show a substantial correctness improvement, but the new fixture cannot open its vector file from some Windows checkout paths. The changed Vulkan image-view path also still needs coverage on supported Tier 1 systems. The shader now matches the CPU reference’s 8-bit and sRGB decoding and corrects several malformed-block and endpoint cases. It adds integer storage views and replaces the GPU comparison fixture; those views need cross-platform validation. **Blocking (1)**: must change before merging. 1. **L1** `tests/astc_decoder_gpu.cpp:95`: The new vector-file input is opened with the narrow Windows file API. (more on the line) **Do:** Accept and open the vector path with Windows wide-character APIs, while retaining the normal POSIX path on Linux. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2**: The new integer storage views and their BC scratch use have not been exercised on all affected Tier 1 systems. *When:* Windows NVIDIA or AMD drivers, a discrete AMD card, or Steam Deck could render decoded or re-encoded textures incorrectly; the reported Linux NVIDIA and integrated RADV runs do not cover those drivers and devices. **Do:** Run the decoder fixture and an in-game texture check on Windows NVIDIA and AMD, Linux discrete AMD, and Steam Deck, recording the results and any validation errors. `@fix` can do L1. **Checks:** Still running: `PR description / Description follows the template (pull_request_target)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes. The reported Linux read-backs match the CPU decoder on 1,392,369,615 RTX texels and 1,321,832,771 integrated-GPU texels; the vector fixture reports 9,388 exact decodes versus 3,888 differing on the base. The reported decoder timings are within 3% on the RTX and 5–8% faster on RADV, while single in-game rounds do not establish a performance difference. **Other systems:** The change affects decoded RGBA textures and BC encoder inputs, including scratch-image views and the resized BC path. Linux NVIDIA, RADV integrated graphics and lavapipe were reported tested; Windows drivers, discrete AMD Tier 1 hardware and Steam Deck remain unverified. **Switches:** None added, changed or removed. **Reviewed:** bb832f2bfe02 against 3e75d518bf26: Read the repository rules, PR template, standards, commit messages, shader changes, renderer view and upload changes, fixture runner and test changes. Skimmed the generated SPIR-V header and portions of the large fixture and renderer files; the full renderer and every changed test file were not read in full. docs/review-checklist.md and the sibling Tooling checkout were absent.; nothing run (a code review). **Checked and fine:** - Each commit records AI assistance. - The change adds no switch and does not change the versioned renderer interface. - The reported GPU fixture compares exact texels in linear and sRGB modes, and the author reports that undoing each shader correction makes it fail. - The new scratch views are included in the deferred destruction path. **Testing:** No code or tests were run, as requested. The review used the author’s reported test and measurement results. **Overlaps and merge order:** Stacked on #2307, which must merge first; no other overlap was established from the supplied information. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.</sub>
@ -326,2 +94,2 @@
std::memcpy(img.linear_astc.data() + static_cast<size_t>(idx) * 16u, blk.b, 16u);
}
std::vector<Vector> load_vectors(const char* path) {
FILE* f = std::fopen(path, "rb");
Member

L1 (blocking): The new vector-file input is opened with the narrow Windows file API.

When: When the checkout path contains characters outside the Windows active code page, the Python runner passes that path to the fixture, but fopen cannot open the vector file, so the default check and GPU fixture fail before testing the decoder.

Do: Accept and open the vector path with Windows wide-character APIs, while retaining the normal POSIX path on Linux.

**L1** (blocking): The new vector-file input is opened with the narrow Windows file API. *When:* When the checkout path contains characters outside the Windows active code page, the Python runner passes that path to the fixture, but fopen cannot open the vector file, so the default check and GPU fixture fail before testing the decoder. **Do:** Accept and open the vector path with Windows wide-character APIs, while retaining the normal POSIX path on Linux.
Owner
@fix
BeanBot force-pushed fix/astc-gpu-exact from bb832f2bfe
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 13s
CI / Conventional Commit title (pull_request) Successful in 14s
CI / Workflow lint (actionlint) (pull_request) Successful in 24s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 24s
Third-party parts / As their notes say (pull_request) Successful in 26s
CI / Website build and checks (pull_request) Has been cancelled
to 8f8398ba86
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 20s
CI / Workflow lint (actionlint) (pull_request) Successful in 33s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 35s
Third-party parts / As their notes say (pull_request) Successful in 43s
PR description / Description follows the template (pull_request_target) Failing after 30s
CI / Website build and checks (pull_request) Successful in 15m52s
2026-11-23 16:04:05 +00:00
Compare
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The Windows vector-file path fix is in place, but the integer storage views still need coverage on the affected Tier 1 systems. The stacked CPU decoder PR must also merge first. Recommend approval; not approved on the forge.

What @fix changed
I changed this pull request: the new head is 8f8398ba86. I rebased it onto main (6acae6aa87).

Changed

  • Windows vector-file paths in tests/astc_decoder_gpu.cpp:95: Read the original Windows command line as wide characters and open the vector file with _wfopen; retain fopen on Linux. Added the Shell32 link flag in tests/test_astc_decoder_gpu.py:50. Tests were not run, as requested.

Nothing was built or run: the checks run again on the new head.

The GPU ASTC decoder produces specification-matching texture bytes and fixes several decoding faults. It adds integer image views and some renderer complexity; the reported Linux runs show correct output without a clear in-game performance cost.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L2: The new integer storage views and their BC scratch use have not been exercised on all affected Tier 1 systems. When: Windows NVIDIA or AMD drivers, a discrete AMD card, or Steam Deck could render decoded or re-encoded textures incorrectly; the reported Linux NVIDIA and integrated RADV runs do not cover those drivers and devices. Do: Run the decoder fixture and an in-game texture check on Windows NVIDIA and AMD, Linux discrete AMD, and Steam Deck, recording the results and any validation errors.

Checks: they run again on this head (Guide screenshots / Guide images and local UI source review (pull_request) failed on the last one); a failure shows on the pull request.

Also noticed (1; not asked for, not blocking)
  • The in-game frame-time comparison has only one round per side.
More: does it help, other systems, switches, what was read

Does it help: Yes. The author reports all 9,388 vector decodes and more than 2.7 billion in-game texels matching the CPU reference on Linux NVIDIA and RADV; main differed on 3,888 vector decodes. The in-game timing comparison was only one round per side.

Other systems: The UINT views affect decoded textures and BC scratch images. Linux NVIDIA and RADV runs are reported; Windows NVIDIA and AMD, discrete AMD on Linux, and Steam Deck coverage remain outstanding.

Switches: None.

Reviewed: 8f8398ba86 against 6acae6aa87: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the fix diff and test_astc_decoder_gpu.py. Inspected the fixture, renderer and shader changes and their callers; the large fixture and renderer diff output was truncated, and the generated SPIR-V header and other changed files were not read in full.; nothing run (a code review).

Checked and fine:

  • The Python fixture passes the vector path as an argument and links Shell32 on Windows.
  • The fix preserves the GPU decoder change and its test coverage.

Testing: No code or tests were run. CI has not run on this head; the reported Linux fixture and game runs are author evidence.

Overlaps and merge order: Stacked on Longshot #2307; merge that first.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The Windows vector-file path fix is in place, but the integer storage views still need coverage on the affected Tier 1 systems. The stacked CPU decoder PR must also merge first. Recommend approval; not approved on the forge. **What `@fix` changed** I changed this pull request: the new head is 8f8398ba861a. I rebased it onto `main` (6acae6aa8752). **Changed** - **Windows vector-file paths in tests/astc_decoder_gpu.cpp:95**: Read the original Windows command line as wide characters and open the vector file with _wfopen; retain fopen on Linux. Added the Shell32 link flag in tests/test_astc_decoder_gpu.py:50. Tests were not run, as requested. Nothing was built or run: the checks run again on the new head. The GPU ASTC decoder produces specification-matching texture bytes and fixes several decoding faults. It adds integer image views and some renderer complexity; the reported Linux runs show correct output without a clear in-game performance cost. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2**: The new integer storage views and their BC scratch use have not been exercised on all affected Tier 1 systems. *When:* Windows NVIDIA or AMD drivers, a discrete AMD card, or Steam Deck could render decoded or re-encoded textures incorrectly; the reported Linux NVIDIA and integrated RADV runs do not cover those drivers and devices. **Do:** Run the decoder fixture and an in-game texture check on Windows NVIDIA and AMD, Linux discrete AMD, and Steam Deck, recording the results and any validation errors. **Checks:** they run again on this head (`Guide screenshots / Guide images and local UI source review (pull_request)` failed on the last one); a failure shows on the pull request. <details> <summary>Also noticed (1; not asked for, not blocking)</summary> - The in-game frame-time comparison has only one round per side. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes. The author reports all 9,388 vector decodes and more than 2.7 billion in-game texels matching the CPU reference on Linux NVIDIA and RADV; main differed on 3,888 vector decodes. The in-game timing comparison was only one round per side. **Other systems:** The UINT views affect decoded textures and BC scratch images. Linux NVIDIA and RADV runs are reported; Windows NVIDIA and AMD, discrete AMD on Linux, and Steam Deck coverage remain outstanding. **Switches:** None. **Reviewed:** 8f8398ba861a against 6acae6aa8752: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the fix diff and test_astc_decoder_gpu.py. Inspected the fixture, renderer and shader changes and their callers; the large fixture and renderer diff output was truncated, and the generated SPIR-V header and other changed files were not read in full.; nothing run (a code review). **Checked and fine:** - The Python fixture passes the vector path as an argument and links Shell32 on Windows. - The fix preserves the GPU decoder change and its test coverage. **Testing:** No code or tests were run. CI has not run on this head; the reported Linux fixture and game runs are author evidence. **Overlaps and merge order:** Stacked on Longshot #2307; merge that first. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.</sub>
HumanBean changed title from WIP: fix(vk): the GPU ASTC decoder decodes exactly as astcenc does: 8-bit conversion, sRGB mode and four decoding faults to fix(vk): the GPU ASTC decoder decodes exactly as astcenc does: 8-bit conversion, sRGB mode and four decoding faults 2026-11-23 16:09:38 +00:00
HumanBean deleted branch fix/astc-gpu-exact 2026-11-23 16:12:55 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2314
No description provided.