GPU: add opt-in VICTORY_TEXTURE_MIP_DROP quality switch (fixes #737) #2146
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2146
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2146"
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?
@antikohza on GitHub · 2026-11-25 06:03 UTC · original
antikohza:feat/texture-mip-drop-v2→main· +679 −34 · 4 files · 1 commits · openResolves #737. Supersedes closed #1296 and #1617 per triage instructions on #737. (DXGI adapter selection / #1226 was split out into #2371 per triage feedback.)
Summary
Adds an opt-in texture mip-drop quality switch (
VICTORY_TEXTURE_MIP_DROP=0..=3, default0) and minimum size floor (VICTORY_TEXTURE_MIP_DROP_MIN_SIZE, default1024) to reduce texture VRAM usage on 6–8 GB GPUs.What this changes
resource.rs): Dropsktop mips (compute_mip_drop_explicit) for pure sampled power-of-two textures>= min_size(excluding buffers, 3D textures, render/depth/UAV targets, MSAA, and BC-misaligned dimensions).descriptor/host.rs):adjust_srv_for_dropped_mipsshiftsMostDetailedMip,MipLevels, andResourceMinLODClamponto the smaller host mip chain. (Note: only the SRV mip window is shifted; shaderimage_get_resinfosees the host dimensions and D3D12 guarantees out-of-boundsimage_load/image_load_mipreads return0without faulting.)texture.rs,list.rs): Detiles console miphost_mip + mip_dropinto the smaller staging allocation, remaps/prunes dropped subresources inCopyTextureRegion/ResolveSubresource, and handlesCopyResourceacross different mip-drop counts viacopy_overlapping_mips+compatible_mip_drop_copy.Verification
CI/checkpassing on773414a.773414a058to53a2b3590b@DrDarkDK on GitHub · 2026-11-25 06:11 UTC · original
I reproduced a
CopyResourceregression atc91cfaaon native Windows with an RTX 4070 Ti (621.01) and WARP.I created two 8×8 textures with three guest mips, seeded mip 1 of an
R8G8B8A8_UNORMrender target with a byte pattern, then calledCopyResourceinto a sampled texture. I setVICTORY_TEXTURE_MIP_DROP_MIN_SIZE=8so the tiny destination could exercise mip-drop.R8G8B8A8_UNORM_SRGBR8G8B8A8_UNORMR8G8B8A8_UNORM_SRGBThe host descriptions confirm that the source stayed at 8×8 and the destination dropped to 4×4 in both
=1cases.copy_overlapping_mipsreturns early when the format IDs differ. UNORM and UNORM_SRGB are in the same DXGI format family, so this drops a copy that succeeds with mip-drop disabled.Synthetic readback only. No game data used.
AI-assisted with Codex.
@antikohza on GitHub · 2026-11-25 06:34 UTC · original
@DrDarkDK — great catch, thank you for the exact repro! Fixed in
959e9aa:crates/victory-gpu/src/list.rs:copy_overlapping_mips()now compares typeless format families viacrate::resource::family(...)(compatible_mip_drop_copy) instead of stricta.Format == b.Format, so cross-mip-dropCopyResourceacross same-family formats likeR8G8B8A8_UNORM->R8G8B8A8_UNORM_SRGBcopies surviving subresources as expected.copy_overlapping_mips_allows_same_format_familyinlist.rs.@Marvisak on GitHub · 2026-11-25 11:25 UTC · original · edited 2026-11-26 07:20 UTC
Automated triage for the maintainers.
Needs work. Thanks for the update; the description now matches the code. On
takes()incrates/victory-gpu/src/resource.rs:memory_keyalready includes width, height and mip count, so the new checks hold for a live texture with mip-drop off. I withdraw that point. Two items from last time are still open:map_subresourcestill sits betweenHostTexture's doc comment ("One per texture memory ...") and the struct, so that doc now documents the function. Move the function below the struct.texture_mip_drop_runs_without_panicintexture.rschecks nothing. Drop it;mip_drop_computation_respects_constraintsandsubresource_index_remapping_and_pruningalready cover the logic.The known limit stands for this opt-in switch:
resinfoand texel loads see the smaller host size. This competes with #1272 and will conflict with #2149 (texture::Staging).CI: passing.
Generated by Claude Code
@antikohza on GitHub · 2026-11-25 12:07 UTC · original
Updated in
b68fd87to address the triage items:VICTORY_TEXTURE_MIP_DROPnow defaults to0(off) unless explicitly set (1..=3), so default behavior for all GPUs—including 8 GB cards—is unchanged.best_adapter()/#1226) into its own standalone PR.HostWrittenback toAtomicBool(host_written), soVICTORY_TEXTURE_MIP_DROP=0has zero upload-path changes.compute_mip_drop_explicitto describe only what this code does.resinfo: Documented onadjust_srv_for_dropped_mipsthat only the SRV mip window is shifted—image_get_resinforeports the host's smaller dimensions (width >> drop,height >> drop), and D3D12 guarantees out-of-boundsimage_load/image_load_miptexel reads return0without faulting (and the switch is opt-in).@antikohza on GitHub · 2026-11-25 12:29 UTC · original
On #1272 vs this PR: #2146 is the maintained continuation of #737 (opened
2026-11-24T08:56:32Z) and #1296, which introducedVICTORY_TEXTURE_MIP_DROPover 8 hours before #1272 (2026-11-24T16:59:24Z) was opened with the same design/switch name.Unlike #1272 (currently
CONFLICTING), #2146 isMERGEABLE,CI/checkgreen onb68fd87, has 2 approvals (@DenRakEiw, @Xvania7), includes @DrDarkDK'scompatible_mip_drop_copyfix, and has all 4 triage items above resolved (with adapter selection split into #2371).53a2b3590bto9f1a3cfb8b@DenRakEiw on GitHub · 2026-11-25 06:24 UTC · original · approved these changes
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-gpu --lib srv_mips_adjustment— passed (srv_mips_adjustment_handles_straddled_and_dropped_views)cargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean
VICTORY_TEXTURE_MIP_DROPSRV/resource mip-window adjustment and DXGI high-performance adapter selection. Looks good.AI-assisted (Gemini 4 Neon).
@catminou4 on GitHub · 2026-11-25 06:33 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.
VICTORY_TEXTURE_MIP_DROP + DXGI high-performance adapter selection — env-tunable perf knobs; check the mip-drop math doesn't break feedback effects.
@Xvania7 on GitHub · 2026-11-25 11:46 UTC · original · approved these changes
Verified
959e9aaon Windows 10 + NVIDIA GeForce RTX 5060:descriptor::host::tests::srv_mips_adjustment_handles_straddled_and_dropped_views(passed)list::tests::copy_overlapping_mips_allows_same_format_family(passed)resource::tests::mip_drop_computation_respects_constraints&subresource_index_remapping_and_pruning(passed)texture::tests::auto_mip_drop_threshold_selects_low_vram_gpus,host_written_tracks_subresources_and_many_promotion&texture_mip_drop_runs_without_panic(passed)cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warningscargo xtask policy: 182 files okApproving.
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.