Skip to content

D3D12.X: XCL_DUMP_TARGETS dumps the most-drawn render targets of a frame - #2050

Open
grahamster2 wants to merge 1 commit into
xcl-dev:mainfrom
grahamster2:xcl-dump-targets
Open

grahamster2 wants to merge 1 commit into
xcl-dev:mainfrom
grahamster2:xcl-dump-targets

Conversation

@grahamster2

Copy link
Copy Markdown
Collaborator

Adds XCL_DUMP_TARGETS=<work>[,<frames>], an opt-in diagnostic for black-screen cases. A busy frame (at least <work> draws and dispatches) gets a table of every render target drawn into and the depth buffer: format, size, and the draws into each, split into ran / stand-in (pipeline still being built) / PC / skipped. The 8 most-drawn targets are copied back and written as BMPs next to the presented frame, with a texel census ("N of M texels sampled not zero, K differ from the first texel"). That tells a lost composite (targets drawn, frame black) from a scene that never ran (draws all stand-ins, targets still at their clear value). XCL_DUMP_AFTER_S=<s> holds the dumps until s seconds after the first present, so the frames you get are the world, not the menus. Off by default: every hook returns on a cached check when the variable is unset.

Related: #1295 fixes how XCL_TRACE_FRAME picks the single busiest live render target for its one intermediate dump (it keeps a reference so a replaced RTV isn't read). This PR is separate: it counts per-target draw outcomes for a whole frame and dumps the top 8 plus the depth row. It reuses main's readback_copy / write_frame / RTV map, and does not touch the selection #1295 changes. The two can merge in either order; if #1295 lands first, view_resource here could use its live-RTV registry.

What is in it

  • crates/xcl/src/hle/d3d12x/targets.rs: switch parsing, per-frame target and outcome counting, ranking, texel census, the table; unit tests.
  • bind.rs / list_x.rs: one hook per draw, dispatch and ExecuteIndirect path with its outcome; bound_render_targets.
  • present.rs: copies the picked targets at the present, logs the census, counts a frame as dumped only once its readback is submitted.
  • real.rs: DSVs go into the view map only when the switch is set.
  • README.md: the two variables.

Limits (also in the module doc): draws are attributed to frames by recording time. The depth buffer is listed but not copied, because XCL doesn't track the title's resource states. Colour targets are copied in whatever state the title left them, as XCL_TRACE_FRAME already does. MSAA and non-2D targets are listed as "not dumped". ExecuteIndirect counts once whatever its count.

Size: +444/-1, of which 104 lines are the test module.

Tested

  • RTX 3080 10 GB (NVIDIA 610.88), Ryzen 5 7600X, 32 GB, Windows 11 build 26200, rustc 1.94.0, debug.
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 on db4cadc (base 6567c5f): 1004 passed, 0 failed, 45 ignored. 23 SKIPPED lines: 22 no wave64 / refused in gpu::recomp, plus heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows.
  • A run of the release build of db4cadc with XCL_DUMP_TARGETS=10,2 XCL_DUMP_AFTER_S=20 on a retail title (60 s, menus): two frames were dumped at 29.8 s (frames 736 and 737). For each, the table listed 2-3 render targets (3840x2160, format 28, all draws ran) and the depth buffer as "not dumped: its state is not known". The BMPs were written, and the census read 518400 of 518400 texels not zero, 284148 differ from the first texel. On that menu screen the targets and the presented frame are the same picture (identical BMPs). The run exited normally.
  • A local version of this diagnostic was used on a retail title over several runs. It showed that G-buffer draws were stand-ins and that the depth and G-buffer targets stayed empty while another target was written. Those runs were on an earlier, broader diagnostic, not this commit.

Regression run
main:

xcl-smoke v1
commit: 6567c5ffa38fbc7039b2d6bf520154689cc1f482
gpu: NVIDIA GeForce RTX 3080
title: 5d6132ca
seconds: 60
exit: 0x0
frames shown: 1627 (PresentX 1627)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16019 MB

PR:

xcl-smoke v1
commit: db4cadca8eba92e0d663760e5eefc486fd7547a0
gpu: NVIDIA GeForce RTX 3080
title: 5d6132ca
seconds: 60
exit: 0x0
frames shown: 1642 (PresentX 1642)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15402 MB

Not tested

  • A busy in-world frame with this commit (the title's world currently stops presenting on this machine); colour targets left in a state other than the one the copy expects; AMD.

AI use

  • Claude Code with Claude Opus 5.5 ported the diagnostic, wrote the tests and this description; an independent Claude review of the diff led to the fixes for depth state, frame counting, unset cost and the census.

A black presented frame does not say whether the scene was drawn and the
composite lost, or the scene never drawn at all; nor which of the draws
that should have made it actually ran. XCL_FRAME_DUMP shows only the
presented image.

XCL_DUMP_TARGETS=<work>[,<frames>]: in the first <frames> frames (default
1) with at least <work> draws and dispatches, each render target drawn
into, and the depth buffer drawn with most, is logged with its address,
size, format and its draws split into ran (translated pipeline), stand-in
(pipeline still being built: draws nothing), PC (untranslated) and
skipped. The eight drawn into most are read back with the presented frame
and written next to it (target<k>_<n>.bmp), with how many of their
sampled texels are not zero and how many differ from the first one (a
cleared target has none that differ). The census reads by the footprint's
texel size and stops at the end of the readback buffer. The depth buffer
is not copied: XCL does not know the state the title left it in, and a
copy from DEPTH_WRITE is invalid. A frame counts as dumped once its
copies are submitted; one waiting for a present that copies is kept.

XCL_DUMP_AFTER_S=<s>: no frame is dumped until <s> seconds (fractions
too) after the first present (a title's menus are busy frames too).
Invalid values of either switch are logged once.

Off by default: every hook returns on a cached check of the switch, and
DSVs are only recorded with it set, so nothing is locked or allocated
without it.

Assisted-by: Claude Code (Claude Opus 5.5)
@raylitebull

Copy link
Copy Markdown
Member

Code review on db4cadc:

  • crates/xcl/src/hle/d3d12x/targets.rs + hooks in bind.rs, list_x.rs, present.rs, and real.rs are cleanly scoped behind XCL_DUMP_TARGETS: targets are tracked by raw address without AddRefing (present::view_resource verifies a live view before copying), depth buffers are counted without issuing invalid state-unknown copies, and census bounds buffer slices cleanly (the_census_stops_at_the_end_of_the_buffer).
  • PR description is green and Build and test (Windows, no GPU) is currently running.

Remaining before merge: Build and test finishing green plus AMD and NVIDIA verification on db4cadc.

@Alm0stSurely

Alm0stSurely commented Nov 25, 2026 •

Copy link
Copy Markdown

Linux/Proton world-loading result for the target census. I applied the unmodified diff of db4cadca8eba92e0d663760e5eefc486fd7547a0 to the previously measured baseline c00f3fcfce59bb4dfd3a1f96bbc84c60e765b538 and built release. EndeavourOS, Proton Experimental, Ryzen 9 9950X3D, RTX 5080, NVIDIA 620.73.04. Launch inside the isolated test environment: proton run /build/xcl.exe run <title-exe>. Main settings: XCL_DUMP_TARGETS=100,3 XCL_DUMP_AFTER_S=215 XCL_FRAME_DUMP=120 XCL_DIRECT_DXIL=0 XCL_COMPACT_CS=auto XCL_PSO_PRELOAD=0 XCL_PSO_WAIT_MS=250 XCL_ACTIVITY=1 XCL_RUN_SECONDS=300 XCL_NETWORK=0, warm cache copied independently per attempt.

Frames 1607, 1608 and 1609 (221.0–223.9 s) each listed 40 color targets. Their presented readbacks contained exactly one RGBA8 value, 0x553a3432, at all 518400 sampled texels. Of the top eight color targets, seven had zero raw values at every sampled position in each frame. The exception was the same 2560×1440 R16G16_FLOAT resource, ranked second or third:

Frame Recorded draws + dispatches Translated draws to R16G16_FLOAT Raw samples differing from first (of 230400)
1607 6996 223 230383
1608 4500 223 230389
1609 2659 222 230360

The tested RGBA8 UNORM and sRGB targets each counted 221/221/220 translated draws across those frames, yet every sampled texel was zero. The R32_UINT target counted 360/180/180 stand-ins and zero translated draws. These counts are per bound target at recording time; MRT counts can overlap. Depth was listed only. The R16G16_FLOAT BMP is marked “format not decoded”, so the raw census is essential here. Pixel variation in this two-channel target alone does not establish a composed scene.

The measured run reached the 300 s cap with 1633 PresentX calls and no logged device removal before the cap. An earlier attempt lost the device at 37.572 s before any target dump. This supplements the author's menu case with paired readbacks from a flat presented frame on Proton. Full-suite testing on the PR's standalone head was outside this run. Test and report assisted by Codex (GPT-6.2 Astra).

Targeted preload comparison on Linux/Proton. On the same instrumented binary (base c00f3fc plus the target-dump change at db4cadc), I compared independent copies of the same warm cache. With XCL_PSO_PRELOAD=0, the R32_UINT target recorded 180/180/360 stand-in draws on frames 1663–1665. All three frames used the same 180 pipeline instances (3 distinct VS, 180 distinct PS). On first observed stand-in use, each instance still had its build job available. The corresponding integer attachment was slot 1 with blending and logic ops disabled.

With XCL_PSO_PRELOAD=1 and only those 180 shader-set keys in the initial pipeline history, frames 1681–1683 recorded 48/180, 49/180, 49/180 translated draws on that target. At readback, every one of the 230,400 sampled R32_UINT texels was still zero in each frame. Each corresponding 960×540 presentation was uniform (raw 0x553a3432). This pair shows that readiness can change substantially while the measured output stays empty. The next useful distinction is whether one translated draw actually writes the integer attachment before later clears or passes. Both runs used XCL_DIRECT_DXIL=0 XCL_PSO_WAIT_MS=250 XCL_DUMP_AFTER_S=215 XCL_DUMP_TARGETS=100,3. One run per condition. Local instrumentation and analysis assisted by Codex (GPT-6.2 Astra).

Pixel-shader output check on the same run. 52 of the 180 selected pixel shaders had a translated cache entry available for inspection. All 52 declare a UINT SV_Target1 at register 1, including the 49 candidate keys inferred by subtracting the stand-ins on frame 1682. The sole instance that disappeared from the stand-in set between frames 1681 and 1682 finished compiling between those captures (PS 1acd1e3b68d87382). Its cached DXIL contains an integer storeOutput to element 1, component 0. A runtime condition selects a computed value or zero. This rules out a missing red-channel export in that binary. The effective RT1 write mask, runtime value and direct identity of the translated draw remain unmeasured.

Effective color write mask. A follow-up on the same instrumented base and selected-key cache setup joined translated draws to their compiled graphics PSO and bound attachment slot. Frames 1676–1678 each recorded 48 translated draws and 132 stand-ins on the R32_UINT attachment. All 48 translated draws per frame bound the target at slot 1 with IndependentBlendEnable=FALSE and effective RenderTarget[0].RenderTargetWriteMask=0xF in the descriptor passed to D3D12. Red writes were enabled. All 230,400 sampled texels remained zero per frame and the matching presentations were uniform gray. This narrows the next measurement to fragment coverage and the contents immediately after an individual translated draw.

Per-draw GPU statistics. On the same setup, a D3D12 pipeline-statistics query bracketed each of three native ExecuteIndirect calls with the same translated graphics pipeline (PS 00771d5dd90bf78c, shader-set key 0c84540f681d8977), R32_UINT bound at slot 1, MaxCommandCount=1, no count buffer. The three recordings were submitted once each. After recording retirement and queue-fence completion, all three queries returned 0 IA vertices, 0 IA primitives, 0 VS invocations, 0 clipper invocations/output primitives and 0 PS invocations. Later frames 1625–1627 still recorded 48 translated calls on this target per frame. For this one pipeline, marking a call as translated did not mean it produced geometry. A second isolated run reproduced all-zero IA/VS/PS counts for three more calls on this pipeline. All three signatures contained only DRAW (non-indexed), stride 16, native argument-buffer offset 16, placement delta 0. XCL tracked no active predicate on those command lists. In a follow-up with an instrumented vkd3d-proton 4522cc1, the driver recorded vkCmdDrawIndirect on each of three calls. Immediately before each draw, the same command buffer copied its actual 16-byte VkDrawIndirectCommand from the native argument buffer at mem.offset + 16. All three records were {vertexCount=0, instanceCount=0, firstVertex=0, firstInstance=0}. A separate 16-byte positive transfer control returned [3,1,7,11] each time. The destinations were initialized with sentinels and read after queue-fence completion. IA/VS/PS counts were again zero. This explains those three empty draws on this pipeline. Some indirect records can legitimately be empty, and the diagnostic adds transfer barriers that can affect timing. This measurement does not establish why other pipelines or the final presentation are empty.

Follow-up on the same instrumented integration (Codex, GPT-6.2 Astra). In a single CPU recording interval between presents, we sampled the other 47 translated graphics pipeline keys on the same R32 target, one native vkCmdDrawIndirect per key. All 47 fenced argument reads returned (0, 0, 0, 0) across 24 distinct offsets of one Vulkan buffer. All 47 corresponding pipeline queries reported zero input vertices and zero vertex/pixel shader invocations. This narrows the next trace to the commands that populate those offsets and their ordering before consumption. It does not establish why the records are empty or whether these draws are required for the scene.

Allocation check on a second replay of the same cohort (Codex, GPT-6.2 Astra): all 47 draws used one 1,920-byte committed DEFAULT-heap buffer with ALLOW_UNORDERED_ACCESS. XCL tracked a separate title address outside its UMA windows for the sampled offsets. None of the most recent 262,144 recorded CopyBufferRegion commands overlapped the sampled bytes. The preceding 1,498,849 copies had aged out, and this probe does not cover UAV writes or different native buffer aliases. This rules out the sparse-window resource as the direct draw argument object in this capture. The producer and execution ordering remain open. A paired replay (same integration, Codex GPT-6.2 Astra) successfully read all 16 bytes at the associated title address at CPU command recording for each of the 47 draws. Across 24 offsets, every CPU tuple and every corresponding fenced GPU tuple was (0, 0, 0, 0). This gives no evidence of populated CPU draw arguments going missing in this sample. CPU recording and GPU consumption are different observation times.

@JJAutoCompare

Copy link
Copy Markdown

PR #2050 — XCL_DUMP_TARGETS on Intel Arc

Verified exact head db4cadca8eba92e0d663760e5eefc486fd7547a0 in a clean detached checkout.

Environment

STOR-WINLAB, Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X. Intel Arc A770 16 GiB, driver 32.0.101.9175, wave sizes 8–32, DoublePrecisionFloatShaderOps=0. DXC/DXIL 1.9.2609.5. rustc 1.100.0 (0ef1bc386 2026-11-09). Dev and test profiles with debug info and incremental compilation disabled. Cargo target and temporary files were directed to L:.

Tested

  • cargo build --workspace and cargo test --workspace --no-run both exited 0 outside the GPU lock.
  • cargo test -p xcl --lib hle::d3d12x::targets::tests -- --nocapture reported 7 passed, 0 failed, 0 ignored, 973 filtered out, and 0 skip markers. The tests cover option parsing, frame eligibility, draw outcomes, depth selection, target ranking and tie order, texel sizing, and census bounds and counts.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once under the shared Arc lock using L:/XclTooling/Invoke-ArcTest.ps1. Cargo exited 101. The combined log is L:\XclTooling\sol-slot-7\tmp\pr2050-suite.log.
Test target Passed Failed Ignored
xcl library 930 25 25
xcl CLI 0 0 0
bcpack_parity 1 0 0
console_dlls_e2e 13 0 0
console_shaders 3 0 4
disasm_e2e 1 0 0
e2e 2 1 0
gpu_compute_e2e 4 0 0
gpu_pso_e2e 7 0 0
heap_probe 0 0 4
low_va 1 0 0
pls_quota 1 0 0
predication_e2e 1 0 0
rpf_e2e 2 0 0
shaders_e2e 4 0 0
sparse_reinit 1 0 0
texture_states 1 0 0
xg_oracle 6 0 12
xcl-testtitle 0 0 0
xcl doc-tests 0 0 0
Total 978 26 45

The suite reported 0 measured and 0 filtered out. The log contains exactly 23 SKIPPED lines across 13 test names. The library emitted 18 for unavailable wave64, 3 for refused wave32 per-lane lowerings, and 1 for unavailable driver-cache control (0x887A002D). gpu_compute_e2e emitted 1 for unavailable heap windows. The table gives raw libtest counts. Skip markers can describe individual cases within a test or early returns counted as passes, and confer no coverage. Libtest captured successful test output, including the debug-layer tests' skip diagnostics, so the count covers the markers visible in this log.

Failures

The 26 failures appear unrelated to the dump logic based on the failing paths and the earlier same-host PR #1924 log. That log records 25 of the same names, including the identical depth-bias failure. The remaining test (gpu_direct_f32_round_preserved_denormal_times_inf_is_inf) is already present in the PR's parent and fails in the direct DXIL compute runner. This was a PR-head run only.

21 shader tests failed at CreateComputePipelineState with 0x80070057.

  • gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0
  • gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1
  • gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_2
  • gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3
  • gpu::dxil::ops_tests::doubles_match_cpu
  • gpu::dxil::ops_tests::groupshared_barrier_and_atomics_run
  • gpu::dxil::round_tests::gpu_direct_f32_round_modes_dynamic_and_denormals
  • gpu::dxil::round_tests::gpu_direct_f32_round_modes_static
  • gpu::dxil::round_tests::gpu_direct_f32_round_preserved_denormal_times_inf_is_inf
  • gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu
  • gpu::recomp::tests::gpu_clamp_and_omod_per_instruction
  • gpu::recomp::tests::gpu_f64_class_compare
  • gpu::recomp::tests::gpu_f64_compares_with_nan
  • gpu::recomp::tests::gpu_f64_literal_high_word
  • gpu::recomp::tests::gpu_f64_math_random
  • gpu::recomp::tests::gpu_f64_roots
  • gpu::recomp::tests::gpu_f64_rounding_and_conversions
  • gpu::recomp::tests::gpu_float_compares_random
  • gpu::recomp::tests::gpu_frexp_f64_exp_and_mant
  • gpu::recomp::tests::gpu_ldexp_f64
  • gpu::recomp::tests::gpu_rndne_f64

Four shader tests failed assertions.

  • gpu::recomp::tests::gpu_nonfused_mad_and_mac_prevent_fma_contraction (fused FMA overflow control)
  • gpu::recomp::tests::gpu_ps_image_sample_offset_implicit_lod_between_mips (implicit-LOD pixel value)
  • gpu::recomp::tests::gpu_valu_16_and_64_bit (preserving the high half of v_add_f16)
  • gpu::recomp::tests::gpu_wave64_ps_whole_wave_reductions (pixel-shader wave reductions)

The integration test test_title_runs_and_game_folder_is_untouched failed the existing dynamic depth-bias check. RSSetDepthBiasX(-1000.5) produced a blue top-right pixel where the test expected green.

Not tested

  • End-to-end XCL_DUMP_TARGETS GPU readback and BMP output with the switch enabled.
  • Retail Xbox title smoke runs, a fresh main or parent baseline suite, and other GPU vendors.
  • D3D12 debug-layer validation. d3d12SDKLayers.dll is absent on this host.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified the counts against pr2050-suite.log and published this report.

@JoaoPauluu

Copy link
Copy Markdown

A run of the switch under Wine on Linux, where this title's picture is a flat dark colour: the dump works and says what the picture already suggested. The few draws in the dumped frames all ran, and every target they drew into holds a single colour.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257, DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. db4cadc as it is (based on 6567c5f), no uncommitted changes. Retail title 1.0.2.1, scripts/linux/smoke.sh (Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257) for 60 s, no input.
  • The 7 new tests in hle::d3d12x::targets::tests pass under Wine, one test per process.
  • XCL_DUMP_TARGETS=10,2 XCL_DUMP_AFTER_S=20: exit: 0x0, 1384 frames, no device removal, no crash. Two frames were dumped at 46.2 s:
    • frame 972: 12 draws and dispatches, 2 render targets (3840x2160, format 28: 10 draws and 1 draw) and the depth buffer (format 19, 10 draws, not dumped: its state is not known). All draws ran, none stand-in, PC or skipped.
    • frame 975: 27 draws and dispatches, 3 render targets (23, 1 and 1 draws), depth buffer 23 draws, again all ran.
    • Every target, and the presented frame, reads 518400 of 518400 texels sampled not zero, 0 differ from the first texel, all 0xff2c2020. The 7 BMPs were written to the title's logs folder.
  • An earlier attempt passed XCL_DUMP_TARGETS="10,2:XCL_DUMP_AFTER_S=20" (my script's mistake). That gave is not <draws and dispatches>[,<frames>]: no targets dumped and the run went on normally, so the bad-value path warns as intended.

The dumped frames are light ones (12 and 27 draws) about 46 s in. In 60 s with no input this title does not get past that, so this does not show the busy frames.

Not tested

  • a longer run or one with input that reaches world frames, a higher <work> threshold, the whole suite on this head, native Windows.

AI use

  • Claude Code (Claude Opus 5.5) built the commit, ran the tests and the runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@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.

6 participants