fix(shader): plan an image table for a T# read at a first-lane offset #10228

Merged
mrfelek merged 2 commits from upstream-pr/10228 into main 2026-10-27 23:56:16 +00:00
mrfelek commented 2026-10-23 14:52:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mrfelek on 2026-10-23T14:52:57Z.


What

A compute shader that reads a T# with s_buffer_load_dwordx8 at an offset taken from v_readfirstlane_b32, without a waterfall loop, stopped with "GetImageResource dword 0 is not a valid runtime value". TryMakeTableColumn only accepted an offset of the form key << n, key * n (+ n) or a masked one. In these shaders the lane value is scaled before the read (v_lshlrev_b32 by 5, then v_lshl_add_u32 x, 1, x for a 96-byte record) and merged across divergent branches:

v_lshlrev_b32  v8, 5, v8
v_lshl_add_u32 v8, v8, 1, v8
v_readfirstlane_b32 vcc_hi, v8
s_buffer_load_dwordx8 s[56:63], s[36:39], vcc_hi
image_sample_lz v[8:10], v[85:86], s[56:63], s[20:23]

A first-lane offset whose value is a known multiple of a dword stride is now planned as an unkeyed table column with that stride. The multiple is found through shifts, multiplies by immediates, sums of one scaled value ((x << 1) + x), selects, Phis, and the selects that the read's active mask implies. A record whose words are not a T# faults when it is selected, as for other unkeyed tables.

Tested

  • Ubuntu 24.04 (cloud, no GPU): the two PPSA26344 compute shaders 0x80001f1100 and 0x8000139c00 (requests from a run's log) fail resource analysis on main and prepare with this change (agc_shader_replay --prepare: 1,782,989 and 2,358,152 SPIR-V words).
  • New --bindless case verifyImageTableFirstLaneScale: a 96-byte-stride table read through v_lshlrev_b32 + v_lshl_add_u32 + v_readfirstlane_b32 is planned with stride 96 and maps its four records. An unscaled first-lane offset is still refused. The case fails on main.
  • ctest -R "agc_shader_|image_table" (40 tests): 33 pass, 7 Vulkan tests skip without a GPU.
  • GPU (NVIDIA GeForce RTX 3080 Ti, driver 615.71.09, Ubuntu 26.10, kernel 7.3), main 4997726a5 vs this change, validation layer on, no shader cache, Vulkan required: ctest -R "agc_shader_|image_table" 39/39 pass on both, nothing skipped, no VUID messages on either. verifyImageTableFirstLaneScale passes with the change.
  • PPSA26344, cold run with an empty shader cache per arm: on main 0x80001f1100, 0x8000139c00 and 0x800037fe00 stop with "not a valid runtime value"; with this change only 0x800037fe00 does (the per-lane form, not covered here). No image-table faults on either. Both later stop on the existing "blending unclamped normalized color is not implemented" exception (same registers on main), which this change reaches sooner.

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
  • Fixes: none
  • Unblocks: PPSA26344 #675
  • GPUs tested: NVIDIA GeForce RTX 3080 Ti, driver 615.71.09, Ubuntu 26.10
  • AI-assisted: yes

Related: #7459 (same error; this covers the first-lane table form only). #8077, #6488 and the nested-table stack (#7395 ... #9790) were replayed on these two shaders and do not cover this form. #10193 (Celegans12, device image table) reads such a T# through the device image lookup only with APS5_GPU_PATH and APS5_KEEP_UNEXPECTED_DEVICE_IMAGES; with its defaults the refusal stays. This change plans it on the default CPU table path.

AI-assisted. Tested by me on my own machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4984671409 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10228). Originally posted by [mrfelek](https://github.com/mrfelek) on 2026-10-23T14:52:57Z. --- ### What A compute shader that reads a T# with `s_buffer_load_dwordx8` at an offset taken from `v_readfirstlane_b32`, without a waterfall loop, stopped with "GetImageResource dword 0 is not a valid runtime value". `TryMakeTableColumn` only accepted an offset of the form `key << n`, `key * n` (+ n) or a masked one. In these shaders the lane value is scaled before the read (`v_lshlrev_b32` by 5, then `v_lshl_add_u32 x, 1, x` for a 96-byte record) and merged across divergent branches: ``` v_lshlrev_b32 v8, 5, v8 v_lshl_add_u32 v8, v8, 1, v8 v_readfirstlane_b32 vcc_hi, v8 s_buffer_load_dwordx8 s[56:63], s[36:39], vcc_hi image_sample_lz v[8:10], v[85:86], s[56:63], s[20:23] ``` A first-lane offset whose value is a known multiple of a dword stride is now planned as an unkeyed table column with that stride. The multiple is found through shifts, multiplies by immediates, sums of one scaled value (`(x << 1) + x`), selects, Phis, and the selects that the read's active mask implies. A record whose words are not a T# faults when it is selected, as for other unkeyed tables. ### Tested - Ubuntu 24.04 (cloud, no GPU): the two PPSA26344 compute shaders 0x80001f1100 and 0x8000139c00 (requests from a run's log) fail resource analysis on main and prepare with this change (`agc_shader_replay --prepare`: 1,782,989 and 2,358,152 SPIR-V words). - New `--bindless` case `verifyImageTableFirstLaneScale`: a 96-byte-stride table read through `v_lshlrev_b32` + `v_lshl_add_u32` + `v_readfirstlane_b32` is planned with stride 96 and maps its four records. An unscaled first-lane offset is still refused. The case fails on main. - `ctest -R "agc_shader_|image_table"` (40 tests): 33 pass, 7 Vulkan tests skip without a GPU. - GPU (NVIDIA GeForce RTX 3080 Ti, driver 615.71.09, Ubuntu 26.10, kernel 7.3), main 4997726a5 vs this change, validation layer on, no shader cache, Vulkan required: `ctest -R "agc_shader_|image_table"` 39/39 pass on both, nothing skipped, no VUID messages on either. `verifyImageTableFirstLaneScale` passes with the change. - PPSA26344, cold run with an empty shader cache per arm: on main 0x80001f1100, 0x8000139c00 and 0x800037fe00 stop with "not a valid runtime value"; with this change only 0x800037fe00 does (the per-lane form, not covered here). No image-table faults on either. Both later stop on the existing "blending unclamped normalized color is not implemented" exception (same registers on main), which this change reaches sooner. ### 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] Fixes: none - [x] Unblocks: PPSA26344 #675 - [x] GPUs tested: NVIDIA GeForce RTX 3080 Ti, driver 615.71.09, Ubuntu 26.10 - [x] AI-assisted: yes Related: #7459 (same error; this covers the first-lane table form only). #8077, #6488 and the nested-table stack (#7395 ... #9790) were replayed on these two shaders and do not cover this form. #10193 (Celegans12, device image table) reads such a T# through the device image lookup only with `APS5_GPU_PATH` and `APS5_KEEP_UNEXPECTED_DEVICE_IMAGES`; with its defaults the refusal stays. This change plans it on the default CPU table path. AI-assisted. Tested by me on my own machine.
MarcZX10 commented 2026-10-23 14:54:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T14:54:59Z.

Review: CHANGES_REQUESTED


The current head is not ready for approval based on the repository's required checks:

  • The hosted conventions check fails on this exact head because the PR checklist still says GPUs tested: TODO (NVIDIA RTX 3080 Ti, driver ..., Ubuntu 26.10). Please replace the placeholder with the actual vendor, model, driver and OS if that run has happened, or report not tested accurately and leave the checklist consistent with the required GPU validation.
  • This changes the shader recompiler. CONTRIBUTING.md requires the focused tests on both main and the change with VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1 and ctest -V, including a comparison of new VUID- errors and the GPU details. The PR currently reports seven Vulkan tests skipped without a GPU and the required GPU run as TODO. Please add that comparison when available; the reported cloud resource-analysis tests and non-Vulkan test coverage are useful but do not exercise the required Vulkan validation path.

I have not run the shader tests locally or independently validated the resource analysis, so this review is based on the hosted check and the stated test report.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5630074521 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10228#pullrequestreview-5630074521). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T14:54:59Z. **Review:** CHANGES_REQUESTED --- The current head is not ready for approval based on the repository's required checks: - The hosted `conventions` check fails on this exact head because the PR checklist still says `GPUs tested: TODO (NVIDIA RTX 3080 Ti, driver ..., Ubuntu 26.10)`. Please replace the placeholder with the actual vendor, model, driver and OS if that run has happened, or report `not tested` accurately and leave the checklist consistent with the required GPU validation. - This changes the shader recompiler. `CONTRIBUTING.md` requires the focused tests on both `main` and the change with `VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1` and `ctest -V`, including a comparison of new `VUID-` errors and the GPU details. The PR currently reports seven Vulkan tests skipped without a GPU and the required GPU run as TODO. Please add that comparison when available; the reported cloud resource-analysis tests and non-Vulkan test coverage are useful but do not exercise the required Vulkan validation path. I have not run the shader tests locally or independently validated the resource analysis, so this review is based on the hosted check and the stated test report.
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!10228
No description provided.