From b1c4bdf6f733a70e3b3f68a9fc32066adc88e550 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 Feb 2019 01:24:41 +0100 Subject: [PATCH] (Cocoa) Cleanups --- gfx/drivers_context/cocoa_gl_ctx.m | 15 --------- gfx/drivers_context/cocoa_gl_ctx_metal.m | 37 ---------------------- gfx/drivers_context/cocoa_gl_shared.h | 39 ++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 52 deletions(-) diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index f55392b1d6..70debb0f0c 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -46,21 +46,6 @@ static bool cocoagl_gfx_ctx_bind_api(void *data, return true; } -static void cocoagl_gfx_ctx_swap_interval(void *data, int i) -{ - (void)data; - unsigned interval = (unsigned)i; -#if defined(HAVE_COCOATOUCH) // < No way to disable Vsync on iOS? - // Just skip presents so fast forward still works. - g_is_syncing = interval ? true : false; - g_fast_forward_skips = interval ? 0 : 3; -#elif defined(HAVE_COCOA) - GLint value = interval ? 1 : 0; - [g_context setValues:&value forParameter:NSOpenGLCPSwapInterval]; - -#endif -} - static bool cocoagl_gfx_ctx_set_video_mode(void *data, video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) diff --git a/gfx/drivers_context/cocoa_gl_ctx_metal.m b/gfx/drivers_context/cocoa_gl_ctx_metal.m index 2952cf401b..1e477b5c55 100644 --- a/gfx/drivers_context/cocoa_gl_ctx_metal.m +++ b/gfx/drivers_context/cocoa_gl_ctx_metal.m @@ -83,43 +83,6 @@ static bool cocoagl_gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, return true; } -static void cocoagl_gfx_ctx_swap_interval(void *data, int interval) -{ -#ifdef HAVE_VULKAN - cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data; -#endif - - switch (cocoagl_api) - { - case GFX_CTX_OPENGL_API: - case GFX_CTX_OPENGL_ES_API: - { -#if defined(HAVE_COCOATOUCH) // < No way to disable Vsync on iOS? - // Just skip presents so fast forward still works. - g_is_syncing = interval ? true : false; - g_fast_forward_skips = interval ? 0 : 3; -#elif defined(HAVE_COCOA_METAL) - GLint value = interval ? 1 : 0; - [g_context setValues:&value forParameter:NSOpenGLCPSwapInterval]; -#endif - break; - } - case GFX_CTX_VULKAN_API: -#ifdef HAVE_VULKAN - if (cocoa_ctx->swap_interval != interval) - { - cocoa_ctx->swap_interval = interval; - if (cocoa_ctx->vk.swapchain) - cocoa_ctx->vk.need_new_swapchain = true; - } -#endif - break; - case GFX_CTX_NONE: - default: - break; - } - -} static bool cocoagl_gfx_ctx_set_video_mode(void *data, video_frame_info_t *video_info, diff --git a/gfx/drivers_context/cocoa_gl_shared.h b/gfx/drivers_context/cocoa_gl_shared.h index 9580a8bff8..59f4e35ee7 100644 --- a/gfx/drivers_context/cocoa_gl_shared.h +++ b/gfx/drivers_context/cocoa_gl_shared.h @@ -544,3 +544,42 @@ static void cocoagl_gfx_ctx_check_window(void *data, bool *quit, *resize = true; } } + +static void cocoagl_gfx_ctx_swap_interval(void *data, int i) +{ + unsigned interval = (unsigned)i; +#ifdef HAVE_VULKAN + cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data; +#endif + + switch (cocoagl_api) + { + case GFX_CTX_OPENGL_API: + case GFX_CTX_OPENGL_ES_API: + { +#if defined(HAVE_COCOATOUCH) // < No way to disable Vsync on iOS? + // Just skip presents so fast forward still works. + g_is_syncing = interval ? true : false; + g_fast_forward_skips = interval ? 0 : 3; +#elif defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL) + GLint value = interval ? 1 : 0; + [g_context setValues:&value forParameter:NSOpenGLCPSwapInterval]; +#endif + break; + } + case GFX_CTX_VULKAN_API: +#ifdef HAVE_VULKAN + if (cocoa_ctx->swap_interval != interval) + { + cocoa_ctx->swap_interval = interval; + if (cocoa_ctx->vk.swapchain) + cocoa_ctx->vk.need_new_swapchain = true; + } +#endif + break; + case GFX_CTX_NONE: + default: + break; + } + +}