fix(agc): find a shader's ShaderData binding by its number when image tables are appended #20067

Merged
freneza merged 3 commits from upstream-pr/20067 into main 2026-11-22 13:38:33 +00:00
freneza commented 2026-11-14 14:43:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by freneza on 2026-11-14T14:43:44Z.


What

ShaderResources::shaderDataAllocation matched the program's ShaderData binding to a resource binding by its index in the two lists. The lists only line up until the first image table. ShaderResources skips the ImageTable/ImageStorageTable program bindings and appends their resource bindings at the end. In a shader that binds an image table before its ShaderData, the index therefore lands on another binding. A thread-dimension dispatch (DISPATCH_INDIRECT with thread counts) of such a shader then aborts with Vulkan dispatch: a thread-dimension dispatch has no ShaderData thread limit.

This PR finds the resource binding by its binding number instead: the same layout.binding, in a set that is not a table set (set < 0). The checks that follow (one allocation, host-side, with a buffer) are unchanged.

agc_driver_image_table_variants gains a case. It compiles its image-table shader with partial thread groups and ShaderData instead of push data, and checks that the ShaderData binding comes after the image table. It then dispatches the shader indirectly with 64 and with 35 threads in a 64-thread group. Lanes inside the limit must sample the right texel, and lanes past it must not run.

Tested

Linux (Bazzite 45, Fedora 44 toolbox), GCC, Release. Each arm ran agc_driver_image_table_variants, agc_driver_indirect_thread_dimensions and agc_driver_indirect_thread_dimensions_cpu 3 times, from the same build tree on the same GPU, with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R '^agc_driver_(image_table_variants|indirect_thread_dimensions|indirect_thread_dimensions_cpu)$' -V:

arm image_table_variants indirect_thread_dimensions indirect_thread_dimensions_cpu VUID- lines
main 3ffcba66e0 + the new test case fails 3/3: a thread-dimension dispatch has no ShaderData thread limit 3/3 pass 3/3 pass 0
this PR 3/3 pass 3/3 pass 3/3 pass 0
  • Validation layer: every log shows Insert instance layer "VK_LAYER_KHRONOS_validation", and none contains was not found but was requested by env var VK_INSTANCE_LAYERS. The layer is vulkan-validation-layers 1.4.341.
  • Where it came from: PPSA01317 01.710.000, on a local stack with #9969. The first dispatch of a car compute shader (0x120aec1a00, 14 program bindings) aborted with the message above. A local diagnostic showed ShaderData at binding 13 with 0 allocations. With this change the same dispatches ran in game and the 12 car compute pipelines were created. The title still stops later, on the call-table limit discussed in #13538.

Checklist

  • Based on current main; no other open PR implements the same functions. pr_overlap.py --names shaderDataAllocation: none. --branch lists only file-level overlaps on ShaderResources.cpp and ImageTableVariants.cpp.
  • 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. PPSA01317 gets past this abort only on a stack with #9969, and then stops on the call-table limit in #13538.
  • GPUs tested: NVIDIA GeForce RTX 5070, driver 620.70.06, Linux (Bazzite 45)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5312455447 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20067). Originally posted by [freneza](https://github.com/freneza) on 2026-11-14T14:43:44Z. --- ### What `ShaderResources::shaderDataAllocation` matched the program's ShaderData binding to a resource binding by its index in the two lists. The lists only line up until the first image table. `ShaderResources` skips the `ImageTable`/`ImageStorageTable` program bindings and appends their resource bindings at the end. In a shader that binds an image table before its ShaderData, the index therefore lands on another binding. A thread-dimension dispatch (DISPATCH_INDIRECT with thread counts) of such a shader then aborts with `Vulkan dispatch: a thread-dimension dispatch has no ShaderData thread limit`. This PR finds the resource binding by its binding number instead: the same `layout.binding`, in a set that is not a table set (`set < 0`). The checks that follow (one allocation, host-side, with a buffer) are unchanged. `agc_driver_image_table_variants` gains a case. It compiles its image-table shader with partial thread groups and ShaderData instead of push data, and checks that the ShaderData binding comes after the image table. It then dispatches the shader indirectly with 64 and with 35 threads in a 64-thread group. Lanes inside the limit must sample the right texel, and lanes past it must not run. ### Tested Linux (Bazzite 45, Fedora 44 toolbox), GCC, Release. Each arm ran `agc_driver_image_table_variants`, `agc_driver_indirect_thread_dimensions` and `agc_driver_indirect_thread_dimensions_cpu` 3 times, from the same build tree on the same GPU, with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R '^agc_driver_(image_table_variants|indirect_thread_dimensions|indirect_thread_dimensions_cpu)$' -V`: | arm | image_table_variants | indirect_thread_dimensions | indirect_thread_dimensions_cpu | `VUID-` lines | |---|---|---|---|---| | `main` 3ffcba66e0 + the new test case | fails 3/3: `a thread-dimension dispatch has no ShaderData thread limit` | 3/3 pass | 3/3 pass | 0 | | this PR | 3/3 pass | 3/3 pass | 3/3 pass | 0 | - **Validation layer:** every log shows `Insert instance layer "VK_LAYER_KHRONOS_validation"`, and none contains `was not found but was requested by env var VK_INSTANCE_LAYERS`. The layer is `vulkan-validation-layers` 1.4.341. - **Where it came from:** PPSA01317 01.710.000, on a local stack with #9969. The first dispatch of a car compute shader (`0x120aec1a00`, 14 program bindings) aborted with the message above. A local diagnostic showed `ShaderData at binding 13 with 0 allocations`. With this change the same dispatches ran in game and the 12 car compute pipelines were created. The title still stops later, on the call-table limit discussed in #13538. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions. `pr_overlap.py --names shaderDataAllocation`: none. `--branch` lists only file-level overlaps on `ShaderResources.cpp` and `ImageTableVariants.cpp`. - [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) - [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 - [x] Fixes: none - [x] Unblocks: none. PPSA01317 gets past this abort only on a stack with #9969, and then stops on the call-table limit in #13538. - [x] GPUs tested: NVIDIA GeForce RTX 5070, driver 620.70.06, Linux (Bazzite 45) - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-14 15:33:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T15:33:00Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the code read supports the binding lookup fix, and the author reports passing targeted GPU tests.

What I ran

Reviewed head 402e1af06ddf019851caac695e24cb29ee78307a using the prepared diff and repo_read.py. No tests or builds were run. The author-reported test results are not runs performed in this review.

Results

Check Result Note
Changed-code review passed Lookup matches binding number and excludes table sets
Targeted GPU tests not run Passes reported by author
Full test suite not run Not run in this review

Findings

Blocking

None.

Non-blocking

None.

Not verified

Read core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp around the changed function and binding construction, core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp around a caller, and core/libs/prx/libSceAgcDriver/tests/execution/ImageTableVariants.cpp around the changed test. files.json was unavailable through the reader, so the reviewed/excluded file inventory could not be confirmed. The complete 7,388-line ShaderResources.cpp was not read; other code paths and reported hardware results were not independently verified.

To get this to a good state

Nothing is required. The author-reported targeted test results are useful supporting evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5905434307 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20067#pullrequestreview-5905434307). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T15:33:00Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the code read supports the binding lookup fix, and the author reports passing targeted GPU tests. ## What I ran Reviewed head `402e1af06ddf019851caac695e24cb29ee78307a` using the prepared diff and `repo_read.py`. No tests or builds were run. The author-reported test results are not runs performed in this review. ## Results | Check | Result | Note | |---|---|---| | Changed-code review | passed | Lookup matches binding number and excludes table sets | | Targeted GPU tests | not run | Passes reported by author | | Full test suite | not run | Not run in this review | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Read `core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp` around the changed function and binding construction, `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` around a caller, and `core/libs/prx/libSceAgcDriver/tests/execution/ImageTableVariants.cpp` around the changed test. `files.json` was unavailable through the reader, so the reviewed/excluded file inventory could not be confirmed. The complete 7,388-line `ShaderResources.cpp` was not read; other code paths and reported hardware results were not independently verified. ## To get this to a good state Nothing is required. The author-reported targeted test results are useful supporting evidence.
MarcZX10 commented 2026-11-22 06:34:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T06:34:33Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation and added regression test support the stated fix.

What I ran

Reviewed head 0c3160a61fd272990d7cdbfca135d6c0eeaba242. No commands or tests were run; the Linux GPU test results in the description are author-reported.

Results

Check Result Note
Diff and changed lines passed One changed test file read
Targeted implementation context passed Binding lookup and dispatch path read
Tests in this review not run No test execution environment

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests were run here. The described Linux GPU runs and validation-layer output were not independently verified. The changed file core/libs/prx/libSceAgcDriver/tests/execution/ImageTableVariants.cpp was read, including all added lines; it is the only file listed as reviewed. The implementation files core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp, core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp, and existing test context in core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp were read as context, not as changed files. No files were excluded by the manifest.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6010781838 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20067#pullrequestreview-6010781838). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T06:34:33Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation and added regression test support the stated fix. ## What I ran Reviewed head `0c3160a61fd272990d7cdbfca135d6c0eeaba242`. No commands or tests were run; the Linux GPU test results in the description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and changed lines | passed | One changed test file read | | Targeted implementation context | passed | Binding lookup and dispatch path read | | Tests in this review | not run | No test execution environment | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No tests were run here. The described Linux GPU runs and validation-layer output were not independently verified. The changed file `core/libs/prx/libSceAgcDriver/tests/execution/ImageTableVariants.cpp` was read, including all added lines; it is the only file listed as reviewed. The implementation files `core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp`, `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp`, and existing test context in `core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp` were read as context, not as changed files. No files were excluded by the manifest. ## 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!20067
No description provided.