GPU: hoisted indirect clamps (VICTORY_HOIST_CLAMPS) and a cap on the planned card budget (VICTORY_VIDEO_BUDGET_MB), both off by default #1181

Open
Marukooh wants to merge 2 commits from upstream-pr/1184 into main
Marukooh commented 2026-11-25 23:10:51 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Marukooh on 2026-11-25T23:10:51Z.


Two switches, both off by default: hoisted indirect clamps (VICTORY_HOIST_CLAMPS=1) and a cap on the card budget the layer plans with (VICTORY_VIDEO_BUDGET_MB). The second turned out to decide most of what the first was measured against, so they come together.

1. VICTORY_VIDEO_BUDGET_MB: a cap on the planned card budget

Host::video_memory reports at most this budget. The texture queue (resource::room), card copies of buffers and windows all use that number.

On an RTX 5070 Ti under Proton the system's budget starts near 12.4 GB. In most runs it drops to about 10.5 GB near frame 725 ("the system changed the budget of the card's memory"). In 13 runs on 25-26 November, the indirect compute 982f3cccd5c04294 took:

system budget runs 982f per call GPU a frame
dropped to ~10.5 GB 8 ~12 ms 50-120 ms
stayed at ~12.4 GB 5 160-170 ms 200-260 ms

That held for every run, both ways, with hoisted clamps on or off. In the slow runs the card was 97% busy at 82-89 W instead of 96-104 W, and NVML showed less memory in use. Both are signs of memory the driver moved out to the PC's. The texture queue fills the card to nine tenths of the budget, so with 12.4 GB it overfills.

With VICTORY_VIDEO_BUDGET_MB=10500: 4 runs of 4 fast (198.7-204.8 ms a frame, GPU 84-97 ms, 982f 11-13 ms). Without it, in the same hour: 6 runs of 6 slow (314-425 ms a frame, 982f 160-169 ms). With the cap the system's budget also dropped every time. I cannot say why; the outcome is what was measured.

2. VICTORY_HOIST_CLAMPS=1: clamps of a run of indirect draws in a list before it

The argument clamps of a run of indirect draws are recorded in a host list of their own that runs before the list that draws. Between the draws of the run there is then no dispatch of ours and no barrier. An inline clamp has two global UAV waits around it, and the prologue records about 4,000 clamps a frame. Adapted from Belobug/VIctory-Belobug-AMD@ccab973.

  • At the first indirect draw of a run the recording is cut: what was recorded is closed into List::runs, a list for the run's clamps is opened after it (indirect::Hoist), and the title's calls go on in a new host list with the state replayed (State::replay), as a cut at a wait does.
  • The run's clamps write one 1 MiB buffer at their own offsets: one UAV barrier at the start of the clamp list, a transition to COMMON at its end, none between clamps.
  • List::runs need no waits. They go through detach, detach_parts and the in-place paths (list::host_runs in queue.rs), so hoisting does not move lists onto the held path.
  • A run ends at anything that may write arguments: dispatches, copies, resolves, query resolves, memory writes, and draws whose shaders store to buffers (translated().stores, the rule windows use). It also ends at cuts for waits, close and reset.
  • All pieces of a title list charge one indirect budget, the first piece's (HostList::budget_to_lend / lend_budget). The card's copy goes COMMON -> UAV -> COMMON in each list that borrows it. After a cut at a wait the new piece has its own, as before.
  • Not hoisted: indirect dispatches, rectangles, windows and gathered records.

Measured with the budget cap at 10500 and the system's budget dropped in both runs; same build, switch at 0 and 1. Prologue, windows of 2,500-6,000 draws a frame with pipelines ready, 70 s each:

frame (median) title lists, card clock clamp, per sample 982f per call
inline 179.8 ms 127.2 ms 5.0 us 12 ms
hoisted 151.8 ms 107.0 ms 2.2 us 11-12 ms

RTX 5070 Ti 16 GB, driver 620.73, CachyOS, Proton Experimental with vkd3d-proton, 3840x2160 swap chain. The measurements come from the same changes on an older base (0b0074e plus local work, which also has the fill-ahead part of #860); this branch has the changes alone on 6d20eed.

Correction to the first version of this PR: its numbers (GPU 95.5 -> 57.8 ms) and its "what did not work first" section came from runs mixed between the two budget states above. The 982f slowdowns I blamed on hoisting were the budget. The rule that draws whose shaders store end a run is kept because it is safe, but no effect of it was shown.

Tests

  • New WARP tests: host_list_hoisted_clamps_serve_the_next_list_at_their_offsets and host_list_lent_budget_is_spent_across_lists (with the card's budget copy and without).
  • victory-gpu --lib under Proton (WARP): 187 passed, 5 ignored, 1 failed with VICTORY_HOIST_CLAMPS at 0 and at 1. The failure, drvwatch::tests::the_system_takes_the_subscription, fails the same way on 6d20eed.

Not covered

  • The value 10500 fits this card and driver. Other cards need their own, which is why the cap is off by default.
  • The image with hoisted clamps on has not been compared frame by frame.
<!-- greyfinch-sync:fxceless/victory-fork:issue:6615645968 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1184). Originally posted by [Marukooh](https://github.com/Marukooh) on 2026-11-25T23:10:51Z. --- Two switches, both off by default: hoisted indirect clamps (`VICTORY_HOIST_CLAMPS=1`) and a cap on the card budget the layer plans with (`VICTORY_VIDEO_BUDGET_MB`). The second turned out to decide most of what the first was measured against, so they come together. ## 1. `VICTORY_VIDEO_BUDGET_MB`: a cap on the planned card budget `Host::video_memory` reports at most this budget. The texture queue (`resource::room`), card copies of buffers and windows all use that number. On an RTX 5070 Ti under Proton the system's budget starts near 12.4 GB. In most runs it drops to about 10.5 GB near frame 725 ("the system changed the budget of the card's memory"). In 13 runs on 25-26 November, the indirect compute `982f3cccd5c04294` took: | system budget | runs | `982f` per call | GPU a frame | |---|---:|---:|---:| | dropped to ~10.5 GB | 8 | ~12 ms | 50-120 ms | | stayed at ~12.4 GB | 5 | **160-170 ms** | 200-260 ms | That held for every run, both ways, with hoisted clamps on or off. In the slow runs the card was 97% busy at 82-89 W instead of 96-104 W, and NVML showed less memory in use. Both are signs of memory the driver moved out to the PC's. The texture queue fills the card to nine tenths of the budget, so with 12.4 GB it overfills. With `VICTORY_VIDEO_BUDGET_MB=10500`: 4 runs of 4 fast (198.7-204.8 ms a frame, GPU 84-97 ms, `982f` 11-13 ms). Without it, in the same hour: 6 runs of 6 slow (314-425 ms a frame, `982f` 160-169 ms). With the cap the system's budget also dropped every time. I cannot say why; the outcome is what was measured. ## 2. `VICTORY_HOIST_CLAMPS=1`: clamps of a run of indirect draws in a list before it The argument clamps of a run of indirect draws are recorded in a host list of their own that runs before the list that draws. Between the draws of the run there is then no dispatch of ours and no barrier. An inline clamp has two global UAV waits around it, and the prologue records about 4,000 clamps a frame. Adapted from Belobug/VIctory-Belobug-AMD@ccab973. - At the first indirect draw of a run the recording is cut: what was recorded is closed into `List::runs`, a list for the run's clamps is opened after it (`indirect::Hoist`), and the title's calls go on in a new host list with the state replayed (`State::replay`), as a cut at a wait does. - The run's clamps write one 1 MiB buffer at their own offsets: one UAV barrier at the start of the clamp list, a transition to `COMMON` at its end, none between clamps. - `List::runs` need no waits. They go through `detach`, `detach_parts` and the in-place paths (`list::host_runs` in `queue.rs`), so hoisting does not move lists onto the held path. - A run ends at anything that may write arguments: dispatches, copies, resolves, query resolves, memory writes, and draws whose shaders store to buffers (`translated().stores`, the rule windows use). It also ends at cuts for waits, close and reset. - All pieces of a title list charge one indirect budget, the first piece's (`HostList::budget_to_lend` / `lend_budget`). The card's copy goes `COMMON -> UAV -> COMMON` in each list that borrows it. After a cut at a wait the new piece has its own, as before. - Not hoisted: indirect dispatches, rectangles, windows and gathered records. Measured with the budget cap at 10500 and the system's budget dropped in both runs; same build, switch at 0 and 1. Prologue, windows of 2,500-6,000 draws a frame with pipelines ready, 70 s each: | | frame (median) | title lists, card clock | clamp, per sample | `982f` per call | |---|---:|---:|---:|---:| | inline | 179.8 ms | 127.2 ms | 5.0 us | 12 ms | | hoisted | **151.8 ms** | **107.0 ms** | 2.2 us | 11-12 ms | RTX 5070 Ti 16 GB, driver 620.73, CachyOS, Proton Experimental with vkd3d-proton, 3840x2160 swap chain. The measurements come from the same changes on an older base (`0b0074e` plus local work, which also has the fill-ahead part of #860); this branch has the changes alone on `6d20eed`. **Correction to the first version of this PR:** its numbers (GPU 95.5 -> 57.8 ms) and its "what did not work first" section came from runs mixed between the two budget states above. The 982f slowdowns I blamed on hoisting were the budget. The rule that draws whose shaders store end a run is kept because it is safe, but no effect of it was shown. ## Tests - New WARP tests: `host_list_hoisted_clamps_serve_the_next_list_at_their_offsets` and `host_list_lent_budget_is_spent_across_lists` (with the card's budget copy and without). - `victory-gpu --lib` under Proton (WARP): 187 passed, 5 ignored, 1 failed with `VICTORY_HOIST_CLAMPS` at 0 and at 1. The failure, `drvwatch::tests::the_system_takes_the_subscription`, fails the same way on `6d20eed`. ## Not covered - The value 10500 fits this card and driver. Other cards need their own, which is why the cap is off by default. - The image with hoisted clamps on has not been compared frame by frame.
Proudnoob4 commented 2026-11-26 16:06:38 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Proudnoob4 on 2026-11-26T15:13:48Z.


RTX 4080 / i5-13600K (Win10) measurement when stacked with VICTORY_INDIRECT_BATCH=1

Ported #1184 (VICTORY_HOIST_CLAMPS=1 + VICTORY_VIDEO_BUDGET_MB) onto our VIctory-NVIDIA tree (989e5c6, which already runs VICTORY_INDIRECT_BATCH=1 by default and is currently CPU-bound on victory-submit at 32.8 ms while RTX 4080 sits 61% busy).

Unit test note: On trees where VICTORY_INDIRECT_REST=0 by default, 3 × (65535 × 16 × 64) leaves 2,048 budget remaining (2^27 - 2 × 67,107,840), so [1, 1, 1] still fits; using 2 × [32768, 32, 1] (2 × 67,108,864 == 2^27) makes host_list_lent_budget_is_spent_across_lists pass under both REST=0 and REST=1. Both #1184 unit tests passed cleanly.

10-minute live A/B (VICTORY_HOIST_CLAMPS=0 vs =1, with VICTORY_INDIRECT_BATCH=1 active; hoist() gated to skip single-record uncounted draws already handled by batch):

Metric (10-min settled / tail-40) Pass 15 (HOIST_CLAMPS=0) Pass 16 (HOIST_CLAMPS=1 + SECTION_MB=2) Delta
Median FPS (ALL / TAIL40) 32.00 / 32.00 30.70 / 30.05 -1.30 / -1.95 fps
VICTORY_THIN lists / pieces 203.0 / 312.2 223.0 / 376.4 +20 lists / +64 pieces
Relay read-backs and lists 7.46 ms 12.35 ms +4.89 ms
VICTORY_CARD_STEPS fills 4,282 (1,612 KB) 7,503 (3,046 KB) +75% fills
victory-submit working 32.8 ms 36.7 ms +3.9 ms
Visual scan (t=140..600s) 0/230 black 0/230 black clean

Why it regressed on our CPU-bound INDIRECT_BATCH=1 setup: Splitting a title list into extra host lists (+20 lists/frame) adds +4.89 ms of list reset/readback bookkeeping on the relay thread and breaks per-HostList fill_scratch CBV deduplication (4,282 -> 7,503 fills), which matters when victory-submit is the bottleneck. Visually it was 100% clean (0/230 black frames, 4,582 draws/frame). Good confirmation that keeping VICTORY_HOIST_CLAMPS opt-in (default off) is the right call — especially when VICTORY_INDIRECT_BATCH=1 is already active!

<!-- greyfinch-sync:fxceless/victory-fork:comment:7195969512 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1184#issuecomment-7195969512). Originally posted by [Proudnoob4](https://github.com/Proudnoob4) on 2026-11-26T15:13:48Z. --- ### RTX 4080 / i5-13600K (Win10) measurement when stacked with `VICTORY_INDIRECT_BATCH=1` Ported `#1184` (`VICTORY_HOIST_CLAMPS=1` + `VICTORY_VIDEO_BUDGET_MB`) onto our `VIctory-NVIDIA` tree (`989e5c6`, which already runs `VICTORY_INDIRECT_BATCH=1` by default and is currently CPU-bound on `victory-submit` at `32.8 ms` while RTX 4080 sits `61%` busy). **Unit test note:** On trees where `VICTORY_INDIRECT_REST=0` by default, `3 × (65535 × 16 × 64)` leaves `2,048` budget remaining (`2^27 - 2 × 67,107,840`), so `[1, 1, 1]` still fits; using `2 × [32768, 32, 1]` (`2 × 67,108,864 == 2^27`) makes `host_list_lent_budget_is_spent_across_lists` pass under both `REST=0` and `REST=1`. Both `#1184` unit tests passed cleanly. **10-minute live A/B (`VICTORY_HOIST_CLAMPS=0` vs `=1`, with `VICTORY_INDIRECT_BATCH=1` active; `hoist()` gated to skip single-record uncounted draws already handled by `batch`):** | Metric (10-min settled / tail-40) | Pass 15 (`HOIST_CLAMPS=0`) | Pass 16 (`HOIST_CLAMPS=1` + `SECTION_MB=2`) | Delta | |---|---:|---:|---:| | Median FPS (ALL / TAIL40) | `32.00` / `32.00` | `30.70` / `30.05` | `-1.30` / `-1.95 fps` | | `VICTORY_THIN` lists / pieces | `203.0` / `312.2` | `223.0` / `376.4` | `+20 lists / +64 pieces` | | Relay `read-backs and lists` | `7.46 ms` | `12.35 ms` | **`+4.89 ms`** | | `VICTORY_CARD_STEPS` fills | `4,282` (`1,612 KB`) | `7,503` (`3,046 KB`) | **`+75%` fills** | | `victory-submit` working | `32.8 ms` | `36.7 ms` | **`+3.9 ms`** | | Visual scan (`t=140..600s`) | `0/230` black | `0/230` black | clean | **Why it regressed on our CPU-bound `INDIRECT_BATCH=1` setup:** Splitting a title list into extra host lists (`+20 lists/frame`) adds `+4.89 ms` of list reset/readback bookkeeping on the relay thread and breaks per-`HostList` `fill_scratch` CBV deduplication (`4,282 -> 7,503` fills), which matters when `victory-submit` is the bottleneck. Visually it was 100% clean (`0/230` black frames, `4,582` draws/frame). Good confirmation that keeping `VICTORY_HOIST_CLAMPS` opt-in (default off) is the right call — especially when `VICTORY_INDIRECT_BATCH=1` is already active!
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1184:upstream-pr/1184'
git switch 'upstream-pr/1184'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1184'
git switch 'upstream-pr/1184'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1184'
git switch 'upstream-pr/1184'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1184'
git switch 'main'
git merge --squash 'upstream-pr/1184'
git switch 'main'
git merge --ff-only 'upstream-pr/1184'
git switch 'main'
git merge 'upstream-pr/1184'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!1181
No description provided.