sdl3 wsi: size the swapchain in pixels on HiDPI displays#1
Merged
fbraz3 merged 1 commit intoJul 12, 2026
Merged
Conversation
getWindowSize returned logical points via SDL_GetWindowSize, but the CAMetalLayer backing the Vulkan surface is in physical pixels. With a high-density drawable (SDL_WINDOW_HIGH_PIXEL_DENSITY) the swapchain was sized in points while the layer was in pixels, so the frame rendered 1:1 in the top-left corner of the window with the rest black. Query SDL_GetWindowSizeInPixels instead, and register it in the SDL proc table. On non-HiDPI displays points equal pixels, so this is a no-op there. Tested with GeneralsX (Zero Hour) on a 14" M4 Pro (3024x1964): before, the game rendered in a quarter of the screen; after, it fills the screen at native resolution. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gpbm3zSo8ggFfLaRByKoaC
Owner
|
Great catch! |
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 macOS Retina displays,
Sdl3WsiDriver::getWindowSizereturns logical points viaSDL_GetWindowSize, but the CAMetalLayer backing the Vulkan surface is in physical pixels. When the consumer requests a high-density drawable (SDL_WINDOW_HIGH_PIXEL_DENSITY), the swapchain gets sized in points while the layer is in pixels, so the rendered frame lands 1:1 in the top-left corner of the window and the rest stays black.This changes
getWindowSizeto useSDL_GetWindowSizeInPixels, which is the size the swapchain and present path actually need. It also registers that function in the SDL proc-loader table.On non-HiDPI displays points equal pixels, so this is a no-op there.
Tested with GeneralsX (Zero Hour) on a 14" M4 Pro (3024x1964): before, the game rendered in a quarter of the screen; after, it fills the screen at native resolution.
Changes:
src/wsi/sdl3/wsi_platform_sdl3_funcs.h: addSDL_GetWindowSizeInPixelsto the proc tablesrc/wsi/sdl3/wsi_window_sdl3.cpp:getWindowSizequeries pixels instead of pointsThis is the DXVK half of the macOS HiDPI fix; the GeneralsX side is fbraz3/GeneralsX#204, which currently vendors this same change as a patch until it lands here.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Gpbm3zSo8ggFfLaRByKoaC