Skip to content

Recompiler: load direct DXIL geometry ES inputs from the heap window - #2383

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
emusynths:verify_heap_windows_correctness
Nov 25, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
emusynths:verify_heap_windows_correctness

Conversation

@emusynths

@emusynths emusynths commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes direct DXIL geometry-shader translation when XCL_HEAP_WINDOWS=1 is active with multiple memory windows. Part of #2088.

When HEAP_WINDOWS is set and mem_windows > 1, mem_windows() in crates/xcl/src/gpu/dxil/kernel.rs fills lw.mems with placeholder i32 0 handles because all memory accesses are expected to go through heap_raw_buffer_uav(). geom_init() bypassed this and called lw.s.raw_load(lw.mems[0], ...) to load pre-fetched ES vertex inputs (v9..v255), which failed DXIL generation (function dx.op.rawBufferLoad.i32 redeclared with another type).

What is in it

  • crates/xcl/src/gpu/dxil/kernel.rs: lazily load the window-0 raw UAV from ResourceDescriptorHeap[MEM_HEAP_BASE] via heap_raw_buffer_uav() in geom_init() when lw.heap_mem is Some(coherent).
  • crates/xcl/src/gpu/dxil/geometry_tests.rs: add geometry_es_inputs_validate_and_run_with_heap_windows (fails before the fix; validates native + split wave64 forms and runs on the GPU after the fix).

Tested

  • Hardware: NVIDIA GeForce RTX 5090 32 GB (driver 621.01, wave32-only), Ryzen 9 5950X, 64 GB RAM, Windows x64, rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, debug (tests) / release (smoke).
  • cargo test -p xcl --lib geometry_tests (rebased head 25af00e on 2898511): 4 passed, 0 failed, 0 ignored.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 (before rebase onto 2898511): 1285 passed, 5 failed, 46 ignored.
    • The 5 failures are pre-existing on main 50a9fde on this adapter/DXC: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (CreateComputePipelineState: 0x8007000E) and gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier.
    • SKIPPED: wave64-only GPU tests (no wave64 on RTX 5090), per-lane f16 refused tests, heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows in default run), pso_measurement_compiles_an_exact_synthetic_record (Developer Mode off).
  • XCL_HEAP_WINDOWS=1 cargo test -p xcl --test gpu_compute_e2e -- --test-threads=1: 4 passed, 0 failed, 0 ignored (including heap_window_out_of_memory_falls_back_to_the_switch_form).

Regression run
60 s release runs of the same title with a warm local DXIL cache (XCL_NETWORK=0, default runtime flags):

xcl-smoke v1
commit: 50a9fdef81cb796b8756a31defb0648301d002ce
gpu: NVIDIA GeForce RTX 5090
title: a155fb60
seconds: 60
exit: 0x0
frames shown: 1637 (PresentX 1637)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16295 MB
xcl-smoke v1
commit: 25af00e196b5f5282d59fe3bcc71b10a6893a526
gpu: NVIDIA GeForce RTX 5090
title: a155fb60
seconds: 60
exit: 0x0
frames shown: 1583 (PresentX 1583)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15471 MB

Not tested

  • AMD / Intel GPUs and native wave64 hardware (covered by independent reports in the comments on f05fe12).
  • Retail title smoke run does not exercise XCL_DIRECT_DXIL=1 + XCL_HEAP_WINDOWS=1 geometry shaders directly (covered by the new GPU unit test).

AI use

  • Antigravity with Gemini 4 Neon: found the bug, wrote the fix, test, and PR description, and ran the tests and smoke runs. I reviewed the diff and results.

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head f05fe12154e1009a15c0989c7ca108496513b967 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1287 passed, 3 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • The PR's GPU test passed (no skips): gpu::dxil::geometry_tests::geometry_es_inputs_validate_and_run_with_heap_windows.
    • The 3 failures are pre-existing on unmodified main 68a284a: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722) and fuzz_validate_and_gpu_3 (seed 1599) on this GPU, plus gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier (from 50a9fde / Recompiler: a bridged mask write in the split form meets no barrier #2074).

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: f05fe12154e1009a15c0989c7ca108496513b967
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1623 (PresentX 1623)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13925 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.

@DarkPanda69

DarkPanda69 commented Nov 25, 2026 •

Copy link
Copy Markdown

Update for head 25af00e: same result. Paired against main 2898511 with XCL_DIRECT_DXIL=1 for the whole gpu:: filter: on both cards the only difference is the new geometry_es_inputs_validate_and_run_with_heap_windows (ok). RX 9070 XT 693 passed, 2 failed (the #2115 fuzz seeds, same on main); RTX 3060 695 passed, 0 failed.


AMD native wave64 run (listed as untested), plus an RTX 3060, paired against main with the direct translator on for the whole GPU suite.

Head f05fe12 applied on main 68a284a, debug, Windows 11 Pro 26200, XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4, on main and on this PR for each card:

main this PR
RX 9070 XT (RDNA4, 32.0.32029.2010, native wave64) 647 passed, 3 failed, 6 SKIPPED 648 passed, 3 failed, 6 SKIPPED
RTX 3060 (32.0.16.1088, wave32) 649 passed, 1 failed, 24 SKIPPED 650 passed, 1 failed, 24 SKIPPED

Per-test comparison: on both cards the only difference is the new geometry_es_inputs_validate_and_run_with_heap_windows (ok). No existing test changes result or skip state. The failures are on main without this PR: a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier on both (fixed by #2379) and, on the RX 9070 XT, the #2115 fuzz seeds.

Not tested: a title with XCL_DIRECT_DXIL=1 and XCL_HEAP_WINDOWS=1.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

…cl-dev#2088)

When XCL_HEAP_WINDOWS=1 is active with multiple memory windows, mem_windows() populates lw.mems with placeholder i32 0 handles so all memory accesses route through heap_raw_buffer_uav(). geom_init() bypassed this and called raw_load(lw.mems[0], ...), failing DXIL generation for any direct-DXIL geometry shader that reads pre-fetched ES vertex inputs (v9..v255).

Load window 0 from ResourceDescriptorHeap[MEM_HEAP_BASE] lazily when lw.heap_mem is set, and add a validation + GPU execution test.

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

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib: 1 real failure, deterministic (also fails --test-threads=1, 1219/1):
gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier
  assertion failed: group barriers in the program (lower_dxil.rs:1155)

The lowered program is missing an expected group barrier (or emits one where none is expected). Needs a fix before merge.

— Devin

@pvfreis

pvfreis commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Whole-suite NVIDIA run of 25af00e196b5f5282d59fe3bcc71b10a6893a526 (this PR's head, whose parent is main 2898511a, so merging changes nothing) next to that main. RTX 3060, one run per tree. DarkPanda69's update above covers this head's gpu:: tests with XCL_DIRECT_DXIL=1; this is the whole workspace with that switch unset. No failure that main lacks.

tree lib binary whole workspace geometry_tests
main 2898511a 1284 passed, 0 failed, 26 ignored 1362 passed, 1 failed, 46 ignored 3 passed
25af00e1 1285 passed, 0 failed, 26 ignored 1363 passed, 1 failed, 46 ignored 4 passed
  • The extra pass is geometry_es_inputs_validate_and_run_with_heap_windows, not SKIPPED: the split form ran on the GPU (no wave64 here). Test by test, nothing else differs.
  • The one failure, the same on both, is the e2e title test's presents assertion (e2e.rs:249, presents 0): CreateSwapChainForHwnd returns 0x887A0022 in this session.
  • a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier passed on both. Its assertion at this head is "group barriers after entry branch" (lower_dxil.rs:1156, since c828d8c0, in this head's base); "group barriers in the program" (:1155) is the text before that commit.
  • The four fuzz_validate_and_gpu_* tests passed on both.

Tested

  • RTX 3060 12 GB (driver 617.14), Ryzen 9 5900XT, 32 GB, Windows 11 (10.0.26300), Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug.
  • cargo build --workspace --locked --offline, then cargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4, as a separate sandbox user: non-interactive session, Low integrity, NVIDIA 32-lane waves only, no display, no audio device, XCL_NETWORK=0.
  • SKIPPED, the same 25 lines on both: 21 "no wave64", 3 f16 / f32 per-lane forms the direct path refuses, heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

Not tested

  • That the new test fails without the fix; XCL_HEAP_WINDOWS=1 (the test sets the option itself).
  • AMD, Intel and native wave64, a title or smoke run, release, presentation, audio output, the network.

AI use: Claude Code. Claude Opus 5.5 ran the two jobs, compared the logs and wrote this; a second Claude Opus 5.5 checked it against the logs and the live PR; Claude Fable 5.2 reviewed the text.

@emusynths

Copy link
Copy Markdown
Contributor Author

Thanks for testing! That failure was a pre-existing main test regression in lower_dxil.rs (untouched by this PR) fixed on main by c828d8c (Tests: check divergent block barriers in a_bridged_mask_write) — your 1219/1 count looks like the earlier f05fe12 commit before our rebase (1,220 lib tests vs 1,311 on current head 25af00e).

Verified on current head 25af00e (rebased onto 2898511): a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier passes (--test-threads=1: 1 passed, 0 failed), matching @DarkPanda69's 25af00e run (695 passed, 0 failed on RTX 3060).

@thehollowedone

Copy link
Copy Markdown

Independent Windows/NVIDIA integration check of #2383 head 25af00e on main 06055a7. The local merge --no-commit --no-ff was clean; its tree is 0e52d9f56020485a44167271cd28ecf6add3d765. No commit or PR update was made. RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC, SDK DXC/DXIL 1.8.2502.11. Offline Cargo; XCL_ADAPTER=RTX 3080 Ti, XCL_NETWORK=0, no sample data.

Tested

  • cargo test --offline --locked -p xcl --lib geometry_tests --jobs 6 -- --test-threads=1 --nocapture, with XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_D3D12_DEBUG=1: 4 passed, 0 failed, 0 ignored, 0 skipped. The new ES-input test executed on the GPU and read back the three expected vertex words from heap window 0 plus the zero beyond nv.
  • cargo build --offline --locked --workspace --jobs 6 passed. With the three overrides above unset, cargo test --offline --locked --workspace --no-fail-fast --jobs 6 -- --test-threads=4 --nocapture reported 1,414 passed, 0 failed, 46 ignored, including 26 runtime skip notices.
  • An additional gpu_compute_e2e run with direct DXIL, heap windows and D3D12 debug enabled reported 4 passed, 2 failed. Both offline-cache failures reproduced with the same command after building unmodified main 06055a7 (4 passed, 2 failed). They are not evidence of a Recompiler: load direct DXIL geometry ES inputs from the heap window #2383 regression under those settings.

Not tested: retail smoke on this integration, AMD/Intel, or performance. The PR still needs its author's current-head regression run and rebase under the repository rules. AI-assisted. Codex (GPT-6, exact variant unavailable) ran the checks and drafted this report.

@ivall
ivall merged commit 6d051da into xcl-dev:main Nov 25, 2026
3 checks passed
@ivall

ivall commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Merging: geometry shaders take their pre-fetched ES inputs from window 0 in the descriptor heap under HEAP_WINDOWS instead of the placeholder handle; without it the code is unchanged.

Tested on AMD RDNA4 (native wave64), Windows, DXC 1.8.2502.11, debug: main 06055a7 with #2333, #2097, #2368, #2408 and #2383 merged locally. Whole suite: 1422 passed, 2 failed, 46 ignored, 7 SKIPPED. With XCL_DIRECT_DXIL=1, cargo test -p xcl --lib -- gpu:: hle::d3d12x: 952 passed, 2 failed, 24 ignored. The two failures are fuzz_validate_and_gpu_1 and _3, which fail the same way on main here. geometry_es_inputs_validate_and_run_with_heap_windows ran on the GPU here (not skipped). Not tested: a title with XCL_DIRECT_DXIL=1 and XCL_HEAP_WINDOWS=1.

AI use: Claude Code (Claude Opus 5.5) read the diff and the thread, ran the tests and wrote this on the maintainer's behalf.

raylitebull added a commit that referenced this pull request Nov 25, 2026
…puts

Three clean improvements to Direct DXIL heap memory windows:
- Default pso::heap_flat() to on (opt-out with XCL_HEAP_FLAT=0) now that branchless Direct DXIL heap reads are verified stable on AMD RDNA4 (cutting PHIs 20x in large compute shaders).
- Remove the !gfx restriction in dxil/kernel.rs so Direct DXIL VS and PS stages also emit branchless heap reads instead of per-load branches and handle PHIs.
- Port #2383 in geom_init so ES+GS pre-fetched vertex inputs read from heap window 0 (MEM_HEAP_BASE) when HEAP_WINDOWS is active, with regression test in geometry_tests.rs.

Assisted-by: Antigravity (Gemini 4 Neon High)
raylitebull added a commit that referenced this pull request Nov 25, 2026
Keep amd-dev 0 commits behind origin/main (#2383 already in amd-dev, #2408 tests).

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

7 participants