perf: an indirect execution's argument buffer stays readable until the next clamp #445
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!445
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-445"
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?
@KainanP on GitHub · 2026-11-26 18:53 UTC · original
KainanP:perf/indirect-args→main· +351 −63 · 5 files · 1 commits · closed without mergingPort of Marvisak/VIctory#3307 (mine) to this tree's indirect path, which has the same per-call clamp plus windows, dispatches in parts and records clamped ahead.
The problem
Every clamped
ExecuteIndirectrecorded three barrier calls on the list's argument buffer: common → unordered access and → indirect argument around the clamp, thenindirect::done's → common right after the execution. On top of that, per call:host_signaturetook a global mutex and AddRef/Release'd one shared COM object; the title's pipeline, bound again after the clamp's own, was kept again (used_pipeline's string set, two QueryInterface + AddRef + push);budget()asked the driver for the budget word's GPU address.The change
HostList::closemoves it back to common, and so does a bigger buffer replacing it mid-list (the old one is moved before it is kept). Between lists it is common as before, so its states are known whatever order lists run in. A clamp marks the buffer readable only once its barriers are recorded.indirect::doneis gone (the WARP tests keep their owndone_on).&'static), each thread remembering the last one it asked for.HostList::holds_pipeline: the pipeline bound again after the clamp is not kept again.The GPU sees the same commands, minus one barrier per execution.
Measured
List bench of #441 with
VICTORY_LIST_BENCH_INDIRECT=1: each thread records one indirect call at a time into its own list, the list's close timed with the calls. Median of 9 interleaved runs [min–max]. RTX 4060 Laptop GPU, Core i7-14650HX, Windows 11, release profile. Foreign CPU load: about 20–30 % from other applications (an editor, Steam, a browser) throughout; the builds were interleaved run by run so they share it, which is also why the absolute numbers sit above an idle machine's.About −0.55 µs per clamped indirect dispatch (−8 to −12 %). Indirect draws in this bench go through this tree's other routes (records clamped ahead, windows), which this PR doesn't change, so they stay within their spread; what they gain comes from #443 and #444.
Tests
New:
indirect/args_state_tests.rseach_execution_reads_its_own_clamped_records: four indirect dispatches in one list through the list's one argument buffer, including 6,000 records that make the list replace its 64 KiB buffer while it is readable; the list runs twice (the second run starts from what the first left). A counting compute shader checks each execution ran its own records' groups (6, 4, 5, 7), and every transition is replayed from the buffers' states by the debug layer's rule (host::barrier_log, test-only; the D3D12 debug layer isn't installed here), all common at the close. It fails with the clamp's barrier changed back to "from common" (barrier 2 starts from common while the buffer is readable) or without the close's move (not common at the close).the_argument_buffer_is_common_until_a_clamp_and_after_the_close, anddraw::indirect_signature_tests(signatures made once across threads;holds_pipelineuntil the reset).done's removal and still check the same values.cargo test -p victory-gpu --release --lib, one thread, same failures as main (8e32daa) on each adapter: RTX 4060 Laptop, Intel UHD (a78b, through a local adapter-selection hook not in this PR), WARP (--features diagnostics,VICTORY_D3D12_WARP=1). Main failsdescriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed,indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slotsandwarp_card_patch_writes_the_masked_bytes_and_no_othershere on all three;draw::heap_texture_tests::duplicate_texture_views_share_uploads_within_each_passis timing-bound and fails now and then on main too. Clippy (--all-targets, with and withoutdiagnostics): no warning main doesn't have.cargo xtask policyok, ruff clean. The four PRs merged together (octopus, on91c15f2): same suite results on RTX.What this does not show
No in-game numbers: I don't run the title. The bench records only indirect calls, the best case for the per-call saving. GPU time should not change (same commands, one barrier fewer), but I didn't time it. Please A/B it in game.
Overlaps
No textual conflict with the open PRs that touch
third_party/victory(checked withgit merge-tree), except those already conflicting with main. No conflict with #441, #443 or #444. If #409 (combined base) lands first, I'll port this again onto it.The kept GPU address of the budget word follows the per-list VA caches of wbkepler's Marvisak/VIctory#1356 (idea only, no code taken).
AI use: Claude Code (Claude Opus 5.5) ported the change, wrote the tests, ran the measurements and drafted this description.
🤖 Generated with Claude Code
@KainanP on GitHub · 2026-11-26 20:21 UTC · original
Closing: after #409 this is already in the base, and what isn't doesn't measure.
The combined base has the two parts of this PR that mattered, written independently:
HostList::indirect_readable/indirect_state/indirect_common(host.rs). The clamp moves the scratch buffer from wherever the last clamp left it, it stays inINDIRECT_ARGUMENTfor the executions that read it, and it goes back to common at the close or when a bigger buffer replaces it. That was this PR's barrier change, most of the ~0.55 µs per indirect dispatch it saved on the old base.HostList::bind_pipelinekeeps a pipeline and notes its name only the first time per list.VICTORY_INDIRECT_BATCH, on by default), so most executions no longer have a clamp of their own.What was left is the per-thread command-signature cache and the cached GPU address of the budget word. I ported both onto
37d4686and measured them with the list bench of #441. Median of 9 interleaved runs [min–max], ns a call with the list's close, RTX 4060 Laptop, release; foreign load from other applications throughout, builds interleaved so they share it:Every difference is inside the other build's spread, in both directions. It's not worth a PR. The indirect rows still gain from #443 and #444 (for example 1 indexed draw on 5 threads: 4518 → 4057), and those PRs carry that.
AI use: Claude Code (Claude Opus 5.5) compared the code, ran the benchmark and drafted this comment.
github-bot referenced this pull request2026-11-26 20:50:57 +00:00
github-bot referenced this pull request2026-11-26 20:50:58 +00:00
github-bot referenced this pull request2026-11-26 20:51:00 +00:00
c02352396ato836325ffde@KainanP on GitHub · 2026-11-26 20:46 UTC · original
Reopened: main reverted #409 (#452), so this is back to the Neptune-base version measured in the original body, rebased onto
15024d5(RTX: its tests pass, and the suite gives the same results as before). On the combined base this change is already in the tree (my closing comment above), so this PR only applies while main is on the Neptune base.AI use: Claude Code (Claude Opus 5.5).
@KainanP on GitHub · 2026-11-26 23:48 UTC · original
Closing: the Vice-Tay base (#454) already does what this PR was for. Its
indirect::boundleaves the list's argument buffer in the indirect-argument state until the next clamp (HostList::indirect_readable/indirect_state), and moves it back to common only before the list closes or a bigger buffer replaces it (indirect_common): the barrier this PR removed is already gone.HostList::bind_pipelinealso keeps a pipeline bound again only once per recording, which coversholds_pipeline.What was left, a per-thread command signature (no global mutex and no AddRef/Release per call) and the budget words' GPU address kept per list, I ported and measured with the list bench of #441 (
VICTORY_LIST_BENCH_INDIRECT=1, mainb6d86cf8, RTX 4060 Laptop, quiet machine, median of 9 interleaved runs [min–max], ns a call with the list's close):All within main's spread, so not worth a PR. The code is on
perf/indirect-args-vicetay-remainderfor reference, and the Neptune version onperf/indirect-args-neptune.AI use: Claude Code (Claude Opus 5.5).
Pull request closed