xcl run: xcl replay runs one captured call alone #2424

Open
madaraXor wants to merge 6 commits from upstream-pr/2434 into main
madaraXor commented 2026-11-25 18:38:17 +00:00 (Migrated from github.com)

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


xcl replay now runs the captured draw or dispatch alone on a device of its own and reads back what it wrote: the GPU time, and each target, the depth buffer and each UAV texture as raw texels and a PNG. Part of #675.

The GPU part runs in a child process with a timeout: a call that hangs the GPU ends as timed out or device removed after N ms in the child, not in the caller.

Over 400 lines: replay/gpu.rs is one function's worth of device state (windows, textures, views, targets, the call, the read-back). A part of it cannot draw, and so cannot be tested.

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

What is in it

  • replay/gpu.rs: the device (the adapter the runtime would take, through the Agility SDK when there is one); the pipeline from the captured description; memory windows as buffers that hold the captured ranges at their offsets (a reserved buffer with only the touched tiles when a range lies far in); io to u0 as captured; textures in the state the call uses them in; views at the heap indices the T# name, null views where the capture has none; samplers; the call between two timestamp queries; read-backs with a hash and each channel's range.
  • replay.rs: the child process and the timeout, --timeout, --repeat, --debug (the D3D12 debug layer, its messages printed), --no-run.
  • main.rs: the help.
  • Test (skips without a GPU, or when the process cannot make XCL's root signature): a capture built in the test replays (a committed and a reserved window, textures with and without contents, a target the capture lacks, a 3D UAV texture, a slot without a view), and every checked pixel of the target is what the PS makes of its SGPR, of a word in memory and of its loop.
  • Review fixes: --timeout takes a finite number of seconds over 0 (no panic on -1, NaN, inf), --repeat 1 or more; unhex's errors are passed on. Tests in options_parse.

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's captures, top of the stack: a DrawIndexed of 30 with 4 textures replayed to done, its target going from zeros to a uniform fill, 3 image slots without a view (null views); a Draw of 3 that reads no texture replayed to done.
  • A capture of a draw that hangs the GPU in the title (a volumetric light pass, 72 x 6003), on a local branch with the same replay code: the replay ended as device removed after 4852 ms in the child (the caller went on), and with the loop budget lowered by a substitution it finished in about 100 ms. That replay led to #2305. This stack's binary replays the same capture the same way (with the budget lowered: 783.6 loop passes a lane on average).
  • The debug layer on the replay of a capture made by hand, on a local branch with the same code: 0 messages.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on dca8ceb: 1436 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; it fails 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

  • The runtime is not changed (the command's own code).

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

Not tested

  • Compute captures on the GPU (the code is there; no dispatch was captured).
  • Only mip 0 / slice 0 of an output is read back; multisampled outputs are not.
  • The direct DXIL translator in the replay; memory windows through the descriptor heap (XCL_HEAP_WINDOWS): the replay always uses root UAVs.
  • NVIDIA, Intel, RDNA3 / RDNA4, WARP; 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

<!-- greyfinch-sync:ivall/xcl:issue:5497045652 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2434). Originally posted by [madaraXor](https://github.com/madaraXor) on 2026-11-25T18:38:17Z. --- `xcl replay` now runs the captured draw or dispatch alone on a device of its own and reads back what it wrote: the GPU time, and each target, the depth buffer and each UAV texture as raw texels and a PNG. Part of #675. The GPU part runs in a child process with a timeout: a call that hangs the GPU ends as `timed out` or `device removed after N ms` in the child, not in the caller. Over 400 lines: `replay/gpu.rs` is one function's worth of device state (windows, textures, views, targets, the call, the read-back). A part of it cannot draw, and so cannot be tested. Stacked on #2433; only the top commit belongs here. **What is in it** - `replay/gpu.rs`: the device (the adapter the runtime would take, through the Agility SDK when there is one); the pipeline from the captured description; memory windows as buffers that hold the captured ranges at their offsets (a reserved buffer with only the touched tiles when a range lies far in); `io` to u0 as captured; textures in the state the call uses them in; views at the heap indices the T# name, null views where the capture has none; samplers; the call between two timestamp queries; read-backs with a hash and each channel's range. - `replay.rs`: the child process and the timeout, `--timeout`, `--repeat`, `--debug` (the D3D12 debug layer, its messages printed), `--no-run`. - `main.rs`: the help. - Test (skips without a GPU, or when the process cannot make XCL's root signature): a capture built in the test replays (a committed and a reserved window, textures with and without contents, a target the capture lacks, a 3D UAV texture, a slot without a view), and every checked pixel of the target is what the PS makes of its SGPR, of a word in memory and of its loop. - Review fixes: `--timeout` takes a finite number of seconds over 0 (no panic on `-1`, `NaN`, `inf`), `--repeat` 1 or more; `unhex`'s errors are passed on. Tests in `options_parse`. **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's captures, top of the stack: a DrawIndexed of 30 with 4 textures replayed to `done`, its target going from zeros to a uniform fill, 3 image slots without a view (null views); a Draw of 3 that reads no texture replayed to `done`. - A capture of a draw that hangs the GPU in the title (a volumetric light pass, 72 x 6003), on a local branch with the same replay code: the replay ended as `device removed after 4852 ms` in the child (the caller went on), and with the loop budget lowered by a substitution it finished in about 100 ms. That replay led to #2305. This stack's binary replays the same capture the same way (with the budget lowered: 783.6 loop passes a lane on average). - The debug layer on the replay of a capture made by hand, on a local branch with the same code: 0 messages. - `cargo test --workspace --no-fail-fast -- --test-threads=4` on `dca8ceb`: 1436 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; it fails 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** - The runtime is not changed (the command's own code). `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: dca8cebc27c13ccd5f0a2d695291c94b8341abae gpu: AMD Radeon RX 6700 XT title: 1778c2d9 seconds: 60 exit: 0x0 frames shown: 935 (PresentX 936) presents per 2 s (last 3): 60 59 60 device removals: 0 crashes: 0 peak commit: 17000 MB ``` **Not tested** - Compute captures on the GPU (the code is there; no dispatch was captured). - Only mip 0 / slice 0 of an output is read back; multisampled outputs are not. - The direct DXIL translator in the replay; memory windows through the descriptor heap (`XCL_HEAP_WINDOWS`): the replay always uses root UAVs. - NVIDIA, Intel, RDNA3 / RDNA4, WARP; 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](https://claude.com/claude-code)
DavidM1911 commented 2026-11-25 20:08:45 +00:00 (Migrated from github.com)

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


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:7172739349 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2434#issuecomment-7172739349). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T19:46:03Z. --- 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!
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:22Z.


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 a_capture_made_here_replays: passed.

<!-- greyfinch-sync:ivall/xcl:comment:7172745838 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2434#issuecomment-7172745838). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-25T19:46:22Z. --- `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 `a_capture_made_here_replays`: passed.
bmjask commented 2026-11-25 20:53:06 +00:00 (Migrated from github.com)

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

Review: COMMENTED


P2 CLI bug: --timeout passes parsed f64 directly to Duration::from_secs_f64, so -1, NaN, or inf panic rather than yielding usage error. Require finite positive values and add parser tests. --repeat 0 is silently converted to one run by max(1), so reject or document it. This also depends on #2430/#2432 capture state tracking, which cannot faithfully reconstruct partial mip/array transitions until that P1 is fixed. Current Windows CI fails and compute replay remains untested.

<!-- greyfinch-sync:ivall/xcl:review:6064834595 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2434#pullrequestreview-6064834595). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-25T20:53:06Z. **Review:** COMMENTED --- P2 CLI bug: --timeout passes parsed f64 directly to Duration::from_secs_f64, so -1, NaN, or inf panic rather than yielding usage error. Require finite positive values and add parser tests. --repeat 0 is silently converted to one run by max(1), so reject or document it. This also depends on #2430/#2432 capture state tracking, which cannot faithfully reconstruct partial mip/array transitions until that P1 is fixed. Current Windows CI fails and compute replay remains untested.
madaraXor commented 2026-11-26 00:05:44 +00:00 (Migrated from github.com)

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


Thanks, fixed in the force-pushed commit:

  • --timeout takes a finite number of seconds over 0 that a Duration holds. -1, 0, NaN, inf and 1e300 are usage errors, not panics.
  • --repeat 0 is a usage error ("a count of 1 or more").
  • Tests in options_parse.
  • The capture-state dependency is fixed in #2430/#2431: partially transitioned textures are left out of the capture rather than copied from a wrong state.
  • Compute replay is still not tested on the GPU: no dispatch has been captured and replayed yet, and the description says so under Not tested.
<!-- greyfinch-sync:ivall/xcl:comment:7177972677 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2434#issuecomment-7177972677). Originally posted by [madaraXor](https://github.com/madaraXor) on 2026-11-25T23:44:01Z. --- Thanks, fixed in the force-pushed commit: - `--timeout` takes a finite number of seconds over 0 that a `Duration` holds. `-1`, `0`, `NaN`, `inf` and `1e300` are usage errors, not panics. - `--repeat 0` is a usage error ("a count of 1 or more"). - Tests in `options_parse`. - The capture-state dependency is fixed in #2430/#2431: partially transitioned textures are left out of the capture rather than copied from a wrong state. - Compute replay is still not tested on the GPU: no dispatch has been captured and replayed yet, and the description says so under **Not tested**.
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:26Z.


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:7180567310 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2434#issuecomment-7180567310). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T02:12:26Z. --- 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:04:06 +00:00 (Migrated from github.com)

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


Triage (#1607) – head dca8ceb

This is stacked on #2433 (itself on #2432, #2431, #2430 and #2429): the lines it shares with them are those PRs' commits. Only the top commit (xcl replay runs one captured call alone: replay.rs, the new replay/gpu.rs, main.rs) belongs here, and #2435 builds on it. No open or merged PR makes the same change. Main has XCL_CAPTURE_FRAME but no XCL_CAPTURE_DRAW and no xcl replay.
A small point in replay.rs:parent: the caller's timeout is armed only between REPLAY submitted and REPLAY finished. A child that hangs in CreateGraphicsPipelineState or the uploads is not bounded by --timeout; the uploads and read-back have the child's own 60 s limit.
The branch conflicts with main.
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:7304831135 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2434#issuecomment-7304831135). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:04:06Z. --- **Triage (#1607)** – head dca8ceb This is stacked on #2433 (itself on #2432, #2431, #2430 and #2429): the lines it shares with them are those PRs' commits. Only the top commit (`xcl replay runs one captured call alone`: `replay.rs`, the new `replay/gpu.rs`, `main.rs`) belongs here, and #2435 builds on it. No open or merged PR makes the same change. Main has `XCL_CAPTURE_FRAME` but no `XCL_CAPTURE_DRAW` and no `xcl replay`. A small point in `replay.rs:parent`: the caller's timeout is armed only between `REPLAY submitted` and `REPLAY finished`. A child that hangs in `CreateGraphicsPipelineState` or the uploads is not bounded by `--timeout`; the uploads and read-back have the child's own 60 s limit. The branch conflicts with main. 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/2434:upstream-pr/2434'
git switch 'upstream-pr/2434'

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/2434'
git switch 'upstream-pr/2434'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2434'
git switch 'upstream-pr/2434'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2434'
git switch 'main'
git merge --squash 'upstream-pr/2434'
git switch 'main'
git merge --ff-only 'upstream-pr/2434'
git switch 'main'
git merge 'upstream-pr/2434'
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!2424
No description provided.