GPU: userspace placeholder fast path, 64-block BlockSet guards & immediate decoration-bake texture flush #1097
No reviewers
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!1097
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1097"
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?
@RealAzemed on GitHub · 2026-11-25 19:23 UTC · original
RealAzemed:perf/placeholder-fast-blockset-bake-flush→main· +797 −158 · 10 files · 1 commits · openSummary
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.@Proudnoob4 on GitHub · 2026-11-25 19:42 UTC · original
Tested on Windows 10 (i5-13600K + RTX 4080 16 GB, driver 621.01, Series X) stacked on
Xeltax/VIckyvicky/rtb18fce0d(RT40blive BVH RT) alongside #1014, #1015, #1029, #1044, #1058, #1059 (NtReadVirtualMemory+Deferred::clear), and #1094 (420s warm-cache run, exit 0, reached frame 3072):VICTORY_PLACEHOLDER_FAST=1):watch 8,396–8,902,absent 52,282–53,173,tex_query 2,126–2,664per frame (~63k+ syscalls skipped/frame)watchbreakdown (BlockSet+VICTORY_HOT_GUARD=1):9.2–10.9 ms/frame (gww 0.0 ms/29–31,guard_scan 1.5–2.1 ms,guard_prot 2.6–3.5 ms / 297–322 vp,hot_skip 723–766)copies& kernel time (vs prior 420svickyrt_fastwithout #1097/RT40b):copiesdropped from104–110.8 msdown to55.9 ms(197.9 MB);submit threadkernel time dropped 30.6–37.6 ms -> 9.1 ms; page faults dropped 1,186–5,351 -> 235;framelogmedian 168 ms (shortest 137 ms, world peak 6.1 fps).victory-gpuunit tests (includingwatch::tests) and 12xmemtests passed on Windows 10 before the run.Note this run measured #1097 bundled with
RT40b+ the PRs above rather than standalone.AI-assisted benchmark and analysis (Gemini 4 Neon).
@Ahmet-Dedeler on GitHub · 2026-11-25 21:19 UTC · original
Data point from macOS (CrossOver 26.3 + D3DMetal 4.0b3, M5 Max, fxceless
0b0074ebase), from our play logs.The flush here only fires for the four hashes in
BAKE_PIXEL_SHADERS. Two decoration-blend programs show up in every one of our sessions and are not in that list:d126bcae5d5d8d26(PS_DecorationBlend_0000) andfcee612943c008e0(PS_DecorationBlend_0011), first bound in 5 of 5 logs. Reading the PSV0 entry names in shaders.rpf gives 322PS_BakeDecorations*and 17PS_DecorationBlend*pixel programs, and the list has 4 of them, so matching by entry name might cover a lot more than a hash list.Also,
early_texturesruns oneheap_texturespass of at most 4,096 slots, butdue_at_the_last_passon the first four bake draws was 1,033-14,183 across 7 sessions (5,398 / 5,342 / 10,177 in one run, 12,102 / 12,441 / 14,183 in another). So even with due = frame, one pass leaves thousands of slots for after the bake.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.
@alpz1000 on GitHub · 2026-11-25 22:52 UTC · original
Windows memory observation on an RTX 3060 12 GB with 32 GB system RAM. I tested
a8bcf21in a local integration of9c184b3with #253 and the 16 KiB readback option from #1164.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
VICTORY_BAKE_TEXTURES_MS=100,VICTORY_TEXTURE_STAGE_MB=128, andVICTORY_STAGING_POOL_MB=64reached the checkpoint and finished a 440-second run. I also tried an opt-in local patch that pauses optional heap texture preloads below 3,200 MiB of commit headroom. With the usual preload settings it logged the pause, recovered from 2,907 to 4,629 MiB between periodic samples, and reached the checkpoint. The exterior was more washed out in that launch. Both launches were around 5 FPS after warming up.AI-assisted with OpenAI Codex.
@rafaconvaitis on GitHub · 2026-11-25 23:31 UTC · original
I measured a narrower view-protection experiment on native Windows/D3D12, RTX 4070 driver 616.64, Series S, Flamingo
63d976bwithVIEW_SET. It keeps the first broadVirtualProtectcall. After a failure, it retries only multi-block runs inside each distinct registered view, then uses the original per-block fallback. The Windows fixture passed in both modes and cut the calls from 5 to 3 for two adjacent 128 KiB mapped views, with the same write stamps.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.
@RealAzemed on GitHub · 2026-11-26 00:28 UTC · original
Thanks @Ahmet-Dedeler, @alpz1000, and @rafaconvaitis for the cross-platform data points — super useful context:
PS_DecorationBlend_*hashes (d126bcae5d5d8d26,fcee612943c008e0) anddue_at_the_last_passexceeding 4,096 slots on early bakes. MatchingPS_BakeDecorations*/PS_DecorationBlend*by entry name instead of a small hash list is definitely much cleaner and more general across scenes/builds — and pairing a multi-pass drain with a bounded time cap (likeVICTORY_BAKE_TEXTURES_MS) avoids the #594 repeat-bake stall. Happy to see that approach land or follow up with entry-name matching!VICTORY_TEXTURE_STAGE_MB=128,VICTORY_STAGING_POOL_MB=64, andVICTORY_BAKE_TEXTURES_MS=100. Just to confirm:resource::bake_room()here only relaxes the VRAM budget check during bake draws (it does not uncap staging buffers), so capping staging/pool size is a great companion lever on Windows when commit headroom is tight.VirtualProtectcalls alone isn't where the win comes from; the measurable speedup in #1097 (e.g. @Proudnoob4's ~63k syscalls/frame skipped andcopies104–110 ms -> 55.9 ms on Win10) comes from skippingGetWriteWatch/VirtualQueryon unmapped placeholder holes in userspace plus the 64-blockBlockSetscan and same-frameVICTORY_HOT_GUARD.@Ahmet-Dedeler on GitHub · 2026-11-26 01:36 UTC · original
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
R32G32B32A32_UINTtexture to a 256×256BC3_UNORM_SRGBtexture preserved all 65,536 bytes. The buffer path did too. Both passed with a CPU upload and with the GPU writing the source through a UAV clear.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.
Standalone probe and results
@RealAzemed on GitHub · 2026-11-26 01:52 UTC · original
Thanks @Ahmet-Dedeler — super useful standalone probe! Confirming that direct
R32G32B32A32_UINT -> BC3_UNORM_SRGBpreserves all 65,536 bytes on D3DMetal rules out a dropped format copy on the driver side, which lines up nicely with #1241 (copying GPU texture aliases even when a list already uploaded the view from title memory) as a real culprit for black clothing/baked textures.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.