Skip to content

D3D12.X: XCL_CAPTURE_DRAW writes one draw or dispatch to disk - #2430

Open
madaraXor wants to merge 2 commits into
xcl-dev:mainfrom
madaraXor:capture-call
Open

madaraXor wants to merge 2 commits into
xcl-dev:mainfrom
madaraXor:capture-call

Conversation

@madaraXor

@madaraXor madaraXor commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

XCL_CAPTURE_DRAW=<container fnv64, hex>[:N] writes the Nth draw or dispatch whose VS, PS or CS is that console shader to <data>\captures\: everything needed to run it again alone except the textures' contents, which the next PR adds. Off unless the variable is set. Part of #675.

The matching calls are not run in that run (XCL_CAPTURE_RUN=1 runs them): the switch is for a call that hangs the GPU. XCL_CAPTURE_DRAW=list only logs each translated pipeline's shader hashes, to find the hash to give.

Over 400 lines: the hook is one piece. The notes it needs (the view at each heap index, the last transition of a resource) are of no use without the call that reads them, and the call cannot be written without them.

Stacked on #2429; only the top commit belongs here.

What is in it

  • hle/d3d12x/capture.rs: the switch; what is noted while it is set (pipelines with the chosen shader, the SRV / UAV made at each heap index, RTV / DSV by handle, samplers, the last transition of a resource; a view counts only if its resource was not released since); on_call (shader containers, PC pipeline description, root arguments and the io words, fixed-function state, targets, vertex / index buffer views, the non-zero slots of each descriptor table, textures with their descriptions and views); memory read on the CPU at the submit of the call's list (titles fill buffers after recording the call); the pipeline listing.
  • bind.rs: the call's arguments, and the capture at the end of bind_abi, where the io words and the argument table exist.
  • real.rs, console_heap.rs, list_x.rs, dred.rs: one-line notes at pipeline, view, sampler and target-view creation, descriptor copies, transitions, resource release, before and after ExecuteCommandLists; list_x::capture_state.
  • Tests: view liveness after a release, the order a texture's state is taken from, root argument words.
  • Review fixes: transition states are kept per subresource (ResState: one state for all of them, then those transitioned on their own); a texture gets one state only when all its subresources (planes included) are in it, else state_source says partial: and why. Test: a_partial_transition_leaves_the_texture_state_unknown.

Tested

  • AMD Radeon RX 6700 XT 12 GB (RDNA2), driver 32.0.21045; Ryzen 5 5600X, 16 GB; Windows 10 22H2 (19045); rustc 1.90.0; release
  • A retail title, top of the stack (on the head before the review fixes): XCL_CAPTURE_DRAW=list in its menus listed 8 pipelines (5 VS + PS, 3 CS); two draws were then captured by hash (:3, a DrawIndexed of 30 with 4 textures; :100, a Draw of 3) and replayed.
  • Earlier, from a local branch with the same hook: the draw of a volumetric light pass that hangs the GPU was captured (DrawIndexed 72 x 6003, 86 memory ranges, 156 textures, nothing left out).
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on f6354cd: 1428 passed, 5 failed, 46 ignored. The failures: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 540), hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory (Tests: align XMemVirtualQuery buffers and verify CPU flags #650) and the e2e tests test_title_runs_and_game_folder_is_untouched, test_title_draws_with_a_root_signature_under_the_debug_layer and test_title_runs_under_the_debug_layer_with_dred, which fail on main e1d84b7 on this machine too (its whole suite: 1416 passed, 7 failed, 46 ignored). SKIPPED: the six per-lane cases of f16_programs_on_the_gpu / f32_programs_on_the_gpu (refused), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)

Regression run

scripts/smoke.ps1, 60 s, release builds, the same title on the same day.

main:

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: AMD Radeon RX 6700 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 788 (PresentX 788)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15646 MB

PR:

xcl-smoke v1
commit: f6354cd4f80c583501c2a386017384631f369e80
gpu: AMD Radeon RX 6700 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 931 (PresentX 931)
presents per 2 s (last 3): 48 58 60
device removals: 0
crashes: 0
peak commit: 18280 MB

Not tested

  • ExecuteIndirect (its arguments are not captured), console geometry and mesh pipelines and compute pipelines split into a dispatch chain (listed, not captured), memory reached through a pointer kept in a buffer (XCL_CAPTURE_EXTRA).
  • Dispatch captures in a title (only draws were captured).
  • Titles whose view heaps are not in the shared heap; several sampler heaps (one index space is assumed).
  • NVIDIA, Intel, RDNA3 / RDNA4; Windows 11.

AI use

  • Claude Code. Claude Fable 5.2 wrote the code, the tests and this description, and ran the tests listed above. Claude Opus 5.5 coordinated the work and ran the game checks. Claude Opus 5.5 wrote the review fixes of the last push and their tests, and ran the suites and smoke runs of this description.

🤖 Generated with Claude Code

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head c2569b06fb949f6b5480e36f31403f98c296700b (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: 1270 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 7 hle::d3d12x::capture tests passed.
    • 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; default capture off)

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

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

Not tested

  • Live XCL_CAPTURE_DRAW capture on the retail title; D3D12 debug layer; Intel GPUs.

AI use

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

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@SlopTart

SlopTart commented Nov 25, 2026 •

Copy link
Copy Markdown

gpu_ suite (cold cache): 160 passed / 4 failed, no crashes. Three are the known baseline trio on this lane; the fourth is gpu_promoted_uav_clear_values_pass_create_committed_resource, newly red on main since #2280 (report), unrelated to this PR.
Targeted run of the capture tests (XCL_CAPTURE_DRAW path): 7 passed.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 capture correctness: state is tracked per resource, not per subresource. note_transition records only resource + after state while the hook discards barrier subresource b[4]; Manifest likewise stores one state per texture. A valid transition of one mip/slice makes capture/replay treat every slice as that state, producing invalid transitions or incorrect inputs. Track state per subresource or omit/refuse partially transitioned resources without complete state knowledge; add a partial-mip regression. Current Windows CI fails; this is the underlying state bug also visible in later #2432.

madaraXor and others added 2 commits November 25, 2026 23:24
A GPU hang in a retail title costs a whole game run per experiment. The
plan is to write one draw or dispatch of a named shader to disk during a
run and to run it again alone, in seconds (this stack: the format, the
hook, the textures, xcl replay).

This is the format only: capture::manifest, the manifest.json of a capture
folder (the call, shader files, the PC pipeline description, root
arguments, fixed-function state, targets, memory ranges, textures, views,
samplers, descriptor slots, what was left out) with Manifest::write and
Manifest::read. Structures D3D12 gives as plain data are kept as hex of
their bytes. Nothing writes a capture yet.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
XCL_CAPTURE_DRAW=<container fnv64, hex>[:N] writes the Nth draw or dispatch
whose VS, PS or CS is that console shader to <data>/captures: the shader
containers, the PC pipeline description, the root arguments and the io
words bind_abi made, the list's fixed-function state, targets, PC vertex
and index buffer views, the non-zero slots of each descriptor table, the
samplers made so far, and the unified memory the tables, root buffers and
V# name. Textures are listed with their descriptions and the PC views made
of them; their contents follow in the next change.

The call is taken in bind_abi, where the io words and the argument table
exist. Memory is read at the submit of the call's list, not when the call
is recorded: titles fill buffers in between. The matching calls are not
run unless XCL_CAPTURE_RUN=1: the switch is for calls that hang the GPU.

To find the hash to give: with the variable set (XCL_CAPTURE_DRAW=list for
that alone) every pipeline made from translated console shaders is logged
with its shaders' hashes, the first 200, where dred::label names it – the
one place all five pipeline kinds pass. Draws of VS + PS pipelines and
dispatches of single compute pipelines are captured; geometry, mesh and
split compute pipelines are listed only.

To name what a slot's T# means on the PC, the SRV / UAV made at each heap
index, the RTV / DSV at each handle, samplers and the last transition of a
resource are noted while a shader is chosen. A view counts only if its
resource was not released since. Without the variable every hook returns
at capture::on().

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@madaraXor

Copy link
Copy Markdown
Contributor Author

Thanks, fixed in the force-pushed commit: states are tracked per subresource.

  • note_transition takes the barrier's subresource (b[4]). Per resource there is a ResState: one state for all subresources (from an ALL_SUBRESOURCES barrier) and the subresources transitioned on their own since.
  • state_of returns one state only when all of the texture's subresources are in it. The count includes planes (D3D12_FEATURE_FORMAT_INFO).
  • Otherwise the texture's state_source says partial: and why: subresources in different states, or one transitioned while the others are unknown. A use hint does not override a partial state recorded on the list.
  • Test: a_partial_transition_leaves_the_texture_state_unknown (a mip on its own, then the others one by one, then all again, and a texture with only one subresource ever transitioned).

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

NVIDIA test report for f6354cd: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug.

cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4 (the hle::xaudio2 tests hang on this machine, on main too):

  • this PR f6354cd: 1299 passed, 0 failed, 26 ignored.
  • main at 08db802: 1295 passed, 0 failed, 27 ignored.
  • The same 25 SKIPPED lines on both sides (no wave64 etc.).

Lib tests only; no title run.

AI-assisted (Claude Code, Claude Opus 5.5).

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

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

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants