GPU: an option to refresh a texture once every N frames #2476

Open
HoLa-Lee wants to merge 1 commit from upstream-pr/2478 into main
HoLa-Lee commented 2026-11-25 14:25:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by HoLa-Lee on 2026-11-25T14:25:26Z.


What this is

A world that renders at a frame a second spends most of that frame reading title memory for textures. Measured on one title and machine, on the card, with docs-level counters: 24,821 texture refreshes pulling 24.8 GB of title memory in a single frame, with none of them skipped, and 6,814 ms of the frame's 7,000 ms of texture work spent waiting for that memory. The GPU did 71-72 ms in the same frame.

VICTORY_TEXTURE_REFRESH_EVERY=<n> reads a texture once every n frames at most, round-robin by the texture's own address so the frames share the work instead of one frame taking all of it:

fn due(&self) -> bool {
    // diagnostics only; 0, 1 or unset: every frame
    every <= 1 || (crate::frame::current() + ((self.memory as usize >> 16) as u64)).is_multiple_of(every)
}

// refresh_all, before in_parallel: a texture that is not due is not handed to a thread
let changed: Vec<usize> = (0..work.len()).filter(|&i| work[i].0.due() && work[i].0.maybe_changed()).collect();

and refresh() returns None (nothing changed, keep the last upload) on the frames that are not its turn.

What it buys

At VICTORY_TEXTURE_REFRESH_EVERY=8, same scene, same captures: 145-522 ms a frame instead of 2,333-6,906 ms (0.1-0.4 fps to 1.9-6.9 fps), with the picture intact - the same frame numbers captured before and after compare.

What it costs

A texture's contents can lag by up to n frames. Unset, 0 or 1: nothing changes, every frame refreshes exactly as now, so this is inert for anyone who does not ask for it. It is a switch for slow machines and for measuring what the refresh costs, not a claim that every frame should skip reads - the proper fix (refresh only what the frame reads) is a larger change in draw.rs/host.rs.

Changes since the last review (a6d6afa)

All four review points are in, in this push (c8d6571):

  1. Behind the diagnostics feature, like the other VICTORY_* switches in capture.rs and pipeline.rs. A build that ships has due() returning true unconditionally: the OnceLock and the env read do not exist there at all.
  2. The check moved out of refresh() into refresh_all, before in_parallel - a texture that is not due this frame is no longer handed to a worker thread. refresh() keeps only its own work.
  3. The trailing newline is back, and the commit is LF-only: git diff --check is clean and the blob starts 2f 2f 21, ends 0a 7d 0a.
  4. Clippy 1.98: % every == 0 became .is_multiple_of(every) (manual_is_multiple_of), and the parse now .filter(|&n| n > 0)s so VICTORY_TEXTURE_REFRESH_EVERY=0 is "every frame" rather than something to reason about. Thanks @kotekompotek and @kais7654 - both of your points are the same two lines.

Checked

  • cargo check -p victory-gpu (default features): ok
  • cargo check -p victory-gpu --profile diag --features diagnostics: ok
  • cargo clippy -p victory-gpu --all-targets --all-features -- -D warnings: 0 warnings
  • cargo test -p victory-gpu --lib --profile diag --features diagnostics: 196 passed, 2 failed, 1 ignored - the 2 are the known #1744 view-heap failures (dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views), which fail on main too on this machine.

The frame-time numbers above come from runs on the title (RTX 4080 SUPER, VICTORY_FAST=1, VICTORY_TEXTURE_STAGE_MB=64), not from a test.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5493233652 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2478). Originally posted by [HoLa-Lee](https://github.com/HoLa-Lee) on 2026-11-25T14:25:26Z. --- ## What this is A world that renders at a frame a second spends most of that frame reading title memory for textures. Measured on one title and machine, on the card, with docs-level counters: **24,821 texture refreshes pulling 24.8 GB of title memory in a single frame, with none of them skipped**, and **6,814 ms of the frame's 7,000 ms of texture work spent waiting for that memory**. The GPU did 71-72 ms in the same frame. `VICTORY_TEXTURE_REFRESH_EVERY=<n>` reads a texture once every n frames at most, round-robin by the texture's own address so the frames share the work instead of one frame taking all of it: ``` fn due(&self) -> bool { // diagnostics only; 0, 1 or unset: every frame every <= 1 || (crate::frame::current() + ((self.memory as usize >> 16) as u64)).is_multiple_of(every) } // refresh_all, before in_parallel: a texture that is not due is not handed to a thread let changed: Vec<usize> = (0..work.len()).filter(|&i| work[i].0.due() && work[i].0.maybe_changed()).collect(); ``` and `refresh()` returns `None` (nothing changed, keep the last upload) on the frames that are not its turn. ## What it buys At `VICTORY_TEXTURE_REFRESH_EVERY=8`, same scene, same captures: **145-522 ms a frame instead of 2,333-6,906 ms** (0.1-0.4 fps to 1.9-6.9 fps), with the picture intact - the same frame numbers captured before and after compare. ## What it costs A texture's contents can lag by up to n frames. Unset, 0 or 1: nothing changes, every frame refreshes exactly as now, so this is inert for anyone who does not ask for it. It is a switch for slow machines and for measuring what the refresh costs, not a claim that every frame should skip reads - the proper fix (refresh only what the frame reads) is a larger change in draw.rs/host.rs. ## Changes since the last review (`a6d6afa`) All four review points are in, in this push (`c8d6571`): 1. **Behind the `diagnostics` feature**, like the other `VICTORY_*` switches in `capture.rs` and `pipeline.rs`. A build that ships has `due()` returning `true` unconditionally: the `OnceLock` and the env read do not exist there at all. 2. **The check moved out of `refresh()` into `refresh_all`, before `in_parallel`** - a texture that is not due this frame is no longer handed to a worker thread. `refresh()` keeps only its own work. 3. **The trailing newline is back**, and the commit is LF-only: `git diff --check` is clean and the blob starts `2f 2f 21`, ends `0a 7d 0a`. 4. **Clippy 1.98**: `% every == 0` became `.is_multiple_of(every)` (`manual_is_multiple_of`), and the parse now `.filter(|&n| n > 0)`s so `VICTORY_TEXTURE_REFRESH_EVERY=0` is "every frame" rather than something to reason about. Thanks @kotekompotek and @kais7654 - both of your points are the same two lines. ## Checked - `cargo check -p victory-gpu` (default features): ok - `cargo check -p victory-gpu --profile diag --features diagnostics`: ok - `cargo clippy -p victory-gpu --all-targets --all-features -- -D warnings`: **0 warnings** - `cargo test -p victory-gpu --lib --profile diag --features diagnostics`: **196 passed, 2 failed, 1 ignored** - the 2 are the known `#1744` view-heap failures (`dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`), which fail on `main` too on this machine. The frame-time numbers above come from runs on the title (RTX 4080 SUPER, `VICTORY_FAST=1`, `VICTORY_TEXTURE_STAGE_MB=64`), not from a test.
DenRakEiw commented 2026-11-25 14:34:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T14:34:24Z.

Review: COMMENTED


Tested against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • cargo test -p victory-gpu texture::tests: 2/2 passed on RTX 5090 and WARP.
  • cargo xtask policy: 183 files ok.
  • Clippy blocker (cargo clippy -p victory-gpu --all-targets -- -D warnings):
    Fails with clippy::manual_is_multiple_of in crates/victory-gpu/src/texture.rs — using (crate::frame::current() + ((self.memory as usize >> 16) as u64)).is_multiple_of(every) will satisfy Rust 1.98 clippy -D warnings.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6059618148 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2478#pullrequestreview-6059618148). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T14:34:24Z. **Review:** COMMENTED --- Tested against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - `cargo test -p victory-gpu texture::tests`: 2/2 passed on RTX 5090 and WARP. - `cargo xtask policy`: 183 files ok. - **Clippy blocker (`cargo clippy -p victory-gpu --all-targets -- -D warnings`):** Fails with `clippy::manual_is_multiple_of` in `crates/victory-gpu/src/texture.rs` — using `(crate::frame::current() + ((self.memory as usize >> 16) as u64)).is_multiple_of(every)` will satisfy Rust 1.98 clippy `-D warnings`. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 14:57:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T14:57:41Z.

Review: COMMENTED


Refresh a texture once every N frames option. Note: this PR introduces a UTF-8 BOM (U+FEFF) at the start of texture.rs — the first line is rewritten with an invisible BOM byte sequence; please drop it, it is noise in every future diff of the file. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.

<!-- greyfinch-sync:Marvisak/VIctory:review:6059997709 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2478#pullrequestreview-6059997709). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T14:57:41Z. **Review:** COMMENTED --- Refresh a texture once every N frames option. **Note: this PR introduces a UTF-8 BOM (U+FEFF) at the start of texture.rs** — the first line is rewritten with an invisible BOM byte sequence; please drop it, it is noise in every future diff of the file. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
Marvisak commented 2026-11-25 17:05:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T16:16:20Z.


Automated triage for the maintainers.

Merge candidate. Staging::due in crates/victory-gpu/src/texture.rs adds VICTORY_TEXTURE_REFRESH_EVERY=N, a diagnostics-only switch. With it set, a texture is re-read from title memory at most once every N frames, with the frames assigned round-robin by the texture's address. Without the feature, or when the variable is unset, 0 or 1, due() returns true and nothing changes.

All three points from the last triage are in c8d6571:

  • the switch is behind #[cfg(feature = "diagnostics")];
  • refresh_all checks due() before in_parallel, so textures that aren't due never reach a worker thread;
  • the file ends with a newline again.

The 0 divide that kotekompotek found is handled by .filter(|&n| n > 0), and the modulo now uses is_multiple_of, as clippy 1.98 wants. On main, refresh_all's only caller is the bindless upload pass in bindless.rs, which only covers copies that already exist. A skipped texture keeps its last upload, and because its tracker isn't cleared, the change is picked up on its next due frame.

Reply to the author: thanks, every point checks out against the code.

CI: not run. The workflow run for c8d6571 is waiting for a maintainer's approval (action_required).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167742669 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2478#issuecomment-7167742669). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T16:16:20Z. --- <!-- victory-triage v1 head=c8d6571db41b66b6e553dc234a5d578d3dee215e verdict=merge-candidate at=2026-11-25T20:18:54Z --> Automated triage for the maintainers. **Merge candidate.** `Staging::due` in `crates/victory-gpu/src/texture.rs` adds `VICTORY_TEXTURE_REFRESH_EVERY=N`, a `diagnostics`-only switch. With it set, a texture is re-read from title memory at most once every N frames, with the frames assigned round-robin by the texture's address. Without the feature, or when the variable is unset, 0 or 1, `due()` returns `true` and nothing changes. All three points from the last triage are in `c8d6571`: - the switch is behind `#[cfg(feature = "diagnostics")]`; - `refresh_all` checks `due()` before `in_parallel`, so textures that aren't due never reach a worker thread; - the file ends with a newline again. The `0` divide that kotekompotek found is handled by `.filter(|&n| n > 0)`, and the modulo now uses `is_multiple_of`, as clippy 1.98 wants. On `main`, `refresh_all`'s only caller is the bindless upload pass in `bindless.rs`, which only covers copies that already exist. A skipped texture keeps its last upload, and because its tracker isn't cleared, the change is picked up on its next due frame. Reply to the author: thanks, every point checks out against the code. CI: not run. The workflow run for `c8d6571` is waiting for a maintainer's approval (`action_required`). --- _Generated by [Claude Code](https://claude.ai/code)_
kotekompotek commented 2026-11-25 17:05:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T16:53:10Z.


The knob is sound as a diagnostic: due() buckets textures by (address >> 16) against frame::current(), so with EVERY=N each texture reads at most once per N frames and the reads spread evenly — exactly what a "world at 1 fps" frame cost needs. Semantics are safe: skipping refresh() leaves the last uploaded copy live, so the worst case is N frames of staleness, never a missing texture.

Two nits: the file lost its trailing newline, and EVERY=0 parses to 0 → % 0 panics — unwrap_or(1) doesn't catch Ok(0). every <= 1 handles 0/1 for the <= 1 check but parse accepts 0 → division by zero in the else branch. Clamp with .filter(|&n| n > 0) or max(1).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7168679037 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2478#issuecomment-7168679037). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T16:53:10Z. --- The knob is sound as a diagnostic: `due()` buckets textures by `(address >> 16)` against `frame::current()`, so with `EVERY=N` each texture reads at most once per N frames and the reads spread evenly — exactly what a "world at 1 fps" frame cost needs. Semantics are safe: skipping `refresh()` leaves the last uploaded copy live, so the worst case is N frames of staleness, never a missing texture. Two nits: the file lost its trailing newline, and `EVERY=0` parses to `0` → `% 0` panics — `unwrap_or(1)` doesn't catch `Ok(0)`. `every <= 1` handles 0/1 for the `<= 1` check but `parse` accepts 0 → division by zero in the else branch. Clamp with `.filter(|&n| n > 0)` or `max(1)`.
kais7654 commented 2026-11-25 18:02:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-25T17:14:56Z.


Tested on Windows 11, RTX 5070 Laptop GPU (driver 616.87) + WARP, rustc
1.98.1, --locked. The CI will fail as-is: clippy -D warnings rejects the
modulo line in crates/victory-gpu/src/texture.rs:555 with
clippy::manual_is_multiple_of (pinned clippy 1.98):

  • every <= 1 || (crate::frame::current() + ((self.memory as usize >> 16) as u64)) % every == 0
  • every <= 1 || (crate::frame::current() + ((self.memory as usize >> 16) as u64)).is_multiple_of(every)

With that one line applied (not committed on my side), the branch is
green: clippy -D warnings clean with and without --all-features,
victory-gpu lib 193 passed / 2 failed (the heap-cap pair #1943 owns),
victory-shader lib 266 passed / 3 failed (the NVIDIA machine trio of
#2317). Merge into current main (67e8ae1) is clean.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169224682 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2478#issuecomment-7169224682). Originally posted by [kais7654](https://github.com/kais7654) on 2026-11-25T17:14:56Z. --- Tested on Windows 11, RTX 5070 Laptop GPU (driver 616.87) + WARP, rustc 1.98.1, --locked. The CI will fail as-is: clippy -D warnings rejects the modulo line in crates/victory-gpu/src/texture.rs:555 with clippy::manual_is_multiple_of (pinned clippy 1.98): - every <= 1 || (crate::frame::current() + ((self.memory as usize >> 16) as u64)) % every == 0 + every <= 1 || (crate::frame::current() + ((self.memory as usize >> 16) as u64)).is_multiple_of(every) With that one line applied (not committed on my side), the branch is green: clippy -D warnings clean with and without --all-features, victory-gpu lib 193 passed / 2 failed (the heap-cap pair #1943 owns), victory-shader lib 266 passed / 3 failed (the NVIDIA machine trio of #2317). Merge into current main (67e8ae1) is clean.
HoLa-Lee commented 2026-11-25 20:06:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by HoLa-Lee on 2026-11-25T19:16:12Z.


Both review comments are in, in c8d6571:

  • @kotekompotek - VICTORY_TEXTURE_REFRESH_EVERY=0 no longer reaches the divide: the parse is .filter(|&n| n > 0).unwrap_or(1), so 0 and 1 both mean "every frame"; the trailing newline is back.
  • @kais7654 - your clippy line is exactly what is committed: .is_multiple_of(every). cargo clippy -p victory-gpu --all-targets --all-features -- -D warnings is 0 warnings on 1.98.1 here, and cargo test -p victory-gpu --lib --profile diag --features diagnostics gives 196 passed / 2 failed (the #1744 view-heap pair, which fails on main on this machine too).

The switch is also behind diagnostics now, and the due check runs in refresh_all before in_parallel, so a texture that is not due is never handed to a thread.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7172061568 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2478#issuecomment-7172061568). Originally posted by [HoLa-Lee](https://github.com/HoLa-Lee) on 2026-11-25T19:16:12Z. --- Both review comments are in, in `c8d6571`: - **@kotekompotek** - `VICTORY_TEXTURE_REFRESH_EVERY=0` no longer reaches the divide: the parse is `.filter(|&n| n > 0).unwrap_or(1)`, so 0 and 1 both mean "every frame"; the trailing newline is back. - **@kais7654** - your clippy line is exactly what is committed: `.is_multiple_of(every)`. `cargo clippy -p victory-gpu --all-targets --all-features -- -D warnings` is 0 warnings on 1.98.1 here, and `cargo test -p victory-gpu --lib --profile diag --features diagnostics` gives 196 passed / 2 failed (the `#1744` view-heap pair, which fails on `main` on this machine too). The switch is also behind `diagnostics` now, and the due check runs in `refresh_all` before `in_parallel`, so a texture that is not due is never handed to a thread.
fuzeofficlal commented 2026-11-26 19:38:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T19:38:11Z.

Review: CHANGES_REQUESTED


Tested c8d6571db41b66b6e553dc234a5d578d3dee215e merged onto origin/main (63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (RTX 5090 + Microsoft WARP, --features diagnostics with VICTORY_D3D12_DEBUG=1, Rust 1.98.1 MSVC).

Default builds (without diagnostics), VICTORY_TEXTURE_REFRESH_EVERY unset / 0 / 1, cargo xtask policy, and cargo clippy --locked -p victory-gpu --all-targets [--all-features] -- -D warnings are all clean.

Blocking Issue: Staging::due() skips the initial upload of newly created and evicted-then-remade textures

Staging::staging() (crates/victory-gpu/src/texture.rs:781-842) does not perform an initial upload — refresh_all() (L519-533) is the only path that detiles and uploads a texture's title memory into its host ID3D12Resource for the first time.

Because Staging::due() (L549-565) checks (crate::frame::current() + ((self.memory as usize >> 16) as u64)).is_multiple_of(every) unconditionally when every > 1, any newly created texture (or texture evicted by resource::evict and later recreated) whose address residue does not match the current frame is skipped on its very first frame (uploads == 0):

  • Committed host textures sample as solid zeros (0x00000000) for up to N - 1 frames (or permanently for one-shot textures).
  • Textures allocated from crate::placement texture heaps do not even start zeroed (as noted at texture.rs:640-641) and sample whatever stale texels previously occupied that heap range until their due frame arrives.

Hardware Repro (--features diagnostics, VICTORY_TEXTURE_REFRESH_EVERY=8)

Created 16 brand-new committed 4x4 DXGI_FORMAT_R8G8B8A8_UNORM textures initialized with 0xDEAD_BEEF in title memory, ran refresh_all(&work) + record_upload, and read back a skipped texture on the GPU:

  • RTX 5090: uploaded_first_frame=0, skipped_first_frame=16; uploads(tex[0]) == 0, GPU readback pixel[0] = 0x00000000 (expected 0xdeadbeef).
  • WARP: uploaded_first_frame=4, skipped_first_frame=12; uploads(tex[1]) == 0, GPU readback pixel[0] = 0x00000000 (expected 0xdeadbeef).

Suggested Fix

Allow the initial upload unconditionally when self.uploads is still 0, and only apply the every-N-frames throttle to subsequent refreshes (crates/victory-gpu/src/texture.rs:560):

if every > 1 && self.uploads.load(std::sync::atomic::Ordering::Relaxed) > 0 {
    return (crate::frame::current() + ((self.memory as usize >> 16) as u64)).is_multiple_of(every);
}

Verified this 1-line fix locally on both RTX 5090 and WARP (--features diagnostics, VICTORY_TEXTURE_REFRESH_EVERY=8):

  • Pass 1 (initial upload): all 16/16 brand-new textures upload immediately (uploads == 1).
  • Pass 2 (after mutating all 16 title memories on the same frame): only textures with (frame + (memory >> 16)).is_multiple_of(8) refresh (actual_due == expected_due: 6/16 on RTX 5090, 0/16 on WARP), keeping the intended steady-state throttling while ensuring no texture is ever sampled uninitialized.
<!-- greyfinch-sync:Marvisak/VIctory:review:6079634181 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2478#pullrequestreview-6079634181). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T19:38:11Z. **Review:** CHANGES_REQUESTED --- Tested `c8d6571db41b66b6e553dc234a5d578d3dee215e` merged onto `origin/main` (`63bcca43c6a00a758510398fa43096ce7e4f7df0`) on Windows 11 x64 (RTX 5090 + Microsoft WARP, `--features diagnostics` with `VICTORY_D3D12_DEBUG=1`, Rust 1.98.1 MSVC). Default builds (without `diagnostics`), `VICTORY_TEXTURE_REFRESH_EVERY` unset / `0` / `1`, `cargo xtask policy`, and `cargo clippy --locked -p victory-gpu --all-targets [--all-features] -- -D warnings` are all clean. ### Blocking Issue: `Staging::due()` skips the initial upload of newly created and evicted-then-remade textures `Staging::staging()` (`crates/victory-gpu/src/texture.rs:781-842`) does not perform an initial upload — `refresh_all()` (`L519-533`) is the only path that detiles and uploads a texture's title memory into its host `ID3D12Resource` for the first time. Because `Staging::due()` (`L549-565`) checks `(crate::frame::current() + ((self.memory as usize >> 16) as u64)).is_multiple_of(every)` unconditionally when `every > 1`, any newly created texture (or texture evicted by `resource::evict` and later recreated) whose address residue does not match the current frame is skipped on its very first frame (`uploads == 0`): - Committed host textures sample as solid zeros (`0x00000000`) for up to `N - 1` frames (or permanently for one-shot textures). - Textures allocated from `crate::placement` texture heaps do not even start zeroed (as noted at `texture.rs:640-641`) and sample whatever stale texels previously occupied that heap range until their due frame arrives. #### Hardware Repro (`--features diagnostics`, `VICTORY_TEXTURE_REFRESH_EVERY=8`) Created 16 brand-new committed `4x4` `DXGI_FORMAT_R8G8B8A8_UNORM` textures initialized with `0xDEAD_BEEF` in title memory, ran `refresh_all(&work)` + `record_upload`, and read back a skipped texture on the GPU: - **RTX 5090**: `uploaded_first_frame=0`, `skipped_first_frame=16`; `uploads(tex[0]) == 0`, GPU readback `pixel[0] = 0x00000000` (expected `0xdeadbeef`). - **WARP**: `uploaded_first_frame=4`, `skipped_first_frame=12`; `uploads(tex[1]) == 0`, GPU readback `pixel[0] = 0x00000000` (expected `0xdeadbeef`). #### Suggested Fix Allow the initial upload unconditionally when `self.uploads` is still `0`, and only apply the every-`N`-frames throttle to subsequent refreshes (`crates/victory-gpu/src/texture.rs:560`): ```rust if every > 1 && self.uploads.load(std::sync::atomic::Ordering::Relaxed) > 0 { return (crate::frame::current() + ((self.memory as usize >> 16) as u64)).is_multiple_of(every); } ``` Verified this 1-line fix locally on both RTX 5090 and WARP (`--features diagnostics`, `VICTORY_TEXTURE_REFRESH_EVERY=8`): - Pass 1 (initial upload): all 16/16 brand-new textures upload immediately (`uploads == 1`). - Pass 2 (after mutating all 16 title memories on the same frame): only textures with `(frame + (memory >> 16)).is_multiple_of(8)` refresh (`actual_due == expected_due`: `6/16` on RTX 5090, `0/16` on WARP), keeping the intended steady-state throttling while ensuring no texture is ever sampled uninitialized.
jordanamr commented 2026-11-28 18:10:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jordanamr on 2026-11-28T18:10:53Z.


The N-frame staleness bound in the description has a counterexample in the diagnostics build at c8d6571. The bindless upload pass constructs its work list from the textures and heaps in this submission. A dirty texture can therefore miss its assigned frame every time it is used.

For example, set VICTORY_TEXTURE_REFRESH_EVERY=4, use a staging address of 0x40000, and submit that texture on frames 1, 5, 9, …, 61 after changing its contents. I checked the predicate for all 16 visits. It admits zero of them, so every visit can sample the old upload. This is a scheduling counterexample, not a gameplay measurement.

Could you track the last successful refresh per staging texture and let an overdue dirty texture refresh on its next use? A regression with the intermittent sequence above would catch this. If exact phase sampling is the intended diagnostic, please document the unbounded staleness for intermittent textures so readers can interpret captures correctly.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7243592492 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2478#issuecomment-7243592492). Originally posted by [jordanamr](https://github.com/jordanamr) on 2026-11-28T18:10:53Z. --- The N-frame staleness bound in the description has a counterexample in the diagnostics build at c8d6571. The bindless upload pass constructs its work list from the textures and heaps in *this submission*. A dirty texture can therefore miss its assigned frame every time it is used. For example, set `VICTORY_TEXTURE_REFRESH_EVERY=4`, use a staging address of `0x40000`, and submit that texture on frames 1, 5, 9, …, 61 after changing its contents. I checked the predicate for all 16 visits. It admits zero of them, so every visit can sample the old upload. This is a scheduling counterexample, not a gameplay measurement. Could you track the last successful refresh per staging texture and let an overdue dirty texture refresh on its next use? A regression with the intermittent sequence above would catch this. If exact phase sampling is the intended diagnostic, please document the unbounded staleness for intermittent textures so readers can interpret captures correctly.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2478:upstream-pr/2478'
git switch 'upstream-pr/2478'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2478'
git switch 'upstream-pr/2478'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2478'
git switch 'upstream-pr/2478'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2478'
git switch 'main'
git merge --squash 'upstream-pr/2478'
git switch 'main'
git merge --ff-only 'upstream-pr/2478'
git switch 'main'
git merge 'upstream-pr/2478'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2476
No description provided.