Skip to content

sdl3 wsi: size the swapchain in pixels on HiDPI displays#1

Merged
fbraz3 merged 1 commit into
fbraz3:generalsx-macos-v2.6from
wormeyman:fix/macos-hidpi-wsi-pixel-size
Jul 12, 2026
Merged

sdl3 wsi: size the swapchain in pixels on HiDPI displays#1
fbraz3 merged 1 commit into
fbraz3:generalsx-macos-v2.6from
wormeyman:fix/macos-hidpi-wsi-pixel-size

Conversation

@wormeyman

Copy link
Copy Markdown

On macOS Retina displays, Sdl3WsiDriver::getWindowSize returns logical points via SDL_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 getWindowSize to use SDL_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: add SDL_GetWindowSizeInPixels to the proc table
  • src/wsi/sdl3/wsi_window_sdl3.cpp: getWindowSize queries pixels instead of points

This 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

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
@fbraz3

fbraz3 commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Great catch!

@fbraz3
fbraz3 merged commit 1132d30 into fbraz3:generalsx-macos-v2.6 Jul 12, 2026
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.

2 participants