metal: Respect the vsync flag on macOS 10.13+.
authorAlex Szpakowski <slime73@gmail.com>
Sat, 30 Dec 2017 22:39:55 -0400
changeset 11790a5620934cf56
parent 11789 01f9851b2c9d
child 11791 c2827923649c
metal: Respect the vsync flag on macOS 10.13+.
src/render/metal/SDL_render_metal.m
     1.1 --- a/src/render/metal/SDL_render_metal.m	Sat Dec 30 20:32:22 2017 -0400
     1.2 +++ b/src/render/metal/SDL_render_metal.m	Sat Dec 30 22:39:55 2017 -0400
     1.3 @@ -356,8 +356,14 @@
     1.4      renderer->info = METAL_RenderDriver.info;
     1.5      renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
     1.6  
     1.7 -    // !!! FIXME: how do you control this in Metal?
     1.8 -    renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
     1.9 +#if defined(__MACOSX__) && defined(MAC_OS_X_VERSION_10_13)
    1.10 +    if (@available(macOS 10.13, *)) {
    1.11 +        layer.displaySyncEnabled = (flags & SDL_RENDERER_PRESENTVSYNC) != 0;
    1.12 +    } else
    1.13 +#endif
    1.14 +    {
    1.15 +        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
    1.16 +    }
    1.17  
    1.18      return renderer;
    1.19  }