Tables made afresh copy their texture views from a cache of views made (VICTORY_TABLE_VIEW_CACHE=1, off) #1484
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1484"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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=1turns it on.What it changes.
State::tablesmakes 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 withCopyDescriptorsSimpleof one slot.Exact invalidation. A record can stay the same while what its view shows changes:
resource::let_go_idle), or another texture can be placed at the same memory;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_idlechecks 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/VIctoryperf/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,main9a9091d.mainVICTORY_TABLE_VIEW_CACHE=1Inside a table (diagnostics build,
TABLESlaps, 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.-D warningsis 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=0and 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
Imported from fxceless/victory-fork. Originally posted by KainanP on 2026-11-27T15:35:21Z.
Closing this:
main5dbf5ce(the VIctory-NVIDIA tree) already has a cache of views made for tables, on by default.ListViews/HostHeap::make_listed: 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,VICTORY_LIST_VIEWS, 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