Pixel shaders: masks hold the helper lanes (#105 item 1) #134
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!134
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/134/head"
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?
@tiagonleal on GitHub · 2026-11-23 14:36 UTC · original
tiagonleal:fix/ps-helper-lane-masks→main· +313 −13 · 4 files · 2 commits · merged 2026-11-25 00:58 UTC#105 item 1 (HANDOFF: "Ballots (v_cmp) still leave helper lanes out").
After
s_wqmthe helper pixels of a quad a primitive's edge splits are in EXEC, and the console'sv_cmp*/ carries set their bits like any other lane's.ballot()usedWaveActiveBallotalone, which leaves helper lanes out before SM 6.7, so in whole-quad sections:v_cndmask_b32gave helper lanes the false value;s_and_saveexec/v_cmpxdropped them, so what was written under that mask never reached them;v_readfirstlane(rlaalready reads a helper lane right) never took the helper lane out of EXEC (itsv_cmp_eqbit stayed 0) and ran until the loop budget: 65 536 iterations, in every wave with a helper lane.Found on the way: not every wave op reaches a helper lane
Each lane holds its own copy of EXEC, so a helper lane has to get the whole mask too, not just contribute its bit. Measured on an RTX 5070 Ti with native HLSL (the new test
gpu_ps_helper_lanes_see_ballots_and_quads_are_lanes_4k):WaveActiveBallotgives a helper lane the wave's result (32 / 32 helper lanes, with a lane-varying condition too);WaveActiveBitOrdoes not (0 / 32: it gets another value);So "quad reads +
WaveActiveBitOr" (the variant HANDOFF says was tried for XDefiant's text) leaves the helper lanes' own EXEC wrong on NVIDIA: with it the new test failed exactly as it does without any change (384 / 1024). Whether AMD behaves the same I could not check.Change
ballot_px(pixel shaders,PRELUDE_PIXEL): every lane gets its quad's four bits through quad reads (they see helper lanes); ballot p collects bit p of them from the live lanes, and any live lane of a quad answers for its member p. 3 quad reads + 4 ballots, nothing else.ballot_px_local: a mask only ever read lane by lane (v_cndmaskselector, carry-ins – thex64_masksliveness pass, now also run for pixel shaders) needs only the lane's own bit: the wave's ballot with that bit OR-ed in. 1 ballot, as before.ballot(true): the live lanes only, as on the console (with the helper lanes in it they never stop – the[WaveOpsIncludeHelperLanes]hang).x64_whole_live→mask_whole_live(it now serves both).quad_bits/ballot_px_quad(second commit): a maskquad_bitscan express reads the compare's vector operands through quad reads and evaluates the compare per member, instead of quad-reading the compare's result (ballot_px). AMD's compilers crashed inCreateGraphicsPipelineStateon theballot_pxform: RDNA2 on quad reads of a value from aWaveReadLaneAtin a waterfall loop (WarmMilkCodes, RX 6600 XT), RDNA3 / RDNA4 on aWaveReadLaneAtwhose lane comes from such a mask, with no loop (gpu_wave64_ps_whole_wave_reductions; srcamarda on an RX 7800 XT with a standalone repro, the maintainer on an RX 9070). Using it for every mask, not only in loops, is srcamarda's change from their review. Masksquad_bitscannot express keepballot_px.HLSL / DXIL cache
Only pixel shaders change. On the first version I dumped every HLSL the lib tests translate on
mainand on this branch: 132 byte-identical; the ones that differ are all pixel shaders (2 existing + 2 from the new tests). VS / CS / mesh / GS keep their cached DXIL; pixel shaders recompile once.What is in it
Pixel shaders: masks hold the helper lanes (#105 item 1):ballot_px/ballot_px_localinPRELUDE_PIXEL(crates/xcl/src/gpu/recomp/emit.rs), the liveness pass for pixel shaders (x64_masks.rs), two GPU tests (tests.rs).Pixel shaders: masks quad-read the compare's operands, not its result (#134):quad_bits/ballot_px_quad(emit.rs), testps_masks_in_loops_quad_read_the_operands_not_the_compare(tests.rs).Tests
gpu_ps_masks_hold_helper_lanes_on_triangle_edges: a hand-assembled PS on two triangles sharing the diagonal of a 32×32 target, wave64 and wave32 programs. Per pixel: |ddx| of a value picked byv_cndmaskin WQM, |ddy| of a value written unders_and_saveexec, and a waterfall loop's iteration count.gpu_ps_helper_lanes_see_ballots_and_quads_are_lanes_4k: the two properties above thatballot_pxandrlarely on, checked on the adapter (theWaveActiveBitOrresult is printed, not checked).Tested
main47efa2e.cargo build --workspace && cargo test --workspace -- --test-threads=4on8c3cfd8: 744 passed, 0 failed, 41 ignored. SKIPPED:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64).cargo test -p xcl --lib -- ps_masks helper_lanes wave64_ps --test-threads=1: 5 passed (gpu_ps_helper_lanes_see_ballots_and_quads_are_lanes_4k,gpu_ps_masks_hold_helper_lanes_on_triangle_edges,gpu_wave64_ps_spill_slots,gpu_wave64_ps_whole_wave_reductions,ps_masks_in_loops_quad_read_the_operands_not_the_compare).afdfc11(RX 7800 XT, not mine):cargo test -p xcl --lib538 passed, 1 failed (gpu_wave64_ps_whole_wave_reductions[2, 928, 2], the #155 case thatmainfails there too, no crash); withXCL_SPLIT_WAVE64=1539 passed, 0 failed.Regression run
Not tested
s_and_saveexec,v_cmpx) costs quad reads and per-member compares instead of 1 ballot; masks read lane by lane cost about the same.AI use
@tiagonleal on GitHub · 2026-11-23 14:54 UTC · original
Rebased on
main484dd57(after #133). No interaction: #133 changes what lane reads of lanes 32..63 give, this changes the masks' helper-lane bits; on a 32-lane waveballot_px's upper word stays 0, which is whatupper_lanesassumes for VALU masks while EXEC's upper word is 0. Re-run on the RTX 5070 Ti:cargo test --workspace562 passed, 0 failed (the two new PS tests included).@WarmMilkCodes on GitHub · 2026-11-23 19:04 UTC · original
Tested #134
737f395merged onto main956a476on AMD Radeon RX 6600 XT (RDNA2), driver 32.0.21045.29003, Windows 11 23H2 (22631.6199): fail – the new test crashes inside the AMD driver'sCreateGraphicsPipelineStateThe PR's new test
gpu_ps_masks_hold_helper_lanes_on_triangle_edgestakes down thexcllib test binary with 0xC0000005 (STATUS_ACCESS_VIOLATION), every run (full suite, serial, and alone). Main at956a476(no such test) runs the whole lib suite here without a crash. No Rust backtrace (not a panic).To find the step, I ran it alone (
--exact --nocapture --test-threads=1) with temporaryeprintln!s before each step of the test and ofrunner::draw/draw_on_multi:So the translation is complete and DXC accepts it (
ps_6_6); the access violation is inID3D12Device::CreateGraphicsPipelineStatefor the wave64 PS – the driver's shader compiler. The marker after PSO creation never prints, and the wave32 pass never runs. The PS usesWaveActiveBallot×4,WaveReadLaneAt×5 (the waterfall loop),QuadReadLaneAt×4,QuadReadAcrossX/Y/Diagonal,WaveActiveBitOr,WaveGetLaneIndexand adiscard, inside 11forloops.The translated HLSL (
pr134_ps_wave64.hlsl, from the synthetic test only) is attached in case it helps reduce it.pr134_ps_wave64.hlsl.txt
@WarmMilkCodes on GitHub · 2026-11-23 19:17 UTC · original
Narrowed the
CreateGraphicsPipelineStatecrash down on the same RX 6600 XT (driver 32.0.21045.29003), compilingps_6_6with DXC and creating the PSO throughrunner::draw, each variant in its own process:In the test's translated PS: only the waterfall loop (C,
0038–0058) matters. Without it: ok. With A and B cut out: still crashes. Replacingrlawith a plainWaveReadLaneAt, removing thexcl_budgetcheck or removing thediscard: still crashes. Replacing the loop'sballot_px(...)withballot(...), i.e. noQuadReadAcrossX/Y/Diagonalin the loop, makes it build and draw.Standalone reproducer, no resources, crashes the driver in
CreateGraphicsPipelineState:So it's AMD's compiler crashing on quad reads of a value derived from
WaveReadLaneAtinside a loop. That's the shapeballot_pxgives everyv_cmpin a translated waterfall loop, so retail shaders with waterfall loops likely hit it too on this driver, not just the test. A workaround on the XCL side would be to keepballot_px's quad reads out of loops (asloop_plain_ballotdoes) or to restructure that step; which one is right for helper-lane semantics is your call.Also reported to AMD through the AMD Bug Report Tool (driver 26.11.2) with the standalone shader above.
@tiagonleal on GitHub · 2026-11-23 20:43 UTC · original
Rebased on
956a476;afdfc11: in a loop,v_cmpmasks quad-read the compare's vector operands (QuadReadLaneAt, once per register and member) and useballot_px_quad; no quad read of aWaveReadLaneAt-derived value in a loop any more. Masks outside loops unchanged.ps_6_6): quad ops in the loop reading aWaveReadLaneAt-derived value 3 → 0 (wave64 and wave32).cargo test --workspace -- --test-threads=4: 572 passed, 0 failed, 39 ignored (main956a476: 569 / 0 / 39).gpu_ps_masks_hold_helper_lanes_on_triangle_edges: 0 of 1024 pixels wrong, wave64 and wave32. New:ps_masks_in_loops_quad_read_the_operands_not_the_compare(fails without the change).@WarmMilkCodes, could you rerun
gpu_ps_masks_hold_helper_lanes_on_triangle_edgeson the RX 6600 XT?@Kalmarv on GitHub · 2026-11-23 20:59 UTC · original
Linux / Turing run of the current head
afdfc11(onmain956a476, so head = merge result). Ubuntu 24.04, GeForce RTX 2060 (Turing, 32-lane waves), NVIDIA 595.91.07, Wine 11.21 Staging (wow64), vkd3d-protonmaster30b0eb9 (relaxed as in #175), DXVK 3.1.1dxgi; XCL cross-built forx86_64-pc-windows-gnu, release; DXC 1.7.2308. So the D3D12 path is vkd3d-proton → dxil-spirv → NVIDIA Vulkan, which translates the wave, quad and helper-lane operations itself.gpu::recompfilter,--test-threads=1:main956a476No new failures. All three new tests pass:
gpu_ps_masks_hold_helper_lanes_on_triangle_edges,ps_masks_in_loops_quad_read_the_operands_not_the_compareandgpu_ps_helper_lanes_see_ballots_and_quads_are_lanes_4k. The PSO with the loop's quad reads builds without trouble through dxil-spirv.The 5 failures on every build are this stack's memory-window reads, which return zeros (explained in #175), and are the same on
main:gpu_memory_windows_above_4_gib,gpu_unified_memory_arena,gpu_mesh_mode_reads_memory_windows,gpu_sparse_vram_descriptors_buffers_and_xmem,gpu_bvh64_intersect_ray_across_memory_windows_and_grazing. The 2 skips on every build areno wave64(gpu_geometry_*).Not covered: whether the RX 6600 XT driver crash is gone at
afdfc11(that needs AMD on Windows); RADV; any title.AI-assisted (Claude Code).
@ivall on GitHub · 2026-11-23 21:09 UTC · original
Not merged yet: with this PR on current main the lib test process dies with 0xC0000005 in
gpu_wave64_ps_whole_wave_reductions(creating its pixel-shader pipeline) on an RX 9070 (RDNA4, driver 32.0.x); main passes it. It looks like the driver's compiler crashing on the new mask form, the RDNA2 crash this PR avoids, now on RDNA4. Could you check it with--test-threads=1on an RDNA3/4 card, and rebase on main?@srcamarda on GitHub · 2026-11-23 21:10 UTC · original
@ivall same crash here on RDNA3 (
gpu_wave64_ps_whole_wave_reductions,--test-threads=1); cause and a fix that removes it below.Tested on RDNA3: RX 7800 XT, driver 32.0.32029.2010, Windows 11 26300, debug build, no
XCL_SAMPLE_*data.afdfc11fixes the loop case on RDNA3 too, but another driver crash remains, without a loop.b9e6e25(before the workaround)afdfc11gpu_ps_masks_hold_helper_lanes_on_triangle_edgesalonegpu_ps_helper_lanes_see_ballots_and_quads_are_lanes_4k,ps_masks_in_loops_…cargo test -p xcl --libThe crash is
gpu_wave64_ps_whole_wave_reductions, natively and withXCL_SPLIT_WAVE64=1, at both commits. Onmainit only fails on RDNA2/3 ([2, 928, 2], #155). Its PS has no loop. The access violation comes after DXC succeeds, in PSO creation (same place as on the RX 6600 XT).What triggers it
I replaced the test's PS with hand-edited HLSL, one variant per run:
rla()without itsXCL_PIXELquad partv_cmp(ballot_px(and(lanebit(exec…), v14 != 0))) without EXECballot_pxwithout itsQuadReadAcross*rla(v13, s0)with a constant lane instead ofs_ff1(s18 & exec)So it is the reverse of the RDNA2 shape: a
WaveReadLaneAtwhose lane index comes from a ballot of quad-read bits. No loop is needed. Standalone, it crashes the driver here:With
l = 3uit builds, and so does the same shader without the quad reads. Your operand form does not crash it. The same shader withqbuilt fromQuadReadLaneAt(x, p)compares (asquad_bitsemits) builds and runs.Suggested change: the operand form for every mask, not only in loops
plus
ps_masks_in_loops_quad_read_the_operands_not_the_compare's last assertion turned around (masks before the loop takeballot_px_quadtoo). Full patch at the end. With it, on the RX 7800 XT:cargo test -p xcl --lib: 538 passed, 1 failed (gpu_wave64_ps_whole_wave_reductions:[2, 928, 2], the #155 case, no crash)XCL_SPLIT_WAVE64=1: 539 passed, 0 failedEm::loops/loop_rangesare then unused for this. Masksquad_bitscan't express still fall back toballot_px, so the shape can still occur there.Not tested: NVIDIA with this change, RDNA2, retail shaders.
On your "whether AMD behaves the same":
gpu_ps_helper_lanes_see_ballots_and_quads_are_lanes_4kprints32 pixels next to a helper lane; its ballot right in 32, its bit-or in 32; quads at lanes 4k in 1024 of 1024. So on this AMD driverWaveActiveBallotreaches helper lanes and quads are lanes 4k..4k+3, as on the RTX 5070 Ti. Unlike there,WaveActiveBitOrreaches them too (32 / 32 vs 0 / 32).Patch against
afdfc11(git apply)@WarmMilkCodes on GitHub · 2026-11-23 21:36 UTC · original · edited 2026-11-23 21:56 UTC
Re-tested
afdfc11(merged onto current main0f34407) on the RX 6600 XT (RDNA2), driver 32.0.21045.29003, Windows 11 23H2.The fix works for its own test:
gpu_ps_masks_hold_helper_lanes_on_triangle_edgesandgpu_ps_helper_lanes_see_ballots_and_quads_are_lanes_4know pass here (serial run). Thanks for picking up the repro.But merged onto current main it crashes another test – same driver crash, 0xC0000005 in the lib binary, in
gpu_wave64_ps_whole_wave_reductions(cargo test -p xcl --lib -- --test-threads=1: 198 tests ok, then that one never returns). On main0f34407alone that test passes and the whole suite is 651 passed / 0 failed on this card.Likely an interaction with #155 (merged at
2abc562, after this branch's base – it's 102 commits behind): on RDNA2/3 the VS / PS are now translated in the 32-laneupper_lanesform, and that test's PS (whole-wave reduction + waterfallv_readlaneof thes_ff1lane) together with this PR's masks seems to hit the same AMD compiler crash again. Rebasing onto main should reproduce it on any RDNA2/3 card; on NVIDIA it wouldn't show.@PHeitor1 on GitHub · 2026-11-23 22:34 UTC · original
Tested
afdfc11merged ontomain9ab7d76on RTX 5060 Ti 8 GB (Blackwell, 32-lane waves), NVIDIA 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native), rustc 1.100.0 MSVC, debug,cargo test --workspace --no-fail-fast -- --test-threads=4, noXCL_SAMPLE_*. Baselinemain9ab7d76: 651 passed, 0 failed, 40 ignored.Pass: 654 passed, 0 failed, 40 ignored. GPU skips: the same 2 as on
main(no wave64).Run and written with Claude Code (Claude Opus 5.5).
@tiagonleal on GitHub · 2026-11-24 14:04 UTC · original
@srcamarda thanks for the repro and the patch. It is in now (
8c3cfd8, credited in the commit): every maskquad_bitscan express takes the operand form, the loop ranges it first needed are gone, and the test's last assertion is turned around as you suggested. Rebased ontomain47efa2e; on the RTX 5070 Ti the whole suite passes (744 / 0 / 41) and the smoke run is clean, both in the description.@WarmMilkCodes @srcamarda if you can, a rerun of
cargo test -p xcl --lib -- --test-threads=1on8c3cfd8on RDNA2 / RDNA3 would say whethergpu_wave64_ps_whole_wave_reductionsstill crashes the driver there; I have no AMD card.AI-assisted (Claude Code).
@thiagocalile on GitHub · 2026-11-24 19:24 UTC · original
Independent AMD RDNA2 (native wave64) test report on exact head
8c3cfd8d8e511dcea13ec2ffa7f682f3c21d5e04(without rebasing or edits).Tested
32.0.21045.29003;XCL_ADAPTER=radeon, native wave64 + mesh shaders), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (26200), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC1.8.2502.11, debug build.XCL_ADAPTER=radeon cargo test -p xcl --lib gpu::recomp -- --test-threads=4: 191 passed, 0 failed, 18 ignored (0 GPU skips).XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 741 passed, 3 failed, 41 ignored. The 3 failures are pre-existing on this RX 6600 onmain(placed_title_textures_share_vram_and_preserve_pixels: 3D 64x64x64 4 mips subresource 2 mismatch, plus 2 mutex-poison cascades; covered by #1028).Not tested
scripts/smoke.ps1(no retail executable here), D3D12 debug layer (nod3d12SDKLayers.dll), NVIDIA / Intel / WARP, Linux / Wine.AI use
8c3cfd8, ran the tests on my RX 6600, and drafted this report; I checked the output before posting.@thaqiart139-alt on GitHub · 2026-11-24 22:48 UTC · original
Test report for this PR's head
8c3cfd8, merged intomain689f2db(no conflicts), on AMD RDNA2 with native 64-lane waves and on a 32-lane NVIDIA card.Tested
XCL_ADAPTER.cargo test --workspace --no-fail-fast -- --test-threads=4:main689f2dbmain, from #1679's new fuzz tests, and both are already reported on #1679:fuzz_validate_and_gpu_0to_3(CreateComputePipelineState:0x8007000E)fuzz_validate_and_gpu_1(seed 540: res[833] = 0x7, CPU 0x6)gpu_ps_masks_hold_helper_lanes_on_triangle_edges,ps_masks_in_loops_quad_read_the_operands_not_the_compare,gpu_ps_helper_lanes_see_ballots_and_quads_are_lanes_4k.SKIPPED tests (the same on
mainand with this PR)gpu::recomp::lower::tests:a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpugpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu, and the wave64 cases of itsf16/f32/f64/integer_programs_on_the_gpugpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardwarelower_dxil's f16 arithmetic, f16 packed and f32 conversions: refused ("its #1426 semantics differ from the console's")heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode is off)gpu::dxil::geometry_tests::gpu_geometry_direct_records,emitted_ms_primitive_attribute_reaches_the_pixel_shader,emitted_ms_ps_draw_a_triangle,gpu_geometry_mode_es_gs_strip,gpu_geometry_mode_es_gs_strip_with_branches,gpu_mesh_mode_two_passeslower_dxil's f16 arithmetic, f16 packed and f32 conversions: refused, as aboveheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)pso_measurement_compiles_an_exact_synthetic_record(Developer Mode is off)Not tested
AI use
@WebIdentity1 on GitHub · 2026-11-24 22:57 UTC · original
RTX 3090 helper-lane regression check on exact head
8c3cfd8d8e511dcea13ec2ffa7f682f3c21d5e04, compared with its parent47efa2ecea0a12934719ae69b81930cf02a4b1c3. I applied this PR'stests.rsonly to the parent so the same three synthetic tests ran on both implementations. No game data or SDK was used.Tested
32.0.15.9174(591.74), Ryzen 7 7800X3D, Rust 1.98.1 MSVC, DXC 1.8.2502.11.XCL_ADAPTER=3090; direct DXIL and forced split-wave64 unset.cargo test --locked -p xcl --lib gpu_ps_masks_hold_helper_lanes_on_triangle_edges -- --test-threads=1 --show-output: parent 0 passed / 1 failed with 384 / 1,024 pixels wrong in its wave64 pass (ddx 32, ddy 32, waterfall loop 384); PR 1 passed / 0 failed, with 0 / 1,024 wrong for both wave64 and wave32 pixel programs.cargo test --locked -p xcl --lib gpu_ps_helper_lanes_see_ballots_and_quads_are_lanes_4k -- --test-threads=1 --show-output: 1 / 0 on each snapshot. On the RTX 3090, all 32 / 32 tested helper-adjacent pixels saw the expected ballot;WaveActiveBitOrmatched in 0 / 32 (observed, not asserted); all 1,024 / 1,024 pixels had the expected 4-lane quad layout.cargo test --locked -p xcl --lib ps_masks_in_loops_quad_read_the_operands_not_the_compare -- --test-threads=1 --show-output: parent 0 / 1, PR 1 / 0, as expected for the emission change.Compiling xclfromsource-head, and the GPU outputs changed as above.Not tested: full workspace suite, retail title, current-main integration, shader compile-time or memory impact, AMD. This is focused native Ampere correctness coverage for the PR's synthetic helper-lane cases, not a merge-readiness claim.
AI use: Codex desktop (GPT-6) prepared the paired snapshots, ran and checked the Windows tests, and drafted this report; all counts come from retained raw logs.
@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-23 14:36 UTC · original · reviewed
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.