Skip to content

gpu: move shadow buffers to DEFAULT VRAM with pooled staging transfers - #693

Open
wbkepler wants to merge 2 commits into
Marvisak:mainfrom
wbkepler:gpu/default-vram-shadow-buffers
Open

wbkepler wants to merge 2 commits into
Marvisak:mainfrom
wbkepler:gpu/default-vram-shadow-buffers

Conversation

@wbkepler

Copy link
Copy Markdown

Summary

Moves registered and loose Shadow buffers from CPU WRITE_BACK L0 system RAM to GPU-local D3D12_HEAP_TYPE_DEFAULT VRAM (with ALLOW_UNORDERED_ACCESS) in host.rs and shadow.rs:

  • Adds Host::default_buffer, Host::readback_buffer, and a reusable 4 MiB StagingArena (capped at 4 pooled chunks; oversized allocations transient) for dirty 64 KiB page upload staging and pre/post-submission GPU-write readback snapshots.
  • Records upload and readback transfers via dedicated upload/readback command lists with proper COPY_DEST -> COPY_SOURCE barriers and COMMON decay between ExecuteCommandLists calls.
  • Coalesces overlapping/adjacent GPU-write ranges via merge_ranges and merges only GPU-modified bytes into title memory via copy_back_range while preserving concurrent CPU writes.

Verification

  • cargo clippy --workspace --all-targets — passed (zero new warnings)
  • cargo clippy -p victory --features diagnostics --all-targets — passed
  • cargo test --workspace — passed (hardware GPU)
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --lib shadow — passed (3/3)
  • VICTORY_D3D12_DEBUG=1 clean on both hardware GPU and WARP
  • cargo xtask policy — passed (151 files ok)

Allocate `Shadow` host copies of title buffers in GPU-local VRAM
(`D3D12_HEAP_TYPE_DEFAULT`) instead of CPU-visible `WRITE_BACK` L0
system memory, eliminating PCIe reads on every shader buffer access.

- `crates/victory-gpu/src/host.rs`:
  - Add `Host::default_buffer` (`D3D12_HEAP_TYPE_DEFAULT`,
    `ALLOW_UNORDERED_ACCESS`, initial state `COMMON`) and
    `Host::readback_buffer` (`D3D12_HEAP_TYPE_READBACK`, mapped).
  - Add a reusable `StagingArena` (4 MiB pooled chunks, capped at 4
    chunks; oversized allocations released per submission) for both
    `UPLOAD` and `READBACK` shadow transfers.
  - Record dirty-page `CopyBufferRegion` uploads (and pre-submission
    `before` readback snapshots when shaders write a buffer, with
    `COPY_DEST -> COPY_SOURCE` barriers where needed) onto a dedicated
    upload prelude list, and post-submission `after` snapshots onto a
    dedicated readback list. Separate `ExecuteCommandLists` calls on
    the same queue let default-heap buffers implicitly decay to `COMMON`
    between phases with a single fence wait.
- `crates/victory-gpu/src/shadow.rs`:
  - Allocate registered and loose `Shadow` buffers via
    `Host::default_buffer`, removing CPU-mapped `data` and `before`
    snapshot pools.
  - Stage dirty 64 KiB write-watched pages into pooled `UPLOAD` staging
    memory (`UploadCopy`).
  - Add `merge_ranges` to coalesce overlapping/adjacent GPU-write
    ranges per submission and `Shadow::copy_back_range` to merge only
    GPU-modified bytes into title memory while preserving concurrent
    CPU writes (leaving concurrently CPU-modified pages dirty so the
    next submission uploads them back to VRAM).
  - Add unit and live D3D12 (hardware + WARP, debug layer) tests
    verifying range coalescing, `DEFAULT` heap allocation, dirty-page
    staging with zero-copy on clean pages, GPU UAV readback merge, and
    concurrent CPU write preservation.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review only — this is the deepest change in the current batch (+993/-264, architectural: shadow buffers move from CPU WRITE_BACK system RAM to GPU-local DEFAULT VRAM with pooled UPLOAD/READBACK staging). I can't compile or run victory-gpu on macOS, so nothing here is execution-verified.

What a Windows pass should focus on, in order of risk:

  1. Readback merge correctness (gpu_writes): shader-written ranges now go through pooled READBACK staging and merge into title memory after submission — the merge must not clobber title writes that happened between submit and fence completion.
  2. Staging pool lifetime vs. list submission: pooled UPLOAD/READBACK buffers reused across submissions need fence-safe retirement; a pool slot recycled before its list's fence signals is the classic UAF here.
  3. Performance: the old path was CPU-visible memory (zero-copy on some paths); DEFAULT VRAM adds upload+readback traffic per frame. Worth a frame-time comparison on the RTX test machine, not just correctness.
  4. The doc-comment rewrite at the top of shadow.rs accurately describes the new flow — good.

No correctness objection from the static read, but this one needs the Windows runtime evidence before merge.

@LAKSHYA-cmd-tech LAKSHYA-cmd-tech left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows 11 MSVC runtime verification (Rust 1.98.1 x86_64-pc-windows-msvc on D3D12 hardware GPU and WARP):

Addressing the verification checklist:

  1. Readback merge correctness (gpu_writes): Shadow::copy_back_range correctly computes diffs between the pre-submission snapshot (�efore_ptr) and post-submission snapshot (�fter_ptr), applying only modified GPU bytes into title memory. Verified by est shadow::tests::gpu_writes_readback_merges_and_preserves_concurrent_cpu_writes where concurrent CPU writes outside the GPU-modified range remain untouched and dirty flags trigger subsequent uploads.
  2. Staging pool lifetime vs. list submission: upload_arena and
    eadback_arena reside strictly under self.submitted.lock() in host.execute(). They are only reset via �rena.reset() after WaitForSingleObject completes the queue fence wait. There is zero risk of early slot recycling or UAF across submissions.
  3. Barriers and state decay: Upload copies run on a separate command list (shadow_upload_list) submitted in its own ExecuteCommandLists call preceding title command lists, allowing DEFAULT buffers to decay back to COMMON per D3D12 rules.
  4. Test suite results:
    • cargo test -p victory-gpu --lib shadow: 3 passed, 0 failed
    • cargo test -p victory-gpu: 46 passed, 0 failed, 1 ignored
    • cargo xtask policy: 151 files ok

@justr4mzi

Copy link
Copy Markdown

Tested PR #693 (ae39e9c1) merged cleanly on current main (02f404e) on Windows 11 with an AMD Radeon RX 6700 XT (RDNA2) and Rust 1.98.1 (x86_64-pc-windows-msvc), against main (02f404e) as negative control.

Test results (victory-gpu)

  • main (02f404e, --test-threads=1): 49 passed, 0 failed, 1 ignored (with --features diagnostics: 52 passed, 0 failed, 1 ignored).
  • PR gpu: move shadow buffers to DEFAULT VRAM with pooled staging transfers #693 (ae39e9c1, default parallel cargo test -p victory-gpu): 52 passed, 0 failed, 1 ignored (including all 3 new shadow::tests::*).
  • PR gpu: move shadow buffers to DEFAULT VRAM with pooled staging transfers #693 (ae39e9c1, sequential cargo test -p victory-gpu -- --test-threads=1): fails (51 passed, 1 failed, 1 ignored; with --features diagnostics: 54 passed, 1 failed, 1 ignored):
    • watch::tests::written_pages_are_reported_to_every_asker panics at crates/victory-gpu/src/watch.rs:306 (assertion failed: before.is_empty()).
    • Running written_pages_are_reported_to_every_asker in isolation passes (1 passed).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 152 files ok.

Why --test-threads=1 fails

In shadow::tests (which run alphabetically before watch::tests under --test-threads=1), WatchedAlloc allocates with MEM_WRITE_WATCH and triggers watch::writes(...), inserting those page numbers into watch::JOURNAL. WatchedAlloc::drop frees the pages via VirtualFree(..., MEM_RELEASE) without clearing watch::JOURNAL entries for that range. Windows then reuses the same virtual address for watch::tests::written_pages_are_reported_to_every_asker, so its initial writes(start, end, false) sees stale JOURNAL entries from shadow::tests and fails before.is_empty(). (More broadly, if title allocations are freed and reallocated at the same VA, watch::JOURNAL would carry stale write records unless cleared on free.)

No game data included; the title itself was not launched. AI-assisted test execution and root-cause analysis (reviewed locally).

@geiyiliyabumo

Copy link
Copy Markdown
Contributor

Tested ae39e9c14 merged with main (8e79c80, clean merge) on Windows 11 Pro (26100), Rust 1.98.1 (x86_64-pc-windows-msvc), AMD Radeon RX 9060 XT (RDNA4, driver 32.0.32029.2010): PASS (with two non-blocking code-review notes below).

Verification

  • cargo xtask policy → asset policy: 153 files ok
  • cargo clippy --workspace --all-targets --locked -- -D warnings → pass (0 warnings)
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings → pass (0 warnings)
  • cargo test --workspace --locked → 314 passed, 0 failed, 6 ignored (all 3 new shadow::tests::* pass on RX 9060 XT)
  • VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --lib --locked shadow → 3 passed, 0 failed on RX 9060 XT (0.17s), zero debug-layer messages
  • VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --lib --locked shadow → 3 passed, 0 failed on WARP (0.11s), zero debug-layer messages

Code-review notes

  1. Per-submission transient allocations for >4 MiB shader-written ranges (host.rs, StagingArena::alloc / reset): oversized allocations (alloc_len > STAGING_CHUNK, 4 MiB) are pushed to self.transient and dropped every submission. Because ReadbackPlan allocates both before and after readback buffers per coalesced GPU-write range, any world pass writing into a large heap (>4 MiB; the removed POOL comment in shadow.rs noted the 174 MiB heap previously hit ~2.3M page faults/frame without reuse) will CreateCommittedResource + Map and release two large READBACK buffers on every submission. Keeping a small capacity-reused slot for oversized readback/upload buffers (or raising/pooling a large chunk) would avoid that churn on world frames.
  2. Stale copied timestamp if staging allocation fails (shadow.rs, copy_stale → stage): copy_stale advances copied[page - base] = now before calling self.stage(...). If alloc(len) returns None, stage returns 0 without pushing an UploadCopy, leaving those pages marked up-to-date so subsequent submissions will not retry uploading them.

AI-assisted; synthetic tests only, no game files (world runtime perf not measured).

@DeerSilver

Copy link
Copy Markdown

Tested head ae39e9c merged onto main ffe310e (clean merge) on NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell), driver 621.24, Windows 11 26300, Rust 1.98.1: pass. No game files: the test suite only.

  • The PR's new tests pass. The ones that use the host GPU ran on the RTX 5060 (DXGI adapter 0 on this laptop, so the host-device helpers return a device and the tests don't take their early return):
    • merge_ranges_coalesces_overlapping_and_adjacent
    • default_vram_shadow_uploads_only_dirty_pages
    • gpu_writes_readback_merges_and_preserves_concurrent_cpu_writes
  • cargo test --workspace --locked: 345 passed, 0 failed, 6 ignored, against 342 passed / 6 ignored on main.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.

AI-assisted (Claude Code).

giritsu pushed a commit to giritsu/VIctory that referenced this pull request Nov 24, 2026
…s (PR Marvisak#693)

Allocate Shadow host copies in D3D12_HEAP_TYPE_DEFAULT VRAM and stage
dirty 64 KiB page uploads and pre/post GPU-write readbacks through
pooled 4 MiB StagingArenas, integrated with bindless prepare (Marvisak#413),
page-coalesced refreshes (Marvisak#393), and lock-free retirement (Marvisak#609).
Update raw_view_tests::unknown_stride_reads to stage via DEFAULT buffers.
giritsu pushed a commit to giritsu/VIctory that referenced this pull request Nov 24, 2026
@SAitken91

Copy link
Copy Markdown
Contributor

In-game results for #693 on an RX 6950 XT (RDNA2), Windows 11, diag build with VICTORY_D3D12_DRED=1, scripted input into the first mission. Base main ffe310e + #693 + #687 + #635 + my open shader PRs, plus the PRs noted per run.

extra PRs time in world how it ended
— (on 8e79c80) ≥165 s no failure, stopped at my 6-min limit
#568 ~48 s page fault inside freed shadow readback staging (8 entries)
#568 #180 ~131 s page fault inside freed 1024×1024 textures + freed shadow readback staging
#568 #180 #575 ~89 s GPU hang (0x887A0006), no page fault
same, VICTORY_SHADER_LOOP_LIMIT=1000 ~73 s page fault inside freed textures + freed shadow readback staging

For comparison, the same base without #693 (with #609) ran out of memory after ~13 s in one run and didn't get past the menus with scripted input in two others.

The recurring shadow readback staging entries in the "inside freed" lists look like a pooled readback staging buffer being released or recycled while a submitted list still uses it. #575 (release behind the queue) covers descriptor slots and title-buffer shadow copies, not this pool, and #609/#431 don't merge with this PR as they stand. Happy to rerun a newer head on this card; logs available.

@ordis-labs

Copy link
Copy Markdown

In-game A/B of this PR on Windows 10 19045, RX 6700 XT (driver 32.0.21045.29003), diag build, VICTORY_D3D12_DRED=1, identical scripted input. Base = main ffe310e + #175 (needed on Windows 10). Two runs each, alternating A/B/A/B. Averages over the world phase:

run time in world draws/frame frame GPU copies ended with
base 168 s 572 1,236 ms 212 ms 381 ms page fault inside freed textures
base 213 s 2,431 1,654 ms 314 ms 663 ms page fault inside freed textures
+#693 91 s 2,282 3,597 ms 2,165 ms 766 ms page fault inside freed texture + freed shadow readback staging / shadow upload staging
+#693 114 s 2,870 3,243 ms 1,714 ms 920 ms GPU hang (0x887A0006), no page fault

At comparable load (base run 2 vs both #693 runs), frames are about 2x slower, GPU time is 5–7x higher, and copy time doesn't drop, so on this machine it's a regression. The freed shadow readback/upload staging entries match what @SAitken91 saw on an RX 6950 XT: a pooled staging buffer seems to be released or reused while a submitted list still uses it.

Tested and written up with Claude's help.

@mercuryVM mercuryVM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ae39e9c on Windows 11, RTX 5070, MSVC: builds; cargo test -p victory-gpu -- --test-threads=1 45 passed, 1 failed: watch::tests::written_pages_are_reported_to_every_asker (finding 7). The three new shadow tests pass.

I read this for ordering first. On the one direct queue it goes upload prelude, then title lists, then readback list, each in its own ExecuteCommandLists call, and one fence wait covers all three before the CPU reads the readback memory and the arenas are reset. Buffers start in COMMON as shared_buffer did, and the COPY_DEST to COPY_SOURCE barrier is there. I found no ordering or barrier bug. merge_ranges and copy_back_range are correct on empty, adjacent, overlapping and unaligned ranges. What blocks it is the failure paths, where title data is lost silently:

  1. A page is marked current before its upload exists (shadow.rs:327 and :361). copy_stale sets copied[page] = now before stage() allocates. If alloc(len) returns None, stage returns 0 and records no copy, but the page already counts as copied. The VRAM copy then stays stale until the title happens to write that page again, and shaders read old data. Fix: update copied only for runs that stage actually recorded. For example, have stage return Option<usize> and set *at afterwards, or roll back that run's entries when it fails.

  2. A failed readback allocation drops the shader's writes (host.rs:651-668). If either readback_arena.alloc fails, the range never enters readback_plans, yet clear_pending (host.rs:876) still runs. The GPU's writes never reach title memory, and the next upload of that page overwrites them in VRAM. The old code had no failure path here. Fix: treat it as fatal (fail()), or at least warn and fall back to a synchronous per-range readback.

  3. Likely bug: two uploads of one range in one prelude, with no barrier between them (host.rs:678-686). A NOT_WATCHED buffer, or a page re-dirtied by a Copy or Run step in the same batch, can be staged twice with different bytes. Two CopyBufferRegion writes to overlapping bytes in one list, with no barrier, have no defined order, whereas the old memcpy always let the last write win. Fix: drop earlier UploadCopy entries that a later one covers, or put a barrier between them.

  4. The fence error is only a warning (host.rs:782). If Signal or SetEventOnCompletion fails, the code goes on to compare readback slots that may still hold the previous submission's bytes, writes the result into title memory, and resets allocators and arenas that may still be in use. Fix: fail() here, as for device removal.

  5. Performance risk: merged write ranges for the world heap can be tens of MB. Above the 4 MiB chunk size, each submission creates and destroys two committed READBACK buffers of that size, which makes finding 2 more likely. Pooling the largest one or two buffers by size class would avoid that.

  6. Behaviour change to note: the old copy_back also wrote the title's bytes into the shadow (*h = *t). Now, pages with CPU-side differences differ in VRAM until the next refresh. Shaders that read outside their declared ranges (the documented shortcut) see older bytes than before.

  7. A new test breaks watch::tests::written_pages_are_reported_to_every_asker. Alone, the watch test passes. Run in one process after shadow::tests::default_vram_shadow_uploads_only_dirty_pages (cargo test -p victory-gpu --lib -- --test-threads=1 shadow::tests::default_vram watch::tests), it fails at watch.rs:306 (before.is_empty()), and it fails in the full serial run too. The watch test VirtualAllocs fresh pages and finds writes already reported for them. Most likely the shadow test leaves watched ranges or journal entries behind after its memory is freed, and the address gets reused. Unregister the shadow and its watch at the end of the test. It's also worth checking whether unregister in production clears the journal for the range.

The new shadow tests pass silently when there is no device, so the WARP and debug-layer coverage in the description isn't enforced by the tests themselves.

It conflicts with our fork's main (upstream plus merged PRs) in host.rs and shadow.rs, so it isn't merged there.

AI-assisted (Claude Code).

…d watch cleanup

Address review findings on PR Marvisak#693 (`gpu/default-vram-shadow-buffers`):

- `crates/victory-gpu/src/shadow.rs`:
  - Have `Shadow::stage` return `Option<usize>` and update `copied[page]`
    in `Shadow::copy_stale` only after staging allocation succeeds, so
    failed allocations never mark dirty pages current.
  - Add `trim_overlapping_uploads` so earlier `UploadCopy` ranges
    overwritten by later uploads to the same shadow buffer are trimmed
    or dropped before recording `CopyBufferRegion` commands (ensuring
    disjoint destination bytes and last-write-wins order without extra
    barriers).
  - Clear freed test page entries from the write-watch journal in
    `WatchedAlloc::drop` so serial test runs reusing the same virtual
    address do not report stale writes in `watch::tests`.
  - Add unit tests for failed upload staging allocation retry and
    overlapping upload trimming.
- `crates/victory-gpu/src/host.rs`:
  - Pool oversized (`> 4 MiB`) staging buffers in `StagingArena` by size
    class (retaining up to 4 large buffers and 8x 4 MiB chunks across
    submissions) to avoid per-submission creation/destruction churn.
  - Treat `readback_arena.alloc` failure and fence `Signal` /
    `SetEventOnCompletion` / `WaitForSingleObject` errors as fatal via
    `fail()` instead of silently dropping GPU writes or resetting
    in-flight arenas.
  - Call `shadow::trim_overlapping_uploads` before recording the upload
    prelude list.
  - Add a unit test verifying oversized staging buffer reuse across
    submissions.
- `crates/victory-gpu/src/watch.rs`:
  - Add `#[cfg(test)] pub(crate) fn forget_pages` to remove freed test
    pages from `JOURNAL` and `GUARDS`.
nazmi added a commit to nazmi/VIctory that referenced this pull request Nov 24, 2026
The title's own crash report records system.memory.free 26472 KB of 31233028 KB total at 99 percent loaded. Our startup check only knows the first boot's 6.1 GiB, so a run can pass the gate and still die in the world. That matters because every buffer a draw uses gets a full-size host copy (shadow.rs), so the README's measured 17.7 GB world peak exists twice on a 32 GB machine.

Records PR Marvisak#693 (default-heap shadow buffers, with pooled staging) as the candidate fix and why it is not merged: its reviewed version left shadows in COPY_SOURCE with no transition back to COMMON.
@fuzeofficlal

Copy link
Copy Markdown
Contributor

Reviewed and verified 1c94839 merged cleanly onto main (ffe310e) across NVIDIA GeForce RTX 5090 (D3D12 Debug Layer), AMD Radeon(TM) Graphics iGPU (D3D12 Debug Layer), and Microsoft D3D12 WARP (D3D12 Debug Layer).

While running clippy, parallel watch::tests stress runs, and multi-submission VRAM shadow tests, I found and fixed six edge cases on top of 1c94839 in fuzeofficlal/VIctory@322724b (branch fix/pr693-watch-and-vram-verify):

  1. CI clippy::undocumented_unsafe_blocks failure (watch.rs:386): assert_eq!(unsafe { ... }, ...) expanded inside the macro without seeing the preceding // SAFETY: comment; binding let got = unsafe { ... }; first satisfies Clippy cleanly.
  2. Parallel VA-reuse race on release (shadow.rs WatchedAlloc::drop, watch.rs, resource.rs Memory::drop):
    • Calling forget_pages after VirtualFree allowed another thread's concurrent VirtualAlloc to reuse the same address and write to it before forget_pages cleared its fresh journal/guard state; written_pages_are_reported_to_every_asker also omitted forget_pages before VirtualFree.
    • Production Memory::drop also needed watch::forget_pages before releasing owned resource backing memory, with inward whole-page rounding (start.div_ceil(PAGE), end / PAGE) so sub-64 KiB edge allocations never clear neighboring live allocations sharing a page.
  3. Active oversized staging eviction churn (host.rs StagingArena::reset): Clearing entry.3 (in_use) before sorting/truncating self.large caused steady-state oversized buffers that were smaller than historical idle peak allocations to be evicted and reallocated every submission. Sorting by Reverse((entry.3, entry.2)) before clearing entry.3 retains active buffers first.
  4. Timed / empty-group ExecuteCommandLists fence ordering (host.rs Host::execute): Handling groups.len() <= 1 in the fast path ensures upload_list / readback_list still wait on the queue fence when groups is empty, and waiting on has_upload before the multi-group VICTORY_GPU_TIMING loop avoids folding upload prelude GPU time into groups[0].
  5. Partial-page readback watch reset (shadow.rs Shadow::copy_back_range): Restricting synced to full n == PAGE slices with !cpu_diff and resetting watch::writes(..., true) per contiguous synced page run avoids clearing write-watch state on partial boundary ranges.

Verification

  • cargo test -p victory-gpu (61 passed, 0 failed, including a new multi-submission compute SRV/UAV + concurrent CPU write + overlapping-upload roundtrip test and 8x parallel watch/shadow stress loops):
    • NVIDIA GeForce RTX 5090 + D3D12 Debug Layer (0 debug layer errors)
    • AMD Radeon(TM) Graphics + D3D12 Debug Layer (0 debug layer errors)
    • D3D12 WARP + D3D12 Debug Layer (0 debug layer errors)
  • cargo clippy --workspace --all-targets & --all-features: 0 warnings
  • cargo xtask policy: passed

@maplerouteadmin-dev

Copy link
Copy Markdown

In-game result on a 12 GB NVIDIA card, where #693 goes far over the video-memory budget.

Setup: RTX 5070 12 GB (driver 32.0.16.2114), Ryzen 5 5600X, 32 GB, Windows 11; Xbox Series 1.0.2.1; diag build, VICTORY_D3D12_DRED=1, scripted input (VICTORY_KEYS), 240 s. Base: main ffe310e + #966 + Peppacodes exp/mesh-host-lanes + a #951 port (needed to reach the world on NVIDIA). Test: base + #952 + #693 (1c94839) + #454 with VICTORY_NO_WATCHDOG=1 (without it, the title's watchdog ended the first try at loading). Merges were union-only plus one test updated to the base's indirect::bound/done signatures; cargo test -p victory-gpu passes. No game data used.

#952's log line, in the world:

video memory: 16906 MB of a 10524 MB budget on the adapter, 1949 MB in system memory
video memory: 17400 MB of a 10570 MB budget on the adapter, 2117 MB in system memory
video memory: 19042 MB of a 10570 MB budget on the adapter, 2299 MB in system memory

World frames (frame-rate lines over 500 ms):

base (2 runs) + #693 (1 run)
ms/frame 4 667 21 350
copies, ms/frame 4 240 14 663
on the GPU, ms/frame 521 1 499
world lines before the end 30 3
ended with device removed in 1 of 2 runs device removed (TDR)

So on this card the shadows in DEFAULT heaps ask for about 19 GB of local memory against a 10.6 GB budget. Windows then pages local memory, the copies and the GPU both slow down by 3-4x, and a submission runs past the timeout. The AMD results above were on cards with more VRAM (or with less of the world), which may be why they did not show this.

A budget check would probably make the PR safe on 8-12 GB cards: for example keep new shadows in WRITE_BACK system memory (as before) once QueryVideoMemoryInfo's current usage passes the budget (#952 already queries it), or move only shadows that are refreshed often. Happy to run a build with such a check on this card.

KainanP added a commit to KainanP/VIctory that referenced this pull request Nov 24, 2026
…y unchanged pages current) onto Marvisak#346 + Marvisak#334 + integ/next

Taken instead of Marvisak#693 (shadow buffers in DEFAULT VRAM with staging
readback): both rewrite how shaders' writes reach title memory, on
incompatible models (Marvisak#1024 stores from the CPU-mapped host copy; Marvisak#693 has
no CPU mapping and merges from readback snapshots), so only one can land.
Marvisak#693 has unfixed in-title regressions on its last head's predecessor and no
title run since: about 2x slower frames and 5-7x GPU time on an RX 6700 XT
(Marvisak#693 (comment)), GPU
page faults inside freed `shadow readback/upload staging` on RX 6950 XT and
RX 6700 XT (Marvisak#693 (comment)),
and a changes-requested review (mercuryVM). Its last commit (1c94839) fixes
the review's failure paths but not the performance loss, and was not run in
the title. Marvisak#1024 has no negative report; its tests pass on RTX 4090/Wine,
RTX 5070 Ti, RX 7700 XT, RTX 5090/Wine, and a title run with it (and Marvisak#472,
Marvisak#322) had shorter frames and less copy-back time (AgneyaK).

Conflicts, crates/victory-gpu/src/shadow.rs:
1. `Shadow::copy_back`: the stack (Marvisak#124, TG0000) skips pages already found
   unchanged against this submission's snapshot (`UnchangedPages`) and
   allocates the title buffer lazily, by PAGE; Marvisak#1024 writes back only the
   runs of bytes the GPU changed (`write_runs`) and marks a synced page
   current only if title memory still equals the copy after the final
   write-watch query. Independent: both kept. The loop keeps the stack's
   `unchanged.differs` guard and lazy buffer, with Marvisak#1024's run collection
   and `write_runs` inside; the final check takes the (by then allocated)
   lazy buffer for its page re-reads.
2. Tests: the stack's `mod tests` and Marvisak#1024's `mod copy_back_tests` at the
   same place. The shared text holds the closing `);`, `}` and `}`, so the
   stack's module is closed in the hunk and Marvisak#1024's module follows as its
   own `#[cfg(test)]` item (not nested).

No other non-textual fix needed (cargo check --all-targets --all-features).
KainanP added a commit to KainanP/VIctory that referenced this pull request Nov 24, 2026
…sak#98, Marvisak#334 to Marvisak#492, validation)

The line rebuilt on the bundles' current heads (Marvisak#1402 119b763, Marvisak#1492 5bbc098
without Marvisak#98, Marvisak#1504 1d41891, Marvisak#1511 ca601f0) with every merge replayed, and the
merges after this file's first version (Marvisak#334, Marvisak#346, Marvisak#1024, Marvisak#211, Marvisak#492): merge
order, the runner's numbers on 967d3ae (RTX 571, WARP 570 + the known Marvisak#1084
failure, all features 580; Marvisak#98's one test leaves), what is not included (Marvisak#98,
Marvisak#282 for Marvisak#346, Marvisak#693 for Marvisak#1024, Marvisak#306's latest commit), and the open pull
requests whose head is contained here (109, from the 18:24 collection).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-gpu/src/host.rs, crates/victory-gpu/src/shadow.rs, crates/victory-gpu/src/watch.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

geiyiliyabumo pushed a commit to geiyiliyabumo/VIctory that referenced this pull request Nov 25, 2026
…d-d16-440-111a

Shaders: keep image_load d16 high half and saturate integer texels (Marvisak#440)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.