perf(victory-gpu): opt-in budget-aware mip-tail clamping (default OFF) #555

Open
Vladimir-Human wants to merge 1 commit from upstream-pr/555 into main
Vladimir-Human commented 2026-11-27 21:40:49 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-27T21:40:49Z.


Summary

Opt-in (VICTORY_TEXTURE_AUTO_MIP_CLAMP=1, default OFF) budget-aware host mip-tail clamping rebased onto main (132da61, #563 + #564), ported from fxceless/victory-fork and avatarmanz/VIctory-7900XTX.

Default-OFF Parity & Scope

  • texture::staging() leaves the default path (VICTORY_TEXTURE_AUTO_MIP_CLAMP unset/0) identical to main: the extra shape predicate, clamp_host_size comparison, and keep-newer staging branch only run when texture_mip_clamp::enabled() is true (covered by texture::staging_tests). copy.tiled.is_some() and VICTORY_GPU_DETILE routing match 132da61.
  • Preserves #564 slot eviction, bindless feedback eviction, and allocation retry paths.

Known Limitations (Lossy by Design)

  • Shader-visible lossy mode: Raising the host mip base (level0 > 0) and rebasing the SRV (MostDetailedMip, MipLevels, ResourceMinLODClamp) alters what shaders observe in explicit Load(.., mip), GetDimensions, and texel-size math when VICTORY_TEXTURE_AUTO_MIP_CLAMP=1 is enabled.
  • Unclamped rebind & dynamic descriptor snapshots: rebind_unclamped updates static/mirrored descriptor slots when a staging copy later uploads wider mip ranges, but intentionally skips dynamic-table snapshots — recorded but unsubmitted command lists may retain descriptors referencing the displaced host resource, relying on host::retire keeping the displaced resource alive until its GPU fences complete.

Verification

Verified locally on Windows 11 (third_party/victory workspace) after the final edit:

  • cargo xtask policy (381 files ok)
  • Hunk-accurate cargo clippy --no-deps -p victory-gpu --locked --all-targets (default & --features diagnostics: 0 errors, 0 own warnings)
  • Both HW (VICTORY_D3D12_WARP=0) and WARP (VICTORY_D3D12_WARP=1, with VICTORY_TEXTURE_AUTO_MIP_CLAMP unset):
    • texture::staging_tests: 2/2 passed
    • resource::texture_mip_clamp::tests: 5/5 passed
    • descriptor::host::mip_clamp_tests: 1/1 passed
    • texture::detile_fallback_tests: 2/2 passed (both default and VICTORY_GPU_DETILE=1)
    • resource::tests::slot_eviction: 2/2 passed
    • resource::tests::refused_texture_allocation_has_one_retry: 1/1 passed
  • In-game FPS/VRAM gain: unmeasured (assumed).

Checklist

  • Neutral naming (0 game, character, or console strings)
  • Rule 10 credits (Source: / Co-authored-by: trailers + THIRD_PARTY.md row; ported from fxceless/victory-fork & avatarmanz/VIctory-7900XTX)
  • Opt-in default OFF (VICTORY_TEXTURE_AUTO_MIP_CLAMP=1 required to activate)
  • Documented lossy SRV trade-off and rebind_unclamped dynamic-snapshot lifetime
  • In-game A/B benchmark (unmeasured)
<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:5533428661 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/555). Originally posted by [Vladimir-Human](https://github.com/Vladimir-Human) on 2026-11-27T21:40:49Z. --- ## Summary Opt-in (`VICTORY_TEXTURE_AUTO_MIP_CLAMP=1`, **default OFF**) budget-aware host mip-tail clamping rebased onto `main` (`132da61`, `#563` + `#564`), ported from `fxceless/victory-fork` and `avatarmanz/VIctory-7900XTX`. ### Default-OFF Parity & Scope - `texture::staging()` leaves the default path (`VICTORY_TEXTURE_AUTO_MIP_CLAMP` unset/`0`) identical to `main`: the extra shape predicate, `clamp_host_size` comparison, and keep-newer staging branch only run when `texture_mip_clamp::enabled()` is true (covered by `texture::staging_tests`). `copy.tiled.is_some()` and `VICTORY_GPU_DETILE` routing match `132da61`. - Preserves `#564` slot eviction, bindless feedback eviction, and allocation retry paths. ### Known Limitations (Lossy by Design) - **Shader-visible lossy mode:** Raising the host mip base (`level0 > 0`) and rebasing the SRV (`MostDetailedMip`, `MipLevels`, `ResourceMinLODClamp`) alters what shaders observe in explicit `Load(.., mip)`, `GetDimensions`, and texel-size math when `VICTORY_TEXTURE_AUTO_MIP_CLAMP=1` is enabled. - **Unclamped rebind & dynamic descriptor snapshots:** `rebind_unclamped` updates static/mirrored descriptor slots when a staging copy later uploads wider mip ranges, but intentionally **skips dynamic-table snapshots** — recorded but unsubmitted command lists may retain descriptors referencing the displaced host resource, relying on `host::retire` keeping the displaced resource alive until its GPU fences complete. ## Verification Verified locally on Windows 11 (`third_party/victory` workspace) after the final edit: - `cargo xtask policy` (381 files ok) - Hunk-accurate `cargo clippy --no-deps -p victory-gpu --locked --all-targets` (default & `--features diagnostics`: 0 errors, 0 own warnings) - Both HW (`VICTORY_D3D12_WARP=0`) and WARP (`VICTORY_D3D12_WARP=1`, with `VICTORY_TEXTURE_AUTO_MIP_CLAMP` unset): - `texture::staging_tests`: 2/2 passed - `resource::texture_mip_clamp::tests`: 5/5 passed - `descriptor::host::mip_clamp_tests`: 1/1 passed - `texture::detile_fallback_tests`: 2/2 passed (both default and `VICTORY_GPU_DETILE=1`) - `resource::tests::slot_eviction`: 2/2 passed - `resource::tests::refused_texture_allocation_has_one_retry`: 1/1 passed - In-game FPS/VRAM gain: **unmeasured** (assumed). ## Checklist - [x] Neutral naming (0 game, character, or console strings) - [x] Rule 10 credits (`Source:` / `Co-authored-by:` trailers + `THIRD_PARTY.md` row; ported from `fxceless/victory-fork` & `avatarmanz/VIctory-7900XTX`) - [x] Opt-in default OFF (`VICTORY_TEXTURE_AUTO_MIP_CLAMP=1` required to activate) - [x] Documented lossy SRV trade-off and `rebind_unclamped` dynamic-snapshot lifetime - [ ] In-game A/B benchmark (unmeasured)
LooperSalty commented 2026-11-27 21:58:52 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T21:58:52Z.


Thanks for making the clamp opt-in. Before an in-game test:

  1. Credits (rule 10). This comes from fxceless/victory-fork and avatarmanz/VIctory-7900XTX, but the commits have no Source: / Co-authored-by: trailers, THIRD_PARTY.md is unchanged, and the checklist says no code was taken. Please fix all three.
  2. Not identical to main when off. texture.rs staging() changes regardless of VICTORY_TEXTURE_AUTO_MIP_CLAMP: the cache hit now also compares on_demand, level0, mips and host size, a new "keep the old staging" branch was added, and on_demand now comes from copy.tiled instead of host_tiled(resource). Please gate it, or say it changes the default path and add a test that fails on main.
  3. Lossy by design. Raising the host base and rebasing the SRV changes what Load(.., mip), GetDimensions or texel-size maths see in shaders. Please say in the description that the mode is lossy, and that rebind_unclamped skips dynamic-table snapshots, so recorded but unsubmitted lists may still hold the displaced copy's descriptors (and relies on host::retire being fence-aware).

This conflicts with #354 in host.rs, resource.rs and texture.rs (take_staged, keep_whole, staging()); whichever lands second needs a rebase.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7228922211 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/555#issuecomment-7228922211). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-27T21:58:52Z. --- Thanks for making the clamp opt-in. Before an in-game test: 1. **Credits (rule 10).** This comes from fxceless/victory-fork and avatarmanz/VIctory-7900XTX, but the commits have no `Source:` / `Co-authored-by:` trailers, `THIRD_PARTY.md` is unchanged, and the checklist says no code was taken. Please fix all three. 2. **Not identical to main when off.** `texture.rs` `staging()` changes regardless of `VICTORY_TEXTURE_AUTO_MIP_CLAMP`: the cache hit now also compares `on_demand`, `level0`, `mips` and host size, a new "keep the old staging" branch was added, and `on_demand` now comes from `copy.tiled` instead of `host_tiled(resource)`. Please gate it, or say it changes the default path and add a test that fails on main. 3. **Lossy by design.** Raising the host base and rebasing the SRV changes what `Load(.., mip)`, `GetDimensions` or texel-size maths see in shaders. Please say in the description that the mode is lossy, and that `rebind_unclamped` skips dynamic-table snapshots, so recorded but unsubmitted lists may still hold the displaced copy's descriptors (and relies on `host::retire` being fence-aware). This conflicts with #354 in `host.rs`, `resource.rs` and `texture.rs` (`take_staged`, `keep_whole`, `staging()`); whichever lands second needs a rebase.
LooperSalty commented 2026-11-28 00:15:39 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-28T00:15:39Z.


Main just took #563 (the VIctory copy moved to Vice-Tay 4f15f09e) and #564 (memory stack), and this PR now conflicts in third_party/victory/crates/victory-gpu/src/resource.rs, third_party/victory/crates/victory-gpu/src/texture.rs. Please rebase on current main, rerun the tests for the files you touch, and force-push.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7230773240 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/555#issuecomment-7230773240). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-28T00:15:39Z. --- Main just took #563 (the VIctory copy moved to Vice-Tay `4f15f09e`) and #564 (memory stack), and this PR now conflicts in `third_party/victory/crates/victory-gpu/src/resource.rs`, `third_party/victory/crates/victory-gpu/src/texture.rs`. Please rebase on current main, rerun the tests for the files you touch, and force-push.
Vladimir-Human commented 2026-11-28 07:20:16 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-28T07:20:16Z.


Rebased onto main (132da61, preserving #563 & #564) and addressed all three review items at commit ded34e9:

  1. Credits (Rule 10): Added Source: / Co-authored-by: trailers to the commit, added the French row in THIRD_PARTY.md, and corrected the PR checklist to acknowledge code adapted from fxceless/victory-fork and avatarmanz/VIctory-7900XTX.
  2. Identical to main when OFF: Gated the extra texture.rs staging() cache-hit checks (on_demand, level0, mips, clamp_host_size) and the keep-newer staging branch behind texture_mip_clamp::enabled() so the default path matches 132da61 (copy.tiled.is_some() and VICTORY_GPU_DETILE intact), verified with texture::staging_tests (2/2 HW+WARP) and texture::detile_fallback_tests (2/2 HW+WARP, default & VICTORY_GPU_DETILE=1).
  3. Lossy by design & dynamic snapshots: Documented in the PR body and module/descriptor comments that opt-in mip clamping is lossy for Load(.., mip), GetDimensions, and texel-size math, and that rebind_unclamped skips dynamic-table snapshots and relies on fence-aware host::retire.

All touched-file tests passed on both HW and WARP after the rebase (policy 381 ok, hunk-accurate clippy default & diagnostics 0 own warnings, texture_mip_clamp 5/5, mip_clamp_tests 1/1, slot_eviction 2/2, refused_texture_allocation_has_one_retry 1/1). Note: rebased before #354; once #354 merges/rebases we'll keep them aligned.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7235869125 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/555#issuecomment-7235869125). Originally posted by [Vladimir-Human](https://github.com/Vladimir-Human) on 2026-11-28T07:20:16Z. --- Rebased onto `main` (`132da61`, preserving `#563` & `#564`) and addressed all three review items at commit `ded34e9`: 1. **Credits (Rule 10):** Added `Source:` / `Co-authored-by:` trailers to the commit, added the French row in `THIRD_PARTY.md`, and corrected the PR checklist to acknowledge code adapted from `fxceless/victory-fork` and `avatarmanz/VIctory-7900XTX`. 2. **Identical to `main` when OFF:** Gated the extra `texture.rs` `staging()` cache-hit checks (`on_demand`, `level0`, `mips`, `clamp_host_size`) and the keep-newer staging branch behind `texture_mip_clamp::enabled()` so the default path matches `132da61` (copy.tiled.is_some() and `VICTORY_GPU_DETILE` intact), verified with `texture::staging_tests` (2/2 HW+WARP) and `texture::detile_fallback_tests` (2/2 HW+WARP, default & `VICTORY_GPU_DETILE=1`). 3. **Lossy by design & dynamic snapshots:** Documented in the PR body and module/descriptor comments that opt-in mip clamping is lossy for `Load(.., mip)`, `GetDimensions`, and texel-size math, and that `rebind_unclamped` skips dynamic-table snapshots and relies on fence-aware `host::retire`. All touched-file tests passed on both HW and WARP after the rebase (policy 381 ok, hunk-accurate `clippy` default & `diagnostics` 0 own warnings, `texture_mip_clamp` 5/5, `mip_clamp_tests` 1/1, `slot_eviction` 2/2, `refused_texture_allocation_has_one_retry` 1/1). Note: rebased before `#354`; once `#354` merges/rebases we'll keep them aligned.
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/555:upstream-pr/555'
git switch 'upstream-pr/555'

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