Tables made afresh copy their texture views from a cache of views made (VICTORY_TABLE_VIEW_CACHE=1, off) #1484

Closed
KainanP wants to merge 2 commits from upstream-pr/1484 into main
KainanP commented 2026-11-27 15:13:12 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by KainanP on 2026-11-27T15:13:12Z.


For #1379 (and the recording threads in #1083). Off by default: VICTORY_TABLE_VIEW_CACHE=1 turns it on.

What it changes. State::tables makes every table that holds a constant buffer view afresh, in dynamic slots, for each list that binds it. Each texture view in that table is made again each time: the placed texture and its host copy are looked up, the description is checked, and the view is created. LeonardoS11 counted 41,000-42,000 such views a frame on a 3080 Ti, at 18-21 µs a table bind. The world's tables show the same textures list after list.

With the switch on, a texture view is made once into a heap that shaders do not see. It is keyed by its record ((generation, index): the same record is the same view). A table's slot is then filled from there with CopyDescriptorsSimple of one slot.

Exact invalidation. A record can stay the same while what its view shows changes:

  • the texture's host copy can be let go when idle and made again (resource::let_go_idle), or another texture can be placed at the same memory;
  • the first level shown can change for a texture whose levels arrive on demand (crate::tiles).

An entry is copied only while both are the ones it was made from. Otherwise the view is made again. The host copy is identified by the address of its shared allocation. The entry keeps that allocation from being reused through a Weak, but it does not hold the texture, so an idle copy can still be let go (let_go_idle checks the strong count and the texture's references). Buffer views, unordered access and anything the host cannot make are made exactly as before. The cache has 64 shards × 1,024 slots, about 65,000 views; a full shard writes over its oldest slot.

Benchmark. pipeline::list_bench::table_bench (new, #[ignore], in the first commit) is the draw sequence of our VIctory list bench (KainanP/VIctory perf/list-call-bench), ported to the fork. Each draw binds a material table: one constant buffer view and five textures the title placed in memory, each table at its own place in the title's heap, 2,000 tables a list, half of them with the same contents as an earlier table. Each list is closed and reset every 2,000 draws, and the close is timed. Numbers are ns per draw for the whole sequence (table, root CBV, 4 constants, index buffer, draw). Each cell is the median of 9 interleaved processes, each the best of 5. RTX 4060 Laptop, i7-14650HX, main 9a9091d.

1 thread 5 threads at once (per thread)
main 11,126 17,459
VICTORY_TABLE_VIEW_CACHE=1 9,534 (−14 %) 14,237 (−18 %)
of which the table (draw minus the same sequence without one) 8,390 → 6,714 (−20 %) 12,405 → 9,043 (−27 %)

Inside a table (diagnostics build, TABLES laps, 1 thread), the five texture views go from 10.3 to 5.4-5.9 µs a table. The rest stays the same: making entries readable takes about 6 µs (readable: a texture's upload check and state, for each list), and the view lookups about 1 µs.

On the Intel UHD (spot check, 5 rounds, through a local adapter-selection hook that is not in this PR), the change is small: 11,241 → 10,977 ns at 1 thread and 15,878 → 15,376 at 5.

The machine had foreign load: a headless Chrome and three small Python jobs from other work, about 2 cores. Single runs ranged from 9.2 to 16-26 µs, which is why the cells are medians.

Tests.

  • descriptor::host::view_cache::tests::a_view_is_made_again_for_a_new_host_copy: a view is cached, its texture's host copy is let go and made again, and the next copy must make the view again and show the new copy (the slot's bytes equal a freshly made descriptor of the view). It also checks that the cache holds no strong reference to the copy. With the comparison of host copy and first level removed from the lookup, it fails, as checked on the RTX.
  • pipeline::list_bench::tables_show_their_views (not ignored) records 64 tables in three lists, with the cache off, then on twice. Every texture slot of every table made must hold exactly the descriptor the host makes of its view, and must hold that view's host texture.
  • Both pass on the RTX 4060 Laptop and on the Intel UHD. clippy -D warnings is clean with and without --all-features.

Asking for an in-game A/B. @Zignixx @LeonardoS11 (#1379), @MKmajster @CuteBooty (#1083): if you can, please run one scene with VICTORY_TABLE_VIEW_CACHE=0 and then =1. The diagnostics line of the tables (TABLES) should show the texture-view part shrink. What matters is whether the recording threads' time and the frame move, and whether the picture stays the same. A texture that goes black or stale after streaming would point to a missed invalidation.

The bench commit is shared with the numbers I posted on #1316, #1455, #1192 and #1443.

AI use: Claude Code (Claude Opus 5.5).

🤖 Generated with Claude Code

<!-- greyfinch-sync:fxceless/victory-fork:issue:5528933750 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1484). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-27T15:13:12Z. --- For #1379 (and the recording threads in #1083). Off by default: `VICTORY_TABLE_VIEW_CACHE=1` turns it on. **What it changes.** `State::tables` makes every table that holds a constant buffer view afresh, in dynamic slots, for each list that binds it. Each texture view in that table is made again each time: the placed texture and its host copy are looked up, the description is checked, and the view is created. LeonardoS11 counted 41,000-42,000 such views a frame on a 3080 Ti, at 18-21 µs a table bind. The world's tables show the same textures list after list. With the switch on, a texture view is made once into a heap that shaders do not see. It is keyed by its record (`(generation, index)`: the same record is the same view). A table's slot is then filled from there with `CopyDescriptorsSimple` of one slot. **Exact invalidation.** A record can stay the same while what its view shows changes: - the texture's host copy can be let go when idle and made again (`resource::let_go_idle`), or another texture can be placed at the same memory; - the first level shown can change for a texture whose levels arrive on demand (`crate::tiles`). An entry is copied only while both are the ones it was made from. Otherwise the view is made again. The host copy is identified by the address of its shared allocation. The entry keeps that allocation from being reused through a `Weak`, but it does not hold the texture, so an idle copy can still be let go (`let_go_idle` checks the strong count and the texture's references). Buffer views, unordered access and anything the host cannot make are made exactly as before. The cache has 64 shards × 1,024 slots, about 65,000 views; a full shard writes over its oldest slot. **Benchmark.** `pipeline::list_bench::table_bench` (new, `#[ignore]`, in the first commit) is the draw sequence of our VIctory list bench (KainanP/VIctory `perf/list-call-bench`), ported to the fork. Each draw binds a material table: one constant buffer view and five textures the title placed in memory, each table at its own place in the title's heap, 2,000 tables a list, half of them with the same contents as an earlier table. Each list is closed and reset every 2,000 draws, and the close is timed. Numbers are ns per draw for the whole sequence (table, root CBV, 4 constants, index buffer, draw). Each cell is the median of 9 interleaved processes, each the best of 5. RTX 4060 Laptop, i7-14650HX, `main` 9a9091d. | | 1 thread | 5 threads at once (per thread) | |---|---|---| | `main` | 11,126 | 17,459 | | `VICTORY_TABLE_VIEW_CACHE=1` | **9,534** (−14 %) | **14,237** (−18 %) | | of which the table (draw minus the same sequence without one) | 8,390 → 6,714 (−20 %) | 12,405 → 9,043 (−27 %) | Inside a table (diagnostics build, `TABLES` laps, 1 thread), the five texture views go from 10.3 to 5.4-5.9 µs a table. The rest stays the same: making entries readable takes about 6 µs (`readable`: a texture's upload check and state, for each list), and the view lookups about 1 µs. On the Intel UHD (spot check, 5 rounds, through a local adapter-selection hook that is not in this PR), the change is small: 11,241 → 10,977 ns at 1 thread and 15,878 → 15,376 at 5. The machine had foreign load: a headless Chrome and three small Python jobs from other work, about 2 cores. Single runs ranged from 9.2 to 16-26 µs, which is why the cells are medians. **Tests.** - `descriptor::host::view_cache::tests::a_view_is_made_again_for_a_new_host_copy`: a view is cached, its texture's host copy is let go and made again, and the next copy must make the view again and show the new copy (the slot's bytes equal a freshly made descriptor of the view). It also checks that the cache holds no strong reference to the copy. With the comparison of host copy and first level removed from the lookup, it fails, as checked on the RTX. - `pipeline::list_bench::tables_show_their_views` (not ignored) records 64 tables in three lists, with the cache off, then on twice. Every texture slot of every table made must hold exactly the descriptor the host makes of its view, and must hold that view's host texture. - Both pass on the RTX 4060 Laptop and on the Intel UHD. clippy `-D warnings` is clean with and without `--all-features`. **Asking for an in-game A/B.** @Zignixx @LeonardoS11 (#1379), @MKmajster @CuteBooty (#1083): if you can, please run one scene with `VICTORY_TABLE_VIEW_CACHE=0` and then `=1`. The diagnostics line of the tables (`TABLES`) should show the texture-view part shrink. What matters is whether the recording threads' time and the frame move, and whether the picture stays the same. A texture that goes black or stale after streaming would point to a missed invalidation. The bench commit is shared with the numbers I posted on #1316, #1455, #1192 and #1443. _AI use: Claude Code (Claude Opus 5.5)._ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
KainanP commented 2026-11-27 15:35:21 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by KainanP on 2026-11-27T15:35:21Z.


Closing this: main 5dbf5ce (the VIctory-NVIDIA tree) already has a cache of views made for tables, on by default.

That is this PR's idea. The only difference is the scope. Main's cache lasts for one recording, which also makes invalidation trivial. This PR kept entries across lists, guarded by the host copy and first-level checks. Reuse across recordings would be a separate, smaller change on top of ListViews. It is worth proposing only if a profile on the new tree shows view creation still costs much after the first table of each list. Thanks!

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7222240323 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1484#issuecomment-7222240323). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-27T15:35:21Z. --- Closing this: `main` 5dbf5ce (the VIctory-NVIDIA tree) already has a cache of views made for tables, on by default. - [`ListViews`](https://github.com/fxceless/victory-fork/blob/5dbf5ce226690bb0f1b2949dc8ef822617ae81ea/crates/victory-gpu/src/descriptor/host.rs#L6890-L6905) / [`HostHeap::make_listed`](https://github.com/fxceless/victory-fork/blob/5dbf5ce226690bb0f1b2949dc8ef822617ae81ea/crates/victory-gpu/src/descriptor/host.rs#L3459-L3464): a thread makes each view a list's tables hold once per recording, in a heap the shaders do not see, keyed by the record. It then copies that descriptor into each fresh table slot ([`State::tables`](https://github.com/fxceless/victory-fork/blob/5dbf5ce226690bb0f1b2949dc8ef822617ae81ea/crates/victory-gpu/src/draw.rs#L4590-L4594), [`VICTORY_LIST_VIEWS`](https://github.com/fxceless/victory-fork/blob/5dbf5ce226690bb0f1b2949dc8ef822617ae81ea/crates/victory-gpu/src/descriptor/host.rs#L6959-L6963), on unless `=0`). That is this PR's idea. The only difference is the scope. Main's cache lasts for one recording, which also makes invalidation trivial. This PR kept entries across lists, guarded by the host copy and first-level checks. Reuse across recordings would be a separate, smaller change on top of `ListViews`. It is worth proposing only if a profile on the new tree shows view creation still costs much after the first table of each list. Thanks! _AI use: Claude Code (Claude Opus 5.5)._

Pull request closed

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!1484
No description provided.