xcl run: xcl replay variants (--sub, --profile, --split, --loops) #2425

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

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


What makes a replay an experiment rather than a reproduction: change the translated HLSL, the profile or the split flag without a build, and count loop passes. With the README. Part of #675.

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

What is in it

  • replay.rs: --sub FROM=>TO||... substitutes text in the HLSL of every stage it occurs in (as XCL_DEBUG_PS_SUB does in a run; one that matches nothing is reported); --profile compiles the stage of that kind with another profile; --split 0|1; --loops (count_loops): a counter in every [loop] of the pixel shader.
  • replay/gpu.rs: the counters' buffer and image, and their report: lanes, passes and the most in a lane, the same for each of the first 16 loops, the most per pixel as an image, and eight debug words (xcl_d0..xcl_d7) a substitution may set, as their most, their OR and the lanes they are not 0 in.
  • main.rs: the help. README.md: capturing and replaying one draw.
  • Tests: the counting text; on the GPU, three passes found in every pixel of the test's capture and a substitution changing what the shader writes (with --profile ps_6_7); options.
  • Review fixes: --split takes exactly 0 or 1; --sub with nothing before => is refused; a --profile that matches no stage prints a warning. Tests in options_parse. Each loop's sum has a high word with the carry, as the overall sum has (a 4096×4096 target at 256 passes a pixel is 2^32), the buffer is read by LoopCounts::read. Test: loop_counts_read_with_their_high_words.

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 capture of a volumetric light draw that hangs the GPU: with the loop budget lowered by --sub, --loops gave 782 passes a lane on average on a local branch with the same code (783.6 with this stack) and showed which of the shader's loops ran away (the march after the light list, not the list); debug words then showed that only helper lanes were left in its mask, their state reading as 0 from the second pass on. That is the finding behind #2305. With #2305's two changes in the translator (local branch), the same replay with the full budget: 7.2 passes a lane, 13.8 ms of GPU time.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on edcc0b7: 1439 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, and the README).

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

Not tested

  • --loops on compute shaders (pixel shaders only; the output says so).
  • --split on a wave64 pixel program.
  • 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

<!-- greyfinch-sync:ivall/xcl:issue:5497047059 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2435). Originally posted by [madaraXor](https://github.com/madaraXor) on 2026-11-25T18:38:22Z. --- What makes a replay an experiment rather than a reproduction: change the translated HLSL, the profile or the split flag without a build, and count loop passes. With the README. Part of #675. Stacked on #2434; only the top commit belongs here. **What is in it** - `replay.rs`: `--sub FROM=>TO||...` substitutes text in the HLSL of every stage it occurs in (as `XCL_DEBUG_PS_SUB` does in a run; one that matches nothing is reported); `--profile` compiles the stage of that kind with another profile; `--split 0|1`; `--loops` (`count_loops`): a counter in every `[loop]` of the pixel shader. - `replay/gpu.rs`: the counters' buffer and image, and their report: lanes, passes and the most in a lane, the same for each of the first 16 loops, the most per pixel as an image, and eight debug words (`xcl_d0`..`xcl_d7`) a substitution may set, as their most, their OR and the lanes they are not 0 in. - `main.rs`: the help. `README.md`: capturing and replaying one draw. - Tests: the counting text; on the GPU, three passes found in every pixel of the test's capture and a substitution changing what the shader writes (with `--profile ps_6_7`); options. - Review fixes: `--split` takes exactly 0 or 1; `--sub` with nothing before `=>` is refused; a `--profile` that matches no stage prints a warning. Tests in `options_parse`. Each loop's sum has a high word with the carry, as the overall sum has (a 4096×4096 target at 256 passes a pixel is 2^32), the buffer is read by `LoopCounts::read`. Test: `loop_counts_read_with_their_high_words`. **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 capture of a volumetric light draw that hangs the GPU: with the loop budget lowered by `--sub`, `--loops` gave 782 passes a lane on average on a local branch with the same code (783.6 with this stack) and showed which of the shader's loops ran away (the march after the light list, not the list); debug words then showed that only helper lanes were left in its mask, their state reading as 0 from the second pass on. That is the finding behind #2305. With #2305's two changes in the translator (local branch), the same replay with the full budget: 7.2 passes a lane, 13.8 ms of GPU time. - `cargo test --workspace --no-fail-fast -- --test-threads=4` on `edcc0b7`: 1439 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, and the README). `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: edcc0b7e290a849fc090ee7e1e6b50d19bf4a4b9 gpu: AMD Radeon RX 6700 XT title: 1778c2d9 seconds: 60 exit: 0x0 frames shown: 811 (PresentX 811) presents per 2 s (last 3): 60 29 0 device removals: 0 crashes: 0 peak commit: 19435 MB ``` **Not tested** - `--loops` on compute shaders (pixel shaders only; the output says so). - `--split` on a wave64 pixel program. - 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](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: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 and a_replay_counts_loop_passes_and_substitutes: 2 passed.

<!-- greyfinch-sync:ivall/xcl:comment:7172746150 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2435#issuecomment-7172746150). 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` and `a_replay_counts_loop_passes_and_substitutes`: 2 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:40Z.


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:7172931076 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2435#issuecomment-7172931076). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T19:54:40Z. --- 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:49:16 +00:00 (Migrated from github.com)

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

Review: COMMENTED


P2: --split parses as value == "1", so invalid values such as --split 2, yes, or typos silently become false despite usage promising 0|1. Validate exactly 0/1 and add parser tests. Also reject an empty --sub FROM: --sub "=>x" calls replace("", to) and inserts at every boundary, potentially creating huge/invalid output. --profile with no matching captured stage should likely warn. Current Windows Build/test fails, so investigate/rerun before merge.

<!-- greyfinch-sync:ivall/xcl:review:6064791637 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2435#pullrequestreview-6064791637). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-25T20:49:16Z. **Review:** COMMENTED --- P2: --split parses as value == "1", so invalid values such as --split 2, yes, or typos silently become false despite usage promising 0|1. Validate exactly 0/1 and add parser tests. Also reject an empty --sub FROM: --sub "=>x" calls replace("", to) and inserts at every boundary, potentially creating huge/invalid output. --profile with no matching captured stage should likely warn. Current Windows Build/test fails, so investigate/rerun before merge.
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:06Z.


Thanks, fixed in the force-pushed commit:

  • --split accepts exactly 0 or 1; 2, yes, an empty value or 01 are usage errors.
  • --sub with nothing before => (e.g. =>x, also inside a=>b||=>x) is an error. Replacing with nothing (a=>) is still allowed.
  • --profile that matches no stage of the capture now prints a REPLAY WARNING naming the capture's stages.
  • Tests in options_parse.
<!-- greyfinch-sync:ivall/xcl:comment:7177974630 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2435#issuecomment-7177974630). Originally posted by [madaraXor](https://github.com/madaraXor) on 2026-11-25T23:44:06Z. --- Thanks, fixed in the force-pushed commit: - `--split` accepts exactly `0` or `1`; `2`, `yes`, an empty value or `01` are usage errors. - `--sub` with nothing before `=>` (e.g. `=>x`, also inside `a=>b||=>x`) is an error. Replacing with nothing (`a=>`) is still allowed. - `--profile` that matches no stage of the capture now prints a `REPLAY WARNING` naming the capture's stages. - Tests in `options_parse`.
madaraXor commented 2026-11-26 00:05:45 +00:00 (Migrated from github.com)

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


About the red Build and test on this push: no test failed. The --lib test process ended with 0xc0000005 partway through the run, in tests this PR does not touch, after replay::tests::a_capture_with_a_gs_is_refused had passed.

Here, with XCL_ADAPTER=warp (no GPU, like the CI), cargo test -p xcl --lib -- replay capture --test-threads=4 passes twice in a row: 17 passed, and the two GPU replay tests print SKIPPED … no GPU. The whole suite on a GPU is in the description.

Could someone with rights re-run the failed job? Pushing an unchanged commit again would not start a new run.

Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7178263875 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2435#issuecomment-7178263875). Originally posted by [madaraXor](https://github.com/madaraXor) on 2026-11-25T23:58:47Z. --- About the red `Build and test` on this push: no test failed. The `--lib` test process ended with `0xc0000005` partway through the run, in tests this PR does not touch, after `replay::tests::a_capture_with_a_gs_is_refused` had passed. Here, with `XCL_ADAPTER=warp` (no GPU, like the CI), `cargo test -p xcl --lib -- replay capture --test-threads=4` passes twice in a row: 17 passed, and the two GPU replay tests print `SKIPPED … no GPU`. The whole suite on a GPU is in the description. Could someone with rights re-run the failed job? Pushing an unchanged commit again would not start a new run. *Claude Code (Claude Opus 5.5).*
DavidM1911 commented 2026-11-26 03:06:28 +00:00 (Migrated from github.com)

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


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:7180566926 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2435#issuecomment-7180566926). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T02:12:25Z. --- 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
luckyteagirl commented 2026-11-26 07:47:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T07:47:57Z.

Review: COMMENTED


replay.rs:218–223 gives the overall loop-pass sum a high word on 32-bit wrap, but each per-loop sum is one uint (InterlockedAdd at 16 + 8*k). replay/gpu.rs:629–633 then prints that wrapped word as #k: ... passes. A 4096×4096 fullscreen replay with 256 passes per pixel in one loop has exactly 2^32 passes: the overall line reports 4,294,967,296 while #0 reports 0 passes, most 256. This is within the stated 65,536-per-lane loop budget and can make the per-loop diagnosis misleading on high-coverage captures.

Could per-loop totals use the same split-word carry as the overall sum, with the decoder and buffer offsets updated, and a synthetic decode test for low=0/high=1? This is exact-head source/arithmetic review at 9e602989cec27ede32dca6d5a0794568ecc9c947; I have not run a 4K GPU replay. AI-assisted review with Codex.

<!-- greyfinch-sync:ivall/xcl:review:6070244671 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2435#pullrequestreview-6070244671). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T07:47:57Z. **Review:** COMMENTED --- `replay.rs:218–223` gives the *overall* loop-pass sum a high word on 32-bit wrap, but each per-loop sum is one `uint` (`InterlockedAdd` at `16 + 8*k`). `replay/gpu.rs:629–633` then prints that wrapped word as `#k: ... passes`. A 4096×4096 fullscreen replay with 256 passes per pixel in one loop has exactly `2^32` passes: the overall line reports 4,294,967,296 while `#0` reports **0 passes, most 256**. This is within the stated 65,536-per-lane loop budget and can make the per-loop diagnosis misleading on high-coverage captures. Could per-loop totals use the same split-word carry as the overall sum, with the decoder and buffer offsets updated, and a synthetic decode test for low=0/high=1? This is exact-head source/arithmetic review at `9e602989cec27ede32dca6d5a0794568ecc9c947`; I have not run a 4K GPU replay. AI-assisted review with Codex.
madaraXor commented 2026-11-26 11:05:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by madaraXor on 2026-11-26T10:26:24Z.


Thanks, fixed (force-pushed): each loop's sum now carries into a high word, as the overall sum does.

  • Layout: 3 words per loop (low, high, most) from word 4; the debug words move to word 52; the buffer is 128 words (LOOP_WORDS).
  • The read-back is a pure LoopCounts::read. Test: loop_counts_read_with_their_high_words, with low 0 / high 1 = 2^32 for both the overall and a loop's sum, and loops or debug words that never ran left out.
  • loops_are_counted_before_the_return checks the new offsets and that the last debug counter lies inside the buffer.
  • The GPU test a_replay_counts_loop_passes_and_substitutes passes on the RX 6700 XT.
<!-- greyfinch-sync:ivall/xcl:comment:7189367860 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2435#issuecomment-7189367860). Originally posted by [madaraXor](https://github.com/madaraXor) on 2026-11-26T10:26:24Z. --- Thanks, fixed (force-pushed): each loop's sum now carries into a high word, as the overall sum does. - Layout: 3 words per loop (low, high, most) from word 4; the debug words move to word 52; the buffer is 128 words (`LOOP_WORDS`). - The read-back is a pure `LoopCounts::read`. Test: `loop_counts_read_with_their_high_words`, with low 0 / high 1 = 2^32 for both the overall and a loop's sum, and loops or debug words that never ran left out. - `loops_are_counted_before_the_return` checks the new offsets and that the last debug counter lies inside the buffer. - The GPU test `a_replay_counts_loop_passes_and_substitutes` passes on the RX 6700 XT.
Foniass commented 2026-12-01 08:04:23 +00:00 (Migrated from github.com)

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


Triage (#1607) – head edcc0b7

This is stacked on #2434 (and the #2429–#2433 chain below it); the 90% of lines it shares with #2434 are that PR's commits. Only the top commit (--sub, --profile, --split, --loops in replay.rs / replay/gpu.rs, and the README section) belongs here. No other PR makes this change.
The --loops buffer layout in count_loops and LoopCounts::read agree (passes/carry/most at bytes 16+12k, debug words from byte 208). One note: the counters are zeroed once before the call, so with --repeat N they add up all N passes.
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:7304836701 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2435#issuecomment-7304836701). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:04:23Z. --- **Triage (#1607)** – head edcc0b7 This is stacked on #2434 (and the #2429–#2433 chain below it); the 90% of lines it shares with #2434 are that PR's commits. Only the top commit (`--sub`, `--profile`, `--split`, `--loops` in `replay.rs` / `replay/gpu.rs`, and the README section) belongs here. No other PR makes this change. The `--loops` buffer layout in `count_loops` and `LoopCounts::read` agree (passes/carry/most at bytes 16+12k, debug words from byte 208). One note: the counters are zeroed once before the call, so with `--repeat N` they add up all N passes. 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/2435:upstream-pr/2435'
git switch 'upstream-pr/2435'

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