Skip to content

D3D12.X: log render-target and depth handles no device call wrote - #3170

Open
KOLESNiii wants to merge 1 commit into
xcl-dev:mainfrom
KOLESNiii:d3d12x-target-handle-diagnostic
Open

KOLESNiii wants to merge 1 commit into
xcl-dev:mainfrom
KOLESNiii:d3d12x-target-handle-diagnostic

Conversation

@KOLESNiii

@KOLESNiii KOLESNiii commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Help wanted: evidence. This PR only measures and changes no behaviour; it is the first step for the console-layout guesses. Please run a title on this head and post the ... with handle ... that no view creation or device copy wrote (...) warnings (at most four) and the device adoption line with +0x10 / +0x18 here (not the whole log). A change to console-shaped RTV / DSV heaps is only worth making if a title shows this. The retail game logs none of the warnings in 60 s.

Console code may copy render-target and depth-stencil descriptors itself, at the console's sizes, into XCL's PC heaps. This diagnostic shows whether a title does, with no change in behaviour.

The console's descriptor helpers are compiled into the title. In an optimised build, CopyDescriptorsSimple of RTV / DSV descriptors is a plain memory copy of N × 112 / 128 bytes (the console's descriptor sizes), not a device call. XCL's RTV / DSV heaps are PC heaps with PC increments. Such a copy would overwrite neighbouring PC descriptors, and the copied handles were never written by CreateRenderTargetView / CreateDepthStencilView or a device copy. A change to console-shaped RTV / DSV heaps is only worth making if a title shows this.

What is in it

  • target_handles.rs (new) tracks:

    • the title's RTV / DSV heaps, from dev_create_descriptor_heap_x, the console device slot;

    • the handles their view creations (dev_create_rtv, dev_create_dsv_x) and device copies (CopyDescriptors(Simple)) write.

  • Checked calls: OMSetRenderTargets (up to 8 RTVs, the single-range form at the heap's increment, and the DSV), ClearRenderTargetView, and ClearDepthStencilView (console list GPU tests that cannot run on the adapter say so: SKIPPED lines, a count in scripts/test.ps1, XCL_REQUIRE_GPU (#42) #51).

  • Each check logs a handle inside a title heap that nothing wrote, with its heap, descriptor index and byte remainder. It logs four lines, then the checks stop. Handles outside the title's heaps (XCL's own) are not checked, so XCL's own work cannot produce a line.

  • At device adoption (real::adopt), the u64 at device +0x10 and the byte at +0x18 are logged once per device, with whether +0x10 lies in unified memory. Inline null CBVs take their address from +0x10, and validation builds read +0x18 to choose inline descriptor writes.

Tested

  • NVIDIA RTX 2070 SUPER (driver 32.0.16.2140), AMD Ryzen 5 3600XT, Windows 11 build 26300, Rust 1.100.0 MSVC; tests in debug

  • cargo test --workspace --no-fail-fast -- --test-threads=4 on 245e471: 2140 passed, 4 failed, 48 ignored. SKIPPED: 15 (14 no wave64, 1 no heap windows).

    • The 4 failures are the e2e title tests incomplete_discovered_corpus_blocks_headless_title_entry, test_title_draws_with_a_root_signature_under_the_debug_layer, test_title_runs_and_game_folder_is_untouched and test_title_runs_under_the_debug_layer_with_dred.

    • They also fail on main 309c3ec: 2138 passed, the same 4 failed, 48 ignored, same 15 SKIPPED.

  • New tests:

    • target_handles::tests::an_unwritten_handle_in_a_title_heap_is_reported_with_its_place: ok

    • target_handles::tests::heaps_and_copies_mark_handles: ok

Regression run

RTX 2070 SUPER, the retail game, 60 s, XCL_PRESS_AT=25:A, XCL_PREPARE=0 (no startup shader preparation), release builds. main ran in one queue job with other PRs' heads, this head in the next job; every run started from the same DXIL cache.

main:


xcl-smoke v1

commit: 309c3ec5a25ea231ddbe01f76748ab8ed3d9d953

gpu: NVIDIA GeForce RTX 2070 SUPER

title: retail game

seconds: 60

exit: 0x0

frames shown: 1297 (PresentX 1298)

presents per 2 s (last 3): 60 60 61

device removals: 0

crashes: 0

peak commit: 14701 MB

This PR's head:


xcl-smoke v1

commit: 245e471c1b2978cae76d3ff1c9db0aa94759f6dc

gpu: NVIDIA GeForce RTX 2070 SUPER

title: retail game

seconds: 60

exit: 0x0

frames shown: 1268 (PresentX 1268)

presents per 2 s (last 3): 61 60 60

device removals: 0

crashes: 0

peak commit: 14905 MB

The retail game logged no unwritten render-target / depth handle line in 60 s. Device adoption logged +0x10 outside unified memory and +0x18 = 0.

Not tested

  • Whether any title copies RTV / DSV descriptors inline. That is what this PR is for.

  • Not done: counting V#s in console view heaps whose address equals device +0x10 (inline null CBVs). No cheap place sees every slot a title writes inline, so the +0x10 value and whether it is in unified memory are logged instead.

  • The regression runs skip startup shader preparation (XCL_PREPARE=0), on main and on this PR alike.

  • AMD GPUs.

AI use

  • Claude Code, Claude Opus 5.5: wrote the code, the tests and this description; ran the tests.

  • Claude Code (Claude Opus 5.5) ran the regression runs and added them here.

🤖 Generated with Claude Code

@JJAutoCompare

Copy link
Copy Markdown

Tested

Independently reran the pinned standalone CPU executable for 245e471c1b2978cae76d3ff1c9db0aa94759f6dc on Windows 11 x64 build 26200.9974 with a Ryzen 7 3800X. The executable was built with Rust 1.100.1 (x86_64 MSVC). I verified the tracker and both stock controls byte for byte against Git. The synthetic fixture uses a stand-in logger to capture the formatted warnings.

target_handles.exe target_handles::tests::mixed_target_handles_share_the_warning_budget --exact --nocapture --test-threads=1
target_handles.exe target_handles::tests::an_unwritten_handle_in_a_title_heap_is_reported_with_its_place --exact --nocapture --test-threads=1
target_handles.exe target_handles::tests::heaps_and_copies_mark_handles --exact --nocapture --test-threads=1

All three native processes exited 0. Total was 3 passed, 0 failed, 0 ignored, 0 skipped. The fixture checked nine initial cases that emitted no warning, then matched four warnings in RTV, DSV, RTV, DSV order. The warning for RTV handle 0x1070 reported descriptor 3 + 16 B. After the fourth warning went to a DSV, the next otherwise-eligible RTV emitted no warning and the shared count stayed at four. Both stock controls passed with empty stderr.

Not tested

Device detection, D3D12 or UMA behavior, production diagnostics and runtime call sites, GPU, full crate and workspace suites, and title smoke.

AI use

T3 Code through Codex (gpt-6.2-sol, high) prepared the standalone fixture, verified the source and executable pins, independently reran the tests, and drafted this report.

The console's descriptor helpers are compiled into the title. In an
optimised build, CopyDescriptorsSimple of render-target or depth-stencil
descriptors is a plain memory copy of N x 112 / 128 bytes (the console's
sizes), while XCL's RTV / DSV heaps are PC heaps with PC increments. Such
a copy would overwrite neighbouring PC descriptors and leave handles that
no CreateRenderTargetView / CreateDepthStencilView / device copy wrote.

Diagnostic only, no behaviour change: the title's RTV / DSV heaps, the
handles their view creations and device copies write, and the handles
OMSetRenderTargets, ClearRenderTargetView and ClearDepthStencilView get
are tracked. A handle in a title heap that nothing wrote is logged with
its heap and offset (four lines, then the checks stop). At device
adoption, the u64 at +0x10 (the console's null constant-buffer address,
which inline null CBVs use) and the byte at +0x18 (validation builds:
0 = inline descriptor writes) are logged, with whether +0x10 is in
unified memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KOLESNiii
KOLESNiii force-pushed the d3d12x-target-handle-diagnostic branch from 6c395e1 to 8560353 Compare November 29, 2026 20:55
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 29, 2026
@KOLESNiii
KOLESNiii marked this pull request as ready for review November 29, 2026 21:00
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 8560353

No open or merged PR adds this check. #3192 and the merged #3179 remap superseded targets, a different change.
No correctness problems found in the diff. It is a diagnostic only, but it is always on (no env switch): until four lines have been logged, every OMSetRenderTargets / clear takes the HEAPS and KNOWN locks and scans the heap list, and note_view grows KNOWN with every RTV / DSV created. On a title where nothing is ever reported, both continue for the whole run. Consider an env switch or a cap.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head 8560353, diff read, not a merge-check; PR description red: its smoke block and counts are from 245e471):

  • Always on, on a hot path. There's no switch. OMSetRenderTargets calls check up to 9 times (real.rs ~11274-11283), plus increment_at. Each call takes the HEAPS read lock, scans every title RTV / DSV heap linearly, then takes the KNOWN read lock, and it also runs on XCL's own lists. It stops after 4 lines, so on a title that never triggers it the cost never stops. A switch (it's a diagnostic), or stopping after the first N frames, would bound it.
  • HEAPS is never pruned (target_handles.rs ~44-52): no hook on heap release, so the scan grows, and a stale range can produce a false line. XCL's own DSVs go to the PC CreateDepthStencilView, not dev_create_dsv_x. If one of XCL's DSV heaps reuses a released title heap's address, the depth check reports XCL's own work, despite "XCL's own work cannot produce a line" (unverified).
  • note_view (~65-67) takes a write lock on every CreateRenderTargetView from any caller and records handles outside title heaps too; filtering with heap_of first would keep the set small.
  • note_device (~128) is a second diagnostic. It reads the PC runtime's device object, so "+0x10 not in unified memory" is true by construction and tells nothing.
  • The test depends on the global stop flag being false; another lib test that logs 4 lines first would make it flaky (unverified).

Fine: no behaviour changes, the 4-line cap holds, copies are recorded after every early return, a null dsizes counts as 1 as in D3D12, single-handle ranges step by the heap's increment, and heap tracking is title-only. No nested locks.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants