macOS: native HiDPI/Retina rendering (full-screen, sharp, correct input)#204
Merged
Conversation
…rect input)
On Apple Silicon Retina displays the game rendered at logical (1x) resolution
and the compositor upscaled it, producing a soft image. Enabling a
high-pixel-density drawable alone made it render 1:1 in the top-left corner
because the DXVK SDL3 WSI sized the swapchain in points while the Metal layer
is in pixels.
Four coordinated changes make the game render at true native resolution,
fill the screen, and map input correctly:
- SDL3Main.cpp (Generals + GeneralsMD): request SDL_WINDOW_HIGH_PIXEL_DENSITY
on Apple so the Metal drawable is native-resolution.
- bundle-macos-{generals,zh}.sh: add NSHighResolutionCapable=true, required for
macOS to give the app a high-res backing store.
- DX8Wrapper::Pillarbox_Setup (dx8wrapper.cpp): populate the pixel density even
when the backbuffer size comes from the present parameters, so the viewport
rect converts back to logical points and SDL point-space mouse coordinates
hit-test correctly.
- cmake/patches/dxvk-macos-hidpi-wsi.patch: DXVK SDL3 WSI getWindowSize() must
query SDL_GetWindowSizeInPixels (pixels), not SDL_GetWindowSize (points).
This lives in the fbraz3/dxvk submodule; the patch is vendored here and is
currently applied via SAGE_DXVK_USE_LOCAL_FORK. It needs a matching PR to
fbraz3/dxvk, after which DXVK_REMOTE_REF can be bumped.
Verified: GeneralsMD (Zero Hour) runs full-screen at native 3024x1898 on a
14" M4 Pro, sharp, with working menu/skirmish input.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gpbm3zSo8ggFfLaRByKoaC
…anch builds standalone Wire cmake/patches/dxvk-macos-hidpi-wsi.patch into the remote DXVK ExternalProject PATCH_COMMAND (idempotent reverse-check + git apply), so a default build (SAGE_DXVK_USE_LOCAL_FORK=OFF) fetches the pinned fbraz3/dxvk commit and applies the pixel-size WSI fix automatically. Removes the need for the local-fork flag. Once the fix lands in the pinned DXVK ref, this PATCH_COMMAND and the patch file can be dropped. Verified: clean DXVK re-clone -> patch applies -> libdxvk_d3d9 built with SDL_GetWindowSizeInPixels; GeneralsXZH runs full-screen native Retina. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gpbm3zSo8ggFfLaRByKoaC
Owner
|
Hi @wormeyman thanks for the contribution, I was noticed something strange with graphics but don't figure out what was it. The DXVK PR has just been merged. Could you please update this PR to point to the new upstream DXVK commit and clean up the temporary patch files? Specifically:
Once these changes are pushed, we are ready to merge this PR. |
The macOS HiDPI WSI fix has merged into fbraz3/dxvk. Bump DXVK_REMOTE_REF to the merged commit (1132d306e36c932fb4d062bce7c5602c45913ac8) and remove the now-redundant vendored patch and its PATCH_COMMAND. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CqpfGUwtpZiH5j5aErC3TE
Author
|
Thanks for merging it! Pushed a commit that bumps One note: the DXVK config actually lives in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Apple Silicon Retina displays the game renders at logical (1x) resolution and the compositor upscales the result, so it looks soft next to the same engine running under Wine/CrossOver.
Requesting a high-density drawable on its own is not enough. The game then renders 1:1 in the top-left corner, because DXVK's SDL3 WSI sizes the swapchain in points while the Metal layer is in pixels. And once the picture does fill the screen, mouse hit-testing is off, because the pillarbox viewport rect stays in pixel space while SDL reports mouse coordinates in points.
Four changes work together so the game renders at native resolution, fills the screen, and maps input correctly:
SDL3Main.cpp(Generals + GeneralsMD): requestSDL_WINDOW_HIGH_PIXEL_DENSITYon Apple, so the Metal drawable is native-resolution. Scoped to__APPLE__; Linux is unchanged.bundle-macos-{generals,zh}.sh: setNSHighResolutionCapable=true. Without it macOS gives the app a 1x backing store and the flag above has no effect.DX8Wrapper::Pillarbox_Setup(dx8wrapper.cpp): populate the pixel density even when the backbuffer size comes from the present parameters.Pillarbox_Get_Rectdivides by that density to convert the viewport back to points for input mapping; with it left at 1.0, clicks landed at roughly half position.getWindowSizemust query pixels, not points. It is vendored here ascmake/patches/dxvk-macos-hidpi-wsi.patchand applied in the DXVKExternalProjectPATCH_COMMAND, so a default build picks it up automatically. Once the fix lands in the pinned DXVK ref, the patch, thePATCH_COMMAND, and this note can be removed andDXVK_REMOTE_REFbumped. A companion PR tofbraz3/dxvkwill carry that change upstream.Testing: GeneralsMD (Zero Hour) fullscreen on a 14" M4 Pro (3024x1964). Before: soft, or corner-cropped once the high-density flag was on. After: fills the screen at native 3024x1898, sharp, with working menu and in-game input. Played a full skirmish to confirm gameplay input.
The vendored patch lets this branch build and run standalone until the DXVK change merges.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Gpbm3zSo8ggFfLaRByKoaC