Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Celegans12:fix/agc-aliased-buffer-views
Oct 13, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Celegans12:fix/agc-aliased-buffer-views

Conversation

@Celegans12

@Celegans12 Celegans12 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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 1c5e628. 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 Ghost of Yōtei (PPSA26344) #675
  • AI-assisted: yes

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed agc libSceAgc* labels Oct 12, 2026
@blawesom

Copy link
Copy Markdown
Contributor

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 oneandonlydean self-assigned this Oct 12, 2026
The SPIR-V emitter declares extra views of the guest buffers binding:
buffers_coherent for GLC or DLC accesses (boykopovar#2369) and buffers_u64 for
64-bit atomics. Each is another StorageBuffer variable on the same set
and binding, decorated Aliased, which Vulkan allows.

ShaderValidation, which checks the stages of every draw, accepted one
StorageBuffer variable per binding with u32 elements only, so such a
graphics shader was refused with "duplicate SPIR-V resource binding".

A second variable is now accepted when the binding is the guest buffers
array and every variable on it is Aliased; an aliased view may hold u64
elements. Other duplicates are still refused. agc_driver_graphics
validates pixel shaders with a GLC store and a 64-bit atomic, and checks
that the same modules without Aliased are refused.
@oneandonlydean

Copy link
Copy Markdown
Collaborator

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
Celegans12 force-pushed the fix/agc-aliased-buffer-views branch from 3f3e3bf to d644c31 Compare October 13, 2026 00:46
@Celegans12

Celegans12 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor Author

@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 (1c5e628) 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

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

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

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@oneandonlydean
oneandonlydean merged commit 0c3dc9c into boykopovar:main Oct 13, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants