Skip to content

D3D12.X: bind console_list view/sampler heaps before root signature and fix shared ClearUAV handle - #2518

Open
Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-console-list-heaps-clear-uav
Open

Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-console-list-heaps-clear-uav

Conversation

@Decodere

Copy link
Copy Markdown
Contributor

Fix three descriptor-heap and ClearUnorderedAccessView bugs in console_list command-stream replay: bind the shared CBV/SRV/UAV heap unconditionally (even with XCL_HEAP_WINDOWS=0), call SetDescriptorHeaps before SetComputeRootSignature, and use the valid shared-heap UAV handle in CLEAR_UAV_MARKER while rejecting sampler slots. Part of #2461. Part of #1452. Part of #1833.

What is in it

  • crates/xcl/src/hle/d3d12x/console_list.rs:
    • ensure_dispatch_heaps: mirror the sampler-heap path to unconditionally fetch or lazily create the shared CBV/SRV/UAV heap via console_heap::global_heap() / console_heap::shared_heap(d) (preserving heap_on_device filtering), instead of gating it on pso::heap_windows(), since translated ABI root signatures always set D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED.
    • bind_dispatch_root / close: resolve the compute root signature first (returning missing-RS errors before mutating command-list state), then invoke ensure_dispatch_heaps (SetDescriptorHeaps) strictly before list.SetComputeRootSignature(root_sig).
    • clear_uav_gpu_handle / CLEAR_UAV_MARKER: reject sampler slots (g.sampler || c.sampler) and select c.pc_gpu_uav when both slots live in the shared GLOBAL heap (c.shared_srv != 0 && g.shared_srv != 0 && c.pc_gpu_uav != 0), falling back to g.pc_gpu_uav otherwise (rejecting 0).
    • Tests:
      • clear_uav_gpu_handle_prefers_shared_cpu_slot_and_rejects_samplers: pure-CPU unit test covering shared GLOBAL inline-copy preference, shared fallback when c.pc_gpu_uav == 0, non-shared and mixed-heap fallback, sampler rejection, and zero-handle rejection.
      • bind_dispatch_root_sets_view_and_sampler_heaps_before_root_signature: isolated subprocess D3D12/WARP test (XCL_HEAP_WINDOWS=0, safe under --test-threads=4) using a recording ID3D12GraphicsCommandList spy vtable + real directly-indexed ABI root signature to verify ["heaps", "rs"] call ordering and [CBV_SRV_UAV, SAMPLER] binding without XCL_HEAP_WINDOWS, plus Close().is_ok() on a real D3D12 command list.

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 4060 8 GB (driver 621.14, 32-lane waves), Intel Core i5-11400F, Windows 11 Home build 26200, Rust 1.100.0, DXC / dxil.dll 1.9.2609.5, release build.
  • Failing-first before the fix (on origin/main 6d12f58a, XCL_ADAPTER=warp): both new tests failed (0 passed, 2 failed: clear_uav_gpu_handle returned Some(20496) instead of Some(24608), and bind_dispatch_root recorded ["rs", "heaps"] instead of ["heaps", "rs"] without creating the shared view heap).
  • Targeted cargo test --release -p xcl --lib -- hle::d3d12x::console_list::tests:: --nocapture:
    • RTX 4060: 9 passed, 0 failed, 0 ignored (0.35 s, 0 skipped).
    • XCL_ADAPTER=warp: 9 passed, 0 failed, 0 ignored (0.32 s, 0 skipped).
  • cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture (RTX 4060): 1425 passed, 0 failed, 46 ignored across 37 test binaries (29 pre-existing SKIPPED GPU/environment checks: 21 no wave64, 3 per-lane wave32 refused, 3 no D3D12 debug layer, 1 no heap windows, 1 cannot disable driver cache; 0 skipped in hle::d3d12x::console_list::tests).

Regression run
main:

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

PR:

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

Not tested

  • D3D12 debug-layer validation of console_list replay (d3d12SDKLayers.dll not installed in this environment) and native wave64 GPU tests.
  • End-to-end runtime execution under XCL_CONSOLE_LISTS=1 beyond unit/D3D12 command-list tests and the default 60 s title smoke test.

AI use

  • Google Antigravity (Gemini 4 Neon) implemented the console_list.rs heap-binding and CLEAR_UAV_MARKER fixes, wrote the unit and subprocess D3D12/WARP tests, ran the test and smoke suites, and drafted this PR description.

…nd fix shared ClearUAV handle

Fix three descriptor-heap and ClearUnorderedAccessView bugs in
console_list replay:

- ensure_dispatch_heaps: unconditionally load or lazily initialize the
  shared CBV/SRV/UAV heap via console_heap::global_heap/shared_heap
  (keeping heap_on_device filtering intact), instead of gating on
  pso::heap_windows(), because translated ABI root signatures always set
  CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED.
- bind_dispatch_root / close: resolve the compute root signature first so
  missing-RS errors return before mutating command-list state, then call
  ensure_dispatch_heaps (SetDescriptorHeaps) strictly before
  SetComputeRootSignature.
- clear_uav_gpu_handle / CLEAR_UAV_MARKER: reject sampler slots and prefer
  c.pc_gpu_uav when both GPU and CPU slots live in the shared GLOBAL heap
  (c.shared_srv != 0 && g.shared_srv != 0 && c.pc_gpu_uav != 0), avoiding
  uninitialized g.pc_gpu_uav after inline descriptor copies.

Add pure-CPU tests for clear_uav_gpu_handle and an isolated subprocess
D3D12/WARP test verifying both call ordering (SetDescriptorHeaps before
SetComputeRootSignature) and unconditional view+sampler heap binding
with XCL_HEAP_WINDOWS=0.

Part of xcl-dev#2461
Part of xcl-dev#1452
Part of xcl-dev#1833

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

Copy link
Copy Markdown
Contributor

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

Thanks!

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head 77f51420c133f3fc251c92628d2fde532c99300b (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: 1423 passed, 2 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.
    • Both PR tests passed: hle::d3d12x::console_list::tests::bind_dispatch_root_sets_view_and_sampler_heaps_before_root_signature and clear_uav_gpu_handle_prefers_shared_cpu_slot_and_rejects_samplers.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

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

xcl-smoke v1
commit: 77f51420c133f3fc251c92628d2fde532c99300b
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1601 (PresentX 1601)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13970 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.

@xpatfussy69x

Copy link
Copy Markdown
Contributor

Test run on exact head 77f5142 (77f51420c133f3fc251c92628d2fde532c99300b, on its base 6d12f58), clean tree.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs
  • cargo test --workspace -- --test-threads=4: 1425 passed, 0 failed, 46 ignored
  • SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 (on main too)
  • cargo test -p xcl --lib console_list: 10 passed, 0 failed
  • This PR's new tests in the workspace run:
    • clear_uav_gpu_handle_prefers_shared_cpu_slot_and_rejects_samplers: ok, not skipped
    • bind_dispatch_root_sets_view_and_sampler_heaps_before_root_signature: ok, not skipped

Regression run (60 s, default settings)

main:

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1091 (PresentX 1091)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14814 MB

this PR:

xcl-smoke v1
commit: 77f51420c133f3fc251c92628d2fde532c99300b
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1144 (PresentX 1144)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14797 MB

No crash or device removal; frames 105 % of main's, peak commit 100 %.

Not tested

  • Whether the title replays a console command list that binds a root signature or clears a UAV in this run: a regression check only
  • The PR merged into current main (tested on its own base; it merges into e1d84b7 without conflicts)
  • AMD / native wave64

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.

@SlopTart

Copy link
Copy Markdown

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of bind_dispatch_root_sets_view_and_sampler_heaps_before_root_signature and clear_uav_gpu_handle_prefers_shared_cpu_slot_and_rejects_samplers: 2 passed.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

@fromthemoonx

Copy link
Copy Markdown

Debug-layer run (listed under Not tested): with console lists on, the e2e title's D3D12 debug-layer messages are the same on this PR and on main. But the title never dispatches on a console list, so this run does not reach the changed code. Full suite passes on NVIDIA.

Tested: 77f5142 merged onto main e1d84b7 (clean). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug, Graphics Tools (D3D12 debug layer) installed.

result
cargo test --workspace --no-fail-fast -- --test-threads=4 1425 passed, 0 failed, 46 ignored; 25 SKIPPED lines; both new tests ran and passed
e2e test_title_draws_with_a_root_signature_under_the_debug_layer, XCL_CONSOLE_LISTS=1, PR and main identical on both: 3× error id 93, 1× error id 1046, 1× error id 1422 (ExecuteCommandLists: a CREATE_NOT_ZEROED render-target resource used by CopyResource before a Discard/Clear/Copy). The test fails on both because of that 1422; it is in main already, not this PR. The title log has 2 console list: SetPipelineState with an object not from XCL lines and no dispatch.
same test without XCL_CONSOLE_LISTS, PR passes; the same messages as main (3× id 93, 1× id 1046, 1× warning id 820, 8× id 0 at exit)

bind_dispatch_root_sets_view_and_sampler_heaps_before_root_signature records the calls on a spy list, so the debug layer cannot check the new heap/root-signature order there; a real list with the layer on would.

Not this PR, but it caught me out: console_list::enabled() checks only that XCL_CONSOLE_LISTS is set (var_os(...).is_some()), so XCL_CONSOLE_LISTS=0 turns console lists on too.

Not tested: a title that dispatches on console lists, AMD, a release build.

AI use: Claude Code (Claude Opus 5.5) ran the suite and the debug-layer comparisons, and wrote this report.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…pstream xcl-dev#2518)

(cherry picked from commit 0042d928634e9d2f6dede21d2be77f80f268a481)
Kalmarv added a commit to Kalmarv/xcl that referenced this pull request Nov 27, 2026
Kalmarv added a commit to Kalmarv/xcl that referenced this pull request Nov 27, 2026
…cl-dev#2518)

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

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 77f5142

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 753e8b1
head: 77f5142
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1514 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1512 passed, 0 failed, 47 ignored
review: no blocking finding. Default path: console-list dispatches now bind the shared view heap whether or not XCL_HEAP_WINDOWS is set (the shared heap exists by default), and heaps are set before the root signature, which is the right order for directly indexed root signatures. Notes: this now differs from list_x::ensure_view_heap, which still gates on heap windows; the test's child process runs with XCL_HEAP_WINDOWS=0, which is the default anyway, and a SKIPPED line of the child is swallowed; from the thread: the e2e title never dispatches on a console list, so no title run reaches this code. Not verified: that the shared copy of the CLEAR_UAV slot is always published.
performance: one mutex lock and one SetDescriptorHeaps per list (reasoned).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K (no SSE4a), Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 77f5142

No open standalone PR or main commit makes this change: main's console_list.rs still calls SetComputeRootSignature before ensure_dispatch_heaps, binds the view heap only under heap_windows, and clears through g.pc_gpu_uav. The same change also appears as commit ddc8a67 (by raylitebull) inside the large amd-dev port branches (#2604, #2704, #2738 and others, 200+ commits each). It is not on main, and those PRs are not a reasonable replacement for this one.
Main has changed the ClearUAV branch since this PR's base (it now clears through list_x::uav_clear_resource), so the rebase needs to keep that and apply clear_uav_gpu_handle on top. ensure_dispatch_heaps now also takes and returns shared_view_bound.
Binding the global view heap when heap_windows is off is a behaviour change for every translated dispatch. It is not covered by a title run here.
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants