Hoisted clamps: a draw whose shaders store ends the run; the pieces of a cut list share one budget (#209) #227
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!227
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-227"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@MamaLeVrai on GitHub · 2026-11-26 04:58 UTC · original
MamaLeVrai:hoist-run-rules→main· +432 −7 · 6 files · 2 commits · openWhat
Two correctness rules for the hoisted indirect-argument clamps (
VICTORY_HOIST_CLAMPS, on by default as mode 7):Translated::writes_memory) now counts as a write (HostList::count_write), the same as dispatches and copies already do. The next indirect draw then starts a new run, so its clamp is recorded after that draw and not before it in the list ahead. Before this, a run kept going past such a draw, so a later draw's arguments were clamped before work that might write them.HostList::budget_to_lend/lend_budget) instead of a fresh 2^27 each. This keeps the cap where the single host list had it before the cut. A cut at a wait and a reset of the title list start a budget of their own again, as before hoisting.Files:
draw.rs(count_storesafter each draw that ran,State::budget_of),host.rs(Deferred::lent_budget,budget()returns the lent address,budget_to_lend,lend_budget),list.rs(hoist()lends the first piece's budget to the clamps list and the next piece,cut()clears it).Why
This comes from issue #209 by Marukooh. After the correction comment there, the timing claim is withdrawn (the 982f slowdown matched the card's memory budget, not hoisting), but the two correctness points still apply. I adapted the change from fxceless/victory-fork#1184 to this fork's code:
translated().stores. The equivalent rule here isTranslated::writes_memory: buffer, image, flat or global stores and atomics, and also true when the code is not fully known.Tests
Both tests are new, in
indirect::tests. They drive a title list through its method table, as the game does, on the host device:a_draw_whose_shaders_store_ends_a_run_of_hoisted_clampsuses two test pipelines (pipeline::test_pipeline), withwrites_memoryfalse and true. It checks how many host lists a submission runs before and after a second indirect draw. A non-storing draw in between leaves the run as it is. A storing plain draw ends it (2 to 4 pieces), and so does a storing indirect draw.pieces_cut_for_hoisted_clamps_charge_the_first_pieces_budgetsaturates the first piece's budget with clamps of three records of 65,535 x 16 groups. After the title's indirect draw cuts the list, it records a hoisted clamp in the clamps list and an inline clamp in the piece after, each of one 1x1x1 record, and a worker shader counts the groups that run. It then resets the title list and checks that the new pieces charge a budget of their own.Results (release,
cargo test --release -p victory-gpu --lib hoisted):count_storescalls)left: 2, right: 4(a storing draw ends the run)count_storestaken outleft: 2, right: 4(a storing indirect draw ends its own run)list.rsas on main)left: 2, right: 0(hits: each later piece had a fresh budget)Full crate (
cargo test --release -p victory-gpu --lib): 114 passed, 1 failed, 4 ignored. The failure islist::tests::lists_are_cut_at_waits_that_follow_work. It is known to fail in release runs on main and is fixed separately in #210. I did not rerun it on main here.cargo clippy --release -p victory-gpu --all-targets --no-deps: none of its warnings is in the changed lines.Not measured
AI-assisted (Claude Code); no game data.
🤖 Generated with Claude Code
@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-26 04:59 UTC · original · reviewed
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
@adrianmjim on GitHub · 2026-11-26 19:55 UTC · original
Tested natively on Windows 11, RX 7900 XT (RDNA3, driver 32.0.32029.2010). Head
acedbae, base4f62c2a. Debug builds. Other heavy jobs were running on the machine.Tests:
cargo test -p victory-gpu --lib: 6 runs each of base and PR, alternating. PR: 115 passed in all 6. Base: 113 passed in 4. The other 2 each had onewatch::testsflake (a_write_is_reported_at_every_checked_view,written_pages_are_reported_to_every_asker).left: 2, right: 4andleft: 2, right: 0). They fail on the 7900 XT and on WARP (--features diagnostics,VICTORY_D3D12_WARP=1). With the PR both pass on both.-p victory-gpu --all-targets --no-deps): the same 47 warning lines on base and PR.Overlap with #212 (point 1):
Translated::writes_memory. Both count it after the draw on the plain, indexed, mesh and indirect paths.storing_draw_counts_as_a_write.hoisting()is on, and #212 counts always. WithVICTORY_HOIST_CLAMPS=0, #212's test fails on this PR (writes 0). Only hoisting reads the count, so this should not change behaviour.draw.rs(5 hunks: the four draw paths and theHoistdoc comment) and inhost.rs(3 doc-comment hunks). All conflicts are in point 1. Point 2 does not touch #212's lines.Point 2, one more test:
None of the PR's tests covers the new
state.budget_of = Noneincut(), which gives a new budget after a wait. I wrote a local test for it:The test passes with the PR (7900 XT and WARP), and it also passes on base. With that line removed it fails (
left: 0, right: 1): the run after the wait charges the budget that was spent before the wait. I can share it.How often rule 1 will end a run: it keys on the same flag as #212, so the archive census in my #212 comment applies here unchanged. For example, 1496 of 1996 VS-only containers and 1546 of 12056 pixel containers count as storing, and 0 of 8765 mesh containers do.
On point 2's effect:
The mode 7 comment in indirect.rs says the mesh flicker came from records past the list's budget. So some lists in the game seem to reach the budget on main, where each piece has its own budget. With one shared budget per title list (until a wait), more records may run empty. That is the cap the list had before hoisting, but I did not measure it.
Not tested: no game run, no timing, no release-mode tests. The census counts containers, not the pipelines or draws a scene uses. I did not measure how many extra runs rule 1 ends or how often a shared budget runs out.
@MamaLeVrai on GitHub · 2026-11-26 23:28 UTC · original
Thanks @adrianmjim, the cross-check with #212 and the census are very useful. Yes, please share the
cut()test (a gist or a branch is fine). It covers the one line of point 2 that nothing tests, and I'll add it to this PR with credit. On #212: since both PRs use the same flag and #212 counts always, keeping #212's draw code for point 1 and only this PR's point 2 on top, as in your local branch, is the cleaner merge. If the maintainer takes #212, I'll cut this PR down to point 2.AI-assisted (Claude Code); no game data.
@MamaLeVrai on GitHub · 2026-11-26 23:35 UTC · original
Added in
272d9b3, in the shape you described (credit in the commit).pieces_cut_for_hoisted_clamps_charge_the_first_pieces_budgetnow also cuts the list at a met 64-bit wait (wait_value, slot 0x240, or 0x250 on newer tables) after the spent first piece and the hoisted run. The next run's inline clamp must run its record (hits 1). Withstate.budget_of = Noneincut()commented out it fails withleft: 0, right: 1; with it, it passes. RX 6950 XT, release,cargo test -p victory-gpu --libtwice: 114 passed, 1 failed (lists_are_cut_at_waits_that_follow_work, the release-only failure #210 fixes), 4 ignored.AI-assisted (Claude Code); no game data.
@adrianmjim on GitHub · 2026-11-26 23:37 UTC · original
Thanks @MamaLeVrai, that's the test I had, and failing with that one line out is what matters. Nothing to share separately then.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.