From 736c63be3449c34678cd4f875b0f41105bb827c7 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Fri, 21 Jul 2017 14:00:51 -0500 Subject: [PATCH] gl_drm: half fix eglGetPlatformDisplayEXT usage Just because the #define is present doesn't mean the extension is, so we're BAILing on egl completely on some systems for no good reason at all. (saw this on an SGX stack) This is still wrong. I don't want to try too hard until after the upcoming release, though. We should actually be testing for the presence of client extensions before attempting to do any of this. It's entirely possible that a gl stack will return bogus functions for these from eglGetProcAddress --- src/modules/evas/engines/gl_drm/evas_outbuf.c | 34 ++++++++++++++++----------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/modules/evas/engines/gl_drm/evas_outbuf.c b/src/modules/evas/engines/gl_drm/evas_outbuf.c index 642ac7a..f51444c 100644 --- a/src/modules/evas/engines/gl_drm/evas_outbuf.c +++ b/src/modules/evas/engines/gl_drm/evas_outbuf.c @@ -174,12 +174,13 @@ _evas_outbuf_init(void) static int _init = 0; if (_init) return EINA_TRUE; #ifdef EGL_MESA_platform_gbm + /* FIXME: Pretty sure we should be checking if EGL_EXT_platform_base + * exists before looking these up and trusting them? + */ dlsym_eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC) eglGetProcAddress("eglGetPlatformDisplayEXT"); - EINA_SAFETY_ON_NULL_RETURN_VAL(dlsym_eglGetPlatformDisplayEXT, EINA_FALSE); dlsym_eglCreatePlatformWindowSurfaceEXT = (PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT"); - EINA_SAFETY_ON_NULL_RETURN_VAL(dlsym_eglCreatePlatformWindowSurfaceEXT, EINA_FALSE); #endif _init = 1; return EINA_TRUE; @@ -225,13 +226,16 @@ _evas_outbuf_egl_setup(Outbuf *ob) else cfg_attr[n++] = 0; cfg_attr[n++] = EGL_NONE; + ob->egl.disp = EGL_NO_DISPLAY; #ifdef EGL_MESA_platform_gbm - ob->egl.disp = - dlsym_eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA, ob->info->info.gbm, NULL); -#else - ob->egl.disp = eglGetDisplay((EGLNativeDisplayType)ob->info->info.gbm); + if (dlsym_eglGetPlatformDisplayEXT) + ob->egl.disp = dlsym_eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA, + ob->info->info.gbm, + NULL); #endif - if (ob->egl.disp == EGL_NO_DISPLAY) + if (ob->egl.disp == EGL_NO_DISPLAY) + ob->egl.disp = eglGetDisplay((EGLNativeDisplayType)ob->info->info.gbm); + if (ob->egl.disp == EGL_NO_DISPLAY) { ERR("eglGetDisplay() fail. code=%#x", eglGetError()); return EINA_FALSE; @@ -288,16 +292,18 @@ _evas_outbuf_egl_setup(Outbuf *ob) } } + ob->egl.surface = EGL_NO_SURFACE; #ifdef EGL_MESA_platform_gbm - ob->egl.surface = - dlsym_eglCreatePlatformWindowSurfaceEXT(ob->egl.disp, ob->egl.config, - ob->surface, NULL); -#else - ob->egl.surface = - eglCreateWindowSurface(ob->egl.disp, ob->egl.config, - (EGLNativeWindowType)ob->surface, NULL); + if (dlsym_eglCreatePlatformWindowSurfaceEXT) + ob->egl.surface = + dlsym_eglCreatePlatformWindowSurfaceEXT(ob->egl.disp, ob->egl.config, + ob->surface, NULL); #endif if (ob->egl.surface == EGL_NO_SURFACE) + ob->egl.surface = eglCreateWindowSurface(ob->egl.disp, ob->egl.config, + (EGLNativeWindowType)ob->surface, + NULL); + if (ob->egl.surface == EGL_NO_SURFACE) { ERR("eglCreateWindowSurface() fail for %p. code=%#x", ob->surface, eglGetError()); -- 2.7.4