fix(agc): give storage image table elements UINT views when their kind needs one #18455

Merged
Pipodi merged 10 commits from upstream-pr/18455 into main 2026-11-16 05:59:56 +00:00
Pipodi commented 2026-11-11 15:22:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-11-11T15:22:32Z.


What

A storage image table element that the shader only writes as raw uint (written-only R16_FLOAT, R16_SINT, R32_SINT) got its native view instead of the UINT view, so the raw uint store hit a format mismatch.

The driver chooses the UINT view of such an image from the binding number (RuntimeAbi::UintStorageImageBinding). The storage image table is binding 260, outside the uint slots, so every table element was bound with StorageView(..., false) while the shader stored uint through the kind's typed array.

  • DescriptorBinding::imageUintStorage: one flag per table element, true when the element's kind is a uint storage kind. Built in DescriptorBindingBuilder::Populate (reserved with the other per-element arrays), serialized in the shader disk cache (FormatVersion 88; DescriptorBinding size check 864 -> 920).
  • ShaderResources::storageUint keeps it next to storageAtomic64; both table write sites OR it into the StorageView argument.
  • The table resolve creates the UINT view once, so a device without the UINT storage format rejects the element through the existing table rejection path. Technical-debt entry in the fragment docs/dev/debt/changes/fix-agc-storage-table-uint-views.md.

Overlap: #18185 (@hamb3r, D16S8 depth conversion) carries the same imageUintStorage flag, encode/decode and Populate line as part of a larger change. Whichever merges second has to drop the shared lines; see the comment below.

Tested

Windows 11, NVIDIA GeForce RTX 4090 (driver 617.42), host tests only, no title. Branch head 4f13ee9e6c on main 6453229902.

  • New agc_driver_image_table case (RunStoreUintViewTests) stores through a table element of written-only R16_FLOAT (f16 store, expects 0x3e00 and untouched padding), R16_SINT and R32_SINT (raw uint). On main plus only the test commit (0839d13e27) it fails: image table store: written-only R16_FLOAT descriptor wrote the wrong texel or padding 0. With the fix it passes.
  • New recompiler unit test verifyImageTableUintStorage (agc_shader_memory): flag set for written-only R16_FLOAT, R16_SINT, R32_SINT; clear for R32_UINT and R8G8B8A8_UNORM table elements. It does not compile on main (no imageUintStorage).
  • agc_shader_table_binding_growth (failed in this PR's Windows CI at 11 allocations against a ceiling of 10): the new per-element array is now reserved with the others and the ceiling counts it (8 image arrays + 2 sampler arrays + 1 spill = 11); the test also checks the flag count. It passes on main (10) and on the branch.
  • The SINT GPU case can pass without the fix on a driver that accepts a mismatched view format; the unit test is the proof (debt entry).
  • Full ctest on the branch before the last main merge (b93d4a14d1 on main 6c9a7b6f8a): 5720 of 5721 pass. On 4f13ee9e6c the focused set (table binding growth, shader memory, image table, storage image, descriptor, disk cache) passes 53/53. The one not run is agc_driver_upload_cache_read_only_flush: main's UploadCacheReadOnlyFlush.cpp:177 uses setenv, which does not build with MinGW (#19899), on main as well.
  • Validation layer, same machine, branch 4f13ee9e6c: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer VK_KHRONOS_VALIDATION_REPORT_FLAGS=error,warn ctest --test-dir build -R "agc_driver_(image_table|nested_image_table|image_store|format_d16|d16_memory|runtime_formatted_store|pixel_float16_store|image_packed16)" -V (55 tests pass). The log shows [Vulkan Loader] INFO | LAYER: Insert instance layer "VK_LAYER_KHRONOS_validation" (C:\VulkanSDK\1.4.363.0\Bin\VkLayer_khronos_validation.dll); no was not found but was requested, VUID- or SYNC-HAZARD. Main (0839d13e27, earlier run, same command) fails only the new case.

Checklist

  • Based on current main; overlaps #18185 on the imageUintStorage flag (see above)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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 (overlaps #18185)
  • Fixes: none
  • Unblocks: PPSA26344 #675
  • GPUs tested: NVIDIA GeForce RTX 4090, driver 617.42, Windows 11
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5262064330 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18455). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-11-11T15:22:32Z. --- ### What A storage image table element that the shader only writes as raw uint (written-only R16_FLOAT, R16_SINT, R32_SINT) got its native view instead of the UINT view, so the raw uint store hit a format mismatch. The driver chooses the UINT view of such an image from the binding number (`RuntimeAbi::UintStorageImageBinding`). The storage image table is binding 260, outside the uint slots, so every table element was bound with `StorageView(..., false)` while the shader stored uint through the kind's typed array. - `DescriptorBinding::imageUintStorage`: one flag per table element, true when the element's kind is a uint storage kind. Built in `DescriptorBindingBuilder::Populate` (reserved with the other per-element arrays), serialized in the shader disk cache (`FormatVersion` 88; `DescriptorBinding` size check 864 -> 920). - `ShaderResources::storageUint` keeps it next to `storageAtomic64`; both table write sites OR it into the `StorageView` argument. - The table resolve creates the UINT view once, so a device without the UINT storage format rejects the element through the existing table rejection path. Technical-debt entry in the fragment `docs/dev/debt/changes/fix-agc-storage-table-uint-views.md`. Overlap: #18185 (@hamb3r, D16S8 depth conversion) carries the same `imageUintStorage` flag, encode/decode and Populate line as part of a larger change. Whichever merges second has to drop the shared lines; see the comment below. ### Tested Windows 11, NVIDIA GeForce RTX 4090 (driver 617.42), host tests only, no title. Branch head 4f13ee9e6c on main 6453229902. - New `agc_driver_image_table` case (`RunStoreUintViewTests`) stores through a table element of written-only R16_FLOAT (f16 store, expects 0x3e00 and untouched padding), R16_SINT and R32_SINT (raw uint). On main plus only the test commit (`0839d13e27`) it fails: `image table store: written-only R16_FLOAT descriptor wrote the wrong texel or padding 0`. With the fix it passes. - New recompiler unit test `verifyImageTableUintStorage` (agc_shader_memory): flag set for written-only R16_FLOAT, R16_SINT, R32_SINT; clear for R32_UINT and R8G8B8A8_UNORM table elements. It does not compile on main (no `imageUintStorage`). - `agc_shader_table_binding_growth` (failed in this PR's Windows CI at 11 allocations against a ceiling of 10): the new per-element array is now reserved with the others and the ceiling counts it (8 image arrays + 2 sampler arrays + 1 spill = 11); the test also checks the flag count. It passes on main (10) and on the branch. - The SINT GPU case can pass without the fix on a driver that accepts a mismatched view format; the unit test is the proof (debt entry). - Full ctest on the branch before the last main merge (b93d4a14d1 on main 6c9a7b6f8a): 5720 of 5721 pass. On 4f13ee9e6c the focused set (table binding growth, shader memory, image table, storage image, descriptor, disk cache) passes 53/53. The one not run is `agc_driver_upload_cache_read_only_flush`: main's `UploadCacheReadOnlyFlush.cpp:177` uses `setenv`, which does not build with MinGW (#19899), on main as well. - Validation layer, same machine, branch 4f13ee9e6c: `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer VK_KHRONOS_VALIDATION_REPORT_FLAGS=error,warn ctest --test-dir build -R "agc_driver_(image_table|nested_image_table|image_store|format_d16|d16_memory|runtime_formatted_store|pixel_float16_store|image_packed16)" -V` (55 tests pass). The log shows `[Vulkan Loader] INFO | LAYER: Insert instance layer "VK_LAYER_KHRONOS_validation" (C:\VulkanSDK\1.4.363.0\Bin\VkLayer_khronos_validation.dll)`; no `was not found but was requested`, `VUID-` or `SYNC-HAZARD`. Main (`0839d13e27`, earlier run, same command) fails only the new case. ### Checklist - [x] Based on current `main`; overlaps #18185 on the `imageUintStorage` flag (see above) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/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 (overlaps #18185) - [x] Fixes: none - [x] Unblocks: PPSA26344 #675 - [x] GPUs tested: NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-12 14:26:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T14:26:30Z.

Review: COMMENTED


Reviewed — no blocking findings

The change gives storage image table elements that need a UINT view one, and the code I read matches the stated goal; one PR description sentence disagrees with the test.

What I ran

  • Head SHA 749818da2d31f74adf82b8757e67640dc6b054a1, base main.
  • Read the diff (diff.patch) for all 10 changed files, and the manifest.
  • Read head context with the reader only:
repo_read.py search storageAtomic64
repo_read.py search UintStorageImageBinding
repo_read.py search storageTextures.push_back
repo_read.py search ImageBindingResourceClass
repo_read.py cat core/shader/recompiler/RuntimeAbi.hpp 95 125
repo_read.py cat core/shader/recompiler/IntermediateRepresentation/src/IrProgram.cpp 960 995
repo_read.py cat core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp 730 752
repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp 5900 5945
repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp 6376 6392
  • No build and no test run here.

Results

Check Result Note
Every storageTextures push has a matching storageUint push passed Read by search, 4 sites
Kind values used as binding numbers passed Read in IrProgram.cpp
Disk cache write and read order passed Read in the diff
Build and ctest not run Author-reported only
verifyImageTableUintStorage not run Author-reported only
agc_driver_image_table GPU case not run Author-reported only
Reader output, abridged

Every storage texture push in ShaderResources.cpp (lines 5911, 5934, 5935, 6394) has one storageUint push beside it. UintStorageImageBinding (RuntimeAbi.hpp 113–118) covers local slots 36–42, which are the storage uint kinds in IrProgram.cpp 986–988.

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp:6209: the test expects the UINT flag to be true for TableFormat32UInt. The PR text says it is clear for R32_UINT. The code agrees with the test, because the uint kinds include R32_UINT. This is harmless, since the UINT view of an R32_UINT element is the same format. Fix the PR description so it says the flag is set for R32_UINT too.

Not verified

  • The GPU expectation storeHalf(12u, uintCode, 0x8000u, ...) in core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp. I could not derive 0x8000 from the 0x89abcdef literal and the store word in the test. Confirm it when the case runs.
  • That StorageTexture::StorageView (Texture.cpp:2361) throws std::runtime_error when the device has no UINT view format. The table rejection depends on it, and I did not read that function.
  • That a table with a stored element is never reused, which the debt entry asserts. I did not read the reuse path.
  • Full text of ShaderResources.cpp, ShaderMemory.cpp and ImageTable.cpp. Those files are too large for the review folder, so I used the diff hunks and reader context only. I did not read files/.
  • FormatVersion 87 against the open PRs that claim 69–86. This is coordination, not code.
  • Author-reported results: ctest 5013 of 5013, the validation-layer run, and the RTX 4090 GPU cases. None were run here.

To get this to a good state

  • Fix the R32_UINT sentence in the PR description to match the test.
  • Nothing else is needed from my side. The author's next step is to confirm the 0x8000 expectation on the next GPU run.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5876104087 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18455#pullrequestreview-5876104087). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-12T14:26:30Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The change gives storage image table elements that need a UINT view one, and the code I read matches the stated goal; one PR description sentence disagrees with the test. ## What I ran - Head SHA `749818da2d31f74adf82b8757e67640dc6b054a1`, base `main`. - Read the diff (`diff.patch`) for all 10 changed files, and the manifest. - Read head context with the reader only: ``` repo_read.py search storageAtomic64 repo_read.py search UintStorageImageBinding repo_read.py search storageTextures.push_back repo_read.py search ImageBindingResourceClass repo_read.py cat core/shader/recompiler/RuntimeAbi.hpp 95 125 repo_read.py cat core/shader/recompiler/IntermediateRepresentation/src/IrProgram.cpp 960 995 repo_read.py cat core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp 730 752 repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp 5900 5945 repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp 6376 6392 ``` - No build and no test run here. ## Results | Check | Result | Note | |---|---|---| | Every `storageTextures` push has a matching `storageUint` push | passed | Read by search, 4 sites | | Kind values used as binding numbers | passed | Read in `IrProgram.cpp` | | Disk cache write and read order | passed | Read in the diff | | Build and ctest | not run | Author-reported only | | `verifyImageTableUintStorage` | not run | Author-reported only | | `agc_driver_image_table` GPU case | not run | Author-reported only | <details> <summary>Reader output, abridged</summary> Every storage texture push in `ShaderResources.cpp` (lines 5911, 5934, 5935, 6394) has one `storageUint` push beside it. `UintStorageImageBinding` (`RuntimeAbi.hpp` 113–118) covers local slots 36–42, which are the storage uint kinds in `IrProgram.cpp` 986–988. </details> ## Findings ### Blocking None. ### Non-blocking - `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp:6209`: the test expects the UINT flag to be **true** for `TableFormat32UInt`. The PR text says it is **clear** for R32_UINT. The code agrees with the test, because the uint kinds include R32_UINT. This is harmless, since the UINT view of an R32_UINT element is the same format. Fix the PR description so it says the flag is set for R32_UINT too. ## Not verified - The GPU expectation `storeHalf(12u, uintCode, 0x8000u, ...)` in `core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp`. I could not derive `0x8000` from the `0x89abcdef` literal and the store word in the test. Confirm it when the case runs. - That `StorageTexture::StorageView` (`Texture.cpp:2361`) throws `std::runtime_error` when the device has no UINT view format. The table rejection depends on it, and I did not read that function. - That a table with a stored element is never reused, which the debt entry asserts. I did not read the reuse path. - Full text of `ShaderResources.cpp`, `ShaderMemory.cpp` and `ImageTable.cpp`. Those files are too large for the review folder, so I used the diff hunks and reader context only. I did not read `files/`. - `FormatVersion` 87 against the open PRs that claim 69–86. This is coordination, not code. - Author-reported results: ctest 5013 of 5013, the validation-layer run, and the RTX 4090 GPU cases. None were run here. ## To get this to a good state - Fix the R32_UINT sentence in the PR description to match the test. - Nothing else is needed from my side. The author's next step is to confirm the `0x8000` expectation on the next GPU run.
MarcZX10 commented 2026-11-15 02:44:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T02:44:10Z.

Review: APPROVED


Reviewed — looks good

The reviewed change at head 81362e7b90b64ceac5e0a4032ee4a14809054240 appears sound; no checks were run during this review, and the evidence inspected supports merging.

What I ran

No commands or tests were run. I reviewed the prepared diff and targeted source ranges at the pinned head.

Results

Check Result Note
Diff and targeted source review passed Relevant behavior inspected
Automated checks not run Author-reported runs were not independently verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

The change appears internally consistent: table elements carry the kind-derived UINT view flag, both descriptor write paths use it, and table resolution creates the requested view to trigger the existing rejection path when unsupported. Disk-cache encoding and decoding include the new field, with the format version incremented. The changed GPU and recompiler tests were reviewed but not run. The author-reported Windows/NVIDIA results were not independently verified.

Read: description.md, commits.md, manifest.json, diff.patch, README.md, and relevant ranges from all changed files, including the two excluded from the prepared file bundle (ShaderResources.cpp and ShaderMemory.cpp). The remaining lines in those changed files were not read.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5908693025 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18455#pullrequestreview-5908693025). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-15T02:44:10Z. **Review:** APPROVED --- # Reviewed — looks good The reviewed change at head `81362e7b90b64ceac5e0a4032ee4a14809054240` appears sound; no checks were run during this review, and the evidence inspected supports merging. ## What I ran No commands or tests were run. I reviewed the prepared diff and targeted source ranges at the pinned head. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | Relevant behavior inspected | | Automated checks | not run | Author-reported runs were not independently verified | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The change appears internally consistent: table elements carry the kind-derived UINT view flag, both descriptor write paths use it, and table resolution creates the requested view to trigger the existing rejection path when unsupported. Disk-cache encoding and decoding include the new field, with the format version incremented. The changed GPU and recompiler tests were reviewed but not run. The author-reported Windows/NVIDIA results were not independently verified. Read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `README.md`, and relevant ranges from all changed files, including the two excluded from the prepared file bundle (`ShaderResources.cpp` and `ShaderMemory.cpp`). The remaining lines in those changed files were not read. ## To get this to a good state Nothing is required.
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!18455
No description provided.