fix(recompiler): drop a sample-adjust S# dword 3 that sets only reserved bits #7290

Merged
gjonn merged 1 commit from upstream-pr/7290 into main 2026-10-17 23:18:17 +00:00
gjonn commented 2026-10-17 21:34:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-17T21:34:35Z.


What

An image_sample_*_a (sample-adjust) S# whose dword 3 is a runtime value was refused with GetSamplerResource dword 3 is not a valid runtime value when every bit it can set lies in the reserved bits 12-29, unless the value was an OR at the top. canonicalizeSampleAdjustDword3 already drops reserved-only terms from an OR one by one; it now drops the whole dword 3 the same way when the value itself (not only one OR operand) can only set reserved bits, for example a field shifted to bit 12 with nothing else.

PPSA01317 hits this in a pixel shader that issues image_sample_a with S# dword 3 = (constant from the resource table) OR (a 16-bit field of a wave ballot shifted to bit 12). On main the recompiler throws on it; with this change the shader compiles and the title gets past it.

A plain image_sample (no _a) with the same ballot-derived dword 3 is still refused.

Tested

Windows 11, MinGW-w64 GCC, NVIDIA GeForce RTX 5090 Laptop GPU (driver 616.92). Rebased on main at e0fcdb52b.

  • agc_shader_memory (verifyUnnormalizedSamplers): a program whose S# dword 3 is s_lshl_b32 of a masked v_cmp/ballot result, used by image_sample_a, must compile; the same S# used by image_sample must still throw GetSamplerResource dword 3 is not a valid runtime value.
    • With ResourceTracker.cpp reverted to main (test kept): fails with
      GetSamplerResource dword 3 is not a valid runtime value; chain: ShiftLeftLogical32(BitwiseAnd32(CompositeExtractU32x4(Ballot(INotEqual32(Immediate, GetBuiltin(Immediate, Immediate))), Immediate), Immediate), Immediate)
    • With this change: passes.
  • agc_constant_phi: passes.
  • python tools/check_conventions.py --base origin/main and python tools/check_test_registration.py pass.
  • PPSA01317: the pixel shader that main refuses compiles with this change and boot continues past it.

Not tested: AMD, Intel, Linux, macOS.

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: PPSA01317 #4697
  • GPUs tested: NVIDIA GeForce RTX 5090 Laptop GPU, driver 616.92, Windows 11
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4904119460 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7290). Originally posted by [gjonn](https://github.com/gjonn) on 2026-10-17T21:34:35Z. --- ### What An `image_sample_*_a` (sample-adjust) S# whose dword 3 is a runtime value was refused with `GetSamplerResource dword 3 is not a valid runtime value` when every bit it can set lies in the reserved bits 12-29, unless the value was an OR at the top. `canonicalizeSampleAdjustDword3` already drops reserved-only terms from an OR one by one; it now drops the whole dword 3 the same way when the value itself (not only one OR operand) can only set reserved bits, for example a field shifted to bit 12 with nothing else. PPSA01317 hits this in a pixel shader that issues `image_sample_a` with S# dword 3 = (constant from the resource table) OR (a 16-bit field of a wave ballot shifted to bit 12). On `main` the recompiler throws on it; with this change the shader compiles and the title gets past it. A plain `image_sample` (no `_a`) with the same ballot-derived dword 3 is still refused. ### Tested Windows 11, MinGW-w64 GCC, NVIDIA GeForce RTX 5090 Laptop GPU (driver 616.92). Rebased on `main` at e0fcdb52b. - `agc_shader_memory` (`verifyUnnormalizedSamplers`): a program whose S# dword 3 is `s_lshl_b32` of a masked `v_cmp`/ballot result, used by `image_sample_a`, must compile; the same S# used by `image_sample` must still throw `GetSamplerResource dword 3 is not a valid runtime value`. - With `ResourceTracker.cpp` reverted to `main` (test kept): fails with `GetSamplerResource dword 3 is not a valid runtime value; chain: ShiftLeftLogical32(BitwiseAnd32(CompositeExtractU32x4(Ballot(INotEqual32(Immediate, GetBuiltin(Immediate, Immediate))), Immediate), Immediate), Immediate)` - With this change: passes. - `agc_constant_phi`: passes. - `python tools/check_conventions.py --base origin/main` and `python tools/check_test_registration.py` pass. - PPSA01317: the pixel shader that `main` refuses compiles with this change and boot continues past it. Not tested: AMD, Intel, Linux, macOS. ### 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: PPSA01317 #4697 - [x] GPUs tested: NVIDIA GeForce RTX 5090 Laptop GPU, driver 616.92, Windows 11 - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-17 21:54:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T21:54:57Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1341 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 4339 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 5371 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 5500 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 5958 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 6094 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6177 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6222 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6235 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6243 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 6412 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6454 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 6635 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6645 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6946 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6947 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6973 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6987 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6989 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6995 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 7002 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 7193 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 7223 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6241814235 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7290#issuecomment-6241814235). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-17T21:54:57Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 1341](https://www.github.com/boykopovar/AnyPS5/pull/1341) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 4339](https://www.github.com/boykopovar/AnyPS5/pull/4339) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 5371](https://www.github.com/boykopovar/AnyPS5/pull/5371) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 5500](https://www.github.com/boykopovar/AnyPS5/pull/5500) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 5958](https://www.github.com/boykopovar/AnyPS5/pull/5958) | `core/shader/recompiler/Optimization/src/ResourceTracker.cpp` | | [PR 6094](https://www.github.com/boykopovar/AnyPS5/pull/6094) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6177](https://www.github.com/boykopovar/AnyPS5/pull/6177) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6235](https://www.github.com/boykopovar/AnyPS5/pull/6235) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6243](https://www.github.com/boykopovar/AnyPS5/pull/6243) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp`<br>`core/shader/recompiler/Optimization/src/ResourceTracker.cpp` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6454](https://www.github.com/boykopovar/AnyPS5/pull/6454) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp`<br>`core/shader/recompiler/Optimization/src/ResourceTracker.cpp` | | [PR 6635](https://www.github.com/boykopovar/AnyPS5/pull/6635) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6645](https://www.github.com/boykopovar/AnyPS5/pull/6645) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6946](https://www.github.com/boykopovar/AnyPS5/pull/6946) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6973](https://www.github.com/boykopovar/AnyPS5/pull/6973) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6987](https://www.github.com/boykopovar/AnyPS5/pull/6987) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6989](https://www.github.com/boykopovar/AnyPS5/pull/6989) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6995](https://www.github.com/boykopovar/AnyPS5/pull/6995) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 7002](https://www.github.com/boykopovar/AnyPS5/pull/7002) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 7193](https://www.github.com/boykopovar/AnyPS5/pull/7193) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 7223](https://www.github.com/boykopovar/AnyPS5/pull/7223) | `core/shader/recompiler/Optimization/src/ResourceTracker.cpp` |
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!7290
No description provided.