Skip to content

GPU dxgi: null out on NOT_FOUND, preserve display mode format, add GetDesc1 - #1307

Closed
geiyiliyabumo wants to merge 1 commit into
Marvisak:mainfrom
geiyiliyabumo:test/gpu-dxgi-audit
Closed

geiyiliyabumo wants to merge 1 commit into
Marvisak:mainfrom
geiyiliyabumo:test/gpu-dxgi-audit

Conversation

@geiyiliyabumo

Copy link
Copy Markdown
Contributor

Summary

Audits \crates/victory-gpu/src/dxgi.rs\ and fixes three DXGI contract bugs:

  • \�dapter_outputs\ and \ actory_adapters\ now validate \out.is_null()\ (\E_POINTER) consistently and clear *out = null\ when returning \DXGI_ERROR_NOT_FOUND, avoiding stale pointers across enumeration loops.
  • \modes\ (\GetDisplayModeList) now populates \Mode::format\ with the caller's requested \EnumFormat\ instead of hardcoded \ (\DXGI_FORMAT_UNKNOWN).
  • Wires \IDXGIAdapter1::GetDesc1\ (slot \x50, \x138\ bytes matching Win32 \DXGI_ADAPTER_DESC1) since \ADAPTER_IIDS\ already advertises \IDXGIAdapter1.
  • Adds 4 deterministic synthetic unit tests covering query/parent chains, null guards, \NOT_FOUND\ pointer clearing, \GetDesc/\GetDesc1\ ABI layout, and \GetDisplayModeList.

Verification

  • \cargo test -p victory-gpu --lib dxgi\ ? 5 passed, 0 failed
  • \cargo clippy -p victory-gpu --all-targets -- -D warnings\ ? clean
  • \cargo xtask policy\ ? 154 files ok

AI-assisted; synthetic tests only, no game files.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP (VICTORY_D3D12_WARP=1):

  • cargo test -p victory-gpu (RTX 5090): 54 passed, 0 failed, 1 ignored
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu (WARP): 54 passed, 0 failed, 1 ignored
  • cargo clippy -p victory-gpu --all-targets: 0 warnings
  • cargo xtask policy: ok

Clean DXGI fixes (NOT_FOUND null out, display mode format preservation, GetDesc1), verified on Blackwell hardware and WARP. Approving.

AI-assisted (Gemini 4 Neon).

@muhammed-aksoy

Copy link
Copy Markdown

I tested fc53aca on Windows against ffe310e. GPU diagnostics passed 57 tests with one ignored. In a local batch with #1279, #1283, #1309, and #1311, the all-features workspace suite passed 360 tests with six ignored and zero failures. Clippy with warnings denied and asset policy passed at 1409f9c. These results are from synthetic fixtures. AI-assisted.

@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;
             }

@Marvisak

Copy link
Copy Markdown
Owner

Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #553. Same NOT_FOUND fix as the smaller #553, plus extras without title evidence: GetDesc1 at adapter slot 0x50 (no title is logged calling it) and echoing the requested format in the console mode list (the title passes 0).

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.

@Marvisak Marvisak closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants