Direct DXIL: include pixel shader helper lanes in ballots and VOPC masks #2083
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!2083
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2083/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?
@Decodere on GitHub · 2026-11-25 03:31 UTC · original
Decodere:fix-1269-dxil-ps-ballot-helpers→main· +324 −6 · 2 files · 1 commits · merged 2026-11-25 18:24 UTCWhat is in it
Brings the direct DXIL translator's pixel-shader masks to parity with the HLSL path's
ballot_px,quad_bits, andballot_px_quad(PR #134 / #105 item 1):Lw::ballot(crates/xcl/src/gpu/dxil/lanes.rs) always called plainWaveActiveBallot(cond), even when lowering pixel shaders (self.gfxwithps: Some(_)). Under SM 6.6,WaveActiveBallotexcludes helper lanes, whereasLw::rlaalready handles pixel-shader helper lanes via quad reads. Afters_wqm_b32/s_wqm_b64, dropping helper-lane bits from compare masks corruptedv_cndmask/s_and_saveexecvalues read via DPP quad derivatives along triangle edges and preventedv_readfirstlanewaterfall loops from removing helper lanes fromEXEC(spinning until the loop budget and discarding pixels). Moreover, as established in #134, quad-reading a compare predicate (QuadReadAcross*on a value derived fromWaveReadLaneAt) crashes AMD RDNA2/3/4amdxc64inCreateGraphicsPipelineState.crates/xcl/src/gpu/dxil/lanes.rs:Lw::ballot_ps_quad(q)to spread a precomputed 4-bit quad maskqacross the wave via fourWaveActiveBallotpasses into bits4k + p, preserving the wave32-in-wave64gfx_halfselect and constant-zero short-circuit.Lw::ballotcalls (self.gfx.as_ref().is_some_and(|g| g.ps.is_some()), covering non-VOPC masks such asv_add_co_u32carries) toLw::ballot_ps, which collects each quad's four bits throughQuadReadAcrossX/Y/Diagonaland delegates toballot_ps_quad. Becausesetup_pixelrunsgfx_common_initbefore assigningself.gfx, entryEXECstays live-lanes-only (WaveActiveBallot(true)), matching HLSLPRELUDE_PIXEL.crates/xcl/src/gpu/dxil/lower_valu.rs:vopc_condandvopc_dstfromLw::vopc/Lw::vopc_write.guard_overrideis unset andopn != "f"), evaluate each quad memberp in 0..4by quad-reading VGPR source operands withQuadReadLaneAtwhile leaving wave-uniform sources (SGPRs such asv_readfirstlaneoutputs, inline constants, literals) untouched, ANDing withlanebit_at(exec_lo, exec_hi, (lane & !3) | p), and passing the 4-bit quad mask toLw::ballot_ps_quad(zerodx.op.quadOpon compare results).ps_ballot_testsincrates/xcl/src/gpu/dxil/lanes.rs):direct_ps_ballot_uses_quad_ops_and_keeps_entry_exec_live_only: CPU +dxil.dllvalidation verifying for bothwave64 = falseandwave64 = truethat:dx.op.quadReadLaneAt.i32and zerodx.op.quadOp;V_CMP_LT_F32(0, v2)PS (with norlacallers) emits exactly 4dx.op.quadReadLaneAt.i32calls and zerodx.op.quadOp;EXEC-only PS emits neitherdx.op.quadOpnordx.op.quadReadLaneAt.direct_ps_constant_false_ballot_skips_quad_ops: CPU +dxil.dllvalidation verifying constant-falseV_CMP_F_F32short-circuits without quad reads.direct_ps_non_vopc_carry_ballot_uses_quad_op: CPU +dxil.dllvalidation verifying non-VOPCV_ADD_CO_U32carry masks useballot_ps(dx.op.quadOp.i32).gpu_direct_ps_masks_hold_helper_lanes_on_triangle_edges: CI-WARP-safe (runner::wave64_programs_supported()) GPU draw test on a 32x32 two-triangle diagonal target mirroringrecomp::tests::gpu_ps_masks_hold_helper_lanes_on_triangle_edges(s_wqm,v_cndmask+ DPPddx,s_and_saveexec+ DPPddy, and av_readfirstlanewaterfall loop) for bothwave64 = trueandwave64 = false.Part of #1269
Tested
rustc 1.100.0, DXC1.9.2609.5, release build.cbc296ab):cargo test --release -p xcl --lib ps_ballot_tests -- --nocapture --test-threads=1: failed on CPU disassembly check and failed on RTX 4060 GPU draw (wave64 true: 384 pixels wrong (ddx 384, ddy 384, loop 0)).cargo test --release -p xcl --lib ps_ballot_tests -- --nocapture --test-threads=1on RTX 4060: 4 passed, 0 failed, 0 ignored, 0 skipped (0 / 1024 wrong pixels for bothwave64 = trueandwave64 = false).XCL_ADAPTER="Microsoft Basic Render Driver" cargo test --release -p xcl --lib ps_ballot_tests -- --nocapture --test-threads=1: 4 passed, 0 failed (3 CPU validation tests ran; GPU draw test skipped withno GPU).XCL_ADAPTER=warp cargo test --release -p xcl --lib ps_ballot_tests -- --nocapture --test-threads=1: 4 passed, 0 failed (3 CPU validation tests ran; GPU draw test skipped withno wave64).cargo build --release --workspace: exit0.cargo test --release --workspace -- --test-threads=4: 1158 passed, 0 failed, 46 ignored across 21 test binaries, with 25SKIPPEDstderr lines:no wave64(32-lane RTX 4060 hardware)per-lane form: refused(#1426unsupported f16/f32 semantics in per-lane wave32 tests)cannot disable the driver cache (Windows Developer Mode is required)(pso_measurement_compiles_an_exact_synthetic_record)no heap windows(heap_window_out_of_memory_falls_back_to_the_switch_form)Regression run
Paired 60s
scripts/smoke.ps1runs on the same retail title (title: 29640639) and GPU (NVIDIA GeForce RTX 4060):Base (
origin/main,cbc296ab):This PR (
ad281429):No regressions (
1615vs1605frames,14518 MBvs14485 MBpeak commit,60 60 60presents per 2 s,0device removals,0crashes).Not tested
gfx_halfupper-half wave32-in-wave64 hardware path and liveamdxc64PSO compilation on AMD hardware (DXIL disassembly verifies zerodx.op.quadOpin VOPC pixel shaders, matching the #134 operand-quad-read shape).XCL_DIRECT_DXIL=allgameplay smoke (the pairedscripts/smoke.ps1runs used the default translator configuration).AI use
ballot_ps_quad/ballot_psimplementation inlanes.rs, the #134 operand-quad-read VOPC path inlower_valu.rs, and the regression tests, and ran all build, unit, GPU, WARP, and paired smoke checks.@JJAutoCompare on GitHub · 2026-11-25 03:39 UTC · original
XCL PR #2083 fixture verification
Tested
ad28142970c6be4ec7634ea786b0c1f21d5c8c40in the assigned clean, detached checkout on STOR-WINLAB. The live PR was open at that SHA before and after the run. The merged PR discussion timeline had zero entries at intake, and none of the 172 issue #42 comments matched the SHA, PR, or fixture.Tested
STOR-WINLAB ran Windows 11 Enterprise Evaluation 26200.9974 on an AMD Ryzen 7 3800X and Intel Arc A770, driver 32.0.101.9175. Rust was 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc), Cargo 1.100.0 (3acc79c0c), and the fixtures logged dxcompiler/dxil 1.9.2609.5 (compiler 01b62ad4) under
%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64.cargo test --locked -p xcl --lib --no-runexited 0 in 48.17 s. The unoptimized test build usedL:/XclTooling/pr1778-2e2ee55-20261125-020159/target, two Cargo jobs,CARGO_INCREMENTAL=0, andCARGO_PROFILE_DEV_DEBUG=CARGO_PROFILE_TEST_DEBUG=0. TEMP and TMP pointed at the run'stempdirectory.Ran the resulting
xcl-97fdf2b9ff8e1482.exeonce per fixture with--exact <fully-qualified-name> --nocapture --test-threads=1. The prefix for every name below isgpu::dxil::lanes::ps_ballot_tests::.direct_ps_ballot_uses_quad_ops_and_keeps_entry_exec_live_onlydirect_ps_constant_false_ballot_skips_quad_opsdirect_ps_non_vopc_carry_ballot_uses_quad_opgpu_direct_ps_masks_hold_helper_lanes_on_triangle_edgesTotal 4 passed, 0 failed, 0 ignored, 0 skipped. Each invocation exited 0 and reported 1,127 filtered out.
The three CPU fixtures have no optional GPU path and ran with an unmatched
XCL_ADAPTER. DXC validated and disassembled eight shader containers. The wave32 and wave64 forms each verified operandquadReadLaneAtand absence of predicatequadOp, exactly four reads in the isolated VOPC shader, and no quad ops in the entry-EXEC-only shader. The wave32 constant-false and carry cases verified absence of quad ops and presence ofquadOp.i32, respectively.The GPU test ran with
XCL_ADAPTER=A770inside& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test { ... }, launched usingpowershell.exe -NoProfile -ExecutionPolicy RemoteSigned -File gpu.ps1. The wrapper logged acquisition and release of the Arc mutex. Both unsplit program forms (wave64=truethenwave64=false) submitted a two-triangle draw and read back a 32×32 target. All 1,024 pixels per form passed the fixture's comparisons: absolute ddx and ddy each equal to 1, waterfall count within 1–64 or 1–32 for the respective form, and alpha equal to 1. The forms exercises_wqm,v_cndmask,s_and_saveexec, DPP derivatives, andv_readfirstlane.Not tested
Full workspace suite, title or smoke runs, other GPUs and drivers, and the physical hardware wave width chosen for these pixel shaders.
AI use
T3 Code / Codex gpt-6.2-sol ran the checked-in fixtures and wrote this report from the local results and fixture source.
@DarkPanda69 on GitHub · 2026-11-25 03:52 UTC · original
Native 64-lane AMD run with live
amdxc64PSO compilation, which this PR lists as not tested (the other report here is Arc).Tested: pass, head
ad28142applied on its basemaincbc296a, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.cargo test -p xcl --lib -- gpu:: --test-threads=4:gpu_direct_ps_masks_hold_helper_lanes_on_triangle_edgesok, so the pixel shader compiled and ran through the AMD driver. The 2 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1and_3, the same as onmaincbc296awithout this PR on this card.Not tested: the
gfx_halfwave32-in-wave64 path specifically; RDNA2/3.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@WebIdentity1 on GitHub · 2026-11-25 04:32 UTC · original
I’m checking one remaining AMD compiler shape: a pixel-shader waterfall loop whose V_ADD_CO_U32 carry depends on V_READFIRSTLANE, then feeds EXEC. The current GPU fixture covers VOPC predicates; the non-VOPC carry fixture validates/disassembles but does not draw. I’ll use a synthetic triangle-edge oracle on our AMD iGPU and RTX3090, preserving exact revisions and distinguishing compiler failures from output differences. This is an investigation, not yet a confirmed bug. AI assistance: Codex (GPT-6).
@JoaoPauluu on GitHub · 2026-11-25 05:22 UTC · original
A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, not the native-Windows path: this PR's 4 new tests pass, none skipped.
Tested
x86_64-pc-windows-gnu.ad28142as it is (merge base withmaincbc296a), no uncommitted changes. The lib test binary runs under Wine, one test per process.direct_ps_ballot_uses_quad_ops_and_keeps_entry_exec_live_only: okdirect_ps_constant_false_ballot_skips_quad_ops: okdirect_ps_non_vopc_carry_ballot_uses_quad_op: okgpu_direct_ps_masks_hold_helper_lanes_on_triangle_edges: okNot tested
AI use
@DavidM1911 on GitHub · 2026-11-25 05:26 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@MarcosMDev on GitHub · 2026-11-25 12:53 UTC · original
Test report:
ad28142against its basecbc296a, RTX 4060 8 GB (Windows): GPU tests, and what the new ballots cost in the driver on retail pixel shaders. Counts and timings only.Tests,
XCL_DIRECT_DXIL=all cargo test -p xcl --lib gpu:: -- --test-threads=4, debug: head 589 passed, 1 failed, 22 ignored; base 585 passed, 1 failed, 22 ignored. The failure isgpu_image_get_resinfo_1d_arrayon both, so it is not from this PR.Driver time. 24 distinct retail 1.0.2.1 PS programs, 8 per size at even spacing, direct DXIL, 4 windows. One
CreateGraphicsPipelineStateper program with a small generated VS with the PS's inputs. Order base, head, head, base; the table has both runs, as sums of 8 programs.This is a cost, not an argument against the fix: the base's masks drop helper lanes. It may be worth finding masks that are only ever read by their own lane, which need no ballot across the wave (as
x64_whole_livedoes for the split form). I have not tried that on this branch.Cold: a new exe basename per run; the second call for the same pipeline took 56 ms at most. NVIDIA's caches were not cleared, there was no ETW proof.
RTX 4060 (32.0.16.2101), Ryzen 7 5700X, 24 GB, Windows 11 26200, DXC 1.9.2609, rustc 1.100.0; timings release. Not tested: images or the title, the branch on today's
main, real VS / blend state, GPU time, the HLSL path on this sample, AMD.AI use: Claude Code (Claude Opus 5.5) ran the measurements and wrote this.
@MarcosMDev on GitHub · 2026-11-25 13:31 UTC · original
@Decodere, a follow-up to my cost report: I tried the idea at its end on
ad28142. It is the direct form of what the HLSL path already does withballot_px_local. I'm not opening a PR; it is yours if you want it.What:
whole_live(x64_masks::by_pc) is computed for pixel shaders too, and a mask that is not whole-live there is written as the lane's own bit,cond << lane31in the word of its half, instead ofballot_psor the VOPC quad reads. No wave or quad op. Helper lanes get their own condition.ballot_px_localalso ORs in theWaveActiveBallot; this leaves that out, since only the own bit is read. About 40 changed lines inkernel.rs,lower.rsandlower_valu.rs.Driver time, RTX 4060, direct DXIL, 21 retail 1.0.2.1 PS programs (7 per size), same harness as before, sums over 7. "Unfixed" is
ad28142with plainWaveActiveBallot, for scale.ad28142DXIL −10 to −14 %. 18 of 21 programs were faster with the switch, 19 of 21 with the heap. In the middle size, 2 of 7 were slower in both forms; I did not look into them. So it gives back about a third of the added cost in the other sizes. The rest are masks that really are read whole (
s_and_saveexecand the like).Tests,
XCL_DIRECT_DXIL=all cargo test -p xcl --lib gpu:: -- --test-threads=4: 587 passed, 3 failed, 22 ignored.gpu_direct_ps_masks_hold_helper_lanes_on_triangle_edgespasses. Failed:gpu_image_get_resinfo_1d_array, as on your base, and two of this PR's structure tests (direct_ps_ballot_uses_quad_ops_...,direct_ps_non_vopc_carry_ballot_uses_quad_op): they expect quad ops for a mask onlyv_cndmaskreads, which is what this removes. They would need a program that reads the mask whole.1 run per form; new exe basename per run, second call 9 ms at most; NVIDIA caches not cleared, no ETW. RTX 4060 (32.0.16.2101), Windows 11 26200, DXC 1.9.2609. Not tested: AMD (the #134 crash), images or the title, today's
main, GPU time.AI use: Claude Code (Claude Opus 5.5) wrote the change, ran the measurements and wrote this.
@upipibi on GitHub · 2026-11-25 17:20 UTC · original
NVIDIA test report for
ad28142(head as is, basecbc296a), for #1607's NVIDIA list. RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug, aftercargo build --workspace:cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2: 1149 passed, 0 failed, 46 ignored. The end-to-end title tests pass.main0829441on the same machine, same command: 1263 passed, 0 failed, 46 ignored (the PR's base is older, so it has fewer tests).hle::xaudio2, because its tests fail or hang on this machine onmaintoo. The PR doesn't touch it.no wave64on this card, 3 f16/f32 forms the per-lane path refuses, 1 no heap windows, and 1 PSO measurement that needs Developer Mode to turn the driver cache off.AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only; no title run.