fix(shader): capture image descriptors read from constant buffers at uniform offsets #5188

Merged
EagleBearerYS merged 2 commits from upstream-pr/5188 into main 2026-10-14 09:58:01 +00:00
EagleBearerYS commented 2026-10-13 14:10:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-13T14:10:03Z.


What

Resident Evil Village (PPSA01556, content 01.210.000) stops preparing one of its mesh programs while it creates its PSO cache:

shader 0x2086a1e500 stage 7 (shader_2086a1e500.req): ShaderRecompiler::Recompile: GetImageResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x000002d0(...)

The program reads its T# with s_buffer_load_dwordx8 from 48-byte records, with the T# at +16. The record index comes through two more constant-buffer loads keyed by user data. Everything in the chain is uniform per draw, so the CPU walk can evaluate it.

ResourceTracker::GetHandle refused every T# whose dwords are scalar buffer loads (ReadConstBuffer) before ValidateSource looked at them. Tables with a 32-byte stride and a wave-uniform key are planned as bindless tables before GetHandle runs, so only the other cases hit the refusal: a T# read at an offset the walk can evaluate. ValidateSource (SrtRuntimeValidator) already accepts ReadConstBuffer with uniform operands and refuses the rest. The pre-check is removed, and the walk reads the T# at each capture.

Tested

  • Windows 11, WinLibs GCC 15.2.0 r7, Release, this branch merged into main a252fcd75: agc_shader_memory verifyUniformTableImage.
    • The test is a compute program that reads its T# with s_buffer_load_dwordx8 at s2 * 48 + 16.
    • With main's ResourceTracker.cpp it fails with the title's message: GetImageResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x0000001c(...).
    • With the change, the plan has one ordinary (not bindless) image, and captures with s2 = 2 and s2 = 1 read the T#s of records 2 and 1.
    • agc_shader_memory, agc_shader_bindless, agc_shader_srt_read_patching, agc_shader_frontend_pair, agc_shader_frontend_pair_off and agc_shader_disk_cache pass, also with the other two Resident Evil Village fixes (listed in #5169) merged in.
  • Linux (WSL2 Ubuntu 24.04, GCC 13.3, CI configuration), with the three Resident Evil Village fixes (listed in #5169) merged into main a252fcd75: the same six tests pass.
  • PPSA01556 on Windows 11 (RTX 3070 Laptop GPU), on a local branch past the title's earlier stops (on main it stops at the first frame, #4949): the mesh program prepares, and the PSO cache build continues past it.
  • python3 tools/check_conventions.py --base origin/main: passed.

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: PPSA01556 #5169
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4844517238 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5188). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-13T14:10:03Z. --- ### What Resident Evil Village (PPSA01556, content 01.210.000) stops preparing one of its mesh programs while it creates its PSO cache: ``` shader 0x2086a1e500 stage 7 (shader_2086a1e500.req): ShaderRecompiler::Recompile: GetImageResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x000002d0(...) ``` The program reads its T# with `s_buffer_load_dwordx8` from 48-byte records, with the T# at +16. The record index comes through two more constant-buffer loads keyed by user data. Everything in the chain is uniform per draw, so the CPU walk can evaluate it. `ResourceTracker::GetHandle` refused every T# whose dwords are scalar buffer loads (`ReadConstBuffer`) before `ValidateSource` looked at them. Tables with a 32-byte stride and a wave-uniform key are planned as bindless tables before `GetHandle` runs, so only the other cases hit the refusal: a T# read at an offset the walk can evaluate. `ValidateSource` (`SrtRuntimeValidator`) already accepts `ReadConstBuffer` with uniform operands and refuses the rest. The pre-check is removed, and the walk reads the T# at each capture. ### Tested - Windows 11, WinLibs GCC 15.2.0 r7, Release, this branch merged into `main` a252fcd75: `agc_shader_memory` `verifyUniformTableImage`. - The test is a compute program that reads its T# with `s_buffer_load_dwordx8` at `s2 * 48 + 16`. - With `main`'s `ResourceTracker.cpp` it fails with the title's message: `GetImageResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x0000001c(...)`. - With the change, the plan has one ordinary (not bindless) image, and captures with `s2 = 2` and `s2 = 1` read the T#s of records 2 and 1. - `agc_shader_memory`, `agc_shader_bindless`, `agc_shader_srt_read_patching`, `agc_shader_frontend_pair`, `agc_shader_frontend_pair_off` and `agc_shader_disk_cache` pass, also with the other two Resident Evil Village fixes (listed in #5169) merged in. - Linux (WSL2 Ubuntu 24.04, GCC 13.3, CI configuration), with the three Resident Evil Village fixes (listed in #5169) merged into `main` a252fcd75: the same six tests pass. - PPSA01556 on Windows 11 (RTX 3070 Laptop GPU), on a local branch past the title's earlier stops (on `main` it stops at the first frame, #4949): the mesh program prepares, and the PSO cache build continues past it. - `python3 tools/check_conventions.py --base origin/main`: passed. ### 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: PPSA01556 #5169 - [x] AI-assisted: yes
mrfelek commented 2026-10-14 10:00:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mrfelek on 2026-10-14T10:00:40Z.


Data point from another title. Marvel's Wolverine (PPSA03671, 01.001.005), Linux, RTX 3080 Ti (NVIDIA 615.71.09): on main 43349d433 with a local patch that drops draws and dispatches whose shader fails, 36 shaders failed with GetImageResource dword 0 is not a valid runtime value (chain: ReadConstBuffer(GetBufferResource(ReadConst(GetSrtResource, ...)))). With this PR merged on top (together with #5620, #5550 and #5473), those 36 go to 0 in the same scene and shader cache fresh. The shaders then stop at the next limit instead: bindless storage image tables are unsupported (13) and static bindless image capacity exceeded (4). The picture does not change yet, because 105 other shaders fail on GetSamplerResource (a sampler read the same way). More in https://github.com/boykopovar/AnyPS5/discussions/5516.

AI-assisted; the runs are from my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6165794054 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5188#issuecomment-6165794054). Originally posted by [mrfelek](https://github.com/mrfelek) on 2026-10-14T10:00:40Z. --- Data point from another title. Marvel's Wolverine (PPSA03671, 01.001.005), Linux, RTX 3080 Ti (NVIDIA 615.71.09): on `main` 43349d433 with a local patch that drops draws and dispatches whose shader fails, 36 shaders failed with `GetImageResource dword 0 is not a valid runtime value` (chain: `ReadConstBuffer(GetBufferResource(ReadConst(GetSrtResource, ...)))`). With this PR merged on top (together with #5620, #5550 and #5473), those 36 go to 0 in the same scene and shader cache fresh. The shaders then stop at the next limit instead: `bindless storage image tables are unsupported` (13) and `static bindless image capacity exceeded` (4). The picture does not change yet, because 105 other shaders fail on `GetSamplerResource` (a sampler read the same way). More in https://github.com/boykopovar/AnyPS5/discussions/5516. AI-assisted; the runs are from my machine.
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!5188
No description provided.