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

Closed
github-bot wants to merge 1 commit from gh-pr/1307/head into gh-pr/1307/base
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 17:18 UTC · original
geiyiliyabumo:test/gpu-dxgi-audit → main · +193 −10 · 1 files · 1 commits · closed without merging

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.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 17:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/1307) `geiyiliyabumo:test/gpu-dxgi-audit` → `main` · +193 −10 · 1 files · 1 commits · closed without merging ## 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.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:27:00 +00:00
github-bot closed this pull request 2026-11-26 04:27:00 +00:00
Author
Owner

@⁠muhammed-aksoy on GitHub · 2026-11-24 17:54 UTC · original

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.

**@⁠muhammed-aksoy** on GitHub · 2026-11-24 17:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/1307#issuecomment-7139872822) 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.
Author
Owner

@⁠pfhandler on GitHub · 2026-11-24 20:52 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 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;
             }
**@⁠pfhandler** on GitHub · 2026-11-24 20:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/1307#issuecomment-7144171544) 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 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; } ```
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:37 UTC · original

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** on GitHub · 2026-11-25 00:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/1307#issuecomment-7148699332) 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.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1307
No description provided.