feat(hle): per-monitor v2 DPI awareness and aspect-preserving ultrawide fullscreen #132

Merged
dcastell1 merged 1 commit from upstream-pr/132 into main 2026-11-28 19:01:28 +00:00
dcastell1 commented 2026-11-27 18:39:47 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dcastell1 on 2026-11-27T18:39:47Z.


Problem

  1. DWM DPI virtualisation blur on high-DPI displays. Without declaring Per-Monitor V2 DPI awareness, Windows 11 reports scaled logical coordinates (for example 3413x1440 on a 5120x2160 display at 150% scaling), causing fit() to shrink the client window and DWM to bilinear-upscale every frame.
  2. Stretched aspect ratio on ultrawide and 16:10 displays with VICTORY_FULLSCREEN=1. fullscreen() previously placed the window at (0, 0, SM_CXSCREEN, SM_CYSCREEN), stretching a 16:9 swap chain horizontally across 21:9 (5120x2160, 3440x1440) and 32:9 (5120x1440) monitors.

Changes (crates/victory-hle/src/modules/lifecycle.rs)

  • ensure_dpi_aware(): requests DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 via user32!SetProcessDpiAwarenessContext once before querying screen/work-area metrics (VICTORY_DPI_AWARE=0 restores legacy OS scaling).
  • Aspect-preserving fullscreen_box(): centres the largest proportional rectangle inside (screen_w, screen_h) using the title's requested dimensions before fit() adjusts overlapped borders (for example (640, 0, 3840, 2160) 1:1 pixel mapping for --res 4k on a 5120x2160 21:9 monitor). VICTORY_FULLSCREEN=stretch preserves full-screen stretching when explicitly requested.
  • Non-activating black pillarbox/letterbox backdrop (VICTORY_FULLSCREEN_BARS=0 disables): when the centred window does not cover the whole screen, spawns a lightweight WS_POPUP | WS_DISABLED (WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE) black backdrop window ordered directly behind hwnd and destroyed on WM_NCDESTROY. Because it is disabled and non-activating, clicking the black bars never steals foreground focus from the title window (keeping DLSS Frame Generation active) and never appears in Alt-Tab or the taskbar.
  • Windowed centring: top-level game windows starting at (0, 0) that already fit inside the work area (such as 2560x1440 on a DPI-aware 5120x2160 desktop) are centred in the work area instead of pinned to (0, 0).

Verification

  • Hardware: Windows 11 (build 26300), i9-12900K, 64 GB RAM, GeForce RTX 5090 32 GB (driver 621.40), 5120x2160 (21:9) display at 150% OS scaling.
  • Verified in release runs (--res 4k --dlss quality --framegen 4 --set VICTORY_FULLSCREEN=1): per-monitor v2 DPI awareness requested ok=true, screen=(5120, 2160), crisp 1:1 3840x2160 presentation with clean black pillarboxes and uninterrupted DLSS Frame Generation focus.
  • cargo test --locked -p victory-hle --lib modules::lifecycle: 12 passed, 0 failed (including fullscreen_box_preserves_aspect_on_ultrawide_and_tall_screens).
  • cargo clippy --locked --no-deps -p victory-hle --all-targets: 0 warnings in lifecycle.rs.
  • cargo test --locked -p xtask: 6 passed, 0 failed (asset policy green).

Note: Made with AI assistance and reviewed, built, and tested by a human.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5531502127 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/132). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-27T18:39:47Z. --- ## Problem 1. **DWM DPI virtualisation blur on high-DPI displays.** Without declaring Per-Monitor V2 DPI awareness, Windows 11 reports scaled logical coordinates (for example `3413x1440` on a `5120x2160` display at 150% scaling), causing `fit()` to shrink the client window and DWM to bilinear-upscale every frame. 2. **Stretched aspect ratio on ultrawide and 16:10 displays with `VICTORY_FULLSCREEN=1`.** `fullscreen()` previously placed the window at `(0, 0, SM_CXSCREEN, SM_CYSCREEN)`, stretching a 16:9 swap chain horizontally across 21:9 (`5120x2160`, `3440x1440`) and 32:9 (`5120x1440`) monitors. ## Changes (`crates/victory-hle/src/modules/lifecycle.rs`) - **`ensure_dpi_aware()`:** requests `DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2` via `user32!SetProcessDpiAwarenessContext` once before querying screen/work-area metrics (`VICTORY_DPI_AWARE=0` restores legacy OS scaling). - **Aspect-preserving `fullscreen_box()`:** centres the largest proportional rectangle inside `(screen_w, screen_h)` using the title's requested dimensions before `fit()` adjusts overlapped borders (for example `(640, 0, 3840, 2160)` 1:1 pixel mapping for `--res 4k` on a `5120x2160` 21:9 monitor). `VICTORY_FULLSCREEN=stretch` preserves full-screen stretching when explicitly requested. - **Non-activating black pillarbox/letterbox backdrop (`VICTORY_FULLSCREEN_BARS=0` disables):** when the centred window does not cover the whole screen, spawns a lightweight `WS_POPUP | WS_DISABLED` (`WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE`) black backdrop window ordered directly behind `hwnd` and destroyed on `WM_NCDESTROY`. Because it is disabled and non-activating, clicking the black bars never steals foreground focus from the title window (keeping DLSS Frame Generation active) and never appears in Alt-Tab or the taskbar. - **Windowed centring:** top-level game windows starting at `(0, 0)` that already fit inside the work area (such as `2560x1440` on a DPI-aware `5120x2160` desktop) are centred in the work area instead of pinned to `(0, 0)`. ## Verification - Hardware: Windows 11 (build 26300), i9-12900K, 64 GB RAM, GeForce RTX 5090 32 GB (driver 621.40), `5120x2160` (21:9) display at 150% OS scaling. - Verified in release runs (`--res 4k --dlss quality --framegen 4 --set VICTORY_FULLSCREEN=1`): `per-monitor v2 DPI awareness requested ok=true`, `screen=(5120, 2160)`, crisp 1:1 `3840x2160` presentation with clean black pillarboxes and uninterrupted DLSS Frame Generation focus. - `cargo test --locked -p victory-hle --lib modules::lifecycle`: **12 passed, 0 failed** (including `fullscreen_box_preserves_aspect_on_ultrawide_and_tall_screens`). - `cargo clippy --locked --no-deps -p victory-hle --all-targets`: **0 warnings in `lifecycle.rs`**. - `cargo test --locked -p xtask`: **6 passed, 0 failed** (asset policy green). --- *Note: Made with AI assistance and reviewed, built, and tested by a human.*
cloph-dsp commented 2026-11-28 02:52:48 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by cloph-dsp on 2026-11-28T02:52:48Z.


Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):

  • PR #132 at head e080431aa37196687ea2f5db3b0596ecb7cc7852, base (single-commit parent) ca9c75cd6d59b04a096746b313baed986608e63a.
  • cargo test --locked -p victory-hle --lib -- modules::lifecycle::tests::fullscreen_box_preserves_aspect_on_ultrawide_and_tall_screens --exact --test-threads=1 --quiet → 1 passed, 0 failed, 173 filtered, exit 0.
  • git grep -F for the test name on the base returned no hits (test is new on this PR); git diff --check ca9c75cd HEAD clean (1 file, +199/-12).
  • Used a per-worktree CARGO_TARGET_DIR (never shared) with CARGO_BUILD_JOBS=2.
  • Only the named synthetic test (integer geometry only, no Win32 call) was replayed; full workspace suite and clippy were not run locally (no clippy component on this toolchain). Pre-existing compiler warning present.
  • GPU/driver: N/A (CPU-only). No game data, assets, extracted shaders, DRM or decrypt involved.

AI-assisted (Hy4 flash).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7232652338 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/132#issuecomment-7232652338). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-28T02:52:48Z. --- Independent local verification (Windows, Rust 1.100.0/MSVC, no game data): - PR #132 at head `e080431aa37196687ea2f5db3b0596ecb7cc7852`, base (single-commit parent) `ca9c75cd6d59b04a096746b313baed986608e63a`. - `cargo test --locked -p victory-hle --lib -- modules::lifecycle::tests::fullscreen_box_preserves_aspect_on_ultrawide_and_tall_screens --exact --test-threads=1 --quiet` → 1 passed, 0 failed, 173 filtered, exit 0. - `git grep -F` for the test name on the base returned no hits (test is new on this PR); `git diff --check ca9c75cd HEAD` clean (1 file, +199/-12). - Used a per-worktree `CARGO_TARGET_DIR` (never shared) with `CARGO_BUILD_JOBS=2`. - Only the named synthetic test (integer geometry only, no Win32 call) was replayed; full workspace suite and clippy were not run locally (no clippy component on this toolchain). Pre-existing compiler warning present. - GPU/driver: N/A (CPU-only). No game data, assets, extracted shaders, DRM or decrypt involved. AI-assisted (Hy4 flash).
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
trustno1-coder/VIctory-NVIDIA!132
No description provided.