GPU: cache alias-copy footprint plans #1888

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

@⁠nathanbzrr on GitHub · 2026-11-25 00:06 UTC · original
nathanbzrr:gpu/alias-copy-pool → main · +699 −39 · 1 files · 1 commits · open

Summary

  • Trimmed per triage to footprint plan caching only (removed AliasScratch / ALIAS_SCRATCH scratch buffer retention so zero GPU memory is retained between copies).
  • Cache D3D12_RESOURCE_DESC copyable footprint plans in a bounded mutex-guarded AliasPlanCache (ALIAS_PLANS, cap 256 entries) keyed by (desc_key(da), desc_key(db)), storing Option<Arc<AliasPlan>> (crates/victory-gpu/src/texture.rs). Compatible and incompatible (n == 0 / total == 0) pairs skip repeated GetCopyableFootprints COM calls and Vec allocations without holding the mutex across COM calls.
  • Keep alias_copy_in allocating a per-copy DEFAULT-heap buffer via host.default_buffer(plan.total) and holding it in list.keep(&buffer) as on main.
  • Add unit and D3D12 GPU tests in crates/victory-gpu/src/texture.rs: subresource_len_stays_inside_staging_total, committed_rejects_overflow_and_noaccess_pages, alias_plan_caches_compatible_and_incompatible_pairs, footprint_span_computes_exact_subresource_byte_extent, and alias_copy_caches_plans_and_copies_bytes (R32_UINT -> R8G8B8A8_UNORM and R32G32_UINT -> BC1_UNORM across lists/submissions with plan cache reuse and D3D12 debug layer check).

Verification

All checks ran after the final edit (f6323bc):

  • cargo run -p xtask --locked -- policy: asset policy: 191 files ok
  • cargo clippy --workspace --all-targets --locked -- -D warnings: passed (0 warnings)
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed (0 warnings)
  • cargo test -p victory-gpu --lib --locked texture::tests -- --test-threads=1 (AMD Radeon RX 7600): 5 passed; 0 failed
  • VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked texture::tests -- --test-threads=1 (AMD Radeon RX 7600 + D3D12 Debug): 5 passed; 0 failed
  • VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked texture::tests -- --test-threads=1 (WARP + D3D12 Debug): 5 passed; 0 failed

AI-assisted; synthetic tests only, no game files.

**@⁠nathanbzrr** on GitHub · 2026-11-25 00:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/1888) `nathanbzrr:gpu/alias-copy-pool` → `main` · +699 −39 · 1 files · 1 commits · open ## Summary - Trimmed per triage to **footprint plan caching only** (removed `AliasScratch` / `ALIAS_SCRATCH` scratch buffer retention so zero GPU memory is retained between copies). - Cache `D3D12_RESOURCE_DESC` copyable footprint plans in a bounded mutex-guarded `AliasPlanCache` (`ALIAS_PLANS`, cap `256` entries) keyed by `(desc_key(da), desc_key(db))`, storing `Option<Arc<AliasPlan>>` (`crates/victory-gpu/src/texture.rs`). Compatible and incompatible (`n == 0` / `total == 0`) pairs skip repeated `GetCopyableFootprints` COM calls and `Vec` allocations without holding the mutex across COM calls. - Keep `alias_copy_in` allocating a per-copy `DEFAULT`-heap buffer via `host.default_buffer(plan.total)` and holding it in `list.keep(&buffer)` as on `main`. - Add unit and D3D12 GPU tests in `crates/victory-gpu/src/texture.rs`: `subresource_len_stays_inside_staging_total`, `committed_rejects_overflow_and_noaccess_pages`, `alias_plan_caches_compatible_and_incompatible_pairs`, `footprint_span_computes_exact_subresource_byte_extent`, and `alias_copy_caches_plans_and_copies_bytes` (`R32_UINT -> R8G8B8A8_UNORM` and `R32G32_UINT -> BC1_UNORM` across lists/submissions with plan cache reuse and D3D12 debug layer check). ## Verification All checks ran after the final edit (`f6323bc`): - `cargo run -p xtask --locked -- policy`: `asset policy: 191 files ok` - `cargo clippy --workspace --all-targets --locked -- -D warnings`: passed (0 warnings) - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passed (0 warnings) - `cargo test -p victory-gpu --lib --locked texture::tests -- --test-threads=1` (AMD Radeon RX 7600): `5 passed; 0 failed` - `VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked texture::tests -- --test-threads=1` (AMD Radeon RX 7600 + D3D12 Debug): `5 passed; 0 failed` - `VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked texture::tests -- --test-threads=1` (WARP + D3D12 Debug): `5 passed; 0 failed` AI-assisted; synthetic tests only, no game files.
Cache `GetCopyableFootprints` plans (up to 256 pairs, including incompatible pairs) and replace per-copy `Host::default_buffer` allocations with a single grow-only power-of-two shared scratch buffer (`AliasScratch`) serialized by the host single queue.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:47:43 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:37 UTC · original · edited 2026-11-26 08:25 UTC

Automated triage for the maintainers.

Merge candidate (recommend a look). f6323bc takes the second option from the last triage: the plan cache alone, with no GPU memory kept between copies. In crates/victory-gpu/src/texture.rs, alias_copy asks AliasPlanCache::get_or_compute for the pair's footprints. The cache holds up to 256 (desc, desc) pairs, is cleared when full, caches incompatible pairs as None, and does not hold its lock across GetCopyableFootprints. Each copy still makes its own default_buffer and list.keeps it, as on main.

What I checked:

  • DescKey covers every D3D12_RESOURCE_DESC field that affects footprints except Alignment, which GetCopyableFootprints does not use.
  • The subresource match in compute_alias_plan is main's, plus guards for the u64::MAX/u32::MAX failure values.
  • The scratch buffer is now sized to the furthest byte of the subresources actually copied (footprint_span), not to da's whole total. That is smaller or equal, and still covers both copies.

For the maintainer: what this saves is two GetCopyableFootprints calls and their Vecs per alias copy, on the CPU. The in-world run in the thread found no measurable difference. It is correct and small in production code (about 200 lines, plus about 480 lines of tests), but the gain is unmeasured.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/1888#issuecomment-7149768374) · edited 2026-11-26 08:25 UTC <!-- victory-triage v1 head=f6323bcc3c182de59a901629f536ea12312bc264 verdict=merge-candidate at=2026-11-26T08:20:18Z --> Automated triage for the maintainers. **Merge candidate (recommend a look).** `f6323bc` takes the second option from the last triage: the plan cache alone, with no GPU memory kept between copies. In `crates/victory-gpu/src/texture.rs`, `alias_copy` asks `AliasPlanCache::get_or_compute` for the pair's footprints. The cache holds up to 256 `(desc, desc)` pairs, is cleared when full, caches incompatible pairs as `None`, and does not hold its lock across `GetCopyableFootprints`. Each copy still makes its own `default_buffer` and `list.keep`s it, as on `main`. What I checked: - `DescKey` covers every `D3D12_RESOURCE_DESC` field that affects footprints except `Alignment`, which `GetCopyableFootprints` does not use. - The subresource match in `compute_alias_plan` is `main`'s, plus guards for the `u64::MAX`/`u32::MAX` failure values. - The scratch buffer is now sized to the furthest byte of the subresources actually copied (`footprint_span`), not to `da`'s whole total. That is smaller or equal, and still covers both copies. For the maintainer: what this saves is two `GetCopyableFootprints` calls and their `Vec`s per alias copy, on the CPU. The in-world run in the thread found no measurable difference. It is correct and small in production code (about 200 lines, plus about 480 lines of tests), but the gain is unmeasured. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠nathanbzrr on GitHub · 2026-11-25 03:06 UTC · original

Rebased onto origin/main (940d32f, new head c2f3417), resolving the merge conflict in crates/victory-gpu/src/texture.rs:

  • Preserved upstream PR #1658's #[cfg(test)] mod tests (subresource_len_stays_inside_staging_total and committed_rejects_overflow_and_noaccess_pages) alongside #1888's alias-copy helpers and tests in a single mod tests block.

Re-verified on c2f3417 (Windows MSVC):

  • cargo run -p xtask -- policy --staged: asset policy: 1 files ok
  • cargo clippy --workspace --all-targets -- -D warnings & --all-features: clean
  • cargo test -p victory-gpu --locked texture (default & --all-features): 12 passed, 0 failed, 1 ignored
  • cargo test --workspace --locked: 0 failures across all workspace crates (CI check also green)
**@⁠nathanbzrr** on GitHub · 2026-11-25 03:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/1888#issuecomment-7151593158) Rebased onto `origin/main` (`940d32f`, new head `c2f3417`), resolving the merge conflict in `crates/victory-gpu/src/texture.rs`: - Preserved upstream PR #1658's `#[cfg(test)] mod tests` (`subresource_len_stays_inside_staging_total` and `committed_rejects_overflow_and_noaccess_pages`) alongside #1888's alias-copy helpers and tests in a single `mod tests` block. Re-verified on `c2f3417` (Windows MSVC): - `cargo run -p xtask -- policy --staged`: `asset policy: 1 files ok` - `cargo clippy --workspace --all-targets -- -D warnings` & `--all-features`: clean - `cargo test -p victory-gpu --locked texture` (default & `--all-features`): 12 passed, 0 failed, 1 ignored - `cargo test --workspace --locked`: 0 failures across all workspace crates (CI `check` also green)
Author
Owner

@⁠nathanbzrr on GitHub · 2026-11-25 04:04 UTC · original

Addressed the two triage items on gpu/alias-copy-pool (rebased on origin/main 940d32f, new head 2054d42):

1. Byte-bounded pool + idle TTL (#1633 host memory)

  • Replaced the 32-buffer count cap in crates/victory-gpu/src/texture.rs with a 16 MiB total retained byte cap (ALIAS_BUFFER_POOL_MAX_BYTES = 16 * 1024 * 1024) using LRU eviction (last_used) whenever returning a buffer would exceed the budget.
  • Scratch buffers larger than 16 MiB are never pooled on drop (matching main's immediate release once the list resets).
  • Added a 5 s idle TTL (ALIAS_BUFFER_IDLE_TTL) checked on acquire/release and swept on Host's 1 s frame tick via trim_idle_alias_buffers() in crates/victory-gpu/src/host.rs, dropping expired COM resources outside the pool mutex so unused buffers return to D3D12 instead of lingering for the process lifetime.
  • Added pooled_alias_buffer_enforces_byte_budget_lru_and_idle_ttl covering total-byte LRU eviction, oversized-buffer bypass, and deterministic TTL expiration.

2. Tightened diff + synthetic D3D12 benchmark

  • Reverted formatting-only churn in alias_copy_in back to main's compact layout (non-test production diff across texture.rs and host.rs is ~300 lines; the remaining diff is unit/GPU tests and the benchmark).
  • Added texture::tests::bench_alias_copy_uncached_vs_pooled (#[ignore]) comparing main's uncached path (GetCopyableFootprints + Host::default_buffer + list.keep per copy) against cached plan + pooled buffer over 200 copies on this host's D3D12 device (cargo test --release -p victory-gpu --lib texture::tests::bench_alias_copy_uncached_vs_pooled -- --ignored --nocapture):
    • 64x64 R32_UINT->RGBA8: uncached 150.37 ms (751.8 us/copy, footprints=400, default_buffer=200) vs pooled 2.43 ms (12.2 us/copy, footprints=2, default_buffer=1) — 61.81x
    • 1024x1024 R32_UINT->RGBA8: uncached 192.57 ms (962.9 us/copy, footprints=400, default_buffer=200) vs pooled 2.45 ms (12.3 us/copy, footprints=2, default_buffer=1) — 78.52x
    • 512x512 R32G32_UINT->BC1: uncached 156.62 ms (783.1 us/copy, footprints=400, default_buffer=200) vs pooled 2.18 ms (10.9 us/copy, footprints=2, default_buffer=1) — 71.90x
  • Note: this environment has no local game files (per asset policy), so an in-game ALIAS_COPIES/frame and frame-time measurement on a real title run remains open for someone with the title.

Verification (2054d42, Windows MSVC)

  • cargo run -p xtask -- policy --staged: passed (2 files ok)
  • cargo clippy --workspace --all-targets --locked -- -D warnings & --all-features: clean
  • cargo test -p victory-gpu --locked texture (default & --all-features): 13 passed, 0 failed, 2 ignored
  • VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --locked texture -- --test-threads=1: 13 passed, 0 failed, 2 ignored
  • cargo test --workspace --locked: all workspace crates passed (0 failures; victory-gpu: 148 passed, 0 failed, 3 ignored)
**@⁠nathanbzrr** on GitHub · 2026-11-25 04:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/1888#issuecomment-7152510116) Addressed the two triage items on `gpu/alias-copy-pool` (rebased on `origin/main` `940d32f`, new head `2054d42`): ### 1. Byte-bounded pool + idle TTL (#1633 host memory) - Replaced the 32-buffer count cap in `crates/victory-gpu/src/texture.rs` with a **16 MiB total retained byte cap** (`ALIAS_BUFFER_POOL_MAX_BYTES = 16 * 1024 * 1024`) using LRU eviction (`last_used`) whenever returning a buffer would exceed the budget. - Scratch buffers larger than 16 MiB are never pooled on drop (matching `main`'s immediate release once the list resets). - Added a **5 s idle TTL** (`ALIAS_BUFFER_IDLE_TTL`) checked on `acquire`/`release` and swept on `Host`'s 1 s frame tick via `trim_idle_alias_buffers()` in `crates/victory-gpu/src/host.rs`, dropping expired COM resources outside the pool mutex so unused buffers return to D3D12 instead of lingering for the process lifetime. - Added `pooled_alias_buffer_enforces_byte_budget_lru_and_idle_ttl` covering total-byte LRU eviction, oversized-buffer bypass, and deterministic TTL expiration. ### 2. Tightened diff + synthetic D3D12 benchmark - Reverted formatting-only churn in `alias_copy_in` back to `main`'s compact layout (non-test production diff across `texture.rs` and `host.rs` is ~300 lines; the remaining diff is unit/GPU tests and the benchmark). - Added `texture::tests::bench_alias_copy_uncached_vs_pooled` (`#[ignore]`) comparing `main`'s uncached path (`GetCopyableFootprints` + `Host::default_buffer` + `list.keep` per copy) against cached plan + pooled buffer over 200 copies on this host's D3D12 device (`cargo test --release -p victory-gpu --lib texture::tests::bench_alias_copy_uncached_vs_pooled -- --ignored --nocapture`): - `64x64 R32_UINT->RGBA8`: uncached `150.37 ms` (`751.8 us/copy`, `footprints=400`, `default_buffer=200`) vs pooled `2.43 ms` (`12.2 us/copy`, `footprints=2`, `default_buffer=1`) — **61.81x** - `1024x1024 R32_UINT->RGBA8`: uncached `192.57 ms` (`962.9 us/copy`, `footprints=400`, `default_buffer=200`) vs pooled `2.45 ms` (`12.3 us/copy`, `footprints=2`, `default_buffer=1`) — **78.52x** - `512x512 R32G32_UINT->BC1`: uncached `156.62 ms` (`783.1 us/copy`, `footprints=400`, `default_buffer=200`) vs pooled `2.18 ms` (`10.9 us/copy`, `footprints=2`, `default_buffer=1`) — **71.90x** - Note: this environment has no local game files (per asset policy), so an in-game `ALIAS_COPIES`/frame and frame-time measurement on a real title run remains open for someone with the title. ### Verification (`2054d42`, Windows MSVC) - `cargo run -p xtask -- policy --staged`: passed (2 files ok) - `cargo clippy --workspace --all-targets --locked -- -D warnings` & `--all-features`: clean - `cargo test -p victory-gpu --locked texture` (default & `--all-features`): 13 passed, 0 failed, 2 ignored - `VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --locked texture -- --test-threads=1`: 13 passed, 0 failed, 2 ignored - `cargo test --workspace --locked`: all workspace crates passed (0 failures; `victory-gpu`: 148 passed, 0 failed, 3 ignored)
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 06:05 UTC · original

Ran this in the game: Grand Theft Auto VI in the world, RTX 5080, Linux, proton-cachyos 11.0 with vkd3d-proton 3.2.0. I compared main plus a few NVIDIA/Wine fixes with and without this PR, back to back.

  • No regression found. Some lights in the world flicker, but they do so without this PR too after the prologue, so it isn't this change.
  • Savings not clearly measurable here: I counted Host::default_buffer calls from texture.rs with a diagnostics counter. In the world it was about 46–62 new buffers per second with the PR and about 44–84 without it. The ranges overlap and move with the scene, so I can't say how much the pool catches in this world. If it helps, I can rerun with a counter of pool hits and misses (cap reached vs size rule).
**@⁠desplmfao** on GitHub · 2026-11-25 06:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/1888#issuecomment-7154434935) Ran this in the game: Grand Theft Auto VI in the world, RTX 5080, Linux, proton-cachyos 11.0 with vkd3d-proton 3.2.0. I compared `main` plus a few NVIDIA/Wine fixes with and without this PR, back to back. - **No regression found.** Some lights in the world flicker, but they do so without this PR too after the prologue, so it isn't this change. - **Savings not clearly measurable here:** I counted `Host::default_buffer` calls from `texture.rs` with a diagnostics counter. In the world it was about 46–62 new buffers per second with the PR and about 44–84 without it. The ranges overlap and move with the scene, so I can't say how much the pool catches in this world. If it helps, I can rerun with a counter of pool hits and misses (cap reached vs size rule).
Author
Owner

@⁠nathanbzrr on GitHub · 2026-11-25 21:57 UTC · original

Rebased onto origin/main (61bfc77, new head bf6787e), resolving the merge conflicts in crates/victory-gpu/src/texture.rs:

  • Updated alias_copy_in and alias_copy_copies_bytes_and_reuses_pooled_buffer_across_submissions (and bench_alias_copy_uncached_vs_pooled) for upstream changes: host_writes tracking (f68442f) and owned ID3D12Resource returned from host_resource (69d1e8e).

@⁠desplmfao Thank you for benchmarking this in-world on GTA VI / RTX 5080! If you happen to run another comparison, a breakdown of alias-copy pool hits vs. misses (empty pool / size-ratio mismatch / >16 MiB bypass / idle-TTL eviction) would be super helpful to see whether the pool sees hits or if most allocations in texture.rs come from non-alias Host::default_buffer paths.

Verification (bf6787e)

  • cargo run -p xtask -- policy -> 186 files ok
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings & --all-features -> clean
  • cargo test -p victory-gpu --lib --locked -- texture::tests --test-threads=1 -> 7 passed; 0 failed; 1 ignored
  • VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked -- texture::tests --test-threads=1 -> 7 passed; 0 failed; 1 ignored
**@⁠nathanbzrr** on GitHub · 2026-11-25 21:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/1888#issuecomment-7175765697) Rebased onto `origin/main` (`61bfc77`, new head `bf6787e`), resolving the merge conflicts in `crates/victory-gpu/src/texture.rs`: - Updated `alias_copy_in` and `alias_copy_copies_bytes_and_reuses_pooled_buffer_across_submissions` (and `bench_alias_copy_uncached_vs_pooled`) for upstream changes: `host_writes` tracking (`f68442f`) and owned `ID3D12Resource` returned from `host_resource` (`69d1e8e`). @⁠desplmfao Thank you for benchmarking this in-world on GTA VI / RTX 5080! If you happen to run another comparison, a breakdown of alias-copy pool hits vs. misses (empty pool / size-ratio mismatch / >16 MiB bypass / idle-TTL eviction) would be super helpful to see whether the pool sees hits or if most allocations in `texture.rs` come from non-alias `Host::default_buffer` paths. ### Verification (`bf6787e`) - `cargo run -p xtask -- policy` -> `186 files ok` - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` & `--all-features` -> clean - `cargo test -p victory-gpu --lib --locked -- texture::tests --test-threads=1` -> `7 passed; 0 failed; 1 ignored` - `VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked -- texture::tests --test-threads=1` -> `7 passed; 0 failed; 1 ignored`
github-bot changed title from GPU: cache alias-copy footprint plans and pool temporary copy buffers to GPU: cache alias-copy footprint plans 2026-11-26 08:07:11 +00:00
github-bot force-pushed github-bot/gh-1888 from ba86b66389 to f6323bcc3c 2026-11-26 08:07:11 +00:00 Compare
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 00:32 UTC · original · reviewed

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Alias-copy footprint plans cached + temporary copy buffers pooled: allocation caching on the copy path.

**@⁠catminou4** on GitHub · 2026-11-25 00:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1888#pullrequestreview-6049697210) · **reviewed** Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Alias-copy footprint plans cached + temporary copy buffers pooled: allocation caching on the copy path.
Author
Owner

@⁠nathanbzrr on GitHub · 2026-11-26 07:48 UTC · original

Updated f6323bc onto main (63bcca4) and reduced this PR to AliasPlanCache alone as suggested during triage:

  • Removed AliasScratch / ALIAS_SCRATCH so zero GPU scratch memory is retained between copies (alias_copy_in uses per-copy host.default_buffer(plan.total) + list.keep(&buffer) as on main).
  • Updated the PR title and description accordingly.

Re-verified after the final edit on Windows 11 / AMD Radeon RX 7600 and WARP:

  • cargo run -p xtask --locked -- policy: 191 files ok
  • cargo clippy --workspace --all-targets --locked -- -D warnings (default & --all-features): clean
  • cargo test -p victory-gpu --lib --locked texture::tests -- --test-threads=1 (RX 7600): 5 passed; 0 failed
  • VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked texture::tests -- --test-threads=1 (RX 7600 + Debug): 5 passed; 0 failed
  • VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked texture::tests -- --test-threads=1 (WARP + Debug): 5 passed; 0 failed

AI-assisted; synthetic tests only, no game files.

**@⁠nathanbzrr** on GitHub · 2026-11-26 07:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/1888#issuecomment-7185856072) Updated `f6323bc` onto `main` (`63bcca4`) and reduced this PR to **`AliasPlanCache` alone** as suggested during triage: - Removed `AliasScratch` / `ALIAS_SCRATCH` so zero GPU scratch memory is retained between copies (`alias_copy_in` uses per-copy `host.default_buffer(plan.total)` + `list.keep(&buffer)` as on `main`). - Updated the PR title and description accordingly. Re-verified after the final edit on Windows 11 / AMD Radeon RX 7600 and WARP: - `cargo run -p xtask --locked -- policy`: `191 files ok` - `cargo clippy --workspace --all-targets --locked -- -D warnings` (default & `--all-features`): clean - `cargo test -p victory-gpu --lib --locked texture::tests -- --test-threads=1` (RX 7600): `5 passed; 0 failed` - `VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked texture::tests -- --test-threads=1` (RX 7600 + Debug): `5 passed; 0 failed` - `VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked texture::tests -- --test-threads=1` (WARP + Debug): `5 passed; 0 failed` AI-assisted; synthetic tests only, no game files.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 11:39 UTC · original · approved these changes

Reviewed f6323bcc. Trimming the PR down to AliasPlanCache alone is clean and self-contained:

  • DescKey captures every D3D12_RESOURCE_DESC field that affects GetCopyableFootprints, the cache is bounded (256 entries), caches both compatible plans and incompatible (None) pairs, and never holds its mutex across COM calls.
  • compute_alias_plan preserves main's subresource compatibility check while guarding u64::MAX/u32::MAX failure sentinels, and footprint_span computes the exact max byte extent across both fa and fb for the n copied subresources.
  • alias_copy_in retains main's per-copy host.default_buffer(plan.total) + list.keep(&buffer) lifetime (zero GPU memory retained between copies) and increments ALIAS_COPIES only when a copy is actually recorded.

Verified locally on Windows 11 with RTX 5090 and WARP (VICTORY_D3D12_WARP=1) under VICTORY_D3D12_DEBUG=1:

  • cargo xtask policy (191 files ok) and cargo clippy -p victory-gpu --tests -- -D warnings (default and --all-features): clean.
  • RTX 5090 (default): texture::tests 5/5, draw::tests 20/20 passed.
  • RTX 5090 + VICTORY_D3D12_DEBUG=1 (--features diagnostics): texture::tests 5/5 passed with zero Debug Layer errors.
  • WARP + VICTORY_D3D12_DEBUG=1 (--features diagnostics): texture::tests 5/5 passed with zero Debug Layer errors.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 11:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/1888#pullrequestreview-6073508023) · **approved these changes** Reviewed `f6323bcc`. Trimming the PR down to `AliasPlanCache` alone is clean and self-contained: - `DescKey` captures every `D3D12_RESOURCE_DESC` field that affects `GetCopyableFootprints`, the cache is bounded (`256` entries), caches both compatible plans and incompatible (`None`) pairs, and never holds its mutex across COM calls. - `compute_alias_plan` preserves `main`'s subresource compatibility check while guarding `u64::MAX`/`u32::MAX` failure sentinels, and `footprint_span` computes the exact max byte extent across both `fa` and `fb` for the `n` copied subresources. - `alias_copy_in` retains `main`'s per-copy `host.default_buffer(plan.total)` + `list.keep(&buffer)` lifetime (zero GPU memory retained between copies) and increments `ALIAS_COPIES` only when a copy is actually recorded. Verified locally on Windows 11 with RTX 5090 and WARP (`VICTORY_D3D12_WARP=1`) under `VICTORY_D3D12_DEBUG=1`: - `cargo xtask policy` (`191 files ok`) and `cargo clippy -p victory-gpu --tests -- -D warnings` (default and `--all-features`): clean. - RTX 5090 (default): `texture::tests` 5/5, `draw::tests` 20/20 passed. - RTX 5090 + `VICTORY_D3D12_DEBUG=1` (`--features diagnostics`): `texture::tests` 5/5 passed with zero Debug Layer errors. - WARP + `VICTORY_D3D12_DEBUG=1` (`--features diagnostics`): `texture::tests` 5/5 passed with zero Debug Layer errors.
This pull request can be merged automatically.
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/1888/head:github-bot/gh-1888'
git switch 'github-bot/gh-1888'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1888'
git switch 'github-bot/gh-1888'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1888'
git switch 'github-bot/gh-1888'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1888'
git switch 'main'
git merge --squash 'github-bot/gh-1888'
git switch 'main'
git merge --ff-only 'github-bot/gh-1888'
git switch 'main'
git merge 'github-bot/gh-1888'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1888
No description provided.