From f56555b5144069d0a8ac81d407abfa0c6be30c2e Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 5 May 2016 13:38:08 +0200 Subject: vo_opengl: EGL: fix hwdec probing If ANGLE was probed before (but rejected), the ANGLE API can remain "initialized", and eglGetCurrentDisplay() will return a non-NULL EGLDisplay. Then if a native GL context is used, the ANGLE/EGL API will then (apparently) keep working alongside native OpenGL API. Since GL objects are just numbers, they'll simply fail to interact, and OpenGL will get invalid textures. For some reason this will result in black textures. With VAAPI-EGL, something similar could happen in theory, but didn't in practice. --- video/out/opengl/hwdec_d3d11egl.c | 3 +++ video/out/opengl/hwdec_dxva2egl.c | 3 +++ video/out/opengl/hwdec_vaegl.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'video') diff --git a/video/out/opengl/hwdec_d3d11egl.c b/video/out/opengl/hwdec_d3d11egl.c index 32fb42a692..de872d1396 100644 --- a/video/out/opengl/hwdec_d3d11egl.c +++ b/video/out/opengl/hwdec_d3d11egl.c @@ -116,6 +116,9 @@ static int create(struct gl_hwdec *hw) if (!egl_display) return -1; + if (!eglGetCurrentContext()) + return -1; + const char *exts = eglQueryString(egl_display, EGL_EXTENSIONS); if (!exts || !strstr(exts, "EGL_ANGLE_d3d_share_handle_client_buffer") || !strstr(exts, "EGL_EXT_device_query")) diff --git a/video/out/opengl/hwdec_dxva2egl.c b/video/out/opengl/hwdec_dxva2egl.c index eed942618c..ed1a6e66b7 100644 --- a/video/out/opengl/hwdec_dxva2egl.c +++ b/video/out/opengl/hwdec_dxva2egl.c @@ -99,6 +99,9 @@ static int create(struct gl_hwdec *hw) if (!egl_display) return -1; + if (!eglGetCurrentContext()) + return -1; + const char *exts = eglQueryString(egl_display, EGL_EXTENSIONS); if (!exts || !strstr(exts, "EGL_ANGLE_d3d_share_handle_client_buffer")) { diff --git a/video/out/opengl/hwdec_vaegl.c b/video/out/opengl/hwdec_vaegl.c index d62a20a219..6356ec4e8c 100644 --- a/video/out/opengl/hwdec_vaegl.c +++ b/video/out/opengl/hwdec_vaegl.c @@ -183,7 +183,7 @@ static int create(struct gl_hwdec *hw) if (hw->hwctx) return -1; - if (!eglGetCurrentDisplay()) + if (!eglGetCurrentContext()) return -1; const char *exts = eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS); -- cgit v1.2.3