GPU: Further improve vsync handling
This commit is contained in:
@ -147,3 +147,24 @@ void CocoaTools::DestroyMetalLayer(WindowInfo* wi)
|
||||
[view setWantsLayer:NO];
|
||||
[layer release];
|
||||
}
|
||||
|
||||
std::optional<float> CocoaTools::GetViewRefreshRate(const WindowInfo& wi)
|
||||
{
|
||||
if (![NSThread isMainThread])
|
||||
{
|
||||
std::optional<float> ret;
|
||||
dispatch_sync(dispatch_get_main_queue(), [&ret, wi]{ ret = GetViewRefreshRate(wi); });
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::optional<float> ret;
|
||||
NSView* const view = (__bridge NSView*)wi.window_handle;
|
||||
const u32 did = [[[[[view window] screen] deviceDescription] valueForKey:@"NSScreenNumber"] unsignedIntValue];
|
||||
if (CGDisplayModeRef mode = CGDisplayCopyDisplayMode(did))
|
||||
{
|
||||
ret = CGDisplayModeGetRefreshRate(mode);
|
||||
CGDisplayModeRelease(mode);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user