End clamp runs after draws that store #212

Open
github-bot wants to merge 1 commit from github-bot/gh-212 into main AGit
Owner

@⁠Ingenioeren on GitHub · 2026-11-25 23:43 UTC · original
Ingenioeren:fix/209-store-draws-end-clamp-run → main · +96 −60 · 4 files · 1 commits · open

What

Count a recorded graphics draw as a possible write when any stage of its bound pipeline has the translated writes_memory flag set. This covers direct, indexed, mesh, and indirect draws.

Part of #209. Rule 2 (the per-piece clamp budget) is out of scope. Thanks to Marukooh for reporting the ordering bug.

Why

The next indirect draw uses the host list’s write count to decide whether it can reuse the current clamp list. A draw that stores to memory can change indirect arguments or counts. Advancing the write count forces the next indirect draw to reconsider hoisting so its clamp can see those writes.

How tested

The regression and the full suite ran with the AMD Radeon RX 6750 XT as the default D3D12 adapter. The full suite also ran its existing software-adapter fixtures.

  • cargo test --locked --offline -p victory-gpu pipeline::depth_bounds_test::storing_draw_counts_as_a_write -- --exact --nocapture failed at the write-count assertion with only the draw.rs change temporarily stashed. The draw recorded successfully and writes() returned 0 instead of 1. After restoring draw.rs, the same command passed (1 passed, 0 failed).
  • cargo test --locked --offline -p victory-gpu passed (114 passed, 0 failed, 4 ignored).
  • cargo clippy --locked --offline -p victory-gpu --all-targets exited successfully with warnings.
  • cargo run --locked --offline -p xtask -- policy --staged passed for all four staged files.

Not tested: no game run and no timing with VICTORY_HOIST_CLAMPS=1. The test checks the write count that ends a run, not a recorded hoisted list.

AI assistance: prepared with OpenAI Codex under Claude Code's direction, reviewed by Ingenioeren.

**@⁠Ingenioeren** on GitHub · 2026-11-25 23:43 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/212) `Ingenioeren:fix/209-store-draws-end-clamp-run` → `main` · +96 −60 · 4 files · 1 commits · open ## What Count a recorded graphics draw as a possible write when any stage of its bound pipeline has the translated `writes_memory` flag set. This covers direct, indexed, mesh, and indirect draws. Part of #209. Rule 2 (the per-piece clamp budget) is out of scope. Thanks to Marukooh for reporting the ordering bug. ## Why The next indirect draw uses the host list’s write count to decide whether it can reuse the current clamp list. A draw that stores to memory can change indirect arguments or counts. Advancing the write count forces the next indirect draw to reconsider hoisting so its clamp can see those writes. ## How tested The regression and the full suite ran with the AMD Radeon RX 6750 XT as the default D3D12 adapter. The full suite also ran its existing software-adapter fixtures. - `cargo test --locked --offline -p victory-gpu pipeline::depth_bounds_test::storing_draw_counts_as_a_write -- --exact --nocapture` failed at the write-count assertion with only the `draw.rs` change temporarily stashed. The draw recorded successfully and `writes()` returned 0 instead of 1. After restoring `draw.rs`, the same command passed (1 passed, 0 failed). - `cargo test --locked --offline -p victory-gpu` passed (114 passed, 0 failed, 4 ignored). - `cargo clippy --locked --offline -p victory-gpu --all-targets` exited successfully with warnings. - `cargo run --locked --offline -p xtask -- policy --staged` passed for all four staged files. Not tested: no game run and no timing with `VICTORY_HOIST_CLAMPS=1`. The test checks the write count that ends a run, not a recorded hoisted list. AI assistance: prepared with OpenAI Codex under Claude Code's direction, reviewed by Ingenioeren.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:38:03 +00:00
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-26 19:51 UTC · original

Tested natively on Windows 11, RX 7900 XT (RDNA3, driver 32.0.32029.2010). Head 888d58a, base 4f62c2a.

Tests:

  • cargo test -p victory-gpu --lib: 14 runs each of base and PR, alternating. Other heavy jobs were running on the machine. The only failures were three watch::tests flakes, one per failing run: two on base (written_pages_are_reported_to_every_asker, a_write_is_reported_at_every_checked_view) and one on the PR (a_write_through_another_view_is_reported_at_the_guarded_one). All other runs: 113 passed on base, 114 on the PR, 4 ignored.
  • With only the new test applied to base, storing_draw_counts_as_a_write fails (writes 0, expected 1). It fails on the hardware adapter and on WARP (--features diagnostics, VICTORY_D3D12_WARP=1). With the PR it passes on both.

How often draws will count as writes:
writes_memory is set per shader container: true if any program in it stores or has an s_setpc_b64/s_swappc_b64. I applied the rule from pipeline.rs to every unique container in the shader archive:

  • Vertex, containers with only a VS program: 1496 of 1996 are true. 867 have buffer stores. 629 are true only because of s_swappc_b64, which lower.rs describes as the vertex fetch call.
  • Vertex, 195 more containers (VS_VoxelizeGeneric) also hold an ES program. All 195 are true through it.
  • Pixel: 1546 of 12056 are true.
  • Mesh: 0 of 8765 are true.

Hoisting is on by default (VICTORY_HOIST_CLAMPS defaults to 7). After a draw with a storing pipeline, the next indirect draw cuts a new list. If the title's draws use these shaders in about these proportions, most VS/PS indirect draws would be followed by a cut. Mesh runs are only cut when their pixel shader stores. If the fetch call is known not to store, not counting s_swappc_b64 in vertex programs would stop the 629 fetch-only containers from counting.

Not tested: no game run, so the number of extra cuts and any timing change are not measured. The census counts containers, not the pipelines or draws a scene actually uses. In a diagnostics build with VICTORY_HOIST_FILE set, the "lists cut for hoisted clamps" log line would show the extra cuts with and without this PR.

**@⁠adrianmjim** on GitHub · 2026-11-26 19:51 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/212#issuecomment-7202034400) Tested natively on Windows 11, RX 7900 XT (RDNA3, driver 32.0.32029.2010). Head 888d58a, base 4f62c2a. Tests: - `cargo test -p victory-gpu --lib`: 14 runs each of base and PR, alternating. Other heavy jobs were running on the machine. The only failures were three `watch::tests` flakes, one per failing run: two on base (`written_pages_are_reported_to_every_asker`, `a_write_is_reported_at_every_checked_view`) and one on the PR (`a_write_through_another_view_is_reported_at_the_guarded_one`). All other runs: 113 passed on base, 114 on the PR, 4 ignored. - With only the new test applied to base, `storing_draw_counts_as_a_write` fails (writes 0, expected 1). It fails on the hardware adapter and on WARP (`--features diagnostics`, `VICTORY_D3D12_WARP=1`). With the PR it passes on both. How often draws will count as writes: `writes_memory` is set per shader container: true if any program in it stores or has an `s_setpc_b64`/`s_swappc_b64`. I applied the rule from pipeline.rs to every unique container in the shader archive: - Vertex, containers with only a VS program: 1496 of 1996 are true. 867 have buffer stores. 629 are true only because of `s_swappc_b64`, which lower.rs describes as the vertex fetch call. - Vertex, 195 more containers (`VS_VoxelizeGeneric`) also hold an ES program. All 195 are true through it. - Pixel: 1546 of 12056 are true. - Mesh: 0 of 8765 are true. Hoisting is on by default (`VICTORY_HOIST_CLAMPS` defaults to 7). After a draw with a storing pipeline, the next indirect draw cuts a new list. If the title's draws use these shaders in about these proportions, most VS/PS indirect draws would be followed by a cut. Mesh runs are only cut when their pixel shader stores. If the fetch call is known not to store, not counting `s_swappc_b64` in vertex programs would stop the 629 fetch-only containers from counting. Not tested: no game run, so the number of extra cuts and any timing change are not measured. The census counts containers, not the pipelines or draws a scene actually uses. In a diagnostics build with `VICTORY_HOIST_FILE` set, the "lists cut for hoisted clamps" log line would show the extra cuts with and without this PR.
Author
Owner

@⁠gut0to on GitHub · 2026-11-27 15:09 UTC · original · reviewed

AI-assisted static review; I inspected the draw-write counter and the clamp-hoisting regression. I did not run the test suite.

**@⁠gut0to** on GitHub · 2026-11-27 15:09 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/212#pullrequestreview-6090144299) · **reviewed** AI-assisted static review; I inspected the draw-write counter and the clamp-hoisting regression. I did not run the test suite.
@ -133,1 +133,4 @@
fn count_draw(list: &HostList, writes_memory: bool) {
if writes_memory {
list.count_write();
Author
Owner

@⁠gut0to on GitHub · 2026-11-27 15:09 UTC · original

AI-assisted static review: the new fixture verifies that a storing draw increments the write counter, but the ordering regression is whether the indirect-argument clamp can be hoisted before that draw. Could a synthetic sequence record a draw that writes the indirect arguments followed by the indirect draw, then assert the clamp consumes the post-draw values? This would exercise the ordering decision changed here rather than only its counter input.

**@⁠gut0to** on GitHub · 2026-11-27 15:09 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/212#discussion_r4720985742) AI-assisted static review: the new fixture verifies that a storing draw increments the write counter, but the ordering regression is whether the indirect-argument clamp can be hoisted before that draw. Could a synthetic sequence record a draw that writes the indirect arguments followed by the indirect draw, then assert the clamp consumes the post-draw values? This would exercise the ordering decision changed here rather than only its counter input.
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/212/head:github-bot/gh-212'
git switch 'github-bot/gh-212'

Merge

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