Frame rate: indirect clamps in runs, landing fetches from card slots, re-check fix (2.5 -> 7.5 fps on a 5070 Ti) #995

Open
github-bot wants to merge 2 commits from github-bot/gh-995 into main AGit
Owner

@⁠tunczzz on GitHub · 2026-11-25 15:26 UTC · original
tunczzz:pr/fps-relay-landing → main · +31078 −1348 · 64 files · 2 commits · open

Frame-rate work on top of 0b0074e, measured on an RTX 5070 Ti (32 GB) in the first prison cutscene and the start of gameplay.

Result: 217-225 ms a frame before the 9376fd6 merge, 133-138 ms (7.2-7.5 fps) with the settings listed in docs/fps-notes.md. The card went from ~117 to ~64 ms a frame; the frame is now bound by the submitting thread, mostly the descriptor heap sync.

Almost everything is behind a switch and off by default, so the default behaviour is unchanged except for the fixes listed below. docs/fps-notes.md has the run table, the exact settings, what was tried and rejected (with the reason), and what is still open.

The big wins

  • Indirect clamp stalls (card 105 -> 64 ms). Each indirect record was clamped by a compute pass between two waits, 7-12 us of card time per call, ~4,700 calls a frame. VICTORY_INDIRECT_BATCH=3 clamps a run of calls in one pass (a run ends only at work that can store to a buffer); VICTORY_MESH_AMPLIFY=1 clamps mesh records inside an amplification stage.
  • Landing fetches. Fetches sat on the main queue behind every later flight (60-105 ms a frame of waiting). VICTORY_CARD_FETCH_INFLIGHT=2 copies each flight's flagged pieces into slots in card memory inside the flight, then copies the slots down on a copy queue at landing. Mode 1 was slow because shader writes into PC memory fall off a cliff on this card (64 MB: ~600 ms, against 0.74 ms into card memory).
  • Windows in GPU upload heaps (VICTORY_GPU_UPLOAD_COPIES=1) and table constants bound to the card copy (VICTORY_TABLE_ON_CARD=1).
  • CPU side: heap-sync skips (VICTORY_HEAP_SYNC_TABLES=2, VICTORY_SYNC_NULL_SKIP=1), wide fills, texture checks and refreshes, and fewer view-memory askings.

Fixes that are on by default

  • Texture re-check: VICTORY_HEAP_RECHECK fingerprinted past a texture's own bytes into the next texture placed in its large levels, and uploaded it again with them; that was the blocky strip at the bottom of the scene. It now stops at the next texture's start. There is also a BTreeMap::range panic fix for textures smaller than the head.
  • Refresh on a full card: VICTORY_REUPLOAD_WHEN_FULL with async texture workers never ran. It is now done in the pass.
  • Stale textures: textures uploaded before a DirectStorage write into their pages are uploaded again.
  • Save containers: they no longer fail when a version folder exists in both layers of a packaged app's virtualised AppData (os error 4395). This is why the settings never saved.
  • Smaller ones: window ghosting is off; the arrow keys also turn the camera (VICTORY_ARROWS_LOOK=0 restores the D-pad); blending is turned off for integer targets, so the wiper-mask pipeline builds.

Not proven / needs a look

  • VICTORY_ASYNC_SUBMIT=1 drew the room without walls here. VICTORY_FLIP_LANDED is the attempted fix and is not measured yet.
  • VICTORY_PICKED_EXACT=1 declares the skinning programs' writes through heap-picked UAVs from their job records. It is not measured yet.
  • Run-to-run differences (window wire mesh, left wall, top colour) track textures held back under the commit floor.
  • Tests: victory-gpu and victory-shader lib tests pass, except indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields, which is flaky on the merged upstream code too.

This is one squashed commit of many smaller ones. Happy to split it if you'd rather take parts of it.

🤖 Generated with Claude Code

Update: merged 3973179 (upstream's frame-rate commit). Where both of us had built the same thing, yours wins: VICTORY_JOIN_PARTS is yours (my own version of it was dropped), and your pace/card-meter diagnostics are kept as they are; the one clash was a field called sked on Fence, mine is unchanged and yours is now pace_asked. After the merge: cargo check is clean with and without diagnostics, ictory-gpu lib tests pass (264), and a five-minute run on the 5070 Ti is 131-136 ms (7.4-7.6 fps) with no device loss.

**@⁠tunczzz** on GitHub · 2026-11-25 15:26 UTC · [original](https://github.com/fxceless/victory-fork/pull/995) `tunczzz:pr/fps-relay-landing` → `main` · +31078 −1348 · 64 files · 2 commits · open Frame-rate work on top of 0b0074e, measured on an RTX 5070 Ti (32 GB) in the first prison cutscene and the start of gameplay. **Result:** 217-225 ms a frame before the 9376fd6 merge, **133-138 ms (7.2-7.5 fps)** with the settings listed in `docs/fps-notes.md`. The card went from ~117 to ~64 ms a frame; the frame is now bound by the submitting thread, mostly the descriptor heap sync. Almost everything is behind a switch and off by default, so the default behaviour is unchanged except for the fixes listed below. `docs/fps-notes.md` has the run table, the exact settings, what was tried and rejected (with the reason), and what is still open. ### The big wins - **Indirect clamp stalls (card 105 -> 64 ms).** Each indirect record was clamped by a compute pass between two waits, 7-12 us of card time per call, ~4,700 calls a frame. `VICTORY_INDIRECT_BATCH=3` clamps a run of calls in one pass (a run ends only at work that can store to a buffer); `VICTORY_MESH_AMPLIFY=1` clamps mesh records inside an amplification stage. - **Landing fetches.** Fetches sat on the main queue behind every later flight (60-105 ms a frame of waiting). `VICTORY_CARD_FETCH_INFLIGHT=2` copies each flight's flagged pieces into slots in card memory inside the flight, then copies the slots down on a copy queue at landing. Mode 1 was slow because shader writes into PC memory fall off a cliff on this card (64 MB: ~600 ms, against 0.74 ms into card memory). - **Windows in GPU upload heaps** (`VICTORY_GPU_UPLOAD_COPIES=1`) and **table constants bound to the card copy** (`VICTORY_TABLE_ON_CARD=1`). - **CPU side:** heap-sync skips (`VICTORY_HEAP_SYNC_TABLES=2`, `VICTORY_SYNC_NULL_SKIP=1`), wide fills, texture checks and refreshes, and fewer view-memory askings. ### Fixes that are on by default - **Texture re-check:** `VICTORY_HEAP_RECHECK` fingerprinted past a texture's own bytes into the next texture placed in its large levels, and uploaded it again with them; that was the blocky strip at the bottom of the scene. It now stops at the next texture's start. There is also a `BTreeMap::range` panic fix for textures smaller than the head. - **Refresh on a full card:** `VICTORY_REUPLOAD_WHEN_FULL` with async texture workers never ran. It is now done in the pass. - **Stale textures:** textures uploaded before a DirectStorage write into their pages are uploaded again. - **Save containers:** they no longer fail when a version folder exists in both layers of a packaged app's virtualised `AppData` (os error 4395). This is why the settings never saved. - **Smaller ones:** window ghosting is off; the arrow keys also turn the camera (`VICTORY_ARROWS_LOOK=0` restores the D-pad); blending is turned off for integer targets, so the wiper-mask pipeline builds. ### Not proven / needs a look - `VICTORY_ASYNC_SUBMIT=1` drew the room without walls here. `VICTORY_FLIP_LANDED` is the attempted fix and is not measured yet. - `VICTORY_PICKED_EXACT=1` declares the skinning programs' writes through heap-picked UAVs from their job records. It is not measured yet. - Run-to-run differences (window wire mesh, left wall, top colour) track textures held back under the commit floor. - Tests: `victory-gpu` and `victory-shader` lib tests pass, except `indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields`, which is flaky on the merged upstream code too. This is one squashed commit of many smaller ones. Happy to split it if you'd rather take parts of it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) **Update:** merged 3973179 (upstream's frame-rate commit). Where both of us had built the same thing, yours wins: VICTORY_JOIN_PARTS is yours (my own version of it was dropped), and your pace/card-meter diagnostics are kept as they are; the one clash was a field called sked on Fence, mine is unchanged and yours is now pace_asked. After the merge: cargo check is clean with and without diagnostics, ictory-gpu lib tests pass (264), and a five-minute run on the 5070 Ti is 131-136 ms (7.4-7.6 fps) with no device loss.
Measured on an RTX 5070 Ti in the first prison cutscene and gameplay:
217-225 ms a frame before the 9376fd6 merge, 133-138 ms (7.2-7.5 fps) with
the settings in docs/fps-notes.md; the card went from ~117 to ~64 ms a
frame. Almost everything is behind switches, off by default; see the notes
for the table of runs, what was rejected and why.

- Indirect calls: VICTORY_INDIRECT_BATCH=1|3 clamps a run of indirect calls
  in one pass (3: a run ends only at work that can store to a buffer);
  VICTORY_MESH_AMPLIFY=1 clamps indirect mesh records in an amplification
  stage (blending turned off for targets the card cannot blend, so the
  wiper-mask pipeline builds).
- Landing: VICTORY_CARD_FETCH_INFLIGHT=2 copies each flight's flagged pieces
  into slots in card memory inside the flight and copies the slots down on
  the landing thread's copy queue; one flight per landing.
- Title reads: VICTORY_TABLE_ON_CARD / VICTORY_TABLE_GPU_COPY bind or copy
  table constants on the card; VICTORY_COPY_ON_CARD runs title buffer copies
  on the card; early-read counters for title copies.
- Memory and buses: VICTORY_GPU_UPLOAD_COPIES (windows in GPU upload heaps),
  card-window gate, levels kept under pressure (VICTORY_PRESSED_LEVELS_KB),
  memory map labels, notes that card memory counts as commit.
- CPU: heap sync parts line and skips (VICTORY_HEAP_SYNC_TABLES=2,
  VICTORY_SYNC_NULL_SKIP, a pre-read that only peeks), wide fills/texture
  checks/declared refreshes, fewer view askings, joined submissions
  (VICTORY_JOIN_PARTS), async-submit fixes (VICTORY_FLIP_LANDED), barrier
  counter and lazy UAV waits, frame-path line.
- Fixes on by default: upstream's texture re-check fingerprints only the
  texture's own bytes (and no BTreeMap range past its end); refresh on a full
  card is done in the pass; textures uploaded before a DirectStorage write are
  uploaded again; save containers survive a folder present in both layers of
  a packaged app's AppData; window ghosting off; arrow keys also turn the
  camera (VICTORY_ARROWS_LOOK=0: the D-pad as before).
- Shaders: wave-wide LDS branches outside loops, VICTORY_WAVE_LOCAL_FIRST,
  VICTORY_WAVE_UNIFORM, VICTORY_LEAN_MATH, picked-store recipes
  (VICTORY_PICKED_EXACT).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Where both sides built the same thing, upstream's wins: VICTORY_JOIN_PARTS is
upstream's (our own joining of parts is dropped), VICTORY_VIEW_KNOWN=alt and
the fence pace/card meter diagnostics are taken as they are. The field
upstream added to Fence for its pace meter is renamed pace_asked (ours is
the highest value a queue was told to signal, asked). Kept from our side: the
async-submit/flip fixes, window-jump stays off by default beside our indirect
runs.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:55:26 +00:00
Author
Owner

@⁠grosterr on GitHub · 2026-11-25 18:50 UTC · original

A data point on "VICTORY_ASYNC_SUBMIT=1 drew the room without walls here": not reproduced on an RTX 3060 12 GB (Ryzen 7 5700X, 32 GB, Windows 11, Series X profile).

Tree: not this PR. It is the fxceless#770 stack (d034ac1) with main a253706 merged in (grosterr/victory-fork rtx3060), with LEVELS_ON_DEMAND=1 EARLY_TEXTURES_MS=40 TEXTURE_NO_WAIT=1 WIDE_TEXTURES=1 as the base. Same save each time, ~5–10 minutes in the first rooms and corridor:

run switches on top of the base walls / picture
A0a ASYNC_SUBMIT=1 alone walls present, picture clean
A0, A0r ASYNC_SUBMIT=1 QUEUE2=1 INDIRECT_WINDOW=1 COPY_PLAIN=1 walls present in both

No device loss and no errors in any of them. So on this tree the missing walls do not follow from ASYNC_SUBMIT alone. It may depend on something else in this PR (or on 0b0074e's changes), which might help narrow down what VICTORY_FLIP_LANDED has to fix.

For scale, the four switches together took this card from 330 to 243–282 ms a frame (copy-back 216 → 66 ms, most of it from QUEUE2).

AI-assisted (Claude Code); the runs and observations are mine.

**@⁠grosterr** on GitHub · 2026-11-25 18:50 UTC · [original](https://github.com/fxceless/victory-fork/pull/995#issuecomment-7171479022) A data point on "`VICTORY_ASYNC_SUBMIT=1` drew the room without walls here": not reproduced on an RTX 3060 12 GB (Ryzen 7 5700X, 32 GB, Windows 11, Series X profile). Tree: not this PR. It is the fxceless#770 stack (`d034ac1`) with main `a253706` merged in ([`grosterr/victory-fork` `rtx3060`](https://github.com/grosterr/victory-fork/tree/rtx3060)), with `LEVELS_ON_DEMAND=1 EARLY_TEXTURES_MS=40 TEXTURE_NO_WAIT=1 WIDE_TEXTURES=1` as the base. Same save each time, ~5–10 minutes in the first rooms and corridor: | run | switches on top of the base | walls / picture | |---|---|---| | A0a | `ASYNC_SUBMIT=1` alone | walls present, picture clean | | A0, A0r | `ASYNC_SUBMIT=1 QUEUE2=1 INDIRECT_WINDOW=1 COPY_PLAIN=1` | walls present in both | No device loss and no errors in any of them. So on this tree the missing walls do not follow from `ASYNC_SUBMIT` alone. It may depend on something else in this PR (or on `0b0074e`'s changes), which might help narrow down what `VICTORY_FLIP_LANDED` has to fix. For scale, the four switches together took this card from 330 to 243–282 ms a frame (copy-back 216 → 66 ms, most of it from `QUEUE2`). AI-assisted (Claude Code); the runs and observations are mine.
Author
Owner

@⁠slauko on GitHub · 2026-11-26 11:31 UTC · original

A request for the split you offered, from a Wine line that cannot take the branch as one piece (vkd3d-proton, RTX 3080 Ti, uiliannn's base; the cell at ~4,950 draws a frame, 636 of them indirect, card 144–190 ms of a 262–288 ms frame):

the indirect clamp batching (VICTORY_INDIRECT_BATCH=3) as its own PR, with whatever host.rs/descriptor.rs plumbing it needs.

Why that one first: my line already records the clamps per gather set — a compute pass per set between a UAV barrier on each side (indirect.rs, record_gather_as: uav_barrier, dispatch, uav_barrier + transition) — which is the shape your 105 → 64 ms is about; what it lacks is the run that takes several of them through one pair of waits. The rest of #995 is either not applicable here (VICTORY_GPU_UPLOAD_COPIES: GPU upload heaps ... supported=false under this stack) or too entangled with this line's own state to port from a 31k-line squashed branch.

I can test a split quickly on my side: the cell's frame and the card's time are in every run's log, and m29/m27 give a baseline (270–318 ms and 275–277 ms with and without a translator port today).

If the split is cheap for you, the other piece I would take next is VICTORY_CARD_FETCH_INFLIGHT=2 (the slots-in-card-memory variant) — =1 is measured here: it removes 141 ms of the relay thread's wait and adds ~60 ms on the card, a net loss on this stack, so the =2 geometry is the interesting one.

**@⁠slauko** on GitHub · 2026-11-26 11:31 UTC · [original](https://github.com/fxceless/victory-fork/pull/995#issuecomment-7190831651) A request for the split you offered, from a Wine line that cannot take the branch as one piece (vkd3d-proton, RTX 3080 Ti, uiliannn's base; the cell at ~4,950 draws a frame, 636 of them indirect, card 144–190 ms of a 262–288 ms frame): **the indirect clamp batching (`VICTORY_INDIRECT_BATCH=3`) as its own PR, with whatever `host.rs`/`descriptor.rs` plumbing it needs.** Why that one first: my line already records the clamps per gather set — a compute pass per set between a UAV barrier on each side (`indirect.rs`, `record_gather_as`: `uav_barrier`, dispatch, `uav_barrier` + transition) — which is the shape your 105 → 64 ms is about; what it lacks is the run that takes several of them through one pair of waits. The rest of #995 is either not applicable here (`VICTORY_GPU_UPLOAD_COPIES`: `GPU upload heaps ... supported=false` under this stack) or too entangled with this line's own state to port from a 31k-line squashed branch. I can test a split quickly on my side: the cell's frame and the card's time are in every run's log, and `m29`/`m27` give a baseline (270–318 ms and 275–277 ms with and without a translator port today). If the split is cheap for you, the other piece I would take next is `VICTORY_CARD_FETCH_INFLIGHT=2` (the slots-in-card-memory variant) — `=1` is measured here: it removes 141 ms of the relay thread's wait and adds ~60 ms on the card, a net loss on this stack, so the `=2` geometry is the interesting one.
Author
Owner

@⁠slauko on GitHub · 2026-11-26 13:29 UTC · original

A follow-up to my split request: the piece I asked for landed through Marvisak#3197's window instead, and it works on this stack — the indirect clamps in the cell fall from 1,757 to 1,796 a frame to 295 to 355 (the mesh draws join a table window; only the compute dispatches are left), with the table filled while recording and one pass per run.

So no split needed on my side for the clamp batch. The other items in this PR that still look interesting here are the CPU ones (VICTORY_HEAP_SYNC_TABLES, the wide fills, the texture checks) — this line's copies are 63–74 ms for ~190 MB a frame, write-bandwidth-bound at ~4 GB/s (VICTORY_COPY_PLAIN=1 changes nothing), and its heap pass is 25–45 ms in the descriptor scan.

**@⁠slauko** on GitHub · 2026-11-26 13:29 UTC · [original](https://github.com/fxceless/victory-fork/pull/995#issuecomment-7193430840) A follow-up to my split request: the piece I asked for landed through Marvisak#3197's window instead, and it works on this stack — the indirect clamps in the cell fall from 1,757 to 1,796 a frame to **295 to 355** (the mesh draws join a table window; only the compute dispatches are left), with the table filled while recording and one pass per run. So no split needed on my side for the clamp batch. The other items in this PR that still look interesting here are the CPU ones (`VICTORY_HEAP_SYNC_TABLES`, the wide fills, the texture checks) — this line's copies are 63–74 ms for ~190 MB a frame, write-bandwidth-bound at ~4 GB/s (`VICTORY_COPY_PLAIN=1` changes nothing), and its heap pass is 25–45 ms in the descriptor scan.
Author
Owner

@⁠Filip722 on GitHub · 2026-11-26 14:18 UTC · original

I backported the device-local flight-slot readback from 7406afb for a matched Series S replay on Bazzite 44 with GE-Proton11-14, vkd3d-proton 3.2.0 and an RTX 5060 Laptop GPU (8 GB, NVIDIA 615.78.08). Both arms used the same executable, stationary prison view and warmed seed, with relay stage 1 and the clamped gathering path from #1171. To exercise actual device-local copies on this GPU, both used a 1 MiB minimum copy size and a 96 MiB buffer budget.

54-second window Flight slots off Device-local flight slots
Unique completed Presents 271 277
FPS 5.017 5.206
Median / p95 Present interval 190 / 246 ms 186 / 221 ms
Median time fetching card pieces 32.3 ms 4.8 ms
Median copy-back phase 117.2 ms 66.6 ms
Minimum free VRAM 1,563 MiB 1,456 MiB

Mode 2 typically read back 295 pieces (~18.4 MiB) per frame, with no old-path landings or slot overflows reported in the measured window. The patched replay responded to camera input. The asset-free fixture read the expected bytes from two ranges on the copy queue after a direct-queue fence, and the fetch pipeline test passed on the hardware adapter. This comparison isolates the readback path on that older compatibility build.

Assisted by Codex (GPT-6.2-Sol High).

**@⁠Filip722** on GitHub · 2026-11-26 14:18 UTC · [original](https://github.com/fxceless/victory-fork/pull/995#issuecomment-7194608062) I backported the device-local flight-slot readback from `7406afb` for a matched Series S replay on Bazzite 44 with GE-Proton11-14, vkd3d-proton 3.2.0 and an RTX 5060 Laptop GPU (8 GB, NVIDIA 615.78.08). Both arms used the same executable, stationary prison view and warmed seed, with relay stage 1 and the clamped gathering path from #1171. To exercise actual device-local copies on this GPU, both used a 1 MiB minimum copy size and a 96 MiB buffer budget. | 54-second window | Flight slots off | Device-local flight slots | | --- | ---: | ---: | | Unique completed Presents | 271 | 277 | | FPS | 5.017 | 5.206 | | Median / p95 Present interval | 190 / 246 ms | 186 / 221 ms | | Median time fetching card pieces | 32.3 ms | 4.8 ms | | Median copy-back phase | 117.2 ms | 66.6 ms | | Minimum free VRAM | 1,563 MiB | 1,456 MiB | Mode 2 typically read back 295 pieces (~18.4 MiB) per frame, with no old-path landings or slot overflows reported in the measured window. The patched replay responded to camera input. The asset-free fixture read the expected bytes from two ranges on the copy queue after a direct-queue fence, and the fetch pipeline test passed on the hardware adapter. This comparison isolates the readback path on that older compatibility build. Assisted by Codex (GPT-6.2-Sol High).
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor.rs
  • crates/victory-gpu/src/descriptor/host.rs
  • crates/victory-gpu/src/draw.rs
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/indirect.rs
  • crates/victory-gpu/src/lib.rs
  • crates/victory-gpu/src/pipeline.rs
  • crates/victory-gpu/src/resource.rs
  • crates/victory-gpu/src/shadow.rs
  • crates/victory-gpu/src/texture.rs
  • crates/victory-gpu/src/tiles.rs
  • crates/victory-gpu/src/watch.rs
  • crates/victory-hle/src/modules/xgamesave.rs
  • crates/victory-hle/src/modules/xmem.rs
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/mod.rs
  • crates/victory-shader/src/emit/valu_tests.rs
  • crates/victory-shader/src/emit/wave64_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/995/head:github-bot/gh-995'
git switch 'github-bot/gh-995'

Merge

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