Skip to content

Commit

Permalink
[Metal] Use 'setDisplaySyncEnabled' on CAMetalLayer to control vsync …
Browse files Browse the repository at this point in the history
…in MTSwapChain (fixes #117).
  • Loading branch information
LukasBanana committed Jun 12, 2024
1 parent ec3e3d3 commit 54b58d3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sources/Renderer/Metal/MTSwapChain.mm
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,14 @@ - (void)mtkView:(nonnull MTKView *)view drawableSizeWillChange:(CGSize)size
view_.preferredFramesPerSecond = static_cast<NSInteger>(display->GetDisplayMode().refreshRate / vsyncInterval);
else
view_.preferredFramesPerSecond = defaultRefreshRate / static_cast<NSInteger>(vsyncInterval);

/* Enable display sync in CAMetalLayer */
[(CAMetalLayer*)[view_ layer] setDisplaySyncEnabled:YES];
}
else
{
/* Set preferred frame rate to default value */
view_.preferredFramesPerSecond = defaultRefreshRate;
/* Disable display sync in CAMetalLayer */
[(CAMetalLayer*)[view_ layer] setDisplaySyncEnabled:NO];
}
return true;
}
Expand Down

0 comments on commit 54b58d3

Please sign in to comment.