Skip to content

Tests: cover Direct DXIL Module::optimize passes and GPU execution - #1842

Open
microwave805 wants to merge 1 commit into
xcl-dev:mainfrom
microwave805:tests-gpu-dxil-opt
Open

microwave805 wants to merge 1 commit into
xcl-dev:mainfrom
microwave805:tests-gpu-dxil-opt

Conversation

@microwave805

Copy link
Copy Markdown

Add standalone integration and GPU tests for the Direct DXIL module optimizer (crates/xcl/src/gpu/dxil/module/opt.rs), which currently has no dedicated unit or integration tests.

What is in it

  • crates/xcl/tests/gpu_dxil_opt.rs:
    • opt_constant_folding_and_identities_validate_and_run: verifies 32-bit constant folding (AShr, UDiv, URem, SExt, SLt, Add, Xor, Select) and algebraic identities (+0, &~0, *1, *0, x^x, select(c, x, x), bitcast(bitcast(x)), cmp(x, x)), checking DXIL disassembly and wave32 GPU execution against CPU values.
    • opt_cse_merges_dominators_isolates_siblings_and_keeps_wave_is_first_lane: verifies dominator-tree CSE across child blocks, sibling-branch undo-stack isolation, same-block waveActiveBallot CSE without hoisting across a divergent branch (verified on GPU via waveActiveBallot(true) returning odd_mask instead of 0xFFFF_FFFF), and waveIsFirstLane remaining unmerged.
    • opt_prunes_unreachable_blocks_and_collapses_trivial_phis: verifies unreachable-block pruning and second-pass trivial-phi collapse after CSE unifies diamond arms, plus GPU execution.
    • opt_dce_drops_dead_32bit_ops_but_preserves_64bit_flags: verifies DCE removes dead 32-bit ops while retaining dead i64/f64 ops so Int64Ops/Doubles shader flags stay consistent under DXC validation.
    • opt_leaves_malformed_use_before_def_for_writer_to_reject: verifies uses_well_formed leaves malformed forward-reference IR untouched so try_to_bitcode still reports an error.

Tested

  • NVIDIA GeForce RTX 3070 (driver 32.0.16.1742), AMD Ryzen 5 5600X, Windows 11 Pro (build 22631), DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), Rust 1.100.0 (stable-x86_64-pc-windows-msvc, debug)
  • On PR head 7753368 (based on main c4d37be):
    • cargo test -p xcl --test gpu_dxil_opt -- --nocapture: 5 passed, 0 failed, 0 ignored (0 skipped)
    • .\scripts\test.ps1 (cargo build --workspace && cargo test --workspace -- --test-threads=4): 964 passed, 0 failed, 43 ignored
    • SKIPPED GPU tests (23 pre-existing, 0 in gpu_dxil_opt): 18× no wave64 (lower::tests, lower_dxil::tests, recomp::tests), 3× per-lane form: refused (lower_dxil::tests: f16 arithmetic, f16 packed, f32 conversions), 1× no heap windows (heap_window_out_of_memory_falls_back_to_the_switch_form), 1× cannot disable the driver cache (shaders::tests::pso_measurement_compiles_an_exact_synthetic_record)

Regression run

  • Not needed: test-only PR adding crates/xcl/tests/gpu_dxil_opt.rs (no runtime or build-input files changed).

Not tested

  • AMD / wave64 GPUs, Intel GPUs, Linux/Wine, and retail titles

AI use

  • Antigravity (Gemini 4 Neon): inspected crates/xcl/src/gpu/dxil/module/opt.rs, wrote crates/xcl/tests/gpu_dxil_opt.rs and this PR description, and ran the verification commands above.

Add integration and GPU tests for gpu::dxil::module::opt (constant folding, algebraic identities, dominator-tree vs. sibling-branch CSE, same-block wave CSE without merging waveIsFirstLane or hoisting across divergent branches, unreachable-block and trivial-phi cleanup, 64-bit-preserving DCE, and the malformed-IR guard).

Every emitted shader is checked against DXC's validator and disassembled to verify the transformations; wave32 shaders run on the GPU and compare against CPU expectations.

Assisted-by: Antigravity (Gemini 4 Neon)
@DarkPanda69

Copy link
Copy Markdown

AMD run with native 64-lane waves, which this PR lists as not tested, plus an NVIDIA one.

Tested: pass, head 7753368 applied on main 689f2db, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.
cargo test -p xcl --test gpu_dxil_opt -- --test-threads=4 with XCL_ADAPTER set to each GPU:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, waves 32..64: 5 passed, 0 failed, 0 SKIPPED.
  • NVIDIA RTX 3060, driver 32.0.16.1088, waves 32 only: 5 passed, 0 failed, 0 SKIPPED.

cargo test -p xcl --lib -- gpu::recomp --test-threads=4 with this PR applied: 261 passed, 0 failed, 18 ignored on both; the SKIPPED lines are the same as on main.

Not tested: Intel; Linux / Wine; the whole workspace suite.

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

@futurepro62

futurepro62 commented Nov 24, 2026 •

Copy link
Copy Markdown

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

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, 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: 959 passed, 0 failed, 43 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: opt_constant_folding_and_identities_validate_and_run, opt_cse_merges_dominators_isolates_siblings_and_keeps_wave_is_first_lane, opt_prunes_unreachable_blocks_and_collapses_trivial_phis, opt_dce_drops_dead_32bit_ops_but_preserves_64bit_flags, opt_leaves_malformed_use_before_def_for_writer_to_reject.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 964 passed, 0 failed, 43 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).
  • On NVIDIA, --skip leaves out five tests where this PR's base has them. They fail on main 689f2db too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns their skips into failures. These are 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) and the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests (follow-up on #1651). 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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@JJAutoCompare

Copy link
Copy Markdown

Tested

PR #1842 was open at 775336821f5c95ecb329a4c06a8a5e14670cdac9 before and after testing. The assigned checkout was clean and detached at that SHA for the run. The PR description and three discussion comments showed no equivalent Arc A770 result.

STOR-WINLAB ran Windows 11 Enterprise Evaluation 25H2 (26200.9974), AMD Ryzen 7 3800X, and Intel Arc A770 (driver 32.0.101.9175). Rust and Cargo were 1.100.0, host x86_64-pc-windows-msvc. Each fixture reported DXC and DXIL 1.9.2609.5.

cargo test -p xcl --locked --test gpu_dxil_opt --no-run built successfully outside the GPU mutex. The unoptimized build used CARGO_BUILD_JOBS=2, CARGO_INCREMENTAL=0, CARGO_PROFILE_DEV_DEBUG=0, and CARGO_PROFILE_TEST_DEBUG=0. CARGO_TARGET_DIR=L:/XclTooling/pr1947-1831ec4-t3-97236edf/target, TEMP=TMP=L:/XclTooling/pr1842/tmp, XCL_ADAPTER=A770, and XCL_DXC_DIR=$env:LOCALAPPDATA/XclTooling/dxc-1.9.2609/bin/x64.

$exe = 'L:/XclTooling/pr1947-1831ec4-t3-97236edf/target/debug/build/xcl/551991fdf0dc4311/out/gpu_dxil_opt-551991fdf0dc4311.exe'
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
    & $exe --exact opt_constant_folding_and_identities_validate_and_run --test-threads=1 --nocapture
    & $exe --exact opt_cse_merges_dominators_isolates_siblings_and_keeps_wave_is_first_lane --test-threads=1 --nocapture
    & $exe --exact opt_prunes_unreachable_blocks_and_collapses_trivial_phis --test-threads=1 --nocapture
}

All three exact invocations exited 0. The checked-in DXIL validation and GPU result assertions passed with 3 passed, 0 failed, 0 ignored, 0 hardware skips, and 0 validator skips. The GPU mutex was released and the assigned Cargo target is available.

Not tested

Other fixtures, the workspace suite, retail titles, and other adapters or drivers.

AI use

T3 Code / Codex gpt-6.2-sol ran the commands, checked the logs, and prepared this report.

@throny throny added the off-goal Does not bear on the current goal (world loading); waits until it is reached label Nov 25, 2026
@github-actions

Copy link
Copy Markdown

Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 28, 2026
@BBareth

BBareth commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

merge-check claim
head: 7753368

@github-actions github-actions Bot added area:tests Unit, integration, e2e tests, or testtitle needs-1st-check Passes gates; needs first independent merge-check (#3041) labels Nov 30, 2026
@BBareth

BBareth commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: 9dfbe3e
head: 7753368
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 1 failed, 51 ignored; failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails on the base alone too (base: 2885 passed, 1 failed, 51 ignored, 28 SKIPPED lines). 28 SKIPPED lines, as on the base. The five new tests in crates/xcl/tests/gpu_dxil_opt.rs passed and ran on the GPU here (no new SKIPPED line): opt_constant_folding_and_identities_validate_and_run, opt_cse_merges_dominators_isolates_siblings_and_keeps_wave_is_first_lane, opt_prunes_unreachable_blocks_and_collapses_trivial_phis, opt_dce_drops_dead_32bit_ops_but_preserves_64bit_flags, opt_leaves_malformed_use_before_def_for_writer_to_reject.
review: no blocking finding; one new test file, every line read, no change outside tests. The tests build small compute kernels through the public Shader / Module API, check the optimized DXIL with the DXC validator and its disassembly, and compare GPU results with values computed on the CPU; they skip through runner::skip_test without DXC or wave32. Two nits, neither blocking: (1) in the last test the assertion err.contains("before") || err.contains("dominat") || !err.is_empty() is always true after expect_err unless the message is empty, so it only pins that emission fails; (2) several checks match disassembly text (", 13 ", "mul i32 ", "-4"), which ties them to the DXC disassembler's formatting.
performance: none at run time; the suite gains five tests (four with a DXC validation, three of them with a GPU run).
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.

@github-actions github-actions Bot added needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) labels Nov 30, 2026
@saintwolf

Copy link
Copy Markdown
Contributor

merge-check claim
head: 7753368

@saintwolf

Copy link
Copy Markdown
Contributor

merge-check
base: 9dfbe3e
head: 7753368
merge: clean (trial merge fba15a10037e364b4a0b746400730c984ae16408; git diff --check clean; +350/-0 in crates/xcl/tests/gpu_dxil_opt.rs)
build: cargo build --workspace -> ok (39 pre-existing warnings, none from the PR's files)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 1 failed, 51 ignored (lib 2737/1/31, integration 153/0/20); SKIPPED: 27 (22 "no wave64" — wave32-only GPU, 2 "no heap windows", 1 "cannot disable the driver cache (Developer Mode)", 2 "no xgameruntime.dll"); failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, pre-existing on this machine (fails identically on base 9dfbe3e, same "2D D16 resinfo clobbered v2/v3" assertion); all five new gpu_dxil_opt tests ran on this GPU (four with wave32 execution, one pure IR) and pass
review: test-only, one new integration test file, read in full; no unsafe, no new dependencies, existing public API only (build-confirmed). Minor nits, nothing blocking: opt_leaves_malformed_use_before_def_for_writer_to_reject's final assertion (err.contains("before") || err.contains("dominat") || !err.is_empty()) is nearly tautological via the third disjunct — any non-empty error passes; opt_constant_folding pins the folded constant via dis.contains("-4"), which is disassembly-format-dependent but fine as a pin.
performance: none; tests only.
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0, DXC 1.8.2502.11 (23992152) / OpenCode, Qwen 3.8 27B

@github-actions github-actions Bot added ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Nov 30, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 7753368

No open or merged PR adds integration tests of Module::optimize (crates/xcl/tests/gpu_dxil_opt.rs is new). #3269 and #3268, merged since, changed the optimizer, so the disassembly assertions need a rerun on current main.
In opt_leaves_malformed_use_before_def_for_writer_to_reject, the assertion err.contains("before") || err.contains("dominat") || !err.is_empty() is always true once expect_err passes, so it checks nothing about the error.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

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

Labels

area:tests Unit, integration, e2e tests, or testtitle off-goal Does not bear on the current goal (world loading); waits until it is reached ready-to-merge Has 2 independent safe merge-checks on current head (#3041) stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants