Add set_flags to context driver

This commit is contained in:
twinaphex 2016-05-05 17:35:28 +02:00
parent b2dac30a5d
commit 60233d1abb
19 changed files with 208 additions and 41 deletions

View File

@ -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

View File

@ -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
};

View File

@ -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
};

View File

@ -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,
};

View File

@ -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
};

View File

@ -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
};

View File

@ -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
};

View File

@ -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
};

View File

@ -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
};

View File

@ -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
};

View File

@ -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
};

View File

@ -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 */
};

View File

@ -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
};

View File

@ -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
};

View File

@ -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

View File

@ -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
};

View File

@ -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

View File

@ -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
};

View File

@ -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);