GPU: a texture subresource in untracked memory is uploaded (#2638) #2689

Closed
github-bot wants to merge 1 commit from gh-pr/2689/head into gh-pr/2689/base
Owner

@⁠Calvix2k on GitHub · 2026-11-25 18:15 UTC · original
Calvix2k:codex/gpu-texture-untracked → main · +139 −1 · 1 files · 1 commits · closed without merging

Fixes #2638.

Since 280b150 the change tracker leaves untracked any 64 KiB page that touches memory other than the runtime's; such parts are copied whole at each use, and buffer copies follow it (shadow.rs, Tracked::untracked). Staging::refresh_now asked only take for changed pages, so since cc5f961 a subresource whose bytes lie only in untracked pages was never read and never uploaded: its host texture kept its initial zeros, even after the title wrote it.

Read the untracked parts at every refresh too, and let the subresources lying in them through the touched filter. They are detiled and uploaded when their bytes change; only textures touching non-runtime memory pay the read.

The test places a two-mip 128x128 RGBA8 texture 48 KiB into a write-watched page that is followed by a plain one, so mip 1 lies wholly in the plain page. It is uploaded at the first refresh and again after a write; with only the changed pages it is never uploaded (checked by removing the fix).

Tests: cargo test -p victory-gpu --features diagnostics --lib texture:: (3 passed), cargo clippy -p victory-gpu --all-targets --features diagnostics clean.

**@⁠Calvix2k** on GitHub · 2026-11-25 18:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/2689) `Calvix2k:codex/gpu-texture-untracked` → `main` · +139 −1 · 1 files · 1 commits · closed without merging Fixes #2638. Since 280b150 the change tracker leaves untracked any 64 KiB page that touches memory other than the runtime's; such parts are copied whole at each use, and buffer copies follow it (`shadow.rs`, `Tracked::untracked`). `Staging::refresh_now` asked only `take` for changed pages, so since cc5f961 a subresource whose bytes lie only in untracked pages was never read and never uploaded: its host texture kept its initial zeros, even after the title wrote it. Read the untracked parts at every refresh too, and let the subresources lying in them through the touched filter. They are detiled and uploaded when their bytes change; only textures touching non-runtime memory pay the read. The test places a two-mip 128x128 RGBA8 texture 48 KiB into a write-watched page that is followed by a plain one, so mip 1 lies wholly in the plain page. It is uploaded at the first refresh and again after a write; with only the changed pages it is never uploaded (checked by removing the fix). Tests: `cargo test -p victory-gpu --features diagnostics --lib texture::` (3 passed), `cargo clippy -p victory-gpu --all-targets --features diagnostics` clean.
Since 280b150 the change tracker leaves untracked any 64 KiB page that
touches memory other than the runtime's; such parts are copied whole at
each use, and buffer copies follow it (shadow.rs). Staging::refresh_now
asked only `take` for changed pages, so since cc5f961 a subresource whose
bytes lie only in untracked pages was never read and never uploaded: its
host texture kept its initial zeros, even after the title wrote it.

Read the untracked parts at every refresh too, and let the subresources
lying in them through the touched filter. They are detiled and uploaded
when their bytes change; only textures touching non-runtime memory pay
the read.

The test places a two-mip 128x128 RGBA8 texture 48 KiB into a
write-watched page that is followed by a plain one, so mip 1 lies wholly
in the plain page. It is uploaded at the first refresh and again after a
write; with only the changed pages it is never uploaded.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:12:05 +00:00
github-bot closed this pull request 2026-11-26 05:12:05 +00:00
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 18:24 UTC · original

Duplicate of #2639, which takes exactly the approach the review asks for: untracked spans stay separate, select candidates for the per-subresource hash, and only tracked changed pages take the whole-page shortcut (plus the unchanged-refresh test). Closing this in its favour.

**@⁠Calvix2k** on GitHub · 2026-11-25 18:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2689#issuecomment-7170861728) Duplicate of #2639, which takes exactly the approach the review asks for: untracked spans stay separate, select candidates for the per-subresource hash, and only tracked changed pages take the whole-page shortcut (plus the unchanged-refresh test). Closing this in its favour.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 18:29 UTC · original

Independent verification (review, not a task claim) — covered by the existing claim on #1633.

  • PR head: 183e974d0fbf1a64435096584016cc8d199686c2 (OPEN, non-draft, merges cleanly; merge-base == origin/main)
  • origin/main: 13f91caee25f2fdf2c062be5f7a27f058e51cbca
  • Environment: Windows 11, VICTORY_WARP=1, VICTORY_D3D12_WARP=1, dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0 x64), WARP only (physical GPU not used), no game files. Every victory-gpu run used --features diagnostics.

Commands and results

  • cargo test --locked -p victory-gpu --features diagnostics --lib texture:: → 3 passed, 0 failed, 0 ignored (repeated 3 more times, stable).
  • cargo test --locked -p victory-gpu --features diagnostics (full crate) → lib 199 passed, 0 failed, 1 ignored; doc-tests 0.
  • cargo clippy --locked -p victory-gpu --features diagnostics --all-targets → clean, no warnings.

Negative control

  • The new test returns early (silent pass) if host() or track() is unavailable, so I confirmed it really runs: with the one-line fix reverted (ranges.extend(t.untracked(..)) removed) a_subresource_lying_only_in_untracked_memory_is_uploaded FAILED with "the subresource wholly in untracked memory is uploaded" (2 passed, 1 failed). Restored, it passes again.

Review notes

  • The fix is small and consistent with the tracker design: take and untracked return disjoint ranges, and the later touched filter only needs a range overlap, so adding the untracked ranges is safe. Hash-based change detection still keeps unchanged untracked subresources from being re-uploaded.
  • Observation, not verified as a bug: refresh_now still returns early on t.clean() before the untracked ranges are read. A texture that has both tracked pages and untracked pages, with no tracked page changing, would not see a change in the untracked part until a tracked page changes. The test passes, so it does not hit this, and I have not tried to build such a case. It may be worth a follow-up or a comment.
  • The test is somewhat fragile by construction (it hunts for two adjacent free pages, with 8 retries, and skips silently if the host or tracker is unavailable). On this WARP setup it ran every time.

AI disclosure: independent verification by Claude Code (Claude Sonnet 5.5).

**@⁠oni-swr** on GitHub · 2026-11-25 18:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2689#issuecomment-7170976365) **Independent verification (review, not a task claim)** — covered by the existing claim on #1633. - PR head: `183e974d0fbf1a64435096584016cc8d199686c2` (OPEN, non-draft, merges cleanly; merge-base == `origin/main`) - `origin/main`: `13f91caee25f2fdf2c062be5f7a27f058e51cbca` - Environment: Windows 11, `VICTORY_WARP=1`, `VICTORY_D3D12_WARP=1`, `dxil.dll` 1.8.2502.11 (Windows Kit 10.0.26100.0 x64), WARP only (physical GPU not used), no game files. Every `victory-gpu` run used `--features diagnostics`. **Commands and results** - `cargo test --locked -p victory-gpu --features diagnostics --lib texture::` → 3 passed, 0 failed, 0 ignored (repeated 3 more times, stable). - `cargo test --locked -p victory-gpu --features diagnostics` (full crate) → lib 199 passed, 0 failed, 1 ignored; doc-tests 0. - `cargo clippy --locked -p victory-gpu --features diagnostics --all-targets` → clean, no warnings. **Negative control** - The new test returns early (silent pass) if `host()` or `track()` is unavailable, so I confirmed it really runs: with the one-line fix reverted (`ranges.extend(t.untracked(..))` removed) `a_subresource_lying_only_in_untracked_memory_is_uploaded` FAILED with "the subresource wholly in untracked memory is uploaded" (2 passed, 1 failed). Restored, it passes again. **Review notes** - The fix is small and consistent with the tracker design: `take` and `untracked` return disjoint ranges, and the later `touched` filter only needs a range overlap, so adding the untracked ranges is safe. Hash-based change detection still keeps unchanged untracked subresources from being re-uploaded. - Observation, not verified as a bug: `refresh_now` still returns early on `t.clean()` before the untracked ranges are read. A texture that has both tracked pages and untracked pages, with no tracked page changing, would not see a change in the untracked part until a tracked page changes. The test passes, so it does not hit this, and I have not tried to build such a case. It may be worth a follow-up or a comment. - The test is somewhat fragile by construction (it hunts for two adjacent free pages, with 8 retries, and skips silently if the host or tracker is unavailable). On this WARP setup it ran every time. AI disclosure: independent verification by Claude Code (Claude Sonnet 5.5).
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 18:38 UTC · original

Root cause matches the history: take() yields only changed tracked pages, so a subresource wholly inside pages the tracker declines (touching non-runtime memory) was never read. Extending with untracked() is the narrow fix - refresh still costs only for textures that actually touch such memory. The two-page fixture (watched + plain, mip 1 fully in the plain one) reproduces the exact geometry that slipped through, and the remove-the-fix check proves the test isn't vacuous.

**@⁠kotekompotek** on GitHub · 2026-11-25 18:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2689#issuecomment-7171184112) Root cause matches the history: take() yields only changed tracked pages, so a subresource wholly inside pages the tracker declines (touching non-runtime memory) was never read. Extending with untracked() is the narrow fix - refresh still costs only for textures that actually touch such memory. The two-page fixture (watched + plain, mip 1 fully in the plain one) reproduces the exact geometry that slipped through, and the remove-the-fix check proves the test isn't vacuous.

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!2689
No description provided.