fix(shader): plan masked descriptor table offsets with addends #23778

Merged
Serph91P merged 2 commits from upstream-pr/23778 into main 2026-11-27 10:56:45 +00:00
Serph91P commented 2026-11-19 16:30:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Serph91P on 2026-11-19T16:30:16Z.


What

Preserve an outer constant addend when matching a masked runtime descriptor-table offset. The affine matcher already handles constant addends; the masked fallback previously received the entire addition and rejected the expression before planning the table. Reuse SplitImmediateAddend for that fallback and keep the existing table bounds and unsupported-path behavior.

Synthetic cases check sampler and pointer-backed image tables, the selected records and descriptor words, and an out-of-range sampler start. This PR does not add border-color-table or presentation changes. Refs #21586; that issue remains open as the title tracker.

Overlap

Tested

  • Release, SPIRV-Tools enabled, CachyOS Linux, Ryzen 7 5800X3D. Compared abc3e4a692 (main) and b101272a42 (this PR) with ctest --test-dir build -R '^agc_shader_bindless$' -V and ctest --test-dir build -R '^agc_driver_image_table_reuse_records$' -V: both tests passed on both revisions.
  • Earlier test-only run on a1c0fea96c: agc_shader_bindless failed on GetSamplerResource dword 0 is not a valid runtime value for a masked sampler offset with an outer addend. The same test passed with the patch. This is the synthetic sampler case, not the Windows title log.
  • Both sides used ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer. The hardware test loaded Khronos validation 1.4.363 on both sides and neither run reported validation warnings, errors or VUIDs. The synthetic shader test does not initialize a Vulkan instance.
  • Independent Linux/NVIDIA verification: both focused tests passed on 40206fe50d and with this PR head merged into it, with the validation layer inserted for the driver test and no VUIDs. The new sampler case failed with the planner from main.
  • Windows/NVIDIA title comparison: Ragnarök PPSA08330 on a local integration based on 9b377461ec, testing the fix commit fc1fec142f before the main sync. The reported descriptor error dropped from 170 shaders to zero across both index forms, and the title began presenting. Captured frames remained black. This was not a title test on the exact PR head. No gameplay or performance claim.

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 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 7900 XTX (RADV Mesa 26.2.6-arch3.1, CachyOS Linux); NVIDIA GeForce RTX 4090 (620.70.06, Arch Linux); NVIDIA GeForce RTX 3060 Laptop GPU (621.24, Windows 11, fix commit only)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5398857339 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23778). Originally posted by [Serph91P](https://github.com/Serph91P) on 2026-11-19T16:30:16Z. --- ### What Preserve an outer constant addend when matching a masked runtime descriptor-table offset. The affine matcher already handles constant addends; the masked fallback previously received the entire addition and rejected the expression before planning the table. Reuse `SplitImmediateAddend` for that fallback and keep the existing table bounds and unsupported-path behavior. Synthetic cases check sampler and pointer-backed image tables, the selected records and descriptor words, and an out-of-range sampler start. This PR does not add border-color-table or presentation changes. Refs #21586; that issue remains open as the title tracker. ### Overlap - #9457 changes the fallback block for fixed offsets and pointer chasing. [Its author confirmed either landing order](https://github.com/boykopovar/AnyPS5/pull/9457#issuecomment-6919499153); the stacked follow-ups can preserve the addend when they sync with `main`. - #7684 changes the same call to return a record mask for range bounds. [The two changes can coexist](https://github.com/boykopovar/AnyPS5/pull/7684#issuecomment-6919309607): pass the offset with the addend split out and keep the record-mask output. - [Maintainer coordination in #21586](https://github.com/boykopovar/AnyPS5/issues/21586#issuecomment-7014382896): open the standalone addend fix first. This PR requires neither change. Any later merge order is subject to review and CI. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> - Release, SPIRV-Tools enabled, CachyOS Linux, Ryzen 7 5800X3D. Compared `abc3e4a692` (main) and `b101272a42` (this PR) with `ctest --test-dir build -R '^agc_shader_bindless$' -V` and `ctest --test-dir build -R '^agc_driver_image_table_reuse_records$' -V`: both tests passed on both revisions. - Earlier test-only run on `a1c0fea96c`: `agc_shader_bindless` failed on `GetSamplerResource dword 0 is not a valid runtime value` for a masked sampler offset with an outer addend. The same test passed with the patch. This is the synthetic sampler case, not the Windows title log. - Both sides used `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer`. The hardware test loaded Khronos validation 1.4.363 on both sides and neither run reported validation warnings, errors or VUIDs. The synthetic shader test does not initialize a Vulkan instance. - [Independent Linux/NVIDIA verification](https://github.com/boykopovar/AnyPS5/pull/23778#issuecomment-7018573418): both focused tests passed on `40206fe50d` and with this PR head merged into it, with the validation layer inserted for the driver test and no VUIDs. The new sampler case failed with the planner from main. - [Windows/NVIDIA title comparison](https://github.com/boykopovar/AnyPS5/pull/23778#issuecomment-7019207316): Ragnarök PPSA08330 on a local integration based on `9b377461ec`, testing the fix commit `fc1fec142f` before the main sync. The reported descriptor error dropped from 170 shaders to zero across both index forms, and the title began presenting. Captured frames remained black. This was not a title test on the exact PR head. No gameplay or performance claim. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) 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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: AMD Radeon RX 7900 XTX (RADV Mesa 26.2.6-arch3.1, CachyOS Linux); NVIDIA GeForce RTX 4090 (620.70.06, Arch Linux); NVIDIA GeForce RTX 3060 Laptop GPU (621.24, Windows 11, fix commit only) <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-11-19 16:44:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T16:44:21Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the reviewed code and added synthetic cases support merging.

What I ran

Reviewed head b101272a4206ab1a3613903f71064ffde5c06af1. I read the prepared description, commit list, manifest and diff, plus targeted ranges of ResourceTracker.cpp. No tests or builds were run.

Results

Check Result Note
Change review passed Addend is split before masked-offset matching.
Tests in this review not run Author-reported tests are not independently verified.

Findings

Blocking

None.

Non-blocking

None.

Not verified

core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp is listed as changed but its full text was excluded from the review folder because it was too large; I did not read it through the repository reader. The code paths and behavior of those added tests are therefore not independently verified. Tests and build were not run. The author reports Linux test runs; Windows/NVIDIA and gameplay remain unverified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5979343383 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23778#pullrequestreview-5979343383). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T16:44:21Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the reviewed code and added synthetic cases support merging. ## What I ran Reviewed head `b101272a4206ab1a3613903f71064ffde5c06af1`. I read the prepared description, commit list, manifest and diff, plus targeted ranges of `ResourceTracker.cpp`. No tests or builds were run. ## Results | Check | Result | Note | |---|---|---| | Change review | passed | Addend is split before masked-offset matching. | | Tests in this review | not run | Author-reported tests are not independently verified. | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` is listed as changed but its full text was excluded from the review folder because it was too large; I did not read it through the repository reader. The code paths and behavior of those added tests are therefore not independently verified. Tests and build were not run. The author reports Linux test runs; Windows/NVIDIA and gameplay remain unverified. ## 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!23778
No description provided.