Skip to content

gta6rt: per-monitor DPI aware, so a mapped title's window is in physical pixels - #9057

Closed
CuteBooty wants to merge 1 commit into
ProjectLeonida:mainfrom
CuteBooty:runtime/gta6rt-dpi-aware
Closed

CuteBooty wants to merge 1 commit into
ProjectLeonida:mainfrom
CuteBooty:runtime/gta6rt-dpi-aware

Conversation

@CuteBooty

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #8683 (comment)

What and why

gta6rt.exe was DPI-unaware: its manifest had only requestedExecutionLevel, and nothing in runtime/ sets DPI awareness. A mapped title creates its window inside gta6rt's process, so on a display scaled above 100% Windows gave the title a smaller logical desktop and bitmap-stretched the result.

  • runtime/src/gta6rt.manifest declares per-monitor DPI awareness (PerMonitorV2,PerMonitor, plus true/pm for older Windows). It is a source of add_executable(gta6rt ...), so the linker merges it into its default manifest (checked with mt.exe: asInvoker kept, both DPI entries added), and the cl.exe fallback in scripts/build_runtime.ps1 passes the same file with /MANIFEST:EMBED /MANIFESTINPUT:.
  • ResizeTarget (runtime/shims/dxgi_com.cpp) sized the window frame with AdjustWindowRectEx, which uses the system DPI. Per-monitor aware, a window on a monitor at another scale needs the frame at its own DPI, so it now uses AdjustWindowRectExForDpi with GetDpiForWindow (looked up at run time; AdjustWindowRectEx where they are missing, as on older Windows or Wine). Found in review (Codex): in a PMv2 process a 640x480 client got a 668x559 frame from AdjustWindowRectEx where 144 DPI needs 662x536.
  • runtime/README.md: one paragraph on what the manifest does.

Tested

NVIDIA GeForce RTX 3070, driver 617.14, Windows 11 25H2, one 3840x2160 display at 225% (216 DPI), MSVC 17.14, Vulkan SDK 1.4.363.0, on main 867d922f.

A small MSVC-built probe run as the title with gta6rt --run (it creates a window, reads the values below and creates a Vulkan surface; no game files):

before after
process awareness, GetDpiForSystem unaware, 96 per-monitor v2, 216
SM_CXSCREEN x SM_CYSCREEN, rcMonitor (DXGI DesktopCoordinates) 1707x960, while the current mode is 3840x2160 3840x2160, same as the mode
borderless window at the monitor rect: client, Vulkan currentExtent 1707x960 (DWM stretches it 2.25x) 3840x2160
windowed, 1920x1080 client requested: client, currentExtent 1711x941 1920x1080
ClipCursor to the borderless client 1707x960 3840x2160

What a title may notice: on a scaled display it now gets physical sizes, so a "fullscreen" swapchain is the monitor's real size (here 3840x2160 instead of 1707x960, about 5x the pixels), and a title that handles WM_DPICHANGED now receives it. Nothing changes at 100%. The D3D12 test programs do not get the manifest.

Not tested: a second monitor at a different scale (single display here, so the AdjustWindowRectExForDpi branch gives the same frame as before), the clang-cl + xwin cross-build on Linux (its llvm-mt needs libxml2), Wine/Proton, the real title.

AI-assisted: yes (Claude Code wrote and ran it; Codex reviewed it).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (not applicable)

🤖 Generated with Claude Code

…cal pixels

gta6rt.exe had no DPI awareness in its manifest, and a mapped title creates
its windows in gta6rt's process, so on a scaled display Windows gave the
title a smaller logical desktop and stretched what it drew. src/gta6rt.manifest
declares PerMonitorV2 (PerMonitor on 1607, true/pm before) and is merged into
the linker's default manifest by CMake and by the cl.exe fallback.

DXGI ResizeTarget sizes the frame with AdjustWindowRectExForDpi at the
window's DPI, which under PerMonitorV2 can differ from the system DPI that
AdjustWindowRectEx uses (falls back to it where the call is missing).

Measured with a probe title under gta6rt --run, 3840x2160 at 225%, RTX 3070:
- borderless window at the monitor rect: client and Vulkan currentExtent
  1707x960 before, 3840x2160 after
- windowed 1920x1080 client: 1711x941 before, 1920x1080 after
- rcMonitor (DXGI DesktopCoordinates): 1707x960 before, 3840x2160 after,
  matching the current mode; GetDpiForWindow 96 before, 216 after

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Grimkaaah Grimkaaah 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.

Independent Linux CPU review

What changed: gta6rt is per-monitor DPI aware so a mapped title's window is in physical pixels.

Checked: diff review of manifest + dxgi_com.cpp + build scripts (no local runtime build).

Looks correct; no game files.

@abnalstlll-byte abnalstlll-byte 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.

Independent Windows review (commit \e40f57ef3fe22d8959fd8bf3104e0b8f2854d25f)

What changed:


  • untime/src/gta6rt.manifest:
    • Embeds \PerMonitorV2,PerMonitor\ DPI awareness into \gta6rt, preventing Windows DWM bitmap stretching on high-DPI displays.

  • untime/shims/dxgi_com.cpp:
    • In \ResizeTarget, calls \AdjustWindowRectExForDpi\ dynamically via \GetProcAddress\ with fallback to \AdjustWindowRectEx.
  • \scripts/build_runtime.ps1\ &
    untime/CMakeLists.txt:
    • Integrates manifest into standalone and CMake build systems.

Verification:

  • Verified on Windows 11 host with MSVC: window dimensions compute cleanly in physical device pixels across DPI scaling.
  • Clean diff: no game files.

LGTM!

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.

4 participants