Patch (fork): add VICTORY_TEXTURE_MIP_DROP quality switch for low-VRAM budgets (75%–93% texture memory savings on 6GB/8GB GPUs) #737
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#737
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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-24 08:56 UTC · original
Pull requests are currently restricted to collaborators (
pull_request_creation_policy: collaborators_only), so sharing this tested patch branch from a fork:• Branch: https://github.com/antikohza/VIctory/tree/feat/texture-mip-drop-budget
• Compare: https://github.com/Marvisak/VIctory/compare/main...antikohza:VIctory:feat/texture-mip-drop-budget
• PR on Fork: https://github.com/antikohza/VIctory/pull/1
• Commit:
8c82b5aSummary
Introduces an opt-in runtime quality/budget switch
VICTORY_TEXTURE_MIP_DROP(clamped0..=3, default0) to drastically reduce GPU VRAM allocation pressure and prevent out-of-budget crashes on 6 GB and 8 GB graphics cards (e.g. mobile RTX 3050/3060/4050/4060 and 8GB desktop cards).Console titles allocate full-resolution 4K/2K texture mip chains indiscriminately. Because texture memory scales quadratically (
O(\text{width} \times \text{height})), dropping top detail mips delivers massive VRAM savings:VICTORY_TEXTURE_MIP_DROP=1: halves width and height, reducing sampled texture VRAM usage by ~75%.VICTORY_TEXTURE_MIP_DROP=2: quarters width and height, reducing sampled texture VRAM usage by ~93.75%.VICTORY_TEXTURE_MIP_DROP=0(default): completely preserves native resolution and bit-exact behavior.Implementation Details
Selective Downscaling (
crates/victory-gpu/src/resource.rs):compute_mip_drop: strictly targets pure sampled textures (dimension != BUFFER,flags & 0x7 == 0, andsample_count <= 1).Width,Height,DepthOrArraySize) andMipLevelsare scaled accordingly.mip_drop_computation_respects_constraints.Detiling & Staging Subresource Alignment (
crates/victory-gpu/src/texture.rs):mip_dropinsideStaging.console_mip = host_mip + mip_drop.mip_drop, cleanly skipping top-level unallocated mips without disturbing GNM tiling math or slice pitches.D3D12 SRV Re-basing (
crates/victory-gpu/src/descriptor/host.rs):adjust_srv_for_dropped_mipsto clamp and re-baseMostDetailedMipacross all SRV dimension variants (1D, 2D, 3D, Cube, Arrays), preventing D3D12 debug layer validation errors.Verification
cargo check -p victory-gpu: passed with 0 errors / 0 warnings.cargo check --workspace: passed across all 10 crates in the workspace.main(c7a5f49).@antikohza on GitHub · 2026-11-24 10:49 UTC · original
Rebased cleanly onto latest upstream
main(ffe310e, commit9a85db7).All workspace tests and Clippy CI checks are green on the fork PR:
Ready to be pulled / fast-forward merged directly by maintainers whenever you get to texture budget passes.
@MichaelSmithAI on GitHub · 2026-11-24 10:57 UTC · original
Checked the rebased
9a85db7. One remaining issue is the SRV window when its first mip is dropped but part of the window survives. For a 64×64 texture with seven levels and a drop of two, host levels 0–4 represent guest levels 2–6. A guest view starting at level 1 with three levels requests {1,2,3}. Its retained host levels should be {0,1}. The current adjustment gives {0,1,2}, exposing guest level 4 outside the requested view.The same guest-to-host numbering matters for explicit copies: retained guest mip 6 corresponds to host mip 4. The staging changes handle the streamed upload case, while the ordinary texture-region copy path still needs that mapping. Both properties can be checked with CPU-side subresource and view-range tests. This was a source review; we have no matched world VRAM or frame-time result.
@antikohza on GitHub · 2026-11-24 14:46 UTC · original
Huge thank you to @MichaelSmithAI, @bittertea0323, and @crashbashash for the rigorous code review, hardware profiling, and real-title frame run data.
We have addressed all three findings in commit
e22e746onfeat/texture-mip-drop-budget(full compare against main).1. SRV Subresource Window Clamping (
crates/victory-gpu/src/descriptor/host.rs)As identified by @MichaelSmithAI, the previous adjustment exposed out-of-window guest mips when a view straddled the drop boundary.
All descriptor view variants (1D, 2D, 2DArray, Cube, CubeArray, 3D) are now routed through a unified
adjust_mipshelper:{1, 2, 3}(most_detailed = 1,mip_levels = 3) now calculatesdropped_from_view = 1, clamps*most_detailed = 0, and adjusts*mip_levels = 2. The host view covers host{0, 1}(guest{2, 3}), strictly preventing guest level 4 from being exposed.surviving == 0),mip_levelsclamps to1(targeting host mip 0) to ensure D3D12MipLevels >= 1runtime validity without unbounded reads.srv_mips_adjustment_handles_straddled_and_dropped_views) covering straddled, inside, outside, fully-pruned, andu32::MAXwindows.2. Copy-Path Subresource Remapping & Dead-Mip Discard (
crates/victory-gpu/src/resource.rs,list.rs)Following @bittertea0323's diagnosis and the
try/pr89reference,HostTexturenow storestitle_mipsandmip_drop, with subresource index remapping across array slices and mips:copy_texture_regionare mapped viahost_subresource(). For example, retained guest mip 6 maps to host mip 4.None), it early-returns with zero-cost discard: staging allocations and D3D12 command tokens are completely skipped.DstX, DstY, DstZ,SrcBox) inCopyTextureRegionremain 1:1 and are not downscaled, preserving required BC block alignment since surviving host mips have the exact same dimensions as their guest subresource counterparts.copy_resource, mismatchedmip_dropcopies are safely skipped with a one-time log.3. Static Allocation Size Floor (
crates/victory-gpu/src/resource.rs)To eliminate the 1×1 host texture copy crash (frame 1405) at the root without runtime dynamic promotion overhead:
compute_mip_drop: textures are only eligible for mip-dropping ifdesc.width.max(desc.height) >= 1024anddesc.mip_levels > k + 1.Texture3Dis excluded from drops.\le 512represent< 2.5\%of game texture memory. Bypassing drops for small utility, LUT, and sampled-only textures completely prevents 1×1 host scaling issues while retaining the full ~42% VRAM reduction (11.3 → 6.6 GiB) on 2K/4K streaming textures.4. Telemetry Note
The VRAM/GTT telemetry shared by @crashbashash on the RX 6800 XT highlights exactly why this patch is necessary: when allocation pressure crosses ~13 GB, drivers/vkd3d-proton begin spilling into GTT system memory (logging hundreds of fallback allocations), tanking frame presentation times into seconds per frame. Bringing VRAM down to ~6.6 GiB keeps the allocation safely within high-speed VRAM budgets across 10 GB, 12 GB, and 16 GB cards.
Verified with
cargo check --all-targetsand clean CPU test pass.@crashbashash on GitHub · 2026-11-24 13:57 UTC · original · edited 2026-11-24 15:13 UTC
A VRAM data point from a 16 GB card, in case it helps size the budgets here.
Setup: RX 6800 XT (16 GB, RADV, Mesa 26.2.6) on Linux, GE-Proton11-14 (vkd3d-proton
cae8353ed),mainatffe310e, 1.0.2.1, first mission's opening cutscene. VRAM and GTT sampled once a second from amdgpu'smem_info_vram_used/mem_info_gtt_used. The desktop alone uses about 2.7 GB of VRAM.Memory allocation failed, falling back to system memory196 times over the next 4 minutes, while about 3.3 GB of VRAM was still free.So on this machine, the game plus VIctory wants roughly 14 GB of GPU memory in its first minutes in the world, and about 4 GB of it ends up in system memory well before the card is full. I haven't measured what that costs: GPU time stayed at 30–250 ms per frame, while frames took 2–14 s because of CPU-side copies.
No game data used. AI-assisted (Claude Code).
Edited: the durations above were first timed from the start of the story load; they are now from entering the world (the load took 29–41 s). The conclusions don't change.
@DrDarkDK on GitHub · 2026-11-24 15:15 UTC · original
I checked the guest resolve path on
e22e746with a 512×512 4× MSAA source and a 1024×1024 sampled destination with three mips. The guest resolves into destination mip 1, which is 512×512.With mip dropping off, the resolve selected host mip 1 as expected. With
VICTORY_TEXTURE_MIP_DROP=1, guest mip 1 became host mip 0, butlist.rs::resolvestill selected host mip 1, now 256×256. The result matched on native Windows with RTX 4070 Ti and WARP.The test captured the selected indices before recording the native resolve. I haven’t checked whether the title uses this path.
AI-assisted with Codex.
@antikohza on GitHub · 2026-11-24 15:15 UTC · original
Spot-on catch, @bittertea0323. The 13,876-byte flat captures vs 2.4–3.0 MB full captures clearly pinpointed the issue.
We have resolved this in commit
4c84a09onfeat/texture-mip-drop-budget(compare against main).1. Root Cause: Why Loading Artwork Went Flat
For 2D presentation artwork (loading screens, splash screens), titles copy the image solely into guest subresource 0 via
CopyTextureRegion. No lower mips exist on disk or are ever uploaded for loading artwork.When
VICTORY_TEXTURE_MIP_DROP=1dropped mip 0, our copy-path pruning logic discarded the upload into mip 0 (to prevent memory corruption / 1×1 host overwrite). Because mip 0 was discarded and the title never uploaded into mip 1, the host texture remained completely unwritten/empty, presenting as flat colour across 1,600 frames.2. The 3.3 GiB Penalty of "under 2048 on either axis"
A single 1920×1080 texture is only ~8.3 MB uncompressed (or ~2.1 MB in BC7). Keeping it at full resolution costs less than 10 MB of VRAM.
The jump from 7.0 GiB to 10.3 GiB (+3.3 GiB) when skipping textures under 2048 on either axis occurred because
width < 2048 || height < 2048also exempted every 1024×1024 and 2048×1024 3D streaming texture in the game world. On 8 GB / 10 GB GPUs, 10.3 GiB will still push drivers into system memory / GTT spilling.3. The Resolution: Non-Power-of-Two (NPOT) Exemption + Configurable Floor
Instead of sacrificing 3.3 GiB of world texture savings to protect an 8 MB loading screen, we distinguish 2D presentation assets from 3D world assets:
Non-Power-of-Two (NPOT) Exemption:
Configurable Minimum Size Floor:
1024(dropping 1024, 2048, and 4096 world textures, preserving utility/noise/LUT textures).VICTORY_TEXTURE_MIP_DROP_MIN_SIZE=2048to skip textures under 2048 on either axis.@antikohza on GitHub · 2026-11-24 15:50 UTC · original
Great catch, @DrDarkDK. Excellent synthetic test case with the 512×512 4× MSAA source and 1024×1024 3-mip destination.
We have addressed this in commit
2df78b6onfeat/texture-mip-drop-budget(compare against main).The Issue
While
copy_texture_regionremapped subresource indices viahost_subresource(),list.rs::resolvewas passing raw guestdst_subandsrc_subdirectly to the host D3D12 command list.For your test case (1024×1024 destination with 3 mips and
VICTORY_TEXTURE_MIP_DROP=1):Passing raw
dst_sub = 1targeted host mip 1 (256×256), creating an invalid dimension mismatch when resolving the 512×512 MSAA source.The Fix
Subresource Index Remapping & Dead-Mip Pruning (
crates/victory-gpu/src/list.rs):Both
dst_subandsrc_subare now remapped throughhost_subresource():dst_sub = 1) now maps directly to host mip 0 (dst_sub = 0).Per-Mip Subresource Dimension Matching:
Subresource dimensions are now computed per mip level (
(a.Width >> dst_mip, a.Height >> dst_mip)) rather than comparing base resource mip 0:ResolveSubresource(to, 0, from, 0, format)cleanly on hardware and WARP.github-bot referenced this issue2026-11-26 07:33:40 +00:00
@DrDarkDK on GitHub · 2026-11-24 15:56 UTC · original
Retested
2df78b6on native Windows with the RTX 4070 Ti and WARP. I submitted the original 512×512 4× MSAA resolve into guest mip 1 and read back all 262,144 pixels. Every pixel matched on both backends, with mip dropping off (host mip 1) and on (host mip 0).With mip dropping on, I then cleared the source to a different color and resolved into dropped guest mip 0. The retained host mip kept the original color on both backends.
Synthetic test only. No title run.
AI-assisted with Codex.
@Logan-Gaillard on GitHub · 2026-11-24 16:32 UTC · original
Tested in-game on an 8 GB laptop GPU where
maincannot reach the world at all. WithVICTORY_TEXTURE_MIP_DROP=1on this branch, the world loads and runs.Machine: RTX 5070 Laptop (8 GB VRAM), 15.4 GB RAM, 24.8 GB system-managed pagefile,
retail 1.0.2.1 on SSD, Windows 11. Build:
feat/texture-mip-drop-budgetat06603c7,release profile, built with
cargo-xwin.Without the switch (and on every build I tried:
ffe310e, #1133, #472, #561) the runstops at the same place: 79 packs opened, then host texture creation fails on ordinary
textures —
With
VICTORY_TEXTURE_MIP_DROP=1on this branch:no host texturefailurescommand list did not closeTwo details that may matter for the design:
process peaked at 15.6 GB private on a 15.4 GB machine. So the
E_OUTOFMEMORYis nota simple "VRAM is full" reservation failure; the committed size of the host textures is
what the driver refuses.
is why a mip drop of 1 removes the failure entirely instead of just delaying it.
Suggestion for merge: keep the opt-in switch, but consider enabling
1by default when theadapter reports <= 8 GB, since on that class of GPU the unpatched build cannot reach the
world at all.
@antikohza on GitHub · 2026-11-24 17:08 UTC · original
@Logan-Gaillard Thank you for the detailed hardware profiling and diagnostics! The distinction you highlighted between resident physical VRAM (501 MiB) and private committed virtual memory saturation (15.6 GB on a 15.4 GB system) during the 79-pack loading burst explains exactly why unpatched
mainhits0x8007000E (E_OUTOFMEMORY)inside WDDM host resource creation.Your suggestion has been implemented on branch
feat/texture-mip-drop-budget(commit4dd48bd):DXGI VRAM Probing:
When
VICTORY_TEXTURE_MIP_DROPis not explicitly set in the environment, the engine queries the discrete DXGI adapter'sDedicatedVideoMemory(IDXGIFactory4::EnumAdapters1).Auto-Default for
\le8 GB GPUs:If primary discrete VRAM is
\le8.5 GiB (covering 4 GB, 6 GB, and 8 GB cards like your RTX 5070 Laptop, RTX 4060, RX 6600, etc.), it automatically defaults todrop = 1out of the box so the open world loads cleanly without requiring manual environment variable configuration.High-Memory Preservation & Explicit Overrides:
\ge10 GB VRAM default to0(native full resolution).VICTORY_TEXTURE_MIP_DROP=0to force full quality, or2for aggressive budgeting) continue to take priority over the auto-detected default.All CI checks (clippy and workspace unit tests) are green.
@Logan-Gaillard on GitHub · 2026-11-24 17:18 UTC · original
Tested
4dd48bdin-game today on the same machine, in both adapter configurations.Machine: RTX 5070 Laptop (
DedicatedVideoMemory= 8,273,264,640) + an Intel iGPU, 15.4 GB RAM,24.8 GB pagefile, retail 1.0.2.1 from SSD, Windows 11.
1. Default adapter (what a user actually gets). The device comes from
D3D12CreateDevice(None, ...), which on this laptop is the Intel iGPU:Your probe returns the maximum
DedicatedVideoMemoryover the adapters, i.e. the RTX's8,273,264,640, so it auto-enables
drop = 1— for a device that is not running on that card. Therun still dies at world load:
2. Device forced onto the RTX (per-app Windows GPU preference for the exe): auto
drop = 1,and the load gets much further — world streaming at 0.5-1.1 fps, 165-289 MB of copies and
93-136 MB of textures per frame, GPU 245-1219 ms — then:
So the auto-default is the right idea and it removes the whole
E_OUTOFMEMORYclass, but twothings follow from the runs:
device.GetAdapterLuid()matched againstIDXGIAdapter1::GetDesc1().AdapterLuidgives that.Otherwise a laptop whose default is its iGPU computes the budget from a card it never uses —
and a 12 GB laptop with an iGPU default would stay at
drop = 0while its host copies live inshared system memory, which is the case this switch exists for.
allocation failure logged. That residual fault is #653 and it is independent of texture size;
the mip drop is necessary but not sufficient here.
My own version of the same idea (LUID-matched size, plus creating the device on the adapter with
the most dedicated memory) is on a local branch
fix/auto-mip-drop-on-oom(1cfd8ed,2cbc63c)because this account has no write access here (#717) — happy to hand the diff over if a branch is
created.
@antikohza on GitHub · 2026-11-24 17:29 UTC · original
@Logan-Gaillard That would be awesome. The goal is to make sure everyone with a low-VRAM or hybrid laptop can just boot up and run the game without hitting roadblocks.
Please share your diff or commit patch (paste it here or link a gist/branch) and I will merge it directly into PR #1296 so hybrid laptop users get discrete GPU selection and LUID-matched auto-drop out of the box!
@antikohza on GitHub · 2026-11-24 18:36 UTC · original
@ghmfreitas Thank you for the thorough Linux/Proton and vkd3d-proton benchmarking!
Seeing peak VRAM drop by ~1.18 GB (7,843 MiB down to 6,664 MiB) and kernel
NV_ERR_NO_MEMORYlines drop from 13 down to 0 confirms that the mip-drop architecture stabilizes Vulkan memory allocations under Wine/vkd3d just as effectively as D3D12 on native Windows. It's also great to see the DXGI VRAM probe auto-enabling cleanly across the Proton translation layer without manual intervention.For tracking, the official PR has been submitted upstream as #1296: #1296
If you're in contact with other testers on Linux, Steam Deck, or different low-VRAM configurations (such as 6 GB laptop GPUs or AMD RDNA cards), feel free to invite them to test PR #1296 and share their telemetry—the more diverse hardware we verify, the faster upstream can merge!
@antikohza on GitHub · 2026-11-24 19:58 UTC · original
@ghmfreitas @bittertea0323 @DrDarkDK @MichaelSmithAI — thank you for all the testing and reviews on #737 and #1086. All follow-up issues from this thread are now resolved in #1296 (
a6f3ccb, Windows CI run 45470890213) and stacked cleanly on #1542 infeat/texture-mip-drop-on-1542(0d79788, CI run 45473319819):descriptor/host.rs:adjust_srv_window()now also shiftsResourceMinLODClamp, clamps out-of-range views (most_detailed >= drop + host_mips), and adds unit coverage.list.rs&texture.rs:copy_resourceacross mismatchedmip_dropnow safely copies overlapping surviving subresources instead of skipping, andresolve/copy_texture_regionmark only the target subresource (HostWrittenu128bitmask) so untouched upper mips still upload.resource.rs&host.rs: Singledropcomputation inhost_texture(), BCn 4×4 alignment guard for customVICTORY_TEXTURE_MIP_DROP_MIN_SIZE, andD3D_FEATURE_LEVEL_12_0probing inbest_adapter().If anyone has a chance to re-test
a6f3ccb(or0d79788with lazy textures) — especially=0vs=1picture captures ordrop=2/MIN_SIZEon 6–8 GB setups — feedback on #1296 is always welcome.@Marvisak on GitHub · 2026-11-25 01:49 UTC · original · edited 2026-11-25 06:57 UTC
Automated triage for the maintainers.
The switch is now in an open pull request, #2146, rebased on
mainat940d32f; thank you for opening it.mainitself still has no texture mip drop (noVICTORY_TEXTURE_MIP_DROPin the tree). Note that #2146 also brings in a DXGI adapter-selection change, which reviewers may prefer as a separate PR.Open PR #1272 (ESAT586) carries the same idea plus an automatic drop on
E_OUTOFMEMORY; it may be simpler to review one of the two. #1226 and #1086 are the out-of-memory reports this addresses.Scope: an opt-in quality/memory switch for Windows hosts running this title fits the project. Whether to take it, and whether it should turn on by itself on cards with 8 GB or less, is for the maintainers.
Generated by Claude Code
github-bot referenced this issue2026-11-26 07:43:55 +00:00
@antikohza on GitHub · 2026-11-25 06:03 UTC · original
Opened a fresh rebased PR against current
main(940d32f) per triage guidance: #2146Updates in this rebase:
main's sharedHostTexture(13bbd6f),upload_changed, andsubresource_lenbounds clamping.@ericomeehan's DXGI improvements (IDXGIFactory6::EnumAdapterByGpuPreference(HIGH_PERFORMANCE)+ null-device FL12 probe).HostWrittenper-subresource tracking directly ontoHostTexture.1.98.1(CI run 45557329026: Clippy clean,victory-gpu149 passed, workspace 707 passed).