GPU: copies of read-only title buffers in GPU upload heaps (opt-in) #2120

Closed
github-bot wants to merge 2 commits from github-bot/gh-2120 into main AGit
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 05:30 UTC · original
0xkn0wh3r3:gpu/upload-heap-copies → main · +457 −10 · 3 files · 2 commits · closed without merging

The problem

Shaders read title buffers about 30 times slower than the console's GPU does.

Host copies of title buffers are in system memory (Host::shared_buffer: a custom heap, write-back, memory pool L0), so that the CPU can refresh them and read back what shaders write. Every shader read of a copy then crosses PCIe. On an RTX 5070 Ti a shader reads 256 MiB from such a copy at 22.9 GB/s, and from video memory at 713 GB/s. The console's memory is one pool, and the GPU reads it at video memory speed.

The fix

A buffer the title makes without unordered access is one shaders only read: nothing reads its copy back, and the CPU only writes it (refreshes). Its copy can be in video memory the CPU writes through the PCI BAR: a GPU upload heap (D3D12_HEAP_TYPE_GPU_UPLOAD, D3D12_OPTIONS16, on hosts with resizable BAR).

With VICTORY_GPU_UPLOAD=1:

  • shadow::register_read_only registers such buffers (resource.rs, from the title's ALLOW_UNORDERED_ACCESS flag), and shadow::find makes their copies with Host::gpu_upload_buffer.
  • Copies past 2 GiB of video memory, and every copy on hosts without GPU upload heaps, stay in system memory, as before.
  • Shaders that still write such a copy (through a view of the same memory under another resource) get it right, slowly: the copy-back reads video memory at ~50 MB/s. A warning names the first one.

Measured on an RTX 5070 Ti (driver 621.24, Ryzen 9 7900X), 256 MiB, through shadow::find (reading_copies_in_video_and_system_memory):

copy shader reads refresh writes (first, every page)
writable buffer's (system memory) 11.74 ms, 22.9 GB/s 42.1 ms
read-only buffer's (GPU upload heap) 0.38 ms, 713 GB/s 32.8 ms

Off by default: how much of a world frame's GPU time this is depends on which buffers the title makes without unordered access, which needs a run of the title to measure.

How to try it

Set VICTORY_GPU_UPLOAD=1 before victory run. The log says whether it is on (host copies that shaders only read in GPU upload heaps). It needs resizable BAR enabled (Windows 11 or a recent Agility SDK runtime). A world-frame comparison with and without it (GPU time per frame, VICTORY_GPU_TIMING=1) is what would tell whether to turn it on by default.

Testing

  • New test read_only_buffers_get_their_copies_in_video_memory (in a child process with the switch on): checks that a read-only buffer's copy is in a GPU upload heap, that the GPU reads what a refresh wrote there, and that a writable buffer's copy stays in system memory.
  • reading_copies_in_video_and_system_memory is the benchmark behind the table above (ignored by default; run in release with --ignored --nocapture).
  • cargo test -p victory-gpu --lib, with and without VICTORY_GPU_UPLOAD=1: 142 passed, the same 2 failing as on main on this GPU (#1835). The victory-gpu tests give the same results with the switch on and off.
  • cargo clippy -p victory-gpu --all-targets with and without --features diagnostics: clean.
  • Not run with a title (no game data here).
  • #693 moves shadow buffers to a DEFAULT (video memory) heap with staging transfers: an extra GPU copy per refresh, and for every buffer. Here the CPU writes the copy in video memory directly, and only for buffers shaders cannot write, so copy-back is untouched.
  • #2112, #407, #880, #1905 read title memory in place: that is system memory over PCIe, the 22.9 GB/s path above.
  • Follow-up: #2130 (stacked on this one) does the same for buffers shaders write, with a system memory mirror for the CPU. A shader reading and writing 256 MiB of such a copy takes 212.23 ms in system memory and 1.25 ms in video memory.

Rebased onto 13f91ca

  • Upstream now has its own Host::mapped_buffer. This PR's mapped_buffer(size, upload), which shared_buffer and gpu_upload_buffer share, is renamed shared_mapped_buffer.
  • Upstream c4e022d adds VICTORY_COPIES_IN_VIDEO_MEMORY=1, a diagnostics switch that puts every shared buffer, copies shaders write included, in a GPU upload heap to measure the cost of reads across the bus. CPU reads of those copies become slow, so it is for that measurement only and does not replace this PR. This PR puts only copies of read-only buffers in video memory, so copy-back still reads system memory.

Rebased onto 63bcca4

  • hand_out_resource tests the title's flags against resource.rs's existing UNORDERED constant instead of a local ALLOW_UNORDERED_ACCESS = 0x4 (folded into the first commit).
  • cargo test -p victory-gpu --lib, with and without VICTORY_GPU_UPLOAD=1: 231 passed, the same 2 failing as on main on this GPU (#1835). cargo clippy -p victory-gpu --all-targets, with and without --features diagnostics: clean. cargo xtask policy: ok.
  • Still not run with a title: the measurement with this switch alone (without #2130) and the read-only share log need a run I cannot do here.
**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 05:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2120) `0xkn0wh3r3:gpu/upload-heap-copies` → `main` · +457 −10 · 3 files · 2 commits · closed without merging ## The problem Shaders read title buffers about 30 times slower than the console's GPU does. Host copies of title buffers are in system memory (`Host::shared_buffer`: a custom heap, write-back, memory pool L0), so that the CPU can refresh them and read back what shaders write. Every shader read of a copy then crosses PCIe. On an RTX 5070 Ti a shader reads 256 MiB from such a copy at 22.9 GB/s, and from video memory at 713 GB/s. The console's memory is one pool, and the GPU reads it at video memory speed. ## The fix A buffer the title makes without unordered access is one shaders only read: nothing reads its copy back, and the CPU only writes it (refreshes). Its copy can be in video memory the CPU writes through the PCI BAR: a GPU upload heap (`D3D12_HEAP_TYPE_GPU_UPLOAD`, `D3D12_OPTIONS16`, on hosts with resizable BAR). With `VICTORY_GPU_UPLOAD=1`: - `shadow::register_read_only` registers such buffers (`resource.rs`, from the title's `ALLOW_UNORDERED_ACCESS` flag), and `shadow::find` makes their copies with `Host::gpu_upload_buffer`. - Copies past 2 GiB of video memory, and every copy on hosts without GPU upload heaps, stay in system memory, as before. - Shaders that still write such a copy (through a view of the same memory under another resource) get it right, slowly: the copy-back reads video memory at ~50 MB/s. A warning names the first one. Measured on an RTX 5070 Ti (driver 621.24, Ryzen 9 7900X), 256 MiB, through `shadow::find` (`reading_copies_in_video_and_system_memory`): | copy | shader reads | refresh writes (first, every page) | |---|---|---| | writable buffer's (system memory) | 11.74 ms, 22.9 GB/s | 42.1 ms | | read-only buffer's (GPU upload heap) | 0.38 ms, 713 GB/s | 32.8 ms | Off by default: how much of a world frame's GPU time this is depends on which buffers the title makes without unordered access, which needs a run of the title to measure. ## How to try it Set `VICTORY_GPU_UPLOAD=1` before `victory run`. The log says whether it is on (`host copies that shaders only read in GPU upload heaps`). It needs resizable BAR enabled (Windows 11 or a recent Agility SDK runtime). A world-frame comparison with and without it (GPU time per frame, `VICTORY_GPU_TIMING=1`) is what would tell whether to turn it on by default. ## Testing - New test `read_only_buffers_get_their_copies_in_video_memory` (in a child process with the switch on): checks that a read-only buffer's copy is in a GPU upload heap, that the GPU reads what a refresh wrote there, and that a writable buffer's copy stays in system memory. - `reading_copies_in_video_and_system_memory` is the benchmark behind the table above (ignored by default; run in release with `--ignored --nocapture`). - `cargo test -p victory-gpu --lib`, with and without `VICTORY_GPU_UPLOAD=1`: 142 passed, the same 2 failing as on `main` on this GPU (#1835). The victory-gpu tests give the same results with the switch on and off. - `cargo clippy -p victory-gpu --all-targets` with and without `--features diagnostics`: clean. - Not run with a title (no game data here). ## Related - #693 moves shadow buffers to a DEFAULT (video memory) heap with staging transfers: an extra GPU copy per refresh, and for every buffer. Here the CPU writes the copy in video memory directly, and only for buffers shaders cannot write, so copy-back is untouched. - #2112, #407, #880, #1905 read title memory in place: that is system memory over PCIe, the 22.9 GB/s path above. - Follow-up: #2130 (stacked on this one) does the same for buffers shaders write, with a system memory mirror for the CPU. A shader reading and writing 256 MiB of such a copy takes 212.23 ms in system memory and 1.25 ms in video memory. ### Rebased onto 13f91ca - Upstream now has its own `Host::mapped_buffer`. This PR's `mapped_buffer(size, upload)`, which `shared_buffer` and `gpu_upload_buffer` share, is renamed `shared_mapped_buffer`. - Upstream c4e022d adds `VICTORY_COPIES_IN_VIDEO_MEMORY=1`, a diagnostics switch that puts every shared buffer, copies shaders write included, in a GPU upload heap to measure the cost of reads across the bus. CPU reads of those copies become slow, so it is for that measurement only and does not replace this PR. This PR puts only copies of read-only buffers in video memory, so copy-back still reads system memory. ### Rebased onto 63bcca4 - `hand_out_resource` tests the title's flags against `resource.rs`'s existing `UNORDERED` constant instead of a local `ALLOW_UNORDERED_ACCESS = 0x4` (folded into the first commit). - `cargo test -p victory-gpu --lib`, with and without `VICTORY_GPU_UPLOAD=1`: 231 passed, the same 2 failing as on `main` on this GPU (#1835). `cargo clippy -p victory-gpu --all-targets`, with and without `--features diagnostics`: clean. `cargo xtask policy`: ok. - Still not run with a title: the measurement with this switch alone (without #2130) and the read-only share log need a run I cannot do here.
Host copies of title buffers are in system memory (`Host::shared_buffer`:
a custom heap, write-back, memory pool L0) so that the CPU can refresh
them and read back what shaders write. Every shader read of a copy then
crosses PCIe. On an RTX 5070 Ti a shader reads 256 MiB from such a copy
at 22.9 GB/s, and from video memory at 713 GB/s: the console's memory is
one pool, and the GPU reads it at video memory speed.

A buffer the title makes without unordered access is one shaders only
read: nothing reads its copy back, and the CPU only writes it (refreshes).
Its copy can be in video memory the CPU writes through the PCI BAR: a GPU
upload heap (`D3D12_HEAP_TYPE_GPU_UPLOAD`, `D3D12_OPTIONS16`, on hosts
with resizable BAR). With `VICTORY_GPU_UPLOAD=1`:

- `shadow::register_read_only` registers such buffers (`resource.rs`, from
  the title's `ALLOW_UNORDERED_ACCESS` flag), and `shadow::find` makes
  their copies with `Host::gpu_upload_buffer`;
- copies past 2 GiB of video memory, and every copy on hosts without GPU
  upload heaps, stay in system memory, as before;
- shaders that still write such a copy (through a view of the same memory
  under another resource) get it right, slowly: the copy-back reads video
  memory at ~50 MB/s; a warning names the first one.

Measured on an RTX 5070 Ti (driver 621.24, Ryzen 9 7900X), 256 MiB,
through `shadow::find` (`reading_copies_in_video_and_system_memory`):

| copy | shader reads | refresh writes (first, every page) |
|---|---|---|
| writable buffer's (system memory) | 11.74 ms, 22.9 GB/s | 42.1 ms |
| read-only buffer's (GPU upload heap) | 0.38 ms, 713 GB/s | 32.8 ms |

Off by default: how much of a world frame's GPU time this is depends on
which buffers the title makes without unordered access, which needs a
run of the title to measure.

`read_only_buffers_get_their_copies_in_video_memory` (in a child process
with the switch on) checks that a read-only buffer's copy is in a GPU
upload heap, that the GPU reads what a refresh wrote there, and that a
writable buffer's copy stays in system memory. The victory-gpu tests
give the same results with the switch on and off.
The 2 GiB allowance for host copies in GPU upload heaps counted every
copy made over the whole run and never took any back. After enough read-
only buffers came and went (64 of 32 MiB on an RTX 3050 Laptop, with
only one alive at a time), every later copy went to system memory for
the rest of the run.

A copy's bytes now leave the count when D3D12 destroys its buffer, through
the buffer's destruction notifier. That is when the last reference goes
(the copy's, and the clones lists and descriptor tables hold), not when
the copy drops. A host without the notifier keeps copies in system memory
instead of charging them for good.

Test: upload_budget_is_given_back_when_copies_go. It makes 20 copies of
128 MiB one after another (2.5 GiB, past the budget). Each one is in a GPU
upload heap, stays charged while a clone of its buffer is held after the
copy dropped, and is given back once the clone goes. With the callback
doing nothing, it fails in the first round.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:55:26 +00:00
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 05:31 UTC · original

Thanks for the bandwidth numbers. The 22.9 vs 713 GB/s comparison is very useful. Some context from the #2112 side, in case it helps decide how the two fit together:

  • #2112 reads over the same path as the copies on main today: those already live in shared_buffer (custom heap, L0, system memory). So in place doesn't make shader reads slower than now. It only removes the copy and its refreshes. This PR is the one that makes reads faster.
  • They pull in different directions on memory. On a 16 GB RTX 5080 under Wine, video memory is currently what runs out first: every run of mine fills it while the world loads, before the first world frame. Title buffers here are about 1.2 GB, so moving the read-only ones into GPU upload heaps would hit that limit sooner on cards like this one. On cards with more headroom, your path is the better one.
  • So they look complementary rather than competing. Per buffer: a GPU upload copy while video memory has room (QueryVideoMemoryInfo budget), and in place otherwise. Both touch shadow::find, so whichever lands second will need a small rebase. I'm happy to do that on my side.

Not measured on my side: the read-only share of those 1.2 GB. Your register_read_only would give that directly if a run logs it.

**@⁠desplmfao** on GitHub · 2026-11-25 05:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2120#issuecomment-7153860858) Thanks for the bandwidth numbers. The 22.9 vs 713 GB/s comparison is very useful. Some context from the #2112 side, in case it helps decide how the two fit together: - #2112 reads over the same path as the copies on `main` today: those already live in `shared_buffer` (custom heap, L0, system memory). So in place doesn't make shader reads slower than now. It only removes the copy and its refreshes. This PR is the one that makes reads faster. - They pull in different directions on memory. On a 16 GB RTX 5080 under Wine, video memory is currently what runs out first: every run of mine fills it while the world loads, before the first world frame. Title buffers here are about 1.2 GB, so moving the read-only ones into GPU upload heaps would hit that limit sooner on cards like this one. On cards with more headroom, your path is the better one. - So they look complementary rather than competing. Per buffer: a GPU upload copy while video memory has room (`QueryVideoMemoryInfo` budget), and in place otherwise. Both touch `shadow::find`, so whichever lands second will need a small rebase. I'm happy to do that on my side. Not measured on my side: the read-only share of those 1.2 GB. Your `register_read_only` would give that directly if a run logs it.
Author
Owner

@⁠Dathinel on GitHub · 2026-11-25 05:38 UTC · original

The 2 GiB allowance currently counts successful allocations across the lifetime of the process. On e8df416 I repeatedly registered one synthetic 32 MiB read-only buffer, called shadow::find, inspected its heap type, then unregistered it and dropped the last shadow reference before the next iteration. I verified that its Weak reference expired each time.

With the production budget and counter unchanged on an RTX 3050 Laptop, allocations 1–64 used GPU upload heaps; 65 and 66 used system memory. This can permanently disable the fast path after enough resource turnover even when very few shadows are live at once.

If the intent is an outstanding-allocation cap, successful reservations need a matching release. A separate one-page-headroom control still fell back while the first shadow was held; experimentally returning its charge on final shadow drop allowed the next allocation to use GPU upload again. When choosing the release point, consider that the descriptor path also clones the underlying D3D resource. The test establishes budget exhaustion, not leaked VRAM.

AI-assisted. Synthetic buffers only.

**@⁠Dathinel** on GitHub · 2026-11-25 05:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2120#issuecomment-7153995827) The 2 GiB allowance currently counts successful allocations across the lifetime of the process. On `e8df416` I repeatedly registered one synthetic 32 MiB read-only buffer, called `shadow::find`, inspected its heap type, then unregistered it and dropped the last shadow reference before the next iteration. I verified that its `Weak` reference expired each time. With the production budget and counter unchanged on an RTX 3050 Laptop, **allocations 1–64 used GPU upload heaps; 65 and 66 used system memory**. This can permanently disable the fast path after enough resource turnover even when very few shadows are live at once. If the intent is an outstanding-allocation cap, successful reservations need a matching release. A separate one-page-headroom control still fell back while the first shadow was held; experimentally returning its charge on final shadow drop allowed the next allocation to use GPU upload again. When choosing the release point, consider that the descriptor path also clones the underlying D3D resource. The test establishes budget exhaustion, not leaked VRAM. AI-assisted. Synthetic buffers only.
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 06:13 UTC · original

@⁠Dathinel thanks, good catch. The allowance was meant to cap outstanding copies, and it never took any back. Fixed in 772c567.

A copy's bytes now leave the count when D3D12 destroys its buffer: the buffer's ID3DDestructionNotifier callback gives the charge back. That covers your point about the descriptor path. The copy, lists and descriptor tables all hold clones of the same resource, so the charge stays until the last one goes, not just until the Shadow drops. A host without the notifier keeps these copies in system memory rather than charging them for good.

Regression test: upload_budget_is_given_back_when_copies_go. It makes 20 copies of 128 MiB, one after another (2.5 GiB in all, past the 2 GiB budget). Each copy lands in a GPU upload heap, stays charged while a clone of its buffer is held after the Shadow dropped, and is given back once the clone goes. With the callback doing nothing, it fails in the first round. cargo test -p victory-gpu --lib is unchanged with and without VICTORY_GPU_UPLOAD=1, apart from the two NVIDIA #1835 failures.

@⁠desplmfao thanks, that fits. Measured against the budget rather than a fixed 2 GiB, the two paths make a natural split: a GPU upload copy while video memory has room, in place otherwise. The fixed 2 GiB is already marked as a shortcut in the code for that reason. I'm happy for whichever lands second to take the small rebase in shadow::find. Logging the read-only share of the 1.2 GB through register_read_only is a good idea; I'll add that when this comes out of draft.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 06:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2120#issuecomment-7154578321) @⁠Dathinel thanks, good catch. The allowance was meant to cap outstanding copies, and it never took any back. Fixed in 772c567. A copy's bytes now leave the count when D3D12 destroys its buffer: the buffer's `ID3DDestructionNotifier` callback gives the charge back. That covers your point about the descriptor path. The copy, lists and descriptor tables all hold clones of the same resource, so the charge stays until the last one goes, not just until the `Shadow` drops. A host without the notifier keeps these copies in system memory rather than charging them for good. Regression test: `upload_budget_is_given_back_when_copies_go`. It makes 20 copies of 128 MiB, one after another (2.5 GiB in all, past the 2 GiB budget). Each copy lands in a GPU upload heap, stays charged while a clone of its buffer is held after the `Shadow` dropped, and is given back once the clone goes. With the callback doing nothing, it fails in the first round. `cargo test -p victory-gpu --lib` is unchanged with and without `VICTORY_GPU_UPLOAD=1`, apart from the two NVIDIA #1835 failures. @⁠desplmfao thanks, that fits. Measured against the budget rather than a fixed 2 GiB, the two paths make a natural split: a GPU upload copy while video memory has room, in place otherwise. The fixed 2 GiB is already marked as a shortcut in the code for that reason. I'm happy for whichever lands second to take the small rebase in `shadow::find`. Logging the read-only share of the 1.2 GB through `register_read_only` is a good idea; I'll add that when this comes out of draft.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 16:18 UTC · original · edited 2026-11-25 19:25 UTC

Automated triage for the maintainers.

Needs work: needs the maintainer's decision. It now merges cleanly into main. CI: not run on this head.

Behind VICTORY_GPU_UPLOAD=1, this puts host copies of title buffers made without unordered access into GPU upload heaps: Host::gpu_upload_buffer in host.rs, and register_read_only/find in shadow.rs. The 2 GiB budget is now given back through ID3DDestructionNotifier when a buffer is destroyed, which fixes the turnover problem raised in this thread. Shadow::update only writes the copy on refresh paths. A GPU write that does reach such a copy is still correct but slow, and it logs a warning.

Remaining items:

  • rerun_with_gpu_upload spawns the test binary as a child process, which needs the maintainer's decision.
  • hand_out_resource declares a local ALLOW_UNORDERED_ACCESS = 0x4, but resource.rs already has UNORDERED for the same flag. Please reuse it.
  • main already has the diagnostics switch VICTORY_COPIES_IN_VIDEO_MEMORY for all copies. A title measurement with this narrower switch (on its own, without #2130) would make the case for adding it. The read-only share log you mentioned would help too.

#2130 and #2222 are stacked on this branch, so this one lands first.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 16:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2120#issuecomment-7167768697) · edited 2026-11-25 19:25 UTC <!-- victory-triage v1 head=3cf0e2aeafd1a2f740b29f453243de29351c3238 verdict=needs-work at=2026-11-25T19:47:30Z --> Automated triage for the maintainers. **Needs work: needs the maintainer's decision.** It now merges cleanly into `main`. CI: not run on this head. Behind `VICTORY_GPU_UPLOAD=1`, this puts host copies of title buffers made without unordered access into GPU upload heaps: `Host::gpu_upload_buffer` in `host.rs`, and `register_read_only`/`find` in `shadow.rs`. The 2 GiB budget is now given back through `ID3DDestructionNotifier` when a buffer is destroyed, which fixes the turnover problem raised in this thread. `Shadow::update` only writes the copy on refresh paths. A GPU write that does reach such a copy is still correct but slow, and it logs a warning. Remaining items: - `rerun_with_gpu_upload` spawns the test binary as a child process, which needs the maintainer's decision. - `hand_out_resource` declares a local `ALLOW_UNORDERED_ACCESS = 0x4`, but `resource.rs` already has `UNORDERED` for the same flag. Please reuse it. - `main` already has the diagnostics switch `VICTORY_COPIES_IN_VIDEO_MEMORY` for all copies. A title measurement with this narrower switch (on its own, without #2130) would make the case for adding it. The read-only share log you mentioned would help too. #2130 and #2222 are stacked on this branch, so this one lands first. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Machad3x on GitHub · 2026-11-25 19:41 UTC · original

Setup: RTX 3080 Ti (driver 621.24), Windows 11, resizable BAR, a local stack of open PRs merged with main 67e8ae1.

1df99a6 has one conflict in shadow.rs (register, rewritten here around a split buffer index), and test entries made by hand need read_only: false. victory-gpu tests pass. At one scene of an 8-minute game run with VICTORY_GPU_UPLOAD=1: frame 919 to 881 ms, GPU step 577 to 557 ms (means of 20 reports, one run each, so within run-to-run variation). No device removal.

Written with Claude Code; tested locally.

**@⁠Machad3x** on GitHub · 2026-11-25 19:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2120#issuecomment-7172644849) Setup: RTX 3080 Ti (driver 621.24), Windows 11, resizable BAR, a local stack of open PRs merged with main 67e8ae1. 1df99a6 has one conflict in `shadow.rs` (`register`, rewritten here around a split buffer index), and test entries made by hand need `read_only: false`. `victory-gpu` tests pass. At one scene of an 8-minute game run with `VICTORY_GPU_UPLOAD=1`: frame 919 to 881 ms, GPU step 577 to 557 ms (means of 20 reports, one run each, so within run-to-run variation). No device removal. Written with Claude Code; tested locally.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 19:50 UTC · original

Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and review of 3cf0e2ae (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo xtask policy: 184 files ok; cargo clippy --locked -p victory-gpu --all-targets (default & --features diagnostics): 0 warnings.
  • WARP (VICTORY_D3D12_WARP=1, --features diagnostics --test-threads=1): 200 passed, 0 failed, 2 ignored with both VICTORY_GPU_UPLOAD unset and =1 (including read_only_buffers_get_their_copies_in_video_memory and upload_budget_is_given_back_when_copies_go).
  • RTX 5090: shadow::tests 10 passed, 0 failed, 1 ignored (both unset and VICTORY_GPU_UPLOAD=1), draw::tests 11 passed, 0 failed.

Review & Ecosystem Note (#2120 vs #2130 vs #2705)

  • Clean, focused opt-in change: zero overhead when unset, accurate ID3DDestructionNotifier budget refunding on actual D3D12 resource destruction, and safe fallback on unexpected writes.
  • In a side-by-side RTX 5090/WARP comparison with #2130 and #2705: #2120 is compact and ready on its own for ReBAR read-only buffers (1x memory, zero DMA copy), and pairs naturally with #2705 (DEFAULT VRAM + staging DMA for writable buffers and non-ReBAR GPUs) once #2705 skips buffers already placed in GPU_UPLOAD.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 19:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2120#issuecomment-7172832118) Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and review of `3cf0e2ae` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo xtask policy`: **184 files ok**; `cargo clippy --locked -p victory-gpu --all-targets` (default & `--features diagnostics`): **0 warnings**. - **WARP (`VICTORY_D3D12_WARP=1`, `--features diagnostics --test-threads=1`):** **200 passed, 0 failed, 2 ignored** with both `VICTORY_GPU_UPLOAD` unset and `=1` (including `read_only_buffers_get_their_copies_in_video_memory` and `upload_budget_is_given_back_when_copies_go`). - **RTX 5090:** `shadow::tests` **10 passed, 0 failed, 1 ignored** (both unset and `VICTORY_GPU_UPLOAD=1`), `draw::tests` **11 passed, 0 failed**. ### Review & Ecosystem Note (#2120 vs #2130 vs #2705) - Clean, focused opt-in change: zero overhead when unset, accurate `ID3DDestructionNotifier` budget refunding on actual D3D12 resource destruction, and safe fallback on unexpected writes. - In a side-by-side RTX 5090/WARP comparison with #2130 and #2705: #2120 is compact and ready on its own for ReBAR read-only buffers (1x memory, zero DMA copy), and pairs naturally with #2705 (`DEFAULT` VRAM + staging DMA for writable buffers and non-ReBAR GPUs) once #2705 skips buffers already placed in `GPU_UPLOAD`.
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 00:27 UTC · original

Thanks. Rebased onto 63bcca4; head is now b7e4a6f6.

  • ALLOW_UNORDERED_ACCESS = 0x4: gone. hand_out_resource now tests desc.flags & UNORDERED against the existing constant (crates/victory-gpu/src/resource.rs:1765, constant at :1139; both are #[cfg(windows)]). Folded into the first commit, 4941d712.
  • rerun_with_gpu_upload child process: your call. The switches are read once per process (OnceLock), which is why the tests re-run themselves.
  • Title measurement with this switch alone, and the read-only share log: I can't run the title here, so I don't have either. The only run with #2120 alone so far is Machad3x's in this thread (RTX 3080 Ti): GPU step 577 → 557 ms, frame 919 → 881 ms, which they put within run-to-run variation. Until there is a measurement, it stays off by default, behind its own switch.

Checks on b7e4a6f6 (RTX 5070 Ti, driver 621.24): cargo test -p victory-gpu --lib with and without VICTORY_GPU_UPLOAD=1 gives 231 passed, with the same 2 failures as on main here (#1835). cargo clippy -p victory-gpu --all-targets, with and without --features diagnostics: clean. cargo xtask policy: ok. #2130 and #2222 are rebased on top.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 00:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2120#issuecomment-7178784693) Thanks. Rebased onto 63bcca4; head is now `b7e4a6f6`. - **`ALLOW_UNORDERED_ACCESS = 0x4`**: gone. `hand_out_resource` now tests `desc.flags & UNORDERED` against the existing constant (`crates/victory-gpu/src/resource.rs:1765`, constant at `:1139`; both are `#[cfg(windows)]`). Folded into the first commit, `4941d712`. - **`rerun_with_gpu_upload` child process**: your call. The switches are read once per process (`OnceLock`), which is why the tests re-run themselves. - **Title measurement with this switch alone, and the read-only share log**: I can't run the title here, so I don't have either. The only run with #2120 alone so far is Machad3x's in this thread (RTX 3080 Ti): GPU step 577 → 557 ms, frame 919 → 881 ms, which they put within run-to-run variation. Until there is a measurement, it stays off by default, behind its own switch. Checks on `b7e4a6f6` (RTX 5070 Ti, driver 621.24): `cargo test -p victory-gpu --lib` with and without `VICTORY_GPU_UPLOAD=1` gives 231 passed, with the same 2 failures as on `main` here (#1835). `cargo clippy -p victory-gpu --all-targets`, with and without `--features diagnostics`: clean. `cargo xtask policy`: ok. #2130 and #2222 are rebased on top.
github-bot closed this pull request 2026-11-26 08:07:29 +00:00
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 05:48 UTC · original · reviewed

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Read-only title buffers copied into GPU upload heaps — upload-heap placement for RO buffers; pairs with #2130's written-buffer path (complementary, not dupes).

**@⁠catminou4** on GitHub · 2026-11-25 05:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2120#pullrequestreview-6052484020) · **reviewed** Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Read-only title buffers copied into GPU upload heaps — upload-heap placement for RO buffers; pairs with #2130's written-buffer path (complementary, not dupes).
Author
Owner

@⁠MeMako on GitHub · 2026-11-26 04:37 UTC · original

Independent AMD RDNA 4 verification + live title read-only share measurement of #2120 (b7e4a6f via #2130's eff9f91):

Setup: Windows 11 (10.0.26200), Ryzen 9 7950X, AMD Radeon RX 9070 XT (RDNA 4, driver 32.0.32029.2010, Resizable BAR enabled, 16 GB VRAM), local integration branch on origin/main 63bcca4 with #2051 + #2472 + #2918 + #1010.

Checks & microbenchmark:

  • cargo clippy -p victory-gpu -p victory --all-targets --locked -- -D warnings (default & --all-features): clean.
  • cargo test -p victory-gpu --locked: 264 passed, 0 failed (including read_only_buffers_get_their_copies_in_video_memory and upload_budget_is_given_back_when_copies_go).
  • reading_copies_in_video_and_system_memory (256 MiB, release):
    • System memory: 5.24 ms (51.2 GB/s) shader reads; 64.6 ms (4.2 GB/s) refresh writes
    • GPU upload heap: 0.63 ms (427.2 GB/s, 8.3x) shader reads; 65.9 ms (4.1 GB/s) refresh writes

Live title run (VICTORY_GPU_UPLOAD=1, VICTORY_GPU_UPLOAD_WRITES off, 11.5 min):

  • Stability: 0 crashes, 0 device removals, 0 upload-budget fallbacks, 0 unexpected-write warnings.
  • Read-only vs. writable share (live copied title buffers in steady state, logged via a local shadow::buffers() stat):
    • Read-only (UNORDERED == 0): 3,163 buffers = 22.8 MB (2.1%)
    • Writable (UNORDERED != 0): 650–718 buffers = 1,080.5 MB (97.9%)
  • World frame medians (>=4,000 draws/frame):
Run Heavy samples Frame (med) Preparing (copies) GPU (med) Copy-back
Baseline (switches off) 66 445.1 ms (2.20 fps) 197.3 ms (69.8 ms / 149 MB) 156.7 ms 89.2 ms
VICTORY_GPU_UPLOAD=1 96 471.4 ms (2.10 fps) 196.4 ms (64.8 ms / 138 MB) 166.0 ms 105.6 ms

(Steady tail, last 20 heavy samples: GPU 155.1 → 164.9 ms, frame 414.1 → 469.8 ms.)

This confirms Machad3x's RTX 3080 Ti observation and directly explains why #2120 alone shows no measurable world-frame GPU speedup: ~98% of the title's copied buffer bytes are created with ALLOW_UNORDERED_ACCESS, leaving only ~23 MB eligible for the read-only path. Keeping it opt-in (or as the foundation for writable-buffer VRAM paths) makes sense given that share.

Hardware runs were performed by me on my 7950X / RX 9070 XT; comment drafted with Antigravity.

**@⁠MeMako** on GitHub · 2026-11-26 04:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2120#issuecomment-7182759176) Independent AMD RDNA 4 verification + live title read-only share measurement of `#2120` (`b7e4a6f` via `#2130`'s `eff9f91`): **Setup:** Windows 11 (`10.0.26200`), Ryzen 9 7950X, AMD Radeon RX 9070 XT (RDNA 4, driver `32.0.32029.2010`, Resizable BAR enabled, 16 GB VRAM), local integration branch on `origin/main` `63bcca4` with `#2051` + `#2472` + `#2918` + `#1010`. **Checks & microbenchmark:** - `cargo clippy -p victory-gpu -p victory --all-targets --locked -- -D warnings` (default & `--all-features`): clean. - `cargo test -p victory-gpu --locked`: **264 passed, 0 failed** (including `read_only_buffers_get_their_copies_in_video_memory` and `upload_budget_is_given_back_when_copies_go`). - `reading_copies_in_video_and_system_memory` (256 MiB, release): - System memory: **5.24 ms** (`51.2 GB/s`) shader reads; `64.6 ms` (`4.2 GB/s`) refresh writes - GPU upload heap: **0.63 ms** (`427.2 GB/s`, **8.3x**) shader reads; `65.9 ms` (`4.1 GB/s`) refresh writes **Live title run (`VICTORY_GPU_UPLOAD=1`, `VICTORY_GPU_UPLOAD_WRITES` off, 11.5 min):** - **Stability:** 0 crashes, 0 device removals, 0 upload-budget fallbacks, 0 unexpected-write warnings. - **Read-only vs. writable share (live copied title buffers in steady state, logged via a local `shadow::buffers()` stat):** - Read-only (`UNORDERED == 0`): `3,163` buffers = **`22.8 MB` (`2.1%`)** - Writable (`UNORDERED != 0`): `650–718` buffers = **`1,080.5 MB` (`97.9%`)** - **World frame medians (`>=4,000` draws/frame):** | Run | Heavy samples | Frame (med) | Preparing (`copies`) | GPU (med) | Copy-back | |---|---:|---:|---:|---:|---:| | Baseline (switches off) | 66 | 445.1 ms (`2.20 fps`) | 197.3 ms (`69.8 ms / 149 MB`) | 156.7 ms | 89.2 ms | | `VICTORY_GPU_UPLOAD=1` | 96 | 471.4 ms (`2.10 fps`) | 196.4 ms (`64.8 ms / 138 MB`) | 166.0 ms | 105.6 ms | *(Steady tail, last 20 heavy samples: GPU `155.1 → 164.9 ms`, frame `414.1 → 469.8 ms`.)* This confirms Machad3x's RTX 3080 Ti observation and directly explains why `#2120` alone shows no measurable world-frame GPU speedup: ~98% of the title's copied buffer bytes are created with `ALLOW_UNORDERED_ACCESS`, leaving only ~23 MB eligible for the read-only path. Keeping it opt-in (or as the foundation for writable-buffer VRAM paths) makes sense given that share. *Hardware runs were performed by me on my 7950X / RX 9070 XT; comment drafted with Antigravity.*
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 08:05 UTC · original

Replaced by #3102, which combines this with the rest of the host-memory placement work in one PR, with measurements on a discrete and an integrated GPU. Closing here.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 08:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2120#issuecomment-7186174884) Replaced by #3102, which combines this with the rest of the host-memory placement work in one PR, with measurements on a discrete and an integrated GPU. Closing here.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2120
No description provided.