Repository navigation
Description
Hi! Did a deep read-only audit of commit 8fc22547 focused on two goals: (1) cutting host RAM/VRAM pressure on 12 GB GPUs / 16–32 GB systems, and (2) unblocking true end-to-end 2 frames in flight (docs/findings.md:170-177).
Full disclosure upfront: we do not have game assets to run live captures, so all performance numbers below are either cited directly from the repo's own logs or measured on a standalone D3D12 repro benchmark on an RTX 3060 12 GB (Win11 26300, driver 621.35) modeling the exact 174 MiB (0xAE00000) / 11-dispatch scenario from docs/findings.md and shadow.rs:147.
Posting this as a concise technical map + standalone benchmark in case any of these pieces help prioritize upcoming PRs.
1. Three quick, zero-render-risk memory wins (especially for 12 GB VRAM / 16–32 GB RAM)
- Auto-trim idle host lists under commit pressure (
list.rs:303-341,host.rs:436-464,1459-1500):docs/findings.md:95notes host-list command allocators hold up to ~9 GB private memory after loading spikes (IDLE_MOST = 512, 2 allocators each).allocator_trimandidle_trimalready exist, just gated behind env vars. Triggering a trim down to e.g.IDLE_TIGHT = 64insideHost::sweep()whenresidency::pressured() || residency::critical_commit()should drop post-load commit peaks by ~0.5–2.5 GB with zero rendering risk (list recreation is already measured at ~0.2 ms inlist.rs:297-299).
- Scale
pool.rsSPARE_KEPTwith VRAM budget (pool.rs:30-77):SPARE_KEPT = 64× 64 MiB holds up to 4 GiB of empty VRAM as a constant until usage crosses 85%. On 8–12 GB GPUs that's 33–50% of local VRAM tied up in empty chunks, causing oscillation between 4 GiB and 128 MiB around the 85% threshold. Capping it as a fraction of DXGI budget (e.g.budget / 32, clamped[2, 64]) fixes this cleanly.
- Pool
read_back_bufferfortexback.rs(host.rs:9513-9550,texback.rs:144-198):- Currently allocates a fresh
CreateCommittedResource(~310 µs/alloc perpool.rs:5-7) on every readback. A small power-of-two reuse pool (mirroringsend.rs::SPARE) removes that hot-path allocation overhead.
- Currently allocates a fresh
2. Standalone RTX 3060 benchmark: GPU-Side Dirty Bitmap (shadow.rs:3444)
shadow.rs:3444-3446 explicitly notes a GPU-side dirty mask as an unimplemented shortcut. Checking the shader compiler, everything needed to emit it is already in place:
- Free root UAV slot:
SLOT_DIRTY = 251(victory-shader/src/emit/shader.rs:26-73, where 252–255 are taken; add tooursinvictory-pipeline/src/host.rs:523-529, guard against the 64 root-param limit). - Store instrumentation points:
emit/lower.rs:12797-12882(buffer stores),:3710-3724(global stores),:12713-12739(narrow),:12767-12795(atomics).atomicBinOp.i32(opcode 78, op2= Or) is already emitted atlower.rs:3766-3773. - Map size: 1 bit per 64 KiB page → 348 bytes (4 KiB alloc) for the 174 MiB heap (vs 174 MiB CPU
beforesnapshot, or 44.6 KB hash + 11.1 KB differs inCARD_COMPARE). - Safety: clamp
wordwith an overflow bit (overflow → mark copy all-dirty), use a small per-flight pool (e.g. 8 × 4 KiB) or 32-bit page generation forLATE_WAIT, and fall back to existingbefore/CARD_COMPAREfor multi-copy draws or image stores.
Measured results on RTX 3060 12 GB (174 MiB UAV, 11 compute dispatches, medians of 21 warm runs)
Tested 3 paths honestly — including the actual default VRAM CARD_COMPARE hash path (host.rs:2461-2541), not just the worst-case CPU before path:
- A (
before+ readback + 8-thread AVX2 diff) — fallback when a copy doesn't fit in VRAM (card_room_forrefusal /VICTORY_CARD_BUFFERS=0/ small copies). - C (
CARD_COMPAREGPU hash) — current default for carded 174 MiB copies. - D (
GPU Dirty Bitmap) — worst-case SM 5.0 per-threadInterlockedOr(noWaveActiveBitOrcoalescing yet; SM 6.6 DXIL withWaveActiveBitOrwill be equal or faster) + 4 KiB map readback + targeted page fetch + AVX2 merge.
| Path | Scenario | GPU (ms) | wait1 (ms) | wait2 / fetch (ms) | CPU work (ms) | Snapshot (ms) | Total (ms) |
|---|---|---|---|---|---|---|---|
A (before + AVX2) |
sparse (16 pages / 1 MiB) | 0.004 | 17.520 | — | 8.532 | 8.417 | 34.871 |
A (before + AVX2) |
dense (256 pages / 16 MiB) | 0.004 | 17.116 | — | 8.214 | 7.984 | 33.571 |
C (CARD_COMPARE default) |
sparse (16 pages) | 0.487 | 0.561 | 0.139 | 0.037 | — | 0.774 |
C (CARD_COMPARE default) |
dense (256 pages) | 0.501 | 0.604 | 1.356 | 1.016 | — | 3.241 |
D (GPU Dirty Bitmap) |
sparse (16 pages) | 0.005 | 0.070 | 0.136 | 0.036 | — | 0.272 |
D (GPU Dirty Bitmap) |
dense (256 pages) | 0.005 | 0.097 | 1.339 | 0.727 | — | 2.308 |
- Accuracy validation: 48 full validation rounds (133,632 page decisions, 254,592 dword checks) — 0 misses, 0 false positives, 0 data errors.
- Realistic scope: On carded copies (C), D saves ~0.5–0.9 ms and 55 KB VRAM; on non-carded copies (A, common on 12 GB cards), it drops ~34 ms → 0.27–2.31 ms and eliminates the 174 MiB snapshot (snapshot pool up to 512 MiB). Crucially, it does not eliminate waiting on an in-flight dispatch (the bitmap is only known after execution), but it unblocks multi-flight / 2-frames-in-flight without duplicating 174 MiB CPU
Shadow::beforesnapshots (which are currently single-per-copy atshadow.rs:60-64) and narrowsline.written/copied_readpost-landing.
3. What actually blocks true "2 Frames In Flight" end-to-end
Tracing queue/behind.rs, host.rs, fence.rs, and draw.rs, most of the async machinery is already built and active via scripts/play-foxhound.ps1 (THIN=1, RELAY=2, CARD_STEPS=2, late_stage() == 3, non-blocking title fences via late_signal). The remaining concrete blockers appear to be:
- Present window & swapchain depth (the main choke point):
frames_most()defaults to1(queue/behind.rs:733-739,VICTORY_SUBMIT_FRAMESisn't set inplay-foxhound.ps1), andBUFFERS = 2(host.rs:9620).- Moving to
VICTORY_SUBMIT_FRAMES=2+BUFFERS = 3also requires handlingHostTexture.state(currently a singleAtomicU32atresource.rs:2897-2904, which can race if two presents/frames touch the same source texture).
- Intra-frame settles &
card_stepsrefusals (biggest single CPU-wait win):- The 226–326 ms
settleon 12 GB configs (findings.md:125-131, 32 B upload fill colliding with the declared 174 MiB heap) can't be solved by dirty bitmaps alone while the skinning dispatches are still in flight —card_stepsis supposed to run that fill on the GPU behind the flight, so checking why it refuses viacard_steps::REFUSALS(card_steps.rs:1012-1043) looks like the fastest single win. - Secondary intra-frame settles to eliminate before 2-frame overlap: dynamic descriptor fallback
settle_for_fence()(draw.rs:2240,2314,4627), synchronous decoration bakeexecute_sync_internal(host.rs:5662) +texture/ahead.rs:155drain(), and synchronousCopyPageMappingsBatchX(queue.rs:1193-1251).
- The 226–326 ms
- Per-flight CPU
Shadow::before(shadow.rs:60-64):- Carded paths already have per-flight
CardPlan, but non-carded CPUShadow::beforeis oneMutex<Option<Vec<u8>>>per copy. Replacing it with a per-flightDirtyMappool (Section 2) prevents 2×–3× RAM blowup and cross-flight contamination when two frames overlap.
- Carded paths already have per-flight
Suggested order of attack
- Measure baseline first (0 code): capture logs with
VICTORY_SUBMIT_FRAMES=2,VICTORY_SUBMIT_DEPTH=128,VICTORY_LATE_WAIT_LISTS=512,VICTORY_BURY_LAG=8and inspectcard_steps::REFUSALS,at presents, andDynamicRefused. - Stage 1: fix the top
card_stepsrefusal on the 174 MiB fill + eliminate intra-frame settles (dynamic slots / async bake) + land the 3 quick memory trims. - Stage 2: implement
SLOT_DIRTY = 251GPU Dirty Bitmap with aVICTORY_DIRTY_CHECK=1parallel validation switch. - Stage 3:
BUFFERS = 3,frames_most = 2, per-flightHostTexturestate/copy handling → based on the timelines indocs/findings.md, this should move RTX 5080 from ~28.4 ms (~35 FPS) toward ~20–22 ms (~45–50 rendered FPS) and reclaim substantial CPU idle/memory headroom on 12 GB cards.
Happy to share the standalone D3D12 C++ benchmark source (bench.cpp) or help draft clean unit-tested PRs for the memory trims / SLOT_DIRTY scaffolding if any of this aligns with your current branch priorities!
Activity
github-actions commentedon Nov 28, 2026
Please attach both logs from the run that went wrong. Without them we can only guess. Paste
%LOCALAPPDATA%into the address bar of File Explorer to get there.%LOCALAPPDATA%\victory\logs\: the newestvictory-nvidia-play-<date>-<time>-<number>.log(fromvictory.exe) orvictory-nvidia-<date>-<time>.log(from the script launcher). The window shows its path at the start, on the lineLog: ....%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newestvictory-<date>-<time>-<number>.crash.login%LOCALAPPDATA%\VIctory\data\7952987A\temp\.Also say which GPU, Windows version (10 or 11)
nick0451 commentedon Nov 28, 2026
In-game numbers for the late-wait stages, since you have no assets to run.
Setup: release build of main at
63b902f,victory.exe playwith its defaults. RTX 3090 24 GB (driver 610.88), i9-14900K, 32 GB, Windows 11. Series S, DLSS Performance, frame generation off. The same save in an interior (about 5,800-6,000 draws a frame). Stages were run alternately, two runs each, and the figures are medians of the last 12 frame lines in the world.VICTORY_LATE_WAITlate_stage()falls to 3 when the relay is on, which the launcher sets)210(an earlier session in the same room)Notes:
VICTORY_LATE_WAIT=0explicitly turns late wait off, so A/B runs against=0measure the wrong baseline. (I made that mistake first; these numbers are against the real default.)If it helps your step 1, I can run your baseline switches (
VICTORY_SUBMIT_FRAMES=2,VICTORY_SUBMIT_DEPTH=128,VICTORY_LATE_WAIT_LISTS=512,VICTORY_BURY_LAG=8) here and post thecard_stepsrefusals and the at-presents lines.Measured with an AI assistant (Claude Code); every number above is from this PC's logs.
GPU, shaders: track shader buffer writes in a 64 KiB dirty-page bitma…
GPU, shaders: track shader buffer writes in a 64 KiB dirty-page bitma…
shiman1901 commentedon Nov 28, 2026
@nick0451 Huge thanks for running those A/B numbers — that's super clean data, and great catch on
92%vs67%GPU busy (#699). You're completely right: in a 92%-busy room, overlapping submissions has at most ~5–8% headroom, whereas the ~67%-busy scene is where the submitting thread is actually the wall.Yes, running the Step 1 switches would be massively helpful! If you have time for a quick A/B against your real default (ideally in that lighter ~67%-busy scene from #699, or both if convenient):
The specific lines from the log that would settle the biggest open questions from our static audit are:
at presents/ queue line (submissions prepared ... presents ... in the line ... at presents) +card busy %/frame/preparing— tells us right away whetherSUBMIT_FRAMES=2immediately stalls on the 2-buffer swapchain (BUFFERS = 2) or actually lifts FPS when the card is ~67% busy (and whether you notice any visual flicker/tearing from 2 frames sharingHostTexture.state).card_stepsrefusals (steps done on the card ... submissions refused) — shows which refusal reason is actually firing in practice.DynamicRefused/tables asked, N refusedandstood waiting— shows if dynamic slots or intra-frame settles spike when pushing 2 frames ahead.VICTORY_MEMORY_MAP=1on your 32 GB system — would give a real live baseline for how much commitidle host lists+CARD_COMPARE/ non-cardedbeforesnapshots actually hold onmain @ 63b902fbefore anyone writes a PR fortrim_idleorSLOT_DIRTY.Really appreciate you testing this live — once we see those lines, we'll know immediately whether Stage 1 (
card_steps+ intra-frame settles) or Stage 3 (BUFFERS = 3+ per-flightHostTexture.state) is the real bottleneck on currentmain!nick0451 commentedon Nov 28, 2026
Step 1 switches, run here:
VICTORY_SUBMIT_FRAMES=2,VICTORY_SUBMIT_DEPTH=128,VICTORY_LATE_WAIT_LISTS=512,VICTORY_BURY_LAG=8.Caveat first: this is not the lighter scene. My save has moved since #699, and the frozen save I benchmark from is outdoors on a balcony by the water, where the card is about 95% busy. So this answers "does it stall or break", not "does it lift fps where the submitting thread is the wall". I'll add the lighter scene when I have a save there.
Setup: release build of main at
63b902f,victory.exe play, RTX 3090 24 GB, i9-14900K, 32 GB, Windows 11, Series S, DLSS Performance, frame generation off. The same frozen save for every run, standing still. One warm-up start per variant, then default and step 1 in turn, three rounds each. Each run is 40 s to settle, 60 s measured. The figures are medians of each run's lines, then the median of the three runs.On your questions:
at presents: the second frame takes the title's 6.7 ms a frame of waiting at presents to zero, and nothing stalls on the swap chain: no waits for room, no unmet waits at a present, the same depth in the line. The fps difference (+2%) is inside the 2-3% noise of this setup (main A/A). With the card at 95%, there is no room for it to show. I saw no flicker or tearing in end-of-run screenshots of all six runs, but a still frame cannot rule out a one-frame flicker.card_stepsrefusals: only one reason fires, in both variants: "a copy at its place in a list writes what it reads, or reads or writes what it writes", 0.12 (default) and 0.08 (step 1) per frame. So refusals are rare here, and the 174 MiB fill case fromfindings.mddoes not appear in this scene.DynamicRefused/ tables refused / no free dynamic slots: none in any measured window of either variant.VICTORY_MEMORY_MAP=1(diagnostics build of63b902f, one warmed run, default switches), committed / in memory:Raw logs are available if you want other lines.
Measured with an AI assistant (Claude Code); every number above is from this PC's logs.
shiman1901 commentedon Nov 28, 2026
@nick0451 Massive thanks for running that clean 3-round A/B and pulling
VICTORY_MEMORY_MAP=1— both results are super informative!Two big takeaways from your numbers:
VICTORY_SUBMIT_FRAMES=2completely eliminatedtitle waited at presents(6.7 ms -> 0.0 ms) with zero swapchain stalls, zeroDynamicRefused, and zero unmet waits even onBUFFERS = 2. Obviously at 95% GPU busy it can't move FPS, so seeing the same switch on a ~65–70%-busy CPU-bound scene (where#699showed19.5 mswaiting at presents!) will be the real test — plus watching out for any 1-frame flicker in motion fromHostTexture.state.VICTORY_MEMORY_MAP=1dump:write-combined (buffers shared with the card)is holding 8,630 MB committed vs only 1,545 MB resident (65 × 64 MB+94 × 32 MB= 6.8 GB of commit alone, over 7 GB of uncommitted/cold WC overhead!). On 16–32 GB systems that looks like the single biggest remaining commit pressure point on63b902f, even bigger than host-list allocators now thatmemory stackis on by default.Also reassuring that
card_stepsrefusals are down to0.08–0.12/frameon your 24 GB setup. Whenever you get a save in a lighter CPU-bound spot, thatSUBMIT_FRAMES=2A/B will be super interesting — and meanwhile we'll dig into where those65 × 64 MB+94 × 32 MBWC shared buffers come from!shiman1901 commentedon Nov 28, 2026
@nick0451 Quick follow-up on the 8,630 MB write-combined / 1,545 MB resident mystery from your dump — turns out my initial impression ("7 GB of cold shared upload overhead") was mostly a WDDM / NVIDIA driver quirk, and we nailed it down empirically!
We ran an isolated D3D12 VirtualQuery + QueryWorkingSetEx probe (mirroring copystat.rs) across 21 test cases on an RTX 3060 (driver 621.35):
65 × 64.00 MB (4,158 MB) is mostly VRAM (pool::TEXTURES), NOT host staging buffers:
On NVIDIA driver 621.35, CreateHeap(D3D12_HEAP_TYPE_DEFAULT, 64 MiB) with pool.rs:826-835's exact flags (ALLOW_ONLY_NON_RT_DS_TEXTURES | CREATE_NOT_RESIDENT) shows up in VirtualQuery as 64.00 MB PAGE_WRITECOMBINE, committed = 64.00 MB, resident = 0.00 MB.
That matches your log almost to the block: 58 × 64 MB (pool::TEXTURES = 3,712 MB VRAM) + 5 × 64 MB (pool::STAGING = 320 MB) + 2 allocated between the two unsynchronized log prints = 65 × 64.00 MB!
Also ruled out ID3D12CommandAllocator (32 allocators × 50,000 commands = 0 bytes of PAGE_WRITECOMBINE) and shared_buffer (CUSTOM / WRITE_BACK / L0 = 0 bytes WC).
94 × 32.00 MB (2,664 MB, avg 28.34 MB) is NVIDIA's 32 MiB small-resource arena fragmentation:
Resources ≥ 4 MiB get dedicated bases of their exact size (no rounding to 32/64 MiB), whereas small ≤ ~2 MiB UPLOAD resources are sub-allocated by the driver into 32.00 MiB WC arenas.
Reproducing churn (1,500 × 1 MiB UPLOAD -> 48 × 32.00 MB arenas at 31.64 MB avg commit -> freeing every 2nd buffer) kept the exact same 48 × 32.00 MB arenas while the driver MEM_DECOMMITted the holes down to 26.30 MB avg commit (whole = 32.00 MB, committed < 32 MB, regions > 1).
Why 8,630 MB committed vs 1,545 MB in memory makes total sense:
~3.7+ GB is pure DEFAULT VRAM (resident = 0 by definition), and cold UPLOAD pages are trimmed out of the working set by Windows while keeping their commit charge (verified with EmptyWorkingSet: 2.68 GB committed -> 1.5 MB resident, commit unchanged).
Practical takeaway
So there is no 7 GB host-RAM leak hiding in that write-combined line — actual host RAM there is ~1.5 GB (and touching pool::TEXTURES wouldn't save RAM).
Tiny diagnostic win for copystat.rs:727-740: because NVIDIA exposes DEFAULT VRAM heaps as PAGE_WRITECOMBINE (resident = 0), the label "write-combined (buffers shared with the card)" mixes pure VRAM with host upload buffers. Printing per-group present (in memory) next to committed would instantly make 65 of 64.00 MB (320 MB in memory) self-explanatory in future memory-map dumps.
For real host RAM / commit savings on 16–32 GB rigs (a realistic ~0.5–1 GB), the actual knobs are capping idle texture staging (texture.rs:538) + trimming STAGING_KEPT (pool.rs:37, 8 -> 2), host/send.rs:123 (768 -> 256 MB), and scratch SPARE_KEPT (host.rs:2244, 1 GB -> 256 MB) — easy to cross-check against the staging of textures: N alive X MB line in a memory-map log.
tippythetaidum commentedon Nov 28, 2026
Some in-game numbers for the "2 frames in flight" question, on a PC where the submitting thread was thought to be the wall. RTX 5080 + Ryzen 7 9800X3D (8 cores, one CCD), 32 GB, Windows 11 26200.
63b902fwith #1014, #1066, #1133, #1134 and #393. Series X 2560x1440, DLSS Quality, frame generation off, relay 2 + relay copy on, indoors, the same save restored before each run (5,000 to 7,500 draws a frame).Where a frame of ~45 ms goes (the card's clock line and
queue::behind):VICTORY_SUBMIT_SPLIT=1+VICTORY_OFF_LINE=1(#1066), two alternating pairs of runs: the lane thread's work drops 4 to 6 ms (to 28 to 31 ms), and the sender works 3.8 ms. The title's waits at presents and the frame rate stayed the same (20 to 22 fps).VICTORY_SUBMIT_FRAMES=2with the split on: the waits at presents go to 0.0 ms, but the lane thread's work goes up to 41 to 44 ms a frame. The settles for "lists in the air" take 4 to 14 ms a frame. The median frame stays at 46 ms. So with this tree, a second frame in the line moves the wait into the submitting thread instead of removing it.VICTORY_PORT_CONSTANTS=1(16 GB card): 7.7 fps, median frame 159 ms. Far worse, as the README warns for 12 GB.What did help on this card was #1271's swap-chain sizing, with frame generation on. With 2 back buffers the present call held the presenting thread ~32 ms a frame at 4x, and the rendered rate sat at exactly 14.0. With 8 back buffers the present takes 0.1 ms.
shiman1901 commentedon Nov 28, 2026
@tippythetaidum Huge thanks for bringing real 50%-GPU-busy numbers on a 9800X3D + RTX 5080 — that
"lists in the air"line (4 to 14 msper frame!) is a huge smoking gun!Checking
host.rs:3046-3051andhost.rs:5725-5750,"lists in the air"(WHY_MOST) is the defaultVICTORY_LATE_WAIT_LISTS = 256cap — andflyingcounts command lists (*flying += order.len()), not submissions, so 40–60 submissions × 1–3 lists/submission hits256at ~1.5–2 frames and forcesrelay_wait/settle(WHY_MOST)right on the lane thread! (And right behind it sitsVICTORY_SUBMIT_DEPTH, default64atqueue/behind.rs:728-731.)If you have a minute to re-test
VICTORY_SUBMIT_FRAMES=2(with#1066split on) together with:— that should clear those
4–14 ms"lists in the air"settles (just watchdynamic slots: N tables asked, M refusedin the log, since holding 2 frames of lists at once can pressure dynamic slots — which#821/VICTORY_DYNAMIC_WAITaddresses).Also great validation on
#1271(BUFFERS = 2holding present for~32 msat 4x FG ->0.1 mswith 8 back buffers) — confirms our Stage 3BUFFERS = 2choke point from live data too!nick0451 commentedon Nov 28, 2026
The indoor run, as promised. The step 1 switches (
VICTORY_SUBMIT_FRAMES=2,VICTORY_SUBMIT_DEPTH=128,VICTORY_LATE_WAIT_LISTS=512,VICTORY_BURY_LAG=8) against the default, in the living room of the same house.Setup: release build of main at
32ecacf(current),victory.exe play, RTX 3090 24 GB, i9-14900K, Windows 11, Series S, DLSS Performance, frame generation off. The save can't be made indoors (it reloads on the balcony), so every run replays the same recorded walk into the living room (keyboard keys throughVICTORY_KEYS_FILE), then stands still. Each run is checked by screenshot: all 6 measured runs ended inside, and two stopped at a slightly different spot (about 8,600 draws against 7,700-8,000) and are left out. One warm-up start per variant, then the variants in turn, three rounds. Each run is 40 s to settle, 60 s measured.So, from this PC: step 1 is clean in two scenes on current main, and the fps question needs a faster card or a CPU-bound scene.
Measured with an AI assistant (Claude Code); every number above is from this PC's logs.
shiman1901 commentedon Nov 28, 2026
@nick0451 Awesome — clean 2/2 scenes on 32ecacf with 0.0 ms present waits and 0 refusals! Agreed, @tippythetaidum's 50%-busy 5080 with LATE_WAIT_LISTS=512 + SUBMIT_DEPTH=128 will be the real FPS test.