Skip to content

GPU: fresh descriptor tables take only their used range (port of upstream #1349) - #218

Closed
m335671 wants to merge 1 commit into
fxceless:mainfrom
m335671:port/trim-fresh-tables
Closed

m335671 wants to merge 1 commit into
fxceless:mainfrom
m335671:port/trim-fresh-tables

Conversation

@m335671

@m335671 m335671 commented Nov 24, 2026

Copy link
Copy Markdown

Summary

A fresh descriptor table took dynamic slots for entries 0..=last used. A draw that reads entries 120..=123 of a table therefore held 124 slots. On a capped NVIDIA view heap (2^18 dynamic slots), heavy scenes asked for more than the pool holds:

WARN no free dynamic descriptor slots: a table is not made n=26
WARN a draw whose descriptor table found no free slots is dropped

The indirect draws behind those tables were then dropped (indirect kind 0/2: prepare failed, about 190 + 120–285 per frame) until the scene got lighter. In the prologue that shows as floors and walls disappearing a few minutes in.

This ports the table trimming of upstream Marvisak/VIctory#1349 (wrothgaril). The 2^18 reservation part of that PR is already in this fork. The port is adapted to this fork's picked indices (selected).

Changes

crates/victory-gpu/src/draw.rs:

  • fresh_table_range: a fresh table spans from its first used entry or picked index to its last, instead of from entry 0.
  • Its virtual slot 0 moves back by that start (base = first - start), so entry k still lies at base + k and the translated shaders' (user_data + offset) >> 5 lands on the slots taken. start is clamped to the mirrored count, so base stays whole.
  • The cache key hashes only the used range, plus its start. Only start..end is made, and the title-slot bookkeeping (texture_slot_tabled, mirror) covers only that range.
  • Tests:
    • fresh_tables_take_their_used_range: used entries, picked indices on either side, no entry, and the clamp.
    • trimmed_tables_index_the_slots_they_take: on a real host heap, entries 120 and 123 land on first and first + 3, and the next table starts at first + 4 (returns early without a GPU).

Verification

  • NVIDIA GeForce RTX 4070 12 GB (driver 32.0.16.2124), AMD Ryzen 9 7900, 32 GB, Windows 11 Pro 26300, Rust 1.97.1. Branch on 2119b0e.
  • cargo clippy --workspace --all-targets --locked -- -D warnings and with --all-features: 0 warnings.
  • cargo test --workspace --locked: 498 passed, 0 failed, 7 ignored (both new tests included).
  • cargo xtask policy: 169 files ok.
  • In game (Series X, prologue checkpoint, VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024, warm pipeline library, diagnostics builds; counts only):
without (base + #77) with this change (+ #77, #51, #81)
run length ~11 min ~5 min and ~10 min
dynamic slots: … refused (sum of samples) 3,504 0 and 0
no free dynamic descriptor slots yes (21:39:31) none
indirect … prepare failed ~190 + 120–285 / frame for ~1 min none
peak tables asked per sample 26,962 18,574 / 18,782
runs walls around the window
without this change (2 release, 1 diagnostics) 3 missing in all 3: sky on both sides, posters missing, stair-stepped stale patches where nothing was drawn
with this change 2 present in both, posters too

An earlier run without the change (on 1684989 + #77) had the room's walls at first, before the pool ran out. So walls are missing much more often without it, not always.

I could not compare one fixed frame: VICTORY_CAPTURE_FRAMES frame numbers fall at different moments from run to run, because loading time varies.

Not tested / caveats

  • The runs with this change did not reach the same peak demand as the run without (18.8k vs 27k tables asked), so the scene with the worst starvation is not covered one-to-one.
  • With the walls present, closed rooms are dark (no ray-traced or indirect light yet, as the README says). That is not a change in lighting.
  • A shader that indexes a descriptor array below its first used entry or picked index would now read outside the range made. Upstream #1349 takes the same range; I saw no a table entry without a view and no new warning in these runs.
  • AMD, other NVIDIA cards, scenes past the prologue's first minutes.

AI use: Claude Code (Claude Opus 5.5) found the starvation in the diagnostics logs, ported and adapted the change, wrote the tests, ran the checks and the title on my machine, and wrote this description.

🤖 Generated with Claude Code

A fresh table took dynamic slots for entries 0..=last used, so a draw that
reads entries 120..=123 held 124 slots. In heavy scenes on a capped NVIDIA
view heap (2^18 dynamic slots) the frame then asked for more than the pool
holds, tables were refused ("no free dynamic descriptor slots"), and the
indirect draws behind them were dropped until the scene got lighter.

A fresh table now takes from its first used entry or picked index to its
last, and its virtual slot 0 is moved back by that start, so entry k still
lies at base + k. The start is clamped to the mirrored count so base stays
whole. After upstream VIctory PR #1349 by wrothgaril, adapted to this
fork's picked indices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@m335671
m335671 force-pushed the port/trim-fresh-tables branch from 7e54c28 to fa5ec43 Compare November 25, 2026 06:58
@m335671

m335671 commented Nov 25, 2026

Copy link
Copy Markdown
Author

Rebased onto main 8dd30ab (now fa5ec43). The only conflict was the end of draw.rs, where main added depth_bounds (#82) at the same place as this PR's helper and tests. Both are kept. The loop over the table keeps title + k for the picked-index texture slots added in a803c87, with k in start..end.

  • cargo test -p victory-gpu --release: 133 passed, 0 failed, 3 ignored (the two tests of this PR included).
  • cargo clippy -p victory-gpu: no new warning.

A data point against the need for it: one run of 8dd30ab without this PR (RTX 4070, diagnostics build, ~7 minutes to the first gameplay room) had 0 refused dynamic slots (11,277 tables asked per sample), and the walls were there. Before, the refusals started some minutes into a run, so a run this short does not show whether main still needs the trim. I'll post a longer run when I have one.

AI use: Claude Code (Claude Opus 5.5) did the rebase and ran the tests and the run on my machine, and wrote this comment.

@m335671

m335671 commented Nov 25, 2026

Copy link
Copy Markdown
Author

A/B on main 8dd30ab, RTX 4070, diagnostics build, the first gameplay room, 20 minutes each: without this PR, 207 samples and 0 refused dynamic slots. With it, 216 samples and 0 refused. The walls were there in both, at 1.8 against 1.9 fps. The overflow this PR fixed on 2119b0e no longer happens on main here, so I'm closing it. If refusals come back in a heavier scene, it can be reopened.

AI use: Claude Code (Claude Opus 5.5) ran the A/B on my machine and wrote this comment.

@m335671 m335671 closed this Nov 25, 2026
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.

1 participant