Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS SDL: Set the metal layer resolution properly, remove DPI hacks. #20011

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SDL/SDLCocoaMetalLayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
if (![view.layer isKindOfClass:[CAMetalLayer class]])
{
[view setLayer:[CAMetalLayer layer]];
[[view layer] setContentsScale:[window backingScaleFactor]];
}
return view.layer;
#else
Expand Down
16 changes: 2 additions & 14 deletions SDL/SDLMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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);

Expand Down
Loading