Skip to content

GPU: cheaper indirect draws: no barrier per draw, one budget charge per group, budget in card memory - #220

Open
venglov wants to merge 9 commits into
fxceless:mainfrom
venglov:gpu/indirect-scratch-stays-readable
Open

venglov wants to merge 9 commits into
fxceless:mainfrom
venglov:gpu/indirect-scratch-stays-readable

Conversation

@venglov

@venglov venglov commented Nov 24, 2026 •

Copy link
Copy Markdown

Refs #107, #10.

Problem

#107 measured about 3,200 one-record indirect draws a frame at roughly 12 µs each, about 40 of 63 ms of GPU time on an RTX 5080. VICTORY_INDIRECT_WINDOW=1, which clamps a run of records in one pass, didn't move it. Two reasons, both in our own clamp path:

  1. A barrier after every draw. Every execution, window draws included, was followed by indirect::done, which moves the clamped-arguments buffer back to COMMON; the next clamp then moved it from COMMON. A barrier into or out of COMMON may be a full wait for the driver.
  2. Budget atomics across the bus. The clamp charged the list's budget record by record, with an atomic read and a compare-and-swap loop on one word, all threads of a group racing for it: n rounds and about n²/2 atomics for n records. The word is CPU-visible memory (shared_buffer, custom heap L0), so on a card of its own each atomic crosses PCIe. On an RTX 5070 Ti, windows of 32 took 46–50 ms for 3,200 draws, where draws clamped one at a time took 19 ms (benchmark below).

Change

  • The scratch buffer stays readable (cc11ccc). HostList remembers that a clamp left its scratch buffer in INDIRECT_ARGUMENT. Executions read it with no barrier of their own, the next clamp moves it straight back to UNORDERED_ACCESS, and it returns to COMMON once, when the list closes or a bigger buffer replaces it. indirect::done is gone.
  • A check for windows (f873394, off by default). With VICTORY_INDIRECT_WINDOW_CHECK=1, every draw served from a window first clamps its record again (own buffer, own budget) and a compare on the card checks it against the window's copy. Counts are logged as window check, plus a warning naming the first record that differed.
  • One budget charge per thread group (3db5a0e, 23daba3). Record costs go to group-shared memory, and one thread charges the group's sum with a single compare-and-swap (retried only if another group got there first). It simulates the same saturation record by record, in lane order, and each thread reads whether its record fit. The mesh diagnostics are summed in the group and added once. What a record costs and when it runs empty are unchanged; which records of a group fit is now lane order instead of whoever won the race.
  • The budget lives in the card's memory (d5c15cb). Even one record clamped alone makes two atomics in a row on the budget word (a read, then a compare-and-swap), and in CPU-mapped memory both cross PCIe, on the default path too. The word is now a device-local buffer of the list. The list zeroes it before its first clamp (WriteBufferImmediate, as a copy) instead of the CPU zeroing it at submission. When the list closes, the clamp's notes on mesh records are copied to the mapped words, where the next submission reads them for the frame line as before. VICTORY_INDIRECT_CARD_BUDGET=0 keeps the old place, for in-game A/B runs.
  • Unchanged: the two global UAV waits around the clamp, window rules, and budget limits.

Barrier calls per indirect execution:

before after
clamped alone (default) 3 2
served from a window 1 0

Why it is safe

  • Only our clamp writes the scratch buffer. Every clamp first moves it out of INDIRECT_ARGUMENT, which orders its writes after all earlier executions' argument reads.
  • Title buffer copies run on the CPU at submission (copy_buffer_region → defer_copy), so nothing recorded between two window draws writes the scratch buffer.
  • The budget is still saturated with a compare-and-swap. The group's simulation applies the old per-record rule in a fixed order.

Measured

In-game, RTX 3070 8 GB (by @VibeClauding, d5c15cb, card-bound cell scene, VICTORY_RELAY=2, frame lines from minutes 3–5, one run each; report):

build VICTORY_INDIRECT_WINDOW fps ms/frame on the GPU
base off 4.9–5.0 201–206 108–113
base 1 4.7–4.8 207–212 115–117
base + #220 1 6.9–7.7 130–145 28–46

The picture was intact in the dumped frames, with no device removal. Afterwards the frame is bound by preparing and copy-back, not the card.

In-game, RTX 5080 (by @Peppacodes, 32c6229/7e239bf, first room, VICTORY_RELAY=2 VICTORY_LATE_WAIT=3, medians of 20 frame lines; report): with windows on, 157–177 ms a frame against 202 ms for main with windows off and 218 ms for main with windows on. The card wait fell from 84 to 22–30 ms. With windows off at 7e239bf: 211 ms against 202 ms, within this machine's run-to-run spread (up to 9 %), with the card wait down from 84 to 64 ms. No errors or device loss in six runs.

Other in-game runs:

  • RTX 5070 (by @ryotdev, 32c6229, windows off, one run each): 232.2 ms against 209.1 ms on main, so slower. One cause found since: every clamp group touched the budget, including groups past a count buffer's count. Fixed in 7e239bf; a rerun has been asked for.
  • RTX 5070 (by @AKA0GHOST, a4a745e, CPU-bound at about 550 ms a frame): same frame time, about 23 % more draws a frame, no hangs.

Benchmark indirect::bench (ignored by default, no title files needed): 3,200 one-record indirect draws of our own, records 32 bytes apart, one at a time and in windows of 32. It runs them as main records them and as this branch does, plus windows with the new barriers but main's clamp, and both modes with the budget in card memory. GPU time comes from timestamps around the list.

cargo test --locked -p victory-gpu --release --lib indirect::bench -- --ignored --nocapture
3,200 draws, GPU ms RTX 3070 (d5c15cb, @VibeClauding) RTX 5070 Ti (a4a745e, @Flyander) software adapter (run)
one at a time, main 22.49 18.98 132–139
one at a time, this 23.19 19.04 136–139
one at a time, budget in card memory 20.04 – 123–141
windows of 32, main 33.56 49.82 63–76
windows, new barriers, main's clamp 30.65 46.43 40–41
windows of 32, this 0.98 – 38–42
windows of 32, budget in card memory 0.88 – 39–40

On an RTX 5080 (by @Peppacodes): one at a time 14.1 ms on main, 14.0–14.2 with this, 10.7–10.9 with the budget in card memory; windows of 32 32.6 ms on main, 0.63 ms with this, 0.52 ms with the budget in card memory.

Synthetic single-record mesh draws on an RTX 5070 (by @ryotdev, 32c6229): 19.68 ms → 17.61 ms (−10.5 %) with the new clamp; the barriers alone were neutral.

What this shows:

  • On cards, windows were slower than clamping one at a time because of the budget atomics. With one charge per group they cost 0.3 µs a draw instead of 10.5 µs (RTX 3070).
  • The barrier change alone is a small gain for windows on cards, and makes recording them two thirds cheaper on the CPU.
  • The budget in card memory takes about 11 % off draws clamped one at a time, which is the default path.
  • The large in-game gain needs VICTORY_INDIRECT_WINDOW=1. VICTORY_INDIRECT_WINDOW_CHECK=1 (f873394) checks every window draw against a fresh clamp of its record on the card and logs any that differ, to settle whether windows can be trusted in a scene. Turning it on by default should wait for GPU: keep indirect argument windows within the named buffers #204 (window bounds) and a check that window draws match fresh clamps; the 16-window breakage on RTX 5080 on 4e17478: 8.5 fps in the lit cutscene; 40 of 63 ms GPU time is 3,227 indirect draws a frame (~12 µs each) #107 likely came from several windows sharing one scratch region, which a single window cannot do (comment).

Tests

  • New WARP tests:
    • window executions with no barrier between them;
    • a group charging its records in lane order.
  • A host-list test runs the windows through HostList and Host::execute, recorded twice across a reset.
  • Another host-list test checks that the budget starts empty at each submission: a recording that spends it all, then one whose small record still runs.
  • The tracked scratch state is checked across clamps, growth and reset.
  • Under the D3D12 debug layer (VICTORY_D3D12_DEBUG=1, diagnostics), the host-list tests check that nothing was reported after closing each list. A control that records a wrong barrier into a HostList is caught by the same check (run).
  • Full CI on windows-latest passes for f873394: clippy in both configurations, and cargo test --workspace (victory-gpu 115 passed, 2 ignored; merged onto main c96b4f2, 117 passed with only that main's own depth_bounds test failing on the software adapter, as it does without this PR). Under the debug layer all 12 indirect:: tests pass with nothing reported (run).

AI-assisted (Claude Code). Tests and benchmark ran on GitHub's Windows runners; hardware and in-game numbers are from the testers credited above.

🤖 Generated with Claude Code

Every indirect execution was followed by a move of the list's clamped
arguments back to the common state, and the next clamp moved them from
common to unordered access. Drivers may treat a barrier into or out of
the common state as a full wait, so even the window path
(VICTORY_INDIRECT_WINDOW=1), whose draws skip the clamp, still recorded
one barrier between every two draws.

The list now remembers that its scratch buffer was left readable as
indirect arguments: executions read it with no barrier of their own, the
next clamp moves it straight back to unordered access, and it returns to
common once, when the list closes or a bigger buffer replaces it. The
waits for earlier shader writes around the clamp are unchanged.

Tests: two windows of executions with no barrier between them, on WARP
and through a host list; the tracked state across clamps, growth and
reset; the existing clamp tests follow the new states. With
VICTORY_D3D12_DEBUG=1 in a diagnostics build, the host-list tests also
check that the debug layer reports nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T22:45:02.245397Z cc11ccc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc11cccc57

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/victory-gpu/src/indirect.rs Outdated
// SAFETY: the list has run; a mapped buffer.
let hits = unsafe { (hits_ptr as *const u32).read_volatile() };
assert_eq!(hits, expected, "every record of both windows runs once");
assert_eq!(host.log_messages(), None, "the debug layer found an error");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve debug-layer errors before checking the queue

With diagnostics and VICTORY_D3D12_DEBUG=1, this assertion runs after host.execute, but Host::submit already calls self.log_messages() at host.rs:4144, discarding its result and clearing the info queue. Nonfatal resource-state errors from recording or submission are therefore consumed before this assertion can inspect them, allowing the test to pass despite the barrier errors it is intended to reject. The new assertion in host_list_reuses_and_grows_scratch_across_submissions has the same problem. Preserve and assert the submission's diagnostic result, or inspect the messages before that drain.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right: Host::submit drains the queue into the log, so those asserts couldn't see errors raised while recording. Fixed in 23daba3: both host-list tests now read the messages after list.close() and before host.execute. Barrier before-state errors are reported at record time, so they're caught there. A control test on the CI-only debug-layer branch records a wrong barrier into a HostList the same way and checks that the read sees it.

A frame's worth (3,200) of one-record indirect draws of our own, clamped
one at a time and in windows of 32, recorded with the old barriers (back
to the common state after every execution) and the new ones, timed with
GPU timestamps around the list. Ignored by default; any machine with a
GPU runs it in seconds, no title files needed:

cargo test -p victory-gpu --release --lib indirect::bench -- --ignored --nocapture

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Flyander Flyander left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the ignored release benchmark on a Windows 11 D3D12 RTX 5070 Ti. Median of 9 frames, 3,200 one-record draws per frame:

Old barriers New barriers Change
Clamped one at a time, GPU 18.98 ms 19.04 ms +0.3%
Clamped one at a time, submit-to-done 19.20 ms 19.24 ms +0.2%
Windows of 32, GPU 49.82 ms 46.43 ms -6.8%
Windows of 32, CPU recording 1.68 ms 0.56 ms -66.7%
Windows of 32, submit-to-done 50.16 ms 46.54 ms -7.2%

The run confirms the no-window path is neutral and the batched-window path improves on this NVIDIA card. These are synthetic draws; I have not measured the title scene. The command was cargo test --locked -p victory-gpu --release --lib --target-dir E:\Dev\victory-fork-target indirect::bench -- --ignored --nocapture.

venglov and others added 2 commits November 24, 2026 23:59
The clamp charged the list's budget record by record: an atomic read and
a compare-and-swap loop per record on one word, every thread of a window
racing for it, so a group of n records took n rounds and about n*n/2
atomics. The word is CPU-visible memory (zeroed on the CPU at
submission), so on a card of its own each of them crosses the bus. On an
RTX 5070 Ti the benchmark's windows of 32 took 46-50 ms for 3,200 draws
where draws clamped one at a time took 19 ms (fxceless#220).

Now the records' costs go to group-shared memory, one thread charges
their sum with one compare-and-swap (retried only if another group got
there first), simulating the same saturation record by record in lane
order, and every thread reads whether its record fitted. The mesh
diagnostics (largest group count asked, groups asked in all) are summed
in the group and added once. What a record costs and when it runs empty
are unchanged; which records of a group fit is now their lane order
instead of the order the GPU served the race.

Test: a group with 300 left of the budget keeps its first draw (100),
empties the second (250, which takes the rest) and the ones after it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s clamp

- The clamp's charge per group walks the group's own records (one, for a
  record clamped alone) instead of all 64 slots.
- The host-list tests read the debug layer's messages after closing the
  list and before the submission, which moves them to the log (review).
- The benchmark lives in its own file and records five cases: what main
  records, one record at a time and in windows of 32; what this tree
  records, both ways; and windows with the new barriers but main's clamp,
  to tell the two changes apart. main's clamp is kept in the benchmark to
  measure against.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@venglov

venglov commented Nov 24, 2026

Copy link
Copy Markdown
Author

Thanks for the RTX 5070 Ti run. It showed something the software adapter couldn't: on the card, windows of 32 took 46–50 ms where draws clamped one at a time took 19 ms, even though windows record far fewer clamp passes and barriers.

The only work that grows with a window is in the clamp. Each record charged the list's budget with an atomic read and a compare-and-swap loop on one word, all 64 threads racing for it. That's a round per record and about n²/2 atomics per window. The word is a shared_buffer (custom heap, MEMORY_POOL_L0), so on a card of its own every one of those atomics crosses PCIe; on WARP they're CPU atomics, which is why it didn't show here. That would also explain why windows didn't pay off in-game in #107.

New commits:

  • 3db5a0e: the clamp charges the budget once per thread group. Record costs go to group-shared memory, one thread does a single compare-and-swap for the group, simulating the same saturation record by record in lane order, and each thread reads whether its record fit. The rules are unchanged. Which records of a group fit is now lane order instead of whoever won the race. New WARP test: warp_a_group_charges_its_records_in_lane_order.
  • 23daba3:
    • that charge walks only the group's own records;
    • the debug-layer asserts now read before the submission (the Codex finding);
    • the benchmark moved to its own file and keeps main's clamp to compare against, so one run separates the two changes.

On the software adapter (run, three repetitions):

GPU ms
one at a time, main 98.7–104.4
one at a time, this 101.8–104.7
windows of 32, main 57.9–59.6
windows, new barriers, main's clamp 20.3–21.3
windows of 32, this 20.0–20.6

As expected, the per-group charge doesn't matter there. The card is where it should. If you can run the updated benchmark on the same 5070 Ti, its fourth and fifth lines will show how much of the windows' cost was the budget atomics:

cargo test --locked -p victory-gpu --release --lib indirect::bench -- --ignored --nocapture

Full CI on 23daba3 passes (victory-gpu 113 passed). Under the D3D12 debug layer, all indirect:: tests pass with nothing reported, and a control that records a wrong barrier into a HostList is caught by the same check (run).

@venglov venglov changed the title GPU: the indirect scratch buffer stays readable between executions (no barrier per indirect draw) GPU: cheaper indirect draws: the scratch buffer stays readable, and the clamp charges the budget once per group Nov 24, 2026
venglov and others added 2 commits November 25, 2026 00:12
Two more cases, one record at a time and windows of 32, with this
tree's clamp and the budget words in a device-local buffer instead of
CPU-mapped memory: whether the clamp's atomics crossing the bus are
what a draw clamped alone still costs on a card.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The clamp charges the list's budget with atomics: at least an atomic
read and a compare-and-swap in a row for every clamp, so for every
indirect execution clamped on its own. The budget was in memory the CPU
maps (zeroed on the CPU at submission), so on a card of its own each of
those crosses the bus.

Now the words live in a device-local buffer of the list. The list zeroes
it before its first clamp (WriteBufferImmediate, as a copy), the clamps
charge it as before, and when the list closes the clamp's notes on mesh
records are copied to the mapped words, where the next submission reads
them for the frame line as before. VICTORY_INDIRECT_CARD_BUDGET=0 keeps
the old place, for an A/B; lists without ID3D12GraphicsCommandList2 keep
it too.

Test: a recording whose clamps spend the whole budget, then one with a
small record after the reset, which runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AKA0GHOST

Copy link
Copy Markdown

Tested in game on Windows 11 D3D12, RTX 5070 (driver 621.14): fork main + #175 + this PR at a4a745e (before your latest push), diag build, VICTORY_RELAY=2, 10-minute run. Thanks for this.

World frames only (samples over 1,000 draws), one run each:

median ms/frame GPU draws/frame
main + #175 552 74 ms 4,796
main + #175 + this PR 559 112 ms 5,899

The frame time stayed the same while each frame carried about 23% more draws, so more indirect work gets through per frame. Here the CPU side (~420 ms preparing) still sets the pace, so the barrier savings don't show up as fps yet. No hangs or device removals in the full run, and the indirect tests pass here (one failure on a first run that I couldn't reproduce or identify; all 9 passed on rerun).

AI-assisted (Claude Code); no game files attached.

@ryotdev

ryotdev commented Nov 24, 2026

Copy link
Copy Markdown

I tested 32c62299 on a desktop RTX 5070 with Windows D3D12 driver 610.88. I added a mesh variant of your triangle benchmark to separate the barrier change from the new clamp on the single-record path. Test source based on this PR

Each arm issued 3,827 single-record indirect mesh dispatches, one group per dispatch, with a 12-byte signature and 32 bytes between source records. The budget remained in CPU-visible memory and lookahead was off. The warm-up for each arm checked 3,827 mesh invocations, 3,827 emitted primitives, nonzero pixel invocations and the expected budget charge. Nine timed rounds rotated the arm order. Times below are GPU timestamps around the complete synthetic command list.

Single-record mesh path GPU median, ms GPU p25–p75, ms
Original clamp and barriers 19.680 19.656–19.763
Original clamp, new barriers 19.647 19.514–19.720
New clamp and barriers 17.613 17.391–17.628

The full change saved 2.067 ms per list (10.5%) on this workload and was faster in all nine paired rounds. The barrier-only median moved by 0.033 ms. This gives the clamp change a measurable result on the RTX 5070 with one requested record per call. Game frame time still needs a separate comparison.

For a local correctness check, the original and new HLSL produced the same indirect arguments and budget counters for 14 single-record WARP cases, including oversized mesh counts, zero work and exact/insufficient remaining budget. The benchmark’s original clamp compiled byte-for-byte identically to the original production shader.

To reproduce, check out the linked commit on a Windows machine with native mesh-shader and mesh pipeline-statistics support. Set VICTORY_PC_DXC to your PC dxc.exe and run the following command.

cargo test --locked --release -p victory-gpu --lib indirect::bench::bench_indirect_mesh_singletons -- --exact --ignored --nocapture --test-threads=1

AI-assisted. All benchmark shaders and inputs are synthetic.

@venglov venglov changed the title GPU: cheaper indirect draws: the scratch buffer stays readable, and the clamp charges the budget once per group GPU: cheaper indirect draws: no barrier per draw, one budget charge per group, budget in card memory Nov 24, 2026
@venglov

venglov commented Nov 24, 2026

Copy link
Copy Markdown
Author

One more change, for the default path: d5c15cb moves the budget word into the card's memory.

Even a record clamped alone makes two atomics in a row on that word (read, then compare-and-swap). In mapped memory, both cross PCIe on every clamped draw, which may be a good part of the ~6 µs a draw in the one-at-a-time line on the 5070 Ti. The list now zeroes a device-local copy before its first clamp (WriteBufferImmediate) and copies the mesh notes back to the mapped words when it closes, so the frame-line stats are unchanged. VICTORY_INDIRECT_CARD_BUDGET=0 restores the old place for an in-game A/B.

The benchmark gained two lines with the budget in card memory: "one at a time, card" and "windows of 32, card". If someone reruns it on a card, the lines comparing "this" with "card" show what that saves. On the software adapter it's neutral, as it should be there (run).

CI on d5c15cb passes (victory-gpu 114 passed, including a test that the budget starts empty at each submission), and under the debug layer all 12 indirect:: tests pass with nothing reported (run).

@ryotdev

ryotdev commented Nov 24, 2026

Copy link
Copy Markdown

Follow-up to the synthetic mesh benchmark. I also compared two plain release builds on the same RTX 5070, one with the four-file delta from 32c62299. Both restored the same checkpoint and native cache seed, with identical launch input, lookahead off and 90 seconds after the first world report.

The last 30 seconds had median reported frame times of 209.1 ms on the control and 232.2 ms with #220 (4.78 and 4.31 FPS). For a closer workload comparison, I paired reports from 30–90 seconds after world entry with at least 3,500 draws/frame, zero pipelines building, timestamps within 10 seconds, and draw counts within 3%. Only three pairs qualified. The candidate was 9.3, 13.0 and 18.3 ms slower in those pairs. Median draws/frame were 4,967 and 5,019, with 347 and 345 dropped.

One run per build. The runs reached the world threshold at different times. We saw the synthetic single-record GPU improvement, but this checkpoint did not show a frame-rate improvement. AI-assisted.

… all

An execution may ask for thousands of records with a count buffer that
counts a few: the clamp runs a group per 64 asked. Before the charge per
group, the threads past the count returned at once; with it, the first
thread of every group read the budget word, and for mesh records added
the group's notes to it, records or none. In memory the CPU maps that is
up to three atomics across the bus per empty group (on an RTX 5070 an
in-game A/B of 32c6229 ran slower, fxceless#220). Now a group without records
makes no atomic; the group's barriers stay in uniform control flow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@venglov

venglov commented Nov 24, 2026

Copy link
Copy Markdown
Author

Thank you, both runs are useful, and the in-game one matters more.

Synthetic. The single-record result (19.68 → 17.61 ms, barriers alone neutral) fits the budget being the cost: even one record makes an atomic read and a compare-and-swap on a word in CPU-mapped memory.

In-game, slower. One run per build is thin, but all three matched pairs going the same way is enough to take seriously. The single-record benchmark can't show one regression I found in 32c6229:

  • The clamp runs a group per 64 records asked. An execution with a count buffer may ask for thousands and count a few.
  • In main's shader, threads past the count returned before touching the budget.
  • In mine, thread 0 of every group, empty ones included, read the budget word and, for mesh records, added the group's notes: up to three PCIe atomics per empty group.

7e239bf makes a group without records make no atomic.

Your build also didn't have d5c15cb, which moves the budget into the card's memory (VICTORY_INDIRECT_CARD_BUDGET=0 turns it off).

If you have time for one more pair on the same checkpoint, 7e239bf against main, ideally two runs each, would show whether it's a gain, neutral or still a loss. A third run of 7e239bf with VICTORY_INDIRECT_CARD_BUDGET=0 would separate the card-memory part. If frames are still slower, I'll cut the PR down to whatever measures as a gain in-game.

@VibeClauding

Copy link
Copy Markdown

RTX 3070 8 GB (Ampere, driver 610.88), Ryzen 7 5700X3D, Windows 11 26200. Tested d5c15cb (before 7e239bf): the benchmark, and one in-game A/B where the card is the limit. With windows on, both show a large gain on this card.

Benchmark (cargo test --release -p victory-gpu --lib indirect::bench -- --ignored --nocapture --test-threads=1):

indirect draw barriers on NVIDIA GeForce RTX 3070: 3200 one-record draws a frame, medians of 9 frames
  one at a time, main    GPU   22.49 ms ( 7.03 us a draw), recording   5.92 ms, submit to done   22.59 ms
  one at a time, this    GPU   23.19 ms ( 7.25 us a draw), recording   5.38 ms, submit to done   23.30 ms
  windows of 32, main    GPU   33.56 ms (10.49 us a draw), recording   1.70 ms, submit to done   33.67 ms
  windows, new barriers  GPU   30.65 ms ( 9.58 us a draw), recording   0.67 ms, submit to done   30.75 ms
  windows of 32, this    GPU    0.98 ms ( 0.31 us a draw), recording   0.59 ms, submit to done    1.09 ms
  one at a time, card    GPU   20.04 ms ( 6.26 us a draw), recording   5.38 ms, submit to done   20.14 ms
  windows of 32, card    GPU    0.88 ms ( 0.28 us a draw), recording   0.56 ms, submit to done    0.98 ms

On this card, the barriers matter little (-8.7%). The per-group charge is what turns windows from slower than one at a time (10.5 µs) into 0.31 µs a draw. The card budget takes another 10-14% off.

In game. The base is fork main 4e17478 plus my branch (VibeClauding/victory-fork@nvidia-8gb-fixes: #203 #186 #188 and a few shader fixes, nothing in indirect.rs).

  • Settings: Series S profile, warm cache, held view in the cell after the prologue hand-over, VICTORY_RELAY=2 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024, DRED off.
  • The table shows the frame lines from minutes 3 to 5, one run each.
  • On this setup the card is the limit: the submitting thread waited 114 ms a frame for it before.
build VICTORY_INDIRECT_WINDOW fps ms/frame on the GPU indirect commands bounded/frame
base off 4.9-5.0 201-206 108-113 4,694
base 1 4.7-4.8 207-212 115-117 2,388
base + #220 d5c15cb 1 6.9-7.7 130-145 28-46 2,224

I'll run 7e239bf against main next, two runs each, plus one with VICTORY_INDIRECT_CARD_BUDGET=0, and post the numbers here.

AI-assisted (Claude Code); runs on my machine with my own copy, counts and timings only.

@venglov

venglov commented Nov 25, 2026

Copy link
Copy Markdown
Author

Thank you, this is the in-game result the PR needed. 201–206 → 130–145 ms a frame, with the card's share going from about 110 ms to 28–46 ms, also says where the windows' cost was: the per-group charge, not the barriers. I've put your tables in the description.

Two notes for your next runs:

  • 7e239bf is the commit to compare against main. It stops clamp groups past a count buffer's count from touching the budget, which @ryotdev's slower windows-off run on an RTX 5070 may have been hitting. A run of it with VICTORY_INDIRECT_WINDOW unset would show whether the default path is now neutral or better on your card. VICTORY_INDIRECT_CARD_BUDGET=0 separates the card-memory part, as you planned.
  • On the caution about records changing under a window: the 16-window breakage on RTX 5080 on 4e17478: 8.5 fps in the lit cutscene; 40 of 63 ms GPU time is 3,227 indirect draws a frame (~12 µs each) #107 looks explained by every window sharing one scratch region at offset 0, which a single window can't do (comment). A fresh-clamp comparison would still be the check to run before windows go on by default.

@Peppacodes

Copy link
Copy Markdown

The benchmark and an in-game A/B on an RTX 5080 (driver 621.24, Ryzen 7 5700X3D, Windows 11 26200), at 32c6229 and again at 7e239bf.

Benchmark

cargo test --locked -p victory-gpu --release --lib indirect::bench -- --ignored --nocapture. Four runs, each the median of 9 frames: three at 32c6229, one at 7e239bf. They agree within 1 %.

3,200 one-record draws GPU ms µs a draw
one at a time, main 14.06–14.11 4.4
one at a time, this 13.96–14.20 4.4
windows of 32, main 32.62–32.66 10.2
windows, new barriers, main's clamp 29.51–29.56 9.2
windows of 32, this 0.63 0.20
one at a time, budget in the card's memory 10.71–10.88 3.4
windows of 32, budget in the card's memory 0.52–0.53 0.16

As on the 3070, the budget atomics were almost all of the windows' cost on this card. The barriers take 9.5 % off, and the per-group charge takes off another 97.9 %.

In game

Setup:

  • Diagnostics builds of 4e17478, plus GPU: 512 MiB pipeline-worker stacks #28's watchdog hook and 64 MB pipeline-worker stacks. "This" adds the PR's commits up to the one named.
  • Settings: VICTORY_RELAY=2 VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024 VICTORY_DISPLAY_MODE=1920x1080, Series X profile.
  • Each run started from a fresh copy of the same save, standing at the window of the first gameplay room with no input.
  • Numbers are the median of 20 frame lines (about 100 s), about 4 minutes into the world.
run build VICTORY_INDIRECT_WINDOW ms/frame (range) on the GPU preparing copying back (relay thread)
48 main off 202 (194–214) 84 98 130
53 this, 7e239bf off 211 (186–252) 64 126 136
51 main 1 218 (211–243) 97 106 132
50 this, 32c6229 1 157 (142–177) 22 121 87
52 this, 32c6229 1 171 (162–187) 25 129 95
54 this, 7e239bf 1 177 (169–196) 30 133 101
  • Windows on: with main's clamp they make the frame 8 % slower, as in RTX 5080 on 4e17478: 8.5 fps in the lit cutscene; 40 of 63 ms GPU time is 3,227 indirect draws a frame (~12 µs each) #107. With this PR they make it 12–22 % faster than main with windows off (5.6–6.4 fps against 4.9). The submitting thread's wait for the card drops from 84 to 22–30 ms.
  • Windows off at 7e239bf: the card wait drops from 84 to 64 ms. The frame was 4 % slower, but repeat runs of one build vary by up to 9 % here, so that's noise, not a regression either way.
  • With the card mostly ahead, this CPU's preparing (120–135 ms) is now the limit.
  • No errors, no unmet waits, no device loss in any of the six runs.

Run 50 drew the first room's walls on both sides, which no run without this PR did here. Runs 52 and 54 didn't. The walls vary from run to run, so I'm not claiming anything for #168.

AI-assisted (Claude Code). Benchmark and runs on my own machine; nothing from the title attached.

…lamps

With fxceless#220 a draw served from a window costs a fraction of one clamped
alone (0.2-0.3 us against 4-7 us on RTX 3070 and 5080, and 12-45 % more
frames in game with VICTORY_INDIRECT_WINDOW=1), so windows are worth
turning on by default. Before that, whether anything writes a record
between its window's clamp and its draw needs answering in game (fxceless#107:
keeping 16 windows per list broke drawing).

With VICTORY_INDIRECT_WINDOW_CHECK=1 every window draw first clamps its
record again, by the window's rules, into a buffer of its own with a
budget of its own, and a one-thread compare checks it against the
window's copy on the card. At the list's next submission the counts go
to the log ("window check", every 10,000 checks) and a warning names the
first differing record of a run (as the window had it, as it is now).
Off by default; costs a clamp and a compare per window draw.

Test: through a host list, a record nothing wrote compares equal, and
one the card writes after the window's clamp is found and named.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@venglov

venglov commented Nov 25, 2026

Copy link
Copy Markdown
Author

Thanks @Peppacodes. The RTX 5080 numbers settle the windows' cost: 32.6 ms → 0.63 ms for 3,200 draws in the benchmark, and 12–22 % shorter frames in game with VICTORY_INDIRECT_WINDOW=1. With windows off, the card's share fell from 84 to 64 ms while the frame stayed within this machine's run-to-run spread, since preparing is the limit there.

So the gain is in windows, and the open question is whether windows can be trusted by default (#107: keeping 16 windows per list broke drawing, and one RTX 4090 run with windows on main showed corrupted blocks). f873394 adds a check for that, off by default:

  • With VICTORY_INDIRECT_WINDOW=1 VICTORY_INDIRECT_WINDOW_CHECK=1, every draw served from a window first clamps its record again, by the window's rules, into a buffer of its own with a budget of its own, and a one-thread compare checks it against the window's copy on the card.
  • Counts go to the log as window check (every 10,000 checks). A warning names the first record of a run that differed, as the window had it and as it is now.
  • It costs a clamp and a compare per window draw, so frame times with it on say nothing; the counts are what to report.
  • Test: through a host list, a record nothing wrote compares equal, and one the card writes after the window's clamp is found and named. Under the debug layer all 13 indirect:: tests pass with nothing reported.

If anyone with windows on can run a few minutes of gameplay with the check and post the last window check line (and any warning), that tells us whether windows read anything stale in this title.

Also: #220 merges cleanly onto the new main (c96b4f2). Two things on main itself will show up in every PR's CI:

  • cargo clippy --workspace --all-targets -- -D warnings (without --all-features) fails with "function placed_filler_twins is never used" (resource.rs, called only from diagnostics code). A #[cfg(feature = "diagnostics")] on it fixes that.
  • On GitHub's runner (software adapter), pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws fails: "depth 0.5 outside [0.6, 1.0] must be rejected", left 255. Perhaps the adapter doesn't apply the test, so it may want a skip there.

With those two aside, #220 merged onto c96b4f2 passes everything: 117 passed against main's 112, the same single failure on both (#220 merged, main alone; both with the one-line cfg added so the tests run).

fxceless added a commit that referenced this pull request Nov 25, 2026
…c, draw-table slots left to their draws, no failing write-watch calls; card fetches inside their flights (off by default)

- Descriptor sync: a multiply-and-fold fingerprint of a record in place of
  BLAKE3 (35 to 42 ms a frame over 250,000 to 300,000 records), and slots
  that draws read through tables lately are left to their draws
  (VICTORY_HEAP_SYNC_TABLES=1 mirrors them too): the pass over the heap
  went from 70-220 ms a frame to about 3.
- Write watch: no kernel asking for memory the guards already hold as view
  memory (pull request #670 by Jonirulah).
- Card copies' flagged pieces can come down inside their own flights
  (pull request #648 by Jonirulah; VICTORY_CARD_FETCH_INFLIGHT=1, off by
  default). One game run with it on: no device loss, the copy-back
  thread's fetch wait 181 -> 0 ms a frame, the card busier; no frame-time
  gain claimed.
- Logging: the heap pass's texture part and buffer slots; indirect compute
  dispatches over 65,535 groups.
- README: what was measured, and that pull request #220 with
  VICTORY_INDIRECT_WINDOW=1 lost the device twice here and is not in.

One five-minute game run of this tree's source on an RTX 4070: no device
loss; the frame is still 250 to 380 ms (the card is the limit). This
merged tree was built; its test suites were not run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@CuteBooty

Copy link
Copy Markdown

A second RTX 3070 (slower CPU), Series S: faster in light scenes, slower in heavy ones

One run with the switch against one without, same exe and settings otherwise, both about 24 minutes from the first
room through the robbery and the chase. Our tree carries an older head of this PR, not 8107935. Settled medians of
the log's frame lines, by draws per frame:

Draws a frame Switch off Switch on
3,000-5,000 (prison scenes) 240 ms (46 lines) 207 ms (49 lines), best frame 117 ms
5,000-7,000 392 ms (29 lines) 595 ms (18 lines)
7,000-9,000 (robbery, street) 447 ms (18 lines) 577 ms (18 lines)
  • In the first room the card's time fell most (about 60-80 ms to about 42 ms); the first minutes sat at 150-175 ms
    where the same scene was 240 ms without.
  • From the robbery on, with 9,000-10,000 draws a frame and the card at its budget, the switch was the slower one.
  • Draws dropped without a host pipeline outdoors were fewer with it (about 220 a frame against 830-1,480); I have
    not worked out why.
  • No error or device removal in either run.

One run each, and the heavy scenes differ a little between runs, so the direction is firmer than the sizes. It
agrees with VibeClauding's cell-view result on the same card; the heavy-scene loss is new as far as I can see.

Setup: RTX 3070 8 GB (driver 621.24, 32-lane waves), Ryzen 5 3600, 32 GB, Windows 11, Series S mode (PR #188), 1920x1080, VICTORY_TEXTURE_DROP_MIPS=1, relay at its default (stage 2), card buffers 1 / 1024 MB, a diagnostics build of a tree with a number of open PRs picked.

@kennymaakay

Copy link
Copy Markdown

Turing data point: RTX 2080 SUPER 8 GB (i9-9900, Windows 11, PCIe 3.0), PR head 8107935, both synthetic benchmarks, no title files.

cargo test -p victory-gpu --release --lib indirect::bench -- --ignored --nocapture, 3,200 one-record draws, medians of 9 frames:

3,200 draws GPU ms µs a draw RTX 3070 (above)
one at a time, main 20.59 6.43 22.49
one at a time, this 21.78 6.81 23.19
one at a time, budget in card memory 19.20 6.00 20.04
windows of 32, main 30.22 9.44 33.56
windows, new barriers, main's clamp 26.89 8.40 30.65
windows of 32, this 0.92 0.29 0.98
windows of 32, budget in card memory 0.86 0.27 0.88

So this card tracks the 3070 closely: windows -96.9 % against main's windows, budget in card memory -11.8 % one at a time.

bare_command_cost (10,000 one-triangle draws, 2560x1440), the part that differs from the 5070 Ti numbers in #696:

between draws µs a draw
nothing 0.02
another pipeline 0.12
a barrier pair on a second texture 0.70
100 lists run one by one 0.29
(h) a compute pass of ours of one group 4.18
(i) the same pass between two waits for earlier shader writes 4.28

On Turing almost all of the per-draw cost is the compute pass between two draws itself (4.18 µs); the two UAV waits add about 0.1 µs. On the 5070 Ti in #696 it was the other way round (0.47 µs without the waits, 4.22 with them). So on this generation removing barriers alone (VICTORY_BARRIER_TEST=indirect) should not help; what helps is not having a clamp between draws at all, which is what windows do here.

Rough synthetic bound for this card: about 5,100 clamped executions a frame × ~6 µs ≈ 30 ms a frame of clamp alone, before any loss of overlap with the real draws. For reference, in game this machine runs at about 190 ms a frame of card work, card-bound (with the c96b4f2 texture passes off, see #594). I haven't run this PR in game yet; that A/B is next.

(Measured and written with Claude Code, Claude Opus 5.5.)

fxceless added a commit that referenced this pull request Nov 25, 2026
…queue for fetches, indirect draw windows made safer, a profiler; all behind switches

- VICTORY_ASYNC_SUBMIT=1: submissions are prepared and sent by a thread of
  the layer, in order, instead of by the title's render thread; the
  queue's line stays open while its head is prepared.
- VICTORY_QUEUE2=1: fetches of what shaders wrote to copies in the card's
  memory go to a copy queue, with the fix for a piece fetched beside a
  later flight (fetched again when that flight lands).
- Pull request #220 (cheaper indirect draws) is in, its windows off by
  default; a draw record of 2^23 vertices an instance or more runs empty
  (its window checker found one list drawing 90 such records).
- Fills of upload memory and read-only title buffer copies no longer wait
  for flights; each is checked against what the flights then wrote, and
  the first mismatch turns the waiting back on (VICTORY_FILL_WAIT=1).
- Up to 512 idle host lists and the texture staging buffers are reused.
- VICTORY_MERGE_GAP / VICTORY_MERGE_RUNS (off / 512 by default; the gap
  form is not exact, see its comment).
- VICTORY_PROFILE=1 (diagnostics builds): a sampling profiler inside the
  layer.
- README: what was measured, the history of the device losses with
  windows, and what is still open (frame rate dips; cause not known).

Measured on an RTX 4070 in the first room: about 3.5-4 frames a second
before, 6-7 with all the switches, defaults about 4.5-5. Five runs with
windows on since the fix, no device loss. This merged tree was built; its
whole test suite was not run (the tests around flights, queues, indirect
draws and the copy queue were, on the development tree).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@kennymaakay

Copy link
Copy Markdown

In-game A/B on the same RTX 2080 SUPER 8 GB (i9-9900, Windows 11), following the benchmarks above. PR head 8107935 merged onto our local tree (fork main 3bff182 + local changes, no other PRs), one binary, only VICTORY_INDIRECT_WINDOW differs. Series X profile, relay stage 2, card copies 1 MiB–1280 MB, VICTORY_HEAP_RECHECK=0 VICTORY_EARLY_TEXTURES_MS=0 VICTORY_BAKE_TEXTURES_MS=0 (#594). Same moment of the opening in-engine scene, standing still, the last minute of each run (12–16 frame lines each):

windows off VICTORY_INDIRECT_WINDOW=1
fps 4.3–4.6 5.7–6.5
ms/frame 215–235 (~228) 155–175 (~163)
on the GPU (the submitting thread's wait) 85–108 40–61
preparing 98–114 96–116
copying back 90–107 92–108
draws/frame ~4,950 ~4,850
dropped without a host pipeline ~345 ~350
card busy (the frame line's own count) 77–81 % 70–73 %
  • About −28 % ms/frame, in line with @VibeClauding's 3070 (201–206 → 130–145) and with @CuteBooty's 3,000–5,000-draw scenes. Draws and drops match between the runs, so it is the same scene.
  • After the change the frame is bound by preparing and copy-back (~100 ms each), not the card, as on the 3070.
  • No errors or device removal.

Not covered: one run each; I did not compare the picture closely between the two runs and have not run VICTORY_INDIRECT_WINDOW_CHECK=1 yet; and only this ~4,900-draw scene, so nothing on the heavier 5,000–9,000-draw scenes where @CuteBooty saw it slower. I'll add a check run and a heavy scene when I can.

(Measured and written with Claude Code, Claude Opus 5.5.)

@npanu420

Copy link
Copy Markdown

Results on an RTX 3070 8 GB + i9-9900X, Windows 11, Series S profile. This is a port of this PR's budget part onto a 9376fd6-based stack (ExoCalibra's #770 head 28b74a9 + #802 #804 #346 #522 #783 #827 #798 #823 + #824).

#780 (VICTORY_INDIRECT_KEEP=1) already covers the scratch-barrier half, so the port takes only the grouped charge with the budget in card memory. It sits behind VICTORY_INDIRECT_GROUP_BUDGET=1 and is off by default. With it off, the clamp compiles to the same DXBC as before. It also carries VICTORY_INDIRECT_WINDOW_CHECK and the bench module. Commit: npanu420@04eb3e1 (branch port-220-on-9376fd6).

The same warm build, three runs back to back. Each is the median over world frames 60-160, with VICTORY_INDIRECT_KEEP=1:

switches GPU (submit thread waiting) median frame crash / device removed
GROUP_BUDGET=0 251 ms 631 ms 0 / 0
GROUP_BUDGET=1 228 ms 580 ms 0 / 0
GROUP_BUDGET=1 INDIRECT_WINDOW=1 139 ms 546 ms 0 / 0

These are single runs with small windows (9-11 status lines), so the medians are noisy, but the GPU drop with windows is large. There were no device losses on this card. WARP tests: 14 passed with all switch combinations, including a lane-order test across the 32-lane boundary.

(AI-assisted: ported with Codex, reviewed and measured with Claude Code. No game data.)

VibeClauding added a commit to VibeClauding/victory-fork that referenced this pull request Nov 25, 2026
…her codes 0x104/0x105/0x106

- fxceless#646 (USER_DISPATCH_THREADS), fxceless#834 (USER_GROUP_BASE) and our
  USER_VIEW_SLOT each took 0x104; here they are 0x104, 0x106, 0x105.
- record_clamp_with takes the scratch buffer's state as record_clamp_as
  does since fxceless#220, and bound_split tracks it like clamp_into.
- The split read asked.x, which since fxceless#220 is the mesh records' count
  (a scalar, 0 for dispatches): every full dispatch got 65,535 more
  groups and twice the charge. It reads the record's x now, as the
  second record's store does. warp_split_runs_every_group_of_a_wide_
  dispatch_once passes again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016TFkzoCQk3ZUibQWPNRBXE
dkdknight added a commit to dkdknight/victory-fork that referenced this pull request Nov 25, 2026
…, small buffers on the card, parallel page merge, absent blocks asked outside the guards' lock, PR fxceless#853 alias guard, GPU_UPLOAD windows, legacy multiply and wide scalar loads); view guard back on in play-lod.ps1

Written by AI agents from this session's leads, reviewed and built here;
measured separately. Switches:
- VICTORY_INDIRECT_CARD_BUDGET (on; =0 as before): the clamp's per-list
  budget counter in card memory, zeroed by the clamp shader's own entry,
  instead of a system-memory buffer with 1-4 atomics per clamp over PCIe
  (after fxceless/victory-fork PR fxceless#220).
- VICTORY_CARD_BUFFERS_MIN_KB (off): card copies for title buffers under
  1 MiB, floor 64 KiB (after PR fxceless#200).
- VICTORY_MERGE_THREADS (4; =1 as before): merge_under_writes reads
  contiguous stale pages in one call and compares them on scoped threads;
  changed_runs skips equal bytes 64 at a time; merging stays in order on
  the submitting thread.
- VICTORY_GUARD_ABSENT_BITS (on; =0 as before): absent blocks still
  uncommitted are dropped from a range's runs before the guards' lock is
  taken (nothing marked clean, unlike parking).
- PR fxceless#853 (Peppacodes et al.) ported: a write through one view no longer
  opens the other views of the page; they are noted written and guarded
  again together (plus clean_bit cleared for the alias).
- VICTORY_UPLOAD_WINDOWS_MB / VICTORY_UPLOAD_WINDOWS_ROOM_MB (off): windows
  in GPU_UPLOAD (ReBAR) heaps, written by the CPU straight into card memory.
- VICTORY_LEGACY_MUL=1|2, VICTORY_SMEM_WIDE=1 (off): plain multiplies for
  exact legacy-multiply cases, scalar buffer loads 4 dwords at a time.
- play-lod.ps1: VICTORY_VIEW_GUARD=0 removed (walls of the cell were
  missing without it: same shot, screenshots).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Trexies pushed a commit to Trexies/victory-fork that referenced this pull request Nov 25, 2026
The clamp charged the list's budget record by record: an atomic read and
a compare-and-swap loop per record on one word, every thread of a window
racing for it, so a group of n records took n rounds and about n*n/2
atomics. The word is CPU-visible memory (zeroed on the CPU at
submission), so on a card of its own each of them crosses the bus. On an
RTX 5070 Ti the benchmark's windows of 32 took 46-50 ms for 3,200 draws
where draws clamped one at a time took 19 ms (fxceless#220).

Now the records' costs go to group-shared memory, one thread charges
their sum with one compare-and-swap (retried only if another group got
there first), simulating the same saturation record by record in lane
order, and every thread reads whether its record fitted. The mesh
diagnostics (largest group count asked, groups asked in all) are summed
in the group and added once. What a record costs and when it runs empty
are unchanged; which records of a group fit is now their lane order
instead of the order the GPU served the race.

Test: a group with 300 left of the budget keeps its first draw (100),
empties the second (250, which takes the rest) and the ones after it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 3db5a0e)
Trexies pushed a commit to Trexies/victory-fork that referenced this pull request Nov 25, 2026
… all


An execution may ask for thousands of records with a count buffer that
counts a few: the clamp runs a group per 64 asked. Before the charge per
group, the threads past the count returned at once; with it, the first
thread of every group read the budget word, and for mesh records added
the group's notes to it, records or none. In memory the CPU maps that is
up to three atomics across the bus per empty group (on an RTX 5070 an
in-game A/B of 32c6229 ran slower, fxceless#220). Now a group without records
makes no atomic; the group's barriers stay in uniform control flow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 7e239bf)
Trexies added a commit to Trexies/victory-fork that referenced this pull request Nov 25, 2026
Trexies added a commit to Trexies/victory-fork that referenced this pull request Nov 25, 2026
@iGoldenNinja

Copy link
Copy Markdown

RTX 5080 16 GB, 617.14, Windows 11 Pro 25H2 build 26200.9974, Ryzen 9 5900X, 32 GB RAM. I used a diagnostics switch to toggle draw windows on and off within an a253706-based build, 74becd8, after reaching controllable Series X prison. The driver watcher was active and VICTORY_COPY_PLAIN was off.

Over three 30-second display segments at 2542 × 1396, off/on/off gave 2.985 / 3.446 / 3.813 displayed FPS and 393.94 / 629.10 / 358.66 ms P99. In the overlapping 4,800–5,300 draws-per-frame band, median host-reported GPU time was 179.45 ms across six initial off samples and 78.40 ms across five on samples. The final off segment drew fewer objects, and the captured viewpoints differed. A performance overlay was also visible in the enabled capture. The GPU time decrease is a useful lead. The test does not establish an FPS gain at matched workload.

No driver error or device removal was logged and the run ended deliberately. Test method and frame timing. Testing and reporting assisted by OpenAI Codex.

triippywhale pushed a commit to triippywhale/victory-fork that referenced this pull request Nov 25, 2026
…with fxceless#220's clamp, 159 -> ~121 ms/frame in the world

(cherry picked from commit f8bc690)
PiloteCode added a commit to PiloteCode/victory-fork that referenced this pull request Nov 25, 2026
…fer indirect windows, a profiler; one implementation where both sides had one

Where both sides did the same thing one implementation was kept:

- Fetches of what shaders wrote, on a copy queue: upstream's lane
  (VICTORY_QUEUE2 bit 1, with its refetch) replaces this fork's (5afe21a,
  VICTORY_RELAY_COPY_QUEUE), on correctness. Ours had the hole upstream
  fixed: a piece fetched while a later flight writes it comes down half
  written, and when that flight leaves the piece as it was its compare
  flags nothing, so title memory keeps the half-written bytes. Upstream's
  WARP test, adapted to our fetch on integration 3833fff, fails that way
  (title memory holds 0xdead0001, the half-way value, where 0x600d0002 is
  due); the merged tree passes it, and fails it again with
  VICTORY_QUEUE2_REFETCH=0. The lane is on by default here (upstream: off),
  as our copy queue was (gameplay frame 213 -> 170 ms when it went in);
  VICTORY_QUEUE2=0, or VICTORY_RELAY_COPY_QUEUE=0 with VICTORY_QUEUE2
  unset, fetches on the direct queue. The progress watch of aca0259 watches
  the lane's fetch as it watched our copy queue's.
- The indirect scratch buffer left readable between draws: upstream's
  tracking (HostList::indirect_state, set at the clamp, back to common
  when the list closes or the buffer is replaced) replaces ours
  (scratch_read, set after each execution): the same barriers, and no
  caller has to report its execution. The ring of 485a070 stays the
  default where the host takes enhanced barriers (VICTORY_INDIRECT_RING=0:
  the scratch buffer).
- The clamp program: upstream's (pull request fxceless#220: one budget charge per
  group, the budget in the card's memory, a draw record of 2^23 vertices
  an instance or more runs empty) with integration's split dispatch
  (6d59c48: kind 3, four records of base and counts) and its counters of
  compute records, now gathered per group as upstream gathers the mesh
  ones; the card's copy of the budget carries all five words back, so the
  frame line's budget (6831678) and group counts are read as before. The
  window check (VICTORY_INDIRECT_WINDOW_CHECK=1) works with the ring (the
  compare reads the ring behind a barrier of the enhanced kind). Windows
  stay on by default here (measured in the second pass), now with that
  fix; upstream lost the device three times with windows on before it.
- Texture staging buffers: this fork's pool (f5f458e: classes of an eighth
  of a power of two, 1 GiB, every size; the opening cutscenes' heap pass
  187 -> 65 ms) stays, upstream's (powers of two up to 8 MiB, 256 MB) is
  left out; upstream's VICTORY_STAGING_POOL=0 turns ours off too.
- The relay's merge of fetched pieces stays one piece at a time, each
  gathering the ranges to leave out as they stand (13494e5); upstream's
  check of read-ahead fills (shaders_write) is called from it per piece.

Upstream's alone, as shipped: VICTORY_ASYNC_SUBMIT (off), fills of upload
memory and read-only title buffer copies no longer waiting for flights
(the first one that read bytes a flight then changed turns the waits back
on; VICTORY_FILL_WAIT=1 waits from the start), up to 512 idle host lists,
VICTORY_MERGE_GAP / VICTORY_MERGE_RUNS, VICTORY_PROFILE (diagnostics).
Both sides' diagnostics of waits for flights are kept. With
VICTORY_ASYNC_SUBMIT a page remap first lets what the queues hold and may
run go (queue::before_sync), so it is prepared from title memory as it
stood when submitted; the land-before-remap of 915add2 follows.

Not timed in a game run here (the general test of the merged build
does). Checked on the software adapter (diagnostics): the queue tests
with VICTORY_QUEUE2 at 0, 1 and 3; the indirect tests on the ring and on
the scratch buffer (window check, executions with no barrier of their
own, the budget, the split dispatch); the profiler's tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.