GPU/texture: key THROUGH alias cache by (placed, source) and evict on source release #743

Open
AscilCH wants to merge 1 commit from upstream-pr/743 into main
AscilCH commented 2026-11-25 06:09:37 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T06:09:37Z.


Summary

Fixes a stale alias copy-footprint cache bug in crates/victory-gpu/src/texture.rs:

  • THROUGH previously mapped placed as usize -> Arc<Through>, caching both the intermediate UAV copy buffer and the source texture's D3D12_PLACED_SUBRESOURCE_FOOTPRINT layouts.
  • When the aliased source texture was released, forget(source) only called through.remove(&source), leaving THROUGH[placed] populated. If a different source texture (with different format, dimensions, or mip count) was later aliased in the same heap memory, alias(list, placed, new_source) hit the stale cache entry, bypassed layout compatibility validation, and recorded invalid CopyTextureRegion calls using the old source's footprints.
  • THROUGH is now keyed by (placed as usize, source as usize), and forget(resource) evicts all entries referencing resource as either placed or source.

Verification

  • cargo test -p victory-gpu --locked -- texture::title_memory_tests: 3 passed, 0 failed
  • VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --all-features --locked -- texture::title_memory_tests: 3 passed, 0 failed
  • cargo clippy -p victory-gpu --all-targets --all-features --locked: 0 warnings in texture.rs (pre-existing 8dd30ab warnings in draw.rs:2377 and indirect.rs:1322 untouched)
  • cargo xtask policy: 171 files ok

(AI-assisted; synthetic unit tests only, no game data.)

<!-- greyfinch-sync:fxceless/victory-fork:issue:6598392432 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/743). Originally posted by [AscilCH](https://github.com/AscilCH) on 2026-11-25T06:09:37Z. --- ### Summary Fixes a stale alias copy-footprint cache bug in `crates/victory-gpu/src/texture.rs`: - `THROUGH` previously mapped `placed as usize -> Arc<Through>`, caching both the intermediate UAV copy buffer and the `source` texture's `D3D12_PLACED_SUBRESOURCE_FOOTPRINT` layouts. - When the aliased `source` texture was released, `forget(source)` only called `through.remove(&source)`, leaving `THROUGH[placed]` populated. If a different `source` texture (with different format, dimensions, or mip count) was later aliased in the same heap memory, `alias(list, placed, new_source)` hit the stale cache entry, bypassed layout compatibility validation, and recorded invalid `CopyTextureRegion` calls using the old source's footprints. - `THROUGH` is now keyed by `(placed as usize, source as usize)`, and `forget(resource)` evicts all entries referencing `resource` as either `placed` or `source`. ### Verification - `cargo test -p victory-gpu --locked -- texture::title_memory_tests`: **3 passed, 0 failed** - `VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --all-features --locked -- texture::title_memory_tests`: **3 passed, 0 failed** - `cargo clippy -p victory-gpu --all-targets --all-features --locked`: 0 warnings in `texture.rs` (pre-existing `8dd30ab` warnings in `draw.rs:2377` and `indirect.rs:1322` untouched) - `cargo xtask policy`: `171 files ok` *(AI-assisted; synthetic unit tests only, no game data.)*
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/743:upstream-pr/743'
git switch 'upstream-pr/743'

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