Repository navigation
Direct DXIL: geometry mode, MSAA loads and directed f32 rounding - #1679
Conversation
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>
|
@bmjask
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 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. |
|
Independent Windows GPU test of Tested
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. |
|
Tested on Windows 11 with an AMD Radeon RX 9070 XT (16191 MiB VRAM, RDNA4, native wave64) on a local merge branch based on Setup & tested configuration
Observed results
Not tested
|
|
Setup
The full seed 1599 passes on this card; only its reduced "dynamic 2" variant fails. The default suite fails on AMD.
783 and 817 are not in the description; the maintainer's RDNA4 batch would likely hit at least 722. Tests
Retail title (1.0.2.1,
Interleaved PR's block (round 2): Not tested
Claude Code (Claude Opus 5.5), from runs on the hardware above. |
, 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.
…SLATOR_VERSION 6 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xcl-dev#1689) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested commit Tested
Not tested
AI use
|
Hardware test report — commit
|
|
Root-caused the RX 6600 ( Backward slice of %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
AI use: Antigravity (Gemini 4 Neon) traced the backward slice from the |
| 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_loadsran 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
758e341without 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 rerungpu_direct_msaa_image_loadswith 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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>
|
@bmjask @eizispark the Tested
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. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Tested On 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. 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>
|
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 AMD fuzz mismatches (@HKEY-Funk-Machine, @srcamarda, @thiagocalile, @nnonno91): not fixed, and I won't claim they are. @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 AI use: Claude Code (Claude Opus 5.5) wrote this comment for @bmjask. |
|
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
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). |
|
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? |
|
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;
Not tested: another driver on this card; seeds after 722 in AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment from the real output; checked by me before posting. |
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)
…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)
Follow-up to #1426.
What is in it
lower_geom.rs,kernel::translate_geometry,cfg::Cfg::build_geometry): the recompiler'sMode::Geometrycompute pass as direct DXIL — the ES for the three vertices of 21 triangles per group,s_setpc_b64into the GS,s_sendmsgGS 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_geometrytries it underXCL_DIRECT_DXIL=1(logged HLSL fallback); coverage routesMode::Geometry. Sweep: 200/200 incl. all 3 GS programs.CfgBlock::pcis kept for irreducible-CFG split copies.image_msaa_loadreads samples fragment..fragment+3 — this ISA reading is not confirmed on hardware); runnerTexDim::D2Ms.MODEround toward +inf / -inf / zero,lower_round.rs): direct path only — the HLSL path lacks it.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) plusamd_reduced_seeds(ignored) reproducing seeds 722 / 1599 on AMD. Seed 722 is suspected to be the driver movingWaveReadLaneFirstinto a divergent switch. @HKEY-Funk-Machine / @emirduran707, could you runcargo test -p xcl --lib gpu::dxil::fuzz_tests::amd_reduced_seeds -- --ignored --nocaptureon your AMD GPUs and post the output?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 ingpu_geometry_wave32_prefix_count_over_a_mask.TRANSLATOR_VERSION4 → 5.Tested
cargo test -p xcl --lib gpu::dxil: 100 passed, 0 failed, 3 ignored.XCL_DIRECT_DXIL=1and=allcargo 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 theLw::newrefactor); 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 60withXCL_PRESS_AT=2:B,4:B,6:B,8:B(B pressed at 2/4/6/8 s to skip splash screens) andXCL_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):
PR (e9ac9f0):
Not tested
image_msaa_loadsample-index reading is unconfirmed on hardware.amd_reduced_seedsrepro needs an AMD tester.s_setpc_b64as 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_recordstherefore compares the HLSL path only in its native form.AI use
🤖 Generated with Claude Code