Create g_egl_api/g_egl_inited

This commit is contained in:
twinaphex 2015-11-20 13:27:31 +01:00
parent 5aad0ebc1b
commit 1101bb34d3
8 changed files with 44 additions and 48 deletions

@ -28,6 +28,8 @@ EGLContext g_egl_hw_ctx;
EGLSurface g_egl_surf;
EGLDisplay g_egl_dpy;
EGLConfig g_egl_config;
enum gfx_ctx_api g_egl_api;
bool g_egl_inited;
bool g_use_hw_ctx;
unsigned g_interval;
@ -109,6 +111,7 @@ void egl_destroy(void *data)
g_egl_dpy = EGL_NO_DISPLAY;
g_egl_config = 0;
g_egl_quit = 0;
g_egl_api = GFX_CTX_NONE;
}
void egl_bind_hw_render(void *data, bool enable)

@ -32,6 +32,8 @@ extern EGLContext g_egl_hw_ctx;
extern EGLSurface g_egl_surf;
extern EGLDisplay g_egl_dpy;
extern EGLConfig g_egl_config;
extern enum gfx_ctx_api g_egl_api;
extern bool g_egl_inited;
extern bool g_use_hw_ctx;
extern unsigned g_interval;

@ -72,8 +72,6 @@ typedef struct gfx_ctx_drm_egl_data
struct gbm_surface *g_gbm_surface;
} gfx_ctx_drm_egl_data_t;
static enum gfx_ctx_api g_api;
static unsigned g_major;
static unsigned g_minor;
@ -528,7 +526,7 @@ error:
static EGLint *egl_fill_attribs(EGLint *attr)
{
switch (g_api)
switch (g_egl_api)
{
#ifdef EGL_KHR_create_context
case GFX_CTX_OPENGL_API:
@ -643,7 +641,7 @@ static bool gfx_ctx_drm_egl_set_video_mode(void *data,
egl_install_sighandlers();
switch (g_api)
switch (g_egl_api)
{
case GFX_CTX_OPENGL_API:
attrib_ptr = egl_attribs_gl;
@ -820,9 +818,9 @@ static bool gfx_ctx_drm_egl_bind_api(void *data,
{
(void)data;
g_major = major;
g_minor = minor;
g_api = api;
g_major = major;
g_minor = minor;
g_egl_api = api;
switch (api)
{

@ -30,8 +30,6 @@
#include "../../config.h"
#endif
static bool g_inited;
static unsigned g_fb_width;
static unsigned g_fb_height;
@ -124,7 +122,7 @@ static bool gfx_ctx_emscripten_init(void *data)
(void)data;
if (g_inited)
if (g_egl_inited)
{
RARCH_LOG("[EMSCRIPTEN/EGL]: Attempted to re-initialize driver.\n");
return true;
@ -171,10 +169,10 @@ static bool gfx_ctx_emscripten_set_video_mode(void *data,
{
(void)data;
if (g_inited)
if (g_egl_inited)
return false;
g_inited = true;
g_egl_inited = true;
return true;
}
@ -200,7 +198,7 @@ static void gfx_ctx_emscripten_destroy(void *data)
{
egl_destroy(data);
g_inited = false;
g_egl_inited = false;
}
static void gfx_ctx_emscripten_input_driver(void *data,
@ -225,7 +223,7 @@ static bool gfx_ctx_emscripten_has_focus(void *data)
{
(void)data;
return g_inited;
return g_egl_inited;
}
static bool gfx_ctx_emscripten_suppress_screensaver(void *data, bool enable)

@ -38,9 +38,6 @@
#include "../../config.h"
#endif
static bool g_inited;
static enum gfx_ctx_api g_api;
static unsigned g_fb_width;
static unsigned g_fb_height;
@ -164,7 +161,7 @@ static bool gfx_ctx_vc_init(void *data)
};
settings_t *settings = config_get_ptr();
if (g_inited)
if (g_egl_inited)
{
RARCH_ERR("[VC/EGL]: Attempted to re-initialize driver.\n");
return false;
@ -179,7 +176,7 @@ static bool gfx_ctx_vc_init(void *data)
goto error;
}
if (!egl_create_context((g_api == GFX_CTX_OPENGL_ES_API) ? context_attributes : NULL))
if (!egl_create_context((g_egl_api == GFX_CTX_OPENGL_ES_API) ? context_attributes : NULL))
{
egl_report_error();
goto error;
@ -281,13 +278,13 @@ static bool gfx_ctx_vc_set_video_mode(void *data,
unsigned width, unsigned height,
bool fullscreen)
{
if (g_inited)
if (g_egl_inited)
return false;
egl_install_sighandlers();
egl_set_swap_interval(data, g_interval);
g_inited = true;
g_egl_inited = true;
return true;
}
@ -299,7 +296,7 @@ static bool gfx_ctx_vc_bind_api(void *data,
(void)major;
(void)minor;
g_api = api;
g_egl_api = api;
switch (api)
{
@ -344,7 +341,7 @@ static void gfx_ctx_vc_destroy(void *data)
if (g_egl_ctx)
{
gfx_ctx_vc_bind_api(data, g_api, 0, 0);
gfx_ctx_vc_bind_api(data, g_egl_api, 0, 0);
eglMakeCurrent(g_egl_dpy,
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(g_egl_dpy, g_egl_ctx);
@ -363,7 +360,7 @@ static void gfx_ctx_vc_destroy(void *data)
if (g_egl_surf)
{
gfx_ctx_vc_bind_api(data, g_api, 0, 0);
gfx_ctx_vc_bind_api(data, g_egl_api, 0, 0);
eglDestroySurface(g_egl_dpy, g_egl_surf);
}
@ -376,7 +373,7 @@ static void gfx_ctx_vc_destroy(void *data)
eglBindAPI(EGL_OPENVG_API);
eglMakeCurrent(g_egl_dpy,
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
gfx_ctx_vc_bind_api(data, g_api, 0, 0);
gfx_ctx_vc_bind_api(data, g_egl_api, 0, 0);
eglMakeCurrent(g_egl_dpy,
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglTerminate(g_egl_dpy);
@ -389,7 +386,7 @@ static void gfx_ctx_vc_destroy(void *data)
g_pbuff_surf = NULL;
g_egl_dpy = NULL;
g_egl_config = 0;
g_inited = false;
g_egl_inited = false;
for (i = 0; i < MAX_EGLIMAGE_TEXTURES; i++)
{
@ -409,7 +406,7 @@ static void gfx_ctx_vc_input_driver(void *data,
static bool gfx_ctx_vc_has_focus(void *data)
{
(void)data;
return g_inited;
return g_egl_inited;
}
static bool gfx_ctx_vc_suppress_screensaver(void *data, bool enable)
@ -448,7 +445,7 @@ static bool gfx_ctx_vc_image_buffer_init(void *data,
};
/* Don't bother, we just use VGImages for our EGLImage anyway. */
if (g_api == GFX_CTX_OPENVG_API)
if (g_egl_api == GFX_CTX_OPENVG_API)
return false;
peglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)
@ -485,7 +482,7 @@ static bool gfx_ctx_vc_image_buffer_init(void *data,
goto fail;
}
gfx_ctx_vc_bind_api(data, g_api, 0, 0);
gfx_ctx_vc_bind_api(data, g_egl_api, 0, 0);
eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx);
g_smooth = video->smooth;
@ -504,7 +501,7 @@ fail:
g_pbuff_surf = EGL_NO_CONTEXT;
}
gfx_ctx_vc_bind_api(data, g_api, 0, 0);
gfx_ctx_vc_bind_api(data, g_egl_api, 0, 0);
eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx);
return false;
@ -550,7 +547,7 @@ static bool gfx_ctx_vc_image_buffer_write(void *data, const void *frame, unsigne
height);
*image_handle = eglBuffer[index];
gfx_ctx_vc_bind_api(data, g_api, 0, 0);
gfx_ctx_vc_bind_api(data, g_egl_api, 0, 0);
eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx);
return ret;

@ -45,7 +45,6 @@ typedef struct gfx_ctx_wayland_data
} gfx_ctx_wayland_data_t;
static enum gfx_ctx_api g_api;
static unsigned g_major;
static unsigned g_minor;
@ -316,7 +315,7 @@ static bool gfx_ctx_wl_init(void *data)
if (!wl)
return false;
switch (g_api)
switch (g_egl_api)
{
case GFX_CTX_OPENGL_API:
attrib_ptr = egl_attribs_gl;
@ -395,7 +394,7 @@ error:
static EGLint *egl_fill_attribs(EGLint *attr)
{
switch (g_api)
switch (g_egl_api)
{
#ifdef EGL_KHR_create_context
case GFX_CTX_OPENGL_API:
@ -565,9 +564,9 @@ static bool gfx_ctx_wl_bind_api(void *data,
{
(void)data;
g_major = major;
g_minor = minor;
g_api = api;
g_major = major;
g_minor = minor;
g_egl_api = api;
switch (api)
{

@ -32,8 +32,6 @@ static unsigned g_screen;
static XF86VidModeModeInfo g_desktop_mode;
static bool g_should_reset_mode;
static bool g_inited;
static enum gfx_ctx_api g_api;
static unsigned g_major;
static unsigned g_minor;
@ -94,12 +92,12 @@ static bool gfx_ctx_xegl_init(void *data)
EGLint major, minor;
EGLint n;
if (g_inited)
if (g_egl_inited)
return false;
XInitThreads();
switch (g_api)
switch (g_egl_api)
{
case GFX_CTX_OPENGL_API:
attrib_ptr = egl_attribs_gl;
@ -144,7 +142,7 @@ error:
static EGLint *xegl_fill_attribs(EGLint *attr)
{
switch (g_api)
switch (g_egl_api)
{
#ifdef EGL_KHR_create_context
case GFX_CTX_OPENGL_API:
@ -358,7 +356,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
XSetErrorHandler(old_handler);
XFree(vi);
g_inited = true;
g_egl_inited = true;
if (!x11_input_ctx_new(true_full))
goto error;
@ -410,7 +408,7 @@ static void gfx_ctx_xegl_destroy(void *data)
/* Do not close g_x11_dpy. We'll keep one for the entire application
* lifecycle to work-around nVidia EGL limitations.
*/
g_inited = false;
g_egl_inited = false;
}
static void gfx_ctx_xegl_input_driver(void *data,
@ -426,7 +424,7 @@ static void gfx_ctx_xegl_input_driver(void *data,
static bool gfx_ctx_xegl_has_focus(void *data)
{
if (!g_inited)
if (!g_egl_inited)
return false;
return x11_has_focus(data);
@ -460,9 +458,9 @@ static bool gfx_ctx_xegl_bind_api(void *data,
{
(void)data;
g_major = major;
g_minor = minor;
g_api = api;
g_major = major;
g_minor = minor;
g_egl_api = api;
switch (api)
{

@ -34,6 +34,7 @@ extern "C" {
enum gfx_ctx_api
{
GFX_CTX_NONE = 0,
GFX_CTX_OPENGL_API,
GFX_CTX_OPENGL_ES_API,
GFX_CTX_DIRECT3D8_API,