Skip to content

Direct DXIL: geometry mode, MSAA loads and directed f32 rounding - #1679

Merged
raylitebull merged 12 commits into
xcl-dev:mainfrom
bmjask:shaders/direct-dxil-followup
Nov 24, 2026
Merged

raylitebull merged 12 commits into
xcl-dev:mainfrom
bmjask:shaders/direct-dxil-followup

Conversation

@bmjask

@bmjask bmjask commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #1426.

What is in it

  • Geometry mode (ES+GS) in the direct translator (lower_geom.rs, kernel::translate_geometry, cfg::Cfg::build_geometry): the recompiler's Mode::Geometry compute pass as direct DXIL — the ES for the three vertices of 21 triangles per group, s_setpc_b64 into the GS, s_sendmsg GS emit / cut building strip triangles per lane, the mesh record written after wave prefix sums. The split wave64 form runs the ES in both hardware waves, then a group barrier and the GS in the lower wave, as the HLSL kernel does. pso::console_geometry tries it under XCL_DIRECT_DXIL=1 (logged HLSL fallback); coverage routes Mode::Geometry. Sweep: 200/200 incl. all 3 GS programs. CfgBlock::pc is kept for irreducible-CFG split copies.
  • MSAA: Texture2DMS / Texture2DMSArray ops, MSAA image loads (image_msaa_load reads samples fragment..fragment+3 — this ISA reading is not confirmed on hardware); runner TexDim::D2Ms.
  • Directed f32 rounding (MODE round toward +inf / -inf / zero, lower_round.rs): direct path only — the HLSL path lacks it.
  • Fuzz tests (dxil/fuzz_tests.rs, left out of gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 only for GitHub's diff-size limit) plus amd_reduced_seeds (ignored) reproducing seeds 722 / 1599 on AMD. Seed 722 is suspected to be the driver moving WaveReadLaneFirst into a divergent switch. @HKEY-Funk-Machine / @emirduran707, could you run cargo test -p xcl --lib gpu::dxil::fuzz_tests::amd_reduced_seeds -- --ignored --nocapture on your AMD GPUs and post the output?
  • New tests: geometry_mode_validates, geometry_tests::{geometry_forms_validate, gpu_geometry_direct_records} (per-lane loops + cuts against a model), MSAA and rounding tests, the direct check in gpu_geometry_wave32_prefix_count_over_a_mask.
  • TRANSLATOR_VERSION 4 → 5.

Tested

  • RTX 4090 (driver 32.0.16.1088, no wave64), i9-12900K, Windows 11, DXC 1.9.2602.17, Rust 1.100.0; debug for tests, release for the sweep / smoke.
  • cargo test -p xcl --lib gpu::dxil: 100 passed, 0 failed, 3 ignored.
  • XCL_DIRECT_DXIL=1 and =all cargo test -p xcl --lib gpu::recomp: 261 passed, 0 failed, 18 ignored each.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4: 975 passed, 0 failed, 45 ignored (23 SKIPPED lines on this GPU: wave64-only GPU comparisons "no wave64", three f16/f32 forms the per-lane path refuses, ir_text_assembles_signs_and_runs: no dxil.dll, heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows). Clean run after merging main (incl. Direct DXIL: image_get_lod accepts static samplers #1806, D3D12.X: eliminate multi-heap UpdateTileMappings and per-texture Signal stalls in vram::Pages #1747 and the Lw::new refactor); TRANSLATOR_VERSION bumped to 7 (main's 6 + 1).
  • xcl shaders D:\game\shaders.rpf --direct --sample 200 --seed 1 --max-bytes 0 --timeout 10 --validate --compare (release): 200/200 translated + validated (CS 21, GS 3, MS 67, PS 86, VS 23); translation time p50 136 ms, p95 1636 ms, max 4775 ms (measured while other builds were running, so on the high side); DXIL size direct 30.3 MB vs HLSL+DXC 24.2 MB (1.25×).

Regression run

scripts/smoke.ps1 -Game D:\game -Seconds 60 with XCL_PRESS_AT=2:B,4:B,6:B,8:B (B pressed at 2/4/6/8 s to skip splash screens) and XCL_PRESS_A_AT=10,15,20,25,30,40 (A pressed to enter the intro), release builds on a quiet machine: PR 1478 frames vs 1511 on main (98 %), peak commit 20855 MB vs 20218 MB (103 %), no device removals or crashes. The PR ran right after the TRANSLATOR_VERSION bump (cold translation cache) and still reached 98 %, so no warm rerun was needed.

main (1d027e5):

xcl-smoke v1
commit: 1d027e5c76c9a86a7ee2ca1cc677edf0be95d331
gpu: NVIDIA GeForce RTX 4090
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1511 (PresentX 1511)
presents per 2 s (last 3): 59 61 34
device removals: 0
crashes: 0
peak commit: 20218 MB

PR (e9ac9f0):

xcl-smoke v1
commit: e9ac9f08aeb226c1b195187011f09444785dbd3c
gpu: NVIDIA GeForce RTX 4090
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1478 (PresentX 1478)
presents per 2 s (last 3): 60 45 52
device removals: 0
crashes: 0
peak commit: 20855 MB

Not tested

  • MSAA image loads and directed rounding on real game frames (no sampled program uses them visibly); the image_msaa_load sample-index reading is unconfirmed on hardware.
  • The native wave64 geometry form on wave64 hardware (this GPU has none; the split form ran on the GPU, the native form only validated).
  • AMD: the amd_reduced_seeds repro needs an AMD tester.
  • Found along the way, not fixed here — HLSL path's split-form geometry bug: with branches in the GS, the HLSL split form emits the ES's s_setpc_b64 as a fall-through into the GS code and the GS phase's entry pc gets no dispatcher case, so the ES phase runs the GS code and the GS phase does nothing → empty records on wave32 GPUs. gpu_geometry_direct_records therefore compares the HLSL path only in its native form.

AI use

  • Claude Code (Claude Opus 5.5): wrote the code and tests on the original branches, cherry-picked them onto main, resolved conflicts, ran the tests / sweep / smoke runs and wrote this description.

🤖 Generated with Claude Code

bmjask and others added 6 commits November 24, 2026 13:30
The recompiler's Mode::Geometry as a direct compute pass: the ES for the
three vertices of 21 triangles per group (pre-fetched inputs), s_setpc_b64
into the GS, s_sendmsg GS emit / cut building strip triangles per lane, and
the mesh record (vertex / triangle counts, vertices copied from the GS
output area in LDS, triangles) written after wave prefix sums. The split
wave64 form runs the ES in both hardware waves, then a group barrier and the
GS in the lower wave with fresh registers, as the HLSL kernel does.
cfg::Cfg::build_geometry, lower_geom.rs; pso::console_geometry tries it
under XCL_DIRECT_DXIL=1 (HLSL fallback); coverage routes Mode::Geometry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ect translator

ops.rs: TexKind::D2MS / D2MSArray, texture_load_sample, Texture2DMSGetSamplePosition,
RenderTargetGetSampleCount / SamplePosition. lower_image.rs: image_load and
image_msaa_load (one component of four samples) on 2D MSAA (array) T#s, the fragment
index as sample index (no FMASK in D3D12), samples past the count read 0;
image_get_resinfo (one level). Stores / atomics (RWTexture2DMS, SM 6.7) and sampling
stay translation errors. runner.rs (test only): TexDim::D2Ms / D2MsArray filled
sample by sample with a per-sample draw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Programs writing a non-default MODE[1:0] track MODE[1:0] / FP_DENORM single in an SSA
variable; f32 add/sub/mul/fma/mad/fmac/fmamk/fmaak/div_fmas, int and f64 conversions,
ldexp and sqrt compute exactly (f64 products, TwoSum) and round on the bits by the
mode, denormals flushed as FP_DENORM says. Constant modes fold, run-time modes
select per instruction. Direct-only (DXIL has no directed rounding). Tests against an
integer CPU reference; docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restores fuzz_tests.rs, left out of xcl-dev#1426 only for the diff-size limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed FUZZ_WATCH

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…copies, TRANSLATOR_VERSION 5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HKEY-Funk-Machine

Copy link
Copy Markdown

@bmjask amd_reduced_seeds on the RX 9070 at ee85bc2: 6 of 7 variants fail, 1 passes.

FAIL 722 switch + WaveReadLaneFirst: res[30] = 0x1, CPU 0x7fffffff
FAIL 722 switch + WaveReadLaneFirst + Countbits.i64 case: res[30] = 0x1, CPU 0x7fffffff
PASS 1599 Countbits.i64(const 2)
FAIL 1599 Countbits.i64(const 2) -> shift / Bfrev: res[1] = 0x1, CPU 0x0
FAIL 1599 Countbits.i64(dynamic 2) -> shift / Bfrev: res[1] = 0x1, CPU 0x0
FAIL full seed 722: 1 mismatching dwords
FAIL full seed 1599: 62 mismatching dwords
  • 722: the plain switch + WaveReadLaneFirst form already fails on its own, with the same value as the full seed (res[30] 1 against 0x7fffffff). That fits your guess that the driver moves the read into a divergent case.
  • 1599: Countbits.i64(2) alone gives the right value. Both the constant and the dynamic operand go wrong once the count goes into the shift / Bfrev. So on this card, splitting the Countbits.i64 per half doesn't cover it; the wrong bit comes in after the count. (@RockFellerX's RDNA2 probe on gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 found the same Countbits → Bfrev.i32 pattern, with the constant case only.)

The full output, with each variant's IR, is about 670 lines. I can post it if the IR on this card would help; it's only the test's own generated programs.

Tested: clean PR head ee85bc2, debug build, XCL_REQUIRE_GPU=1 cargo test -p xcl --lib gpu::dxil::fuzz_tests::amd_reduced_seeds -- --ignored --nocapture (test result: FAILED. 0 passed; 1 failed, 6 AMD repro variants failed). AMD Radeon RX 9070 (RDNA4), driver 32.0.32015.7029, Ryzen 9 7945HX3D, 32 GB, Windows 11 Pro 26300, Rust 1.100.0, DXC 1.9.2602.17.

Not tested: the rest of the suite on this head, release build, and the retail title on this head.

AI use: Claude Code (Claude Opus 5.5) ran the test and wrote this comment.

@nnonno91

Copy link
Copy Markdown

Independent Windows GPU test of ee85bc2686e0df7a818cd5fa0f3889e632a274e7. Native wave64 geometry passed on the 9800X3D's Radeon iGPU. The iGPU reproduced one of the seven requested variants and had three output mismatches in the 500–999 seed batch.

Tested

  • Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, AMD Radeon(TM) Graphics (PCI 1002:13C0, driver 32.0.21042.62) and RTX 5090 (32.0.16.1742), Rust 1.100.0 MSVC, Windows SDK DXC 1.8.2502.11, debug/test profiles. Selected each adapter with XCL_ADAPTER.
  • cargo test --locked -p xcl --lib gpu::dxil::fuzz_tests::amd_reduced_seeds -- --exact --ignored --nocapture on the iGPU twice: 6 of 7 variants matched on each run (test result 0 passed, 1 failed). Both full seeds, both reduced 722 cases, and both constant 1599 cases matched. Only 1599 Countbits.i64(dynamic 2) -> shift / Bfrev failed, res[1] GPU 0x1 vs CPU 0x0. On the RTX 5090 the same filter with the same flags passed all 7 (1 test passed, 0 failed). No skips.
  • A temporary print of the existing dynamic-1599 outputs on the iGPU showed that the count and shift matched in all 32 lanes. The bit reversal returned 0x80000001 vs 0x80000000 in all 32 lanes, and the combined output differed in 31. This describes the observed outputs of that program.
  • cargo test --locked -p xcl --lib gpu::dxil::geometry_tests::gpu_geometry_direct_records -- --exact --nocapture on the iGPU: 1 passed, 0 failed, no skips. The CPU model matched the generated mesh records for both direct DXIL wave64 forms (native and split) and native HLSL. The targeted AMD commands above used XCL_REQUIRE_GPU=wave64,mesh.
  • On the clean head, cargo build --workspace --locked passed. The iGPU run of cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-output reported 873 passed, 1 failed, 44 ignored, with one explicit skip counted as a pass (heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows). The failure was fuzz_validate_and_gpu_1 at seed 540, res[833] GPU 0x7 vs CPU 0x6. cargo test --locked -p xcl --lib gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 -- --exact --nocapture reproduced that independently. The same command on the RTX 5090 stopped at seed 545 in both runs with CreateComputePipelineState returning 0x8007000E (2932 bytes, 148 instructions).
  • I ran a temporary continue-on-mismatch copy of that batch on the iGPU (cargo test --locked -p xcl --lib gpu::dxil::fuzz_tests::pr1679_scan_batch -- --exact --nocapture). It validated 500, GPU-compared 313, and found these three mismatching programs. The temporary diagnostics were removed afterward.
Seed Differing dwords First result GPU CPU
540 21 res[833] 0x7 0x6
783 32 res[64] 0x951d1075 0x7fffffff
817 64 res[320] 0xfe53ffff 0x4a43fdeb

Not tested

Retail titles, compile timing, the full workspace suite on NVIDIA, or the root cause of the output mismatches and pipeline creation error.

AI use

OpenAI Codex (GPT-6 family, exact variant unavailable) ran the tests, added temporary diagnostic output, and wrote this report.

@raylitebull

Copy link
Copy Markdown
Member

Tested on Windows 11 with an AMD Radeon RX 9070 XT (16191 MiB VRAM, RDNA4, native wave64) on a local merge branch based on c160d86.

Setup & tested configuration

  • Local test branch: c160d86 + #1693 (b5d6322) + #1679 (ee85bc2) + #751, #1288, #1005, #1053, #1195, #1529, #1584, #1661 (release build).
  • Flags: XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=1, XCL_NETWORK=0, XCL_SKIP_BINK=1, XCL_MUTE_TTS=1 (300 s run on a newer retail title).

Observed results

  • Exit: 0x0 after full 300.00 s (0 crashes, 0 device removals, 0 OOMs).
  • Frames shown: 1,914 (PresentX 1914; 651 translated PSOs, 19,207 unique shaders).
  • Memory: 25,644 MB peak commit (13,065 MB process VRAM / 14,515 MB adapter VRAM, 8,791 MB target pages).
  • Visual check: captured 4K loading frames (frame_1520, frame_1880, frame_1910) rendered cleanly with no corruption.
  • Merge note: #1679 (ee85bc2) and #1693 (b5d6322) share a small 2-line overlap in crates/xcl/src/gpu/dxil/kernel.rs (keeping both || geo.is_some() and the mem_windows(...) heap-window call resolves cleanly).

Not tested

  • Cold-cache direct-DXIL shader compilation (dxil_cache logged 1,288 hits / 0 misses / 0 compilations on pre-warmed caches).
  • gpu::dxil::fuzz_tests / cargo test --workspace on this merged tree, standalone #1679, and in-world 3D geometry/MSAA/directed-rounding paths past the 300 s loading screen.

@srcamarda

Copy link
Copy Markdown
Contributor

ee85bc2 on AMD RDNA3 (RX 7800 XT): amd_reduced_seeds fails here too, and so does the non-ignored fuzz_validate_and_gpu_1 (seed 722; seeds 783 and 817 mismatch as well); the native wave64 geometry form runs and passes

Setup

  • AMD Radeon RX 7800 XT 16 GB (RDNA3, native wave64), driver 32.0.32029.2010; Ryzen 5 5600G, 32 GB; Windows 11 Pro 26300; rustc 1.100.0; debug for the tests, release for the title.
  • Head ee85bc2 as it is (it already contains main c160d86).

amd_reduced_seeds (cargo test -p xcl --lib gpu::dxil::fuzz_tests::amd_reduced_seeds -- --ignored --nocapture): the same output in two runs, so on RDNA3 as well, not only RDNA4:

FAIL 722 switch + WaveReadLaneFirst: res[30] = 0x1, CPU 0x7fffffff
FAIL 722 switch + WaveReadLaneFirst + Countbits.i64 case: res[30] = 0x1, CPU 0x7fffffff
PASS 1599 Countbits.i64(const 2)
PASS 1599 Countbits.i64(const 2) -> shift / Bfrev
FAIL 1599 Countbits.i64(dynamic 2) -> shift / Bfrev: res[1] = 0x1, CPU 0x0
FAIL full seed 722: 1 mismatching dwords
PASS full seed 1599: 0 mismatching dwords

The full seed 1599 passes on this card; only its reduced "dynamic 2" variant fails.

The default suite fails on AMD. fuzz_validate_and_gpu_1 (seeds 500..1000) is not ignored and panics at seed 722 (res[30] = 0x1, CPU 0x7fffffff), so cargo test --workspace is red on this card. It stops at the first mismatch, so for one run I changed the panic into a log line, locally and not pushed, to see every seed:

  • 0..500: 299 GPU-compared, 0 mismatches
  • 500..1000: 313 GPU-compared; 722 (1 dword), 783 (32 dwords, first res[64] = 0xfffffff0, CPU 0x7fffffff), 817 (64 dwords, first res[320] = 0xfe53ffff, CPU 0x4a43fdeb)
  • 1000..1500: 314, 0 mismatches; 1500..2000: 306, 0 mismatches (1599 passes here)

783 and 817 are not in the description; the maintainer's RDNA4 batch would likely hit at least 722.

Tests

  • cargo test -p xcl --lib gpu::dxil: 95 passed, 1 failed (fuzz_validate_and_gpu_1), 3 ignored.
  • cargo test -p xcl --lib gpu_geometry -- --nocapture: 3 passed (gpu::dxil::geometry_tests::gpu_geometry_direct_records, gpu_geometry_mode_es_gs_strip, gpu_geometry_wave32_prefix_count_over_a_mask). On this card wave64_supported() is true, so gpu_geometry_direct_records runs both the split and the native form on the GPU, and the HLSL native form's records agree.
  • XCL_DIRECT_DXIL=1 and =all cargo test -p xcl --lib gpu::recomp: 194 passed, 0 failed, 18 ignored each. No SKIPPED (gpu_wave32_program_in_wave64_hardware runs here).
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 873 passed, 1 failed (fuzz_validate_and_gpu_1), 44 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

Retail title (1.0.2.1, scripts/smoke.ps1 -Seconds 60, no input; it stays on the title screens):

frames shown presents per 2 s (last 3) peak commit
main c160d86 1 019 · 1 064 60 60 60 · 60 60 60 16 700 · 16 725 MB
this PR ee85bc2 1 065 · 1 071 60 60 60 · 60 58 61 16 714 · 16 741 MB
this PR, XCL_DIRECT_DXIL=1 993 60 60 60 16 772 MB
this PR, XCL_DIRECT_DXIL=all 1 009 60 60 60 17 027 MB

Interleaved main / PR / main / PR, then the two direct runs. No device removal or crash in any of them. XCL_DIRECT_DXIL_STATS=1: CS direct 45 / HLSL fallback 0 with =1; CS direct 46 / 0, PS direct 18 / 0, VS direct 18 / 0 with =all.

PR's block (round 2):

xcl-smoke v1
commit: ee85bc2686e0df7a818cd5fa0f3889e632a274e7
gpu: AMD Radeon RX 7800 XT
title: RetailGame_Dump
seconds: 60
exit: 0x0
frames shown: 1071 (PresentX 1072)
presents per 2 s (last 3): 60 58 61
device removals: 0
crashes: 0
peak commit: 16741 MB

Not tested

  • Whether the 722 / 783 / 817 mismatches are the driver or the translation (no bisecting beyond the test's own variants); RDNA2 / RDNA4.
  • The world load and gameplay; whether the direct path draws the title screens correctly (frames and timing only, no image check).
  • The --direct sweep over a shader pack; MSAA loads and directed rounding on real frames.

Claude Code (Claude Opus 5.5), from runs on the hardware above.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
, xcl-dev#1709 and update README

Integrates four new rendering and direct-DXIL PRs on top of c160d86:
- xcl-dev#1679: Direct DXIL geometry mode, MSAA loads, and directed f32 rounding
- xcl-dev#1707: Direct DXIL entry function fp32-denorm-mode=ftz (bumped
  TRANSLATOR_VERSION to 6)
- xcl-dev#1709: pixel shader ordered sections via rasterizer ordered views (ROVs)
- xcl-dev#1705: recover poisoned report crash/write locks instead of dropping report

Verified under GE-Proton11-14 + vkd3d-proton ec20719452e916b:
- Release build (x86_64-pc-windows-msvc): ok (31.38s)
- Proton tests (gpu::dxil::tests::, gpu_ps_ordered_section_*,
  ordered_section_images_*, report::tests): 9 passed, 0 failed, 0 skipped.
bmjask and others added 4 commits November 24, 2026 14:48
@thiagocalile

Copy link
Copy Markdown

Tested commit ee85bc2686e0df7a818cd5fa0f3889e632a274e7 on an AMD Radeon RX 6600 (RDNA2, native 64-lane waves). Hit 1 deterministic GPU test failure (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, seed 540: res[833] = 0x7, CPU 0x6) in both the targeted gpu::dxil run and the full workspace run.

Tested

  • Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, native wave64 + mesh shaders, driver 32.0.21045.29003; XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.8.2502.11, debug build.
  • XCL_ADAPTER=radeon cargo test -p xcl --lib gpu::dxil -- --test-threads=4: 95 passed, 1 failed, 3 ignored (43.4s).
  • XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 870 passed, 4 failed, 44 ignored (78.46s).
    • New failure on RX 6600: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 panicked at crates\xcl\src\gpu\dxil\fuzz_tests.rs:1171:21 with seed 540: res[833] = 0x7, CPU 0x6 (reproduced in both the targeted and workspace runs).
    • The other 3 workspace failures are pre-existing on main on this RX 6600 (placed_title_textures_share_vram_and_preserve_pixels: 3D mip subresource mismatch, plus 2 mutex-poison cascades transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory; tracked by D3D12.X: map and unmap 3D texture mips separately #1028).
    • SKIPPED (not counted as coverage): heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows (plus D3D12 debug-layer tests skip because d3d12SDKLayers.dll is not installed).

Not tested

  • Retail title run (scripts/smoke.ps1 — no game executable here), D3D12 debug layer, NVIDIA / Intel GPUs, Linux / Wine.

AI use

  • Antigravity (Gemini 4 Neon) ran the test suites on my RX 6600 and drafted this report; I checked the results before posting.

@eizispark

Copy link
Copy Markdown

Hardware test report — commit 758e341

Checked 758e341f0cfe735d617c629bfd22eee09bf05f2b (clean merge with main 4178e88): regression in gpu::dxil::msaa_tests::gpu_direct_msaa_image_loads on AMD RDNA4 (0xc0000005 STATUS_ACCESS_VIOLATION); geometry mode, directed f32 rounding, the dx.op MSAA helpers, and the 60 s retail smoke run all pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 x64, rustc 1.100.0 (0ef1bc386 2026-11-09), debug tests + release smoke
  • cargo test --workspace --no-fail-fast -- --test-threads=4:
    • xcl --lib aborts in gpu::dxil::msaa_tests::gpu_direct_msaa_image_loads with exit code: 0xc0000005, STATUS_ACCESS_VIOLATION (reproduced solo with --test-threads=1; note this test skips on NVIDIA via wave64_programs_supported()). The other 3 tests in msaa_tests (msaa_texture_ops_run on GPU, render_target_sample_ops_validate, direct_msaa_store_is_rejected) pass (3/3)
    • Re-running xcl --lib -- --skip gpu_direct_msaa_image_loads --test-threads=4: 855 passed, 2 failed, 24 ignored (1 skipped: shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is off)); the 2 failures are the pre-existing #1426 AMD fuzz seeds (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599)
    • All integration / bin targets (16 targets): 49 passed, 0 failed, 20 ignored (1 skipped: heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows)
  • Geometry & rounding on RDNA4: gpu::dxil::core_tests::geometry_mode_validates, gpu::dxil::geometry_tests::geometry_forms_validate, gpu::dxil::geometry_tests::gpu_geometry_direct_records (wave64), and gpu::dxil::round_tests (4/4: direct_f32_round_mode_unsupported_op_rejected, directed_reference_basics, gpu_direct_f32_round_modes_dynamic_and_denormals, gpu_direct_f32_round_modes_static) all passed; gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, and console_wave64_compute_through_the_pso_hook_dispatch_and_read_back also passed
  • Requested cargo test -p xcl --lib gpu::dxil::fuzz_tests::amd_reduced_seeds -- --ignored --nocapture result on RX 9070 XT (32.0.32015.16001) — 1 variant passed, 6 reproduced:
FAIL 722 switch + WaveReadLaneFirst: res[30] = 0x1, CPU 0x7fffffff
FAIL 722 switch + WaveReadLaneFirst + Countbits.i64 case: res[30] = 0x1, CPU 0x7fffffff
PASS 1599 Countbits.i64(const 2)
FAIL 1599 Countbits.i64(const 2) -> shift / Bfrev: res[1] = 0x1, CPU 0x0
FAIL 1599 Countbits.i64(dynamic 2) -> shift / Bfrev: res[1] = 0x1, CPU 0x0
FAIL full seed 722: 1 mismatching dwords
FAIL full seed 1599: 62 mismatching dwords
assertion `left == right` failed: 6 AMD repro variants failed (left: 6, right: 0)

Regression run (scripts/smoke.ps1, 60 s, default HLSL backend)
main (85e38262ff94aecd75d6f83fa8156a8b7697bd13):

xcl-smoke v1
commit: 85e38262ff94aecd75d6f83fa8156a8b7697bd13
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1669 (PresentX 1669)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14860 MB

PR (758e341f0cfe735d617c629bfd22eee09bf05f2b):

xcl-smoke v1
commit: 758e341f0cfe735d617c629bfd22eee09bf05f2b
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1675 (PresentX 1675)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14859 MB

Not tested

  • retail run with XCL_SHADER_BACKEND=dxil, NVIDIA/Intel GPUs, Wine/vkd3d-proton, gameplay past the menus

AI use

  • Verified and formatted with Antigravity (Google DeepMind, Gemini 4 Carbon).

@thiagocalile

Copy link
Copy Markdown

Root-caused the RX 6600 (32.0.21045.29003) seed 540: res[833] = 0x7, CPU 0x6 failure from the emitted DXIL disassembly — the emitted DXIL is mathematically sound, so this looks like an AMD Windows DXIL driver miscompilation (similar to amd_reduced_seeds), not a bug in #1679's translator.

Backward slice of res[833] (lane %5 = 1, slot 832 + %5, %287 = trunc i64 %208 to i32):

%24 = trunc i32 %11 to i1
%25 = sext i1 %24 to i64
%26 = and i64 %25, 63
%27 = ashr i64 %25, %26
%96 = sub i64 %27, -7
%208 = phi i64 [ %96, %202 ], [ %42, %197 ]

For %24 = true:

  • Valid DXIL / CPU: %25 = -1, %26 = 63, %27 = ashr(-1, 63) = -1, %96 = -1 - (-7) = 6 (0x6).
  • RX 6600 (32.0.21045.29003): produced 0x7 (0 - (-7)), meaning %27 evaluated to 0 (either sext i1 true to i64 miscompiled as zext +1 so ashr(1, 1) = 0, or ashr i64 -1, 63 miscompiled to 0).

AI use: Antigravity (Gemini 4 Neon) traced the backward slice from the seed 540 DXIL disassembly; I reviewed it before posting.

let dims = lw.s.get_dimensions(tex.handle, None);
let count = lw.s.m.extract(dims, 3);
for (si, &sv) in samples.iter().enumerate() {
let r = lw.s.texture_load_sample(tex, sv, &coords);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make the sample index valid before this load? For IMAGE_MSAA_LOAD, samples is fragment..fragment+3; the new GPU regression deliberately reaches indices beyond the resource count (4x at fragment 3, 2x at fragment 1). This call still performs Texture2DMS.Load for those indices and only selects zero afterward. Microsoft documents out-of-range ld2dms sample indices as undefined: ld2dms. That makes this a plausible cause of the reported RDNA4 STATUS_ACCESS_VIOLATION; the post-load select cannot prevent the invalid fetch. Could the load use a safe in-range index (for example, sample 0 when sv >= count) while retaining the existing zero result mask? I ran gpu_direct_msaa_image_loads on an RTX 5070 Ti and it passes there, which does not rule out the AMD-specific failure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A patch for this, in case it saves a round trip (against 758e341; @bmjask, take it or leave it as you like):

--- a/crates/xcl/src/gpu/dxil/lower_image.rs
+++ b/crates/xcl/src/gpu/dxil/lower_image.rs
@@ -857,8 +857,12 @@ impl Lw {
                 let dims = lw.s.get_dimensions(tex.handle, None);
                 let count = lw.s.m.extract(dims, 3);
                 for (si, &sv) in samples.iter().enumerate() {
-                    let r = lw.s.texture_load_sample(tex, sv, &coords);
+                    // the load itself only with a sample the resource has (sample 0 in place of
+                    // one past its count; the result is zeroed below)
                     let inside = lw.cmp(Pred::ULt, sv, count);
+                    let first = lw.c(0);
+                    let loaded = lw.sel(inside, sv, first);
+                    let r = lw.s.texture_load_sample(tex, loaded, &coords);
                     for k in 0..4 {
                         let b = lw.bits(r[k]);
                         let zz = lw.c(0);

The range check moves in front of the load, and the load takes sample 0 where the index is past the resource's count. The zeroing of the result stays as it is, so what the test expects does not change. It covers image_load of one sample as well as the four of image_msaa_load (the same loop).

Tested

  • RTX 5080 (32-lane waves, driver 32.0.16.1047), i7-7700K, Windows 10, Rust 1.100.0, DXC 1.9.2602.17, debug, 758e341 + the patch.
  • cargo test -p xcl --lib gpu::dxil::msaa_tests -- --test-threads=1: 4 passed, 0 failed. gpu_direct_msaa_image_loads ran on the GPU (split form), not skipped, and its values match, the past-the-count samples included.
  • cargo test -p xcl --lib gpu::dxil -- --test-threads=4: 98 passed, 0 failed, 3 ignored (dump_dxc_lowering, amd_reduced_seeds, debug_seed).

Not tested

  • AMD. I have no such card, and the same four tests pass here on 758e341 without the patch too (as on Flyander's RTX 5070 Ti), so this run does not show that the access violation on RDNA4 is gone - only that the patched form validates and gives the same values. @eizispark, could you rerun gpu_direct_msaa_image_loads with it on the RX 9070 XT?
  • The rest of the workspace suite, a title run.

AI use

  • Claude Code with Claude Fable 5.2 wrote the patch, ran the tests and wrote this comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Flyander, agreed: the post-load select can't stop an out-of-range ld2dms fetch, and that fits the RDNA4 access violation. And thanks @imnicho for the patch. I took it as is: the range check now runs before the load, which uses sample 0 when sv >= count, and the zero mask stays the same. It covers image_load and image_msaa_load. Commit ba3dc42 (with TRANSLATOR_VERSION 7 → 8) is prepared and being handed to this branch. gpu::dxil passes here (100 passed, 0 failed, 3 ignored), but that's on NVIDIA, where the test already passed, so it doesn't show the AMD fault is gone.

AI use: Claude Code (Claude Opus 5.5) wrote this comment for @bmjask.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bmjask a heads-up so the fix is not lost: the merge at 22:07 UTC took e9ac9f0, which does not have ba3dc42 yet. On main 689f2db the load still comes before the range check (gpu/dxil/lower_image.rs, line 860), so gpu_direct_msaa_image_loads will still crash on the RDNA4 cards there.

It is your commit, so the follow-up is yours to send if you want it (with the TRANSLATOR_VERSION bump you mention). If you would rather I open the small PR, say so and I will, with the test report from here and a request to @eizispark / @HKEY-Funk-Machine for the AMD run.

AI use: Claude Code with Claude Fable 5.2 checked main and wrote this.

Resolve kernel.rs against main's Lw::new refactor: the geometry entry's
res buffer, LDS, 64-thread groups and f32_rm/geom fields move into
Lw::new. TRANSLATOR_VERSION 7 (main's 6 + 1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HKEY-Funk-Machine

Copy link
Copy Markdown

@bmjask @eizispark the gpu_direct_msaa_image_loads access violation reproduces on a second RDNA4 card and driver: RX 9070, driver 32.0.32015.7029 (eizispark's is an RX 9070 XT on .16001). Debug and release builds both crash the same way.

Tested

  • Clean PR head 758e341. AMD Radeon RX 9070 (RDNA4, native wave64), Ryzen 9 7945HX3D, 32 GB, Windows 11 Pro 26300, Rust 1.100.0, DXC 1.9.2602.17.
  • XCL_REQUIRE_GPU=1 cargo test -p xcl --lib gpu::dxil::msaa_tests -- --test-threads=1 --nocapture: direct_msaa_store_is_rejected ... ok, then gpu_direct_msaa_image_loads ends the process with exit code: 0xc0000005, STATUS_ACCESS_VIOLATION, right after DXC loads.
  • The same test alone in release (cargo test --release … gpu_direct_msaa_image_loads): same 0xc0000005.

Not tested: which module faults (no dump captured), the rest of the suite on this head, and the retail title on this head.

AI use: Claude Code (Claude Opus 5.5) ran the test and wrote this comment.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

@thehollowedone

Copy link
Copy Markdown

Tested

On 758e341f, I extended the stock ES+GS strip fixtures to draw the same geometry through direct DXIL and HLSL on the RTX 3080 Ti. Both versions of the shader, with and without branches, emitted strips for 25 primitives across a full group and a partial final group.

Direct DXIL with one and four configured memory windows matched HLSL exactly in each case. Per comparison, all 858 live record words and all 1,024 pixels matched, including the 41 covered pixels. The fixture used the first memory window for its input.

Windows 11 build 26300, NVIDIA driver 621.35, Ryzen 7 9800X3D, Rust 1.99.1 MSVC debug, DXC 1.8.2502.11. cargo test --offline --locked -p xcl --lib <filter> -- --nocapture --test-threads=1 passed 2/2 for the stock gpu::dxil::geometry_tests:: filter and 2/2 for the extended gpu_geometry_mode_es_gs_strip filter. Zero skips.

Not tested

This is synthetic split-wave64 geometry and raster output coverage. Retail, native wave64 hardware, MSAA, and the reported AMD failures were outside this check.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) extended and ran the fixture and drafted this report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bmjask

bmjask commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks everyone for the hardware runs. Where things stand:

MSAA access violation on RDNA4 (@eizispark, @HKEY-Funk-Machine): the likely cause is the out-of-range Texture2DMS.Load that @Flyander found. The fix is @imnicho's patch: load sample 0 for indices past the count and zero the result as before. It's prepared as ba3dc42 and being handed to this branch. Once it's on the PR head, could you both re-run XCL_REQUIRE_GPU=1 cargo test -p xcl --lib gpu::dxil::msaa_tests -- --test-threads=1 on the RX 9070 / 9070 XT? I can't verify it on AMD myself.

AMD fuzz mismatches (@HKEY-Funk-Machine, @srcamarda, @thiagocalile, @nnonno91): not fixed, and I won't claim they are. amd_reduced_seeds fails 6/7 on the RX 9070 and fails on the RX 7800 XT. The non-ignored fuzz_validate_and_gpu_1 also fails there: seeds 722/783/817 on the RX 7800 XT and seed 540 on the RX 6600. @thiagocalile, thanks for the backward slice of seed 540. The emitted sext i1 → ashr → sub chain does look sound, which points at the AMD DXIL compiler. I haven't confirmed that independently, and a deterministic failure in a non-ignored test on three AMD generations needs either a translator-side workaround or an explicit AMD skip with a tracking issue before merge. It shouldn't just be left red. Still open. One check would help, if anyone with an AMD card has time: does fuzz_validate_and_gpu_1 fail on plain main too, or only on this head?

@nnonno91: thanks for the iGPU wave64 geometry check. @thehollowedone: thanks for the direct-vs-HLSL ES+GS strip comparison (858 record words and 1,024 pixels identical, one and four windows). @raylitebull: thanks for the 300 s RX 9070 XT run and the merge note on the kernel.rs overlap with #1693. @DavidM1911: thanks for the RTX 3060 Ti run.

AI use: Claude Code (Claude Opus 5.5) wrote this comment for @bmjask.

@raylitebull
raylitebull merged commit 689f2db into xcl-dev:main Nov 24, 2026
1 of 4 checks passed
@PHeitor1

PHeitor1 commented Nov 24, 2026 •

Copy link
Copy Markdown

Update: the patch is now the draft #1919, so please test that branch instead of opening a PR.

@frenziedcoder thanks for checking this: your RTX 5080 (617.14) stopping at the same four seeds (70, 545, 1019, 1507) means it is not only 621.24.

If you have time, would you run the patch from my comment above on that card? It applies to main 689f2db. What would help most:

  1. cargo test -p xcl --lib -- gpu_ds_sub_u32_of_a_register gpu::dxil::fuzz_tests, once as it is and once with XCL_DIRECT_DXIL=1. To see the new test fail without the fix, apply only the recomp/tests.rs part.
  2. A smoke pair (main / patched), since it changes the translators and I can't run one.

If it holds up and @bmjask doesn't want to take it, please feel free to open the PR yourself. No problem if not.

Written with Claude Code (Claude Opus 5.5).

@bmjask

bmjask commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

imnicho's sample-clamp patch from this review is now in #1908 (on current main). @eizispark @HKEY-Funk-Machine, could you re-test on AMD with that build when you get a chance?

@cindertheblue

Copy link
Copy Markdown
Contributor

amd_reduced_seeds on a second RDNA3 card (RX 7600 XT, older driver): seed 722 fails as on the RX 7800 XT, but all three 1599 variants pass – main at 689f2db

Setup: AMD Radeon RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.31041.1004 (AMD Software 26.8.1); Ryzen 5 9600X; Windows 11 Home 26200.9974; rustc 1.99.1; DXC 1.8.2502.11 (SDK 10.0.26100); debug build; main at 689f2db, no local changes.

cargo test -p xcl --lib amd_reduced_seeds -- --ignored --nocapture, the same output without and with XCL_DIRECT_DXIL=1:

FAIL 722 switch + WaveReadLaneFirst: res[30] = 0x1, CPU 0x7fffffff
FAIL 722 switch + WaveReadLaneFirst + Countbits.i64 case: res[30] = 0x1, CPU 0x7fffffff
PASS 1599 Countbits.i64(const 2)
PASS 1599 Countbits.i64(const 2) -> shift / Bfrev
PASS 1599 Countbits.i64(dynamic 2) -> shift / Bfrev
FAIL full seed 722: 1 mismatching dwords
PASS full seed 1599: 0 mismatching dwords
card driver 722 1599 dynamic → shift / Bfrev
RX 7600 XT (RDNA3), this run 32.0.31041.1004 fail pass
RX 7800 XT (RDNA3), @srcamarda 32.0.32029.2010 fail fail
RX 9070 (RDNA4), @HKEY-Funk-Machine 32.0.32015.7029 fail fail
  • Seed 722 fails the same way on all three cards in the table (on @nnonno91's RDNA2 iGPU both 722 cases matched).
  • The 1599 "dynamic 2" variant passes here. This card has an older driver and a different chip than the RX 7800 XT, so this run can't tell which of the two makes the difference.
  • Whole workspace (cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture): 974 passed, 1 failed (fuzz_validate_and_gpu_1, seed 722, res[30] = 0x1, CPU 0x7fffffff), 45 ignored.

Not tested: another driver on this card; seeds after 722 in fuzz_validate_and_gpu_1 (it stops at the first mismatch).

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment from the real output; checked by me before posting.

anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 24, 2026
Brings main to full parity with upstream/main (689f2db):
- xcl-dev#1679: direct DXIL follow-up (geometry ES+GS mode, MSAA
  Texture2DMS/Texture2DMSArray loads, directed f32 rounding modes, GPU fuzz
  tests, TRANSLATOR_VERSION 7)
- CI stale PR workflow

Assisted-by: Antigravity (Gemini 4)
raylitebull pushed a commit that referenced this pull request Nov 24, 2026
…lues in `round_exact`

In directed f32 rounding (`dxil/lower_round.rs`, #1679), `round_exact`
returned the native D3D12 f32 result (`native`) whenever the f64 value `s`
was `±inf` or `NaN` (`ex == 0x7FF`). Because `native` is computed with
D3D12's default f32 denormal behaviour rather than `MODE`'s input denormal
control (`ext_exact`), `denormal * +inf` and `fma(denormal, +inf, 1.0)`
returned `NaN` (`0xffc00000`) instead of `+inf` (`0x7f800000`) when input
denormals are preserved (`MODE_INIT`), and could similarly disagree when
input denormals are flushed.

`s` already holds the exact f64 `±inf`/`NaN` computed from the `MODE`-aware
inputs: truncate `s` directly with `FPTrunc` on the `special` path and remove
the unused `native` parameter from `round_exact` and `round_sum`.

Assisted-by: Antigravity (Gemini 4 Neon)
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.