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

Closed
Calvix2k wants to merge 1 commit from upstream-pr/2689 into main
Calvix2k commented 2026-11-25 18:15:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T18:15:53Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6610832697 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2689). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T18:15:53Z. --- 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.
upstream-sync closed this pull request 2026-11-25 19:05:57 +00:00
DrDarkDK commented 2026-11-25 19:05:57 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6062765712 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2689#pullrequestreview-6062765712). Originally posted by [DrDarkDK](https://github.com/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.*
Calvix2k commented 2026-11-25 19:06:18 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170861728 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2689#issuecomment-7170861728). Originally posted by [Calvix2k](https://github.com/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.
oni-swr commented 2026-11-25 19:06:21 +00:00 (Migrated from github.com)

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.

  • 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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170976365 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2689#issuecomment-7170976365). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T18:29:21Z. --- **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).
kotekompotek commented 2026-11-25 19:06:26 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171184112 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2689#issuecomment-7171184112). Originally posted by [kotekompotek](https://github.com/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

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