From 0bdcbd75e001f6f344f28378227d5fbff0ed9a06 Mon Sep 17 00:00:00 2001 From: memeka Date: Sat, 4 Aug 2018 21:33:35 +0930 Subject: context_drm_egl: Use eglGetPlatformDisplayEXT if available Check if eglGetPlatformDisplayEXT is available and try to use it to obtain the display connection. Fall back to eglGetDisplay if eglGetPlatformDisplayEXT is not available or failing. From PR #5992 --- video/out/opengl/context_drm_egl.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/video/out/opengl/context_drm_egl.c b/video/out/opengl/context_drm_egl.c index f06494b799..fe296d2592 100644 --- a/video/out/opengl/context_drm_egl.c +++ b/video/out/opengl/context_drm_egl.c @@ -180,11 +180,30 @@ static int match_config_to_visual(void *user_data, EGLConfig *configs, int num_c return -1; } +static EGLDisplay egl_get_display(struct gbm_device *gbm_device) +{ + const char *ext = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); + + if (ext) { + PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL; + get_platform_display = (void *) eglGetProcAddress("eglGetPlatformDisplayEXT"); + + if (get_platform_display && strstr(ext, "EGL_MESA_platform_gbm")) + return get_platform_display(EGL_PLATFORM_GBM_MESA, gbm_device, NULL); + + if (get_platform_display && strstr(ext, "EGL_KHR_platform_gbm")) + return get_platform_display(EGL_PLATFORM_GBM_KHR, gbm_device, NULL); + } + + return eglGetDisplay(gbm_device); +} + static bool init_egl(struct ra_ctx *ctx) { struct priv *p = ctx->priv; MP_VERBOSE(ctx, "Initializing EGL\n"); - p->egl.display = eglGetDisplay(p->gbm.device); + p->egl.display = egl_get_display(p->gbm.device); + if (p->egl.display == EGL_NO_DISPLAY) { MP_ERR(ctx, "Failed to get EGL display.\n"); return false; -- cgit v1.2.3