GPU: opt-in VICTORY_PARTIAL_MIP_CLAMP, shader views start at the first mip with memory (off by default) #3647
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3647"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by TG0000 on 2026-11-28T01:53:44Z.
What
VICTORY_PARTIAL_MIP_CLAMP=1, off by default (unset or0: no change).A streamed texture gets its smallest mips first. The finer ones read as zeros in the host texture until their pages arrive, so a view that starts at mip 0 samples black up close while the same texture looks right further away. With the switch on:
Layout::first_present_mip,victory-formats);MostDetailedMip;ResourceMinLODClampis left alone);Limits
start_view_atin5a99fb53).Where it comes from, and what is not shown
The idea comes from our fork, whose texture path differs from
main's. There, on an RX 6800, a build with this clamp and two other changes to its texture queue fixed close-up surfaces that had rendered black (a railing among them), but character skin stayed black. A later build, adding three more changes to the fork's handling of one-shot texture bakes, showed lit skin and face at native 1440p; with upscaling on, skin was still black. These were single runs, in an area that varies from run to run, and the clamp's own share was never isolated.The fork's other changes hook into a texture queue and bake handling that
maindoes not have, so they are not here. Do not read this PR as a fix for black skin onmain.Tested
cargo clippy --workspace --all-targets -- -D warnings, with and without--all-features, forx86_64-pc-windows-msvc(cross-built on macOS): clean.cargo test -p victory-formats -p xtask(asset policy): passed, including two new tests for the mip search and the view arithmetic.5a99fb53, which changes a comment only.aa51c796, with thanks:andrewpozdnakov7-jpgread back the view rewrite (and pointed out the one-mip case);TheGrayOrangechecked uploads, found registered views follow mip availability and the switch-off control matches, and measured the dynamic-slot limit above. See the comments.Our hardware, for the fork runs above: AMD Radeon RX 6800 16 GB (ReBAR), Adrenalin 26.11.2, Ryzen 9 5900X, Windows 11.
Overlaps
Layout.AI-assisted (Claude).
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T02:14:46Z.
I checked the SRV rewrite from
aa51c796on app-local WARP 1.0.22 with D3D12 Agility 1.620.2. The standalone compute test used the PR's exactstart_view_atto generate the descriptors. It ran 13 views each with distinct values in all mips and with mip 0/1 zeroed to model a partial upload.The resource was a 16×16
R32_FLOATtexture. Mip 2 held 30, mip 3 held 40, and mip 4 held 50. With mip 0/1 zeroed and the first present mip set to 2, I read back:GetDimensions(0)Load(0)Load(1)SampleLevel(0)ResourceMinLODClamp=3ResourceMinLODClamp=2The one-mip case is worth documenting. When there is no overlap with the original range, the view exposes one mip that the original descriptor excluded. The min-LOD-only control keeps the original dimensions and redirects point samples, while explicit loads into the clamped mips still return zero. This probe covers the shader-visible SRV behavior. Upload tracking, descriptor remakes, and the game were outside the probe.
If you reuse the test, please retain Git authorship on a cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if you fold it into another commit.AI-assisted with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by TheGrayOrange on 2026-11-28T03:03:17Z.
Independent WARP verification at
aa51c79using actual synthetic texture uploads confirms that registered SRVs correctly follow streamed mip availability, avoid incomplete mip chains and preserve ResourceMinLODClamp.However, dynamic SRVs retain their previous mip range during the submission that discovers the availability change:
The disabled-feature parity control passes.
The dynamic descriptors created through
HostHeap::make_atappear to be skipped byremake_viewsbecause they lack amaderecord.I have a focused reproduction and can prepare a correction that refreshes affected dynamic SRVs while preserving the existing allocation lifetime and disabled-feature behavior. Are you already working on this?
Imported from Marvisak/VIctory. Originally posted by TG0000 on 2026-11-28T09:51:05Z.
Thank you both for checking
aa51c796on WARP independently.@andrewpozdnakov7-jpg: agreed, the one-mip fallback needed saying.
5a99fb53documents it onstart_view_at(comment only, no behaviour change) and it is now listed under Limits. Your test code is not reused in the branch.@TheGrayOrange: you're right.
make_atleaves nomaderecord, soremake_viewsskips those dynamic slots, and a table made before the upload keeps the old range for that submission. This is the "table made afresh in dynamic slots" line under Limits (and theshortcut:note onpartial_mip_clamp); your readback shows what it looks like. This push does not change it. To your question: I have no fix for it in progress.AI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by TheGrayOrange on 2026-11-28T17:25:14Z.
I've prepared and independently verified a follow-up implementation addressing the dynamic SRV refresh issue.
The correction refreshes eligible dynamic SRVs when streamed mip availability changes, using the saved descriptor description and the host texture retained by the allocation.
Verified on WARP and RTX 4070 Ti SUPER:
A test-only descriptor binding correction eliminated the four D3D12 validation errors observed during initial NVIDIA verification. Existing startup and heap-capacity messages remain unchanged.
The implementation is ready locally. Would you prefer a follow-up commit, a patch, or a reference branch on my fork?
Original implementation by TG0000. Follow-up development and independent verification were AI-assisted using Strata and Codex. All verification used synthetic textures.
Imported from Marvisak/VIctory. Originally posted by TG0000 on 2026-11-28T18:36:54Z.
@TheGrayOrange Thank you for taking this further and for checking it on WARP and an RTX 4070 Ti. A reference branch on your fork would suit best: I'll read it, run our tests on an RX 6800, and fold it in with your authorship if it holds up.
AI-assisted (Claude).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.