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

Open
github-bot wants to merge 1 commit from github-bot/gh-743 into main AGit
Owner

@⁠AscilCH on GitHub · 2026-11-25 06:09 UTC · original
AscilCH:fix/gpu-texture-through-alias-cache-key-and-eviction → main · +118 −5 · 1 files · 1 commits · open

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

**@⁠AscilCH** on GitHub · 2026-11-25 06:09 UTC · [original](https://github.com/fxceless/victory-fork/pull/743) `AscilCH:fix/gpu-texture-through-alias-cache-key-and-eviction` → `main` · +118 −5 · 1 files · 1 commits · open ### 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.)*
`THROUGH` previously keyed cached `alias()` copy buffers and subresource
footprints only by `placed as usize`, and `forget(resource)` only removed
entries whose key equaled `resource`. When a transient aliased `source`
render target was released and replaced by another texture with different
format, dimensions, or mip count in the same heap memory, `alias(list,
placed, new_source)` hit the stale `THROUGH[placed]` entry, skipped
compatibility checks, and recorded `CopyTextureRegion` using the old
source's footprints.

Key `THROUGH` by `(placed as usize, source as usize)` and retain only
entries where neither `placed` nor `source` equals `resource` in
`forget(resource)`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:50:05 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/743/head:github-bot/gh-743'
git switch 'github-bot/gh-743'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-743'
git switch 'github-bot/gh-743'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-743'
git switch 'github-bot/gh-743'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-743'
git switch 'main'
git merge --squash 'github-bot/gh-743'
git switch 'main'
git merge --ff-only 'github-bot/gh-743'
git switch 'main'
git merge 'github-bot/gh-743'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.