fix(shader): test an empty exec mask in s_subvector_loop_begin with one compare #7623
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7623"
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 thuanquang on 2026-10-18T17:43:25Z.
What
s_subvector_loop_beginskips the loop when the whole wave64 exec mask is zero. The recompiler tested that as two 32-bit compares joined by a logical and:exec_lo == 0 && exec_hi == 0. It now tests it as one compare:(exec_lo | exec_hi) == 0. It is the same condition, andenteredand the newexec_histill useexec_lo == 0as before.AMD's Windows driver compiles the two-compare form wrongly once the guest's exec mask comes from a loaded value. This is the
agc_driver_subvector_loopfailure in #7376 (lane 0 exec hi after the loop is 0, expected 4294967295). #7351 hides it by keepingrobustBufferAccess2off on that driver. With the single compare, the test passes on that driver withrobustBufferAccess2on. The exclusion stays: the two layered-volume failures in #7351 are a separate question (#7376), so this PR does not change which devices get the feature. The debt entry for the guest memory load guards now records thatsubvector_loopis no longer one of the failures.The pipeline's ISA, read back with
VK_KHR_pipeline_executable_properties, shows where it goes wrong. Case "initial exec high half": the guestv_cmpxleavesexec_lo0 andexec_hiset.target.robustBufferAccess2 = false(test passes): the low and high halves are tested separately.target.robustBufferAccess2 = true(test fails): the load's lane guard is now ans_and_b64in the same block. Bothexec_lo == 0andexec_hi == 0are taken from that instruction's SCC, which says whether all 64 bits are zero. Soexec_lo == 0comes out false, andexec_hiafter the begin instruction is selected to 0 (s_cselect_b32 s22, 0, s5).robustBufferAccess2on (test passes):exec_lo == 0is a 32-bit compare again, and the empty-mask test iss_or_b32plus a compare.The two SPIR-V modules differ only around the guest load: a selection in one, an
OpSelectover a guarded index in the other, as @Mouad-Scriptz-0 found on #7376. The begin instruction's ops are the same, and both modules passspirv-val --target-env vulkan1.3.Tested
Windows 11 26200, AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON,ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,APS5_NO_PIPELINE_JOURNAL=1. Eachsubvector_looprun used a renamed copy of the test executable, so AMD's per-executable pipeline cache started empty:agc_driver_subvector_looponmain218aa8f00, withRobustBufferAccess2Usablechanged locally to returntrue(that change is not part of this PR):lane 0 exec hi after the loop is 0, expected 4294967295;agc_driver_subvector_loopwith this change and the exclusion kept, as merged: passes.The three ISA listings above come from
main3e3e8b905, read back through a local capture hook that is not part of this PR.Full
ctest --parallel 4 --timeout 120onmain3e3e8b905, with an earlier form of this change that also kept the now unusedexec_hi == 0compare, androbustBufferAccess2forced on: 1479 tests. These fail:agc_driver_lds_mixed_width_atomics(#6976),agc_driver_lds_lock_budget(#7344), andhardware_oracle_compare, which times out on this machine's Python startup;agc_driver_layered_volume_drawandagc_driver_layered_volume_vertex, the cache-order failures described on #7376;agc_robust_buffer_access, whose table expects AMD to be excluded.agc_driver_subvector_loopandagc_driver_layered_volume_vertex_no_gplpass.AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001, Windows 11 26300), run by @LeandroLP23 on
mainc3591adf9with this PR and six others merged (comment):agc_driver_subvector_loop,agc_driver_layered_volume_draw,agc_driver_layered_volume_vertex,agc_driver_lds_lock_budget,agc_driver_lds_mixed_width_atomicsandagc_robust_buffer_accesspass 3 of 3;RobustBufferAccess2Usableforced totrue, from renamed copies of the test executables:agc_driver_subvector_loop,agc_driver_layered_volume_draw(with and without--vertex-only) andagc_driver_lds_mixed_width_atomics --lock-budgetpass 2 of 2;agc_driver_layered_volume_vertex_no_gplfails there the same way onmain(#5271), so it is not from this PR. That driver did not show thesubvector_loopfailure before this change either (#7376), so this run shows no regression on a second AMD driver, not the fix itself.Not run: the full suite on
218aa8f00.python tools/check_conventions.py --base origin/mainwith this title and body passes.NVIDIA RTX 3070 (595.99.02, Ubuntu 26.04), run by @jotitadev on
f65b4bbe9merged ontomain84c1a4d9a:agc_driver_subvector_looppasses 3 runs, and passes withmain's two-compare form too, so the miscompile is specific to AMD's Windows driver.Not tested: AMD drivers other than these two, and Intel hardware runs of
subvector_loopwith this change. CI's lavapipe skips that test because its subgroup is too small.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T17:52:57Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/debt/shader.mdL171docs/dev/debt/shader.mdL171docs/dev/debt/shader.mdL171docs/dev/debt/shader.mdL171docs/dev/debt/shader.mdL171Some 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.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.mdImported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T18:06:14Z.
Another AMD driver, since the description lists other AMD drivers as not tested. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON. Build:mainc3591adf9with #7623, #7612, #7611, #7603, #7579, #7563 and #7541 merged together (each merge clean, built once).robustBufferAccess2still off on AMD's proprietary driver):agc_driver_subvector_loop,agc_driver_layered_volume_draw,agc_driver_layered_volume_vertex,agc_driver_lds_lock_budget,agc_driver_lds_mixed_width_atomicsandagc_robust_buffer_accesspass 3 runs of 3. The one failure in the list,agc_driver_layered_volume_vertex_no_gpl, which fails the same way onmainhere (#5271), is not from this PR.RobustBufferAccess2Usableforced totrue, from renamed copies of the test executables so the driver cache starts empty:agc_driver_subvector_loop,agc_driver_layered_volume_draw(with and without--vertex-only) andagc_driver_lds_mixed_width_atomics --lock-budget(robustBufferAccess2=1) pass, 2 runs of 2.This driver didn't show the
subvector_loopfailure before either (#7376), so this shows no regression on a second AMD driver, not the fix itself.AI-assisted
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T19:00:19Z.
The Radeon 860M follow-up is useful additional coverage: it passes the six listed tests 3/3 with the AMD exclusion in place, and the forced-
truesubvector/volume/lock-budget cases pass 2/2 from renamed executables. Could you add this GPU and OS/driver to theGPUs testedchecklist and note thatagc_driver_layered_volume_vertex_no_gplis a #5271 main failure? The current checklist lists only the RX 6700 XT.Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-18T19:38:48Z.
@MarcZX10 Added: @LeandroLP23's Radeon 860M run is under Tested and on the
GPUs testedline, withagc_driver_layered_volume_vertex_no_gplnoted as the #5271 failuremainhas on that machine.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-19T00:27:52Z.
Review: COMMENTED
An NVIDIA run of
agc_driver_subvector_loop, since NVIDIA is listed under "Not tested" and CI's lavapipe skips the test.Machine: Ubuntu 26.04, i7-8700, GCC 15.2, Release,
BUILD_TESTING=ON. NVIDIA GeForce RTX 3070 (driver 595.99.02; it reportsrobustBufferAccess2, and only the AMD Windows driver is excluded from it) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same host. PR merged ontomain84c1a4d9a(clean).ANYPS5_NO_SHADER_CACHE=1,-j1 --timeout 30.agc_driver_subvector_loopf65b4bbe9ControlFlowInstructions.cppfrommain(two compares)So the single compare gives the same result on NVIDIA, and NVIDIA's compiler handles the two-compare form correctly too. The
exec_lo/exec_himiscompile looks specific to AMD's Windows driver, as described.Not run: Windows, AMD, Intel, the layered-volume tests from #7351.
GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T23:43:44Z.
Checked the diff:
(exec_lo | exec_hi) == 0is the same condition as the two compares,enteredandexec_hiare unchanged, and the debt entry now matches. Covered by the existingagc_driver_subvector_loop, with the AMD 6700 XT / 860M and NVIDIA 3070 runs in the thread; merged.