Repository navigation
Conversation
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.
|
Tested this head ( Machine: RTX 5070 Laptop ( 1. Default adapter — what a user gets without touching anything. The device comes from The probe takes the maximum 2. Device forced onto the RTX (per-app Windows GPU preference for the exe): auto 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 enumeratingOtherwise a laptop whose default is its iGPU computes its texture budget from a card it never For the record, even on the right adapter world streaming still removes the device here with no |
|
Since the probe is the one open point, here is the concrete patch I ran here (from my local
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 DEVICE_MEMORY.store(adapter_memory(&device).unwrap_or(0), Ordering::Relaxed);
tracing::info!(bytes = device_memory(), "host device memory");
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 Optional, and worth it on this class of machine — create the device on the biggest card } 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 Measured here with both parts in place: |
|
@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! |
|
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. |
… 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>
cefe552 to
814c580
Compare
|
@Logan-Gaillard @geiyiliyabumo Head updated to
All workspace unit tests and clippy checks pass clean. |
|
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). |
…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>
#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
|
Updated to
|
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>
… 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>
|
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):
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;
} |
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>
RTX 3060 Ti (8 GB): #578 + #1296 + #1666 on
|
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:
- GPU: add VICTORY_TEXTURE_MIP_DROP and DXGI auto-default for <= 8 GB GPUs (fixes #737, #1226) #1296:
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. - GPU: refuse wave64 mesh and compute programs on hosts without 64-lane waves #578:
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 Test report: RTX 4060 Laptop (8 GB), the world hangs the GPU, and VRAM is full #1508's RTX 4060 Laptop run (579 s with GPU: refuse wave64 mesh and compute programs on hosts without 64-lane waves #578). - GPU: small first scratch chunk per list; log host memory against budget #1666: list scratch flat at ~104 MB.
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.
…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>
|
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
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). |
|
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 (
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 |
|
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. |
|
@ericomeehan @cyudev @Witredd @Logan-Gaillard — thank you for the review and hardware data. Since #1296 and #1617 were closed before merge and |
Resolves #737, resolves #1226.
Summary
Introduces a proactive texture mip-drop subsystem and quality switch ($\le 8\text{ GiB}$ dedicated VRAM.
VICTORY_TEXTURE_MIP_DROP, clamped0..=3), plus discrete GPU adapter selection and automatic LUID-matched VRAM detection that defaultsdrop = 1on GPUs withPrimary 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.no 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 = 1whenVICTORY_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 forHardware & Test Verification
@Logan-Gaillard, Patch (fork): add VICTORY_TEXTURE_MIP_DROP quality switch for low-VRAM budgets (75%–93% texture memory savings on 6GB/8GB GPUs) #737 / GPU: a failed host texture allocation removes the device instead of dropping detail (8 GB NVIDIA laptop, world load) #1226 / World load removes the host D3D12 device — on the real GPU (0x887A0006) and on WARP (0x887A0005) #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, Patch (fork): add VICTORY_TEXTURE_MIP_DROP quality switch for low-VRAM budgets (75%–93% texture memory savings on 6GB/8GB GPUs) #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, A configuration that gets the world stage running on a 12 GB Windows 10 card: nine stacked changes, what each fixed, and the two bottlenecks left #1086): Reduced peak VRAM 11.3 GiB → 10.3 GiB (~1 GiBsaved with 2048 floor), fitting the world stage under 12 GB.@DrDarkDK, Patch (fork): add VICTORY_TEXTURE_MIP_DROP quality switch for low-VRAM budgets (75%–93% texture memory savings on 6GB/8GB GPUs) #737): MSAA resolve readback verified bit-for-bit across all 262,144 pixels on both hardware and WARP.@geiyiliyabumo, GPU: add VICTORY_TEXTURE_MIP_DROP and DXGI auto-default for <= 8 GB GPUs (fixes #737, #1226) #1296): Verified4dd48bd(victory-gpu: 54 passed, 0 failed; clippy +xtask policyclean).