RFC: VRAM-first lazy coherency & async pipelined submissions (unified-memory V2 roadmap) #3703
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?
Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-28T09:32:55Z.
Summary
Incremental optimization PRs on
main(63bcca4) have already made huge progress — e.g. VRAM shadows (#3312), wave-coalesced dirty marks (#2958, 411 → 283 ms on RTX 4070 SUPER), multi-threaded marked copy-back (#2914), batched guard takes (#3585), batchedMEM_WRITE_WATCHhot-page tracking (#3615), and sparse streamed texture mips (#2389).However, profiling in
#400and#407shows that even with all of those combined, world frame times will hit a hard architectural ceiling because of three coupled assumptions in the current coherency model:Host::execute(crates/victory-gpu/src/host.rs:1156) holds a globalsubmittedlock and blocks onWaitForSingleObject(self.event, INFINITE)(host.rs:1283) after everyExecuteCommandLists. Frame time issum(CPU + Prep + GPU + CopyBack)instead ofmax(CPU, GPU).Shadow::writing(shadow.rs:326),Shadow::copy_back(shadow.rs:397), andShadow::copy_back_marked(shadow.rs:491) assume the title's CPU might read every page shaders write, forcing per-write shader dirty-mark atomics, synchronous GPU drains, and post-submission copy-backs even though the vast majority of GPU outputs (G-buffers, shadow maps, skinning/morph outputs, indirect args, compute intermediates) are never read back by the CPU.L0host-RAM residency vs.L1VRAM bandwidth:#407explored eliminating copies viaOpenExistingHeapFromAddress/MEMORY_POOL_L0, but@qntic's measurements in#407confirmed the PCIe ceiling of that route (~13 GB/s GPU reads from host heap vs. ~71 GB/s from VRAM on an RX 6600 XT; the gap is even wider on 500–1000 GB/s GPUs). Meanwhile,#3312confirmed that moving buffers into VRAM directly cuts frame time.This RFC proposes a 5-track, incremental, opt-in roadmap that builds directly on existing PRs (
#3312,#3585,#3615,#2389) rather than discarding them, so multiple contributors can work in parallel without colliding.The 5-Track Incremental Architecture
Each track can land behind an opt-in environment variable, be validated with synthetic D3D12/VEH tests, and be benchmarked on live world runs before becoming default.
Track 1 — Lazy
GPU_OWNEDRead-Fault Coherency (VICTORY_LAZY_COPYBACK=1) (Keystone)CPU_OWNED,SHARED,GPU_OWNED).ExecuteCommandLists. Instead, mark those pagesGPU_OWNEDand set their CPU virtual addresses toPAGE_NOACCESS.merge_writeback.#PF→ VEH seesGPU_OWNED→ waits only on the fence that last wrote that page → copies that 64 KiB page from VRAM to title RAM → transitions it toSHARED→ resumes.WaitForSingleObjectper submission) and Track 4 (removing dirty-mark shader atomics).Track 2 — Async Pipelined
Host::execute(VICTORY_ASYNC_SUBMIT=1)submittedlock +WaitForSingleObject(self.event, INFINITE)(host.rs:1283) with a ring of in-flight submission contexts (each carrying its fence value, upload ring slice, and deferred resource retirement list).N+1with GPU frameN), blocking only when:ID3D12Fence,GPU_OWNEDpage (Track 1), orTrack 3 —
DEFAULTVRAM + 64 KiBCreateReservedResourceTiled Residency + AsyncCOPYQueue#3312(DEFAULTVRAM shadows) and#2389(sparse streamed texture mips).MapViewOfFile3/XMem) directly in GPU VRAM using D3D12CreateReservedResource+UpdateTileMappings(D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES == 65536, matchingwatch::PAGE1:1):#3585+#3615) from a pinnedUPLOAD/ ReBARD3D12_HEAP_TYPE_GPU_UPLOADring over a dedicated D3D12COPYqueue running concurrently with 3D/Compute.Track 4 — Zero-Instrumentation Shaders for
GPU_OWNEDBuffers#2958).Track 5 — GPU Compute-Shader Texture Detiling
COPYqueue and dispatch a small DXIL compute shader to detile directly intoDEFAULTtiled textures.Coordination & Next Steps
watch.rsaliasing,PAGE_NOACCESSinteraction with kernel reads / DirectStoragewatch::writing, andmemory.rsraw-address writes).VICTORY_LAZY_COPYBACK=1) with synthetic D3D12 + VEH read-fault tests.Related:
#400,#407,#1633,#2389,#2914,#2958,#3312,#3585,#3615.Imported from Marvisak/VIctory. Originally posted by Ym1r1710 on 2026-11-28T10:17:41Z.
Some numbers from a setup where part of track 1 already exists in a different form. They might help size tracks 1 and 2.
7800X3D (8c/16t), RTX 5080 16 GB, 32 GB RAM, Win 11, Series S profile. The build is main plus a lot of fork work. In this build the copy-back doesn't happen at the end of each submission. It runs on its own threads next to the submit thread.
Copy-back stops being what the frame waits for, but it doesn't get cheaper. It is still about 36 MB a frame and roughly 30 ms of CPU on those threads. The submit thread waits on it only 1-2 ms a frame. So the lazy GPU_OWNED idea would mostly free CPU time on other cores, not frame time directly.
That freed time still matters here, because the CPU is close to full. The process uses about 400 ms of CPU per ~35 ms frame indoors, so about 12 of 16 logical cores are busy. Every attempt to move cores between thread groups lost as much as it gained.
Where the limit moved for us:
One thing that may apply to main as well: host memory pressure.
I'd guess the reports of world entry under memory pressure (7-8 fps on a 4090 with 64 GB) see part of the same thing.
On track 2: on this machine the per-submission wait isn't the limit any more. The submit thread stands idle for 0.3-3 ms a frame indoors.
Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-28T12:03:06Z.
This telemetry is pure gold — thank you @Ym1r1710, especially the outdoor translator breakdown and the trim-thrashing numbers.
Three huge takeaways that sharpen this RFC immediately:
GPU_OWNED) under core saturation: Even when copy-back is offloaded off the submit thread, burning ~30 ms/frame across 12/16 busy logical cores directly starves the list-translation threads outdoors. Eliminating the ~95% of GPU-only copy-backs gives those cores back and cuts the memory pressure that triggers the trim loop.GUARDScontention).Imported from Marvisak/VIctory. Originally posted by CheetahDoesStuff on 2026-11-28T13:28:15Z.
I would definently recommend that you fork this and write a prototype, the maintainer hasnt merged anything in several days so dont expect too much work being done for you.
Fork it, implement it, showcase it (here and r/fitgirlrepack), get attention/awareness.
Prove that it works, that is what would get this merged/implemented in the mainstream forks.
Imported from Marvisak/VIctory. Originally posted by KingKaom on 2026-11-28T18:09:11Z.
RDNA4 (RX 9070 XT) data point — second machine, series-x profile, fork build (VIctory-RDNA) with its
fastpreset applied (flags spanning guard-page handling, journal/copy-back paths, constants/descriptors):Caveat: our numbers are diag-profile builds (this fork's plain release path is currently blocked on a separate boot regression, logged in VIctory-RDNA#3).
AI-assisted (Hermes Agent)
Imported from Marvisak/VIctory. Originally posted by KingKaom on 2026-11-28T18:20:49Z.
Self-correction (day after my comment above): our first human playtest with the pad on this same build showed our movement framing was too generous. The ~30 fps cadence-lock holds while standing; under actual player input frame time drops to single digits on any movement (overlay sample 7 fps / 142.9 ms / 9140 draws during world streaming). The "walk medians" we and others cite blend standing with scripted forward-walk, so they overstate moving fps.
This actually sharpens this RFC's model from the AMD side: standing is cheap, moving is where draws explode and every submission's drain/copy-back cost becomes directly visible in frame time — the movement cliff is the serialization wall.
One more observed fact from the live run (fork-specific, reported here since it affects how any of us read frame numbers): the player character rendered without proper hand/leg meshes and some wrong textures in this build — separate from the frame-time story.
AI-assisted (Hermes Agent)
Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-28T23:25:28Z.
Appreciate the RDNA4 data point and especially the honest human-playtest follow-up, @KingKaom.
Two really useful signals here:
VIctory-RDNA#4showing zero walk-window gain and ~2x worse entry hitches when overlapping submissions without removing eager copy-back matches the RFC's dependency order cleanly — pipelining on top of eager readbacks just widens the contention window.7 fps / 142.9 ms @ 9,140 draws): That aligns right alongside @Ym1r1710's outdoor numbers (8–16k draws). Once you're actually moving and streaming, draw count, descriptor-table translation, and copy-back/guard contention all spike together — which is why real pad movement is the only honest benchmark for this.@CheetahDoesStuff — totally fair point, and agreed that working code + A/B numbers are what actually move the needle while upstream
mainis quiet. The write-watch tracking piece is already implemented and benchmarked in #3615 (CI green, independently verified on Windows), and the next concrete prototype on my fork is Track 1 (VICTORY_LAZY_COPYBACK=1) starting with narrow, resource-levelGPU_OWNEDownership (GPU-written scratch/shadow-mask buffers first rather than a blanket global flip) so we can verify zero visual corruption or TDRs before widening it. Will post real A/B numbers once that's running.Imported from Marvisak/VIctory. Originally posted by Fran-co-F on 2026-11-29T03:25:27Z.
Data point for Tracks 1-3: a Linux fork that already has most of Track 1/2 in another form, measured both standing and while playing.
Setup: Ryzen 7 9800X3D, RX 9070 XT 16 GB, 31 GB RAM, Linux (CachyOS). SlaktarnVI (a VIctory fork for Proton/AMD) under a self-built Wine 11.17 with patched vkd3d-proton, S70 preset (Series X profile, 1440p).
In that fork submissions are already sent ahead (
VICTORY_LATE_WAIT+VICTORY_RELAY): about 20 submissions a frame, settled 0.3-1 times a frame. Copy-back runs on its own thread, and submissions are prepared on a thread of ours (VICTORY_ASYNC_SUBMIT).1. Track 1/3 in practice: write-combined title memory in VRAM, at the title's own addresses
XMemVirtualAllocprotect0x400) goes into VRAM in place, in 32 MiB blocks. The heaps are opened withOpenExistingHeapFromAddress, and vkd3d-proton backs them with VRAM placed at the same address (VK_EXT_map_memory_placed). This needs a Wine change to allow placed maps for 64-bit processes.safecopy.rs) reads title memory 32 bytes at a time. An access map (per 64 KiB block, AMD IBS sampling for CPU loads) showed the CPU reads only about 0.3 % of what is copied back.Result in a static scene (prison cell, 120 s, median of 5-s windows):
The prologue cutscene went from 19.9 to 28.7 fps.
2. Standing vs. playing: this matters more than any of the above
Fifteen minutes of real play with a pad, binned by draws per frame (median real fps of 5-s windows, frame generation off in the count):
The static scene has about 3,000 draws per frame; playing gives 6,000-14,000 (correlation of fps with draws: −0.68). The memory work helps in every bin, but it moves a cost that is roughly fixed per frame. The cost that grows when moving is per draw. (Caveat: with our changes we also saw visual problems in that session, such as flicker on trees, missing menu glyphs, and textures and assets not loading while driving, none of which the unmodified fork showed. So the fps column is not "free".) Our submit thread worked a median 32 ms a frame while playing (42-98 ms in the worst windows), against 13-21 ms standing. This matches @KingKaom's standing-vs-moving report above. Medians from scripted or standing scenes overstate playable fps by a lot.
3. Smaller findings that may save someone time
VICTORY_LATE_WAIT_LISTS=512(default 256): the submit thread's waits for "lists in the air" went from a median of 4 ms a frame (peaks of 20-48 ms) to 0. Its work fell from about 21 to 13 ms in the static scene, with 0 tables refused and no crash. Fps did not rise there, because the title's own threads became the limit (about 46 ms a frame).pread64waiting for page-cache I/O (folio_wait_bit_common) 50-87 % of the time during a cut.VirtualProtectdoes nothing: the blocks opened per frame are isolated 64 KiB blocks, 1.1-1.3 per call.VICTORY_PORT_GUARD=1cuts the lock waits but quadruples protect time.NtProtectVirtualMemorytakes Wine's globalvirtual_mutexplusmmap_lock.VICTORY_COPY_BESIDE/STORE_BESIDE/WRITE_SITEScut view-memory guard cost by about a third (copies −44 % in MB). Yet the submit thread only saved about 2 ms, and some combinations showed wrong textures on screen, so we left them off.Code (all opt-in, experimental, with the Wine and vkd3d-proton patches F1 needs): Fran-co-F/SlaktarnVI branches
vram-wcanddstorage-workers. Full write-up with known problems: Slaktarn700/SlaktarnVI#15.Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-29T09:02:18Z.
This is an incredible dataset, @Fran-co-F — thank you for sharing both the draw-binned pad-play numbers and the negative results (and for being upfront about the visual regressions).
A few things here sharpen the RFC significantly:
AMD IBS measuring ~0.3% CPU reads of copy-back is the cleanest hardware proof yet of Track 1's premise: ~99.7% of eager copy-back is never touched by the CPU. Cutting copy-back from 42 MB → 0 MB and copies 98 → 31 MB (19.9 → 28.7 fps in the prologue, +2–6 fps across every draw bin) shows the ceiling of removing that fixed per-frame memory tax.
The visual glitches (flicker, missing menu glyphs, unloaded assets while driving) reinforce narrow/lazy ownership: Even with a strict WC-only filter, blanket 32 MiB block placement in VRAM still gets bitten by that remaining ~0.3% (or missing CPU/GPU visibility barriers on specific resources like glyph atlases/streaming buffers). That lines up with what folks have seen on Windows too: either narrow, resource-level GPU ownership first, or a lazy read-fault (
PAGE_NOACCESS) trap to catch the rare CPU read cleanly without paying 10 MB/s uncached VRAM reads or silent staleness.The fixed-per-frame vs. per-draw split is now confirmed across 3 independent setups:
29.0 fpsat 1–3k draws →11.8 fpsat >7k draws (r = -0.68, submit thread 32 ms median / 42–98 ms worst).That makes the roadmap much clearer: Tracks 1–3 remove a large fixed per-frame tax (and free CPU cores), but hitting 30+ fps in 8k–14k draw street driving also requires attacking per-draw translation & descriptor-table overhead once copy-back stops dominating.
Bonus takeaways that save a ton of dead-end work:
pread64queue-depth starvation (not BCPack, which uses ≤1.5 workers) — pointing straight at real async I/O (io_uringon Linux / properly pipelined overlapped I/O) rather than throwing more synchronous threads at it.VirtualProtectdoing nothing (1.1–1.3 isolated 64 KiB pages/call) matchesneonbyte1/VIctory#59(1.67 pages/call) and reinforces why skippingVirtualProtectaltogether on hot pool pages (GetWriteWatch, #3615) is a different lever from trying to mergeVirtualProtectcalls.Really appreciate you linking
Slaktarn700/SlaktarnVI#15— this gives everyone working on both Windows and Linux forks a much more honest picture of where the wall moves next.Imported from Marvisak/VIctory. Originally posted by UlisesVoxer on 2026-11-29T23:26:45Z.
Native-Windows measurements for Track 3 (tiled residency), plus some
related numbers for Tracks 1 and 3. Sections 1–6 are standalone D3D12
tests with no title involved. Section 7 is from title runs.
System: Ryzen 9 5900X, 64 GB DDR4, NVIDIA GeForce RTX 4090
(22,608 MB dedicated reported), driver 616.64 (32.0.16.1664),
Windows 11 Pro 25H2 (build 26200.9974). D3D12 reports tiled resources
tier 4, resource heap tier 2, GPU upload heaps supported, 40-bit GPU
virtual addresses. Release build.
UpdateTileMappings(run at DDR4-3200)How each figure was timed:
UpdateTileMappingscall(s) on thedirect queue.
written by one command list submitted just before the call(s) and
one just after. Note this interval includes driver and kernel work,
not only GPU time: the same test at DDR4-2133 gave roughly twice
these figures, CPU and card alike.
Its first call is reported apart; the median and p90 are over the
next 50 calls.
for buffers, non-RT/DS textures for textures.
Each call's region starts n tiles further on in the resource,
wrapping round at the end.
1. Cost per call
cost about the same.
card.
when mapping to heap tiles; about 0.17 ms CPU / 0.25 ms card when
mapping to none.
takes about 40–60 µs more than the card figure.
card. The exception is all 4,096 tiles to one heap tile: 512 MiB
buffer 3.6 ms, 2 GiB buffer 3.6 ms, 512 MiB texture 3.6 ms, 2 GiB
texture 5.5 ms.
Full table: median, CPU µs / card µs
2. One call with K regions against K separate calls
Reserved buffer of 512 MiB and reserved texture of 512 MiB
(16384x8192 RGBA8). The K regions are spread apart (every other
region-sized slot), with one range each and heap tiles in a row. The
"K calls" figures time all K calls together, back to back, between
the same two timestamps. Median, µs.
The cost is per call, not per tile. One call carrying all K
regions is 8–100x cheaper on the CPU and 6–24x cheaper on the card
than K calls. Each separate call costs about 25–115 µs of CPU and
110–220 µs on the card, so 256 separate calls take 39–55 ms of card
time, against 1.6–3.5 ms batched.
3. Two regions on the same heap tiles (aliasing)
Each case has a fresh 16-tile DEFAULT heap; regions A and B are 16
tiles each, both mapped to heap tiles 0..15. A pattern was written
through A and read back through both; then a different pattern was
written through B and read back through both.
buffers.
after each write, plus a COPY_DEST → COPY_SOURCE transition of the
written resource. Buffers otherwise go by implicit promotion from
COMMON.
through either shows through the other.
the other reads; the same bytes come through in another order, the
texture's layout.
in a process of its own, there were 0 messages at warning or worse
in all three cases.
4. Heap types that can back a reserved resource
All nine tried worked, for both a reserved buffer and a reserved 2D
texture: DEFAULT, GPU_UPLOAD, UPLOAD, READBACK, CUSTOM L0
(not-available, write-combine, write-back), CUSTOM L1 (not-available,
write-combine).
mapped to it, and bytes copied in through the reserved resource
came back right. The device was not removed.
or errors.
Many tiles to one heap tile and to none: with
D3D12_TILE_RANGE_FLAG_REUSE_SINGLE_TILE, 16 tiles mapped to oneheap tile all read the same bytes. Tiles mapped with
D3D12_TILE_RANGE_FLAG_NULLread zeros.Not tested: CPU access to tiles of a reserved resource backed by
a GPU_UPLOAD heap, and aliasing between a reserved resource and a
placed resource on the same heap.
Related measurements (standalone, at DDR4-2133)
5. Where the bytes live decides the card's read and write rate
Same direction as the #407 figures quoted in the RFC, with a larger
gap on this card.
6. A GPU upload heap as VRAM-resident, CPU-visible memory
it in 2.66 ms.
both directions.
wrong). It worked as a vertex, index and constant buffer, and as a
copy source and destination.
address space around a hole, then
Maplands in the hole. Witheverything from 4 GB up reserved it took 6.9–10.0 s for one 2.2 GB
mapping; in a form with three mappings and small RAM pieces between
them it took 0.07–0.45 s per mapping. The mapping survives the
release of the reservations.
D3D12 spec says a GPU upload heap falls back to system RAM silently
when over budget.
So this suits memory the CPU only writes. Any CPU read of it is
hundreds of times slower than reading RAM.
From title runs
7. For Tracks 1 and 3
copy-back): the title touched about 7% within a second, about 77%
were touched only by the layer's own code, and about 16% by nobody.
Most copy-back today serves the layer's bookkeeping, not the title.
(the fork's
VICTORY_WC_NO_BACKwith its 1 MiB floor): about 95%less data copied back per frame on my PC. The floor matters, and so
do exceptions above it: the title does read some large
shader-written textures on the CPU.
physical pages at two CPU addresses for its large pools (147,768
such mapping calls in one run). A VRAM-resident design needs an
answer for those ranges.
frame time with no code change. Worth checking on any DDR4 test
machine.
Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-30T09:26:10Z.
VOXER ACTUALLY COMING THROUGH! This is an incredible set of native-Windows measurements, @UlisesVoxer — thank you for running the full D3D12 test matrix and posting it here.
A few headline results that completely de-risk Track 3 on Windows (and give us hard design rules):
UpdateTileMappingsis completely viable — as long as it's batched: Unlikevkd3d-proton's full-resource tile walk noted inneonbyte1/VIctory#128, native Windows cost is independent of reserved-resource size (64 MiB vs 2 GiB are identical at ~31–41 µs CPU / ~133–149 µs card), and batching K regions into a single call is 8–100x cheaper on CPU and 6–24x cheaper on card (256 regions in 1 call =0.20 ms CPU / 1.62 ms cardvs39–55 msunbatched). Hard rule for Track 3: always batch tile remaps per submission/frame.GPU_UPLOADhitting865 GB/sGPU reads +21.2 GB/sCPU writes (at6 MB/sCPU reads) cleanly defines its exact lane: CPU write-only, GPU read-many buffers under budget.VICTORY_WC_NO_BACKcutting copy-back by ~95% and your note that the title does CPU-read some large shader-written textures above the 1 MiB floor, that reinforces keeping Track 1 behind either a narrow resource-class allowlist or a lazy read-fault safety net rather than a blind global skip.Also wild that DDR4-2133 → DDR4-3200 alone shaved ~32% off frame time — huge reminder to log RAM speed on any DDR4 A/B runs. Really appreciate you contributing this data to the thread! Good luck with future projects!