From f84c58e777277112c20517ec4459dcc567114776 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Nov 2015 18:25:19 +0100 Subject: [PATCH] (Android) Start using egl_create_context --- gfx/common/egl_common.c | 6 +++--- gfx/common/egl_common.h | 2 +- gfx/drivers_context/androidegl_ctx.c | 18 +++--------------- gfx/drivers_context/drm_egl_ctx.c | 4 +++- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/gfx/common/egl_common.c b/gfx/common/egl_common.c index ba7e6eeb25..c17c537cac 100644 --- a/gfx/common/egl_common.c +++ b/gfx/common/egl_common.c @@ -205,10 +205,10 @@ bool egl_init_context(NativeDisplayType display, return true; } -bool egl_create_context(EGLint *attr, EGLint *egl_attribs) +bool egl_create_context(EGLint *egl_attribs) { g_egl_ctx = eglCreateContext(g_egl_dpy, g_egl_config, EGL_NO_CONTEXT, - (attr != egl_attribs) ? egl_attribs : NULL); + egl_attribs); if (g_egl_ctx == EGL_NO_CONTEXT) return false; @@ -216,7 +216,7 @@ bool egl_create_context(EGLint *attr, EGLint *egl_attribs) 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); + egl_attribs); RARCH_LOG("[EGL]: Created shared context: %p.\n", (void*)g_egl_hw_ctx); if (g_egl_hw_ctx == EGL_NO_CONTEXT) diff --git a/gfx/common/egl_common.h b/gfx/common/egl_common.h index 153941947b..bfd99bbf11 100644 --- a/gfx/common/egl_common.h +++ b/gfx/common/egl_common.h @@ -55,6 +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); +bool egl_create_context(EGLint *egl_attribs); #endif diff --git a/gfx/drivers_context/androidegl_ctx.c b/gfx/drivers_context/androidegl_ctx.c index 1264c74bbd..9ff113f45e 100644 --- a/gfx/drivers_context/androidegl_ctx.c +++ b/gfx/drivers_context/androidegl_ctx.c @@ -76,22 +76,10 @@ static bool android_gfx_ctx_init(void *data) ANativeWindow_setBuffersGeometry(android_app->window, 0, 0, format); - 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("[Android/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, diff --git a/gfx/drivers_context/drm_egl_ctx.c b/gfx/drivers_context/drm_egl_ctx.c index 2cf03a6902..579de744c9 100644 --- a/gfx/drivers_context/drm_egl_ctx.c +++ b/gfx/drivers_context/drm_egl_ctx.c @@ -722,6 +722,7 @@ static bool gfx_ctx_drm_egl_set_video_mode(void *data, goto error; } + if (!egl_init_context((EGLNativeDisplayType)drm->g_gbm_dev, &major, &minor, &n, attrib_ptr)) { @@ -730,8 +731,9 @@ static bool gfx_ctx_drm_egl_set_video_mode(void *data, } attr = egl_fill_attribs(egl_attribs); + EGLint *egl_attribs_ptr = &egl_attribs[0]; - if (!egl_create_context(attr, &egl_attribs[0])) + if (!egl_create_context((attr != egl_attribs_ptr) ? egl_attribs_ptr : NULL)) { egl_report_error(); goto error;