Skip to content

GPU: add VICTORY_TEXTURE_MIP_DROP and DXGI auto-default for <= 8 GB GPUs (fixes #737, #1226) - #1296

Closed
antikohza wants to merge 8 commits into
Marvisak:mainfrom
antikohza:feat/texture-mip-drop-budget
Closed

antikohza wants to merge 8 commits into
Marvisak:mainfrom
antikohza:feat/texture-mip-drop-budget

Conversation

@antikohza

@antikohza antikohza commented Nov 24, 2026 •

Copy link
Copy Markdown

Resolves #737, resolves #1226.

Summary

Introduces a proactive texture mip-drop subsystem and quality switch (VICTORY_TEXTURE_MIP_DROP, clamped 0..=3), plus discrete GPU adapter selection and automatic LUID-matched VRAM detection that defaults drop = 1 on 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 FPS on Windows / ~10 s/frame on 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:

  1. Default iGPU selection trap: D3D12CreateDevice(None, ...) picked the Intel iGPU (128 MiB dedicated), pushing host texture copies into shared system memory and failing on submission 1 (0x887A0004).
  2. Commit quota exhaustion: On the discrete card or default heap, opening 79 packs creates thousands of committed host textures; Windows Private Committed Memory spiked to 15.6 GB on a 15.4 GB machine (38.3 GB commit limit) even while nvidia-smi physical VRAM sat at 501 MiB, causing E_OUTOFMEMORY (0x8007000E) and command list did not close.
  3. Why proactive beats reactive: By halving dimensions upfront across pure sampled POT textures ($\ge 1024\text{ px}$), allocation pressure drops by ~75% from pack 1, keeping commit under ceiling with 0 no host texture failures.

Key Features & Design Choices

  1. Discrete GPU Selection & LUID-Matched VRAM Detection (host.rs, texture.rs):

    • best_adapter() probes non-software DXGI adapters supporting D3D_FEATURE_LEVEL_12_0 and picks the card with the largest DedicatedVideoMemory (with fallback to D3D12CreateDevice(None, ...)), preventing hybrid laptops from defaulting to the 128 MiB iGPU.
    • adapter_memory() matches device.GetAdapterLuid() against DXGI adapter LUIDs and stores it in DEVICE_MEMORY.
    • texture_mip_drop() reads device_memory() live (no stale OnceLock caching), automatically defaulting to drop = 1 when $\text{VRAM} \le 8.5\text{ GiB}$. Explicit VICTORY_TEXTURE_MIP_DROP=0..=3 always takes precedence.
  2. NPOT / UI Exemption, Size Floor & BCn Alignment (resource.rs):

    • Explicitly exempts non-power-of-two textures (1920×1080, 1280×720, 2560×1440) so loading artwork and UI surfaces remain at native resolution.
    • Enforces a configurable VICTORY_TEXTURE_MIP_DROP_MIN_SIZE floor (default 1024, e.g. 2048 for conservative mode) and preserves element(pc_format(format)) block alignment (4×4 for BC1–BC7) when MIN_SIZE is lowered.
    • host_texture() returns (ID3D12Resource, u32) so HostTexture.mip_drop is computed once and cannot drift from the actual resource.
  3. SRV Window Re-basing, Clamping & ResourceMinLODClamp (descriptor/host.rs):

    • Shifts MostDetailedMip, clamps MipLevels, and shifts ResourceMinLODClamp ((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 to host_mips - 1.
  4. Command-List Copy, Partial Copy & Resolve Mapping (list.rs, texture.rs):

    • copy_texture_region and resolve: Remap guest subresource indices via host_subresource(), discard copies/resolves into dropped mips, and clip ResolveSubresourceRegion using mip-adjusted dimensions.
    • copy_resource: When source and destination differ in mip_drop (e.g., RT/UAV to sampled texture), safely copies overlapping surviving mips via CopyLocation::subresource(...) without raw pointer transmutes.
    • HostWritten: Tracks partial host writes per subresource via a zero-allocation u128 bitmask (with HashSet<u32> fallback for $\ge 128$ subresources) so untouched upper mips stay eligible for title-memory upload.

Hardware & Test Verification

When VICTORY_TEXTURE_MIP_DROP is not explicitly configured in the environment,
query DXGI adapter DedicatedVideoMemory across non-software adapters.
If primary discrete VRAM is <= 8.5 GiB (capturing 4 GB, 6 GB, and 8 GB cards
such as RTX 5070 Laptop, RTX 4060, RX 6600), default mip drop to 1 to prevent
host driver committed memory exhaustion (E_OUTOFMEMORY 0x8007000E). Textures on
>= 10 GB GPUs remain at full native resolution (drop = 0). Explicit user
overrides via VICTORY_TEXTURE_MIP_DROP continue to take precedence.
@Logan-Gaillard

Copy link
Copy Markdown

Tested this head (4dd48bd) in-game on the machine the issue came from, in both adapter
configurations. 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:

host adapter adapter=Intel(R) Graphics
host device memory bytes=134217728      (128 MiB dedicated)

The probe takes the maximum DedicatedVideoMemory across adapters (the RTX), so it auto-enables
drop = 1 for a device that is not on that card. The run still dies at world load:

ERROR host GPU device removed after a submission of 1 lists (0x887A0004)
ERROR a host command list did not close (0x887A0005, device paused)

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:

ERROR host GPU device removed after a submission of 11 lists (0x887A0004)

Request. Measure the adapter the device was created on, not the best one:

let luid = device.GetAdapterLuid();               // the device's own card
// match it against IDXGIAdapter1::GetDesc1().AdapterLuid while enumerating

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 = 0 while its host copies live in
shared 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

Copy link
Copy Markdown

Since the probe is the one open point, here is the concrete patch I ran here (from my local
fix/auto-mip-drop-on-oom branch, built and tested on the same laptop). It replaces "the best
adapter'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:

static DEVICE_MEMORY: AtomicU64 = AtomicU64::new(0);

/// The memory of the adapter `device` runs on (`0` when DXGI does not name it).
pub(crate) fn device_memory() -> u64 {
    DEVICE_MEMORY.load(Ordering::Relaxed)
}

fn adapter_memory(device: &ID3D12Device) -> Option<u64> {
    unsafe {
        let factory: IDXGIFactory4 = CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0)).ok()?;
        let luid = device.GetAdapterLuid();
        let mut i = 0;
        while let Ok(adapter) = factory.EnumAdapters1(i) {
            if let Ok(desc) = adapter.GetDesc1() && desc.AdapterLuid == luid {
                return Some(desc.DedicatedVideoMemory as u64);
            }
            i += 1;
        }
        None
    }
}

called right after let device = device.ok_or_else(...)?;:

DEVICE_MEMORY.store(adapter_memory(&device).unwrap_or(0), Ordering::Relaxed);
tracing::info!(bytes = device_memory(), "host device memory");

crates/victory-gpu/src/texture.rs — read that live instead of enumerating:

let own = crate::host::device_memory();            // 0 before the device exists
let automatic = u32::from(own != 0 && own <= (8 << 30));

Read it live rather than caching it in a OnceLock: the first call can happen while the device is
still being created, and a cached 0 then keeps the drop off for the whole run (that is exactly
how 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:

} else if let Some(adapter) = best_adapter() {
    D3D12CreateDevice(&adapter, D3D_FEATURE_LEVEL_12_0, &mut device)?;
} else {
    D3D12CreateDevice(None, D3D_FEATURE_LEVEL_12_0, &mut device)?;
}

with best_adapter() returning the non-software IDXGIAdapter1 with the largest
DedicatedVideoMemory.

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 with
zero no host texture, before the residual #653 fault. Without the LUID part, the same build on
the same machine logs host adapter adapter=Intel(R) Graphics, drops detail based on a card it is
not using, and still dies at the first submission.

@antikohza

Copy link
Copy Markdown
Author

@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

Copy link
Copy Markdown
Contributor

Independent verification of \4dd48bd\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200, 16 GB VRAM) / Rust 1.98.1 MSVC:

  • Merge check vs \main\ (\ fe310e): clean
  • \cargo test -p victory-gpu --lib: 54 passed, 0 failed, 1 ignored (including \srv_mips_adjustment_handles_straddled_and_dropped_views\ and the new \mip_drop\ unit tests)
  • \cargo clippy -p victory-gpu --all-targets -- -D warnings\ (default and --all-features): clean
  • \cargo xtask policy: 154 files ok

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.

… mip-drop

- Select the non-software adapter with the most DedicatedVideoMemory during
  D3D12CreateDevice to prevent hybrid laptops (Intel/NVIDIA) from defaulting
  to the 128 MiB integrated GPU.
- Match device.GetAdapterLuid() against DXGI adapter LUIDs to record the exact
  memory of the active device.
- Read device_memory() live in texture_mip_drop to avoid stale caching during
  early device initialization.
- Clamp most_detailed in adjust_mips to host_mips - 1 to guard out-of-range
  guest SRV descriptors.

Reported-and-tested-by: Logan-Gaillard <Logan-Gaillard@users.noreply.github.com>
Reviewed-by: geiyiliyabumo <geiyiliyabumo@users.noreply.github.com>
@antikohza
antikohza force-pushed the feat/texture-mip-drop-budget branch from cefe552 to 814c580 Compare November 24, 2026 18:42
@antikohza

Copy link
Copy Markdown
Author

@Logan-Gaillard @geiyiliyabumo Head updated to 814c580 with all checks green:

  1. Discrete GPU Selection & LUID Matching:

    • Host::create now selects the non-software adapter with the most DedicatedVideoMemory via best_adapter(), completely bypassing the 128 MiB Intel iGPU trap on hybrid laptops.
    • adapter_memory matches device.GetAdapterLuid() against DXGI adapter LUIDs to ensure the exact device memory is recorded.
    • texture_mip_drop() reads device_memory() live, avoiding stale early caching.
  2. Descriptor Clamping:

    • Clamped *most_detailed in adjust_mips (descriptor/host.rs) to host_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

Copy link
Copy Markdown

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).

edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
…lt for <= 8 GB GPUs

Head 4dd48bd (antikohza). On by default (drop 1) on adapters with at
most 8 GB of dedicated memory, such as the RTX 4060 Ti;
VICTORY_TEXTURE_MIP_DROP=0 turns it off. Conflicts:
- texture.rs: the staging state keeps our per-subresource extents
  (#1135) beside mip_drop; the extents and the detile read the title's
  mip (host mip + mip_drop), detiled through our detile_subresource
  (packed 16-bit widening).
- resource.rs: HostTexture keeps our staged generation, depth twin and
  retire-on-drop with #1296's title_mips/mip_drop (a twin, never
  dropped, carries the same values).
- list.rs: our mixed packed-16 copy skips come before #1296's mip-drop
  checks and subresource remapping.
- descriptor/host.rs: our whole_uav beside #1296's SRV mip clamps.
- Tests: both sides'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
#1215 #1135 #1296 #1277 #1238 #464 #1073 #1057 #1084 #416 #704 #621.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d adapter probe

- Adjust ResourceMinLODClamp across all 7 SRV dimensions and avoid duplicate GetDesc() in descriptor/host.rs
- Return (texture, drop) from host_texture() so HostTexture.mip_drop is computed once, and guard BCn 4x4 block alignment for custom MIN_SIZE
- Replace mip-drop mismatch skip in copy_resource() with safe CopyLocation::subresource overlapping-mip copies
- Track per-subresource HostWritten via zero-alloc u128 bitmask (with HashSet fallback) for partial copies and resolves
- Probe D3D_FEATURE_LEVEL_12_0 in best_adapter() with fallback to default adapter in Host::create()
- Add unit tests for out-of-range SRV clamping, ResourceMinLODClamp, BC7 alignment, VRAM threshold, and HostWritten tracking
@antikohza

Copy link
Copy Markdown
Author

Updated to a6f3ccb (CI green: run 45470890213):

  1. PR Description (@crashbashash): Replaced the 29–30 FPS / 11 draws world-load wording with the verified VRAM/commit savings (~1.1–1.2 GiB saved, 0 E_OUTOFMEMORY / kernel NV_ERR_NO_MEMORY errors), clearly distinguishing loading/menu pacing (30 FPS / 11 draws) from CPU-copy-bound world streaming (Wine/Proton: one-page MapViewOfFile3 calls get slower with every view (the stop at +0x4dcbc9d reported here was the no-audio-device case, see #222) #834).
  2. Code Hardening (a6f3ccb):
    • descriptor/host.rs: shifted ResourceMinLODClamp uniformly across all 7 SRV dimensions and added tests for most_detailed >= drop + host_mips and ResourceMinLODClamp.
    • resource.rs: host_texture() returns (ID3D12Resource, u32) once (no duplicate compute_mip_drop call) and guards element(pc_format(format)) BCn 4×4 block alignment when VICTORY_TEXTURE_MIP_DROP_MIN_SIZE is lowered.
    • list.rs & texture.rs: replaced the mip_drop mismatch skip in copy_resource with safe CopyLocation::subresource overlapping-mip copies and a zero-alloc u128 bitmask (HostWritten) for partial copies/resolves.
    • host.rs: added supports_fl12 probe inside best_adapter() and default-adapter fallback in Host::create().
  3. Compatibility with #1542 (#431 + #967 + #1418/#1426/#1439): Maintained a clean rebased branch at antikohza:feat/texture-mip-drop-on-1542 (0d79788, Windows MSVC CI green: run 45473319819) in case #1542 lands before this PR.

edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
Taken from try/wave64:
- #189 Wave64Mode (native / wave32 / emulate) and its LDS emulation of
  64-lane waves (its helpers in emit/lower/wave64.rs, keeping lower.rs
  under the 512 KiB policy limit), selected with VICTORY_WAVE64_EMULATE
  (emulate|1|force, wave32|32, native|0, auto). Default (auto) is Native,
  which keeps our Target-based path; the mode is part of the shader cache
  key. Their wave64 tests (wave64_tests.rs, host recommendation test).
- #940 mesh lanes counted the host's way when an emulate mode is chosen.
- Wave scalars and whole-wave sections: sections skip dead SGPR spills
  as ours did; wave scalars stay off under the emulate modes.
- Translator inferences: a descriptor read only as data, and a scalar use
  point, infer the view (ported onto our descriptor_data).
- 1 MiB windows for title memory outside buffers (shadow.rs).
- Trace every mesh draw (draw.rs); WARP adapter check in the test host.
- #737 mip drop floor: VICTORY_TEXTURE_MIP_DROP_MIN_SIZE now defaults to
  2048 (spares the 1920x1080 artwork).

Kept from our side:
- Target (--host-lanes, host wave sizes), split halves, console flow,
  whole-wave sections with SGPR-spill (dead) filtering, lane-mask
  lowering, #298, #269, waterfall, wave scalars (off under emulate modes).
- Our VICTORY_TEXTURE_MIP_DROP (#1296: auto for <= 8 GB, NPOT exemption,
  subresource mapping and copy routing around dropped mips, SRV mip
  adjustment): list.rs, resource.rs, texture.rs, descriptor/host.rs are
  ours apart from the floor default.
- Shader cache: VSH3 magic, KeySpec/store for offline warming, cache
  errors after a good translation, target key (+ wave64 mode byte).
- Write-watch journal, CommittedRegions, bindless plans, copystat
  counters, compute early start, #1388 queue thread, #1418, #704 raw
  view pool/stride table, the 16 MiB stack in build.rs.

Left out: #729 Agility SDK opt-in (build.rs exports, agility.rs, README
note): without D3D12Core.dll beside the exe the runtime throws
D3D12_ERROR_INVALID_REDISTRIBUTABLE at startup, and Windows 11 needs none.
Their host-recommended Wave32 default (it never remapped lanes on NVIDIA).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
… the all-together merge

Two insertions in one place each, both kept: raw_view_tests and adjust_mips in
descriptor.rs; recommended_wave64_mode and adapter_memory in gpu/host.rs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@pfhandler

Copy link
Copy Markdown

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 lets VICTORY_KEYS drive 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.

diff --git a/crates/victory-gpu/src/dxgi.rs b/crates/victory-gpu/src/dxgi.rs
index c7f7c45..2535b68 100644
--- a/crates/victory-gpu/src/dxgi.rs
+++ b/crates/victory-gpu/src/dxgi.rs
@@ -219,6 +219,19 @@ struct Mode {
 }
 const _: () = assert!(size_of::<Mode>() == 32);
 
+/// The console's fixed output mode, overridable for hosts smaller than the
+/// console's 4K target: `VICTORY_MODE=1920x1080` reports that instead.
+fn mode_size() -> (u32, u32) {
+    const DEFAULT: (u32, u32) = (3840, 2160);
+    let Some(text) = std::env::var_os("VICTORY_MODE") else {
+        return DEFAULT;
+    };
+    let text = text.to_string_lossy();
+    text.split_once('x')
+        .and_then(|(w, h)| Some((w.trim().parse().ok()?, h.trim().parse().ok()?)))
+        .unwrap_or(DEFAULT)
+}
+
 /// The console's mode list: one 4K mode at 60 Hz (Grand Theft Auto VI looks
 /// for a 120 Hz one to allow 120 Hz frame intervals).
 /// shortcut: fixed mode, not the host display's; report the host's rates if
@@ -242,9 +255,10 @@ extern "system" fn modes(
         return MORE_DATA;
     }
     *count = 1;
+    let (width, height) = mode_size();
     let mode = Mode {
-        width: 3840,
-        height: 2160,
+        width,
+        height,
         refresh: [60, 1],
         format: 0,
         scanlines: 1, // progressive
diff --git a/crates/victory-hle/src/modules/gameinput.rs b/crates/victory-hle/src/modules/gameinput.rs
index a411bd0..da8d66c 100644
--- a/crates/victory-hle/src/modules/gameinput.rs
+++ b/crates/victory-hle/src/modules/gameinput.rs
@@ -1134,6 +1134,11 @@ mod host {
 
     impl Source for Host {
         fn pad(&mut self, slot: usize) -> Option<PadState> {
+            // The keyboard stand-in pad only exists while no host pad is
+            // connected; this hides a host pad the title mis-handles.
+            if std::env::var_os("VICTORY_NO_HOST_PAD").is_some() {
+                return None;
+            }
             if self.empty_until[slot].is_some_and(|until| Instant::now() < until) {
                 return None;
             }

edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
Ports antikohza's VICTORY_TEXTURE_MIP_DROP (upstream PR #1296, head
4dd48bd) onto this tree. Pure sampled power-of-two textures at least
VICTORY_TEXTURE_MIP_DROP_MIN_SIZE (default 2048: the 1920x1080 loading
artwork turned flat colour below that) on both axes get host copies
without their most detailed mip(s); on by default (drop 1) on adapters
with at most 8.5 GiB of dedicated memory, VICTORY_TEXTURE_MIP_DROP=0
turns it off, 2 or 3 drop more.

Adapted to this tree: host copies are made on first use
(HostTexture::new), so the made path records the title's mip count and
the drop; depth twins keep 0 (never dropped). Copies, copy regions and
resolves map console subresources onto host ones and skip dropped mips;
SRVs clamp their mip window; the staging detiles the title's mip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cyudev

cyudev commented Nov 24, 2026

Copy link
Copy Markdown

RTX 3060 Ti (8 GB): #578 + #1296 + #1666 on main holds 16+ minutes in the world, under the video memory budget

Machine: 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: main ffe310e + #578 (pr-578 head) + #1296 (a6f3ccb) + #1666 (a672556). All three merge cleanly. Diagnostics build, fresh shader cache, only VICTORY_LOG=info set.

Result: world entered at ~21:42 UTC and still running at 21:58 with no device removal, no ERROR, no no upload buffer, no crashes.log. The 3D scene is black, as on every card, with sound and subtitles.

earlier runs on this card (integration/testers u10, ± #1666) this tree
time in the world 2.5-6 min, then upload-heap E_OUTOFMEMORY and device removal 16+ min, still running
video memory in use / budget ~9,200 / 7,256 MB (over budget from world entry) ~6,000 / 7,085 MB
system memory in use / budget 4,300-5,600 / 7,437 MB, climbing ~2,000 / 7,437 MB, flat
list scratch 1,500 MB (130-170 with #1666) 104 MB, flat
frame rate in the world 0.2-0.3 fps 3.2 fps (308 ms/frame)

Memory figures come from #1666's host memory: line (QueryVideoMemoryInfo), every 5 s.

What each did, by the log:

Still there: 512 shader does not translate lines; ~4,250 draws dropped per frame without a host pipeline and ~4,900 indirect. no host texture comes 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.

Callimann8 added a commit to Callimann8/VIctory-fork that referenced this pull request Nov 24, 2026
…TEXTURE_MIP_DROP)

Ported from upstream VIctory PR Marvisak#1296 (Marvisak/VIctory, GPL-3.0-or-later):
the same drop rule (sampled power-of-two 2D textures of at least
VICTORY_TEXTURE_MIP_DROP_MIN_SIZE, default 1024, at least two mips left,
whole BC blocks) and the same view window adjustment, on this fork's
lazily made host copies. The drop is found from the title and host
descriptions wherever it matters: staging detiles title mip m + drop into
host mip m, shader views move their levels down, copies map subresources
(a dropped mip is skipped), whole copies between differently dropped
copies are skipped. Off by default (0).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ericomeehan

Copy link
Copy Markdown

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_fl12 creates a full device on every adapter. D3D12CreateDevice with 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

Witredd commented Nov 24, 2026

Copy link
Copy Markdown

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 on ffe310e), release build. Memory is the process's GPU counters, sampled every 2 s.

Run Reached Dedicated peak Shared peak
#961 alone failed on the loading screen 5.8 GB (full) 7.5 GB
+ VICTORY_TEXTURE_MIP_DROP=2 the opening title card, then failed 5.8 GB (full) 6.8 GB
+ =3 and --console series-s a few seconds of the opening's audio, then failed 5.9 GB (full) 7.5 GB

The 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) and no shared buffer, ending in a 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

Copy link
Copy Markdown
Owner

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

Copy link
Copy Markdown
Author

@ericomeehan @cyudev @Witredd @Logan-Gaillard — thank you for the review and hardware data. Since #1296 and #1617 were closed before merge and main moved to 940d32f, I opened a clean rebased PR at #2146 (including @ericomeehan's EnumAdapterByGpuPreference(HIGH_PERFORMANCE) and null-device FL12 probe suggestions, plus reconciliation with shared HostTexture).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

9 participants