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

Open
github-bot wants to merge 1 commit from github-bot/gh-132 into main AGit
Owner

@⁠dcastell1 on GitHub · 2026-11-27 18:39 UTC · original
dcastell1:feat/dpi-ultrawide-fullscreen → main · +199 −12 · 1 files · 1 commits · open

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.

**@⁠dcastell1** on GitHub · 2026-11-27 18:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/132) `dcastell1:feat/dpi-ultrawide-fullscreen` → `main` · +199 −12 · 1 files · 1 commits · open ## 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.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 18:40:00 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/132/head:github-bot/gh-132'
git switch 'github-bot/gh-132'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-132'
git switch 'github-bot/gh-132'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-132'
git switch 'github-bot/gh-132'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-132'
git switch 'main'
git merge --squash 'github-bot/gh-132'
git switch 'main'
git merge --ff-only 'github-bot/gh-132'
git switch 'main'
git merge 'github-bot/gh-132'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.