diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index 2bb0547f35..976c02cb05 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -539,8 +539,15 @@ static void *android_gfx_ctx_get_context_data(void *data) static uint32_t android_gfx_ctx_get_flags(void *data) { - (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + + return flags; +} + +static void android_gfx_ctx_set_flags(void *data, uint32_t flags) +{ + (void)flags; } const gfx_ctx_driver_t gfx_ctx_android = { @@ -569,6 +576,7 @@ const gfx_ctx_driver_t gfx_ctx_android = { NULL, "android", android_gfx_ctx_get_flags, + android_gfx_ctx_set_flags, android_gfx_ctx_bind_hw_render, #ifdef HAVE_VULKAN android_gfx_ctx_get_context_data diff --git a/gfx/drivers_context/bbqnx_ctx.c b/gfx/drivers_context/bbqnx_ctx.c index 947df8e918..34981e6bc6 100644 --- a/gfx/drivers_context/bbqnx_ctx.c +++ b/gfx/drivers_context/bbqnx_ctx.c @@ -400,8 +400,14 @@ static void gfx_ctx_qnx_get_video_size(void *data, static uint32_t gfx_ctx_qnx_get_flags(void *data) { - (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void gfx_ctx_qnx_set_flags(void *data, uint32_t flags) +{ + (void)flags; } const gfx_ctx_driver_t gfx_ctx_bbqnx = { @@ -430,5 +436,6 @@ const gfx_ctx_driver_t gfx_ctx_bbqnx = { NULL, "blackberry_qnx", gfx_ctx_qnx_get_flags, + gfx_ctx_qnx_set_flags, gfx_ctx_qnx_bind_hw_render }; diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index 2d24b75fea..c16b5c121b 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -341,9 +341,15 @@ error: } static uint32_t gfx_ctx_cgl_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void gfx_ctx_cgl_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_cgl = { @@ -372,5 +378,6 @@ const gfx_ctx_driver_t gfx_ctx_cgl = { gfx_ctx_cgl_show_mouse, "cgl", gfx_ctx_cgl_get_flags, - gfx_ctx_cgl_bind_hw_render, + gfx_ctx_cgl_set_flags, + gfx_ctx_cgl_bind_hw_render }; diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index dde8ab6ee4..0563fcc439 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -597,8 +597,14 @@ static void cocoagl_gfx_ctx_bind_hw_render(void *data, bool enable) static uint32_t cocoagl_gfx_ctx_get_flags(void *data) { - (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void cocoagl_gfx_ctx_set_flags(void *data, uint32_t flags) +{ + (void)flags; } const gfx_ctx_driver_t gfx_ctx_cocoagl = { @@ -627,5 +633,6 @@ const gfx_ctx_driver_t gfx_ctx_cocoagl = { NULL, "cocoagl", cocoagl_gfx_ctx_get_flags, + cocoagl_gfx_ctx_set_flags, cocoagl_gfx_ctx_bind_hw_render, }; diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 58ec05682f..9cf38a7742 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -304,8 +304,15 @@ static bool gfx_ctx_d3d_get_metrics(void *data, static uint32_t gfx_ctx_d3d_get_flags(void *data) { - (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + + return flags; +} + +static void gfx_ctx_d3d_set_flags(void *data, uint32_t flags) +{ + (void)flags; } const gfx_ctx_driver_t gfx_ctx_d3d = { @@ -334,4 +341,5 @@ const gfx_ctx_driver_t gfx_ctx_d3d = { gfx_ctx_d3d_show_mouse, "d3d", gfx_ctx_d3d_get_flags, + gfx_ctx_d3d_set_flags }; diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index dc662835bb..b6d3ba4b89 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -80,6 +80,8 @@ typedef struct gfx_ctx_drm_data unsigned interval; unsigned fb_width; unsigned fb_height; + + bool core_hw_context_enable; } gfx_ctx_drm_data_t; struct drm_fb @@ -871,11 +873,25 @@ static void gfx_ctx_drm_bind_hw_render(void *data, bool enable) } static uint32_t gfx_ctx_drm_get_flags(void *data) +{ + uint32_t flags = 0; + gfx_ctx_drm_data_t *drm = (gfx_ctx_drm_data_t*)data; + + if (drm->core_hw_context_enable) + { + BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); + } + else + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + + return flags; +} + +static void gfx_ctx_drm_set_flags(void *data, uint32_t flags) { gfx_ctx_drm_data_t *drm = (gfx_ctx_drm_data_t*)data; - if ((drm->egl.major * 1000 + drm->egl.minor) >= 3001) - return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); - return 1UL << GFX_CTX_FLAGS_NONE; + if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) + drm->core_hw_context_enable = true; } const gfx_ctx_driver_t gfx_ctx_drm = { @@ -904,5 +920,6 @@ const gfx_ctx_driver_t gfx_ctx_drm = { NULL, "kms", gfx_ctx_drm_get_flags, + gfx_ctx_drm_set_flags, gfx_ctx_drm_bind_hw_render }; diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index 80bd2d91cc..793a5dcad0 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -304,9 +304,15 @@ static void gfx_ctx_emscripten_bind_hw_render(void *data, bool enable) } static uint32_t gfx_ctx_emscripten_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void gfx_ctx_emscripten_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_emscripten = { @@ -335,5 +341,6 @@ const gfx_ctx_driver_t gfx_ctx_emscripten = { NULL, "emscripten", gfx_ctx_emscripten_get_flags, + gfx_ctx_emscripten_set_flags, gfx_ctx_emscripten_bind_hw_render }; diff --git a/gfx/drivers_context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index 055bd6b0ae..589da8d7fa 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -134,9 +134,16 @@ static void *gfx_ctx_null_init(void *video_driver) } static uint32_t gfx_ctx_null_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + + return flags; +} + +static void gfx_ctx_null_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_null = { @@ -165,6 +172,7 @@ const gfx_ctx_driver_t gfx_ctx_null = { gfx_ctx_null_show_mouse, "null", gfx_ctx_null_get_flags, + gfx_ctx_null_set_flags, gfx_ctx_null_bind_hw_render }; diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index ac47fb7893..7f6d833b73 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -292,9 +292,16 @@ static void gfx_ctx_mali_fbdev_bind_hw_render(void *data, bool enable) } static uint32_t gfx_ctx_mali_fbdev_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + + return flags; +} + +static void gfx_ctx_mali_fbdev_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_mali_fbdev = { @@ -323,6 +330,7 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = { NULL, "mali-fbdev", gfx_ctx_mali_fbdev_get_flags, + gfx_ctx_mali_fbdev_set_flags, gfx_ctx_mali_fbdev_bind_hw_render }; diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index 34ff6c09df..d2a7971b6c 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -268,9 +268,15 @@ static void gfx_ctx_opendingux_bind_hw_render(void *data, bool enable) } static uint32_t gfx_ctx_opendingux_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void gfx_ctx_opendingux_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev = { @@ -299,5 +305,6 @@ const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev = { NULL, "opendingux-fbdev", gfx_ctx_opendingux_get_flags, + gfx_ctx_opendingux_set_flags, gfx_ctx_opendingux_bind_hw_render }; diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index 9b65b6d857..33de8136d8 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -415,9 +415,15 @@ static void gfx_ctx_ps3_get_video_output_next(void *data) } static uint32_t gfx_ctx_ps3_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void gfx_ctx_ps3_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_ps3 = { @@ -446,5 +452,6 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = { NULL, "ps3", gfx_ctx_ps3_get_flags, + gfx_ctx_ps3_set_flags }; diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index 3ab6f5ada9..c5c9ef890c 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -401,9 +401,15 @@ static void sdl_ctx_show_mouse(void *data, bool state) } static uint32_t sdl_ctx_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void sdl_ctx_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_sdl_gl = @@ -433,5 +439,6 @@ const gfx_ctx_driver_t gfx_ctx_sdl_gl = sdl_ctx_show_mouse, "sdl_gl", sdl_ctx_get_flags, + sdl_ctx_set_flags, NULL /* bind_hw_render */ }; diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 05d8bd83c1..d8fde21683 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -625,9 +625,15 @@ static gfx_ctx_proc_t gfx_ctx_vc_get_proc_address(const char *symbol) } static uint32_t gfx_ctx_vc_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void gfx_ctx_vc_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_videocore = { @@ -656,5 +662,6 @@ const gfx_ctx_driver_t gfx_ctx_videocore = { NULL, "videocore", gfx_ctx_vc_get_flags, + gfx_ctx_vc_set_flags, gfx_ctx_vc_bind_hw_render }; diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index 5c6ac27acc..4a554fc33b 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -262,9 +262,15 @@ static void gfx_ctx_vivante_swap_buffers(void *data) } static uint32_t gfx_ctx_vivante_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void gfx_ctx_vivante_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = { @@ -293,5 +299,6 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = { NULL, "vivante-fbdev", gfx_ctx_vivante_get_flags, + gfx_ctx_vivante_set_flags, gfx_ctx_vivante_bind_hw_render }; diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 6efddac860..f7fedd1f22 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -66,6 +66,7 @@ typedef struct gfx_ctx_wayland_data struct wl_keyboard *wl_keyboard; struct wl_pointer *wl_pointer; unsigned swap_interval; + bool core_hw_context_enable; unsigned buffer_scale; @@ -1140,10 +1141,24 @@ static void gfx_ctx_wl_bind_hw_render(void *data, bool enable) static uint32_t gfx_ctx_wl_get_flags(void *data) { + uint32_t flags = 0; gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - if ((wl->egl.major * 1000 + wl->egl.minor) >= 3001) - return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); - return 1UL << GFX_CTX_FLAGS_NONE; + + if (wl->core_hw_context_enable) + { + BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); + } + else + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + + return 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; } const gfx_ctx_driver_t gfx_ctx_wayland = { @@ -1172,6 +1187,7 @@ const gfx_ctx_driver_t gfx_ctx_wayland = { NULL, "wayland", gfx_ctx_wl_get_flags, + gfx_ctx_wl_set_flags, gfx_ctx_wl_bind_hw_render, #ifdef HAVE_VULKAN gfx_ctx_wl_get_context_data diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index f5a5c20572..4fb452c70d 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -70,6 +70,7 @@ static bool g_use_hw_ctx; static HGLRC g_hrc; static HGLRC g_hw_hrc; static HDC g_hdc; +static bool g_core_hw_context_enable; static unsigned g_major; static unsigned g_minor; @@ -306,7 +307,7 @@ static void *gfx_ctx_wgl_init(void *video_driver) if (g_inited) return NULL; - + win32_window_reset(); win32_monitor_init(); @@ -353,12 +354,14 @@ static void gfx_ctx_wgl_destroy(void *data) if (g_restore_desktop) { win32_monitor_get_info(); - g_restore_desktop = false; + g_restore_desktop = false; } - g_inited = false; - g_major = g_minor = 0; - p_swap_interval = NULL; + g_core_hw_context_enable = false; + g_inited = false; + g_major = 0; + g_minor = 0; + p_swap_interval = NULL; } static bool gfx_ctx_wgl_set_video_mode(void *data, @@ -450,10 +453,23 @@ static void gfx_ctx_wgl_bind_hw_render(void *data, bool enable) static uint32_t gfx_ctx_wgl_get_flags(void *data) { - (void)data; - if ((g_major * 1000 + g_minor) >= 3001) - return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); - return (1UL << GFX_CTX_FLAGS_NONE); + uint32_t flags = 0; + if (g_core_hw_context_enable) + { + BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); + } + else + { + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + } + return falgs; +} + +static void gfx_ctx_wgl_set_flags(void *data, uint32_t flags) +{ + uint32_t flags = 0; + if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) + g_core_hw_context_enable = true; } const gfx_ctx_driver_t gfx_ctx_wgl = { @@ -482,6 +498,7 @@ const gfx_ctx_driver_t gfx_ctx_wgl = { gfx_ctx_wgl_show_mouse, "wgl", gfx_ctx_wgl_get_flags, + gfx_ctx_wgl_set_flags, gfx_ctx_wgl_bind_hw_render }; diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 8dfe02d9cc..d26f6967d8 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -44,6 +44,7 @@ typedef struct gfx_ctx_x_data bool g_debug; bool g_should_reset_mode; bool g_is_double; + bool core_hw_context_enable; #ifdef HAVE_OPENGL GLXWindow g_glx_win; @@ -888,10 +889,24 @@ static void *gfx_ctx_x_get_context_data(void *data) static uint32_t gfx_ctx_x_get_flags(void *data) { + uint32_t flags = 0; gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data; - if (x->g_core_es_core) - return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); - return 1UL << GFX_CTX_FLAGS_NONE; + if (x->core_hw_context_enable) + { + BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); + } + else + { + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + } + return flags; +} + +static void gfx_ctx_x_set_flags(void *data, uint32_t flags) +{ + gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data; + if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) + x->core_hw_context_enable = true; } const gfx_ctx_driver_t gfx_ctx_x = { @@ -920,10 +935,11 @@ const gfx_ctx_driver_t gfx_ctx_x = { gfx_ctx_x_show_mouse, "x", gfx_ctx_x_get_flags, + gfx_ctx_x_set_flags, gfx_ctx_x_bind_hw_render, #ifdef HAVE_VULKAN - gfx_ctx_x_get_context_data, + gfx_ctx_x_get_context_data #else NULL #endif diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index bbe05755c3..21aa905c95 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -576,11 +576,14 @@ static gfx_ctx_proc_t gfx_ctx_xegl_get_proc_address(const char *symbol) static uint32_t gfx_ctx_xegl_get_flags(void *data) { - xegl_ctx_data_t *xegl = (xegl_ctx_data_t*)data; + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} - if ((xegl->egl.major * 1000 + xegl->egl.minor) >= 3001) - return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); - return 1UL << GFX_CTX_FLAGS_NONE; +static void gfx_ctx_xegl_set_flags(void *data, uint32_t flags) +{ + (void)data; } const gfx_ctx_driver_t gfx_ctx_x_egl = @@ -610,5 +613,6 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = gfx_ctx_xegl_show_mouse, "x-egl", gfx_ctx_xegl_get_flags, + gfx_ctx_xegl_set_flags, gfx_ctx_xegl_bind_hw_render }; diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index d6cdfe7544..6c5538680f 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -191,6 +191,8 @@ typedef struct gfx_ctx_driver uint32_t (*get_flags)(void *data); + void (*set_flags)(void *data, uint32_t flags); + /* Optional. Binds HW-render offscreen context. */ void (*bind_hw_render)(void *data, bool enable);