Direct DXIL: skip unused compare/DATA1 VGPR reads on single-operand atomics #2077
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!2077
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2077"
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?
@certified-retart on GitHub · 2026-11-25 03:16 UTC · original
certified-retart:dxil/atomic-no-spurious-vreg→main· +167 −6 · 3 files · 1 commits · openSkip reading the unused second/compare VGPR in Direct DXIL (
#1426) lowering for single-operand buffer, global/flat, image, and LDS atomics. Part of #1269.Previously all five Direct DXIL atomic paths unconditionally called
self.vreg(...)for the compare /DATA1operand even when the instruction only takes a single data operand:atomic64readcmpandcmp + 1on non-cmpswap/fcmpswap64-bit atomics.buffer_atomicreadvdata + 1on non-cmpswap/fcmpswap32-bit MUBUF atomics.flat_atomicreaddata + 1on non-cmpswap/fcmpswap32-bit global/flat atomics.dsreadf("DATA1")(which is0/v0in single-data DS encodings) on every DS atomic other thancmpst_*/mskor_b32.image_atomicreadvdata + 1on non-cmpswap/fcmpswapimage atomics.In per-instruction Direct DXIL this emitted dead VGPR loads; in the per-lane Direct DXIL bridge (
recomp/lower_dxil), it caused every single-operand atomic to be refused because the bridge only supplies the registers the instruction actually reads (rdna2::vgpr_uses).What is in it
crates/xcl/src/gpu/dxil/lower_mem.rs: gate the compare/DATA1self.vreg(...)reads inatomic64,buffer_atomic,flat_atomic, anddsso onlycmpswap/fcmpswap(andcmpst_*/mskor_b32for DS) read the second operand; passc(0)/c64(0)otherwise.crates/xcl/src/gpu/dxil/lower_image.rs: gateself.vreg(vdata + 1)inimage_atomiconmatches!(opn, "cmpswap" | "fcmpswap").crates/xcl/src/gpu/recomp/lower_dxil.rs: addper_lane_bridges_atomics_without_spurious_vreg_reads(wave32 and wave64 bridge + DXIL validation covering 32/64-bit MUBUF, global, image, and LDS 1-data and 2-data atomics) andper_lane_atomics_run_on_the_gpu(real GPU dispatch checking exact output and parity with per-instruction Direct DXIL).Measured impact (retail shader pack, 2,689 compute programs)
XCL_RECOMP_NO_HLSL=1 xcl shaders <pack> --recomp --top 25:579→705/2,689(+126CS programs, +21.8%).1,078→952(-126).BUFFER_ATOMIC_ADD563→0,BUFFER_ATOMIC_UMIN359→0,DS_WRXCHG_RTN_B3264→0,DS_ADD_U3260→0,DS_ADD_RTN_U3244→0,DS_MAX_U3235→0,DS_MIN_U3235→0,DS_OR_B3228→0).2,689 / 2,689CS and9,282 / 9,282MS ok.Tested
XCL_D3D12_DIR), DXC1.9.2602.17.cargo test -p xcl --lib -- per_lane_bridges_atomics_without_spurious_vreg_reads per_lane_atomics_run_on_the_gpu --nocapture: 2 passed, 0 failed (real GPU execution + per-instruction parity).cargo test --workspace -- --test-threads=4: all workspace unit and integration tests passed, 0 failed.XCL_RECOMP_NO_HLSL=1 target\release\xcl.exe shaders <pack> --recomp --top 25on1bcd2c7: verified705per-lane CS ok and0single-operand atomic refusals.Regression run
main:
PR:
Not tested
IMAGE_ATOMIC_CMPSWAPin the per-lane bridge (its two-VGPRDMASK=3vgpr_usestracking is separate from this PR).AI use
@JJAutoCompare on GitHub · 2026-11-25 03:26 UTC · original
Tested
1bcd2c7a9abee4b41ba23dbc33c07f8248003a8e. The PR was open at this SHA before and after testing. The existing detached checkout matched that SHA and was clean both times. The PR discussion and GPU-results issue #42 contained no equivalent Arc A770 result when checked.26200.9974, AMD Ryzen 7 3800X (6 cores and 12 logical processors exposed), Intel Arc A770 Graphics driver32.0.101.9175, rustc1.100.0 (0ef1bc386)and Cargo1.100.0onx86_64-pc-windows-msvc. Both fixture logs confirm the selected directory supplieddxcompiler.dll1.9.2609.5 (01b62ad4)anddxil.dll1.9.2609.5.[32, 10, 32, 0, 42, 64, 32, 0, 64, 90], matched the per-instruction Direct DXIL readback exactly.0and neither log contained aSKIPPEDnotice. The prebuild and CPU fixture ran outside the Arc mutex. The wrapper logged acquisition and release around the GPU fixture.Cargo identified the executable in
prebuild.jsonl. The test profile was unoptimized with debug info disabled.prebuild.stderr.log,cpu.stdout.log,cpu.stderr.log,gpu.stdout.log, andgpu.stderr.logare in the run directory.Not tested
Native wave64 GPU dispatch, GPU image atomics, GPU atomic forms outside the readback fixture, per-lane image compare-swap lowering, HLSL parity, other adapters or drivers, retail shaders or titles, smoke runs, or the full suite.
AI use
T3 Code / Codex (
gpt-6.2-sol) ran the two checked-in fixtures and wrote this report.@futurepro62 on GitHub · 2026-11-25 03:37 UTC · original
NVIDIA and AMD full-suite run, to go with the Intel Arc A770 report above. Tested exact head
1bcd2c7(on its basecbc296a).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1144 passed, 0 failed, 44 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_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,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.per_lane_bridges_atomics_without_spurious_vreg_reads,per_lane_atomics_run_on_the_gpu.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1155 passed, 0 failed, 46 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on maincbc296atoo, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
@DarkPanda69 on GitHub · 2026-11-25 03:53 UTC · original
AMD run with native 64-lane waves, which this PR lists as not tested (the other reports here are Arc).
Tested: pass, head
1bcd2c7applied 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:per_lane_atomics_run_on_the_gpuandper_lane_bridges_atomics_without_spurious_vreg_readsok. The 2 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1and_3, the same as onmaincbc296awithout this PR on this card.Not tested:
IMAGE_ATOMIC_CMPSWAPin the per-lane bridge.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@DavidM1911 on GitHub · 2026-11-25 05:10 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!
@JoaoPauluu on GitHub · 2026-11-25 05:22 UTC · original
A run with vkd3d-proton as the host D3D12:
per_lane_atomics_run_on_the_gpufails here, with the per-lane and per-instruction forms agreeing with each other on the wrong values.Tested
x86_64-pc-windows-gnu.1bcd2c7as it is (merge base withmaincbc296a), no uncommitted changes. The lib test binary runs under Wine, one test per process.per_lane_bridges_atomics_without_spurious_vreg_reads: ok.per_lane_atomics_run_on_the_gpu: fails atlower_dxil.rs:1149,BUFFER_ATOMIC_ADD,left: 90,right: 32.println!before the first assertion and reverted it afterwards (the result above is from the unchanged head). Three runs, each giving the same output: So the buffer UMIN, ADD_X2, CMPSWAP and global atomics match.out[0]holds 90 (=0x5A, the value expected inout[9]), andout[8]/out[9]stay 0. That looks like lane 0's twoGLOBAL_STORE_DWORDs of the LDS results landing at byte 0 rather than 32/36, or the LDS part going wrong. I have not narrowed it down. Both forms give the same values, so this is not a per-lane-only difference.Not tested
main's code for these instructions (the test is new in this PR), native Windows, AMD.AI use
@certified-retart on GitHub · 2026-11-25 06:40 UTC · original
Thanks for testing on vkd3d-proton and printing all 10 dwords, @JoaoPauluu!
The fact that both
per-laneandper-inst(which is untouchedmainlowering) produce the exact same[90, 10, 32, 0, 42, 64, 32, 0, 0, 0]— while native Windows NVIDIA (RTX 5070 / 5070 Ti / 3060 Ti), AMD iGPU, and Intel Arc A770 all produce[32, 10, 32, 0, 42, 64, 32, 0, 64, 90]— confirms this isn't a per-lane or #2077-specific bug.Very interesting clue though:
90 == 0x5Ais the exact result ofDS_CMPST_RTN_B32+DS_MSKOR_RTN_B32+DS_READ_B32, so the LDS atomics succeeded, and then both lane-0GLOBAL_STORE_DWORDs (atbyte 32andbyte 36) appear to have written tobyte 0(overwritingout[0]with64then90while leavingout[1]=10andout[8..9]=0). That smells like adxil-spirv/ NVIDIA Linux Vulkan quirk aroundrawBufferStore(or itsundefelementOffset) when the sameRawBufferUAV also hasatomicBinOp/atomicCompareExchangein the same shader. Worth investigating separately if it reproduces onmain!@bmjask on GitHub · 2026-11-25 17:18 UTC · original
@certified-retart can you join our discord please, message the mods
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.