fix(shader): retain adjacent anchor byte loads on RADV #7829
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7829"
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 JJenkx on 2026-10-19T09:23:46Z.
What
On RX 6650 XT / RADV,
agc_driver_bda_deviceon current main fails the anchored 16-bit read comparison. The optimized anchor path can return a different halfword from the checked lookup path. Keep the two adjacent physical byte loads volatile for 16-bit anchored reads, retaining the original masks for single-byte reads and the existing bounds/fallback logic.Adds small uniform-lane and mixed direct/fallback halfword cases before the original boundary, permission, overlap and overflow comparisons. Records the workaround and unresolved driver transformation in shader debt. This is the previously validated follow-up from fork PR #67, isolated from the anchor optimization that has since merged. No title performance or bring-up gain is claimed.
Tested
Linux 7.2.9-arch1-1, GCC, RX 6650 XT / RADV Mesa 26.2.4-arch1.1, same machine and current-main base
8816fd772005585886f19b3f6c13a99931e41241.agc_driver_bda_devicefails at anchor0x7fff12340101, offset 0, immediate -1, 16 bits. A temporary diagnostic reports first differing output word 4: lookup 41376 (0xa1a0), anchor 160 (0x00a0). That diagnostic is excluded from this patch.ctest --test-dir build-full --output-on-failure -R '^(agc_driver_bda_device|agc_driver_graphics|agc_shader_memory)$': 3/3 passed, 5.19 seconds, no CTest skips. The physical Radeon executes the hardware readback section.python3 tools/check_conventions.py --base origin/mainandgit diff origin/main --checkpass.Our own Windows execution, other physical GPUs beyond the independent Windows reports below, title runtime on this isolated patch and full hosted CI have not been tested. The cause inside the driver remains unisolated; this is a measured workaround, not a claim about PS5 halfword semantics.
Independent Windows validation reported by @LeandroLP23 (full report): AMD Radeon 860M (RDNA 3.5), AMD Windows driver 32.0.13058.8001, Windows 11 (reported by @LeandroLP23); WinLibs GCC 15.2.0, Release,
ANYPS5_NO_SHADER_CACHE=1. With the PR head merged into main118266aec,agc_driver_bda_device,agc_driver_graphicsandagc_shader_memorypass 3/3. The same three also pass with main'sSpirvBdaRead.cppand this PR's tests: the RADV anchor mismatch does not reproduce on that Windows driver. These are the tester's results; they show no regression on this tested driver.Independent discrete RDNA 2 Windows validation by @thuanquang (full report): RX 6700 XT (gfx1031), AMD Windows driver 32.0.21045.5002, Windows 11 26200, WinLibs GCC 15.2.0 r7, Release, full builds on main
54e4adde5. Main with only this PR'sBdaExecution.cppand main'sSpirvBdaRead.cpppasses the three core BDA/graphics/shader-memory tests; the anchored halfword mismatch does not reproduce. The tester also reports the patched variant passing, including the anchor/span/native-depth cases. This supports a driver/compiler distinction within RDNA 2 rather than a hardware-family-wide failure; it does not isolate the responsible transformation. Test counts for the expanded selection are not inferred from the comment.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T09:37:39Z.
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.
docs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/src/SpirvBdaRead.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdImported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-19T10:44:05Z.
AMD's own Windows driver, as a non-RADV check. AMD Radeon 860M (RDNA 3.5,
1002:1114), driver 32.0.13058.8001, Windows 11, WinLibs GCC 15.2.0, Release,ANYPS5_NO_SHADER_CACHE=1. Head merged intomain118266aec(clean merge). "Main's sources" means this PR's test files overmain's other files.agc_driver_bda_device,agc_driver_graphicsandagc_shader_memorypass 3 of 3.main'sSpirvBdaRead.cpp, all three also pass.agc_driver_bda_devicedoesn't show the anchor mismatch you see on RADV.So the case is RADV-specific, as the title says, and the change doesn't break this driver.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-19T12:33:44Z.
A discrete RDNA 2 card on AMD's own Windows driver, to help separate an RDNA 2 cause from a RADV one: RX 6700 XT (gfx1031, same family as the RX 6650 XT), driver 32.0.21045.5002, Windows 11 26200, WinLibs GCC 15.2.0 r7, Release,
main54e4adde5, full builds.mainwith only this PR'sBdaExecution.cpp(main'sSpirvBdaRead.cpp):agc_driver_bda_device,agc_driver_graphicsandagc_shader_memorypass 3 of 3. The anchored 16-bit mismatch does not reproduce here.main+ this PR: those three plusagc_driver_bda_anchor_reads,agc_driver_bda_span_readsandagc_driver_native_depth_bda_clearpass 3 of 3.So with the same RDNA 2 hardware family, the wrong halfword shows up under RADV and not under AMD's Windows compiler, which points at RADV's transformation rather than the hardware, consistent with the 860M result. No regression from the change on this driver.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T14:06:32Z.
Re-checked against current main (including #6373 and #7628): the merge is clean, the 16-bit anchored read keeps the volatile access mask while 1-byte and 32-bit paths are untouched, and the new halfword cases and debt entry still apply; merged.