Replay: --skip-clamps and --batch-clamps leave a capture's batched clamps alone #629

Open
github-bot wants to merge 2 commits from github-bot/gh-629 into a-publier AGit
Owner

@⁠adrianmjim on GitHub · 2026-11-27 15:10 UTC · original
adrianmjim:replay/batched-clamps → a-publier · +219 −15 · 2 files · 2 commits · open

Fixes #621. On a capture whose clamp passes are batched (the host's way unless it was recorded with VICTORY_INDIRECT_BATCH=0), victory replay --skip-clamps stopped with clamp capture has no completed scratch transition in its command list, and --batch-clamps put the batches into batches again and drew another picture. With this change both switches edit the plain clamps only and say how many batched passes of the capture they left as they are.

Machine: RX 7900 XT (RDNA 3), driver 32.0.32029.2010, Windows 11 26300, a-publier 4eb6cfd.

Cause

The host names its two clamp pipelines alike (indirect.rs#L356), and the replay took every pass of that name for a plain clamp: constants at parameter 0, where it writes at parameter 3 (edit.rs#L175). A batched pass has another root signature, with its fourth source at parameter 3 (indirect/batch.rs#L33). #621 has the rest.

#621's title calls batching play.ps1's default. It is the host's too: unset and =1 batch as =2 does, and only =0 turns it off (draw.rs#L338-L345).

Change

It is in the replay only, so captures already recorded work too. #621 proposed a name of its own for the batched pipeline; a capture already recorded has the old name, so the replay tells the two apart by their parameters instead.

  • edit::find_clamps tells the two apart by what is bound at the dispatch: a pass with a compute root view at parameter 5 or 6 since its pipeline was bound is a batch. The plain root signature has parameters 0-4 only (indirect.rs#L46); the batched one sets 5 and 6 before every dispatch (indirect/batch.rs#L290-L291). It returns the plain clamps and the number of batches it met.
  • The views the finder tracks (where a clamp writes, and whether 5 or 6 was bound) are reset at every pipeline and compute root signature. Before, the view at parameter 3 of an earlier pass could be taken for a clamp's.
  • batch_clamps goes by the pipelines of the plain clamps found, so a recorded batch passes through as any other dispatch does.
  • Both switches add a note when the capture has batches, for example --skip-clamps: 118 clamp passes of the capture are batches already (not recorded with VICTORY_INDIRECT_BATCH=0) and stay as they are. The existing notes keep their wording and now count plain clamps only.
  • The timing's argument clamps (ours) still counts both kinds, by the code: it goes by the name, and those lines are not touched (play.rs#L2457-L2458).
  • I left docs/replay.md alone because #521 and #528 are open on it. Its two rows could say that batches of the capture stay.

Tested

  • cargo test --locked -p victory-gpu --features diagnostics --lib replay::edit: 8 passed. Three are new or extended: a list with a plain clamp and a batch in both orders, a list of batches only, and a recorded batch followed by a plain clamp under --batch-clamps. They need no card. replay::play::tests::reports has the note's text: 1 passed.
  • Mutations: with the match on parameters 5 and 6 taken out, the three fail; with the two resets taken out, two of them fail (the one with both orders and the --batch-clamps one).
  • cargo clippy --locked -p victory-gpu --features diagnostics --tests -- -D warnings: clean.
  • cargo test --locked -p victory-gpu --features diagnostics --test replay, on this commit with #550's two commits on top (the tree of the replays below; not run on this branch alone): 1 passed. That test records plain clamps, and its "3 clamp passes" check under --skip-clamps still holds.
  • The capture of #621 (a world frame, 118 batched passes, no plain ones), with #550 on top, one run of 3 loops each:
    • --skip-clamps: completes; 0 clamp passes, 0 KB of arguments kept from a first run and the note above; picture 57.5 dB against the presented one.
    • --batch-clamps: completes; 0 clamp passes became 0, of 0 records and its note; 57.0 dB.
    • both together: all four notes; 57.9 dB.
    • --compare --skip-clamps: completes, with the same two notes on the edited side.
    • Runs of the recorded commands of this capture gave 57.2-59.3 dB in #621, more in a run's first loop. Here the unchanged side of the --compare run gave 65.9, 57.0 and 57.4 dB in its three loops, so the 57.0 dB above is within what the recorded commands give. The card was shared with other work during these runs, so I give no times.

Not tested

  • A capture of the title with plain clamps on a card: one recorded with VICTORY_INDIRECT_BATCH=0, or a mixed list. By the code the host can make mixed lists with batching on: an execution with a count buffer, or with more than one record, still gets a plain clamp (draw.rs#L4054). The unit tests cover those shapes; I have no such capture. On the card, plain clamps ran under --skip-clamps in the integration test's own frame only; --batch-clamps over plain clamps ran in the unit test only.
  • --batch-clamps 2, and a --timing run.
  • Any other card, or a second capture.
**@⁠adrianmjim** on GitHub · 2026-11-27 15:10 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/629) `adrianmjim:replay/batched-clamps` → `a-publier` · +219 −15 · 2 files · 2 commits · open Fixes #621. On a capture whose clamp passes are batched (the host's way unless it was recorded with `VICTORY_INDIRECT_BATCH=0`), `victory replay --skip-clamps` stopped with `clamp capture has no completed scratch transition in its command list`, and `--batch-clamps` put the batches into batches again and drew another picture. With this change both switches edit the plain clamps only and say how many batched passes of the capture they left as they are. Machine: RX 7900 XT (RDNA 3), driver 32.0.32029.2010, Windows 11 26300, a-publier 4eb6cfd. ## Cause The host names its two clamp pipelines alike ([indirect.rs#L356](https://github.com/Belobug/VIctory-Belobug-AMD/blob/4eb6cfd/crates/victory-gpu/src/indirect.rs#L356)), and the replay took every pass of that name for a plain clamp: constants at parameter 0, where it writes at parameter 3 ([edit.rs#L175](https://github.com/Belobug/VIctory-Belobug-AMD/blob/4eb6cfd/crates/victory-gpu/src/replay/edit.rs#L175)). A batched pass has another root signature, with its fourth source at parameter 3 ([indirect/batch.rs#L33](https://github.com/Belobug/VIctory-Belobug-AMD/blob/4eb6cfd/crates/victory-gpu/src/indirect/batch.rs#L33)). #621 has the rest. #621's title calls batching `play.ps1`'s default. It is the host's too: unset and `=1` batch as `=2` does, and only `=0` turns it off ([draw.rs#L338-L345](https://github.com/Belobug/VIctory-Belobug-AMD/blob/4eb6cfd/crates/victory-gpu/src/draw.rs#L338-L345)). ## Change It is in the replay only, so captures already recorded work too. #621 proposed a name of its own for the batched pipeline; a capture already recorded has the old name, so the replay tells the two apart by their parameters instead. - `edit::find_clamps` tells the two apart by what is bound at the dispatch: a pass with a compute root view at parameter 5 or 6 since its pipeline was bound is a batch. The plain root signature has parameters 0-4 only ([indirect.rs#L46](https://github.com/Belobug/VIctory-Belobug-AMD/blob/4eb6cfd/crates/victory-gpu/src/indirect.rs#L46)); the batched one sets 5 and 6 before every dispatch ([indirect/batch.rs#L290-L291](https://github.com/Belobug/VIctory-Belobug-AMD/blob/4eb6cfd/crates/victory-gpu/src/indirect/batch.rs#L290-L291)). It returns the plain clamps and the number of batches it met. - The views the finder tracks (where a clamp writes, and whether 5 or 6 was bound) are reset at every pipeline and compute root signature. Before, the view at parameter 3 of an earlier pass could be taken for a clamp's. - `batch_clamps` goes by the pipelines of the plain clamps found, so a recorded batch passes through as any other dispatch does. - Both switches add a note when the capture has batches, for example `--skip-clamps: 118 clamp passes of the capture are batches already (not recorded with VICTORY_INDIRECT_BATCH=0) and stay as they are`. The existing notes keep their wording and now count plain clamps only. - The timing's `argument clamps (ours)` still counts both kinds, by the code: it goes by the name, and those lines are not touched ([play.rs#L2457-L2458](https://github.com/Belobug/VIctory-Belobug-AMD/blob/4eb6cfd/crates/victory-gpu/src/replay/play.rs#L2457-L2458)). - I left `docs/replay.md` alone because #521 and #528 are open on it. Its two rows could say that batches of the capture stay. ## Tested - `cargo test --locked -p victory-gpu --features diagnostics --lib replay::edit`: 8 passed. Three are new or extended: a list with a plain clamp and a batch in both orders, a list of batches only, and a recorded batch followed by a plain clamp under `--batch-clamps`. They need no card. `replay::play::tests::reports` has the note's text: 1 passed. - **Mutations:** with the match on parameters 5 and 6 taken out, the three fail; with the two resets taken out, two of them fail (the one with both orders and the `--batch-clamps` one). - `cargo clippy --locked -p victory-gpu --features diagnostics --tests -- -D warnings`: clean. - `cargo test --locked -p victory-gpu --features diagnostics --test replay`, on this commit with #550's two commits on top (the tree of the replays below; not run on this branch alone): 1 passed. That test records plain clamps, and its "3 clamp passes" check under `--skip-clamps` still holds. - The capture of #621 (a world frame, 118 batched passes, no plain ones), with #550 on top, one run of 3 loops each: - `--skip-clamps`: completes; `0 clamp passes, 0 KB of arguments kept from a first run` and the note above; picture 57.5 dB against the presented one. - `--batch-clamps`: completes; `0 clamp passes became 0, of 0 records` and its note; 57.0 dB. - both together: all four notes; 57.9 dB. - `--compare --skip-clamps`: completes, with the same two notes on the edited side. - Runs of the recorded commands of this capture gave 57.2-59.3 dB in #621, more in a run's first loop. Here the unchanged side of the `--compare` run gave 65.9, 57.0 and 57.4 dB in its three loops, so the 57.0 dB above is within what the recorded commands give. The card was shared with other work during these runs, so I give no times. ## Not tested - A capture of the title with plain clamps on a card: one recorded with `VICTORY_INDIRECT_BATCH=0`, or a mixed list. By the code the host can make mixed lists with batching on: an execution with a count buffer, or with more than one record, still gets a plain clamp ([draw.rs#L4054](https://github.com/Belobug/VIctory-Belobug-AMD/blob/4eb6cfd/crates/victory-gpu/src/draw.rs#L4054)). The unit tests cover those shapes; I have no such capture. On the card, plain clamps ran under `--skip-clamps` in the integration test's own frame only; `--batch-clamps` over plain clamps ran in the unit test only. - `--batch-clamps 2`, and a `--timing` run. - Any other card, or a second capture.
The host names its two clamp pipelines alike, and the replay took every
pass of that name for a plain clamp: constants at parameter 0 and where
it writes at parameter 3. A batched pass (the host's way unless
VICTORY_INDIRECT_BATCH=0) has other parameters, with its fourth source
there. On a capture made with play.ps1's settings --skip-clamps stopped
with "clamp capture has no completed scratch transition in its command
list", and --batch-clamps put the batches into batches again and drew
another picture (#621).

A pass that has a view bound at parameter 5 or 6 since its pipeline was
bound is a batch: the finder counts it and does not give it out as a
clamp, and the views it tracks no longer leak from one pass into the
next. Both switches edit the plain clamps only and say in a note how
many batches of the capture they left as they are.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 15:14:16 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-27 15:14 UTC · original · reviewed

A compute indirect command can leave replay batch tracking unchanged, allowing a later clamp to move ahead of the compute work that produces its arguments even across a global UAV barrier.

1 open issue
What changed in this PR

This PR addresses #621 by distinguishing plain clamp passes from recorded batches, so replay’s --skip-clamps and --batch-clamps switches target only plain clamps.

Changes:

  • Identify recorded batches from their root bindings and reset tracked views between passes.
  • Preserve recorded batches and report how many each switch leaves unchanged.
  • Add regression coverage for mixed and batch-only command lists, plus report text.
File Description
crates/​victory-gpu/​src/​replay/​play.rs Accumulates preserved-batch counts and adds reporting with test coverage.
crates/​victory-gpu/​src/​replay/​edit.rs Distinguishes clamp layouts, limits edits to plain clamps, and tests batch preservation.

Review effort: Balanced

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-27 15:14 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/629#pullrequestreview-6090207349) · **reviewed** <!-- ccr-overview-v2 --> ### 🟡 Changes recommended A compute indirect command can leave replay batch tracking unchanged, allowing a later clamp to move ahead of the compute work that produces its arguments even across a global UAV barrier. <details open> <summary><strong>1 open issue</strong></summary> - <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.png" alt="High severity" width="62" height="18" align="texttop"></picture> [Recorded compute indirect dispatch leaves replay batch open](https://git.gtahub.st/github/Belobug--VIctory-Belobug-AMD/pulls/629) · New </details> <details> <summary><strong>What changed in this PR</strong></summary> This PR addresses #621 by distinguishing plain clamp passes from recorded batches, so replay’s `--skip-clamps` and `--batch-clamps` switches target only plain clamps. **Changes:** - Identify recorded batches from their root bindings and reset tracked views between passes. - Preserve recorded batches and report how many each switch leaves unchanged. - Add regression coverage for mixed and batch-only command lists, plus report text. | File | Description | | ---- | ----------- | | `crates/​victory-gpu/​src/​replay/​play.rs` | Accumulates preserved-batch counts and adds reporting with test coverage. | | `crates/​victory-gpu/​src/​replay/​edit.rs` | Distinguishes clamp layouts, limits edits to plain clamps, and tests batch preservation. | </details> <sub>Review effort: Balanced</sub>
@ -379,0 +404,4 @@
done.left = left;
// The pipelines of the clamps found: not the one of batches.
let psos: HashSet<u32> = found.iter().map(|c| c.pso).collect();
let scratches: HashSet<u32> = found.iter().map(|c| c.scratch).collect();
Author
Owner

@⁠Copilot on GitHub · 2026-11-27 15:14 UTC · original

In a mixed list, a compute Cmd::Indirect using a recorded batch's arguments falls through without setting written or dirty. If it runs between two plain clamps while a replay batch is open, even a subsequent global UAV barrier can leave that batch open, moving the second clamp ahead of the compute work that produces its arguments. Before the fallback dispatch arm at line 608, add a Cmd::Indirect { .. } if compute.contains(&bound) arm that sets both flags to true and pushes the command unchanged; add a regression test for this ordering.

**@⁠Copilot** on GitHub · 2026-11-27 15:14 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/629#discussion_r4721036986) In a mixed list, a compute `Cmd::Indirect` using a recorded batch's arguments falls through without setting `written` or `dirty`. If it runs between two plain clamps while a replay batch is open, even a subsequent global UAV barrier can leave that batch open, moving the second clamp ahead of the compute work that produces its arguments. Before the fallback dispatch arm at line 608, add a `Cmd::Indirect { .. } if compute.contains(&bound)` arm that sets both flags to `true` and pushes the command unchanged; add a regression test for this ordering.
Author
Owner

@⁠ANDREANIADS on GitHub · 2026-11-27 15:50 UTC · original

Independent replay test on an NVIDIA RTX 3070 (driver 621.40). The synthetic capture contains three plain clamp passes and three batched clamp passes with the seven-parameter layout. On base commit 4eb6cfd, --skip-clamps failed with the missing scratch-transition error. With the PR change, I tested skip, batch sizes 1 and 2, and skip combined with batch. Across three replay loops, both pixel output and readback matched the reference. This covers the synthetic replay case. Game performance and ray tracing were outside the scope of this test.

Regression fixture: https://github.com/ANDREANIADS/VIctory-Belobug-AMD/commit/1ddbeebb2813284e112cdf51e89cb2cfa2685ae1

**@⁠ANDREANIADS** on GitHub · 2026-11-27 15:50 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/629#issuecomment-7222540526) Independent replay test on an NVIDIA RTX 3070 (driver 621.40). The synthetic capture contains three plain clamp passes and three batched clamp passes with the seven-parameter layout. On base commit `4eb6cfd`, `--skip-clamps` failed with the missing scratch-transition error. With the PR change, I tested skip, batch sizes 1 and 2, and skip combined with batch. Across three replay loops, both pixel output and readback matched the reference. This covers the synthetic replay case. Game performance and ray tracing were outside the scope of this test. Regression fixture: [https://github.com/ANDREANIADS/VIctory-Belobug-AMD/commit/1ddbeebb2813284e112cdf51e89cb2cfa2685ae1](https://github.com/ANDREANIADS/VIctory-Belobug-AMD/commit/1ddbeebb2813284e112cdf51e89cb2cfa2685ae1)
With --batch-clamps, an execution whose arguments no plain clamp gave (a
recorded batch's) went through as any other command. When it is an
indirect dispatch its shader writes, as a dispatch's does: after it and
a wait of the title's, a clamp must get a batch of its own, or its pass
would run ahead of the work that makes its arguments. It now counts as
written and dirty, as the dispatches and the clamped indirect dispatches
already do.
@ -379,0 +404,4 @@
done.left = left;
// The pipelines of the clamps found: not the one of batches.
let psos: HashSet<u32> = found.iter().map(|c| c.pso).collect();
let scratches: HashSet<u32> = found.iter().map(|c| c.scratch).collect();
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-27 16:14 UTC · original

Right, and it comes with this change: before it, every execution in the list had a clamp's arguments. Done in 3b046bb. An indirect dispatch whose arguments no plain clamp gave now marks the list written and dirty, as the dispatches and the clamped indirect dispatches already do, and goes through unchanged.

The regression case is at the end of clamps_are_batched: a recorded batch, a plain clamp and its draw, an indirect dispatch on the recorded batch's records, a wait of the title's, then a second plain clamp. With the fix the second clamp gets a batch of its own (2 batches); without the new arm it joins the first (1), and the test fails on that count.

cargo test --locked -p victory-gpu --features diagnostics --lib replay::edit: 8 passed. Clippy (-p victory-gpu --features diagnostics --tests -- -D warnings) is clean. No card is needed for these.

**@⁠adrianmjim** on GitHub · 2026-11-27 16:14 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/629#discussion_r4721575727) Right, and it comes with this change: before it, every execution in the list had a clamp's arguments. Done in 3b046bb. An indirect dispatch whose arguments no plain clamp gave now marks the list written and dirty, as the dispatches and the clamped indirect dispatches already do, and goes through unchanged. The regression case is at the end of `clamps_are_batched`: a recorded batch, a plain clamp and its draw, an indirect dispatch on the recorded batch's records, a wait of the title's, then a second plain clamp. With the fix the second clamp gets a batch of its own (2 batches); without the new arm it joins the first (1), and the test fails on that count. `cargo test --locked -p victory-gpu --features diagnostics --lib replay::edit`: 8 passed. Clippy (`-p victory-gpu --features diagnostics --tests -- -D warnings`) is clean. No card is needed for these.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-27 16:14 UTC · original

Thanks. A capture with both layouts is the case I could not test: mine has batched passes only.

3b046bb, pushed after your run, changes --batch-clamps in mixed lists only (review comment above): an indirect dispatch that reads a recorded batch's records now ends an open batch at the next wait. If you run the fixture again, the --batch-clamps variants are the ones it could touch.

On the fixture: I have not run it. I would rather not add an env-gated case to this PR on my own. If the maintainer wants it here I can take your commit as it is, with you as author; or it can go in as a follow-up of yours.

**@⁠adrianmjim** on GitHub · 2026-11-27 16:14 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/629#issuecomment-7223024186) Thanks. A capture with both layouts is the case I could not test: mine has batched passes only. 3b046bb, pushed after your run, changes `--batch-clamps` in mixed lists only (review comment above): an indirect dispatch that reads a recorded batch's records now ends an open batch at the next wait. If you run the fixture again, the `--batch-clamps` variants are the ones it could touch. On the fixture: I have not run it. I would rather not add an env-gated case to this PR on my own. If the maintainer wants it here I can take your commit as it is, with you as author; or it can go in as a follow-up of yours.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/629/head:github-bot/gh-629'
git switch 'github-bot/gh-629'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-629'
git switch 'github-bot/gh-629'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-629'
git switch 'github-bot/gh-629'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-629'
git switch 'a-publier'
git merge --squash 'github-bot/gh-629'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-629'
git switch 'a-publier'
git merge 'github-bot/gh-629'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.