From 033e0ac3ad82f139b7bb2a784b13615629dd86d8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Nov 2015 18:18:44 +0100 Subject: [PATCH] (drm_egl_ctx.c) Start using egl_create_context --- gfx/common/egl_common.c | 21 +++++++++++++++++++++ gfx/common/egl_common.h | 2 ++ gfx/drivers_context/drm_egl_ctx.c | 16 +++------------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/gfx/common/egl_common.c b/gfx/common/egl_common.c index 85c77f889c..ba7e6eeb25 100644 --- a/gfx/common/egl_common.c +++ b/gfx/common/egl_common.c @@ -204,3 +204,24 @@ bool egl_init_context(NativeDisplayType display, return true; } + +bool egl_create_context(EGLint *attr, EGLint *egl_attribs) +{ + g_egl_ctx = eglCreateContext(g_egl_dpy, g_egl_config, EGL_NO_CONTEXT, + (attr != egl_attribs) ? egl_attribs : NULL); + + if (g_egl_ctx == EGL_NO_CONTEXT) + return false; + + if (g_use_hw_ctx) + { + g_egl_hw_ctx = eglCreateContext(g_egl_dpy, g_egl_config, g_egl_ctx, + (attr != egl_attribs) ? egl_attribs : NULL); + RARCH_LOG("[EGL]: Created shared context: %p.\n", (void*)g_egl_hw_ctx); + + if (g_egl_hw_ctx == EGL_NO_CONTEXT) + return false;; + } + + return true; +} diff --git a/gfx/common/egl_common.h b/gfx/common/egl_common.h index e88a1bdc3a..153941947b 100644 --- a/gfx/common/egl_common.h +++ b/gfx/common/egl_common.h @@ -55,4 +55,6 @@ bool egl_init_context(NativeDisplayType display, EGLint *major, EGLint *minor, EGLint *n, const EGLint *attrib_ptr); +bool egl_create_context(EGLint *attr, EGLint *egl_attribs); + #endif diff --git a/gfx/drivers_context/drm_egl_ctx.c b/gfx/drivers_context/drm_egl_ctx.c index 50ef011f3e..2cf03a6902 100644 --- a/gfx/drivers_context/drm_egl_ctx.c +++ b/gfx/drivers_context/drm_egl_ctx.c @@ -731,20 +731,10 @@ static bool gfx_ctx_drm_egl_set_video_mode(void *data, attr = egl_fill_attribs(egl_attribs); - g_egl_ctx = eglCreateContext(g_egl_dpy, g_egl_config, EGL_NO_CONTEXT, - attr != egl_attribs ? egl_attribs : NULL); - - if (g_egl_ctx == EGL_NO_CONTEXT) - goto error; - - if (g_use_hw_ctx) + if (!egl_create_context(attr, &egl_attribs[0])) { - g_egl_hw_ctx = eglCreateContext(g_egl_dpy, g_egl_config, g_egl_ctx, - attr != egl_attribs ? egl_attribs : NULL); - RARCH_LOG("[KMS/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,