KhronosGroup / MoltenVK

MoltenVK is a Vulkan Portability implementation. It layers a subset of the high-performance, industry-standard Vulkan graphics and compute API over Apple's Metal graphics framework, enabling Vulkan applications to run on macOS, iOS and tvOS.
Apache License 2.0
4.63k stars 402 forks source link

Fullscreen Performance Degredation #2259

Open Muketsu opened 6 days ago

Muketsu commented 6 days ago

Hello!

I've come across an issue where Vulkan framerate seems to drop off when an application enters fullscreen mode. Before I get into the details, I'm using an M1 Max MacBook Pro 16 inch, no external monitors are connected, and I've got the latest version of MacOS (14.5) and the latest Vulkan SDK for Mac from LunarG.

I’m working on a tech demo game engine that’s rendering part of a 3D scene with Vulkan and GLFW, and I also have a basic FPS counter implemented to track performance. Since MacOS usually imposes a system-wide Vsync, it runs at a consistent 120 FPS in windowed mode. As soon as I go to fullscreen mode, though, it drops down to about 80-90 FPS and gets stuck there.

At first I thought this might be related to fullscreen using more resolution, but if I turn off Vsync by using the MacOS Quartz debug tools, the FPS performance hovers between 140-180 FPS, regardless of if it’s in windowed or fullscreen mode. So from a hardware perspective, the system should be able to output more than enough frames to keep pace with the 120 Hz refresh rate.

I’m wondering if it could be related to MacOS’s Vsync and how it interacts with the variable refresh rate in the ProMotion retina screen, so I tried setting the MacBook screen to a fixed 60 Hz resolution, and doing that I got a smooth 60 Hz in windows and fullscreen mode.

I was also able to reproduce the same behavior in the default Vulkan cube demo app that comes with the SDK, by viewing the framerate with the Metal HUD, so I don't think it's related to anything specific in my code itself.

I've never posted an issue here before, so apologies if I didn't format this correctly or if more information is needed.

Thanks for your time!

John

billhollings commented 6 days ago

Thanks for posting this, and thanks for the diligent research you did exploring different scenarios and possible causes! It's great that you explored this with the Cube demo, because it should allow us to easily replicate the issue.

I've never posted an issue here before, so apologies if I didn't format this correctly

No need to apologize. You provided great content!

Muketsu commented 5 days ago

Thanks, I'm glad the information I shared was helpful! Hopefully it can be reproduced pretty easily with the cube, but if there's anything else I can share, or test I can do, I'd be happy to!