(Context drivers) Cleanups

This commit is contained in:
twinaphex 2020-07-17 14:53:49 +02:00
parent 7c66a7457a
commit 3983a19281
7 changed files with 28 additions and 88 deletions

View File

@ -56,8 +56,6 @@ extern CGLError CGLSetSurface(CGLContextObj gl, CGSConnectionID cid, CGSWindowID
} }
#endif #endif
static enum gfx_ctx_api cgl_api = GFX_CTX_NONE;
typedef struct gfx_ctx_cgl_data typedef struct gfx_ctx_cgl_data
{ {
CGLContextObj glCtx; CGLContextObj glCtx;
@ -150,16 +148,13 @@ static gfx_ctx_proc_t gfx_ctx_cgl_get_proc_address(const char *symbol_name)
static bool gfx_ctx_cgl_has_focus(void *data) { return true; } static bool gfx_ctx_cgl_has_focus(void *data) { return true; }
static bool gfx_ctx_cgl_suppress_screensaver(void *data, bool enable) { return false; } static bool gfx_ctx_cgl_suppress_screensaver(void *data, bool enable) { return false; }
static enum gfx_ctx_api gfx_ctx_cgl_get_api(void *data) { return cgl_api; } static enum gfx_ctx_api gfx_ctx_cgl_get_api(void *data) { return GFX_CTX_OPENGL_API; }
static bool gfx_ctx_cgl_bind_api(void *data, enum gfx_ctx_api api, static bool gfx_ctx_cgl_bind_api(void *data, enum gfx_ctx_api api,
unsigned major, unsigned minor) unsigned major, unsigned minor)
{ {
if (api == GFX_CTX_OPENGL_API) if (api == GFX_CTX_OPENGL_API)
{
cgl_api = api;
return true; return true;
}
return false; return false;
} }

View File

@ -588,9 +588,19 @@ static bool gfx_ctx_drm_egl_set_video_mode(gfx_ctx_drm_data_t *drm)
if (!egl_create_surface(&drm->egl, (EGLNativeWindowType)g_gbm_surface)) if (!egl_create_surface(&drm->egl, (EGLNativeWindowType)g_gbm_surface))
return false; return false;
switch (drm_api)
{
case GFX_CTX_OPENGL_API:
case GFX_CTX_OPENGL_ES_API:
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
#endif #endif
break;
case GFX_CTX_NONE:
default:
break;
}
#endif #endif
egl_swap_buffers(drm); egl_swap_buffers(drm);

View File

@ -27,8 +27,6 @@
#include "../common/switch_common.h" #include "../common/switch_common.h"
#include "../../frontend/frontend_driver.h" #include "../../frontend/frontend_driver.h"
static enum gfx_ctx_api ctx_nx_api = GFX_CTX_OPENGL_API;
extern bool platform_switch_has_focus; extern bool platform_switch_has_focus;
void switch_ctx_destroy(void *data) void switch_ctx_destroy(void *data)
@ -197,15 +195,12 @@ static void switch_ctx_input_driver(void *data,
static enum gfx_ctx_api switch_ctx_get_api(void *data) static enum gfx_ctx_api switch_ctx_get_api(void *data)
{ {
return ctx_nx_api; return GFX_CTX_OPENGL_API;
} }
static bool switch_ctx_bind_api(void *data, static bool switch_ctx_bind_api(void *data,
enum gfx_ctx_api api, unsigned major, unsigned minor) enum gfx_ctx_api api, unsigned major, unsigned minor)
{ {
(void)data;
ctx_nx_api = api;
if (api == GFX_CTX_OPENGL_API) if (api == GFX_CTX_OPENGL_API)
if (egl_bind_api(EGL_OPENGL_API)) if (egl_bind_api(EGL_OPENGL_API))
return true; return true;

View File

@ -52,14 +52,13 @@
#include "../common/angle_common.h" #include "../common/angle_common.h"
#endif #endif
static egl_ctx_data_t uwp_egl;
#ifdef HAVE_DYNAMIC #ifdef HAVE_DYNAMIC
static dylib_t dll_handle = NULL; /* Handle to libGLESv2.dll */ static dylib_t dll_handle = NULL; /* Handle to libGLESv2.dll */
#endif #endif
static void gfx_ctx_uwp_destroy(void *data); static int uwp_interval = 0;
static egl_ctx_data_t uwp_egl;
static int uwp_interval = 0;
typedef struct gfx_ctx_cgl_data typedef struct gfx_ctx_cgl_data
{ {
@ -131,7 +130,6 @@ static void gfx_ctx_uwp_check_window(void *data, bool *quit,
win32_check_window(quit, resize, width, height); win32_check_window(quit, resize, width, height);
} }
static gfx_ctx_proc_t gfx_ctx_uwp_get_proc_address(const char* symbol) static gfx_ctx_proc_t gfx_ctx_uwp_get_proc_address(const char* symbol)
{ {
#ifdef HAVE_DYNAMIC #ifdef HAVE_DYNAMIC
@ -162,7 +160,6 @@ static void *gfx_ctx_uwp_init(void *video_driver)
if (!uwp) if (!uwp)
return NULL; return NULL;
#ifdef HAVE_DYNAMIC #ifdef HAVE_DYNAMIC
dll_handle = dylib_load("libGLESv2.dll"); dll_handle = dylib_load("libGLESv2.dll");
#endif #endif

View File

@ -43,8 +43,6 @@ typedef struct
unsigned width, height; unsigned width, height;
} vivante_ctx_data_t; } vivante_ctx_data_t;
static enum gfx_ctx_api viv_api = GFX_CTX_NONE;
static void gfx_ctx_vivante_destroy(void *data) static void gfx_ctx_vivante_destroy(void *data)
{ {
vivante_ctx_data_t *viv = (vivante_ctx_data_t*)data; vivante_ctx_data_t *viv = (vivante_ctx_data_t*)data;
@ -188,14 +186,12 @@ static void gfx_ctx_vivante_input_driver(void *data,
static enum gfx_ctx_api gfx_ctx_vivante_get_api(void *data) static enum gfx_ctx_api gfx_ctx_vivante_get_api(void *data)
{ {
return viv_api; return GFX_CTX_OPENGL_ES_API;
} }
static bool gfx_ctx_vivante_bind_api(void *data, static bool gfx_ctx_vivante_bind_api(void *data,
enum gfx_ctx_api api, unsigned major, unsigned minor) enum gfx_ctx_api api, unsigned major, unsigned minor)
{ {
viv_api = api;
if (api == GFX_CTX_OPENGL_ES_API) if (api == GFX_CTX_OPENGL_ES_API)
return true; return true;
return false; return false;

View File

@ -49,18 +49,17 @@
#include "../common/vulkan_common.h" #include "../common/vulkan_common.h"
typedef struct gfx_ctx_w_vk_data
{
void *empty;
} gfx_ctx_w_vk_data_t;
/* TODO/FIXME - static globals */ /* TODO/FIXME - static globals */
static gfx_ctx_vulkan_data_t win32_vk; static gfx_ctx_vulkan_data_t win32_vk;
static void *dinput_vk_wgl = NULL; static void *dinput_vk_wgl = NULL;
static int win32_vk_interval = 0; static int win32_vk_interval = 0;
static enum gfx_ctx_api win32_vk_api = GFX_CTX_NONE;
typedef struct gfx_ctx_w_vk_data
{
void *empty;
} gfx_ctx_w_vk_data_t;
void create_vk_context(HWND hwnd, bool *quit) void create_vk_context(HWND hwnd, bool *quit)
{ {
@ -276,13 +275,11 @@ static void gfx_ctx_w_vk_input_driver(void *data,
#endif #endif
} }
static enum gfx_ctx_api gfx_ctx_w_vk_get_api(void *data) { return win32_vk_api; } static enum gfx_ctx_api gfx_ctx_w_vk_get_api(void *data) { return GFX_CTX_VULKAN_API; }
static bool gfx_ctx_w_vk_bind_api(void *data, static bool gfx_ctx_w_vk_bind_api(void *data,
enum gfx_ctx_api api, unsigned major, unsigned minor) enum gfx_ctx_api api, unsigned major, unsigned minor)
{ {
win32_vk_api = api;
if (api == GFX_CTX_VULKAN_API) if (api == GFX_CTX_VULKAN_API)
return true; return true;
return false; return false;

View File

@ -45,12 +45,6 @@
/* Generated from xdg-decoration-unstable-v1.h */ /* Generated from xdg-decoration-unstable-v1.h */
#include "../common/wayland/xdg-decoration-unstable-v1.h" #include "../common/wayland/xdg-decoration-unstable-v1.h"
static enum gfx_ctx_api wl_api = GFX_CTX_NONE;
#ifndef EGL_OPENGL_ES3_BIT_KHR
#define EGL_OPENGL_ES3_BIT_KHR 0x0040
#endif
#ifndef EGL_PLATFORM_WAYLAND_KHR #ifndef EGL_PLATFORM_WAYLAND_KHR
#define EGL_PLATFORM_WAYLAND_KHR 0x31D8 #define EGL_PLATFORM_WAYLAND_KHR 0x31D8
#endif #endif
@ -423,18 +417,10 @@ static void gfx_ctx_wl_destroy(void *data)
gfx_ctx_wl_destroy_resources(wl); gfx_ctx_wl_destroy_resources(wl);
switch (wl_api)
{
case GFX_CTX_VULKAN_API:
#if defined(HAVE_THREADS) #if defined(HAVE_THREADS)
if (wl->vk.context.queue_lock) if (wl->vk.context.queue_lock)
slock_free(wl->vk.context.queue_lock); slock_free(wl->vk.context.queue_lock);
#endif #endif
break;
case GFX_CTX_NONE:
default:
break;
}
free(wl); free(wl);
} }
@ -603,16 +589,11 @@ static bool gfx_ctx_wl_suppress_screensaver(void *data, bool state)
return true; return true;
} }
static enum gfx_ctx_api gfx_ctx_wl_get_api(void *data) static enum gfx_ctx_api gfx_ctx_wl_get_api(void *data) { return GFX_CTX_VULKAN_API; }
{
return wl_api;
}
static bool gfx_ctx_wl_bind_api(void *video_driver, static bool gfx_ctx_wl_bind_api(void *video_driver,
enum gfx_ctx_api api, unsigned major, unsigned minor) enum gfx_ctx_api api, unsigned major, unsigned minor)
{ {
wl_api = api;
if (api == GFX_CTX_VULKAN_API) if (api == GFX_CTX_VULKAN_API)
return true; return true;
return false; return false;
@ -645,45 +626,14 @@ static uint32_t gfx_ctx_wl_get_flags(void *data)
uint32_t flags = 0; uint32_t flags = 0;
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
if (wl->core_hw_context_enable)
BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT);
switch (wl_api)
{
case GFX_CTX_OPENGL_API:
case GFX_CTX_OPENGL_ES_API:
if (string_is_equal(video_driver_get_ident(), "glcore"))
{
#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS) #if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS)
BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_SLANG); BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_SLANG);
#endif #endif
}
else if (string_is_equal(video_driver_get_ident(), "gl"))
{
#ifdef HAVE_GLSL
BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_GLSL);
#endif
}
break;
case GFX_CTX_VULKAN_API:
#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS)
BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_SLANG);
#endif
break;
case GFX_CTX_NONE:
default:
break;
}
return flags; return flags;
} }
static void gfx_ctx_wl_set_flags(void *data, uint32_t flags) static void gfx_ctx_wl_set_flags(void *data, uint32_t flags) { }
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT))
wl->core_hw_context_enable = true;
}
static float gfx_ctx_wl_get_refresh_rate(void *data) static float gfx_ctx_wl_get_refresh_rate(void *data)
{ {