fix(agc): accept aliased views of the guest buffers in graphics shaders #4381

Merged
Celegans12 merged 1 commit from upstream-pr/4381 into main 2026-10-13 01:31:54 +00:00
Celegans12 commented 2026-10-12 08:24:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-12T08:24:22Z.


What

The SPIR-V emitter declares extra views of the guest buffers binding when a shader needs them: buffers_coherent for GLC or DLC accesses (#2369) and buffers_u64 for 64-bit atomics. Each is another StorageBuffer variable on the same set and binding, decorated Aliased, which Vulkan allows when the types fit the descriptor.

ShaderValidation, which checks the stages of every draw (compute dispatches are not validated), accepted one StorageBuffer variable per binding with u32 elements only. A vertex, tessellation or pixel shader with a GLC store next to a plain access, or with a 64-bit buffer atomic, was refused at draw time with "duplicate SPIR-V resource binding".

  • A second variable on a binding is accepted when the binding is the guest buffers array and every variable on it is Aliased; an aliased view may hold u64 elements.
  • Every other duplicate is still refused.

PPSA26344 stopped on this at a pixel program (0x80003a6b00). Its shader cache holds 32 graphics programs that declare buffers and buffers_coherent on one binding (26 vertex, 1 hull, 1 domain, 4 pixel), so any draw using one of them was refused.

#4250 and #4085 add 8- and 16-bit views of the same binding; they need the same acceptance for u8 views, which can follow once one of them lands.

Tested

Based on main 1c5e6287. Windows 11 (MinGW-w64 GCC 15.2.0) and Linux: configure -DBUILD_TESTING=ON, full build, --target libs, ctest.

  • Windows, NVIDIA: 1019/1020 tests pass; log_macros also fails on main here.
  • Linux (upstream's job on WSL, lavapipe), merged with main: 1002/1003; agc_driver_depth_compare_copy also fails on main there.

agc_driver_graphics recompiles pixel shaders with a GLC store and with a 64-bit atomic, validates them, and checks that the same modules without Aliased are refused. It fails on main with "duplicate SPIR-V resource binding".

Not tested: console behaviour.

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
  • Unblocks: PPSA26344 #675
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4826803866 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4381). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-12T08:24:22Z. --- ### What The SPIR-V emitter declares extra views of the guest buffers binding when a shader needs them: `buffers_coherent` for GLC or DLC accesses (#2369) and `buffers_u64` for 64-bit atomics. Each is another StorageBuffer variable on the same set and binding, decorated `Aliased`, which Vulkan allows when the types fit the descriptor. `ShaderValidation`, which checks the stages of every draw (compute dispatches are not validated), accepted one StorageBuffer variable per binding with u32 elements only. A vertex, tessellation or pixel shader with a GLC store next to a plain access, or with a 64-bit buffer atomic, was refused at draw time with "duplicate SPIR-V resource binding". - A second variable on a binding is accepted when the binding is the guest buffers array and every variable on it is `Aliased`; an aliased view may hold u64 elements. - Every other duplicate is still refused. PPSA26344 stopped on this at a pixel program (0x80003a6b00). Its shader cache holds 32 graphics programs that declare `buffers` and `buffers_coherent` on one binding (26 vertex, 1 hull, 1 domain, 4 pixel), so any draw using one of them was refused. #4250 and #4085 add 8- and 16-bit views of the same binding; they need the same acceptance for u8 views, which can follow once one of them lands. ### Tested Based on `main` 1c5e6287. Windows 11 (MinGW-w64 GCC 15.2.0) and Linux: configure -DBUILD_TESTING=ON, full build, --target libs, ctest. - Windows, NVIDIA: 1019/1020 tests pass; `log_macros` also fails on `main` here. - Linux (upstream's job on WSL, lavapipe), merged with `main`: 1002/1003; `agc_driver_depth_compare_copy` also fails on `main` there. `agc_driver_graphics` recompiles pixel shaders with a GLC store and with a 64-bit atomic, validates them, and checks that the same modules without `Aliased` are refused. It fails on main with "duplicate SPIR-V resource binding". Not tested: console behaviour. ### 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](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] Unblocks: PPSA26344 #675 - [x] AI-assisted: yes
blawesom commented 2026-10-12 15:07:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-12T15:07:06Z.


Rebase handoff — rebased onto current main, authorship unchanged.

One test-file conflict: main landed the stencil-reference export tests where this PR adds its aliased-buffer-view tests — kept both test families and both calls.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

  • builds; tools/check_conventions.py --base origin/main passes
  • full suite: 957/957 passed

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/4381
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 926492c95.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6126980373 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4381#issuecomment-6126980373). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-12T15:07:06Z. --- **Rebase handoff** — rebased onto current `main`, authorship unchanged. One test-file conflict: main landed the stencil-reference export tests where this PR adds its aliased-buffer-view tests — kept both test families and both calls. Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): - builds; `tools/check_conventions.py --base origin/main` passes - **full suite: 957/957 passed** **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/4381 git checkout <your branch> git merge --ff-only FETCH_HEAD ``` Head is `926492c95`.
oneandonlydean commented 2026-10-13 00:19:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:19:43Z.


Conflicts with main in core/libs/prx/libSceAgcDriver/tests/Graphics.cpp (the stencil-reference export tests landed where this adds its own); please rebase.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6135169598 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4381#issuecomment-6135169598). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-13T00:19:43Z. --- Conflicts with main in `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` (the stencil-reference export tests landed where this adds its own); please rebase.
Celegans12 commented 2026-10-13 00:46:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-13T00:46:43Z.


@oneandonlydean done.
Thanks @blawesom for doing the rebase and running the whole suite on RADV, that's a GPU I can't test here. I've just force-pushed a rebase onto a newer main (1c5e6287) rather than fast-forwarding to your branch, since main had moved again in the meantime. I resolved the Graphics.cpp conflict the same way you did, keeping the stencil-reference export tests and the aliased buffer view tests side by side; the only difference from your 926492c is a stray blank line in main().

On my side the Windows NVIDIA run is 1019/1020 and the Linux job on WSL lavapipe, merged with main, is 1002/1003. The two failures, log_macros on Windows and agc_driver_depth_compare_copy on lavapipe, fail on plain main here as well.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6135521409 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4381#issuecomment-6135521409). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-13T00:46:43Z. --- @oneandonlydean done. Thanks @blawesom for doing the rebase and running the whole suite on RADV, that's a GPU I can't test here. I've just force-pushed a rebase onto a newer `main` (1c5e6287) rather than fast-forwarding to your branch, since `main` had moved again in the meantime. I resolved the `Graphics.cpp` conflict the same way you did, keeping the stencil-reference export tests and the aliased buffer view tests side by side; the only difference from your 926492c is a stray blank line in `main()`. On my side the Windows NVIDIA run is 1019/1020 and the Linux job on WSL lavapipe, merged with `main`, is 1002/1003. The two failures, `log_macros` on Windows and `agc_driver_depth_compare_copy` on lavapipe, fail on plain `main` here as well.
github-actions[bot] commented 2026-10-13 00:54:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T00:54:56Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4584 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp L4078, L5126
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6135672839 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4381#issuecomment-6135672839). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T00:54:56Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #4584 | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` [L4078](https://github.com/boykopovar/AnyPS5/blob/22c30bed2b28d1a1ede116310c0e225d9caf8c80/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp#L4078), [L5126](https://github.com/boykopovar/AnyPS5/blob/22c30bed2b28d1a1ede116310c0e225d9caf8c80/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp#L5126) | | |
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!4381
No description provided.