~88,800 Create*View per frame on a 4070; a CPU-heap copy cache hits 76% (measurement and a lead) #1161
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork#1161
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@xunbreakablex on GitHub · 2026-11-25 22:08 UTC · original
Needs human attention: one machine, one run per arm, and the speed number is for a package of four switches, so this is a measurement of how often the layer creates views and a lead, not a proposal to merge anything.
AI-assisted (Claude); runs on my machine: RTX 4070 (undervolted, 100 W limit), Ryzen 5 5600 at 3.95 GHz (6 cores), Windows 11, driver 621.01, Series X profile. Tree:
465b94fplus a few switched-off commits of mine (diagnostics build), steady window world +300..+480 s.How many views the layer creates. Every shader-visible slot gets its descriptor from a fresh
Create*View(descriptor/host.rs:make(),buffer_srv/buffer_uav,raw_at/raw_uav_at,constant_at, thenull_*helpers);CopyDescriptorsSimpleis used only to fill new heaps with null views. With a counter on those calls: about 88,800Create*Viewper frame at ~4,700 draws in the cell scene. vkd3d-proton's author measured a view creation at 50-100x the cost of a descriptor copy (https://themaister.net/blog/2021/11/), and Flamingo (FLAMINGO.md, run 93/94) put the driver's descriptor making at ~8.6% of the frame. As far as I can find, no open PR here caches created views (#807 fixesHostHeap::copiedinvalidation, a different thing).What a cache does. I wrote a switch, off by default, that creates each distinct SRV/UAV (optionally CBV) once in a CPU-only heap, keyed by exactly what the create call would receive (host resource, view description; address and size for CBVs), and fills slots with
CopyDescriptorsSimple. Entries hold a reference on their resource, are forgotten when the resource's host copy is dropped, and are swept after 2 unused frames; the table is bounded. In the run: 69,400 views per frame copied from the cache, 22,100 created (76% hits).Speed: I only have it inside a package with three other switches (
CARD_HASH_WIDEfrom #1014,INDIRECT_GATHER, a barrier-group deferral of mine that turned out to do almost nothing): 144.9 ms vs 162.5 ms per frame for the same set without the four (−17.6 ms, one run each). I cannot say how much of that is the view cache; #1014's own effect on the card is large in the same run. A run with the view cache alone is next.Picture: the cell-window shot looked the same in both runs by the measures I use (black ratio, a stair-edge measure); a stale copy would show as wrong or flickering textures, which I did not see in one run.
The branch is local; I can push it if someone wants to try it or wants the counter alone.
@xunbreakablex on GitHub · 2026-11-26 07:25 UTC · original
Result of the run I said was next, and a correction (AI-assisted, Claude; RTX 4070 (undervolted), Ryzen 5 5600 at 3.95 GHz, same binary as above, one warm-up run discarded, then one run each, steady window world +300..+480 s):
So the cache cuts the device's view creation by 77% but the frame does not move (-1.6 ms, inside the noise): on this machine creating views is not on the critical path. Correction: the "144.9 vs 162.5 ms" in the issue text was almost certainly run-to-run drift, not the package: today's base-set run alone gave 143.6 ms. I am closing this as measured and not worth pursuing here; the view counts stay above in case they are useful to someone profiling the descriptor path.