fix(shader): leave pixel helpers out of EXEC values only where ballots skip them #12458
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12458"
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 QRMOE on 2026-10-28T14:35:40Z.
What
Re-lands the helper-lane waterfall fix from #11199 (reverted by #12298) without the part that broke derivatives on NVIDIA.
#11199 cleared helper invocations from every pixel-stage ballot. NVIDIA's helpers take part in ballots and run, so that filter handed them compare-mask bits and saved EXEC values the console's helpers would not get, and PPSA21564 showed lines along triangle edges (@oneandonlydean's report on #11199). This PR leaves ballots alone and changes three things:
hostExecWord:s_mov_b64 sN, exec, the saveexec copy, ALU sources) is masked by the plain host ballot instead of its whole-quad expansion. On a driver that keeps helpers out of ballots (AMD's Windows driver: RX 9070 XT here, and the RDNA2 iGPU in @wachi35676's run on #11199), a helper thats_wqmput into EXEC is no longer in the value, so a waterfall over EXEC (s_ff1,v_readlane_b32,v_cmp,s_andn2_b64) ends instead of looping on a bit that no compare can clear (#11052). Where helpers take part in ballots, the plain ballot already holds the whole quad, so the value is the same as onmain.s_mov_b64of a mask operand and thes_*_saveexeccopy store each lane's own EXEC bit, and writing EXEC back from that copy uses it, so a restored helper is switched back on whatever the driver does with ballots. Other stages keep the word copy, because there the per-lane bit would hide that lanes 32-63 of a wave64 on a 32-lane host are 0, which the vertex half-wave reduction proof inagc_shader_memoryrelies on.s_mov_b32and the 32-bit scalar logic ops (s_and_b32,s_or_b32,s_andn2_b32, ...) on SGPR masks combine the sources' lane bits, as the 64-bit forms already did. So av_cmpmask combined bys_and_b32and read byv_cndmask_b32(path 1 in the report) gives each lane its own compare bit. Before, wave32 rebuilt that bit from the ballot word, so on a driver that leaves helpers out of ballots a helper thats_wqmswitched on read 0. That is theagc_driver_pixel_helper_lane_masksfailure on CI's llvmpipe (983 wrong pixels, wave32 only).Compare-mask words keep the driver's own helper bits, as on
main. Read per lane, a mask now holds the lane's own bit on every driver, and where helpers take part in ballots (NVIDIA) that is the bit it got before #11199.Tests:
agc_driver_pixel_helper_waterfallis back, with the pixel index computed afters_wqmso helpers carry their own key. It no longer requires helpers to be skipped: the console iterates the helpers whole-quad mode put into EXEC, NVIDIA does too, and AMD's driver cannot. It checks that the loop ends under the pass limit, that every live lane is picked exactly once, and that the pass count lies between the live lanes and the lanes of their quads.agc_driver_pixel_helper_lane_masks: implicit-LOD sampling on a 5-level mip chain, with every covered pixel checked against the expected level (6696 inside, 1121 in partly covered quads), for wave64 and wave32, native and emulated barycentrics, and mips 0-2. Three programs: twov_cmpmasks combined bys_and_b64/s_and_b32and thenv_cndmask_b32of the coordinate; EXEC copied to an SGPR and back withouts_wqm; EXEC saved bys_and_saveexecand restored bys_or. Before the save, the coordinate registers hold 4.0 while helpers are on, so a helper that is switched off feeds a wrong derivative.docs/dev/debt/shader.mdentry for EXEC read as a value now states what differs from the console on each kind of driver, and no longer lists the 32-bit scalar logic ops as keeping only the value.Tested
Windows 11 26200, AMD Radeon RX 9070 XT (driver 32.0.31021.1015), Vulkan SDK 1.4.363.0, GCC 15.2.0, Release. Same machine and GPU for every arm,
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R <pattern> -V. Themainarm is this tree withcore/shaderanddocs/dev/debt/shader.mdfrom the branch's basemain6a11d88f70and the two new tests kept.Tests (22):
agc_driver_pixel_helper_waterfall,agc_driver_pixel_helper_lane_masks,agc_driver_pixel_helper_lanes,agc_driver_pixel_implicit_derivatives,agc_driver_pixel_row_reduction,agc_driver_pixel_exec_interpolation,agc_driver_pixel_barycentric_emulation,agc_driver_mesh_barycentric_emulation,agc_shader_memory,agc_shader_entry_lane_proof_budget,agc_shader_quad_mask_no_demote,agc_shader_helpers,agc_subgroup_barrier,agc_dpp_write,agc_driver_dpp16_inactive_source,agc_driver_dpp16_operands,agc_driver_dpp16_row_share_xmask,agc_driver_dpp8,agc_driver_dpp8_pk_fmac,agc_driver_dpp_no_form,agc_driver_wave32_subgroup,agc_driver_graphics. For head9b2aea4955both arms also ran every otheragc_driver_pixel*test andagc_driver_wave32_exec_lane_bits, 36 in all.main9b2aea4955)agc_driver_pixel_helper_waterfall: "the wave whose first lane is pixel 584 hit the pass limit"VUID-lineswas not found but was requested by env var VK_INSTANCE_LAYERSWith
VK_LOADER_DEBUG=layerthe loader reportsInsert instance layer "VK_LAYER_KHRONOS_validation".tools/check_conventions.py --base origin/mainpasses, and the branch merges cleanly into currentmain.Narrow subgroups (CI's llvmpipe, subgroup size 8, failed
agc_driver_pixel_helper_lane_masksonec04b0cf52withcompare masks combined by a scalar AND, emulate0 wave32 mip0: ... incorrect=983 incorrect_edge=983; the test stops at its first failure, so the later cases did not run there):s_wqm, whose quads lie inside a subgroup. The failing case is the only one that rebuilt a lane's bit from a compare's ballot word, and the wave64 form already used lane bits and passed on llvmpipe.!OpIsHelperInvocationEXT, so helpers are left out of ballots as on llvmpipe. Onec04b0cf52it fails with exactly the CI line,incorrect=983 incorrect_edge=983inemulate0 wave32 mip0. On9b2aea4955agc_driver_pixel_helper_lane_maskspasses all 36 cases, andagc_driver_pixel_helper_waterfall,agc_driver_pixel_helper_lanesandagc_driver_pixel_implicit_derivativespass too.VK_KHR_8bit_storage, so the test skips there. CI's Linux lane is the narrow-subgroup check for this head.In a title: @hugodearaujo ran CONTROL Resonant (PPSA34547 01.300.300) on Linux, RX 9070 XT, RADV (Mesa 26.2.6), with #11580 in every build (comment). On
mainthe GPU hung about 115 s after New Game, inside a pixel shader's waterfall over EXEC (s_mov_b32 s80, execbefores_wqm_b32). Withec04b0cf52and noAPS5_LOOP_GUARD, it did not hang in 900 s. The change in9b2aea4955was not run in a title.Limits of this testing:
agc_driver_pixel_helper_lane_maskspasses onmain, on this branch, and also with #11199's original recompiler change, so this card does not show the derivative regression. SeaSunPT's RTX 5070 Ti runs show the same: it also passes there with #11199's change. So it checks the intended per-lane values, but it is not a guard for the NVIDIA picture regression;agc_driver_pixel_helper_waterfallstill covers the hang. Onec04b0cf52, @oneandonlydean's RTX 4090 passes both new tests, and in PPSA21564 the cloud-sea lines do not come back (0.38 at +100 s, against 0.57 onmainand 0.69 after #11199). TechLevelZero's RTX 2000 Ada run shows no new failures or validation IDs. These runs were not repeated on9b2aea4955.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 MarcZX10 on 2026-10-28T14:43:56Z.
Review: COMMENTED
I reviewed the exact head
ec04b0cf52against currentmain446bd8776c; the merge tree is clean andgit diff --checkpasses. The translator changes keep the per-lane EXEC mask alongside the guest-visible words for pixels_saveexecand exact-masks_mov_b64, while other shader stages retain their existing word-copy behavior. The new waterfall and lane-mask tests exercise wave32/64 and barycentric modes; the author reports the focused Vulkan comparison on the RX 9070 XT with 0 validation errors. I could not run these GPU tests on this host (Matrox G200eW). Since #12298 records the derivative regression on RTX 4090 and the PR body asks for that cross-vendor run, I am leaving approval pending that evidence; the current CI run does not provide that GPU coverage.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T06:34:45Z.
Review: DISMISSED
Reviewed — changes requested
The new NVIDIA GPU report is useful, but the previously reported llvmpipe subgroup-size-8 failure remains unresolved and the current hosted Linux job is skipped.
What I ran
ec04b0cf52642d9b169b0e69bfc5bb55e07a56b9; PR base:04fefebe901d9ff4b29acc7d6c4c28d66643d86f; currentmain:47cdccde40bca36c1203ec498d9ff47f23bc6537.main: clean, tree4eed75f2fe8c52fcce82ef84c6f81135bcabbe6e.Results
main, and no new Vulkan validation IDs. This report is on the exact PR head but does not exercise llvmpipe's subgroup-size-8 path.Unedited check output
Findings
Blocking
The test unconditionally runs wave32 cases after checking only for
geometryShader; it does not check whether the host subgroup can execute the requested wave width. An earlier test report in this thread says llvmpipe (subgroup size 8) ranagc_driver_pixel_helper_lane_masksand produced 983 incorrect pixels in a wave32 case. The new NVIDIA report is on a device with a different subgroup configuration and does not resolve that failure. Please determine whether this path is supported: fix the behavior if it is, or add a precise capability precondition and an explicit skip if it is not. Then report a focused lavapipe or other narrow-subgroup run on the updated head.Sources
ec04b0cf52642d9b169b0e69bfc5bb55e07a56b9Not verified
I did not reproduce the llvmpipe failure or run a GPU test locally. The llvmpipe failure and NVIDIA results are contributor-reported; the current hosted Linux job is skipped.
To get this to a good state
Resolve the narrow-subgroup behavior or add a justified capability skip, then provide the focused low-subgroup result. I will rerun the same source checks and inspect the exact new head and CI.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T11:14:36Z.
Review: APPROVED
Reviewed — approved
At head
9b2aea4955,agc_driver_pixel_helper_lane_maskspasses all 36 cases on lavapipe (subgroup size 8). That is the narrow-subgroup run MarcZX10's change request asks for. Withmain's recompiler files the same test fails with the exact line CI reported, and I found nothing blocking.What I ran
Head
9b2aea4955e187f6d3d3a29921b4abb167c3e6ab,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree2ba05bd0dd7020e526016bf81a41e569ae4f970e. Debian 13 VM (Intel Xeon Gold 6136, AVX2/FMA), GCC 14.2.0, Release, Vulkan through lavapipe (Mesa 26.1.6, LLVM 19, subgroup size 8). No GPU.Results
maingit diff --checkcheck_conventions.pylibs)mainagc_driver_pixel_helper_lane_masks(lavapipe, layer loaded)inside=6696 edge=1121 incorrect=0 incorrect_edge=0, includingcompare masks combined by a scalar AND, emulate0 wave32 mip0agc_driver_pixel_helper_waterfall,agc_driver_pixel_helper_lanessubgroup size 8 cannot hold a wave32agc_driver_pixel_implicit_derivatives,agc_driver_wave32_exec_lane_bits,agc_shader_memory,agc_shader_quad_mask_no_demoteInsert instance layer "VK_LAYER_KHRONOS_validation"in every Vulkan test; nowas not found but was requestedline; 0VUID-lines in the focused setnew_vuid:agc_driver_native_depth_uniform_planes(VUID-vkCmdDispatch-groupCountX-00386)main, not this PR. The test was added onmainafter the baseline, and the same 4 errors appear withmain's recompiler filesFocused run, summary
Negative control
I restored
TranslationContext.hpp,ControlFlowInstructions.cpp,ScalarInstructions.cppandTranslationContext/ExecMask.cppfrommain, kept the two new tests, and rebuilt.agc_driver_pixel_helper_lane_masksfails:This is the same line oneandonlydean reported from CI on
ec04b0cf52. So the test catches the wave32sU32Maskgap on a driver that leaves helpers out of ballots, and the second commit closes it. The author's cause analysis matches what I saw.agc_driver_pixel_helper_waterfallskips on this device, so I could not run a negative control for it here. After restoring the merged files and rebuilding, the lane-mask test passes again andgit status --porcelainis empty.On MarcZX10's blocking finding (no subgroup-width precondition): it was a real translator bug, not a missing skip, and on this head the test passes on a subgroup-size-8 device without a skip. I consider that finding resolved by this run.
Findings
Blocking
None.
Non-blocking
s_mov_b32for wave64 (docs/dev/debt/shader.md:119). The entry says that in a pixel program, copying EXEC to an SGPR withs_mov_b32keeps each lane's bit. The lane-bit path insU32Mask(core/shader/recompiler/Translation/src/ScalarInstructions.cpp:19) still requiresprogram.WaveSize() == 32u. As I read it, a wave64 pixel program doings_mov_b32 sN, exec_lo/s_mov_b32 exec_lo, sNstill rebuilds the bits from the ballot-masked word. Suggested fix: say "in wave32" fors_mov_b32and the 32-bit logic ops, or list the wave64 half-word copy among the paths that keep only the value.core/shader/recompiler/Translation/src/ScalarInstructions.cpp:17).involvedis now true for every pixel-stages_mov_b32and 32-bit logic op with SGPR or constant operands, including non-mask data such as descriptor words. The result stays correct, because an untagged register falls back tothreadBitthroughSelectU1with a false tag. But each such op now emits the per-lane mask bookkeeping. Presumably dead-code elimination removes the unused parts. No action needed unless shader size or compile time shows a regression.Not verified
agc_driver_pixel_helper_waterfallandagc_driver_pixel_helper_lanesskip on lavapipe (subgroup size 8), so this machine did not check the waterfall hang fix (#11052). CI's lavapipe lane will skip them too. The coverage comes from the author's RX 9070 XT runs, TechLevelZero's RTX 2000 Ada report on this head, and earlier NVIDIA runs onec04b0cf52.ec04b0cf52, not this head.