fix(agc): bind UINT views for float16 stores outside compute shaders #15741

Merged
zorde23 merged 3 commits from upstream-pr/15741 into main 2026-11-04 19:21:16 +00:00
zorde23 commented 2026-11-04 10:54:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zorde23 on 2026-11-04T10:54:42Z.


What

027c6f06a8 and 4a25a6560c bind a UINT storage view for write-only float16 images, which the recompiler declares as uint. The driver picks that view only when the binding number is in FirstStorageImageBinding + 7 .. + 13 (36..42). Binding numbers are stage * Binding::Count + slot (RuntimeAbi::BindingNumber), so this matches only the main stage. In a pixel, hull or domain shader the same slots are 101..107, 166..172 and 231..237: the shader writes uint texels through a float16 view (undefined behaviour), and on AMD's Windows driver the store writes nothing.

RuntimeAbi::UintStorageImageBinding takes the slot from the binding number within its stage. The three call sites in ShaderResources.cpp (storage images, the compact binding path and multisample storage views) use it. The image table bindings (260, 261) are never uint storage slots. The function only picks the host view, so it is listed in shaderCacheReviewedNames without a cache key change.

Overlap: #7642, #9508, #10193, #13928 and #13929 make the same correction at the same three call sites (a UintStorageBinding helper taking the binding modulo Binding::Count) inside larger image table and descriptor heap work; none is merged and none adds a test for this case. This PR is the fix alone with a GPU test that fails on main, so it can go first and those would use RuntimeAbi::UintStorageImageBinding instead of their own helper. #10743 and #13796 change the same lines without this fix and will need a small rebase.

Tested

  • New agc_driver_pixel_float16_store: a full-screen draw stores each pixel's position and two constants to 16_FLOAT, 16_16_FLOAT and 16_16_16_16_FLOAT images from the pixel shader (wave64 and wave32) and checks every texel. On main it fails (texel (0, 0) component 0 is 0, expected 14336) and the validation layer reports VUID-vkCmdDraw-format-07753 (uint image type through a float16 view); with this change it passes with no VUID- errors.
  • agc_shader_device_profile now checks every stage × binding against the stage-local uint storage slots, plus the two image table bindings.
  • Focused AGC tests (81, run before the new test was added: agc_shader_device_profile, image_store_*, uint*, multisample*, *storage*) on main (5b1d381d5a) and on this branch, same machine, ctest -V -j 1 with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1: 81/81 pass on both. Neither log reports was not found but was requested by env var VK_INSTANCE_LAYERS. 0 VUID- errors on both; the only validation output is the same WARNING-VkImageSubresourceRange-layerCount-compatibility on both (tests 1311, 1565, 2022).
  • A retail title's depth-of-field pass writes a 960x540 R16G16_SFLOAT image from a pixel shader. Before the fix the image stays all zero and dark tiles appear on screen edges; with an equivalent fix in a local build, a captured frame replayed through agc_frame_replay writes 518400/518400 texels, and the artefact is gone in live play. RX 6750 XT, Windows 11.
  • python3 tools/check_conventions.py passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 6750 XT, Adrenalin 26.10.2 (driver 32.0.21045.20006), Windows 11 Pro 25H2 (26200.9711)
  • AI-assisted: yes

Test image of agc_driver_pixel_float16_store (16_16_16_16_FLOAT, wave64; R = x/64, G = y/32, B = 1.0; 8x), dumped by a local uncommitted change to the test.

Main: store lost, all black.

main-pixel-float16

This PR: every texel written.

pr-pixel-float16
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5153042687 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15741). Originally posted by [zorde23](https://github.com/zorde23) on 2026-11-04T10:54:42Z. --- ### What 027c6f06a8 and 4a25a6560c bind a UINT storage view for write-only float16 images, which the recompiler declares as uint. The driver picks that view only when the binding number is in `FirstStorageImageBinding + 7 .. + 13` (36..42). Binding numbers are `stage * Binding::Count + slot` (`RuntimeAbi::BindingNumber`), so this matches only the main stage. In a pixel, hull or domain shader the same slots are 101..107, 166..172 and 231..237: the shader writes uint texels through a float16 view (undefined behaviour), and on AMD's Windows driver the store writes nothing. `RuntimeAbi::UintStorageImageBinding` takes the slot from the binding number within its stage. The three call sites in `ShaderResources.cpp` (storage images, the compact binding path and multisample storage views) use it. The image table bindings (260, 261) are never uint storage slots. The function only picks the host view, so it is listed in `shaderCacheReviewedNames` without a cache key change. Overlap: #7642, #9508, #10193, #13928 and #13929 make the same correction at the same three call sites (a `UintStorageBinding` helper taking the binding modulo `Binding::Count`) inside larger image table and descriptor heap work; none is merged and none adds a test for this case. This PR is the fix alone with a GPU test that fails on `main`, so it can go first and those would use `RuntimeAbi::UintStorageImageBinding` instead of their own helper. #10743 and #13796 change the same lines without this fix and will need a small rebase. ### Tested - New `agc_driver_pixel_float16_store`: a full-screen draw stores each pixel's position and two constants to 16_FLOAT, 16_16_FLOAT and 16_16_16_16_FLOAT images from the pixel shader (wave64 and wave32) and checks every texel. On `main` it fails (`texel (0, 0) component 0 is 0, expected 14336`) and the validation layer reports `VUID-vkCmdDraw-format-07753` (uint image type through a float16 view); with this change it passes with no `VUID-` errors. - `agc_shader_device_profile` now checks every stage × binding against the stage-local uint storage slots, plus the two image table bindings. - Focused AGC tests (81, run before the new test was added: `agc_shader_device_profile`, `image_store_*`, `uint*`, `multisample*`, `*storage*`) on `main` (5b1d381d5a) and on this branch, same machine, `ctest -V -j 1` with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1`: 81/81 pass on both. Neither log reports `was not found but was requested by env var VK_INSTANCE_LAYERS`. 0 `VUID-` errors on both; the only validation output is the same `WARNING-VkImageSubresourceRange-layerCount-compatibility` on both (tests 1311, 1565, 2022). - A retail title's depth-of-field pass writes a 960x540 R16G16_SFLOAT image from a pixel shader. Before the fix the image stays all zero and dark tiles appear on screen edges; with an equivalent fix in a local build, a captured frame replayed through `agc_frame_replay` writes 518400/518400 texels, and the artefact is gone in live play. RX 6750 XT, Windows 11. - `python3 tools/check_conventions.py` passes. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 6750 XT, Adrenalin 26.10.2 (driver 32.0.21045.20006), Windows 11 Pro 25H2 (26200.9711) - [x] AI-assisted: yes Test image of agc_driver_pixel_float16_store (16_16_16_16_FLOAT, wave64; R = x/64, G = y/32, B = 1.0; 8x), dumped by a local uncommitted change to the test. Main: store lost, all black. <img width="512" height="256" alt="main-pixel-float16" src="https://github.com/user-attachments/assets/1383c94a-76dc-4244-a2ad-3f384aed1a73" /> This PR: every texel written. <img width="512" height="256" alt="pr-pixel-float16" src="https://github.com/user-attachments/assets/11fe1fbf-ccfa-4522-b16e-a08d5be0a92b" />
Superseabas commented 2026-11-04 17:49:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-04T17:49:40Z.

Review: APPROVED


Head b70a3fc6fc merged onto current main b11c7bf84f (clean merge, local only): code read, red/green check and a run on two Windows GPUs, NVIDIA and AMD's Windows driver.

Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (x86_64-ucrt-posix-seh, r3), Release, BUILD_TESTING=ON. ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest -R '^(agc_driver_graphics|agc_driver_.*uint.*|agc_driver_pixel_.*|agc_driver_.*float16.*|agc_driver_.*storage_image.*|agc_driver_.*export.*)$', ANYPS5_GPU selecting the device (confirmed by Selected GPU):

GPU Driver main (44 tests) merged (45, with agc_driver_pixel_float16_store)
NVIDIA GeForce RTX 5070 Ti (10de:2c05) 621.01 43 + 1 skip 44 + 1 skip
AMD Radeon Graphics, Ryzen 7 7700X iGPU (1002:164e) AMD 26.10.2 43 + 1 skip 44 + 1 skip
  • The skips are the same on both sides. The only VUID- in either tree is VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (#11990), which is on main too. No new ID appears, and there is no missing-layer line. The new test prints pixel float16 store tests passed on both GPUs.
  • Red check: the merged tree with only this PR's ShaderResources.cpp change reversed fails agc_driver_pixel_float16_store on both GPUs with pixel shader wave64 image_store of 16_FLOAT: texel (0, 0) component 0 is 0, expected 14336. The store writes nothing on NVIDIA's Windows driver too, not only on AMD's.
  • check_conventions.py --base main passes on the merge.

Read through the change:

  • UintStorageImageBinding takes the binding modulo Binding::Count (65) and checks for slots 36..42 (FirstStorageImageBinding + 7 .. + 13) within that stage. It returns false at or above StageCount * 65 = 260, so the image table bindings 260 and 261 stay out, and ShaderDeviceProfile checks exactly that.
  • For the main stage (bindings below 65) the result is the same as the old range check.
  • The three call sites, storage image table entries, compact storage bindings and multisample storage views, now use it.
  • Only the host view changes, which fits the shader-cache review listing.

I found nothing to change.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5773078315 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15741#pullrequestreview-5773078315). Originally posted by [Superseabas](https://github.com/Superseabas) on 2026-11-04T17:49:40Z. **Review:** APPROVED --- Head `b70a3fc6fc` merged onto current `main` `b11c7bf84f` (clean merge, local only): code read, red/green check and a run on two Windows GPUs, NVIDIA and AMD's Windows driver. Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (`x86_64-ucrt-posix-seh`, r3), Release, `BUILD_TESTING=ON`. `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ctest -R '^(agc_driver_graphics|agc_driver_.*uint.*|agc_driver_pixel_.*|agc_driver_.*float16.*|agc_driver_.*storage_image.*|agc_driver_.*export.*)$'`, `ANYPS5_GPU` selecting the device (confirmed by `Selected GPU`): | GPU | Driver | `main` (44 tests) | merged (45, with `agc_driver_pixel_float16_store`) | |---|---|---|---| | NVIDIA GeForce RTX 5070 Ti (`10de:2c05`) | 621.01 | 43 + 1 skip | 44 + 1 skip | | AMD Radeon Graphics, Ryzen 7 7700X iGPU (`1002:164e`) | AMD 26.10.2 | 43 + 1 skip | 44 + 1 skip | - The skips are the same on both sides. The only `VUID-` in either tree is `VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605` (#11990), which is on `main` too. No new ID appears, and there is no missing-layer line. The new test prints `pixel float16 store tests passed` on both GPUs. - Red check: the merged tree with only this PR's `ShaderResources.cpp` change reversed fails `agc_driver_pixel_float16_store` on **both** GPUs with `pixel shader wave64 image_store of 16_FLOAT: texel (0, 0) component 0 is 0, expected 14336`. The store writes nothing on NVIDIA's Windows driver too, not only on AMD's. - `check_conventions.py --base main` passes on the merge. Read through the change: - `UintStorageImageBinding` takes the binding modulo `Binding::Count` (65) and checks for slots 36..42 (`FirstStorageImageBinding + 7 .. + 13`) within that stage. It returns false at or above `StageCount * 65` = 260, so the image table bindings 260 and 261 stay out, and `ShaderDeviceProfile` checks exactly that. - For the main stage (bindings below 65) the result is the same as the old range check. - The three call sites, storage image table entries, compact storage bindings and multisample storage views, now use it. - Only the host view changes, which fits the shader-cache review listing. I found nothing to change. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!15741
No description provided.