From 01614bb7f428618cb5001e439815a3c68b85d5cb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Nov 2015 18:29:15 +0100 Subject: [PATCH] Start using egl_create_context in more drivers --- gfx/drivers_context/bbqnx_ctx.c | 15 +++------------ gfx/drivers_context/emscriptenegl_ctx.c | 7 ++++--- gfx/drivers_context/vc_egl_ctx.c | 17 +++-------------- gfx/drivers_context/vivante_fbdev_ctx.c | 13 ++++++------- gfx/drivers_context/xegl_ctx.c | 18 +++--------------- 5 files changed, 19 insertions(+), 51 deletions(-) diff --git a/gfx/drivers_context/bbqnx_ctx.c b/gfx/drivers_context/bbqnx_ctx.c index bb9fa99e01..36e1c12b6c 100644 --- a/gfx/drivers_context/bbqnx_ctx.c +++ b/gfx/drivers_context/bbqnx_ctx.c @@ -111,19 +111,10 @@ static bool gfx_ctx_qnx_init(void *data) goto error; } - g_egl_ctx = eglCreateContext(g_egl_dpy, g_egl_config, EGL_NO_CONTEXT, context_attributes); - - if (g_egl_ctx == EGL_NO_CONTEXT) - goto error; - - if (g_use_hw_ctx) + if (!egl_create_context(context_attributes)) { - g_egl_hw_ctx = eglCreateContext(g_egl_dpy, g_egl_config, g_egl_ctx, - context_attributes); - RARCH_LOG("[BLACKBERRY QNX/EGL]: Created shared context: %p.\n", (void*)g_egl_hw_ctx); - - if (g_egl_hw_ctx == EGL_NO_CONTEXT) - goto error; + egl_report_error(); + goto error; } if(!screen_win) diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index 1fe3fa27e6..1545310326 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -137,10 +137,11 @@ static bool gfx_ctx_emscripten_init(void *data) goto error; } - /* Create an EGL rendering context. */ - g_egl_ctx = eglCreateContext(g_egl_dpy, g_egl_config, EGL_NO_CONTEXT, context_attributes); - if (!g_egl_ctx) + if (!egl_create_context(context_attributes)) + { + egl_report_error(); goto error; + } /* create an EGL window surface. */ g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_config, 0, NULL); diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index f9e34343ac..df2bbd34e6 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -179,21 +179,10 @@ static bool gfx_ctx_vc_init(void *data) goto error; } - /* Create an EGL rendering context. */ - g_egl_ctx = eglCreateContext( - g_egl_dpy, g_egl_config, EGL_NO_CONTEXT, - (g_api == GFX_CTX_OPENGL_ES_API) ? context_attributes : NULL); - if (!g_egl_ctx) - goto error; - - if (g_use_hw_ctx) + if (!egl_create_context((g_api == GFX_CTX_OPENGL_ES_API) ? context_attributes : NULL)) { - g_egl_hw_ctx = eglCreateContext(g_egl_dpy, g_egl_config, g_egl_ctx, - context_attributes); - RARCH_LOG("[VC/EGL]: Created shared context: %p.\n", (void*)g_egl_hw_ctx); - - if (g_egl_hw_ctx == EGL_NO_CONTEXT) - goto error; + egl_report_error(); + goto error; } /* Create an EGL window surface. */ diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index 78f9033435..a2c776bd48 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -128,6 +128,12 @@ static bool gfx_ctx_vivante_set_video_mode(void *data, g_width = width; g_height = height; + if (!egl_create_context(attribs)) + { + egl_report_error(); + goto error; + } + window = fbCreateWindow(fbGetDisplayByIndex(0), 0, 0, 0, 0); g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_config, window, 0); @@ -137,13 +143,6 @@ static bool gfx_ctx_vivante_set_video_mode(void *data, goto error; } - g_egl_ctx = eglCreateContext(g_egl_dpy, g_egl_config, 0, attribs); - if (g_egl_ctx == EGL_NO_CONTEXT) - { - RARCH_ERR("eglCreateContext failed.\n"); - goto error; - } - if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx)) { RARCH_ERR("eglMakeCurrent failed.\n"); diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 4c660bec49..db454c26fe 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -291,22 +291,10 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, CWBorderPixel | CWColormap | CWEventMask | (true_full ? CWOverrideRedirect : 0), &swa); XSetWindowBackground(g_x11_dpy, g_x11_win, 0); - g_egl_ctx = eglCreateContext(g_egl_dpy, g_egl_config, EGL_NO_CONTEXT, - attr != egl_attribs ? egl_attribs : NULL); - - RARCH_LOG("[X/EGL]: Created context: %p.\n", (void*)g_egl_ctx); - - if (g_egl_ctx == EGL_NO_CONTEXT) - goto error; - - if (g_use_hw_ctx) + if (!egl_create_context((attr != egl_attribs) ? egl_attribs : NULL)) { - g_egl_hw_ctx = eglCreateContext(g_egl_dpy, g_egl_config, g_egl_ctx, - attr != egl_attribs ? egl_attribs : NULL); - RARCH_LOG("[X/EGL]: Created shared context: %p.\n", (void*)g_egl_hw_ctx); - - if (g_egl_hw_ctx == EGL_NO_CONTEXT) - goto error; + egl_report_error(); + goto error; } g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_config, (EGLNativeWindowType)g_x11_win, NULL);