D3D12.X: the capture format of one draw or dispatch #2419

Open
madaraXor wants to merge 1 commit from upstream-pr/2429 into main
madaraXor commented 2026-11-25 18:37:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by madaraXor on 2026-11-25T18:37:49Z.


A GPU hang in a retail title costs a whole game run per experiment. This stack writes one draw or dispatch of a named shader to disk during a run (XCL_CAPTURE_DRAW) and runs it again alone, in seconds (xcl replay). Part of #675.

This first part is the format of a capture only; nothing writes one yet.

What is in it

  • hle/d3d12x/capture/manifest.rs: 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), Manifest::write / Manifest::read with a version check. D3D12 structures are kept as hex of their bytes.
  • hle/d3d12x/capture.rs, mod.rs: the module.
  • Tests: a manifest reads back as written; another version, or no file, is an error naming the file; a manifest without a later field still reads; hex round trip.
  • Review fixes: unhex refuses an odd number of digits or non-hex text; Manifest::read checks every hex field, that D3D12 structures have this build's size, that root arguments are whole dwords, and that every file it names is a plain name in the capture folder (plain_name). Tests: a_damaged_manifest_is_refused, plain_names_only.

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
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on 69e0883: 1423 passed, 6 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 (#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); hle::d3d12x::vram::tests::d32s8_targets_take_their_own_size_of_video_memory failed in this whole-suite run; both fail in the whole-suite run of main e1d84b7 on this machine too. 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

  • No runtime code runs differently: the new module is not called yet.

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: 69e0883d7e61f85c171dac64407319caa68c54d9
gpu: AMD Radeon RX 6700 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 870 (PresentX 870)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18896 MB

Not tested

  • Reading a capture written by a build with other windows crate structure layouts (the manifest keeps their bytes).

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

<!-- greyfinch-sync:ivall/xcl:issue:5497038705 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2429). Originally posted by [madaraXor](https://github.com/madaraXor) on 2026-11-25T18:37:49Z. --- A GPU hang in a retail title costs a whole game run per experiment. This stack writes one draw or dispatch of a named shader to disk during a run (`XCL_CAPTURE_DRAW`) and runs it again alone, in seconds (`xcl replay`). Part of #675. This first part is the format of a capture only; nothing writes one yet. **What is in it** - `hle/d3d12x/capture/manifest.rs`: 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), `Manifest::write` / `Manifest::read` with a version check. D3D12 structures are kept as hex of their bytes. - `hle/d3d12x/capture.rs`, `mod.rs`: the module. - Tests: a manifest reads back as written; another version, or no file, is an error naming the file; a manifest without a later field still reads; hex round trip. - Review fixes: `unhex` refuses an odd number of digits or non-hex text; `Manifest::read` checks every hex field, that D3D12 structures have this build's size, that root arguments are whole dwords, and that every file it names is a plain name in the capture folder (`plain_name`). Tests: `a_damaged_manifest_is_refused`, `plain_names_only`. **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 - `cargo test --workspace --no-fail-fast -- --test-threads=4` on `69e0883`: 1423 passed, 6 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` (#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); `hle::d3d12x::vram::tests::d32s8_targets_take_their_own_size_of_video_memory` failed in this whole-suite run; both fail in the whole-suite run of `main` `e1d84b7` on this machine too. 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** - No runtime code runs differently: the new module is not called yet. `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: 69e0883d7e61f85c171dac64407319caa68c54d9 gpu: AMD Radeon RX 6700 XT title: 1778c2d9 seconds: 60 exit: 0x0 frames shown: 870 (PresentX 870) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 18896 MB ``` **Not tested** - Reading a capture written by a build with other `windows` crate structure layouts (the manifest keeps their bytes). **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](https://claude.com/claude-code)
SlopTart commented 2026-11-25 20:08:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T19:46:17Z.


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 new capture-format tests (manifest round-trip, version refusal, subresource/plane copy, texture-state list, hex round-trip): 3 passed.

<!-- greyfinch-sync:ivall/xcl:comment:7172744062 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2429#issuecomment-7172744062). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-25T19:46:17Z. --- `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](https://github.com/xcl-dev/xcl/pull/2280#issuecomment-7172066690)), unrelated to this PR. Targeted run of the new capture-format tests (manifest round-trip, version refusal, subresource/plane copy, texture-state list, hex round-trip): 3 passed.
DavidM1911 commented 2026-11-25 20:08:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T19:54:37Z.


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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7172929941 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2429#issuecomment-7172929941). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T19:54:37Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
bmjask commented 2026-11-25 20:51:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:51:19Z.

Review: COMMENTED


P2 capture-integrity issue: unhex silently drops malformed pairs/odd nibbles (manifest.rs:229-231; tests explicitly accept "zz10" and "0fa"), and Manifest::read validates only JSON/version. Corrupt descriptors become None/default views, while padded malformed PSO blobs can still be consumed as shifted raw structures. A diagnostic capture can silently replay a different pipeline/view. Make unhex return Result and reject odd/non-hex input; validate fixed-size hex fields on read and add malformed-capture rejection tests. Current Windows check also fails.

<!-- greyfinch-sync:ivall/xcl:review:6064814980 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2429#pullrequestreview-6064814980). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-25T20:51:19Z. **Review:** COMMENTED --- P2 capture-integrity issue: unhex silently drops malformed pairs/odd nibbles (manifest.rs:229-231; tests explicitly accept "zz10" and "0fa"), and Manifest::read validates only JSON/version. Corrupt descriptors become None/default views, while padded malformed PSO blobs can still be consumed as shifted raw structures. A diagnostic capture can silently replay a different pipeline/view. Make unhex return Result and reject odd/non-hex input; validate fixed-size hex fields on read and add malformed-capture rejection tests. Current Windows check also fails.
madaraXor commented 2026-11-26 00:05:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by madaraXor on 2026-11-25T23:43:32Z.


Thanks, fixed in the force-pushed commit:

  • unhex now returns Result: an odd number of digits, or anything but hex digits (signs included), is an error that names the digit.
  • Manifest::read checks every hex field after the version check:
    • a D3D12 structure (graphics pipeline, RTV, DSV, SRV, UAV, sampler) must have this build's size;
    • root arguments must be whole dwords;
    • every file the manifest names (shaders, memory.bin, tex_<id>.bin) must be one plain name inside the capture folder (plain_name).
  • A damaged manifest is refused with what is wrong, so it is never read as another pipeline or view.
  • Tests: hex_round_trips now expects the errors; a_damaged_manifest_is_refused covers odd and non-hex fields, wrong-size structures, partial root dwords and paths out of the folder; plain_names_only covers the name check.
<!-- greyfinch-sync:ivall/xcl:comment:7177961477 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2429#issuecomment-7177961477). Originally posted by [madaraXor](https://github.com/madaraXor) on 2026-11-25T23:43:32Z. --- Thanks, fixed in the force-pushed commit: - `unhex` now returns `Result`: an odd number of digits, or anything but hex digits (signs included), is an error that names the digit. - `Manifest::read` checks every hex field after the version check: - a D3D12 structure (graphics pipeline, RTV, DSV, SRV, UAV, sampler) must have this build's size; - root arguments must be whole dwords; - every file the manifest names (shaders, `memory.bin`, `tex_<id>.bin`) must be one plain name inside the capture folder (`plain_name`). - A damaged manifest is refused with what is wrong, so it is never read as another pipeline or view. - Tests: `hex_round_trips` now expects the errors; `a_damaged_manifest_is_refused` covers odd and non-hex fields, wrong-size structures, partial root dwords and paths out of the folder; `plain_names_only` covers the name check.
DavidM1911 commented 2026-11-26 03:06:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T02:12:33Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7180569258 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2429#issuecomment-7180569258). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T02:12:33Z. --- 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
Foniass commented 2026-12-01 08:02:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:02:46Z.


Triage (#1607) – head 69e0883

This is the base of the stack #2429-#2435, all by the same author; the shared lines across those PRs are the stack, not duplicates. No other open or merged PR adds a single-draw capture format or xcl replay.
The conflict comes from main: b85c3161 (XCL_CAPTURE_FRAME, one frame's command stream) added a private mod capture; and hle/d3d12x/capture.rs after this PR's base, so the new pub mod capture and capture/manifest.rs clash with it. The stack needs to be rebased under another module name, or merged into that module.
No problems found in the manifest code. Only samplers has #[serde(default)], so the claim that older manifests still read covers that one field only.
Recommendation: keep open.

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

<!-- greyfinch-sync:ivall/xcl:comment:7304802822 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2429#issuecomment-7304802822). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:02:46Z. --- **Triage (#1607)** – head 69e0883 This is the base of the stack #2429-#2435, all by the same author; the shared lines across those PRs are the stack, not duplicates. No other open or merged PR adds a single-draw capture format or `xcl replay`. The conflict comes from main: b85c3161 (`XCL_CAPTURE_FRAME`, one frame's command stream) added a private `mod capture;` and `hle/d3d12x/capture.rs` after this PR's base, so the new `pub mod capture` and `capture/manifest.rs` clash with it. The stack needs to be rebased under another module name, or merged into that module. No problems found in the manifest code. Only `samplers` has `#[serde(default)]`, so the claim that older manifests still read covers that one field only. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2429:upstream-pr/2429'
git switch 'upstream-pr/2429'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2429'
git switch 'upstream-pr/2429'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2429'
git switch 'upstream-pr/2429'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2429'
git switch 'main'
git merge --squash 'upstream-pr/2429'
git switch 'main'
git merge --ff-only 'upstream-pr/2429'
git switch 'main'
git merge 'upstream-pr/2429'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2419
No description provided.