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!1296
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1296/head"
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 17:13 UTC · original
antikohza:feat/texture-mip-drop-budget→main· +850 −41 · 6 files · 8 commits · closed without mergingResolves #737, resolves #1226.
Summary
Introduces a proactive texture mip-drop subsystem and quality switch (
VICTORY_TEXTURE_MIP_DROP, clamped0..=3), plus discrete GPU adapter selection and automatic LUID-matched VRAM detection that defaultsdrop = 1on GPUs with\le 8\text{ GiB}dedicated VRAM.Primary verified result: Eliminates
E_OUTOFMEMORY (0x8007000E)host allocation failures and driver commit exhaustion during world loading on 6–8 GB cards (~1.1–1.2 GiB VRAM saved, keeping process commit within budget so world streaming proceeds instead of crashing at 79 packs). Frame pacing in world streaming (~0.5–1.1 FPSon Windows /~10 s/frameon Proton) remains governed by CPU-side memory copies (#834), not mip-drop.Root Cause Analysis (Profiled by @Logan-Gaillard)
During world loading on an 8 GB VRAM / 15.4 GB RAM hybrid laptop:
D3D12CreateDevice(None, ...)picked the Intel iGPU (128 MiB dedicated), pushing host texture copies into shared system memory and failing on submission 1 (0x887A0004).nvidia-smiphysical VRAM sat at 501 MiB, causingE_OUTOFMEMORY (0x8007000E)andcommand list did not close.\ge 1024\text{ px}), allocation pressure drops by ~75% from pack 1, keeping commit under ceiling with 0no host texturefailures.Key Features & Design Choices
Discrete GPU Selection & LUID-Matched VRAM Detection (
host.rs,texture.rs):best_adapter()probes non-software DXGI adapters supportingD3D_FEATURE_LEVEL_12_0and picks the card with the largestDedicatedVideoMemory(with fallback toD3D12CreateDevice(None, ...)), preventing hybrid laptops from defaulting to the 128 MiB iGPU.adapter_memory()matchesdevice.GetAdapterLuid()against DXGI adapter LUIDs and stores it inDEVICE_MEMORY.texture_mip_drop()readsdevice_memory()live (no staleOnceLockcaching), automatically defaulting todrop = 1when\text{VRAM} \le 8.5\text{ GiB}. ExplicitVICTORY_TEXTURE_MIP_DROP=0..=3always takes precedence.NPOT / UI Exemption, Size Floor & BCn Alignment (
resource.rs):1920×1080,1280×720,2560×1440) so loading artwork and UI surfaces remain at native resolution.VICTORY_TEXTURE_MIP_DROP_MIN_SIZEfloor (default1024, e.g.2048for conservative mode) and preserveselement(pc_format(format))block alignment (4×4 for BC1–BC7) whenMIN_SIZEis lowered.host_texture()returns(ID3D12Resource, u32)soHostTexture.mip_dropis computed once and cannot drift from the actual resource.SRV Window Re-basing, Clamping &
ResourceMinLODClamp(descriptor/host.rs):MostDetailedMip, clampsMipLevels, and shiftsResourceMinLODClamp((min_lod - drop as f32).max(0.0)) uniformly across all 7 SRV dimensions (1D,1DArray,2D,2DArray,3D,Cube,CubeArray), clamping out-of-range views tohost_mips - 1.Command-List Copy, Partial Copy & Resolve Mapping (
list.rs,texture.rs):copy_texture_regionandresolve: Remap guest subresource indices viahost_subresource(), discard copies/resolves into dropped mips, and clipResolveSubresourceRegionusing mip-adjusted dimensions.copy_resource: When source and destination differ inmip_drop(e.g., RT/UAV to sampled texture), safely copies overlapping surviving mips viaCopyLocation::subresource(...)without raw pointer transmutes.HostWritten: Tracks partial host writes per subresource via a zero-allocationu128bitmask (withHashSet<u32>fallback for\ge 128subresources) so untouched upper mips stay eligible for title-memory upload.Hardware & Test Verification
@Logan-Gaillard, #737 / #1226 / #653): Eliminated all 40+E_OUTOFMEMORYfailures andcommand list did not close; reaches world streaming (726 draws/frame,0.5–1.1 FPSbefore separate residual#653fault; loading/menu screen runs at30 FPS / 11 draws/frame). Local LUID +best_adaptertest confirmed RTX selection (8,273,264,640bytes) anddrop = 1.@ghmfreitas, #737): Tested4dd48bd(auto): peak VRAM 7,843 MiB → 6,664 MiB (~1.18 GiB saved), kernelNV_ERR_NO_MEMORY13 → 0, ran 15 min world streaming (200+ draws/frame,~9.8–12.0 s/frameCPU-copy bound).@bittertea0323, #1086): Reduced peak VRAM 11.3 GiB → 10.3 GiB (~1 GiBsaved with 2048 floor), fitting the world stage under 12 GB.@DrDarkDK, #737): MSAA resolve readback verified bit-for-bit across all 262,144 pixels on both hardware and WARP.@geiyiliyabumo, #1296): Verified4dd48bd(victory-gpu: 54 passed, 0 failed; clippy +xtask policyclean).@Logan-Gaillard on GitHub · 2026-11-24 17:19 UTC · original
Tested this head (
4dd48bd) in-game on the machine the issue came from, in both adapterconfigurations. The memory half is solid; the probe reads the wrong card on this class of laptop.
Machine: RTX 5070 Laptop (
DedicatedVideoMemory= 8,273,264,640) plus an Intel iGPU,15.4 GB RAM, 24.8 GB pagefile, retail 1.0.2.1 from SSD, Windows 11, release build.
1. Default adapter — what a user gets without touching anything. The device comes from
D3D12CreateDevice(None, ...), which on this laptop is the Intel iGPU:The probe takes the maximum
DedicatedVideoMemoryacross adapters (the RTX), so it auto-enablesdrop = 1for a device that is not on that card. The run 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, 245-1219 ms on the GPU — then:
Request. Measure the adapter the device was created on, not the best one:
Otherwise a laptop whose default is its iGPU computes its texture budget from a card it never
uses, and a 12 GB laptop with an iGPU default stays at
drop = 0while its host copies live inshared system memory — the exact case this switch is for. Creating the device on the adapter with
the most dedicated memory would also do it, and would help the frame rate on this class of
machine independently of the mip drop.
For the record, even on the right adapter world streaming still removes the device here with no
allocation failure in the log: that residual fault is #653 and is independent of texture size, so
this PR resolves the memory failure (#1226) but not world entry on this hardware.
@Logan-Gaillard on GitHub · 2026-11-24 17:24 UTC · original
Since the probe is the one open point, here is the concrete patch I ran here (from my local
fix/auto-mip-drop-on-oombranch, built and tested on the same laptop). It replaces "the bestadapter's memory" with "the memory of the adapter the device was actually created on", and
optionally creates the device on the best adapter in the first place.
crates/victory-gpu/src/host.rs— remember the device's own card:called right after
let device = device.ok_or_else(...)?;:crates/victory-gpu/src/texture.rs— read that live instead of enumerating:Read it live rather than caching it in a
OnceLock: the first call can happen while the device isstill being created, and a cached
0then keeps the drop off for the whole run (that is exactlyhow my first attempt silently did nothing).
Optional, and worth it on this class of machine — create the device on the biggest card
instead of DXGI's default, which is the iGPU on most laptops:
with
best_adapter()returning the non-softwareIDXGIAdapter1with the largestDedicatedVideoMemory.Measured here with both parts in place:
host adapter adapter=NVIDIA GeForce RTX 5070 Laptop GPU,host device memory bytes=8273264640,texture mip drop drop=1 asked=0, world streaming withzero
no host texture, before the residual #653 fault. Without the LUID part, the same build onthe same machine logs
host adapter adapter=Intel(R) Graphics, drops detail based on a card it isnot using, and still dies at the first submission.
@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 this PR so hybrid laptop users get discrete GPU selection and LUID-matched auto-drop out of the box!
@geiyiliyabumo on GitHub · 2026-11-24 17:35 UTC · original
Independent verification of \
4dd48bd\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200, 16 GB VRAM) / Rust 1.98.1 MSVC:Minor edge-case note in \djust_mips\ (\descriptor/host.rs:646): if a guest view has *most_detailed >= drop + host_mips, clamping *most_detailed = (*most_detailed).min(host_mips.saturating_sub(1))\ before computing \max_mips\ avoids passing an out-of-range \MostDetailedMip\ with \MipLevels = 1\ to \CreateShaderResourceView. (Live <= 8 GB VRAM auto-default path not triggered on this 16 GB GPU.)
AI-assisted; synthetic tests only, no game files.
@antikohza on GitHub · 2026-11-24 18:44 UTC · original
@Logan-Gaillard @geiyiliyabumo Head updated to
814c580with all checks green:Discrete GPU Selection & LUID Matching:
Host::createnow selects the non-software adapter with the mostDedicatedVideoMemoryviabest_adapter(), completely bypassing the 128 MiB Intel iGPU trap on hybrid laptops.adapter_memorymatchesdevice.GetAdapterLuid()against DXGI adapter LUIDs to ensure the exact device memory is recorded.texture_mip_drop()readsdevice_memory()live, avoiding stale early caching.Descriptor Clamping:
*most_detailedinadjust_mips(descriptor/host.rs) tohost_mips.saturating_sub(1)as suggested by @geiyiliyabumo to guard out-of-range guest SRV descriptors.All workspace unit tests and clippy checks pass clean.
@crashbashash on GitHub · 2026-11-24 18:50 UTC · original
The test line in the description ("loading into the open world at 29–30 FPS (34.4 ms/frame, 11 draws/frame)") and the "Open World: 29–30 FPS / 34.4 ms" row look out of date. 11 draws per frame is a loading or menu screen: the title sits at exactly that pacing in the menus on my machine too (30.0 fps / 33.3 ms, RX 6800 XT, Proton).
@Logan-Gaillard's later runs on this PR have world streaming at 0.5–1.1 fps, and in one run 726 draws per frame at about 1.4 s per frame before the device was removed. His summary: the PR fixes the memory failure (#1226) but not world entry on that laptop. @ghmfreitas's A/B in #737 shows world pacing doesn't change with the drop (9.8 s per frame off, 10.5–12.0 s on, most of it CPU-side copies, #834).
So the result to state is the memory one (about 1.1 GB less VRAM, no allocation failures, commit kept under ~5 GB), not a frame rate.
No game data used. AI-assisted (Claude Code).
@antikohza on GitHub · 2026-11-24 19:46 UTC · original
Updated to
a6f3ccb(CI green: run 45470890213):@crashbashash): Replaced the29–30 FPS / 11 drawsworld-load wording with the verified VRAM/commit savings (~1.1–1.2 GiB saved, 0E_OUTOFMEMORY/ kernelNV_ERR_NO_MEMORYerrors), clearly distinguishing loading/menu pacing (30 FPS / 11 draws) from CPU-copy-bound world streaming (#834).a6f3ccb):descriptor/host.rs: shiftedResourceMinLODClampuniformly across all 7 SRV dimensions and added tests formost_detailed >= drop + host_mipsandResourceMinLODClamp.resource.rs:host_texture()returns(ID3D12Resource, u32)once (no duplicatecompute_mip_dropcall) and guardselement(pc_format(format))BCn 4×4 block alignment whenVICTORY_TEXTURE_MIP_DROP_MIN_SIZEis lowered.list.rs&texture.rs: replaced themip_dropmismatch skip incopy_resourcewith safeCopyLocation::subresourceoverlapping-mip copies and a zero-allocu128bitmask (HostWritten) for partial copies/resolves.host.rs: addedsupports_fl12probe insidebest_adapter()and default-adapter fallback inHost::create().#1542(#431+#967+#1418/#1426/#1439): Maintained a clean rebased branch atantikohza:feat/texture-mip-drop-on-1542(0d79788, Windows MSVC CI green: run 45473319819) in case#1542lands before this PR.RTX 4060) D3D12 compatibility, 2s TDR submissions, and 16 GB host OOM #1076@pfhandler on GitHub · 2026-11-24 20:50 UTC · original
Local patches for two issues hit while running GTA VI 1.0.2.1 through VIctory on Linux (GE-Proton 11-14, vkd3d-proton 3.2.0, RTX 4060 Ti 8 GB):
VICTORY_NO_HOST_PAD=1— a connected host pad (e.g. DualShock appearing as XInput pad 0) keeps the keyboard stand-in pad from being enumerated. Hiding the host pad letsVICTORY_KEYSdrive the title again.VICTORY_MODE=1920x1080— the DXGI output mode list is fixed at the console's 3840x2160. Reporting 1920x1080 instead keeps the title's render targets and VRAM use down on smaller hosts (Series S profile + 1080p settled around 3.5 GB VRAM here).Both are local uncommitted diffs, posted here for reuse. Tested only on the configuration above.
@cyudev on GitHub · 2026-11-24 21:57 UTC · original
RTX 3060 Ti (8 GB): #578 + #1296 + #1666 on
mainholds 16+ minutes in the world, under the video memory budgetMachine: RTX 3060 Ti 8 GB (driver 621.24, 32-lane waves), i5-12600KF, 16 GB RAM, Windows 11 26200, game files on SATA SSD. Series X profile.
Tree:
mainffe310e+ #578 (pr-578head) + #1296 (a6f3ccb) + #1666 (a672556). All three merge cleanly. Diagnostics build, fresh shader cache, onlyVICTORY_LOG=infoset.Result: world entered at ~21:42 UTC and still running at 21:58 with no device removal, no
ERROR, nono upload buffer, nocrashes.log. The 3D scene is black, as on every card, with sound and subtitles.integration/testersu10, ± #1666)E_OUTOFMEMORYand device removalMemory figures come from #1666's
host memory:line (QueryVideoMemoryInfo), every 5 s.What each did, by the log:
auto-enabling VICTORY_TEXTURE_MIP_DROP=1 for <= 8 GB GPU (vram_mb=8024). Video memory stayed ~3 GB lower than without it, which brings this card under budget.host wave lanes min=32 max=32, then one log line each for refused wave64 programs: compute (052a2316a03b9ba1), mesh, and compute with PSV0[64, 64]. No hang; that matches #1508's RTX 4060 Laptop run (579 s with #578).Still there: 512
shader does not translatelines; ~4,250 draws dropped per frame without a host pipeline and ~4,900 indirect.no host texturecomes up for formats 86 and 115, the packed 16-bit targets #89 handles; #89 is not in this tree.The two runs are not the same tree: u10 carries far more translated shaders and therefore more GPU work. So the time comparison says this set is stable on 8 GB. It does not isolate which PR buys the stability.
Counts and messages only; no game data.
@ericomeehan on GitHub · 2026-11-24 23:34 UTC · original
The memory numbers and Logan-Gaillard's hybrid-laptop runs make a good case, and picking the discrete GPU fixes a real trap (the 128 MiB iGPU and 0x887A0004 on the first submission).
Two small suggestions on
best_adapter, from reading the diff:IDXGIFactory6::EnumAdapterByGpuPreference(0, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE)is the standard way to get the discrete GPU, and unlike "most dedicated VRAM" it respects the per-app GPU choice the user set in Windows' graphics settings (useful on machines with two discrete cards or an eGPU).supports_fl12creates a full device on every adapter.D3D12CreateDevicewith a null device out-pointer only checks that the adapter supports the feature level, without creating a device.Separately, the adapter choice is small and useful on its own, and might be easier to take as its own PR than together with the mip drop; and because the automatic mip drop on 8 GB cards changes image quality for every such user, an opt-in switch that only logs "would drop 1" by default might be easier to accept.
Written with an AI assistant (Claude).
@Witredd on GitHub · 2026-11-24 23:54 UTC · original
A data point from a 6 GB card, in case it helps scope the 6–8 GB claim.
RX 5600 XT 6 GB (RDNA1, no mesh shaders), Ryzen 7 5700X, 16 GB RAM, Windows 11. The card has no mesh shaders, so the world needs #961: this is #961 (
31568ce) with this PR merged on top (clean merge, both onffe310e), release build. Memory is the process's GPU counters, sampled every 2 s.VICTORY_TEXTURE_MIP_DROP=2=3and--console series-sThe mip drop gets the run further, but on 6 GB it is not enough: in every run the card fills as soon as the world loads. What fails is not textures but
no shader-writable buffer(1–32 MiB, about 1,400 of the 32 MiB ones),no upload buffer(4 MiB) andno shared buffer, ending ina host command list did not close (0x8007000E). On this card the remaining pressure looks like the title-memory copies (#880 / #407) rather than texture memory.@Marvisak on GitHub · 2026-11-25 00:36 UTC · original
Automated triage for the maintainers. Closing because another open pull request covers the same change.
See #1272. Same mip-drop feature as #1272, but on by default for cards up to 8 GB and with a change of adapter selection on the side.
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
@antikohza on GitHub · 2026-11-25 06:04 UTC · original
@ericomeehan @cyudev @Witredd @Logan-Gaillard — thank you for the review and hardware data. Since #1296 and #1617 were closed before merge and
mainmoved to940d32f, I opened a clean rebased PR at #2146 (including@ericomeehan'sEnumAdapterByGpuPreference(HIGH_PERFORMANCE)and null-device FL12 probe suggestions, plus reconciliation with sharedHostTexture).Pull request closed