Skip to content

Direct DXIL: skip read64 and EXEC_HI for wave32 and b32 saveexec/wrexec - #2073

Open
Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-1269-dxil-saveexec-b32
Open

Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-1269-dxil-saveexec-b32

Conversation

@Decodere

Copy link
Copy Markdown
Contributor

What is in it

Bring Direct DXIL saveexec and wrexec lowering for wave32 and _b32 forms into parity with the HLSL path (merged in #191).

Part of #1269

  • Problem: In crates/xcl/src/gpu/dxil/lower.rs, Lw::salu unconditionally called self.read64(d, ins[0], false) on _b64 saveexec/wrexec instructions even in wave32 (!self.wave64), and unconditionally called self.sreg(127) (EXEC_HI) and computed the high-half result t1 before branching on if !self.wave64 || name.ends_with("_b32"):
    • On 32-bit-only source encodings such as m0 (SSRC0 = 124), wave32 S_AND_SAVEEXEC_B64 s0, m0 failed translation with Err("s_and_saveexec_b64 s[0:1], m0: op") because code64(124, ...) returns None, even though the HLSL path accepts it.
    • On SGPR sources, wave32 _b64 forms spuriously touched s[n+1] in init.touched, and both wave32 and _b32 forms spuriously touched EXEC_HI (s127) and emitted dead high-half IR.
  • Fix: Move source reading and EXEC_HI (sreg(127)) handling inside the if !self.wave64 || name.ends_with("_b32") vs else (wave64 _b64) branches in crates/xcl/src/gpu/dxil/lower.rs:
    • Wave32 / _b32 branch reads a single 32-bit operand (self.read(d, ins[0], false)), reads only EXEC_LO (self.sreg(126)), updates EXEC_LO and SCC, and writes 32-bit dst (t0 for wrexec, old el for saveexec) without touching s[n+1] or EXEC_HI.
    • Wave64 _b64 branch reads the 64-bit source pair (self.read64), updates EXEC_LO + EXEC_HI + SCC, and writes the 64-bit destination pair unchanged.
  • Tests: Add saveexec_tests at the end of crates/xcl/src/gpu/dxil/lower.rs:
    • direct_wave32_and_b32_saveexec_skip_read64_and_exec_hi: verifies wave32 S_AND_SAVEEXEC_B64 s0, m0 translates and validates, checks Lw::init.touched across wave32 _b64/_b32/wrexec and wave64 _b32 forms (confirming neither s11 nor s127 is touched), checks wave32 disassembly emits only one and i32, and checks wave64 S_AND_SAVEEXEC_B64 control still touches s10, s11, EXEC_LO, and EXEC_HI.
    • gpu_direct_wave32_saveexec_and_wrexec: wave32 Direct DXIL GPU test (guarded by runner::wave32_supported()) executing S_AND_SAVEEXEC_B64 s0, m0, S_OR_SAVEEXEC_B32 s2, s10, and S_ANDN2_WREXEC_B64 s4, s12 and asserting exact s0/s2/s4/EXEC_LO/SCC results while s1, s5, and EXEC_HI (s127) keep their initial sentinel values.

Tested

  • Hardware & toolchain: NVIDIA GeForce RTX 4060 8 GB (driver 621.14, wave32), Intel Core i5-11400F, 32 GB RAM, Windows 11 Home build 26200, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5 (01b62ad4).
  • Pre-fix failure (unfixed origin/main cbc296ab with new test added, debug): cargo test -p xcl --lib gpu::dxil::lower::saveexec_tests::direct_wave32_and_b32_saveexec_skip_read64_and_exec_hi -- --nocapture -> 0 passed; 1 failed (panicked: wave32 S_AND_SAVEEXEC_B64 s0, m0: "s_and_saveexec_b64 s[0:1], m0: op").
  • Post-fix targeted (release, identical code tree as d8f8dd33): cargo test --release -p xcl --lib gpu::dxil::lower::saveexec_tests -- --nocapture -> 2 passed; 0 failed; 0 ignored (both CPU/disassembly test and RTX 4060 wave32 GPU test).
  • Full workspace (release, identical code tree as d8f8dd33): cargo build --release --workspace + cargo test --release --workspace -- --test-threads=4 --nocapture -> 1156 passed, 0 failed, 46 ignored across 21 test binaries.
  • SKIPPED lines (27 total, all pre-existing on this wave32 Windows host without Graphics Tools / Developer Mode / heap windows):
    • 20 no wave64 skips (4 in gpu::recomp::lower::tests, 14 in gpu::recomp::lower_dxil::tests, 2 in gpu::recomp::tests).
    • 3 pre-existing wave32 per-lane form: refused skips in gpu::recomp::lower_dxil::tests (f16 arithmetic, f16 packed, f32 conversions).
    • 2 D3D12 debug layer skips (test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dll; uploads_start_from_each_subresources_state: 0x887A002D).
    • 1 shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable driver cache without Windows Developer Mode.
    • 1 heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows.

Regression run

Paired 60 s retail title runs with scripts/smoke.ps1 (release build, same title, clean working tree) on origin/main (cbc296ab) and this PR (d8f8dd33):

main:

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1584 (PresentX 1585)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14481 MB

this PR:

xcl-smoke v1
commit: d8f8dd33d9b228c45644d0aff1d30d1dab2e29f4
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1617 (PresentX 1617)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14485 MB

Not tested

  • AMD / Intel GPUs, native wave64 hardware GPU execution (wave64 S_AND_SAVEEXEC_B64 translation/validation and init.touched were tested on CPU only), D3D12 debug layer, heap windows, and Linux/Wine.
  • Whether the retail smoke title hits wave32 S_*_SAVEEXEC_B64 with a 32-bit-only source; the paired smoke run is a regression check only.

AI use

Google Antigravity (Gemini 4 Neon) wrote the fix, tests, and this PR description; all builds, tests, and paired retail smoke runs were executed locally on the hardware listed above.

In crates/xcl/src/gpu/dxil/lower.rs, Lw::salu unconditionally called read64 on _b64 saveexec/wrexec forms even in wave32 (!self.wave64) and unconditionally read sreg(127) (EXEC_HI) before branching on (!self.wave64 || name.ends_with("_b32")). On 32-bit-only source encodings such as m0 (SSRC0 = 124), wave32 S_AND_SAVEEXEC_B64 failed translation with Err("...: op"), and on SGPR sources it spuriously touched s[n+1] and EXEC_HI (s127).

Move source reads and EXEC_HI handling inside the wave32/_b32 vs wave64 _b64 branches to mirror HLSL (xcl-dev#191), and add unit/disassembly and wave32 RTX 4060 GPU regression tests in lower.rs.

Part of xcl-dev#1269

Assisted-by: Google Antigravity (Gemini 4 Neon)
@JJAutoCompare

Copy link
Copy Markdown

PR #2073 compatibility verification

Tested

PR #2073 was open at exact head d8f8dd33d9b228c45644d0aff1d30d1dab2e29f4 before and after testing. GitHub’s PR page, refs/pull/2073/head, and the reused clean checkout agreed after the run at 2026-11-25T03:06:52.4996740Z.

  • CPU, DXC validation and disassembly — direct_wave32_and_b32_saveexec_skip_read64_and_exec_hi: 1 passed, 0 failed, 0 ignored, 0 skipped. 1,125 filtered out, exit 0, 0.20 s. Wave32 S_AND_SAVEEXEC_B64 translated and validated with m0. The disassembly assertion checked one and i32 for the SGPR-source example. Register-touch assertions covered both wave32 and _B32 cases, and the wave64 _B64 control validated and touched both halves.
  • Native wave32 hardware — gpu_direct_wave32_saveexec_and_wrexec: 1 passed, 0 failed, 0 ignored, 0 skipped. 1,125 filtered out, exit 0, 0.16 s. The Arc A770 dispatched the signed direct-DXIL fixture with the wave size fixed at 32. Eight readback assertions covered EXEC_LO, SCC, the destination SGPRs and preserved high halves including EXEC_HI across the three-instruction sequence.
  • Environment — Windows 11 Enterprise Evaluation x64 build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc), Cargo 1.100.0 (3acc79c0c), DXC and DXIL 1.9.2609.5 (DXC build 01b62ad4). Both test logs show the selected DXC and DXIL DLLs.

Commands

The unoptimized test binary was prebuilt outside the Arc mutex in 63.801 s. The GPU confirmation ran inside Invoke-ArcTest.ps1 using process-scoped RemoteSigned. It took 78.13 s including lock wait. An initial GPU invocation also returned an ordinary libtest pass, but PowerShell mishandled its combined stderr. The counts above use the confirmation invocation with separate streams. The original log is preserved.

$env:CARGO_TARGET_DIR = 'L:/XclTooling/pr1512-tiling-edges-fddfa267/target'
$env:CARGO_BUILD_JOBS = '2'
$env:CARGO_INCREMENTAL = '0'
$env:CARGO_PROFILE_DEV_DEBUG = '0'
$env:CARGO_PROFILE_TEST_DEBUG = '0'
$env:XCL_ADAPTER = 'A770'
$env:XCL_DXC_DIR = Join-Path $env:LOCALAPPDATA 'XclTooling/dxc-1.9.2609/bin/x64'
$env:TEMP = 'L:/XclTooling/pr2073/temp-20261125T030153830Z'
$env:TMP = $env:TEMP
cargo test -p xcl --lib --no-run
$binary = 'L:/XclTooling/pr1512-tiling-edges-fddfa267/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe'
& $binary 'gpu::dxil::lower::saveexec_tests::direct_wave32_and_b32_saveexec_skip_read64_and_exec_hi' --exact --nocapture --test-threads=1

# Script block encoded as UTF-16LE for the child PowerShell's -EncodedCommand.
# Child options were -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -OutputFormat Text.
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
    & $binary 'gpu::dxil::lower::saveexec_tests::gpu_direct_wave32_saveexec_and_wrexec' --exact --nocapture --test-threads=1
}

In the actual child command, the binary path was passed as a literal. The logs under L:/XclTooling/pr2073 are:

  • prebuild-d8f8dd3-20261125T030153830Z.log
  • cpu-dxc-d8f8dd3-20261125T030153830Z.log
  • arc-wave32-confirm-d8f8dd3-20261125T030153830Z.stdout.log and arc-wave32-confirm-d8f8dd3-20261125T030153830Z.stderr.log
  • arc-wave32-d8f8dd3-20261125T030153830Z.log (initial capture)

The public PR discussion had no separate discussion anchors before or after the run. The PR description already records the author's RTX 4060 results. The public GPU results issue #42 had no matching reference to this head or either fixture in the returned discussion. Publication was left to the coordinator.

Not tested

Native or split wave64 hardware execution, other adapters, retail titles, smoke tests, performance, release builds, and the full workspace suite. The checked-in CPU wave64 control is included above.

AI use

T3 Code / Codex (gpt-6.2-sol) executed the checked-in fixtures, checked the logs and live SHA, and signed this empirical report.

@JoaoPauluu

Copy link
Copy Markdown

A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, a different compiler from a native-Windows run: this PR's 2 new tests pass.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257, DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. d8f8dd3 as it is (merge base with main cbc296a), no uncommitted changes. The lib test binary runs under Wine, one test per process.
    • direct_wave32_and_b32_saveexec_skip_read64_and_exec_hi: ok, not skipped
    • gpu_direct_wave32_saveexec_and_wrexec: ok, not skipped

Not tested

  • the whole suite on this head, a retail title, native Windows, AMD.

AI use

  • Claude Code (Claude Opus 5.5) built the commit, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@DarkPanda69

Copy link
Copy Markdown

Native-wave64 AMD run on Windows, which this PR lists as not tested (the reports above are Intel and NVIDIA).

Tested: pass, head d8f8dd3 applied on its base main cbc296a, 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:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, waves 32..64: 586 passed, 2 failed, 22 ignored. gpu_direct_wave32_saveexec_and_wrexec ok. The 2 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 and _3, the same as on main cbc296a without this PR on this card.
  • NVIDIA RTX 3060, driver 32.0.16.1088: 588 passed, 0 failed, 22 ignored.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@Parakeet-Wheat

Copy link
Copy Markdown

NVIDIA RTX 3070 on native Windows, head d8f8dd3 on its base cbc296a (current main): both new tests fail without the fix and pass with it, the whole suite passes, and the smoke pair is within the limits. This adds the whole-suite counts and the smoke pair to the test runs above.

Tested

  • NVIDIA GeForce RTX 3070 8 GB (driver 610.88, 32-lane waves), Ryzen 5 5600X, 32 GB, Windows 11 26300, Rust 1.95.0 stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11, retail 1.0.2.1. Head d8f8dd3 (one commit on main cbc296a), checked out clean. Tests in the debug profile, smoke in release.
  • cargo test -p xcl --lib saveexec_tests -- --nocapture --test-threads=1:
    • on cbc296a with the PR's lower.rs but its two Lw::salu hunks (the fix) reverted: 2 failed, 0 passed. Both stop at s_and_saveexec_b64 s[0:1], m0: op (direct_wave32_and_b32_saveexec_skip_read64_and_exec_hi at the wave32 m0 translate, gpu_direct_wave32_saveexec_and_wrexec at its direct translate);
    • on d8f8dd3: 2 passed, 0 failed, not skipped.
  • .\scripts\test.ps1 (cargo build --workspace, then cargo test --workspace -- --test-threads=4) on d8f8dd3: 1156 passed, 0 failed, 46 ignored, exit 0. SKIPPED, 25: 20 × no wave64, 3 × per-lane form refused (V_CVT_F16_F32, V_PK_MUL_F16, V_MUL_F16: "its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's"), 1 × no heap windows, 1 × cannot disable the driver cache (Windows Developer Mode required).

Regression run (scripts/smoke.ps1 -Game <folder> -Seconds 60, the same title, back to back, menus, no input; unedited). main cbc296a:

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 3070
title: 3d7db37d
seconds: 60
exit: 0x0
frames shown: 1481 (PresentX 1481)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17947 MB

PR head d8f8dd3:

xcl-smoke v1
commit: d8f8dd33d9b228c45644d0aff1d30d1dab2e29f4
gpu: NVIDIA GeForce RTX 3070
title: 3d7db37d
seconds: 60
exit: 0x0
frames shown: 1549 (PresentX 1549)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17822 MB

That is 105 % of main's frames and 99 % of its peak commit.

Not tested

  • Native wave64 (the 20 no wave64 skips above), AMD, a world run (the smoke stays in the menus, so it does not show whether the title reaches a wave32 saveexec with an m0 source), the tests on game data (XCL_SAMPLE_* not set).

AI use

  • Claude Code (Claude Sonnet 5.5) ran the tests and wrote this report. The account owner has not reviewed it.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants