GPU: back hidden, uncommitted BC1 mips on demand #704

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

@⁠ryotdev on GitHub · 2026-11-25 05:07 UTC · original
ryotdev:codex/sparse-sampled-mips → main · +693 −2 · 6 files · 1 commits · draft

Change

VICTORY_SPARSE_BC1=1 lets a restricted BC1 shader resource view use a D3D12 reserved resource when its hidden high-resolution levels have no committed source pages. The default uses the existing allocator.

The D3D12 texture retains its original size, format, mip numbering and identity. The initial mapping covers every sampleable level and the entire packed mip tail. A broader view or nonzero source content promotes the missing standard levels on the existing direct queue. Every heap stays alive with its resource. Initial allocation failure falls back to committed backing. If a later allocation fails on a healthy device, resident levels continue receiving updates and the failed wider view cannot replace the last usable view of that resource. This last case does not retry a refused allocation every draw.

The initial scope is internal single-slice, single-sample, read-only BC1 at least 512 texels on each side. Unsupported tilings and any layout that would cost more than conventional backing when fully promoted fall back. #610 deliberately trades away high-resolution detail. #676 improves full-card scheduling and is related but orthogonal.

Windows results

RTX 5070 12 GB, driver 610.88, Series X. I used the same checkpoint, independent copies of a warm cache, matched frame offsets and the same executable within each pair. FPS is 140 frames divided by elapsed wall time in the post-loading window.

Run order Conventional Sparse
Conventional first 2.21 FPS 4.50 FPS
Sparse first 2.23 FPS 4.48 FPS

Separate instrumented runs observed about 1.4–1.5 GiB less physical backing for the affected textures. The renderer admitted extra resources and whole-process dedicated usage increased, while shared usage fell. The camera, some geometry and surfaces varied across independent loads. Existing visual defects remain. These are checkpoint-specific observations on one adapter. The final source additionally compares the actual held D3D12 object after a rejected promotion to handle irrelevant description padding. This failure case was validated synthetically after the timed runs.

Verification

  • Windows WARP: 125 normal victory-gpu tests passed with the switch on and off; four were ignored by the normal runner. Both new process-isolated ignored regressions passed when run explicitly with the switch on. The fixtures check object identity and valid old/new views, later content promotion, allocation failure, descriptor replacement with different padding and resident mip updates.
  • A standalone synthetic D3D12 sampler on WARP and the RTX compared old restricted and new broad views before/after promotion. All 36 original comparisons and all 72 post-promotion comparisons matched the committed control. The test separately checked zero-block BC1 samples. There are no external inputs to the committed tests.
  • Windows-target Clippy, default and diagnostics, had no new warnings in the diff. The pinned base still warns about existing draw sorting, an unused indirect-test field and (default build) an unused accounting function.
  • cargo xtask policy --staged and cargo xtask policy passed. No game data or captures are included.

AI-assisted. Further testing on different adapters and additional scenes would help before considering any change to the default.

**@⁠ryotdev** on GitHub · 2026-11-25 05:07 UTC · [original](https://github.com/fxceless/victory-fork/pull/704) `ryotdev:codex/sparse-sampled-mips` → `main` · +693 −2 · 6 files · 1 commits · draft ## Change `VICTORY_SPARSE_BC1=1` lets a restricted BC1 shader resource view use a D3D12 reserved resource when its hidden high-resolution levels have no committed source pages. The default uses the existing allocator. The D3D12 texture retains its original size, format, mip numbering and identity. The initial mapping covers every sampleable level and the entire packed mip tail. A broader view or nonzero source content promotes the missing standard levels on the existing direct queue. Every heap stays alive with its resource. Initial allocation failure falls back to committed backing. If a later allocation fails on a healthy device, resident levels continue receiving updates and the failed wider view cannot replace the last usable view of that resource. This last case does not retry a refused allocation every draw. The initial scope is internal single-slice, single-sample, read-only BC1 at least 512 texels on each side. Unsupported tilings and any layout that would cost more than conventional backing when fully promoted fall back. #610 deliberately trades away high-resolution detail. #676 improves full-card scheduling and is related but orthogonal. ## Windows results RTX 5070 12 GB, driver 610.88, Series X. I used the same checkpoint, independent copies of a warm cache, matched frame offsets and the same executable within each pair. FPS is 140 frames divided by elapsed wall time in the post-loading window. | Run order | Conventional | Sparse | | --- | ---: | ---: | | Conventional first | 2.21 FPS | 4.50 FPS | | Sparse first | 2.23 FPS | 4.48 FPS | Separate instrumented runs observed about 1.4–1.5 GiB less physical backing for the affected textures. The renderer admitted extra resources and whole-process dedicated usage increased, while shared usage fell. The camera, some geometry and surfaces varied across independent loads. Existing visual defects remain. These are checkpoint-specific observations on one adapter. The final source additionally compares the actual held D3D12 object after a rejected promotion to handle irrelevant description padding. This failure case was validated synthetically after the timed runs. ## Verification - Windows WARP: 125 normal `victory-gpu` tests passed with the switch on and off; four were ignored by the normal runner. Both new process-isolated ignored regressions passed when run explicitly with the switch on. The fixtures check object identity and valid old/new views, later content promotion, allocation failure, descriptor replacement with different padding and resident mip updates. - A standalone synthetic D3D12 sampler on WARP and the RTX compared old restricted and new broad views before/after promotion. All 36 original comparisons and all 72 post-promotion comparisons matched the committed control. The test separately checked zero-block BC1 samples. There are no external inputs to the committed tests. - Windows-target Clippy, default and diagnostics, had no new warnings in the diff. The pinned base still warns about existing draw sorting, an unused indirect-test field and (default build) an unused accounting function. - `cargo xtask policy --staged` and `cargo xtask policy` passed. No game data or captures are included. AI-assisted. Further testing on different adapters and additional scenes would help before considering any change to the default.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:49:17 +00:00
Author
Owner

@⁠CuteBooty on GitHub · 2026-11-25 05:55 UTC · original

It cannot be combined with #610 as written

From reading 770e1940 next to #610's 5971e08b; not from a run.

sparse_host creates the reserved texture at full size, without #610's dropped levels, but dropped() still
reports the drop for that texture. The view level shift in descriptor/host.rs (shift_view_levels) and
Staging::detile (mip + self.drop) would then address the wrong levels: black or wrong textures with both
switches on.

The smallest guard is to take the sparse path only where dropped() == 0; a real combination (sparse for the
levels the drop keeps) would be the better end state for 8 GB cards, where the drop is what makes the title usable.

Not tested on this card yet; tiled-resources tier not checked here.

Setup: RTX 3070 8 GB (driver 621.24, 32-lane waves), Ryzen 5 3600, 32 GB, Windows 11, Series X mode, 1920x1080, relay at its default (stage 2), card buffers 1 / 1024 MB, a diagnostics build.

**@⁠CuteBooty** on GitHub · 2026-11-25 05:55 UTC · [original](https://github.com/fxceless/victory-fork/pull/704#issuecomment-7154261747) **It cannot be combined with #610 as written** From reading 770e1940 next to #610's 5971e08b; not from a run. `sparse_host` creates the reserved texture at full size, without #610's dropped levels, but `dropped()` still reports the drop for that texture. The view level shift in `descriptor/host.rs` (`shift_view_levels`) and `Staging::detile` (`mip + self.drop`) would then address the wrong levels: black or wrong textures with both switches on. The smallest guard is to take the sparse path only where `dropped() == 0`; a real combination (sparse for the levels the drop keeps) would be the better end state for 8 GB cards, where the drop is what makes the title usable. Not tested on this card yet; tiled-resources tier not checked here. Setup: RTX 3070 8 GB (driver 621.24, 32-lane waves), Ryzen 5 3600, 32 GB, Windows 11, Series X mode, 1920x1080, relay at its default (stage 2), card buffers 1 / 1024 MB, a diagnostics build.
Author
Owner

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

@⁠CuteBooty confirmed on the merged source of 770e1940 and 5971e08b. Git combines them without a conflict. When a 2048×2048 three-level BC1 resource qualifies for a one-level drop, the committed path makes a 1024×1024 two-level texture. The reserved path instead passes 2048×2048 and all three levels to D3D12. The SRV and staging code both still apply the one-level drop. Please use just one of these switches on this combination. I haven't run both switches on an RTX 3070.

Main now has its own opt-in level residency implementation in 8dd30ab (VICTORY_LEVELS_ON_DEMAND=1), including pooled tiles and promotion on upload. This draft conflicts with it in resource.rs and texture.rs. I'm keeping the draft open for comparison with main's implementation. The RTX results in the description only cover this draft on its pinned base. Thanks for catching the interaction before anyone used both.

**@⁠ryotdev** on GitHub · 2026-11-25 06:06 UTC · [original](https://github.com/fxceless/victory-fork/pull/704#issuecomment-7154443674) @⁠CuteBooty confirmed on the merged source of `770e1940` and `5971e08b`. Git combines them without a conflict. When a 2048×2048 three-level BC1 resource qualifies for a one-level drop, the committed path makes a 1024×1024 two-level texture. The reserved path instead passes 2048×2048 and all three levels to D3D12. The SRV and staging code both still apply the one-level drop. Please use just one of these switches on this combination. I haven't run both switches on an RTX 3070. Main now has its own opt-in level residency implementation in `8dd30ab` (`VICTORY_LEVELS_ON_DEMAND=1`), including pooled tiles and promotion on upload. This draft conflicts with it in `resource.rs` and `texture.rs`. I'm keeping the draft open for comparison with main's implementation. The RTX results in the description only cover this draft on its pinned base. Thanks for catching the interaction before anyone used both.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor/host.rs
  • crates/victory-gpu/src/resource.rs
  • crates/victory-gpu/src/texture.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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