fix(shader): keep pixel helper lanes out of guest lane masks #11199
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11199"
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-25T21:42:15Z.
What
A pixel program's waterfall loop over a saved whole-quad EXEC (
s_wqm_b64, thens_ff1_i32_b64/v_readlane_b32/v_cmp_eq_u32into an SGPR /s_andn2_b64until the mask is empty) never ended on an RX 9070 XT, so RESIDENT EVIL requiem (PPSA31246) lost the device in its intro (#11052).hostExecWordexpands pixel-stage EXEC reads to whole quads (#6291), so the saved mask held helper lanes. The host's subgroup ballot and shuffle leave helper invocations out, which Vulkan allows, and on this driver helper invocations did not run the shader's ordinary instructions at all.v_readlane_b32of a helper lane returned no key, the compare matched no lane, and the helper's bit was never cleared.Pixel-stage ballots and EXEC reads now count only lanes that are not helper invocations, so guest SGPR masks, lane picks and lane counts never name a helper lane. Writing EXEC from a value keeps a helper invocation active while a live lane of its quad is, so #6291's save/restore after
s_wqmstill runs the quad's helpers for implicit-LOD sampling. That rule is built as one lane mask (mask | (WQM(mask) & helper lanes)), so the row and half-wave reduction matcher still recognises an all-lane EXEC.Unlike the console, a program that reads a helper lane's value or waterfalls over helper lanes now skips them; the shader debt entry says so.
Tried and dropped, both measured on the same GPU:
RequireFullQuadsKHR(VK_KHR_shader_quad_control, which this driver exposes) on pixel programs that ballot or shuffle: the same device loss with the mode in the compiled modules. In a shader without derivatives no helper lanes were launched with it.OpGroupNonUniformQuadBroadcast: helper lanes held 0 for values computed outside a derivative chain, so the compare cleared every helper bit in one pass.Tested
Windows 11 Home 26200, Ryzen 7 9800X3D, AMD Radeon RX 9070 XT (AMD 32.0.31021.1015, Vulkan 1.4.349), WinLibs GCC 15.2.0 r7, Release, on
mainbaabfbc204.agc_driver_pixel_helper_waterfall, wave64 and wave32: the pixel program samples a texture with implicit LOD, so the driver launches helper lanes. It copies EXEC afters_wqm_b64and waterfalls over the copy withs_ff1_i32_b64,v_readlane_b32,v_cmp_eq_u32ands_andn2_b64, with an 80-pass cap. Each live lane stores the pass count and the XOR of the keys it read; the check compares them with the wave's live pixels from coverage. Most selected lanes sit in another quad than the reader.main: 80 passes over a wave of 26 live lanes, the cap. Without the cap the loop does not end.agc_driver_pixel_implicit_derivativespasses, as doagc_driver_pixel_helper_lanes,agc_driver_pixel_row_reduction,agc_shader_memoryandagc_shader_entry_lane_proof_budget. Thes_wqmcondition keeps EXEC writes exact in programs that never enter whole-quad mode; without it the last two lost their upper-lane proofs on a 32-lane host.tools/select_tests.pyselected 1479 of 2378 tests for this diff. Run onmainand on this branch on the same machine withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1,-j4:main: 7 failures, the 6 below plus the new test.main:select_tests,nid_database_cache,agc_host_import_cut_lifetime,agc_driver_depth_plane_partial_store,agc_driver_sample_order_grid_reference,loadexec_arguments(timeout).main29ce6d87ebwith #10935, #10304 and #9950 applied locally (without them it stops earlier).APS5_LOOP_GUARD=100000, the guard trips at the waterfall exits of the intro scene's fragment programs; without the guard the device is lost (#11052).guest writes over native multisample depth are not implemented; a run of this revision reached the title's main menu.mainbaabfbc204and this branch,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest --test-dir build -R <pattern> -Vover 22 focused tests (the pixel helper, derivative, row reduction, EXEC interpolation, barycentric, DPP, subgroup and shader memory tests, andagc_driver_graphics; list in the comment below):was not found but was requested by env var VK_INSTANCE_LAYERS; withVK_LOADER_DEBUG=layerthe loader insertsVK_LAYER_KHRONOS_validation.VUID-occurrences: 0 onmain, 0 on this branch.main: 21 of 22 pass (agc_driver_pixel_helper_waterfallfails). This branch: 22 of 22.tools/check_conventions.py --base origin/mainandtools/pr_overlap.py --branch fix/shader-pixel-helper-lane-maskspass (no overlap with open pull requests).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-25T21:50:45Z.
Review: CHANGES_REQUESTED
The same-GPU functional runs are useful, including the title repro and baseline comparison. However,
CONTRIBUTING.mdrequires shader-recompiler changes to rerun the focused tests on bothmainand the change withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1, then compare the logs for newly introducedVUID-errors. The report says the validation layer was unavailable and no VUID comparison was run. Please provide that required same-machine/GPU comparison before this is ready for approval; the skipped hosted product jobs do not cover it.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T05:51:55Z.
Review: DISMISSED
The required validation comparison has now been supplied on the same RX 9070 XT machine: the loader confirms the Khronos layer loaded, neither log contains the missing-layer message, and both report zero
VUID-occurrences.agc_driver_pixel_helper_waterfallfails on the reported main and passes on the PR; the 22-test comparison is 21/22 on main and 22/22 on the change. The separate multivendor suite and controlled baseline also support the fix. I audited the changed helper filtering, EXEC mask reconstruction, and focused test; I found no remaining functional blocker.I cannot approve this integration point yet.
tools/check_main_sync.py --base upstream/main --head 08dfcc028d47c9f38fb4faabb65e2106ea1ca5a0reports 1 ahead and 477 behind currentmain(14c99b52ac); the merge preview is clean, withdocs/dev/debt/shader.mdchanged on both sides. There are also textual conflicts with #11265 inTranslationContext.hppandInstructionTranslator.cpp; both patches make adjacent translator-setup edits that appear composable, so I do not infer a functional dependency. Please refresh on current main, preserve both edits when resolving the open-PR overlap, and rerun the focused helper-waterfall test plus the required validation comparison on the resulting exact tree.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T07:53:35Z.
Review: COMMENTED
Linux NVIDIA and lavapipe run. The existing runs are RX 9070 XT on Windows, RDNA and lavapipe on Linux, and NVIDIA on Windows.
Setup: Ubuntu 26.04, GCC 15.2, Release. RTX 3070 (NVIDIA 595.99.02, subgroup 32) and lavapipe (Mesa 26.0.3, LLVM 21.1.8, subgroup 8), each selected with
VK_DRIVER_FILES. Head5f10d0a22merged with--no-commitontomainb7105f728(clean; it also merges cleanly onto8df2c3ed0). Focused runs useANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Khronos layer 1.4.341).VK_LOADER_DEBUG=layershows the layer inserted, and no log has the missing-layer message.main+ onlyPixelHelperWaterfall.cpp): on the 3070,agc_driver_pixel_helper_waterfallfails differently from the RX 9070 XT. The loop ends, but makes one pass too many:pixel helper waterfall wave64: pixel 584 of the wave whose first lane is pixel 584 made 26 passes over 25 live lanes. That fits helper lanes that run the ordinary instructions on this driver: the helper's key is read once, the compare clears its bit, and the loop ends one pass late. The test still catches the bug there, as a wrong pass count rather than the cap. On lavapipe the test skips (subgroup size 8 cannot hold a wave32), so lavapipe gives no red/green signal for this PR. The same holds foragc_driver_pixel_helper_lanes.^agc_driver_pixel_,agc_driver_quad_pixel_mask,agc_shader_memory,agc_shader_entry_lane_proof_budget,agc_driver_graphics), includingagc_driver_pixel_helper_waterfall,pixel_implicit_derivativesandpixel_row_reduction. 0VUID-.VUID-.^agcsuite (without display/flip/lds_atomics64,-j1 --timeout 30), compared with the samemain:mainwas 1041/1042 here, with oneagc_submit_progress_no_timelinefailure that passed 3/3 alone right after. It looks flaky on a GPU shared with another run, and this PR doesn't touch it.agc_driver_multisample_retirement, which fails the same way onmainon this host.sizeofasserts inShaderDiskCache.cppandPipelineJournal.cpphold.public_headerspasses withmain8df2c3ed0(it fails onb7105f728itself, which #11718 fixed).GPUs tested: NVIDIA RTX 3070 (Linux), lavapipe
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T09:32:27Z.
Review: COMMENTED
Apple GPU run of head
5f10d0a229: the new test catches the bug on MoltenVK too, but there it shows up as an extra waterfall pass, not a hang.Setup: Apple M2 Max, macOS 27.2, x86-64 Release under Rosetta 2.
maindoesn't build and run on macOS, so this ismainb87d3d87e2+ the macOS port PRs (#7631 #11249 #11358 #10669 #10552 #7804 #11447 #11437 #11554) + one local patch (#11705's), with this PR merged on top (clean). Two drivers: MoltenVK 1.4.2 from Vulkan SDK 1.4.363.0, and MoltenVKmainwith KhronosGroup/SPIRV-Cross#2704.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1,ctest -j1 --timeout 30.With this PR: the 22 tests from QRMOE's validation comparison pass 3 of 3 on both drivers.
agc_driver_mesh_barycentric_emulation(noVK_EXT_mesh_shader) andagc_driver_pixel_implicit_derivatives(nogeometryShader) skip on MoltenVK. WithVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, the layer is inserted, nothing reportswas not found but was requested, and there are 0VUID-lines.Red (this PR's tests, with the 6 non-test source files under
core/shadertaken back to the base):agc_driver_pixel_helper_waterfallfails 3 of 3 on both drivers and with the layer. The failure is the same every time:There's no device loss and no timeout. On this GPU the loop ends, but it takes one pass more than there are live lanes. That fits helper invocations running the shader's ordinary instructions on Apple, unlike the RX 9070 XT:
v_readlane_b32of the helper lane returns a key, so the helper's bit gets cleared, but only after an extra pass. The test's pass count catches that case as well as the hang.agc_driver_pixel_helper_lanespasses on both sides.Suite:
^agc(1041 tests, flip/display/lds_atomics64excluded) gives the same failures as the base on both drivers: 41 with the SDK MoltenVK and 40 with MoltenVKmain. Those are known macOS failures, and none of them involves pixel helpers or subgroups.GPUs tested: Apple M2 Max (MoltenVK 1.4.2 / MoltenVK main + SPIRV-Cross#2704), macOS 27.2
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.