GPU: automatic texture mip-drop on E_OUTOFMEMORY and VICTORY_TEXTURE_MIP_DROP #1272
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!1272
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1272"
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?
@ESAT586 on GitHub · 2026-11-24 16:59 UTC · original
ESAT586:gpu/auto-mip-drop→main· +1474 −97 · 5 files · 3 commits · openSummary
Addresses #1226 and #737 by introducing automatic texture mip-drop recovery on
E_OUTOFMEMORYalongside the opt-inVICTORY_TEXTURE_MIP_DROP(0..=3, default0) quality switch, complete with end-to-end SRV re-basing, staging detile offsetting, and command-list subresource remapping/pruning so mip-dropped textures never invalidate host command lists.On machines with sufficient VRAM/commit headroom (
VICTORY_TEXTURE_MIP_DROPunset and noE_OUTOFMEMORY),mip_dropremains0and behavior is bit-identical tomain. On 6 GB / 8 GB GPUs or 16 GB RAM hosts where world streaming hitsE_OUTOFMEMORY(0x8007000E), the first failing pure-sampled texture automatically raisesOOM_MIP_PRESSURE, drops top mip level(s), and retries instead of leaving a null host texture that causes device removal.What Changed
crates/victory-gpu/src/resource.rs)compute_mip_drop: restricts mip dropping to pure sampled textures (dimension != BUFFER,flags & 0x7 == 0,sample_count <= 1,mip_count > 1), keeps a64 pxfloor (avoiding the tiny/1×1 texture shrinkage issue observed in #737 testing), and verifies 4×4 block alignment for BC formats.allocate_with_oom_retry: onE_OUTOFMEMORY, monotonically raisesOOM_MIP_PRESSURE(up toMAX_MIP_DROP = 3), logs a warning, and retriesCreateCommittedResource.HostTexture: trackstitle_mips,mip_drop, andis_3d, and exposeshost_subresource(console_sub) -> Option<u32>for subresource remapping / dropped-mip pruning.crates/victory-gpu/src/texture.rs)mip_droponStagingand reads console miphost_mip + mip_dropduringStaging::detile; staging footprints automatically shrink to match the host texture's reduced mip chain.crates/victory-gpu/src/descriptor/host.rs)rebase_mip_windowandadjust_srv_for_mip_dropacrossTexture1D,Texture1DArray,Texture2D,Texture2DArray,Texture3D,TextureCube, andTextureCubeArray.drop = 2, guest{1,2,3}→ host{0,1}), preservesu32::MAX, clamps all-dropped views to host mip0, and shiftsResourceMinLODClamp.crates/victory-gpu/src/list.rs)copy_texture_region: remaps destination and texture-source subresources viahost_subresource, pruning dead copies that target or read dropped top mips.copy_resource: falls back to subresource-by-subresourceCopyTextureRegionacross overlapping surviving mips when source and destination have different mip-drop counts.resolve: remapsdst_subandsrc_sub, prunes dead resolves to dropped top mips, and compares per-mip extents rather than mip-0 extents.Credits
Built on the design and real-hardware testing findings documented in #737 (
antikohza,MichaelSmithAI,bittertea0323,DrDarkDK) and #1226 (Logan-Gaillard).Verification
All checks run locally on Windows 11 with NVIDIA GeForce RTX 3060 Ti (
Driver 32.0.16.1656), Rust1.98.1MSVC:cargo clippy --workspace --all-targets --locked -- -D warnings— 0 warningscargo clippy --workspace --all-targets --all-features --locked -- -D warnings— 0 warningscargo test -p victory-gpu --locked— 55 passed, 0 failed, 1 ignoredcargo test -p victory-gpu --all-features --locked— 58 passed, 0 failed, 1 ignored (includingmip_dropped_texture_copy_and_srv_work_on_host_gpuend-to-end on RTX 3060 Ti,oom_retry_escalates_pressure_and_recovers,mip_drop_respects_constraints_and_bc_alignment,subresource_remapping_drops_top_mips_and_preserves_slices, andsrv_mip_window_rebasing_handles_partial_full_and_dropped_ranges)cargo xtask policy— 154 files okgithub-bot referenced this pull request2026-11-26 04:56:04 +00:00
@Logan-Gaillard on GitHub · 2026-11-24 17:22 UTC · original
Tested this head (
dfd1bc4) in-game on the machine behind #1226, same route (retail 1.0.2.1from SSD). The mechanism works, but it fires too late to save the world load — the same result I
measured with my own version of the reactive idea.
Run: RTX 5070 Laptop + Intel iGPU, 15.4 GB RAM, 24.8 GB pagefile, Windows 11, release build,
no environment variable set.
Why it cannot work from the failure side. By the time
CreateCommittedResourcefirst returns0x8007000E, the process is already against its commit ceiling (15.6 GB private on a 15.4 GBmachine, system commit at 38.3/38.3 GB in my measurements). Dropping one mip from the texture
that happened to fail buys nothing: the next 1024-wide texture fails too, and the run ends on the
same
command list did not close. In my version of the reactive drop, the pressure level wasraised three times and 86 creations still failed afterwards.
What does work here: the same drop applied from the start of the run instead of on failure.
With
drop = 1decided up front (on this machine, #737's manual switch, and #1296's automaticdefault) the load reaches world streaming with zero
no host textureand zerocommand list did not close.Second point, independent of the drop:
D3D12CreateDevice(None, ...)picks this laptop'sIntel iGPU (128 MiB dedicated), so host copies live in shared system memory. Choosing the adapter
with the most dedicated memory (or honouring the Windows per-app GPU preference) moves the run to
the RTX and changes the failure from an allocation error to a GPU fault much later in the
streaming. Worth having regardless of what the drop does.
So: right diagnosis, wrong moment. Making the level proactive (before the first allocation, from
the device's own adapter memory) is the part that reaches the world.
@ESAT586 on GitHub · 2026-11-24 17:30 UTC · original
Thanks for the live retail test and measurements, @Logan-Gaillard — that pinpoints the exact timing issue cleanly.
Updated this branch with a proactive default before the first texture allocation:
DedicatedVideoMemoryviaIDXGIFactory4::EnumAdapterByLuid(crates/victory-gpu/src/host.rs) and physical RAM viaGlobalMemoryStatusEx(crates/victory-gpu/src/resource.rs).VICTORY_TEXTURE_MIP_DROPis unset, proactively defaults todrop = 1on hosts with<= 8 GiBdedicated VRAM (covering 6/8 GB GPUs and iGPUs) or<= 16 GiBphysical RAM, and keeps0on> 8 GiBVRAM +> 16 GiBRAM machines.VICTORY_TEXTURE_MIP_DROP=0..=3overrides the proactive default (so=0forces native resolution), while the reactiveE_OUTOFMEMORYretry remains as a fallback safety net.cargo clippy --workspace --all-targets --locked -- -D warnings,--all-features,cargo test -p victory-gpu --all-features --locked: 59 passed / 0 failed,cargo xtask policy: ok).(Authored and verified by Gemini 4 Neon — High Mode; synthetic tests only, no game data.)
@ESAT586 on GitHub · 2026-11-24 18:39 UTC · original
Thanks for the thorough review and exact reproduction, @fladit123 — that caught a real subresource-ownership bug.
Fixed in the latest push on this branch:
crates/victory-gpu/src/texture.rs: Replaced resource-wideHOST_WRITTEN: HashSet<usize>withHashMap<usize, HostWritten>(HostWritten::AllvsHostWritten::Subresources(HashSet<u32>)) sotexture::upload()skips only subresources actually written by the host GPU while still uploading untouched upper mips.crates/victory-gpu/src/list.rs: Movedtexture::host_written(dst)onto the full-resourceCopyResourcepaths only; the cross-mip-dropCopyTextureRegionfallback loop now recordstexture::host_written_subresource(dst, dst_sub)per copied host subresource.crates/victory-gpu/src/resource.rs: Addedpartial_copy_resource_preserves_untouched_mip_uploadscovering all three GPU readback controls (no-copy control, full-copy control, and256x48RGBA8 6-mipsrc drop=2 -> dst drop=1partial-copy integrity: untouched guest mip 1 reads updated0xC8while copied guest mip 2 preserves GPU-copied0x55).Verified locally on Windows 11 with NVIDIA GeForce RTX 3060 Ti and WARP (
VICTORY_D3D12_WARP=1):cargo test -p victory-gpu --all-features --locked(RTX 3060 Ti): 60 passed, 0 failedVICTORY_D3D12_WARP=1 cargo test -p victory-gpu --locked partial_copy_resource_preserves_untouched_mip_uploads: 1 passed, 0 failedcargo clippy --workspace --all-targets --locked -- -D warnings&--all-features: passcargo xtask policy: 154 files ok(Authored and verified by Gemini 4 Neon — High Mode; synthetic tests only, zero game data.)
@Marvisak on GitHub · 2026-11-25 01:20 UTC · original · edited 2026-11-25 16:03 UTC
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-gpu/src/descriptor/host.rs,crates/victory-gpu/src/list.rs,crates/victory-gpu/src/resource.rs,crates/victory-gpu/src/texture.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (needs-work) was for an older state ofmain.Generated by Claude Code
@ESAT586 on GitHub · 2026-11-25 14:21 UTC · original
Rebased cleanly onto
main(940d32f) at37b5b93(resolved the adjacent test conflict incrates/victory-gpu/src/descriptor/host.rs, keeping bothdynamic_search_can_find_a_run_across_the_cursorandsrv_mip_window_rebasing_handles_partial_full_and_dropped_ranges). Re-verified on RTX 3060 Ti + WARP: all mip-drop, proactive VRAM/RAM default, partial-copy, and SRV rebasing tests pass; strict Clippy (--all-targetsand--all-features) clean;cargo xtask policyok.@fladit123 on GitHub · 2026-11-24 18:00 UTC · original · requested changes
Independent validation of
356d55f19f486fc8853b686e15c8436395b47997.The OOM recovery mechanism is promising, but I found a blocking texture-content correctness issue that persists after the proactive mip-drop update.
Finding: partial CopyResource suppresses uploads of untouched destination subresources
In
list.rs,copy_resource()callstexture::host_written(dst)before determining which subresources will actually be copied.With different mip-drop levels, the fallback copies only overlapping surviving mips. However,
texture.rstracks HOST_WRITTEN at resource granularity, causing subsequent uploads of the entire destination texture to be skipped.Synthetic reproduction
0xA4instead of expected0xC8.Both backends reproduced the issue in separate processes. The controls distinguish this finding from the intended upload suppression following a full-resource copy.
Suggested change
Please ensure that partial copies preserve correct ownership and upload behavior for destination subresources that were not written, while retaining the contents of successfully copied subresources.
A regression test should verify both properties through GPU readback. Simply removing HOST_WRITTEN suppression entirely could overwrite valid GPU-written contents.
Environment
Limitations: The focused validation used a zero-byte BCPack placeholder, with the original table excluded. The reproduction uses an additional synthetic test in an isolated worktree, not an unmodified full-workspace validation. No game files or proprietary console SDK data were used.
I have a standalone regression-test patch and supporting readback logs available.
AI use: OpenAI Codex assisted with test implementation and execution; ChatGPT (GPT-6.2) assisted with code review and reporting.
Requesting changes for the partial-copy correctness issue.
@fladit123 on GitHub · 2026-11-24 19:30 UTC · original · approved these changes
Thanks for addressing the finding!
I independently revalidated
ccd13f80949a36c9ca6c7c3b736724fd37cee3dfusing your new regression test on both the RTX 4060 and WARP, in separate processes.After the partial copy, the untouched mip correctly accepted
0xC8, while the copied mip retained0x55.Test-only instrumentation confirmed the active D3D12 adapter and prevented an early return if host initialization failed. All original readback assertions remained unchanged.
Limitations: The focused build used a zero-byte synthetic BCPack placeholder. Validation covered the first row of the sampled RGBA8 mips. The full workspace suite and retail titles were not tested.
My previously reported blocking finding is resolved. Approving with respect to that finding.
AI use: OpenAI Codex (GPT-6) assisted with local validation and reporting. ChatGPT (GPT-6.2) assisted with review and interpretation.
@potatoe0100 on GitHub · 2026-11-26 14:21 UTC · original
Two things for the rebase onto current
main(63bcca4). I tried merging37b5b93here: 13 conflict hunks indescriptor/host.rs,list.rs,resource.rsandtexture.rs.mainnow has a real texture-to-buffer read-back.copy_texture_regioncallsread_back(list, &dst, ..., &src, source_box)where this branch still has the "not implemented" warning.read_back(list.rs:816) gets the mip assrc.footprint.offset % desc.MipLevelsfrom the host texture's desc. With a mip drop the host has fewer levels than the title, so a read-back of a dropped-mip texture would read the wrong level. It needs the samehost_subresourceremapping as the copy paths (and should skip dropped top mips).copy_resourceonmainnow marks the destination withcrate::texture::host_writes(list, dst)(per list) instead ofhost_written(dst). So the per-subresourceHostWrittentracking here needs carrying over to the list-based version.Also worth saying in the description: the proactive default turns mip drop on for every card with 8 GiB or less, and an RTX 4060 8 GB counts. That is what 8 GB players need (the 8 GB forks run with mip dropping on), but it changes the default look on those cards.
AI-assisted (Claude).
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.Merge
Merge the changes and update on Forgejo.