GPU: back shadow buffers, page tables, and dirty bitmaps in VRAM on discrete GPUs #3312
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3312"
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 danielibabet on 2026-11-26T17:03:11Z.
Summary
Addresses part of #3028 on discrete GPUs where
GPUUploadHeapSupportedisfalse(e.g., NVIDIA RTX 4070 / Ada Lovelace without ReBAR enabled).Root Cause
On discrete GPUs without
GPUUploadHeapSupported,Host::shared_buffer(D3D12_HEAP_TYPE_CUSTOM,WRITE_BACK,MEMORY_POOL_L0) andHost::upload_buffer(MEMORY_POOL_L0) place all shadow buffers, title-memory page tables, and atomic dirty-page bitmaps in system RAM over PCIe. Every shader buffer load, UAV store, page-table lookup, andInterlockedOratomic crosses the PCIe bus instead of hitting local GDDR6X / L2.Changes
host.rs:Host::is_uma()(D3D12_FEATURE_ARCHITECTURE) andHost::vram_shadow_budget()(25% of localDXGI_MEMORY_SEGMENT_GROUP_LOCALbudget on discrete GPUs so streaming textures are not evicted).Host::default_uav_buffer(), reusable 64 MiBUPLOADring (upload_vram_copies), and reusable 32 MiBREADBACKring (readback_vram_copies) synchronized viarun_copy_list.memory.rs:Shared::table(title-memory page table) andBitmap(title-memory dirty-page bitmap) withdefault_uav_bufferon discrete GPUs, synced pre/post submission viaCopyBufferRegion.shadow.rs:shadow::bitmap(VIEW_WRITES/VIEW_READS) withdefault_uav_bufferon discrete GPUs.Shadowallocations (find,loose,Arena) up tovram_shadow_budget()(<= 128 MiBper allocation) inD3D12_HEAP_TYPE_DEFAULTVRAM with demand-committedCpuMem(alloc_zeroed) instead of duplicatingL0D3D12 resources, falling back cleanly toshared_bufferonce the VRAM budget is reached or on UMA/WARP adapters.Measured Results (NVIDIA RTX 4070 12 GB, Windows 11, i9-14900KF)
VICTORY_GPU_TIMING=1) with VRAM-backed shadow buffers + page tables/bitmaps:on the GPU(5.1k–5.3k draws/frame): ~405–417 ms -> ~285–323 ms (total frame time ~545 ms -> ~440 ms).Verification
cargo test -p victory-gpu --locked -- --test-threads=1 --skip dynamic_slots_are_held_until_released --skip lists_share_a_table_and_copies_keep_their_views: 229 passed, 0 failed (the 2 skipped tests requireHEAP_VIEWS <= 1_000_000or WARP on this NVIDIA driver; tested separately on WARP in PR #3218).cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: 0 warnings.cargo run -p xtask --locked -- policy: asset policy: 191 files ok.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T17:07:11Z.
Review: APPROVED
Reviewed the diff and verified locally on Windows 11 x64 with a discrete NVIDIA RTX 5090 (
is_uma() == false, exercising the VRAM-backed shadow buffers, page tables, and dirty bitmaps path):cargo test -p victory-gpu --lib shadow:: -- --test-threads=1(RTX 5090): 10 passed, 0 failed.cargo test -p victory-gpu --lib memory::tests:: -- --test-threads=1 --skip lists_share_a_table_and_copies_keep_their_views(RTX 5090): 7 passed, 0 failed (pre-existing #1744 test skipped).cargo test -p victory-gpu --lib draw:: -- --test-threads=1(RTX 5090): 20 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T20:58:42Z.
Review: CHANGES_REQUESTED
Moving hot shadow buffers, page tables, and dirty bitmaps into
DEFAULTVRAM on discrete GPUs (!is_uma()) while keeping UMA/APU/WARP on shared memory is a great direction, and theclippy/policychecks and WARP (UMA=true) suite pass cleanly.Testing on a discrete GPU (
NVIDIA GeForce RTX 5090,UMA=false,vram_shadow_budget=8,236,302,336bytes,VICTORY_D3D12_DEBUG=1) versus WARP (UMA=true) and probing an integrated GPU (AMD Radeon(TM) Graphics,UMA=true) uncovered four blocking correctness/synchronization bugs on the discrete VRAM path:1. Silent data loss for marked-page UAV writes (
VIEW_WRITES) into VRAM shadows (crates/victory-gpu/src/host.rs:1315-1339)Host::executeonly schedules VRAM ->CpuMemreadbacks for explicitStep::GpuWriteentries before runningshadow::copy_back_marks. Any shader write through a heap/bindless/marked UAV that sets a bit inVIEW_WRITESwithout a matchingStep::GpuWriteleavesShadow::data(CpuMem) holding the old pre-GPU bytes;Shadow::copy_back_markedthen compares staleCpuMemagainst title memory and writes back zero bytes.0x1337c0deinto a VRAM shadow and setting itsview_writes(false)bit:is_uma=false):gpu_word=0x1337c0de,title_word=0x00000000(write lost).is_uma=true):gpu_word=0x1337c0de,title_word=0x1337c0de.2. Silent data loss for title-memory shader writes via the page table (
crates/victory-gpu/src/host.rs:1315-1339,crates/victory-gpu/src/memory.rs:689-691)Similarly, shaders writing through the title-memory page table mark pages in
map.dirty(noStep::GpuWrite), andmemory::bind'sdefer_afterclosure callscopies[k].copy_back_page(at). Because those dirty pages are never copied back from VRAM intocopies[k].data(CpuMem) aftersync_vram_postreads back the dirty bitmap,copy_back_pagesees unchangedCpuMemand writes nothing to title memory. (Existing testa_submission_that_missed_leaves_the_copies_at_oncedid not catch this because its non-missed branch only checked GPU-sideread(), not CPUtitle().)memory::tests::WRITEshader storing0xcafef00dthrough the page table:is_uma=false):gpu_word=0xcafef00d,title_word=0x00000000(write lost).is_uma=true):gpu_word=0xcafef00d,title_word=0xcafef00d.3. Global
ACTIVE_BITMAPS.drain(..)drops dirty/missed bitmaps across separate submissions (crates/victory-gpu/src/memory.rs:205, 239-254, 695-703)memory::bindpushes(vram, ram)into the process-globalACTIVE_BITMAPSat record time, andsync_vram_postdrains the entire vector on whicheverHost::executeruns next:L1andL2are both recorded withmemory::bindand submitted separately (host.execute(&[&L1])thenhost.execute(&[&L2])), submittingL1drainsL2's bitmap too. WhenL2later executes, its VRAM dirty bitmap is never zeroed beforeL2and never copied back to RAM afterL2, silently dropping bothL2's missed-region withholding and its page writebacks.ACTIVE_BITMAPSstill holds clones of a bitmap already returned toBITMAP_POOL.L1andL2(L2setting region-1 missed bit inmap2.dirty), then executing[&L1]followed by[&L2]:is_uma=false):missed_regions_delta=0(L2's miss completely lost).is_uma=true):missed_regions_delta=1.(vram, ram)bitmap pair with the specificHostList(Deferred) rather than a global vec, and only zero/read back the bitmaps belonging toruns.4.
ID3D12CommandAllocator::Resetcalled while previous copy list is still executing (crates/victory-gpu/src/host.rs:2861, 2959-2970, 2983-3017)upload_vram_copiessubmits its finalflush(..., wait = false)onstatic CMD's single(alloc, list)without signaling/waiting on a fence, andrun_copy_listunconditionally callslet _ = alloc.Reset();on the next call (also discardingReset/CloseHRESULTs). This immediately violates D3D12 allocator lifetime rules whenever another copy runs before the previous GPU submission finishes (e.g.,Shadow::read_host/write_hostcallingflush_test_vram_uploads()immediately followed bytest_readback_buffer/test_upload_buffer, orHost::execute(&[])).VICTORY_D3D12_DEBUG=1: callingsh.copy(...)+sh.read_host(...)produced 16/16 D3D12 Debug Layer errors:ID3D12CommandAllocator::Reset: A command allocator ... is being reset before previous executions associated with the allocator have completed.(0/16 on WARP).flush_test_vram_uploads(host.rs:2963-2967), falling back tolet mut dummy = 0u64;whenself.submitted.try_lock()fails can signal the monotonicself.fenceto1while the fence is already past1, causingSetEventOnCompletion(1, ...)to return immediately without waiting.Additional notes
crates/victory-gpu/src/shadow.rs:970-975,host.rs:2798, 2867):has_vram_bitmaps()callsbitmap(false)andbitmap(true)on everyHost::execute, eagerly allocating both bitmaps on the first submission and forcing bothupload_vram_copiesand a second synchronousreadback_vram_copies+ fence wait on every single submission on discrete GPUs even when no shader uses view write marks or VRAM shadows. Consider checking whether eitherOnceLockis actually initialized (and whether the submission used view marks/reads) instead.crates/victory-gpu/src/shadow.rs:133-157):try_vram_shadowchecksVRAM_BYTES.load(Relaxed) + size > budgetbeforefetch_add(non-atomic TOCTOU across threads), and ifCpuMem::new(size)fails at line 154,VRAM_BYTESis never decremented. Also noteShadow::peek(underdiagnostics) still readsself.datawithout a VRAM readback.Imported from Marvisak/VIctory. Originally posted by danielibabet on 2026-11-26T21:19:29Z.
Thanks for the thorough review and live RTX 5090 +
VICTORY_D3D12_DEBUG=1repros @fuzeofficlal! Pushed fixes for all four blocking issues and the two notes infc39e73:VIEW_WRITESreadback beforecopy_back_marks(shadow.rs,host.rs): addedshadow::vram_marked_reads()so after bitmap readbacks, any marked pages belonging to VRAM-backed shadows are copied back toCpuMemin a batch beforecopy_back_marksruns. Covered by new testshadow::tests::vram_marked_view_writes_go_back_to_title.defer_after(memory.rs,host.rs): addedDeferred::vram_probes/defer_vram_probesomemory::bindcollects dirty pages backed by VRAM shadows (without clearing the bitmap) and reads them back toCpuMembeforecopy_back_page. Covered by new testmemory::tests::vram_page_table_writes_go_back_to_title.ACTIVE_BITMAPS(memory.rs,host.rs): removedACTIVE_BITMAPSand stored each list's(vram, ram)bitmap pair inDeferred::vram_bitmaps, sosync_vram_pre/sync_vram_postonly zero and read back bitmaps belonging to the executedruns. Covered by new testmemory::tests::separate_memory_bind_submissions_keep_their_own_bitmaps.host.rs):upload_vram_copiesnow waits on the final flush,run_copy_listuses its own dedicatedID3D12Fenceand monotonic counter underCMD(avoiding bothReset-while-in-flight and anyself.submitted/1collision fromflush_test_vram_uploads), and checksReset/Closeresults.has_vram_bitmaps,sync_bitmaps_pre, andsync_bitmaps_postnow useexisting_bitmap()(OnceLock::get()) so unused bitmaps are never eagerly initialized.try_vram_shadownow reservesVRAM_BYTESatomically viafetch_updateand rolls back on allocation failure intry_vram_shadow/alloc_backing.Verified locally on Windows 11 x64 (RTX 4070,
is_uma() == false) withVICTORY_D3D12_DEBUG=1: all 3 new regression tests +a_submission_that_missed_leaves_the_copies_at_oncepass with zero D3D12 debug errors,cargo clippy -p victory-gpu --all-targets -- -D warningsis clean, andcargo xtask policypasses (191 files ok).Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T21:41:00Z.
Review: CHANGES_REQUESTED
Thanks for the quick turnaround — I re-verified all four issues from the previous round on a discrete RTX 5090 (
is_uma = false) and on WARP (is_uma = true) withVICTORY_D3D12_DEBUG=1:VIEW_WRITES(compute shader writing directly to VRAM withoutStep::GpuWrite): passes on both RTX 5090 and WARP (0x1337c0dereaches title memory).memory::bind: passes on both RTX 5090 and WARP (0xcafef00dreaches title memory).memory::bindsubmissions (L1/L2): passes on both (missed_regions_delta = 1).Shadow::copy+read_hostunderVICTORY_D3D12_DEBUG=1: passes on both with zero debug layer errors.However, discrete-GPU testing uncovered two remaining blocking issues:
1. Concurrent title + GPU writes merged in
Shadow::copy_backandShadow::copy_back_markednever upload the merged bytes back to VRAMcrates/victory-gpu/src/shadow.rs:585-600(copy_back_or_not) andcrates/victory-gpu/src/shadow.rs:659-669(copy_back_marked)When both the GPU and a title thread write different offsets of the same 64 KiB page during a submission,
merge_writeback(...)copies the title's new bytes into CPUself.data(CpuMem) and thent.taken(...)marks the page clean inTracked. Becauseself.queue_vram_upload(...)is not called, the VRAM buffer (self.buffer) keeps the stale pre-merge bytes, and subsequentShadow::refresh/Shadow::updatecalls return0immediately (self.clean() == true), leaving the title's concurrent write permanently invisible to the GPU.Live reproduction on RTX 5090 (
is_uma = false) vs WARP (is_uma = true) — initial page[0x11111111, 0x22222222](and[0x33333333, 0x44444444]), submission 1 writes word 0 on GPU while the title writes word 1 (0xbbbbbbbb/0xdddddddd), submission 2 callsrefreshand reads both words in a compute shader:copy_back):title_after_s1 = [0xaaaaaaaa, 0xbbbbbbbb],clean = true,gpu_saw_s2 = [0xaaaaaaaa, 0x22222222](expected[0xaaaaaaaa, 0xbbbbbbbb])copy_back_marked):title_after_s1 = [0x1337c0de, 0xdddddddd],clean = true,gpu_saw_s2 = [0x1337c0de, 0x44444444](expected[0x1337c0de, 0xdddddddd])Calling
self.queue_vram_upload(at as u64, n as u64)right aftermerge_writeback(title, host, old)incopy_back_or_notandself.queue_vram_upload((from - start) as u64, n as u64)in theSome(before)arm ofcopy_back_markedresolves both cases (verified live on RTX 5090: both submissions read back[0xaaaaaaaa, 0xbbbbbbbb]and[0x1337c0de, 0xdddddddd]).2. Existing
shadow::tests::fail under default parallel test execution on discrete GPUs (self.event/CMD/VRAM_UPLOADS/BITMAPSraces)Running
cargo test --locked -p victory-gpu --features diagnostics -- shadow::tests::on RTX 5090 fails 3/3 times (while passing 10/10 on WARP and 10/10 with--test-threads=1):shadow::tests::bytes_off_the_runtimes_memory_are_copied_at_each_use(shadow.rs:1690):left: [0], right: [4660]shadow::tests::title_writes_under_a_busy_range_are_copied(shadow.rs:1625):left: 0, right: 85There are three concurrency bugs interacting here:
Host::run_test_copy_sync(crates/victory-gpu/src/host.rs:2989-3005) callsself.run_copy_list(record, None)(releasing theCMDmutex before GPU execution finishes, allowing another thread to resetCMD's allocator while in flight) and then waits on the shared auto-resetself.event(host.rs:3002) without holdingself.submitted, violatingHost's safety contract (host.rs:69) and racing withHost::execute/run_copy_list(host.rs:3072). GivingCMDits own private event handle created alongside its dedicatedfenceand havingrun_test_copy_syncpassSome(0)intorun_copy_listkeeps allocator reset and wait serialization strictly insideCMD(and avoids re-entrant deadlock onself.submittedwhenwrite_hostruns insidedefer_host).Host::flush_test_vram_uploads(host.rs:3019-3025) drains globalVRAM_UPLOADSand flushes without serializing concurrent callers: thread B can drain thread A's pending upload, and thread A then observes an empty queue and reads zeroed VRAM before thread B's copy finishes. Holding a dedicated mutex acrosstake_vram_uploads()+upload_vram_copies(...)inflush_test_vram_uploadseliminates this race.shadow::tests::vram_marked_view_writes_go_back_to_title(shadow.rs:1949) submits viaHost::executewhile othershadow::tests(marked_pages_go_back_by_the_bytes_the_gpu_changed,marks_of_shaders_using_title_memory_are_held_back) concurrently mutate and clear the globalBITMAPSviacopy_back_marks(...)without serialization, causing intermittentleft: 0, right: 322420958failures in parallel runs. (Also note thatvram_marked_view_writes_go_back_to_titleusescopy_w.write_host(...), which writes to CPUself.dataas well as VRAM, so it would still pass even without VRAM readback; writing only tocopy.bufferon the GPU viaCopyBufferRegionfrom an upload buffer makes the regression test strictly exercisevram_marked_reads.)Minor note (non-blocking)
Host::execute,readback_vram_copies(host.rs:1357) runs beforeGetDeviceRemovedReason()(host.rs:1380). If the main submission triggers device removal,alloc.Reset().expect(...)insiderun_copy_list(host.rs:3061) can panic beforeHost::executereachesfail(...)and reports DRED breadcrumbs /removal_data(runs). Moving theGetDeviceRemovedReason()check ahead of the VRAM readback block preserves crash diagnostics.Imported from Marvisak/VIctory. Originally posted by danielibabet on 2026-11-26T22:51:59Z.
Thanks @fuzeofficlal for the detailed review and live RTX 5090 repros! Fixed both blocking issues and the minor note:
VRAM upload after concurrent
merge_writeback(crates/victory-gpu/src/shadow.rs):self.queue_vram_upload(at as u64, n as u64)right aftermerge_writeback(title, host, old)+write_mappedincopy_back_or_not.self.queue_vram_upload((from - start) as u64, n as u64)in theSome(before)arm ofcopy_back_markedwhenmerge_writebackwrites merged bytes.Parallel test races (
crates/victory-gpu/src/host.rs&shadow.rs):Host::run_copy_list(CMD) now owns a privateCreateEventWhandle alongside itsfence, andHost::run_test_copy_synccallsself.run_copy_list(record, Some(0))so allocator reset and fence wait stay strictly serialized insideCMDwithout touchingself.event.Host::flush_test_vram_uploadswith a dedicatedFLUSHmutex acrosstake_vram_uploads()+upload_vram_copies(...).BITMAPStests (marked_pages_go_back_by_the_bytes_the_gpu_changed,marks_of_shaders_using_title_memory_are_held_back,vram_marked_view_writes_go_back_to_title) withTEST_BITMAP_LOCK, and updatedvram_marked_view_writes_go_back_to_titleto write0x1337_c0dedirectly tocopy.bufferon the GPU viaCopyBufferRegionso it strictly exercisesvram_marked_reads.Device-removal diagnostics order (
Host::execute):GetDeviceRemovedReason()ahead of the VRAM readback block sofail(...)preserves DRED /removal_datadiagnostics instead of panicking insiderun_copy_list.Verified locally on RTX 4070 (Windows 11):
cargo test --locked -p victory-gpu --features diagnostics -- shadow::tests::(parallel, 2 consecutive runs: 10 passed / 0 failed each)cargo clippy -p victory-gpu --all-targets -- -D warningscargo xtask policyImported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-26T23:00:34Z.
In-game on an RTX 5090 (driver 620.73.04), Linux, GE-Proton11-14 Wine with vkd3d-proton, GTA VI's opening yard.
Setup:
mainplus #2958, #3120 (VICTORY_GPU_OVERLAP=1), #2309, #2461 and a few others this setup needs.fc39e73f, 3 small conflicts resolved.That's about 31% less frame time, the biggest single gain I've measured here, with no faults or device removal. VRAM peaks at 21.8 GB instead of ~14 GB.
Three things I noticed reading it, with line numbers at
fc39e73f:Host::runuploads before and reads back after the lists withrun_copy_list(.., wait = true)on the direct queue (host.rs~2840/2871 and ~2915/2945, called from ~1357/1365; the wait is at ~3038 and ~3066–3072). So the CPU waits for each submission's GPU work: average GPU utilisation fell from 64% to 37% here, and #3120's overlap stops helping. Completing the read-back on its own fence, for example on the completion thread that already owns in-flight submissions, might give some of that back. I haven't tried that yet.shadow.rs~1294, ~1333) leaves this title's 174 MiB descriptor heap copy in system memory.AI-assisted (Claude); measured on my machine, no game data shared.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T23:39:49Z.
Review: CHANGES_REQUESTED
Re-tested
317ea6fbon a discrete GPU (is_uma() == false,VICTORY_D3D12_DEBUG=1) and WARP. The previous fixes for the normalmerge_writeback == trueupload path,CopyEventisolation, and standaloneshadow::testsparallel execution (5/5 parallel rounds passed 10/10 on discrete GPU with zero D3D12 Debug Layer errors) are working as intended.However, live discrete-GPU testing uncovered two remaining blocking issues:
1. Permanent silent VRAM data loss when
merge_writebackreturnsfalsecrates/victory-gpu/src/shadow.rs:27-37(merge_writeback),crates/victory-gpu/src/shadow.rs:585-601(copy_back_or_not),crates/victory-gpu/src/shadow.rs:661-674(copy_back_marked)merge_writeback(title, host, old)updates*host_byte = *title_byteto absorb concurrent CPU writes into the CPU staging slice (self.data) unconditionally, but itsboolreturn value only reflects whether any byte intitlechanged (changed != 0). Bothcopy_back_or_not(line 588) andcopy_back_marked(line 668) only callself.queue_vram_upload(...)whenmerge_writebackreturnstrue, yet both still unconditionally mark the 64 KiB page clean viat.taken(...)right afterward (lines 591/601 and 672-674).On a discrete GPU (
copy.vram == true), whenever CPU staging absorbs CPU writes whilemerge_writebackreturnsfalse,t.taken(...)clears the dirty bit without queueing a VRAM upload, so subsequentShadow::update()calls return0and VRAM permanently retains stale pre-CPU-write data. Reproduced live on discrete hardware (is_uma=false,copy.vram=true):copy_back_marked(idempotent GPU UAV write marking the page + concurrent CPU write0xdeadbeefat+64):written=0, clean=true, next_update=0, title=0xdeadbeef, staging=0xdeadbeef, vram=0x22222222(stale).copy_back(GPU writes0xaaaaaaaaat+0while CPU writes the same0xaaaaaaaaat+0and a new0xcafebabeat+64):written=0, clean=true, next_update=0, title=0xcafebabe, staging=0xcafebabe, vram=0x22222222(stale).Fix: Have
merge_writebackreturn(title_changed, host_changed)(trackinghost_changed |= prev_host ^ *title_bytebefore writing*host_byte = *title_byte), write back to title memory whentitle_changedis true, and callself.queue_vram_upload(...)wheneverhost_changedis true (which also avoids redundant VRAM uploads when onlytitlechanged).2. Unlocked
RINGbuffer andflush_test_vram_uploads/Host::executeconcurrency races break parallelvictory-gputests on discrete GPUscrates/victory-gpu/src/host.rs:2855-2906(upload_vram_copies),crates/victory-gpu/src/host.rs:2929-2970(readback_vram_copies),crates/victory-gpu/src/host.rs:3007-3015(flush_test_vram_uploads),crates/victory-gpu/src/host.rs:1261-1272(Host::execute)upload_vram_copiesandreadback_vram_copieslockstatic RING, clone(ring_buf, ring_ptr), and immediately drop the mutex guard before copying throughring_ptrand submittingCopyBufferRegion.flush_test_vram_uploadsonly locks its ownstatic FLUSHand does not acquireself.submitted, so it runs concurrently withHost::execute. That both races onring_ptrat offset0and allowsHost::executeto drainVRAM_UPLOADSviatake_vram_uploads()while its GPU upload is still in flight;flush_test_vram_uploadsthen sees an empty queue and returns early before the copy completes, causing subsequent VRAM reads to observe zeros.TEST_BITMAP_LOCKonly covers tests insideshadow.rs, whiledraw::testsexercises the same globalVIEW_WRITESbitmap concurrently viaHost::execute(sync_bitmaps_pre/copy_back_marks).Running the full
victory-gpuunit suite in parallel on discrete hardware (--features diagnostics,VICTORY_D3D12_DEBUG=1) failed 2/2 runs with zeroed-readback/bitmap failures that all pass serially (--test-threads=1):shadow::tests::bytes_off_the_runtimes_memory_are_copied_at_each_use([0]vs[22136]),draw::tests::marked_subpage_uav_writes_copy_back_and_keep_neighbor_bytes(0vs0xdeadbeef),draw::tests::compute_view_marks_rebind_after_depth_twin_conversion(0x0).shadow::tests::what_a_frame_withholds_leaves_the_copies_at_its_end((0, 0)vs(17, 17)),bindless::tests::heap_views_follow_writes_through_another_mapping(0vs9034).Fix: Hold the
RINGmutex guard for the full duration ofupload_vram_copiesandreadback_vram_copies, acquireself.submittedinflush_test_vram_uploadsbefore callingtake_vram_uploads(), and coordinate tests that mutate/read the globalVIEW_WRITESbitmap acrossshadow::testsanddraw::tests.Imported from Marvisak/VIctory. Originally posted by danielibabet on 2026-11-27T00:04:10Z.
Thanks @fuzeofficlal for catching both remaining issues! Fixed in
HEAD:merge_writebackreturning(title_changed, host_changed)(crates/victory-gpu/src/shadow.rs):merge_writebacknow returns(title_changed, host_changed)(trackinghost_changed |= prev_host ^ *title_bytebefore*host_byte = *title_byte).copy_back_or_notandcopy_back_markedwrite back to title memory whentitle_changedis true and callself.queue_vram_upload(...)wheneverhost_changedis true, preventing stale VRAM whenself.dataabsorbs CPU writes whiletitleitself did not change.RING,flush_test_vram_uploads, andTEST_BITMAP_LOCKcoordination (crates/victory-gpu/src/host.rs,shadow.rs,draw.rs):upload_vram_copiesandreadback_vram_copiesnow hold theRINGmutex guard for the entire copy +CopyBufferRegion+ readback loop.flush_test_vram_uploadsnow acquiresself.submittedbeforetake_vram_uploads()(skipping via thread-localTEST_IN_EXECUTEonly when called re-entrantly fromHost::executeon the same thread).lock_test_bitmaps()(TEST_BITMAP_LOCKacquired beforeself.submittedinHost::executeand in theshadow::tests/draw::teststhat mutate/readBITMAPS).Verified locally on RTX 4070 (Windows 11):
cargo test --locked -p victory-gpu --features diagnostics -- --skip dynamic_slots_are_held_until_released --skip lists_share_a_table_and_copies_keep_their_views(2 consecutive parallel runs: 247 passed; 0 failed; 1 ignored; 2 skipped)cargo clippy -p victory-gpu --all-targets -- -D warningscargo xtask policy(191 files ok)Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T00:28:27Z.
Review: APPROVED
Re-verified
0837b47ed0710d23603721878d6d52cd9bca5984on discrete RTX 5090 (is_uma = false) and WARP withVICTORY_D3D12_DEBUG=1. Both previously reported discrete-GPU blockers are cleanly resolved:VRAM writeback merge (
crates/victory-gpu/src/shadow.rs:138-153, 616-625, 689-709):merge_writebackinto(title_changed, host_changed)ensuresqueue_vram_uploadruns whenever host staging picks up concurrent CPU writes, even when title RAM bytes do not change.is_uma = false) probes covering bothcopy_back(overlapping identical GPU/CPU byte + concurrent neighbor CPU byte:written = 0, VRAM reads(0xaa, 0xbb)) andcopy_back_marked(idempotent GPU write + concurrent CPU byte: VRAM reads(0x22, 0xcc)).Parallel discrete-GPU synchronization (
crates/victory-gpu/src/host.rs:1174, 2870, 2944, 3022-3034,shadow.rs:108-136,draw.rs:2185, 3316):RINGmutexes across submission + wait, synchronizingflush_test_vram_uploadswithself.submitted(with re-entrantTEST_IN_EXECUTE), and coordinating globalVIEW_WRITESbitmaps vialock_test_bitmaps()eliminated all parallel test races.Checks run:
cargo xtask policy— passcargo clippy --tests -p victory-gpu -- -D warnings(default and--features diagnostics) — cleancargo test -p victory-gpu --features diagnosticson RTX 5090 (247/247 passed every round, excluding the two pre-existing NVIDIA heap-cap baseline failures)shadow::tests(10/10),draw::tests(20/20), andmemory::tests(9/9) on RTX 5090 withVICTORY_D3D12_DEBUG=1— 0 failures, 0 Debug Layer errorsVICTORY_D3D12_WARP=1,VICTORY_D3D12_DEBUG=1):shadow::tests(10/10),draw::tests(20/20),memory::tests(10/10) — all pass with 0 Debug Layer errors.LGTM!
Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-27T03:01:11Z.
Tested in game on an RTX 5090 (driver 620.73.04), Linux, GE-Proton11-14 Wine with its vkd3d-proton, GTA VI's opening prison yard, with this PR and #2051 both on a stack of
mainplus the unmerged PRs this setup needs.One integration point is missing when a refresh is deferred rather than made where it is asked for.
Shadow::copyuploads the refreshed range to VRAM, but #2051'sShadow::copy_queued/Shadow::queued_madedo the copy later and upload nothing, andqueued_madereturns early when the copy has no tracker. A VRAM-backed copy then keeps what the GPU read before the update. With both PRs on, the world's title-written page tables and arguments reached the GPU stale: frames ran 1.0-1.3 s instead of ~0.4 s, the refresh set grew from 137 to 166-226 MB per frame, and the title eventually took an access violation in a DirectStorage inflate writing into a reserved title page.Fix (in
shadow.rs):copy_queueduploads a range it makes at once and remembers a queued one whenself.vram || self.tracked.is_some();queued_madeuploads every remembered range before filling armed pages' saved bytes, without the tracker-only early return. Reference:0b22c702(on my test stack, so only itsshadow.rshunk applies here), with testsa_deferred_refresh_of_a_vram_copy_is_uploaded_to_vram(device) anda_vram_copy_defers_every_refresh(CPU only; fails without thevramterm).With the hunk, the same build runs the full 600 s without a crash, and both tests plus the other 14
shadow::tests pass on the GPU. Whichever of this PR and #2051 lands second needs the hunk.AI-assisted (Claude); measured on my machine, no game data shared.
Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-27T03:02:54Z.
Following up on my earlier comment (each submission waits for its own upload and read-back before it can be prepared): here is a branch on your new head
0837b47e,suggest/3312-copies-in-submission— two commits,crates/victory-gpu/src/host.rsonly, +298/−112.Your two new commits and these touch the same functions; both are kept: your
CopyCmdwith its own event, theRING/submittedholding across the VRAM copy sync, theflush_test_vram_uploadsguard, and the device-removal check before the read-back (so a removed device is reported instead of panicking inrun_copy_list's allocator reset). Only thewait_fence: Option<u64>parameter becamewait: bool, which is all it was ever tested for, andrun_test_copy_syncpassestrue.What the two commits do. The uploads into copies in video memory and their read-back are no longer copy lists of their own, each with its own fence and wait. Per submission they are two lists of ours, run by the submission:
vram_before, executed as its ownExecuteCommandListsright before the submission's lists: the refreshed ranges through your 64 MiB upload ring, the dirty page tables, the zeroing of the lists' page bitmaps, and — only for a submission that marks — the views' bitmaps RAM → VRAM.vram_after, executed right after the lists and before the submission'sSignal: the declared write ranges VRAM → your 32 MiB read-back ring, the lists' page bitmaps VRAM → RAM, and the views' bitmaps back, again for a marking submission.vram_ran, after it, copies the ring into theCpuMemmirrors; then, still waited for as before, the pages only the bitmaps name (vram_marked_reads, the probes) and any declared ranges past the ring.Step::GpuWrite(.., marked, ..)invram_after). Such a range keeps no snapshot when its copy is tracked (Shadow::writingreturns after arming), socopy_backcompares nothing in it; its pages already go back by their marks. Reading it back whole as well was 742 MB a frame in Grand Theft Auto VI's world on an RTX 5090, all of it discarded.Why it matters. A submission used to make three round trips on its own GPU work: its lists, the upload before them, the read-back after them. Round trips on a submission's own work cannot be hidden by anything else — whoever prepares the next submission must know the previous one is done. That is precisely what keeps a submission from staying in flight, so removing them is the prerequisite for overlap, not just the saving of the waits themselves.
Measured, for context. On my test stack I carry the same in-submission folding on top of an asynchronous submission (a submission stays in flight while the next is prepared): 372 ms → 320 ms per frame on an RTX 5090, GPU time 243 → 179 ms. That branch needs the asynchronous submission, which is not on
main, so it is not what this suggestion branch is; this one is the part that stands on its own, and its effect here is ~24 fewer round trips per world frame rather than overlap.Tests. Wine 11 + vkd3d-proton (GE-Proton11-14) on an RTX 5090,
--test-threads=1, suitesshadow:: host:: memory::, present tests skipped (they fault in a null read under a headless compositor on every branch and end the test process):0837b47e576188a1host::vram_around::ranges_take_the_ring_in_order_at_16_byte_offsets(no device) andhost::vram_around::vram_writes_go_back_within_and_past_the_readback_ring— two declared ranges of a copy in video memory, written by the list's own commands, one inside the 32 MiB read-back ring and one past it, both in title memory once the submission returns. Yourshadow::tests::vram_marked_view_writes_go_back_to_titlepasses on both heads.memory::tests whose pipeline Wine's builtind3dcompiler_47cannot compile (E5017: not yet implemented feature: Unbounded resource arrays,InterlockedOr is not defined on type RWByteAddressBuffer), anddescriptor::host::tests::dynamic_slots_are_held_until_releasedasserting that the heap vkd3d-proton reports has at leastHEAP_VIEWSdescriptors. Sovram_page_table_writes_go_back_to_titleandseparate_memory_bind_submissions_keep_their_own_bitmapsare not exercised here; a run on Windows would cover them.Branch: https://github.com/neonbyte1/VIctory/tree/suggest/3312-copies-in-submission
AI-assisted (Claude); measured on my machine, no game data shared.
Imported from Marvisak/VIctory. Originally posted by Desamodeth on 2026-11-27T06:52:20Z.
Native Windows follow-up to the proposed in-submission copies. Both requested hardware tests pass on the PR head and the proposed tip:
vram_page_table_writes_go_back_to_titleandseparate_memory_bind_submissions_keep_their_own_bitmaps. I made their missing-device/heap paths fail the run. The view-mark test passed on both, and the in-ring/overflow test passed on the tip.On an RTX 5070, skipping the whole-range readback accounts for most of the saving in a 24-submission replay with sparse GPU writes. Each marked submission declares a 31 MiB VRAM buffer. Times are total wall time inside
Host::executefor 24 submissions.0837b47e4b40d5c6576188a1The unmarked control still reads back the full declaration. The separate bitmap readbacks totalled another 36 MiB per 24 submissions on all three versions. The two commits are worth taking together on this evidence.
Method and remaining failures
Windows, Ryzen 7 9800X3D, RTX 5070 driver 621.40, Rust 1.98.1, release. One real tracked VRAM shadow, a 64 KiB page, a real D3D12 list per submission. GPU copies wrote a changing word to each selected page and set the corresponding view-mark bits on the card. Checked each changed word in title memory as soon as the submission returned and compared the entire 31 MiB backing to an independent expected image after every 24 submissions. Counted bytes at the D3D12 ring and bitmap copy commands. The shadow was already resident; the measured cycles had no shadow payload upload. All six orders of the three binaries, fresh process per version, one warm-up and three measured cycles per case per process. No game FPS inferred.
In the wider checks, the same two descriptor-capacity assertions failed on unmodified upstream code at
63bcca43, the PR head and the proposed tip:memory::tests::lists_share_a_table_and_copies_keep_their_views(“past the dynamic slots”) anddescriptor::host::tests::dynamic_slots_are_held_until_released(heap has fewer thanHEAP_VIEWS). Each also failed in isolation. All tenshadow::testspassed on both PR versions.AI-assisted with Codex Astra 6.2 High.
Imported from Marvisak/VIctory. Originally posted by danielibabet on 2026-11-27T08:31:01Z.
Thank you @neonbyte1 for \suggest/3312-copies-in-submission\ (\
4b40d5c\ + \576188a) and @Desamodeth for the native Windows RTX 5070 verification!I've fast-forwarded \pr/vram-default-buffers\ to \
576188a\ (retaining @neonbyte1's Git authorship on both commits). Verified on Windows 11 / RTX 4070:cc @fuzeofficlal — these two commits fold the VRAM upload/readback into the submission's own command lists and skip whole-range readback on marked ranges.
Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T09:35:21Z.
Intel Arc B580: device removed twice within a minute, before the world is reached
Tested because the GPU-command claim here (297.6 -> 90.5 ms/frame) is the largest on the board, and this card
is unusually sensitive to exactly this kind of traffic. It does not survive the menus on Battlemage.
Setup: Windows 11 x64, Intel Arc B580 12 GB (driver default), Ryzen 5 5600, 32 GB, retail 1.0.2.1, my own
dump,
--console series-x,diagbuild,VICTORY_GPU_TIMING=1 VICTORY_D3D12_DRED=1.Tree:
main63bcca4+ #2958 (already verified separately: world reached, 1298.8 ms/frame, no deviceremoval in runs of 230 s and 300 s), then this PR's
576188a1applied on top. Same base commit, so the fourfiles (
host.rs,memory.rs,shadow.rs,draw.rs) applied cleanly with no conflict.Result, twice:
A fault address with no title memory copy below it reads like a shader reading an address nothing backs, which
is what I would expect if the page table or the dirty bitmap is being read from VRAM while the shader's address
is not mapped there — this PR is the change that moves exactly those structures and adds the 64 MiB upload and
32 MiB readback rings. It could equally be the ring's sync; I have not bisected the four files.
There are no Intel reports in this thread that I can find, so this is the first: on this card the PR is a hard
failure rather than a speedup. Happy to bisect per-file (or per-switch, if there is one that isolates the VRAM
backing from the rings) and to run it again with
VICTORY_D3D12_DEBUG=1if the extra validation would helpnarrow it.
Synthetic runs only beyond the title itself; no game data included.
Imported from Marvisak/VIctory. Originally posted by danielibabet on 2026-11-27T09:40:38Z.
@borosf Thank you for testing on Intel Arc B580 and reporting the exact page-fault addresses!
Since \
576188a\ added the in-submission \ram_before\ / \ram_after\ lists on top of \Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T09:53:34Z.
Correction to my comment above: I cannot pin this on the PR, and my "reverted, no device removal" line was wrong
Following up honestly because I kept digging after posting and the picture is not what I first said. Same setup
throughout (Arc B580 12 GB, series-x, my own dump,
diag, 130-230 s runs,VICTORY_GPU_TIMING=1+VICTORY_D3D12_DRED=1unless noted).main63bcca4+ #2958, this PR not appliedpage fault at 0x800003d2f000)main+ #2958 + this PR576188a1So the fault also happens without this PR — the same build that had run 230 s clean earlier removed the device
on a later run. What I can say is that it looks far more likely with the PR (5/5 against 1/3), which is a lead,
not a diagnosis. My earlier sentence "with this PR reverted and everything else identical: no device removal,
both runs reach the world" does not hold up: a control run did remove the device. Apologies for the noise.
What the bisect does rule out: I put the PR's two new VRAM substrates behind local switches and ran the
three combinations:
shadow.rs)memory.rs)So it is not the VRAM-backed shadow buffers and not the VRAM-backed bitmap/page table — with both disabled
almost all of the PR is dormant and it still faults. The fault address is also not inside any of the twins:
they land at
0xffffb802…/0xffffb806…, and every fault I have seen is0x8000_xxxx_xxxx.Two other facts that may help whoever owns this:
page fault at 0x8000…withno title memory copy below it, after a submission of 33-34lists, always before the world is reached.
VICTORY_D3D12_DRED(i.e. no per-command notes) have been clean; the only runs thatfault are the ones with DRED's marker commands and per-list timing on. That may be coincidence, but if the
fault needs DRED to show up, it is a different bug from the one this PR is about, and it would explain why
it is intermittent.
I am happy to bisect further (per hunk, or with
VICTORY_D3D12_DEBUG=1) if that is useful, but I did not wantthe earlier "hard failure" claim to stand in the thread. The timings I posted first are unaffected — those runs
completed, and the numbers are medians over their own frame reports.
Imported from Marvisak/VIctory. Originally posted by Desamodeth on 2026-11-27T13:33:48Z.
Native RTX 5070 12 GB, driver 621.40, Series X profile, opening car sequence. Tested
576188a1against63bcca43with #2885, #2958 and the same instrumentation on both sides. Same save and application cache seed, one warm-up per build, then PR/control/control/PR. Each run supplied 98 matched Present intervals after excluding capture frames and their successors.The median frame improved 15–26%. The direction held when comparing the same elapsed-time window and when restricting to offsets with ≥500 draws in every run. Camera cuts varied across runs. In the 20–48 s window, median DXGI process-local usage rose 1.15–1.28 GB and non-local usage fell 2.77–3.20 GB (decimal). The PR reported about 2.73 GiB allocated for shadows. Both native GPU writeback tests reached their final value checks and passed.
Image regression to investigate before merge. Offset +2 after the first ≥500-draw frame was solid green across the entire image (RGB 0,135,0) in both timed PR runs and neither control. A separate pair capturing every frame from +1 through +8 reproduced green at +2 only on the PR. The PR had visible image variation again at +3. This pair was excluded from timing. The cause is still open.
Imported from Marvisak/VIctory. Originally posted by Desamodeth on 2026-11-27T14:42:12Z.
Reproduced the early green frame on a native RTX 5070 (12 GB, driver 621.40). In three traces the video draw's three R8 SRVs pointed to the expected resources when recorded. All three were null at submission on the exact present that turned solid RGB (0, 135, 0). GPU readback shows the video pass produces that color and the final overlay covers an already rendered scene with it.
I traced the clear to
HostHeap::evict. The affected draw used live dynamic slots in one run and ordinary title slots 733044–733046 in another (heap title count 934464). #2598 protects the dynamic range. Its live-slot test failed with the old eviction behavior and passed with protection on native D3D12. With #2598 applied, two short scene traces had 54/54 matching SRV checks and no solid green frame through world +8. The ordinary-slot case and whether #3312 changes the likelihood of eviction remain open.The ordinary slots were evicted about 111 seconds after process start, before the 120-second idle threshold in
resource::choose. That narrows this eviction to the local-memory budget path. Three control runs had zero solid-green images in 27 captures over world +0…+8.In the opening car sequence, repeating A/B/B/A on the original binaries gave median Present intervals of 470.1 → 385.8 ms and 473.0 → 367.5 ms (96 common intervals per run). Timing runs used the same save, cache seed and Series X profile, with per-draw readbacks disabled. Camera and draw counts vary.
With #2598 stacked on #3312, a separate A/C/C/A gave 491.4 → 347.8 ms and 470.5 → 442.9 ms (98 common intervals per run). The larger gain came with fewer draws. The closely matched pair averaged 2,415 vs 2,418 draws and improved by 5.9%. All timed runs reached world +144 with successful Presents. Measured with Codex assistance.
Imported from Marvisak/VIctory. Originally posted by Desamodeth on 2026-11-27T15:01:25Z.
Follow-up on the RTX 5070: reproduced the ordinary title-slot case with #2598 active in two of three new opening-scene traces. The three solid-green presents were world +2, +2 and +5. On each one, the video draw's three R8 SRVs matched at recording,
HostHeap::evictnulled all three ordinary slots, and the same draw had three null bindings at submission. The full captured image was RGB (0, 135, 0). All 21 dynamic SRV checks across those runs retained the expected resource. A separate old-policy control lost three live dynamic slots on its green frame.The separate timing binary (#3312 + #2598, no per-draw probes) also produced a solid-green image at world +2 on its first rerun. Both affected instrumented runs reached the flash within 45 seconds of process start, before the 120-second idle threshold. The remaining fix needs to preserve the recorded draw's ordinary SRVs during budget eviction while allowing legitimate title rewrites. AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by JurajSimicevic on 2026-11-27T17:52:49Z.
Native Windows, RTX 5080, on a tree with #439, #2121 and #2958:
576188atakes the frame from 1,743 to 530 ms, and the GPU time from 1,482 to 150 ms.Method (the same as my rows on #3425):
VICTORY_KEYS, with no input after.63bcca4+ #2098, #2626, #2464, #2118, #439 (e2d3cfd), #2121 (0bc5edb) and #2958 (4f99be4), plus #3415's dump diagnostics.576188aand nothing else.The draw count is the same, so the GPU does the same work about 10 times faster. That is much more than the 15-26% Desamodeth measured on
main+ #2885. On this tree, most of the GPU time went to the shadow buffers, page tables and bitmaps that #3312 moves into video memory. Preparing rises by 20 ms, mostly in title copies (about 30 MB more a frame), and copy-back by 16 ms.No device errors or alerts in about 10 minutes in the world. The image looks as it did before. I didn't see a solid-green frame, but I didn't capture frame by frame.
For whichever of #3312 and #2121 lands second: the new
vram_page_table_writes_go_back_to_titleneeds #2121's paged test setup.576188amerges with #2121 (0bc5edb) with two small conflicts. Both sides are kept: the test bitmap lock indraw.rs, andforget_reads_nownext to the VRAM copies inHost::execute. After that, the new test fails on a host that pages its view heap (RTX 5080, and WARP). The title word stays0x11instead of0xcafef00d.The cause is the test's setup, not the write-back. #2121 extends the shared
WRITEtest shader:paged;SRV(t1, space=2));#2121's own tests pass
paged, bind the page table, and bind the heap from its start. The new test still binds as onmain. With the three changes below it passes on both, and leaving out any one of them still fails:With that change, on
63bcca4+ #2121 + #3312, the wholevictory-gpusuite with--features diagnostics(RTX 5080, two runs) fails only:placed_uav_dispatch_writes_its_texture, which already fails on #2121's head with diagnostics (reported there);a_placed_texture_read_with_no_page_free_is_made_after_one_submission, in one of the two runs. It also comes and goes on a tree with #2121 but without #3312.The two descriptor-capacity tests that fail on
mainon NVIDIA pass there.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by Desamodeth on 2026-11-27T20:16:53Z.
RTX 5070 12 GB, driver 621.40, opening car scene. With #3312 + #2598, one capture showed solid green at world +1 and +2. With Neon's local texture-lifetime prototype (
4a7bbb45985a, patch SHA-256), all three early-frame captures passed without green. In the instrumented run, all 18 ordinary and 3 dynamic video SRV bindings still matched at submission. The flash is intermittent in the control.Median full-frame Present interval in two opposite-order blocks (97 matched intervals per run, same save and cache seed):
63bcca43+ #2885 + #2958The stack retained its median gain over baseline in both blocks. The prototype's incremental effect varied (+3.1% / −11.5% frame time), and its p95 worsened in the first block. Fence-failure handling is still under review. AI-assisted with Codex and Gemini.
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-27T22:17:47Z.
8 GB NVIDIA row, tests only: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, debug, at
576188a1againstmain63bcca4.cargo test -p victory-gpu --lib -- --test-threads=1:mainThe 2 failures are the same on both sides:
dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views, the two your description skips, which fail on capped NVIDIA view heaps. So nothing regresses here. The five new tests pass:vram_writes_go_back_within_and_past_the_readback_ring,ranges_take_the_ring_in_order_at_16_byte_offsets,vram_page_table_writes_go_back_to_title,vram_marked_view_writes_go_back_to_titleandseparate_memory_bind_submissions_keep_their_own_bitmaps.vram_writes_go_back_within_and_past_the_readback_ringreturns early ("no copies in video memory here") when no copy gets a VRAM side, so I checked with a local print: on this card it did get one and ran the full path. That is withvram_shadow_budget()at 25% of an 8 GB card's local budget, the smallest budget reported on this PR so far.No game run on my side.
AI-assisted (Claude Code, Claude Opus 5.5 ran the tests).
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T04:05:07Z.
An ordering case another tree hit with the same kind of budget (read from this head
576188aand that tree's code; not run here).try_vram_shadowadmits copies first come, first served, up to 25 % of the local budget (vram_shadow_budget), and every backing up to 128 MB may take a share. ZigZagBoi1/ScarlettPort (a VIctory-derived tree) had the same shape with a 512 MB card-copy cap. With small copies allowed, the 891 copies made during the world load took the whole 512 MB before the title's upscaler made its buffers (frame 4147). So the upscaler's 24 MB tensor stayed in system memory, and its three 3x3 convolutions read it over the bus at 31-41 ms each, against 0.2-0.9 ms from card memory (engine/crates/scarlett-gpu/src/shadow.rs, the note oncard_big_room).Their fix keeps a second room, 256 MB by default (
SCARLETT_CARD_BIG_ROOM), that only buffers of 16 MiB or more may take once the main cap is spent. It is an ordinary card copy otherwise, and their four-fifths-of-the-card rule still applies. Their 0.5.0 numbers, from one boot on an RTX 3060 12 GB with the Series S profile: the upscaler's slowest pass went from 55.7-70.8 ms to 0.10-0.28 ms a frame, and 3.4 fps in the world against 1.6 (with other 0.5.0 changes).A 25 % budget is far larger than 512 MB, so this may never fill here on a 12 GB card. On 8 GB cards, or after a long session, it could. One log line when
try_vram_shadowfirst turns a buffer down (its size and the bytes used) would show whether it happens. A reserve for large buffers, or admission by how often a buffer is read rather than by arrival, would keep the late big ones from losing out.AI-assisted (Claude Code, Claude Opus 5.5 read this head and ScarlettPort's shadow.rs).
Imported from Marvisak/VIctory. Originally posted by reallyvibe on 2026-11-28T22:43:27Z.
@danielibabet A 6 GB low-VRAM row, tests only. RTX 4050 Laptop 6 GB on native Windows 11, debug, at
576188a1. Real local budget 5402 MB, so the cap is about 1351 MB. This builds on @upipibi's 8 GB RTX 3070 row.Four local tests fix the cap through a test-only override of the DXGI local
Budgetinvideo_memory(). Each runs in its own process, fails rather than skips without a discrete GPU, and checksVRAM_BYTES. All four pass:shared_buffer, and only the first is charged.give_backnever frees chunks, as onmain.Mutation controls show the tests run the intended paths. Dropping VRAM uploads or the ring readback fails only the VRAM copy's checks. Detaching the shared mapping fails only the two fallback copies. Removing the
Shadow::dropdecrement fails the release checks. Removing the declaredGpuWritefails write-back to title memory for all three.Also noted:
vram_shadow_budget(host.rs:2792-2805) caches its first reading in aOnceLock. With the override dropping from 400 to 40 MB after that reading, 16.8 MB still went to VRAM against the 10 MB cap that would result from recalculating the budget. That is a simulated change only. I haven't shown real memory pressure, or any effect in game.Not covered: shader UAV dispatches, marked (
VIEW_WRITES) write-back on fallback copies, concurrent allocation, the lifetime of a resource whose upload is still pending after its charge is returned, real VidMm demotion, and any game run.Sources:
try_vram_shadowandalloc_backing(shadow.rs:158-214),Shadow::drop(shadow.rs:897-903), andArena::take/give_back(shadow.rs:1520-1590). The test patch is available on request.AI-assisted (Claude Code, Claude Opus 5.5 wrote and ran the tests and drafted this comment).
Imported from Marvisak/VIctory. Originally posted by Desamodeth on 2026-11-30T06:32:08Z.
Follow-up on the regular SRV slot eviction fix discussed above: I finished porting and hardening the fix cleanly on top of
#3312HEAD (576188a1) as a single cherry-pickable commit:github.com/Desamodeth/VIctory@89dd6155dd(branchfix/3312-regular-srv-eviction)Summary of what it covers:
HostTexture::pin_list) strictly to mutable regular descriptor-heap SRV slots (index < HostHeap::count(),State::table_entry->HostList::note_regular_slot+PreparedSlots), leaving direct-read eviction (HostList::track/a_texture_given_up_is_made_again_with_its_bytes_and_recorded_lists_keep_it) untouched.O(1)deduplication regardless of initial slot contents (empty, typed null SRV, buffer SRV, or texture SRV) soDESCRIPTORS_VOLATILElate binds afterClose/Executeand closed-list overwrites work without touching neighboring slots or accumulating replaced textures on the closed list.Host::unconfirmedwhen GPU wait confirmation fails, releasing them once a later fence confirms or the device is removed.HostHeap::mirror/HostHeap::evictrace by holdingself.madeacross thekeptscan and slot clear.VICTORY_D3D12_WARP=1,VICTORY_WARP=1,VICTORY_D3D12_DEBUG=1,--profile diag --features diagnostics):cargo clippy --locked -p victory-gpu --lib --tests -- -D warningsclean (default &diagnostics), fullvictory-gpulib suite259 passed; 0 failed; 1 ignoredin both default parallel and--test-threads=1runs.Handoff note: I'm stepping away from this project — @danielibabet or any maintainer/contributor is free to cherry-pick, fold, or adapt
89dd6155directly.AI-assisted with Gemini 4 Neon
Imported from Marvisak/VIctory. Originally posted by danielibabet on 2026-12-01T09:33:46Z.
Thanks @Desamodeth and @reallyvibe!
Cherry-picked Desamodeth/VIctory@89dd6155 (1e4a99) onto pr/vram-default-buffers to close the regular SRV slot eviction / late-bind / unconfirmed-wait paths.
Verified on RTX 4070:
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.