Skip to content

D3D12.X: ensure view and sampler descriptor heaps before console-list dispatches - #2323

Open
Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-1991-console-list-sampler-heap
Open

Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-1991-console-list-sampler-heap

Conversation

@Decodere

Copy link
Copy Markdown
Contributor

What is in it

Follow-up to #1991 in crates/xcl/src/hle/d3d12x/console_list.rs:

  1. Track bound descriptor heaps across HEAPS_MARKER: Replaces the single heaps_set: bool flag in console_list::close() with (bound_heaps: Vec<ID3D12DescriptorHeap>, has_sampler_heap: bool). When HEAPS_MARKER has n == 0, close() now clears the command list via SetDescriptorHeaps(&[]) and clears (bound_heaps, has_sampler_heap) to match list_x::set_descriptor_heaps_x; when n > 0, it records the bound heaps returned by list_x::pc_heaps and whether a sampler heap is among them.
  2. Ensure view and sampler descriptor heaps before translated dispatches: Adds a pure generic default_dispatch_heaps helper (mirroring list_x::default_bound_heaps) and calls ensure_dispatch_heaps(&list, &mut bound_heaps, &mut has_sampler_heap) before each translated compute dispatch. When fewer than 2 heaps are bound, ensure_dispatch_heaps lazily initializes console_heap::shared_sampler_heap via list.GetDevice() if needed, filters shared heaps to the list's device, binds both view and sampler heaps when 0 heaps are bound (or sampler alone when !pso::heap_windows()), and upgrades 1-heap bindings missing either a view or sampler heap so directly-indexed translated pipelines (SAMPLER_HEAP_DIRECTLY_INDEXED) never dispatch with 0 sampler heaps bound.

Tested

  • cargo test --release -p xcl --lib hle::d3d12x::console_list::tests:: -- --test-threads=1 --nocapture on NVIDIA GeForce RTX 4060 and under XCL_ADAPTER="Microsoft Basic Render Driver" / XCL_ADAPTER=warp: 7 passed, 0 failed, 0 ignored (0 skipped), including:
    • default_dispatch_heaps_binds_and_upgrades_missing_view_or_sampler (pure CPU): covers 0-heap binding under both heap_windows modes (Some(view) and None), 1-heap view->view+sampler and sampler->view+sampler upgrades, no-op when satisfied, and (None, None).
    • gpu_ensure_dispatch_heaps_binds_view_and_sampler_heaps (D3D12, skip_test-guarded): exercises ensure_dispatch_heaps_with on a real ID3D12GraphicsCommandList across 0-heap bind, idempotent repeat call, SetDescriptorHeaps(&[]) reset + !heap_windows sampler-only bind, 1-view-heap upgrade, 1-sampler-heap upgrade, and list.Close().
  • Full release workspace (cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture on RTX 4060): 23 test binaries, 1267 passed, 0 failed, 46 ignored (28 pre-existing hardware/debug-layer SKIPPED: 21 no wave64 on 32-lane GPU, 3 wave32 per-lane refused, 2 missing D3D12 debug layer, 1 driver cache toggle, 1 no heap windows; 0 skipped in console_list).

Regression run

Paired 60 s scripts/smoke.ps1 runs on the same RTX 4060 host against origin/main (06c9f5505f63f10c5ec49ef932d75b2c28177324) and PR head (a78ffa89f64c31ed248b1e643e6ebb6c1b31455f):

Baseline (origin/main):

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

PR head:

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

Not tested

  • Retail title run with XCL_CONSOLE_LISTS=1 enabled (default smoke runs without XCL_CONSOLE_LISTS=1; descriptor-heap binding logic is verified directly by the unit and D3D12 command-list tests).
  • AMD/Intel GPUs and D3D12 debug-layer checks (d3d12SDKLayers.dll is not installed on this host).

AI use

Implemented and verified with Google Antigravity (Gemini 4 Neon).

… dispatches

Track `(bound_heaps, has_sampler_heap)` across `HEAPS_MARKER` records in
`console_list::close()` (clearing both via `SetDescriptorHeaps(&[])` when
`n == 0` to match `list_x::set_descriptor_heaps_x`) and call
`ensure_dispatch_heaps` before translated compute dispatches.

`ensure_dispatch_heaps` mirrors `list_x::default_bound_heaps` via a pure
`default_dispatch_heaps` helper, lazily creates `shared_sampler_heap` via
`list.GetDevice()` when missing (filtering heaps to the list's device), binds
both view and sampler heaps when 0 heaps are bound (or sampler alone when
`!heap_windows()`), and upgrades 1-heap bindings missing a view or sampler heap
so directly-indexed translated pipelines (`SAMPLER_HEAP_DIRECTLY_INDEXED`) never
dispatch with 0 sampler heaps bound.

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

Copy link
Copy Markdown

AMD run, plus an RTX 3060: the new GPU test passes on both, and nothing else in the GPU suite changes.

Head a78ffa8 applied on main 06c9f55, debug, Windows 11 Pro 26200, cargo test -p xcl --lib -- gpu:: --test-threads=4:

Not tested: a title with XCL_CONSOLE_LISTS=1, the D3D12 debug layer (not installed here).
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@nnonno91

Copy link
Copy Markdown

Independent Radeon check of a78ffa89f64c31ed248b1e643e6ebb6c1b31455f.

Tested

  • AMD Radeon(TM) Graphics driver 32.0.21042.62, Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC, unoptimized profile.
  • On the unchanged head, cargo test --locked -p xcl --lib hle::d3d12x::console_list::tests:: -- --nocapture --test-threads=1 gave 7 passed, 0 failed. This fixture uses the D3D12 default device.
  • I changed only the GPU fixture's device selection to explicitly select and print AMD Radeon(TM) Graphics. cargo test --locked -p xcl --lib gpu_ensure_dispatch_heaps_binds_view_and_sampler_heaps -- --nocapture --test-threads=1 then passed on the Radeon. It exercised empty bindings, sampler-only and one-heap upgrades, repeat binding and command-list close. Both runs had 0 ignores and no skips. The selection edit was restored.

Not tested

Retail smoke, the full workspace suite, and GPU shader output from a translated dispatch in this check.

AI use

OpenAI Codex (GPT-6.2 Sol) adapted the test fixture, ran the checks and wrote this report.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
…#2296, xcl-dev#2297, xcl-dev#2320, xcl-dev#2323, xcl-dev#2329, xcl-dev#2333

Integrates shader heap-base addresses (xcl-dev#1803), fenced superseded texture unmaps (xcl-dev#2270), cross-queue VRAM heap reclamation fencing (xcl-dev#2275, using create_raw_fence under Wine), PcCall frame clamping and orphan PSO drop (xcl-dev#2296), PSO pointer guards (xcl-dev#2297), KickoffX idle spare list switching (xcl-dev#2320, preserving UnadoptGuard), console-list descriptor heap binding (xcl-dev#2323), ClearUnorderedAccessView PC handles (xcl-dev#2329), and dispatch_chain PSO retention (xcl-dev#2333).
@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

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.

4 participants