GPU: refresh heap textures with untracked pages (FIND-17) #3039

Open
leftmove wants to merge 1 commit from upstream-pr/3041 into main
leftmove commented 2026-11-26 04:58:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by leftmove on 2026-11-26T04:58:33Z.


FIND-17, coordinated in Marvisak/VIctory#1633.

A texture can span both tracked and untracked memory. The submission-time refresh used only the tracker's dirty ranges, so once those pages were clean, a late write to the untracked portion could leave the heap texture at its initial zeros.

Include untracked ranges when choosing subresources to refresh. A subresource that touches untracked memory keeps a content hash to avoid another GPU copy when its bytes stay the same. The synthetic regression exercises the heap upload path, samples the resulting host texture, and checks the initial zero, the late write, and the absence of duplicate uploads.

Verification

  • Linux — victory-formats and xtask passed (52 passed, 5 ignored). The staged asset-policy check passed.
  • A temporary Linux harness using the refresh routine with a simulated tracker and staging buffer reproduced the missed write on main and passed with the fix.
  • The victory-gpu tests type-checked for x86_64-pc-windows-gnu in default and diagnostics builds. The native Linux victory-gpu build hits the same Windows-gating errors on main.
  • The D3D12 regression was not executed locally. Windows, WARP, and a compatible GPU were unavailable. The reported gameplay symptom remains unverified.

AI-assisted with Codex. Original finding

<!-- greyfinch-sync:Marvisak/VIctory:issue:6619846184 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3041). Originally posted by [leftmove](https://github.com/leftmove) on 2026-11-26T04:58:33Z. --- FIND-17, coordinated in Marvisak/VIctory#1633. A texture can span both tracked and untracked memory. The submission-time refresh used only the tracker's dirty ranges, so once those pages were clean, a late write to the untracked portion could leave the heap texture at its initial zeros. Include untracked ranges when choosing subresources to refresh. A subresource that touches untracked memory keeps a content hash to avoid another GPU copy when its bytes stay the same. The synthetic regression exercises the heap upload path, samples the resulting host texture, and checks the initial zero, the late write, and the absence of duplicate uploads. ### Verification - Linux — `victory-formats` and `xtask` passed (52 passed, 5 ignored). The staged asset-policy check passed. - A temporary Linux harness using the refresh routine with a simulated tracker and staging buffer reproduced the missed write on `main` and passed with the fix. - The `victory-gpu` tests type-checked for `x86_64-pc-windows-gnu` in default and diagnostics builds. The native Linux `victory-gpu` build hits the same Windows-gating errors on `main`. - The D3D12 regression was not executed locally. Windows, WARP, and a compatible GPU were unavailable. The reported gameplay symptom remains unverified. AI-assisted with Codex. [Original finding](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7160609645)
fuzeofficlal commented 2026-11-26 05:15:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T05:15:12Z.

Review: APPROVED


Code review and Windows GPU verification of ddadc546.

Logic looks sound:

  • watch::track already leaves trackers with non-empty untracked runs without a dirty bit (bit = None), so t.clean() and clean_bit(bit) stay false and refresh_all / bindless always reach refresh_now.
  • t.untracked(start, start + size) clamps runs to [start, start + size), so f - start / e - start cannot underflow.
  • Keeping !has_untracked on the whole-page shortcut ensures a subresource touching untracked memory keeps its content hash even after a tracked write, avoiding redundant uploads on subsequent submissions; and on detile failure, last.hashes[i] is cleared so the next refresh retries.

Tested locally on Windows 11 with both NVIDIA RTX 5090 and D3D12 WARP:

  • cargo test --locked -p victory-gpu --lib a_heap_texture_refreshes_after_a_write_to_its_untracked_page — passed on RTX 5090 and WARP
  • cargo test --locked -p victory-gpu --lib texture::tests:: — 2/2 passed
<!-- greyfinch-sync:Marvisak/VIctory:review:6068892636 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3041#pullrequestreview-6068892636). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T05:15:12Z. **Review:** APPROVED --- Code review and Windows GPU verification of `ddadc546`. Logic looks sound: - `watch::track` already leaves trackers with non-empty `untracked` runs without a dirty bit (`bit = None`), so `t.clean()` and `clean_bit(bit)` stay `false` and `refresh_all` / `bindless` always reach `refresh_now`. - `t.untracked(start, start + size)` clamps runs to `[start, start + size)`, so `f - start` / `e - start` cannot underflow. - Keeping `!has_untracked` on the whole-page shortcut ensures a subresource touching untracked memory keeps its content hash even after a tracked write, avoiding redundant uploads on subsequent submissions; and on `detile` failure, `last.hashes[i]` is cleared so the next refresh retries. Tested locally on Windows 11 with both NVIDIA RTX 5090 and D3D12 WARP: - `cargo test --locked -p victory-gpu --lib a_heap_texture_refreshes_after_a_write_to_its_untracked_page` — passed on RTX 5090 and WARP - `cargo test --locked -p victory-gpu --lib texture::tests::` — 2/2 passed
kotekompotek commented 2026-11-26 05:26:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T05:26:21Z.

Review: APPROVED


Verified: trackers with untracked parts never carry a clean bit (watch.rs), so refresh_now reaches the new path every submission; has_untracked subresources are always hashed rather than taking the owned-dirty-page shortcut — the only detector for writes the tracker cannot see — and the hash is kept across refreshes so unchanged spans still skip. The hardware test's committed-untracked/reserved-tracked split discriminates all four transitions.

<!-- greyfinch-sync:Marvisak/VIctory:review:6068971430 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3041#pullrequestreview-6068971430). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T05:26:21Z. **Review:** APPROVED --- Verified: trackers with untracked parts never carry a clean bit (watch.rs), so `refresh_now` reaches the new path every submission; `has_untracked` subresources are always hashed rather than taking the owned-dirty-page shortcut — the only detector for writes the tracker cannot see — and the hash is kept across refreshes so unchanged spans still skip. The hardware test's committed-untracked/reserved-tracked split discriminates all four transitions.
Marvisak commented 2026-11-26 07:01:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T06:15:49Z.


Automated triage for the maintainers.

I confirmed the bug on main. watch::track_as gives a tracker with untracked parts no dirty bit, so it is never clean(). However, Staging::refresh_now in crates/victory-gpu/src/texture.rs looks only at Tracked::take. A write to the untracked part of a texture that is partly tracked returns no ranges, so the texture is never refreshed. shadow.rs already handles Tracked::untracked, but texture.rs did not.

This PR adds subresources that overlap t.untracked(..) to the refresh set. For those subresources it always decides by the blake3 hash, skipping the "a whole page changed" shortcut, so unchanged bytes are not uploaded again. This is the content-hash behaviour the module doc already describes for untracked memory. I found no other callers affected.

CI: check passing. The new D3D12 test a_heap_texture_refreshes_after_a_write_to_its_untracked_page returns early without a host device, and the author did not run it on Windows. Please run it once on a GPU machine before merging. The reported in-game symptom is also unverified, as the description says.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7184255472 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3041#issuecomment-7184255472). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T06:15:49Z. --- <!-- victory-triage v1 head=ddadc546877a0ac25c0b3ac9a905e9229d226fb7 verdict=merge-candidate at=2026-11-26T06:28:00Z --> Automated triage for the maintainers. I confirmed the bug on `main`. `watch::track_as` gives a tracker with untracked parts no dirty bit, so it is never `clean()`. However, `Staging::refresh_now` in `crates/victory-gpu/src/texture.rs` looks only at `Tracked::take`. A write to the untracked part of a texture that is partly tracked returns no ranges, so the texture is never refreshed. `shadow.rs` already handles `Tracked::untracked`, but `texture.rs` did not. This PR adds subresources that overlap `t.untracked(..)` to the refresh set. For those subresources it always decides by the blake3 hash, skipping the "a whole page changed" shortcut, so unchanged bytes are not uploaded again. This is the content-hash behaviour the module doc already describes for untracked memory. I found no other callers affected. CI: `check` passing. The new D3D12 test `a_heap_texture_refreshes_after_a_write_to_its_untracked_page` returns early without a host device, and the author did not run it on Windows. Please run it once on a GPU machine before merging. The reported in-game symptom is also unverified, as the description says. --- _Generated by [Claude Code](https://claude.ai/code)_
Dukestar69 commented 2026-11-26 08:31:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T08:31:15Z.

Review: APPROVED


Verified on RTX 5090 & WARP against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 21/21 passed on RTX 5090 and WARP (including a_heap_texture_refreshes_after_a_write_to_its_untracked_page).
  • cargo test -p victory-gpu --lib host:: -- --test-threads=1: all host:: tests passed (only pre-existing #1744 descriptor::host::tests::dynamic_slots_are_held_until_released failed).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly ensures heap textures backed by untracked pages are refreshed on CPU writes.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6070734780 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3041#pullrequestreview-6070734780). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T08:31:15Z. **Review:** APPROVED --- Verified on RTX 5090 & WARP against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib draw:: -- --test-threads=1`: 21/21 passed on RTX 5090 and WARP (including `a_heap_texture_refreshes_after_a_write_to_its_untracked_page`). - `cargo test -p victory-gpu --lib host:: -- --test-threads=1`: all `host::` tests passed (only pre-existing `#1744` `descriptor::host::tests::dynamic_slots_are_held_until_released` failed). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly ensures heap textures backed by untracked pages are refreshed on CPU writes. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
leftmove commented 2026-11-26 09:06:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by leftmove on 2026-11-26T08:24:14Z.


Thanks for confirming the bug on main and marking this a merge candidate. Triage review

This Linux machine has no GPU, so I couldn’t run a_heap_texture_refreshes_after_a_write_to_its_untracked_page here. The test returns early without a host device, and the in-game symptom remains unverified. A maintainer or verifier with a Windows GPU machine will need to run the test before merging.

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7186551518 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3041#issuecomment-7186551518). Originally posted by [leftmove](https://github.com/leftmove) on 2026-11-26T08:24:14Z. --- Thanks for confirming the bug on `main` and marking this a merge candidate. [Triage review](https://github.com/Marvisak/VIctory/pull/3041#issuecomment-7184255472) This Linux machine has no GPU, so I couldn’t run `a_heap_texture_refreshes_after_a_write_to_its_untracked_page` here. The test returns early without a host device, and the in-game symptom remains unverified. A maintainer or verifier with a Windows GPU machine will need to run the test before merging. AI-assisted with Codex.
Jackster commented 2026-11-26 16:35:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T16:35:53Z.


Windows 11, Radeon RX 7900 XTX (gfx1100, 32.0.32029.2010), 63bcca4 + this PR. You wrote that Windows, WARP and a compatible GPU were unavailable for the D3D12 regression, so here are all three:

  • draw::tests::a_heap_texture_refreshes_after_a_write_to_its_untracked_page passes on the hardware adapter (0.17 s).
  • The same test passes on WARP (VICTORY_D3D12_WARP=1, diagnostics build, 0.07 s).
  • Control: with the texture.rs half of the patch reverted and the test kept, it fails on the hardware adapter — assertion left == right failed: late write reaches the GPU — so the test does catch the missed refresh, as your Linux harness said it should.
  • cargo test -p victory-gpu --lib on the head: 232 passed / 0 failed / 1 ignored.

The gameplay symptom (FIND-17) is still unverified, as you said; this covers the D3D12 path only. Synthetic only. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7197853297 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3041#issuecomment-7197853297). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T16:35:53Z. --- Windows 11, Radeon RX 7900 XTX (gfx1100, 32.0.32029.2010), `63bcca4` + this PR. You wrote that Windows, WARP and a compatible GPU were unavailable for the D3D12 regression, so here are all three: - `draw::tests::a_heap_texture_refreshes_after_a_write_to_its_untracked_page` **passes on the hardware adapter** (0.17 s). - The same test **passes on WARP** (`VICTORY_D3D12_WARP=1`, diagnostics build, 0.07 s). - Control: with the `texture.rs` half of the patch reverted and the test kept, it fails on the hardware adapter — `assertion left == right failed: late write reaches the GPU` — so the test does catch the missed refresh, as your Linux harness said it should. - `cargo test -p victory-gpu --lib` on the head: 232 passed / 0 failed / 1 ignored. The gameplay symptom (FIND-17) is still unverified, as you said; this covers the D3D12 path only. Synthetic only. AI-assisted.
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/3041:upstream-pr/3041'
git switch 'upstream-pr/3041'

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/3041'
git switch 'upstream-pr/3041'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3041'
git switch 'upstream-pr/3041'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3041'
git switch 'main'
git merge --squash 'upstream-pr/3041'
git switch 'main'
git merge --ff-only 'upstream-pr/3041'
git switch 'main'
git merge 'upstream-pr/3041'
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!3039
No description provided.