GPU: a texture subresource in untracked memory is uploaded (#2638) #2687
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2689"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T18:15:53Z.
Fixes #2638.
Since
280b150the 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_nowasked onlytakefor changed pages, so sincecc5f961a 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 diagnosticsclean.Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T18:18:53Z.
Review: CHANGES_REQUESTED
ranges.extend(t.untracked(...))also feeds untracked spans into the whole-changed-page shortcut. If a mip contains a full untracked 64 KiB page, that shortcut skips hashing and re-uploads the mip on every refresh, even when its bytes are unchanged. The current test writes new bytes before the second refresh, so it misses this case.#2639 keeps untracked spans separate and uses them only to select candidates for hashing. Could we use that approach here and check that an unchanged refresh of a mip covering a full untracked page returns no upload?
Static review only.
AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T18:24:19Z.
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.
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T18:29:21Z.
Independent verification (review, not a task claim) — covered by the existing claim on #1633.
183e974d0fbf1a64435096584016cc8d199686c2(OPEN, non-draft, merges cleanly; merge-base ==origin/main)origin/main:13f91caee25f2fdf2c062be5f7a27f058e51cbcaVICTORY_WARP=1,VICTORY_D3D12_WARP=1,dxil.dll1.8.2502.11 (Windows Kit 10.0.26100.0 x64), WARP only (physical GPU not used), no game files. Everyvictory-gpurun 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
host()ortrack()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_uploadedFAILED with "the subresource wholly in untracked memory is uploaded" (2 passed, 1 failed). Restored, it passes again.Review notes
takeanduntrackedreturn disjoint ranges, and the latertouchedfilter 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.refresh_nowstill returns early ont.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.AI disclosure: independent verification by Claude Code (Claude Sonnet 5.5).
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T18:38:15Z.
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