Skip to content

Direct DXIL: route split-wave64 GS-only entry through gate block - #2079

Open
Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-1269-dxil-gs-only-gate
Open

Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-1269-dxil-gs-only-gate

Conversation

@Decodere

Copy link
Copy Markdown
Contributor

What is in it

Route Block(0) through the gate block when translating split-wave64 GS-only geometry shaders in Direct DXIL.

Part of #1269

  • Problem: In crates/xcl/src/gpu/dxil/kernel.rs, when gs_only == true (split && gs_start == Some(0)), translate_on_this_thread created a gate block (lw.edge(Block(0), gate) and lw.cond_br(up, exit, h0)) to confine GS-only execution to the lower 32-lane hardware wave and registered gate (not Block(0)) as the SSA entry predecessor of h0 and exit. However, line 391 unconditionally terminated Block(0) with lw.s.m.br(h0); instead of branching to gate. This caused two bugs:
    1. Any split-wave64 GS-only shader whose entry block (pc == 0) is a loop header failed Direct DXIL construction/validation (forward reference ... blocks must be in dominance order) because h0's PHIs referenced unreachable gate.
    2. Straight-line split-wave64 GS-only shaders bypassed gate so both hardware waves (lanes 32..63 in addition to lanes 0..31) executed the GS body in parallel, double-executing global atomics/stores and clobbering LDS.
  • Fix: Capture let first = if gs_only { ... gate } else { ... h0 }; in crates/xcl/src/gpu/dxil/kernel.rs and terminate Block(0) with lw.s.m.br(first);.
  • Tests: Add gs_only_tests at the end of crates/xcl/src/gpu/dxil/kernel.rs:
    • direct_gs_only_split_routes_entry_through_gate_and_validates_entry_loop: translates and validates a split-wave64 GS-only program whose entry block (pc == 0) is a loop header.
    • gpu_direct_gs_only_split_skips_upper_wave: wave32 Direct DXIL GPU test (guarded by runner::wave32_supported()) dispatching a 1-group ([64, 1, 1]) split GS-only shader with GLOBAL_ATOMIC_ADD of 1 to mem[0] and asserting mem[0] == 32 (not 64).

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 failures verified on origin/main cbc296ab (debug):
    • direct_gs_only_split_routes_entry_through_gate_and_validates_entry_loop: panicked with "direct DXIL builder error: forward reference to value 106 at instruction 105 (blocks must be in dominance order)".
    • gpu_direct_gs_only_split_skips_upper_wave (with lw.s.m.br(h0);): panicked on RTX 4060 with assertion left == right failed: left: 64, right: 32.
  • Post-fix targeted (release, fa4bfd11):
    • cargo test --release -p xcl --lib gpu::dxil::kernel::gs_only_tests -- --nocapture (RTX 4060) -> 2 passed; 0 failed; 0 ignored (0 skips).
    • XCL_ADAPTER="Microsoft Basic Render Driver" cargo test --release -p xcl --lib gpu::dxil::kernel::gs_only_tests -- --nocapture -> 2 passed; 0 failed; 0 ignored (CPU entry-loop validation passed; GPU dispatch skipped cleanly via runner::wave32_supported()).
    • cargo test --release -p xcl --lib gpu::dxil::geometry_tests -- --nocapture (RTX 4060) -> 2 passed; 0 failed; 0 ignored (geometry_forms_validate and gpu_geometry_direct_records).
  • Full workspace (release, fa4bfd11): 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 (fa4bfd11):

main:

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

this PR:

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

Not tested

  • AMD / Intel GPUs, native wave64 hardware (where split == false), D3D12 debug layer, heap windows, and Linux/Wine.
  • Whether the retail smoke title dispatches a split-wave64 GS-only geometry shader (gs_start == Some(0)); 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/kernel.rs, when translating a split-wave64 GS-only geometry shader (gs_only == true), translate_on_this_thread created a gate block to confine execution to the lower 32-lane hardware wave (cond_br(up, exit, h0)) and registered gate as the SSA entry predecessor of h0 and exit, but then unconditionally closed Block(0) with br(h0) instead of br(gate).

This caused two bugs: (1) any split GS-only shader whose entry block is a loop header failed DXIL construction/validation because h0's entry PHI predecessor (gate) was unreachable, and (2) straight-line split GS-only shaders bypassed gate so lanes 32..63 executed the GS body in parallel with lanes 0..31.

Capture first (gate when gs_only, else h0) and branch Block(0) to first. Add unit/validator and RTX 4060 wave32 GPU regression tests in kernel.rs.

Part of xcl-dev#1269

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

futurepro62 commented Nov 25, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head fa4bfd1 (on its base cbc296a).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_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.
  • The new tests ran and passed: direct_gs_only_split_routes_entry_through_gate_and_validates_entry_loop, gpu_direct_gs_only_split_skips_upper_wave.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, 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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main cbc296a too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@JJAutoCompare

Copy link
Copy Markdown

Independent focused verification of #2079 on STOR-WINLAB (2026-11-25).

Tested

  • GitHub showed the PR open at fa4bfd1149330ae4e0831702a9ce0eddb327981e before and after. The assigned worktree matched that SHA and was clean and detached at both checks.
  • Windows 11 Enterprise Evaluation 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 x86_64-pc-windows-msvc, DXC/DXIL 1.9.2609.5. Both fixtures logged the expected DXC package. Unoptimized test profile with two Cargo jobs, incremental and dev/test debug info disabled. XCL_ADAPTER=A770 and XCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64.
cargo test --locked -p xcl --lib --no-run
cargo test --locked -p xcl --lib gpu::dxil::kernel::gs_only_tests::direct_gs_only_split_routes_entry_through_gate_and_validates_entry_loop -- --exact --nocapture --test-threads=1
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
    cargo test --locked -p xcl --lib gpu::dxil::kernel::gs_only_tests::gpu_direct_gs_only_split_skips_upper_wave -- --exact --nocapture --test-threads=1
}
  • Prebuild exited 0 outside the lock. The CPU fixture exited 0 after translating the split GS-only entry loop and validating its DXIL.
  • The GPU fixture exited 0 under the Arc lock. It dispatched [1, 1, 1] groups of [64, 1, 1] threads with two 32-lane hardware waves. Starting from zero, the atomic readback satisfied mem[0] == 32, the fixture's assertion that only the lower wave contributed.
  • Each exact filter reported 1 passed, 0 failed, 0 ignored, 0 explicit skips and 1,125 filtered out. The GPU result is from the invocation with complete stdout and stderr. The first invocation printed a pass and released the lock, but PowerShell failed to decode part of its stderr. The repeat used separate output files from a fresh powershell.exe -NoProfile -ExecutionPolicy RemoteSigned process.
  • The author reports these fixtures on RTX 4060. The existing independent comment reports NVIDIA and AMD coverage at this head. The live discussion showed no Arc A770 or STOR-WINLAB result at the final check.

Not tested

  • Full workspace suite, base-commit comparison, retail smoke, native wave64 and other adapters.

AI use

  • T3 Code / Codex gpt-6.2-sol ran the fixtures and wrote this report.

@SzczepanGrela

Copy link
Copy Markdown

Linux/RADV + Wine GPU test report on PR #2079 head fa4bfd1 (fast-forward onto origin/main cbc296a, rustc 1.97.1, zero compiler warnings).

Tested

  • CachyOS Linux (kernel 7.3.0-5-cachyos), AMD Radeon RX 9070 (RADV GFX1201, device 0x7550, native wave64, Mesa 26.2.5-arch3.1, Vulkan 1.4.354), GE-Proton11-12 (wine-11.0 (Staging), vkd3d-proton v3.1-1-g8293130eb), DXC 1.9.2602.17 (21d28f72). Cross-built x86_64-pc-windows-gnu release (--lib, 39.37 s) with XCL_REQUIRE_GPU=wave64 XCL_NETWORK=0.
  • gs_only_tests --test-threads=1 --nocapture (direct_gs_only_split_routes_entry_through_gate_and_validates_entry_loop and gpu_direct_gs_only_split_skips_upper_wave): 2 passed, 0 failed in all 4 env modes: default (0.11 s), XCL_SPLIT_WAVE64=1 (0.08 s), XCL_DIRECT_DXIL=all (0.08 s), and XCL_DIRECT_DXIL=all XCL_SPLIT_WAVE64=1 (0.08 s).
  • gpu::dxil::geometry_tests --test-threads=1 (geometry_forms_validate, gpu_geometry_direct_records): 2 passed, 0 failed in default env (0.16 s, vs origin/main cbc296a 0.17 s) and XCL_DIRECT_DXIL=all (0.16 s, vs origin/main cbc296a 0.19 s).
  • gpu::dxil --skip ops_tests::integer_ops_match_cpu --skip ops_tests::uaddc_and_usubb_match_cpu --test-threads=1: 121 passed, 1 failed, 3 ignored (2.64 s), vs origin/main cbc296a 119 passed, 1 failed, 3 ignored (3.26 s; +2 passed from gs_only_tests, identical single failure gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_2 at crates/xcl/src/gpu/dxil/fuzz_tests.rs:1171:21, seed 1003: res[713] = 0x1, CPU 0x0).
  • gpu::recomp::tests::gpu_ --test-threads=1 --skip gpu_sparse_vram_descriptors_buffers_and_xmem --skip gpu_uma_import_check_at_init --skip gpu_unified_memory_arena:
    • Default env: 99 passed, 1 failed, 1 ignored (4.15 s), vs origin/main cbc296a 99 passed, 1 failed, 1 ignored (4.50 s); identical failure gpu_nonfused_mad_and_mac_prevent_fma_contraction.
    • XCL_DIRECT_DXIL=all: 96 passed, 4 failed, 1 ignored (2.30 s), vs origin/main cbc296a 96 passed, 4 failed, 1 ignored (2.48 s); identical 4 failures (gpu_f64_math_random, gpu_f64_roots, gpu_image_get_resinfo_1d_array, gpu_nonfused_mad_and_mac_prevent_fma_contraction).
    • XCL_SPLIT_WAVE64=1: run 1 89 passed, 11 failed, 1 ignored (5.03 s) and run 2 90 passed, 10 failed, 1 ignored (4.67 s), vs origin/main cbc296a run 1 89 passed, 11 failed, 1 ignored (5.27 s) and run 2 89 passed, 11 failed, 1 ignored (4.83 s). PR #2079 run 1 matches origin/main cbc296a run 2 on the exact same 11 failing tests (including gpu_grouped_loads_bounds_and_inactive_lanes failing with s127: 0x0 / 0xffff while gpu_split_wave64_masks_read_whole_after_partial_writes passed), and PR #2079 run 2 passed both of those tests.

Not tested

  • Retail game shader packs, scripts/smoke.ps1, integration test binaries, --lib modules outside gpu::dxil and gpu::recomp::tests::gpu_, and XCL_DIRECT_DXIL=1 on recomp (no retail title files locally).
  • gpu::dxil::ops_tests::integer_ops_match_cpu and uaddc_and_usubb_match_cpu (skipped: pre-existing vkd3d-proton v3.1 / libvulkan_radeon.so abort exit 3).
  • gpu_sparse_vram_descriptors_buffers_and_xmem, gpu_uma_import_check_at_init, and gpu_unified_memory_arena (skipped: pre-existing Wine in-process COM vtable swap).

AI use

  • Diff audit, test execution, and summary drafted with Antigravity (Gemini 4 Neon) multi-agent verification and verified by me before posting.

@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, not the native-Windows path: this PR's 2 new tests pass, none skipped.

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. fa4bfd1 as it is (merge base with main cbc296a), no uncommitted changes. The lib test binary runs under Wine, one test per process.
    • direct_gs_only_split_routes_entry_through_gate_and_validates_entry_loop: ok
    • gpu_direct_gs_only_split_skips_upper_wave: ok

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants