From 7d8c7dd70ab9ed41226f89d9bf7e477108a99a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 20 Feb 2025 13:54:50 -0600 Subject: [PATCH] macOS SDL: Set the metal layer resolution properly, remove DPI hacks. Fixes #19183 Thanks to @schm1dtmac for the fix. @shm1dtmac also mentions that this may have issues when moving the window between displays, but this should still be an improvement for most people. --- SDL/SDLCocoaMetalLayer.mm | 1 + SDL/SDLMain.cpp | 16 ++-------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/SDL/SDLCocoaMetalLayer.mm b/SDL/SDLCocoaMetalLayer.mm index cb7bd551923e..539a91c7f878 100644 --- a/SDL/SDLCocoaMetalLayer.mm +++ b/SDL/SDLCocoaMetalLayer.mm @@ -17,6 +17,7 @@ if (![view.layer isKindOfClass:[CAMetalLayer class]]) { [view setLayer:[CAMetalLayer layer]]; + [[view layer] setContentsScale:[window backingScaleFactor]]; } return view.layer; #else diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index 0ee28bec6dd4..7a553df63e28 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -185,8 +185,8 @@ static void StopSDLAudioDevice() { } static void UpdateScreenDPI(SDL_Window *window) { - int drawable_width, window_width; - SDL_GetWindowSize(window, &window_width, NULL); + int drawable_width, window_width, window_height; + SDL_GetWindowSize(window, &window_width, &window_height); if (g_Config.iGPUBackend == (int)GPUBackend::OPENGL) SDL_GL_GetDrawableSize(window, &drawable_width, NULL); @@ -200,13 +200,6 @@ static void UpdateScreenDPI(SDL_Window *window) { // Round up a little otherwise there would be a gap sometimes // in fractional scaling g_DesktopDPI = ((float) drawable_width + 1.0f) / window_width; - - // Temporary hack -#if PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(IOS) - if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN) { - g_DesktopDPI = 1.0f; - } -#endif } // Simple implementations of System functions @@ -1438,11 +1431,6 @@ int main(int argc, char *argv[]) { } #endif } -#if PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(IOS) - if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN) { - g_ForcedDPI = 1.0f; - } -#endif UpdateScreenDPI(window);