16 GB cards: every title buffer's copy in the card's memory (VICTORY_CARD_BUFFERS_MIN_KB=64) takes ~10 ms of snapshots off the submitting thread #343

Open
opened 2026-11-26 17:59:36 +00:00 by github-bot · 2 comments
Owner

@⁠Arvi23 on GitHub · 2026-11-26 17:48 UTC · original

On a 16 GB card, VICTORY_CARD_BUFFERS_MIN_KB=64 (every title buffer's copy in the card's memory) takes the CPU snapshots (~9 ms a frame) off the submitting thread: in busy gameplay it went from working 53.7 to 46.5 ms a frame, and frames from 58.1 to 49.4 ms (median). VRAM in use stayed the same.

Edited: an earlier version gave 7–18 ms for the submitting thread; those were menu frames at the end of the run. The numbers below are busy stretches only (frame lines with more than 3,000 draws, and the lines logged with them).

Machine: RX 9070 XT 16 GB (budget 14.8 GB), driver 32.0.32029.2010, Ryzen 7 5800X3D (8 cores), 32 GB, Windows 10 LTSC 21H2 (Agility SDK 620). Build: c9c932c + local patches, diag, scripts\play.ps1 defaults, Series X, renderer ports 1 and 2. Same route both runs: opening cutscene, then the city waterfront on the boat.

On a 12–20 GiB budget, default_card_limits_mb puts copies in the card's memory from 4 MiB. Smaller copies that shaders write take the CPU path: a snapshot on the submitting thread before each submission, and a compare afterwards. On this machine that path set the frame.

per frame default (4 MiB) VICTORY_CARD_BUFFERS_MIN_KB=64
snapshots (submitting thread, preparing per frame line) 8.9 ms 0.0
submitting thread worked (VICTORY_ASYNC_SUBMIT line) 53.7 ms 46.5 ms
busy frames (>3,000 draws), median / best 58.1 / 47.2 ms 49.4 / 43.1 ms
card busy (the card's clock line) 68 % 70 %
card memory in use / budget 14,389 / 14,821 MB 14,213 / 14,780 MB

There was no device loss in either run. By eye: cutscenes reach 30 fps, and the boat averages 20–22 instead of 16–18. The submitting thread still sets the frame (the title waits ~20 ms at each present in both runs). With more cores the gain may be smaller, but the snapshots ran one after another on that one thread either way.

Suggested default: 64 KiB on budgets over 12 GiB, unless VICTORY_CARD_BUFFERS_MIN_MB asks for a size (the _KB variable still wins). This is what we run:

Diff (crates/victory-gpu/src/shadow.rs)
diff --git a/crates/victory-gpu/src/shadow.rs b/crates/victory-gpu/src/shadow.rs
index 7520e22..e4456ef 100644
--- a/crates/victory-gpu/src/shadow.rs
+++ b/crates/victory-gpu/src/shadow.rs
@@ -207,6 +207,16 @@ fn resolve_card_limits(
     (min_bytes, max_bytes)
 }
 
+/// `VICTORY_CARD_BUFFERS_MIN_KB` when it is not set: 64 (every title buffer)
+/// on budgets over 12 GiB, unless `VICTORY_CARD_BUFFERS_MIN_MB` says a size.
+/// On an RX 9070 XT (16 GB, 8 cores) the copies under 4 MiB took 9-10 ms of
+/// snapshots a frame on the submitting thread, which worked 53-55 ms a frame;
+/// with every buffer on the card 7-18 ms, frames 58 -> 52 ms (median), the
+/// card's memory in use the same.
+fn default_min_kb(local_vram_budget: Option<u64>, min_mb_override: Option<u64>) -> Option<u64> {
+    (min_mb_override.is_none() && local_vram_budget.is_some_and(|b| b > 12 << 30)).then_some(64)
+}
+
 /// The smallest title buffer whose copy goes to the card's memory, and the
 /// most bytes of such copies (their "before" twins not counted: a copy
 /// shaders write takes its size twice), both in bytes:
@@ -229,7 +239,8 @@ fn card_limits() -> (u64, u64) {
         // buffer. Copies under 1 MiB are nearly all there are and few bytes;
         // in the PC's memory every load, store and atomic a shader does on
         // them crosses the bus.
-        if let Some(kib) = std::env::var("VICTORY_CARD_BUFFERS_MIN_KB").ok().and_then(|v| v.trim().parse::<u64>().ok())
+        let kib = std::env::var("VICTORY_CARD_BUFFERS_MIN_KB").ok().and_then(|v| v.trim().parse::<u64>().ok());
+        if let Some(kib) = kib.or(default_min_kb(vram_budget, env_mb("VICTORY_CARD_BUFFERS_MIN_MB")))
             && kib > 0
         {
             min_bytes = kib << 10;
@@ -5724,7 +5735,7 @@ pub(crate) fn exact_line(frames: f64) {
 #[cfg(test)]
 mod window_tests {
     use super::{
-        WINDOW, cover, default_card_limits_mb, grid, holder, longest_tail, resolve_card_limits,
+        WINDOW, cover, default_card_limits_mb, default_min_kb, grid, holder, longest_tail, resolve_card_limits,
         tail_of, window_of, window_victims,
     };
 
@@ -5771,6 +5782,13 @@ mod window_tests {
         assert_eq!(default_card_limits_mb(Some(32 * GIB)), (1, 8192));
         assert_eq!(default_card_limits_mb(Some(48 * GIB)), (1, 8192));
 
+        // Every title buffer on the card over 12 GiB, unless a size in MiB is asked.
+        assert_eq!(default_min_kb(Some(15 * GIB), None), Some(64));
+        assert_eq!(default_min_kb(Some(24 * GIB), None), Some(64));
+        assert_eq!(default_min_kb(Some(12 * GIB), None), None);
+        assert_eq!(default_min_kb(None, None), None);
+        assert_eq!(default_min_kb(Some(16 * GIB), Some(4)), None);
+
         // Explicit env overrides always win, clamp min to >= 1 MiB, and saturate on overflow.
         assert_eq!(resolve_card_limits(Some(32 * GIB), Some(8), Some(4096)), (8 * MIB, 4096 * MIB));
         assert_eq!(resolve_card_limits(Some(12 * GIB), Some(0), Some(1024)), (MIB, 1024 * MIB));
**@⁠Arvi23** on GitHub · 2026-11-26 17:48 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/343) **On a 16 GB card, `VICTORY_CARD_BUFFERS_MIN_KB=64` (every title buffer's copy in the card's memory) takes the CPU snapshots (~9 ms a frame) off the submitting thread: in busy gameplay it went from working 53.7 to 46.5 ms a frame, and frames from 58.1 to 49.4 ms (median). VRAM in use stayed the same.** _Edited: an earlier version gave 7–18 ms for the submitting thread; those were menu frames at the end of the run. The numbers below are busy stretches only (frame lines with more than 3,000 draws, and the lines logged with them)._ Machine: RX 9070 XT 16 GB (budget 14.8 GB), driver 32.0.32029.2010, Ryzen 7 5800X3D (8 cores), 32 GB, Windows 10 LTSC 21H2 (Agility SDK 620). Build: `c9c932c` + local patches, diag, `scripts\play.ps1` defaults, Series X, renderer ports 1 and 2. Same route both runs: opening cutscene, then the city waterfront on the boat. On a 12–20 GiB budget, `default_card_limits_mb` puts copies in the card's memory from 4 MiB. Smaller copies that shaders write take the CPU path: a snapshot on the submitting thread before each submission, and a compare afterwards. On this machine that path set the frame. | per frame | default (4 MiB) | `VICTORY_CARD_BUFFERS_MIN_KB=64` | |---|---|---| | snapshots (submitting thread, `preparing per frame` line) | 8.9 ms | 0.0 | | submitting thread worked (`VICTORY_ASYNC_SUBMIT` line) | 53.7 ms | 46.5 ms | | busy frames (>3,000 draws), median / best | 58.1 / 47.2 ms | 49.4 / 43.1 ms | | card busy (`the card's clock` line) | 68 % | 70 % | | card memory in use / budget | 14,389 / 14,821 MB | 14,213 / 14,780 MB | There was no device loss in either run. By eye: cutscenes reach 30 fps, and the boat averages 20–22 instead of 16–18. The submitting thread still sets the frame (the title waits ~20 ms at each present in both runs). With more cores the gain may be smaller, but the snapshots ran one after another on that one thread either way. Suggested default: 64 KiB on budgets over 12 GiB, unless `VICTORY_CARD_BUFFERS_MIN_MB` asks for a size (the `_KB` variable still wins). This is what we run: <details><summary>Diff (crates/victory-gpu/src/shadow.rs)</summary> ```diff diff --git a/crates/victory-gpu/src/shadow.rs b/crates/victory-gpu/src/shadow.rs index 7520e22..e4456ef 100644 --- a/crates/victory-gpu/src/shadow.rs +++ b/crates/victory-gpu/src/shadow.rs @@ -207,6 +207,16 @@ fn resolve_card_limits( (min_bytes, max_bytes) } +/// `VICTORY_CARD_BUFFERS_MIN_KB` when it is not set: 64 (every title buffer) +/// on budgets over 12 GiB, unless `VICTORY_CARD_BUFFERS_MIN_MB` says a size. +/// On an RX 9070 XT (16 GB, 8 cores) the copies under 4 MiB took 9-10 ms of +/// snapshots a frame on the submitting thread, which worked 53-55 ms a frame; +/// with every buffer on the card 7-18 ms, frames 58 -> 52 ms (median), the +/// card's memory in use the same. +fn default_min_kb(local_vram_budget: Option<u64>, min_mb_override: Option<u64>) -> Option<u64> { + (min_mb_override.is_none() && local_vram_budget.is_some_and(|b| b > 12 << 30)).then_some(64) +} + /// The smallest title buffer whose copy goes to the card's memory, and the /// most bytes of such copies (their "before" twins not counted: a copy /// shaders write takes its size twice), both in bytes: @@ -229,7 +239,8 @@ fn card_limits() -> (u64, u64) { // buffer. Copies under 1 MiB are nearly all there are and few bytes; // in the PC's memory every load, store and atomic a shader does on // them crosses the bus. - if let Some(kib) = std::env::var("VICTORY_CARD_BUFFERS_MIN_KB").ok().and_then(|v| v.trim().parse::<u64>().ok()) + let kib = std::env::var("VICTORY_CARD_BUFFERS_MIN_KB").ok().and_then(|v| v.trim().parse::<u64>().ok()); + if let Some(kib) = kib.or(default_min_kb(vram_budget, env_mb("VICTORY_CARD_BUFFERS_MIN_MB"))) && kib > 0 { min_bytes = kib << 10; @@ -5724,7 +5735,7 @@ pub(crate) fn exact_line(frames: f64) { #[cfg(test)] mod window_tests { use super::{ - WINDOW, cover, default_card_limits_mb, grid, holder, longest_tail, resolve_card_limits, + WINDOW, cover, default_card_limits_mb, default_min_kb, grid, holder, longest_tail, resolve_card_limits, tail_of, window_of, window_victims, }; @@ -5771,6 +5782,13 @@ mod window_tests { assert_eq!(default_card_limits_mb(Some(32 * GIB)), (1, 8192)); assert_eq!(default_card_limits_mb(Some(48 * GIB)), (1, 8192)); + // Every title buffer on the card over 12 GiB, unless a size in MiB is asked. + assert_eq!(default_min_kb(Some(15 * GIB), None), Some(64)); + assert_eq!(default_min_kb(Some(24 * GIB), None), Some(64)); + assert_eq!(default_min_kb(Some(12 * GIB), None), None); + assert_eq!(default_min_kb(None, None), None); + assert_eq!(default_min_kb(Some(16 * GIB), Some(4)), None); + // Explicit env overrides always win, clamp min to >= 1 MiB, and saturate on overflow. assert_eq!(resolve_card_limits(Some(32 * GIB), Some(8), Some(4096)), (8 * MIB, 4096 * MIB)); assert_eq!(resolve_card_limits(Some(12 * GIB), Some(0), Some(1024)), (MIB, 1024 * MIB)); ``` </details>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 17:59:36 +00:00
Author
Owner

@⁠Lancito01 on GitHub · 2026-11-26 18:27 UTC · original

Same switch on a 10 GB NVIDIA card, where the effect is much larger. One run each, so treat it as a strong lead rather than a measurement.

Machine: RTX 3080 10 GB (budget 9285 MB), 32 GB RAM, Windows 11. Tree: cool_fox f4b48ad (on this repo's 0a43566), diag, Series S profile. Switches: INDIRECT_WINDOW=1 LEVELS_ON_DEMAND=1 TEXTURE_NO_WAIT=1 CARD_REHASH_RUNS=1 TEXTURE_BACK=1 LATE_WAIT=3 AMBIENT=0.6 CARD_BUFFERS_MB=1536 (the #213 set). Scene: prison cutscene, ~4,000-4,500 draws, all pipelines built (0 being made).

On a budget under 12 GiB the default puts copies in the card's memory only from 16 MiB (logged card_buffers_min_kb=16384).

per frame (settled) default (16 MiB) CARD_BUFFERS_MIN_KB=64
frame 146-150 ms 79-85 ms
on the GPU 64-73 ms 7-12 ms
preparing 62-64 ms 61-65 ms
copying back 51-53 ms (47 MB) 37-42 ms (45-46 MB)

So on this card the bigger cost of the default is on the GPU, not the submitting thread: shaders reading and writing the small copies in system memory over the bus. With 64 KiB the GPU drops to about a tenth, and the frame is then set by the CPU side (preparing plus copying back, ~100 ms together).

The same tree with output at 1080p instead of the default gave the same 79-85 ms, so on this card resolution is not the limit once the copies are in VRAM.

**@⁠Lancito01** on GitHub · 2026-11-26 18:27 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/343#issuecomment-7200482487) Same switch on a 10 GB NVIDIA card, where the effect is much larger. One run each, so treat it as a strong lead rather than a measurement. Machine: RTX 3080 10 GB (budget 9285 MB), 32 GB RAM, Windows 11. Tree: cool_fox f4b48ad (on this repo's 0a43566), diag, Series S profile. Switches: INDIRECT_WINDOW=1 LEVELS_ON_DEMAND=1 TEXTURE_NO_WAIT=1 CARD_REHASH_RUNS=1 TEXTURE_BACK=1 LATE_WAIT=3 AMBIENT=0.6 CARD_BUFFERS_MB=1536 (the #213 set). Scene: prison cutscene, ~4,000-4,500 draws, all pipelines built (0 being made). On a budget under 12 GiB the default puts copies in the card's memory only from 16 MiB (logged `card_buffers_min_kb=16384`). | per frame (settled) | default (16 MiB) | `CARD_BUFFERS_MIN_KB=64` | |---|---|---| | frame | 146-150 ms | 79-85 ms | | on the GPU | 64-73 ms | 7-12 ms | | preparing | 62-64 ms | 61-65 ms | | copying back | 51-53 ms (47 MB) | 37-42 ms (45-46 MB) | So on this card the bigger cost of the default is on the GPU, not the submitting thread: shaders reading and writing the small copies in system memory over the bus. With 64 KiB the GPU drops to about a tenth, and the frame is then set by the CPU side (preparing plus copying back, ~100 ms together). The same tree with output at 1080p instead of the default gave the same 79-85 ms, so on this card resolution is not the limit once the copies are in VRAM.
Author
Owner

@⁠Arvi23 on GitHub · 2026-11-26 19:55 UTC · original

Thanks for running it on a 10 GB card, that's the most useful data point here. It also shows where the cost really sits: on your card it's the GPU reading and writing the small copies over the bus, and on mine it was mostly the CPU snapshots on the submitting thread.

In our fork the 64 KiB default only applies to budgets over 12 GiB (default_min_kb in the diff above). Your run suggests it's worth it on smaller cards too. One thing to watch there: a copy that shaders write takes its size twice in VRAM, so on 8–10 GB cards the VICTORY_CARD_BUFFERS_MB cap (1536 MB in your set) matters more. If someone has an 8 GB card, a run with 64 KiB and the texture memory line would show whether it starts evicting textures.

**@⁠Arvi23** on GitHub · 2026-11-26 19:55 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/343#issuecomment-7202100647) Thanks for running it on a 10 GB card, that's the most useful data point here. It also shows where the cost really sits: on your card it's the GPU reading and writing the small copies over the bus, and on mine it was mostly the CPU snapshots on the submitting thread. In our fork the 64 KiB default only applies to budgets over 12 GiB (`default_min_kb` in the diff above). Your run suggests it's worth it on smaller cards too. One thing to watch there: a copy that shaders write takes its size twice in VRAM, so on 8–10 GB cards the `VICTORY_CARD_BUFFERS_MB` cap (1536 MB in your set) matters more. If someone has an 8 GB card, a run with 64 KiB and the texture memory line would show whether it starts evicting textures.
This discussion has been locked. Commenting is limited to contributors.
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/avatarmanz--VIctory-7900XTX#343
No description provided.