fix(shader): read relative SGPRs through a one-hot mux #928
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/928"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-06T18:09:24Z.
What
s_movrels_b32/b64ands_movrelsd_2_b32read their source SGPR through a chain of selects keyed on the M0 offset. The relative destination write is a select between that value and the old register. When the old register also appears in the read chain, the NVIDIA shader compiler (RTX 5080, driver 610.74) gets the nesting wrong:In
agc_driver_scalar_sop1this mades_movrelsd_2_b32overwrite s13 with s8 in every lane whose source offset was 3. The SPIR-V is valid and the translation is correct. Rewriting the select with inverted conditions, a branch with a phi, a masked xor or a small function-local array all fold back into the same wrong result.The change builds the relative read as an OR of
select(offset == k, s[base + k], 0)terms. Offsets outside[1, count)still read the base register, as before. The result is the same, and the nesting the compiler mishandles no longer forms.Tested
Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 610.74), MinGW-w64 GCC 15.2.0.
ctest -R "agc_|spirv|recompiler"(174 tests):agc_driver_scalar_sop1failed before, everything passes now.agc_shader_replay --spvover 110 captured recompile requests (GTA V, Demon's Souls and others) gives byte-identical SPIR-V before and after (none of them uses a scalar relative-source move).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-06T20:04:57Z.
Tested on Linux with NVIDIA as well, since the PR was verified on Windows only.
mainat5895ea72:agc_driver_scalar_sop1fails withlane 3 movrelsd_2_b32 s13 is 0x00007fff, expected 0xd4cbd76dmain+ this PR (177a452c): passes in 3 of 3 runs. Full ctest (359 tests, with #833 also merged) passes.The miscompile is also present in the 595 Linux driver, not only 610.x on Windows.
Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-07T08:17:27Z.
@fisherjoey thanks for checking on Linux. Good to know the 595 driver has the same miscompile, so it's not a Windows-only or 610-only thing.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T09:16:33Z.
Checked the new mux against main's select chain for every offset (0, in range, out of range, base = last SGPR), the s_movrels_b32/b64 and s_movrelsd_2_b32 forms on the HW oracle (gfx1035, incl. src = dst = 3), full ctest on RADV and
agc_driver_scalar_sop1on CI's lavapipe; NVIDIA confirmed by @fisherjoey. Merging.