NVIDIA: dynamic descriptor slots (word search, early release), a pool barrier fix, a diagnostics counter #237

Open
github-bot wants to merge 5 commits from github-bot/gh-237 into main AGit
Owner

@⁠HenriqueSBueno on GitHub · 2026-11-26 12:16 UTC · original
HenriqueSBueno:contrib/nvidia-descriptor-slots → main · +216 −29 · 5 files · 5 commits · open

Four small changes found while running this fork on NVIDIA (RTX 3080 10 GB, i5-10400F, 32 GB, Windows 11). All numbers: same save, 9-minute runs, median of the last 30 frame-rate lines.

1. Dynamic descriptor slots searched a word at a time

NVIDIA caps shader-visible view heaps at 1,000,000 views, so only 2^18 dynamic slots fit (a quarter of what an uncapped AMD heap gets). The ring was a Vec<bool> walked one slot at a time under the lock every recording thread takes; when it fragments, every refused table walks the whole ring. Taken keeps one bit per slot and skips whole free or taken words. A failed search now logs (at powers of two) the free slots, the longest free run and slots given out / back.

before after
slot search (all recording threads) 558–572 ms/frame 73–85 ms/frame
recording (all threads) 830–852 ms/frame 350–384 ms/frame
median frame 185 ms 160 ms

A unit test checks it against the slot-at-a-time search on random patterns across word ends.

2. A landed flight's table slots go back before the bury lag (VICTORY_EARLY_TABLES=1, off by default)

The counters above showed ~239,000 of 262,144 slots held while a frame takes ~38,000: landed flights keep their lists, and with them their table slots, for VICTORY_BURY_LAG (64 submissions, about four frames). 2,200–2,400 tables a frame were refused (each drops its draw) with 45,000–69,000 slots free, longest run 100–163. Fewer lists in flight (VICTORY_LATE_WAIT_LISTS=128) and per-list chunks of 256 did not change the refusals. A landed flight's fence is done, so its table slots are not read again; the lag still applies to the lists and memory.

before after
tables refused per frame ~2,300 0
slot search 73–85 ms 4–6 ms
draws per frame ~2,800 ~4,000
picture after 9 min draws missing, whites out later complete

(The frame time goes up at first because the dropped draws are drawn again.)

3. Diagnostics: differing pieces counted on the relay and wide copy-back paths

BackDiffer was counted only on the shadow path, so the frame account said "0 pieces that differ" while the relay scans find 600–970 a frame.

4. The first upload's aliasing barrier only for textures made in a pool block

With the pool on, the first upload into any title-filled texture records an aliasing barrier. A committed texture (one the block refused, or a stand-in made elsewhere) cannot take one: the host refuses to close the list (E_INVALIDARG; debug layer id 528, "cannot use aliasing barrier since committed resource memory cannot be aliased"). Seen as a stop about three minutes into a run together with the PC FidelityFX upscaler port. pool::pooled tells a block's texture by the private data it already carries.

Built with --profile diag --features diagnostics; the gpu crate's slot tests pass and clippy is clean for the touched files. Related measurement for small cards (no code here): on a ≤12 GiB budget, VICTORY_CARD_BUFFERS_MIN_MB=1 took the median frame from 191 to ~85 ms; 64 KB left the world undrawn.

AI-assisted (Claude Code)

**@⁠HenriqueSBueno** on GitHub · 2026-11-26 12:16 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/237) `HenriqueSBueno:contrib/nvidia-descriptor-slots` → `main` · +216 −29 · 5 files · 5 commits · open Four small changes found while running this fork on NVIDIA (RTX 3080 10 GB, i5-10400F, 32 GB, Windows 11). All numbers: same save, 9-minute runs, median of the last 30 frame-rate lines. ### 1. Dynamic descriptor slots searched a word at a time NVIDIA caps shader-visible view heaps at 1,000,000 views, so only 2^18 dynamic slots fit (a quarter of what an uncapped AMD heap gets). The ring was a `Vec<bool>` walked one slot at a time under the lock every recording thread takes; when it fragments, every refused table walks the whole ring. `Taken` keeps one bit per slot and skips whole free or taken words. A failed search now logs (at powers of two) the free slots, the longest free run and slots given out / back. | | before | after | |---|---|---| | slot search (all recording threads) | 558–572 ms/frame | 73–85 ms/frame | | recording (all threads) | 830–852 ms/frame | 350–384 ms/frame | | median frame | 185 ms | 160 ms | A unit test checks it against the slot-at-a-time search on random patterns across word ends. ### 2. A landed flight's table slots go back before the bury lag (`VICTORY_EARLY_TABLES=1`, off by default) The counters above showed ~239,000 of 262,144 slots held while a frame takes ~38,000: landed flights keep their lists, and with them their table slots, for `VICTORY_BURY_LAG` (64 submissions, about four frames). 2,200–2,400 tables a frame were refused (each drops its draw) with 45,000–69,000 slots free, longest run 100–163. Fewer lists in flight (`VICTORY_LATE_WAIT_LISTS=128`) and per-list chunks of 256 did not change the refusals. A landed flight's fence is done, so its table slots are not read again; the lag still applies to the lists and memory. | | before | after | |---|---|---| | tables refused per frame | ~2,300 | 0 | | slot search | 73–85 ms | 4–6 ms | | draws per frame | ~2,800 | ~4,000 | | picture after 9 min | draws missing, whites out later | complete | (The frame time goes up at first because the dropped draws are drawn again.) ### 3. Diagnostics: differing pieces counted on the relay and wide copy-back paths `BackDiffer` was counted only on the shadow path, so the frame account said "0 pieces that differ" while the relay scans find 600–970 a frame. ### 4. The first upload's aliasing barrier only for textures made in a pool block With the pool on, the first upload into any title-filled texture records an aliasing barrier. A committed texture (one the block refused, or a stand-in made elsewhere) cannot take one: the host refuses to close the list (`E_INVALIDARG`; debug layer id 528, "cannot use aliasing barrier since committed resource memory cannot be aliased"). Seen as a stop about three minutes into a run together with the PC FidelityFX upscaler port. `pool::pooled` tells a block's texture by the private data it already carries. Built with `--profile diag --features diagnostics`; the gpu crate's slot tests pass and clippy is clean for the touched files. Related measurement for small cards (no code here): on a ≤12 GiB budget, `VICTORY_CARD_BUFFERS_MIN_MB=1` took the median frame from 191 to ~85 ms; 64 KB left the world undrawn. AI-assisted (Claude Code)
The dynamic slot ring was a Vec<bool> walked one slot at a time under the
lock every recording thread takes. On hosts whose view heaps stop at
1,000,000 views (NVIDIA), only 2^18 dynamic slots fit, they fragment, and
every table that finds no run walks the whole ring before it is refused.

Taken keeps a bit per slot and skips whole free or whole taken words. A
failed search now logs (at powers of two) the free slots and the longest
free run, which tells fragmentation from exhaustion.

Boat scene, RTX 3080, AMD fork 2080 SUPER profile, same save, 9 minutes:
slot search 558-572 -> 73-85 ms per frame (all recording threads),
recording 830-852 -> 350-384 ms, median frame 185 -> 160 ms.
Refusals are fragmentation: 45,000-69,000 slots free, longest run 100-163.

AI-assisted (Claude Code)
A flight's lists keep their descriptor table slots until the lists are
recycled, 64 submissions (about four frames) after the flight landed. The
lag is for memory and lists the card may still read; a landed flight's
fence is done, so its slots are not read again.

On an NVIDIA host (2^18 dynamic slots) about six frames of tables were
held: 239,000 slots taken while a frame takes 38,000 (run ds-4, from the
new given-out/given-back counters in the failed-search log), and 2,200
tables a frame were refused, each dropping its draw.

VICTORY_EARLY_TABLES=1 gives them back at landing. Boat scene, RTX 3080,
AMD fork 2080 SUPER profile, 9 minutes: 0 tables refused (was 2,200-2,400),
slot search 4-6 ms per frame, 4,000 draws a frame drawn (was 2,800), full
picture with no whiteout at 9 minutes; median frame 160 -> 191 ms as the
restored draws are now drawn.

AI-assisted (Claude Code)
BackDiffer was only counted on the shadow path, so the frame account line
said '0 pieces that differ' for the relay's scans that find 600-970 a frame
in the boat scene.

AI-assisted (Claude Code)
With the texture pool on, the first upload into any texture the title fills
recorded an aliasing barrier, as if every such texture lay in a block. A
committed one (the block refused it, or the PC upscaler's RGB9E5 stand-in,
which the host cannot write as the title asks) takes no aliasing barrier:
the host refused to close the list (E_INVALIDARG; debug layer id 528, "cannot
use aliasing barrier since committed resource memory cannot be aliased")
and the process stopped about three minutes into a Series S run.

pool::pooled tells a block's texture by the private data it carries.

AI-assisted (Claude Code)
AI-assisted (Claude Code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 12:21:33 +00:00
Author
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-26 18:28 UTC · original

A test of this PR on another NVIDIA card: RTX 2070 SUPER 8 GB (Turing, driver 621.14, 32-lane waves, host view heaps capped at 1,000,000), 32 GB RAM, Windows 11. Tested as part of a local merge of this PR and about 30 other open PRs onto main c9c932c, diagnostics build, default play.ps1 settings.

The slots still run out under load. About 3 minutes into the prologue, one window of frames hits no free dynamic descriptor slots: a table is not made n=27, and this PR's counter reads:

dynamic slots: 12063 tables asked, 91 refused, 0.9 ms searching

That's over 8 frames with 45,057 list calls (0.6 fps there). Earlier, quieter windows had 0 refused, with searching at or below 1 ms.

Those refusals are what #70 sees as indirect kind 0/1/2/10: prepare failed. With a diagnostics change that names the failing exit, every indirect drop in this run was descriptor table: no free slots (354 dispatches, 55 mesh dispatches and 4 draws in that frame). Details are in #70.

Compared with main without this PR (a 4.5-minute run on the same card), slot shortages came up in more and bigger windows: up to 2,504 dropped mesh dispatches in one frame. The runs differ in length, place in the game and frame rate, so I can't put a number on the improvement. It looks like this PR helps, but the pool can still run out on an 8 GB card.

This comment was written with AI assistance (Claude Code).

**@⁠Jesper-Andersson** on GitHub · 2026-11-26 18:28 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/237#issuecomment-7200504467) A test of this PR on another NVIDIA card: **RTX 2070 SUPER 8 GB** (Turing, driver 621.14, 32-lane waves, host view heaps capped at 1,000,000), 32 GB RAM, Windows 11. Tested as part of a local merge of this PR and about 30 other open PRs onto main `c9c932c`, diagnostics build, default `play.ps1` settings. **The slots still run out under load.** About 3 minutes into the prologue, one window of frames hits `no free dynamic descriptor slots: a table is not made n=27`, and this PR's counter reads: ``` dynamic slots: 12063 tables asked, 91 refused, 0.9 ms searching ``` That's over 8 frames with 45,057 list calls (0.6 fps there). Earlier, quieter windows had 0 refused, with searching at or below 1 ms. Those refusals are what #70 sees as `indirect kind 0/1/2/10: prepare failed`. With a diagnostics change that names the failing exit, every indirect drop in this run was `descriptor table: no free slots` (354 dispatches, 55 mesh dispatches and 4 draws in that frame). Details are in #70. Compared with main without this PR (a 4.5-minute run on the same card), slot shortages came up in more and bigger windows: up to 2,504 dropped mesh dispatches in one frame. The runs differ in length, place in the game and frame rate, so I can't put a number on the improvement. It looks like this PR helps, but the pool can still run out on an 8 GB card. This comment was written with AI assistance (Claude Code).
Author
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-26 23:10 UTC · original

A follow-up to my comment above, this time with this PR alone on main: with VICTORY_EARLY_TABLES=1 the slots no longer run out on an 8 GB card. With the default (off), they still do.

Setup: RTX 2070 SUPER 8 GB (driver 621.14, host view heap capped at 1,000,000), Ryzen 7 5800X, 32 GB, Windows 11. Builds:

  • base: main 126acb3 + #360 (names the failing exit of prepare failed) + #203 (DLSS).
  • tip: base + this PR (77e4543). The two differ only in this PR's files.

Diagnostics build, play.ps1 settings of 126acb3, Series S profile with DLSS (quality 2). Each run is the same stretch of the open world, about 1 to 1.5 minutes after loading. The numbers are the range over the 5 s lines in the world.

per frame base tip, defaults tip, VICTORY_EARLY_TABLES=1
tables asked 11,300–14,400 9,000–14,700 9,900–15,500
tables refused 1,950–3,620 (20–27%) 1,130–3,980 (10–27%) 0 (every line)
slot search 29–61 ms 2.3–4.8 ms 0.7–1.6 ms
indirect draws dropped (prepare failed (descriptor table: no free slots)) 1,440–2,420 0–2,340, mostly 800–2,000 0 (every line in the world)
draws 2,600–4,600 2,800–4,600 2,900–7,100
frame 2.2–4.0 fps (248–456 ms) 1.7–4.1 fps (242–588 ms) 1.9–3.0 fps (329–515 ms)
on screen meshes vanish and come back the same no missing meshes
  • The word search alone makes the search 10 to 15 times faster, but at its default the pool runs out as often as on main. VICTORY_EARLY_TABLES=1 is what removes the refusals here, as in your RTX 3080 numbers.
  • With it on, the log never says "a list ran again after its descriptor tables were given back", and nothing crashed or was removed.
  • The frame time goes up somewhat with it on, as you saw: the draws that used to be dropped get drawn. Preparing stayed about the same (51–103 ms a frame with it on, 48–127 ms on base), so the extra time isn't spent preparing. These are single runs of 1 to 1.5 minutes, so the fps ranges are rough.
  • Another run here, in a different stretch of the world, with a larger dynamic part of the capped heap (393,215 title / 606,784 dynamic; mgrein/victory-nvidia d4b8094a, after DexNom/VIctory#68, the same idea as #96's heap sizing) on top of this PR with VICTORY_EARLY_TABLES=1, also had 0 refused and 0 indirect dropped. On this card the early release alone is enough with 2^18 slots.

So on capped (NVIDIA) heaps, VICTORY_EARLY_TABLES=1 looks worth having on by default.

Separate from this PR but in the same code: #392, a list gives its dynamic slots back to whatever heap now has the old heap's address.

Not checked: AMD (no card here), runs longer than 1.5 minutes in the world, and Series X.

This comment was written with AI assistance (Claude Code).

**@⁠Jesper-Andersson** on GitHub · 2026-11-26 23:10 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/237#issuecomment-7205318874) A follow-up to my comment above, this time with this PR alone on main: **with `VICTORY_EARLY_TABLES=1` the slots no longer run out on an 8 GB card. With the default (off), they still do.** Setup: RTX 2070 SUPER 8 GB (driver 621.14, host view heap capped at 1,000,000), Ryzen 7 5800X, 32 GB, Windows 11. Builds: - **base:** main `126acb3` + #360 (names the failing exit of `prepare failed`) + #203 (DLSS). - **tip:** base + this PR (`77e4543`). The two differ only in this PR's files. Diagnostics build, `play.ps1` settings of `126acb3`, Series S profile with DLSS (quality 2). Each run is the same stretch of the open world, about 1 to 1.5 minutes after loading. The numbers are the range over the 5 s lines in the world. | per frame | base | tip, defaults | tip, `VICTORY_EARLY_TABLES=1` | |---|---|---|---| | tables asked | 11,300–14,400 | 9,000–14,700 | 9,900–15,500 | | tables refused | 1,950–3,620 (20–27%) | 1,130–3,980 (10–27%) | **0** (every line) | | slot search | 29–61 ms | 2.3–4.8 ms | 0.7–1.6 ms | | indirect draws dropped (`prepare failed (descriptor table: no free slots)`) | 1,440–2,420 | 0–2,340, mostly 800–2,000 | **0** (every line in the world) | | draws | 2,600–4,600 | 2,800–4,600 | 2,900–7,100 | | frame | 2.2–4.0 fps (248–456 ms) | 1.7–4.1 fps (242–588 ms) | 1.9–3.0 fps (329–515 ms) | | on screen | meshes vanish and come back | the same | no missing meshes | - The word search alone makes the search 10 to 15 times faster, but at its default the pool runs out as often as on main. `VICTORY_EARLY_TABLES=1` is what removes the refusals here, as in your RTX 3080 numbers. - With it on, the log never says "a list ran again after its descriptor tables were given back", and nothing crashed or was removed. - The frame time goes up somewhat with it on, as you saw: the draws that used to be dropped get drawn. Preparing stayed about the same (51–103 ms a frame with it on, 48–127 ms on base), so the extra time isn't spent preparing. These are single runs of 1 to 1.5 minutes, so the fps ranges are rough. - Another run here, in a different stretch of the world, with a larger dynamic part of the capped heap (393,215 title / 606,784 dynamic; mgrein/victory-nvidia `d4b8094a`, after DexNom/VIctory#68, the same idea as #96's heap sizing) on top of this PR with `VICTORY_EARLY_TABLES=1`, also had 0 refused and 0 indirect dropped. On this card the early release alone is enough with 2^18 slots. So on capped (NVIDIA) heaps, `VICTORY_EARLY_TABLES=1` looks worth having on by default. Separate from this PR but in the same code: #392, a list gives its dynamic slots back to whatever heap now has the old heap's address. Not checked: AMD (no card here), runs longer than 1.5 minutes in the world, and Series X. This comment was written with AI assistance (Claude Code).
Author
Owner

@⁠akimfomin on GitHub · 2026-11-26 23:30 UTC · original

The current rebase of #237 onto 014d52dedf837d1ac660a0bd256c4704be9eeb40 conflicts in host.rs and texture.rs. PortBridge checked 77e4543 against that exact Git tree. Jesper's isolated RTX 2070 SUPER run establishes the slot-exhaustion benefit of early release. I also verified that the #237 head still releases ranges by heap address alone, the separate lifetime case in #392.

After resolving the two files, carry the fxceless #1324 two-heaps regression to verify early release does not free another heap's live range. The source check establishes the missing identity guard. It does not attribute a 2070 artifact to it. PortBridge · AI-assisted comparison.

**@⁠akimfomin** on GitHub · 2026-11-26 23:30 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/237#issuecomment-7205598787) The current rebase of #237 onto `014d52dedf837d1ac660a0bd256c4704be9eeb40` conflicts in `host.rs` and `texture.rs`. PortBridge checked `77e4543` against that exact Git tree. Jesper's [isolated RTX 2070 SUPER run](https://git.gtahub.st/github/avatarmanz--VIctory-7900XTX/pulls/237) establishes the slot-exhaustion benefit of early release. I also verified that [the #237 head still releases ranges by heap address alone](https://github.com/avatarmanz/VIctory-7900XTX/blob/77e4543121a687aa17d30347f9ed161bb327c818/crates/victory-gpu/src/descriptor.rs#L784-L802), the separate lifetime case in [#392](https://git.gtahub.st/github/avatarmanz--VIctory-7900XTX/issues/392). After resolving the two files, carry the [fxceless #1324 two-heaps regression](https://github.com/fxceless/victory-fork/pull/1324) to verify early release does not free another heap's live range. The source check establishes the missing identity guard. It does not attribute a 2070 artifact to it. [PortBridge](https://github.com/akimfomin/PortBridge/issues/98) · AI-assisted comparison.
Author
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-26 23:49 UTC · original

A correction to my last comment: main already does part 2. Since 1e72861 (now in main 014d52d), a landed flight's lists give their tables' slots back through HostList::release_tables() in both settle paths (host.rs:5165 and :5635), always, with no switch. That's what VICTORY_EARLY_TABLES=1 does here, so the "on by default" I suggested is already main's behaviour. It's also probably why this PR now conflicts in host.rs and list.rs.

From reading main at 014d52d, the other three parts still apply:

  1. The slot search: main still keeps the dynamic slots as a Vec<bool> searched one slot at a time (descriptor/host.rs:180). In my runs above the word search alone took the search from 29–61 ms to 2.3–4.8 ms a frame.
  2. BackDiffer is still counted only on the shadow path (shadow.rs:3410).
  3. With the pool on, the first upload into a texture still records an aliasing barrier whatever the texture is (host.rs:6971), committed ones included.

So a rebase onto main could drop part 2 and keep 1, 3 and 4. I haven't run main 014d52d itself in game. This is from the code only.

This comment was written with AI assistance (Claude Code).

**@⁠Jesper-Andersson** on GitHub · 2026-11-26 23:49 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/237#issuecomment-7205899562) A correction to my last comment: main already does part 2. Since 1e72861 (now in main `014d52d`), a landed flight's lists give their tables' slots back through `HostList::release_tables()` in both settle paths (`host.rs:5165` and `:5635`), always, with no switch. That's what `VICTORY_EARLY_TABLES=1` does here, so the "on by default" I suggested is already main's behaviour. It's also probably why this PR now conflicts in `host.rs` and `list.rs`. From reading main at `014d52d`, the other three parts still apply: 1. The slot search: main still keeps the dynamic slots as a `Vec<bool>` searched one slot at a time (`descriptor/host.rs:180`). In my runs above the word search alone took the search from 29–61 ms to 2.3–4.8 ms a frame. 3. `BackDiffer` is still counted only on the shadow path (`shadow.rs:3410`). 4. With the pool on, the first upload into a texture still records an aliasing barrier whatever the texture is (`host.rs:6971`), committed ones included. So a rebase onto main could drop part 2 and keep 1, 3 and 4. I haven't run main `014d52d` itself in game. This is from the code only. This comment was written with AI assistance (Claude Code).
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/texture.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/237/head:github-bot/gh-237'
git switch 'github-bot/gh-237'

Merge

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