xshader: lower constant-lane v_readlane_b32 for Wave32 and portable Wave64 #185
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/brcly--TuxBox!185
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-185"
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?
@Vladimir-Human on GitHub · 2026-11-25 17:55 UTC · original
Vladimir-Human:xshader/readlane-wave-reduction→main· +2085 −70 · 13 files · 4 commits · openAI-assisted PR.
Summary
Lowers constant-lane
v_readlane_b32wave reductions intools/shader-compiler:WaveReadLaneAtwhen the wave execution context and SGPR/SCC/Exec operands are proven uniform across a dataflow + control-dependence fixpoint, falling back cleanly to VGPR-indexedtb_swizzleLDS exchange otherwise.s_bitset*/s_cmov*/Sopk/Smemuniformity rules,ExecLo/ExecHiconflict checks,v_mbcnt[WaveSize(32)]WaveActiveBallothandling, guarded partial-group OOB loads between unconditional barriers, andtb_guardloop checks rejecting preceding/nested non-uniform loops.<= 1,200lines with zero inline#[cfg(test)]modules (exec_group.rsuntouched).Verification (commit
4ecbc63c)test_repository_hygiene.py,test_translator_checks.py,test_wave_extrema.py,test_dpp8_exchange.py): 13 passed, 0 failedcargo test --manifest-path tools/shader-compiler/Cargo.toml: 318 passed, 0 failed, 0 ignored (316 lib + 2 integration)cs_6_6/cs_6_0) + hardware D3D12 readback (RTX 4070 SUPER,10de:2783,readlane_probe+compute.cpp): 15/15 cases passed, 5,760/5,760 words exactgit merge-tree --write-treeclean againstorigin/mainand PR#176.@brcly on GitHub · 2026-11-25 18:37 UTC · original
Thanks for this. I trial-merged it onto
main(4cb6a4a) and ran the full check, which passed: 348 Python tests, 313 shader translator tests, 65 guest checks, the D3D12 regression controls and the translator GPU checks.Before merging, I'd like to understand a tail latency change in the Lanes benchmark. I ran
python tuxbox.py verify --only lanes-benchmark15 times on each build.mainmedian (min–max)The medians match, but frame p99 went over 450 µs in 5 of 15 runs with this PR and 0 of 15 on
main:main: 298, 325, 329, 335, 342, 351, 357, 363, 364, 367, 371, 374, 375, 378, 379The full check's own benchmark run on the merged tree also read 725.6 µs. The runs for each build were done in blocks (5, then 10), not strictly alternated. I haven't found the cause. The new wake-up path for waiting queues is the first place I'd look, but that's a guess.
Could you check whether you see the same spread over repeated runs, and either fix it or explain it?
On the elision logic: from reading it, only monotone waits at list start are skipped, and only with no tracked or in-flight write to the address. I found draws, dispatches, copies, markers, queries and bundles all recording writes. One case I don't see covered is the CPU lowering a label between submission and GPU execution. Is that something you considered?
I didn't test this in a retail title.
Host: NVIDIA GeForce RTX 4070 Ti SUPER (
10de:2705), driver 620.73.04, Proton Experimental 11.0-20261027b, Linux 7.3.5, AMD Ryzen 7 9800X3D.@brcly on GitHub · 2026-11-25 18:56 UTC · original
This ended up being noise, ignore me. will merge this and others soon. thank you.
@tsunderejay on GitHub · 2026-11-25 21:04 UTC · original
Automated review against current main found blocking correctness risks before merge: (1) wave width is inferred from b32/b64 EXEC operand width, which is not conclusive and can silently select Wave32 for a Wave64 program; (2) the unproven-selector fallback can use a hardcoded 64-lane base without bounds checks and can read stale values for branch-skipped lanes; (3) new readlane refusals may be swallowed by the lone-lane retry; (4) scalar memory loads are treated as workgroup-uniform for loop-convergence proofs, which can introduce barrier deadlocks. Please address these with regressions before merging.
@Vladimir-Human on GitHub · 2026-11-25 23:35 UTC · original
@tsunderejay Thank you for the detailed review — pushed monotonic fix commit
543999bdon top of4ecbc63caddressing all 4 blocking correctness findings with regression tests:Wave width inference (
indexed_lane.rs):_b32/_u32/_i32touches_execclause fromhas_wave32_markersso a Wave64 shader inspectingexec_lowiths_mov_b32/s_and_b32can no longer be misclassified as Wave32.Opnd::ExecHireference as a Wave64 marker, and explicitly refused ambiguous 32-bitexec_loinstructions lacking conclusive Wave32 or Wave64 proof (wave64_exec_lo_b32_inspect_keeps_wave64_and_ambiguous_b32_exec_refuses).Unproven-selector fallback &
GROUP_READ(pipeline.rs,indexed_lane.rs,exchange.rs):swizzle_group_reads,can_swizzle_fallback,group_reads, andemit_compute_swizzle(GROUP_READ)strictly to proven-safecompute_swizzleshapes (count % 64 == 0,1..=1024,guest_width == 64,scan_width.is_none(),!dispatched).emit_compute_swizzle(GROUP_READ)to publishtb_swizzle[tb_lane] = <src0>;unconditionally before the firstGroupMemoryBarrierWithGroupSync(), guard only the read/result assignment on active branches, and mask the selector with& 63u(unproven_swizzle_fallback_refuses_partial_groups_and_preserves_skipped_lanes).lone_lane::retryswallowing readlane refusals (pipeline.rs,indexed_lane.rs):translate_outputsto returnfirstdirectly wheneverindexed_lane::has_non_spill_readlane(&original)is true so cross-lanev_readlane_b32errors propagate cleanly instead of falling through to per-lane retry (refused_readlane_is_not_swallowed_by_lone_lane_retry).Enc::Smemuniformity (indexed_lane.rs):analyze_uniformity_passsoEnc::Smem(s_load_*,s_buffer_load_*) conservatively taints written SGPRs as non-uniform, preventing scalar memory load loops from proving convergence around barriers (smem_loads_are_not_treated_as_workgroup_uniform_for_readlane_loops).Verification (
543999bd6fafa17f)git merge-treeagainstorigin/main(cb8c38b) and PR#201(079143b1).python -m unittest discover -s tests -p "test_repository_hygiene.py" -v: 4/4 passed (max.rs= 1,106 lines;indexed_lane.rs= 1,031;tests/hlsl/indexed_lane.rs= 930).cargo test --manifest-path tools/shader-compiler/Cargo.toml: 320 lib + 2 integration passed; 0 failed.readlane_probe(15/15) + DXC10.0.26100.0cs_6_6compile: 15/15 passed.cargo test --manifest-path runtime/d3d12/Cargo.toml -- --test-threads=1: 111/111 passed.python build.py lanes+lanes.exe --adapter 10de:2783 --selftest all: passed (12/12).@brcly on GitHub · 2026-11-26 02:05 UTC · original
The 128 lost shaders are mostly from the early return in translate_outputs for has_non_spill_readlane: disabling it leaves 4 lost and 26 changed, with none gained.
Please suppress the fallbacks only when the lane read itself is what failed, and fall back for the 4 that lack a lane bound.
On recorded requests the PR doesn’t translate any of the 278 shaders refused for lane reads, so could you show a case it fixes, ideally a GPU check where main computes the wrong result?
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.