Repository navigation
GPU: userspace placeholder fast path, 64-block BlockSet guards & immediate decoration-bake texture flush - #1097
Conversation
…uards, immediate bake texture flush
|
Tested on Windows 10 (i5-13600K + RTX 4080 16 GB, driver 621.01, Series X) stacked on
Note this run measured #1097 bundled with AI-assisted benchmark and analysis (Gemini 4 Neon). |
|
Data point from macOS (CrossOver 26.3 + D3DMetal 4.0b3, M5 Max, fxceless The flush here only fires for the four hashes in Also, We have a branch that matches by entry name and loops passes until nothing is due, but it's not tested in game yet, so take this as numbers only. If someone tries a loop, #594's point about bake pre-uploads getting expensive when bakes repeat probably applies too. |
|
Windows memory observation on an RTX 3060 12 GB with 32 GB system RAM. I tested With the usual preload settings, live texture staging went from 70 MiB to 1,420 MiB between two diagnostic samples during loading. Our external guard stopped the run at 253 seconds, with about 8,769 MiB of physical RAM free but only 1,727 MiB of commit headroom. This is a combined build and the observation does not isolate #1097 as the cause. A warmed retry with AI-assisted with OpenAI Codex. |
|
I measured a narrower view-protection experiment on native Windows/D3D12, RTX 4070 driver 616.64, Series S, Flamingo In the controllable prison window, the same process and fixed camera alternated OFF/ON every 20 s. Three complete segments and 300 presents per mode, excluding cross-boundary samples:
I found no useful gain from batching only the successfully identified multi-block views in this native scene. This did not test the PR's placeholder-hole skip, bitsets or texture changes. The block retry counts include successful protections as well as failures, so they do not estimate how many retries a trusted hole skip could remove. |
|
Thanks @Ahmet-Dedeler, @alpz1000, and @rafaconvaitis for the cross-platform data points — super useful context:
|
…ts as bit blocks, counters; s2 switches (g22-g24) Measured (g24, VICTORY_JOURNAL_FREE=1 with the bit blocks): 158.9 ms a frame at 7-10k draws against 179.1 (g23) and 167.5 (g21); copies 45.7 ms against 54.4; journal waits 124 -> 5 ms a frame. - watch.rs: COSTS counters (lock waits, kernel askings, guard passes, questions to Windows, faults), logged on the frame line. - watch.rs: protected/clean/absent/viewed guard sets kept as 64-block words (`Blocks`); a guard pass walks only the blocks not known clean. Idea from RealAzemed (fxceless#1097). - VICTORY_JOURNAL_FREE=1: the journal's lock is let go while the kernel is asked about written pages; askings in flight are waited for by range. Idea from Joshua Odom (JoshuuDev/victory-amd 3b270b1). - texture.rs: why textures are read again, counted per reason. - Off by default, not yet measured in a game: - VICTORY_HOLES_KEEP (+ _FRAMES): placeholder holes kept until a remap or write hook (ideas from Peppacodes e277b98, cc642f9); - VICTORY_OPEN_RUNS: one VirtualProtect per run (idea from Marvisak/VIctory PR 2849); - VICTORY_VIEW_RECHECK=N: aliases unguarded, clean blocks made due every N frames (idea from d55223b); - VICTORY_SYNC_SKIP: sync_heaps skips unchanged 64 KiB pages (ideas from naixue2233 d695015/c6060592, UwUCammie PR 1043, Nazar Ukolov 7f475db6); - VICTORY_TEXTURE_MISSING_WAIT, VICTORY_TEXTURE_TURN, VICTORY_TEXTURE_SKIP_FAILED_ASK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I checked the copy at the end of the decoration bake separately on an M5 Max (CrossOver 26.3, D3DMetal 4.0b3). A direct copy from a 64×64 This covers mip 0 on committed textures. For the black clothing I’d check what the compressor actually wrote and which texture the draw sampled before assuming the driver dropped the format copy. |
|
Thanks @Ahmet-Dedeler — super useful standalone probe! Confirming that direct |
Summary
Three self-contained GPU-layer optimizations and a character decoration-bake texture-freshness fix, all gated behind env switches (default on, easily disabled for A/B) and verified with unit tests and
cargo xtask policy:1. Userspace
xmemPlaceholder & View-Region Fast Path (VICTORY_PLACEHOLDER_FAST=1)MEM_RESERVE_PLACEHOLDERreservations once inXMemVirtualAllocviavictory_gpu::title_memory_placeholder(base, size)(RwLock<BTreeMap<usize, usize>>).watch::writes(..., false)returnsNoneimmediately in userspace for placeholders, avoiding doomedGetWriteWatchcalls.watch::guard()recognizes placeholder ranges withoutGetWriteWatch/VirtualQuery, skipsuncommitted_end()queries on absent blocks (which only become mapped viaxmem::map->title_memory_remapped), andprotect_here()marks unmapped holes directly fromVIEWSwhile only callingVirtualProtecton contiguous mapped runs.watch::protect()looks up aliased pages across[from, to)in a singleVIEWSlock (aliased_pages_in) instead of per-block locking.texture.rs::{committed, mapped_bytes}()answer directly fromVIEWSinside placeholders (0VirtualQuerysyscalls).copies243.6 -> 115–127 ms (-53%),heap_tex_pass107.8 -> 22.8–38.6 ms (-79%), median frame time 733 -> 629 ms.2. 64-Block Bitset
BlockSet, Coalescedopen_here, & Same-Frame Hot-Block Guarding (VICTORY_HOT_GUARD=1)BTreeSet<usize>inwatch::Guards(protected,clean,absent,viewed) withBlockSet(BTreeMap<usize, u64>, 64 blocks = 4 MiB peru64), turningguard()into an O(words) bitwise!(clean | absent)+trailing_zeros()scan with zero allocations.VirtualProtect(..., PAGE_READWRITE)runs inopen_here()with per-block fallback.on_write: blocks faulting >= 4 times within the same frame stayPAGE_READWRITEfor a short bounded cooldown (4 -> 8 frames, then re-probed), strictly conservative (guard()always reports them written).watch243 -> 41.1 ms (guard_scan8.8 ms,guard_prot36.5 ms / 425 vp, down from 64–104 ms / 675–960 vp); median frame time 629 -> 566 ms (0.90 -> 1.75 fps, +94% vs baseline).3. Immediate Decoration-Bake Texture Flush & 8 GB VRAM
bake_room()PAGE_WRITTENranges (BAKE_PAGE_WRITTEN, capped) when continuousVICTORY_PAGE_WRITESbit 2 is off, and flushesREMAPPED,PAGE_WRITTEN, and recently-uploaded/partially-mapped slots (texture_slots_bake_prepare) with 0-frame delay (due = frame) right beforePS_BakeDecorations_*draws.resource::bake_room()(97% DXGI budget, ignoring long-term reserves during one-time bakes) so 8 GB GPUs do not permanently bake black character faces when VRAM is near the normal texture limit.Verification
cargo xtask policypasses (181 files ok)cargo check --target x86_64-pc-windows-gnu --tests -p victory-gpu -p victory-hlepassesplaceholder_fast_path_tracks_mapped_bytes_and_blocks,blockset_range_and_run_operations_match_exact_membership, and immediatetexture_slots_remapped/slots_written_underbake flush pass under Proton.