Skip to content

HLE: show title windows through a stand-in that always reads its messages - #1677

Merged
Marvisak merged 1 commit into
Marvisak:mainfrom
Calvix2k:codex/hle-window-standin-1616
Nov 25, 2026
Merged

Marvisak merged 1 commit into
Marvisak:mainfrom
Calvix2k:codex/hle-window-standin-1616

Conversation

@Calvix2k

Copy link
Copy Markdown
Contributor

Fixes #1616.

Ports the verified fix from @Vaximous's fork (commit 7592443 by Vax), applied unchanged onto ffe310e; the commit keeps its original author.

Summary

The title creates its window on its own thread and only reads messages when it reaches its PeekMessage loop, which can be seconds apart during loads. Windows then shows the busy cursor and, on a click, a "Not responding" ghost window.

  • The title's top-level window becomes message-only (HWND_MESSAGE), so it is never shown.
  • A stand-in window copies its text, style, icon and fitted size and runs on a dedicated victory-window thread that only pumps messages.
  • ShowWindow shows the stand-in, WM_SETTEXT is mirrored, closing it ends the title as before, and frames present to the process's visible window (the stand-in).
  • Adds the Win32_Graphics_Gdi feature to victory-hle.

Validation

  • cargo test -p victory-hle --locked -- --test-threads=1 — passed (96 unit tests and 1 integration test).
  • cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings — passed.
  • cargo xtask policy — passed (154 files).
  • Runtime measurement is the author's (RTX 4070 Ti, Windows 11): WM_NULL round trip 0 ms in 47 of 50 samples versus 100-690 ms before; no busy cursor or ghost window.

…ages

A title makes its window on one of its own threads and reads its messages
only when that thread reaches its PeekMessage loop. In slow frames and
loads that is seconds apart, so the system shows the busy cursor over the
window and a click turns it into a "Not responding" ghost.

A top-level title window is now made message-only (it can never be shown),
and a stand-in window with the title's text, style, icon and fitted size is
made on a thread of ours that does nothing but pump its messages. The
title's ShowWindow shows the stand-in, its window text follows, closing the
stand-in suspends and ends the title as before, the keyboard window menu is
still refused, and the stand-in goes when the title's window does. Frames
are presented to the process's visible window, now the stand-in; input is
unaffected, since titles read it through GameInput, not window messages.

Co-Authored-By: Claude Opus 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;
             }

@Calvix2k

Copy link
Copy Markdown
Contributor Author

Thanks — these were unrelated to this PR, so I upstreamed them separately, with you credited:

Both keep your semantics; the mode parser rejects zero and anything above D3D12's 16384 limit instead of reporting an invalid mode.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Static review only: Windows-only code (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; source review of the diff.

Title windows are shown through a stand-in window that always reads its messages: stand_in() creates a hidden-ish window with the title's icon/text, SetPropW links it, stand_in_proc handles WM_DESTROY/WM_QUIT via PostQuitMessage, and pump() drains messages. This is the classic 'message-only window' trick for titles that never pump their own queue. The stand-in must not swallow input the title expects — worth a Windows session with a title known to hang on window messages.

Calvix2k added a commit to Calvix2k/VIctory that referenced this pull request Nov 24, 2026
The DXGI output mode list was fixed at the console's 3840x2160, so hosts
smaller than that carried the 4K render targets and their VRAM cost. Read
VICTORY_MODE=<width>x<height> instead (both dimensions 1..=16384); an
unparseable or out-of-range value keeps the 4K default.

From the local patches @pfhandler posted under Marvisak#1677 while running through
vkd3d-proton on an 8 GB card.

Validation:
- cargo test -p victory-gpu --locked -- --test-threads=1
- cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings
- cargo xtask policy
- rustfmt --edition 2024 --check on the changed file
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
zhaibingye pushed a commit to zhaibingye/VIctory that referenced this pull request Nov 24, 2026
A connected host pad (for example a DualShock that XInput reports as pad
0) keeps the keyboard stand-in pad from being enumerated, so a title that
mis-handles that pad has no keyboard input left. VICTORY_NO_HOST_PAD=1
makes every XInput slot report empty, which brings the stand-in back.

From the local patch @pfhandler posted under Marvisak#1677 while running through
vkd3d-proton.

The flag is read once when the input hub is built and logs its state.

Validation:
- cargo test -p victory-hle --locked -- --test-threads=1
- cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings
- cargo xtask policy
@Marvisak
Marvisak merged commit d4ef9eb into Marvisak:main Nov 25, 2026
Calvix2k added a commit to Calvix2k/VIctory that referenced this pull request Nov 25, 2026
A connected host pad (for example a DualShock that XInput reports as pad
0) keeps the keyboard stand-in pad from being enumerated, so a title that
mis-handles that pad has no keyboard input left. VICTORY_NO_HOST_PAD=1
makes every XInput slot report empty, which brings the stand-in back.

From the local patch @pfhandler posted under Marvisak#1677 while running through
vkd3d-proton.

The flag is read once when the input hub is built and logs its state.

Validation:
- cargo test -p victory-hle --locked -- --test-threads=1
- cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings
- cargo xtask policy
Calvix2k added a commit to Calvix2k/VIctory that referenced this pull request Nov 25, 2026
The DXGI output mode list was fixed at the console's 3840x2160, so hosts
smaller than that carried the 4K render targets and their VRAM cost. Read
VICTORY_MODE=<width>x<height> instead (both dimensions 1..=16384); an
unparseable or out-of-range value keeps the 4K default.

From the local patches @pfhandler posted under Marvisak#1677 while running through
vkd3d-proton on an 8 GB card.

Validation:
- cargo test -p victory-gpu --locked -- --test-threads=1
- cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings
- cargo xtask policy
- rustfmt --edition 2024 --check on the changed file
Calvix2k added a commit to Calvix2k/VIctory that referenced this pull request Nov 25, 2026
A connected host pad (for example a DualShock that XInput reports as pad
0) keeps the keyboard stand-in pad from being enumerated, so a title that
mis-handles that pad has no keyboard input left. VICTORY_NO_HOST_PAD=1
makes every XInput slot report empty, which brings the stand-in back.

From the local patch @pfhandler posted under Marvisak#1677 while running through
vkd3d-proton.

The flag is read once when the input hub is built and logs its state.

Validation:
- cargo test -p victory-hle --locked -- --test-threads=1
- cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings
- cargo xtask policy
Calvix2k added a commit to Calvix2k/VIctory that referenced this pull request Nov 25, 2026
The DXGI output mode list was fixed at the console's 3840x2160, so hosts
smaller than that carried the 4K render targets and their VRAM cost. Read
VICTORY_MODE=<width>x<height> instead (both dimensions 1..=16384); an
unparseable or out-of-range value keeps the 4K default.

From the local patches @pfhandler posted under Marvisak#1677 while running through
vkd3d-proton on an 8 GB card.

Validation:
- cargo test -p victory-gpu --locked -- --test-threads=1
- cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings
- cargo xtask policy
- rustfmt --edition 2024 --check on the changed file
Steenax6 added a commit to Steenax6/VIctory-NVID that referenced this pull request Nov 26, 2026
…strained before it is suspended

Two window and life-cycle changes of the VIctory family, taken as the whole
file since ours was still the fork point's apart from comment wording:

- Constrain before suspend (a7847a5, Giuseppe Rainone, PR Marvisak#1080). The console
  runs a title's constrained-change routines before its suspend routines, and
  the title's suspend routine waits for a state its constrained routine
  brings about. We called only the suspend routine, so every close ran into
  the one-second deadline. RegisterAppConstrainedChangeNotification is now
  ours, and `end_title` runs both in the console's order.
- Stand-in window (9145d9d, Vax, PR Marvisak#1677). A title makes its window on one
  of its own threads and reads its messages when that thread gets round to
  it: seconds apart in a slow frame or a load. Windows then shows the busy
  cursor and, after a click, a "Not responding" ghost. The title's top-level
  window is now message-only and a stand-in with its text, style and fitted
  size, owned by a thread that only reads messages, is shown instead.
  ShowWindow and WM_SETTEXT of the title's window are passed on to it, a
  close of the stand-in ends the title as before, and the stand-in goes with
  the title's window. Our presenter picks the process's visible top-level
  window, which is now the stand-in; input is polled (GameInput), not read
  from window messages.
- `VICTORY_WINDOW_MAX=WIDTHxHEIGHT` (a7636dd, fluffyflattershy-afk, PR Marvisak#1455):
  a smaller limit for the window's size, off by default; documented in the
  README's switch table.

Not tried in the title: it needs a look at the next run (the window shows and
takes keyboard focus, the title bar shows the frame meter, closing it ends the
title cleanly).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Calvix2k added a commit to Calvix2k/VIctory that referenced this pull request Nov 26, 2026
A connected host pad (for example a DualShock that XInput reports as pad
0) keeps the keyboard stand-in pad from being enumerated, so a title that
mis-handles that pad has no keyboard input left. VICTORY_NO_HOST_PAD=1
makes every XInput slot report empty, which brings the stand-in back.

From the local patch @pfhandler posted under Marvisak#1677 while running through
vkd3d-proton.

The flag is read once when the input hub is built and logs its state.

Validation:
- cargo test -p victory-hle --locked -- --test-threads=1
- cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings
- cargo xtask policy
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.

HLE: title window shows the busy cursor and goes "Not responding" during loads (fix on a fork)

5 participants