summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKurt Kartaltepe <kkartaltepe@gmail.com>2021-12-03 17:15:27 -0800
committerDudemanguy <random342@airmail.cc>2021-12-04 03:04:17 +0000
commitfc94c8c365ebeb038af6052bf4ea0506c1220559 (patch)
tree702e2b99a09ee1d3eebae8ded2adb574d793b471
parent181656955b6a556515238b2692a8bde210274793 (diff)
downloadmpv-fc94c8c365ebeb038af6052bf4ea0506c1220559.tar.bz2
mpv-fc94c8c365ebeb038af6052bf4ea0506c1220559.tar.xz
wayland: ensure read and draw buffers are assigned
This is a workaround for nvidia proprietary drivers. The authors of those drivers interpret the spec such that eglMakeCurrent will not reconfigure the read and draw buffers. Thus windows wont display anything drawn by opengl. nvidia authors refer to https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_no_config_context.txt specifically Issues 2/3 which reference eglMakeCurrent. On mesa this is a non-issue and the read/draw targets are assigned with eglMakeCurrent. The context must be made current in order to query OpenGL strings. An earlier proposal to create the wayland window surface similarly to X11 during init was deemed inappropriate so instead we manually set the targets once we have created a window surface.
-rw-r--r--video/out/opengl/common.c1
-rw-r--r--video/out/opengl/common.h1
-rw-r--r--video/out/opengl/context_wayland.c7
3 files changed, 9 insertions, 0 deletions
diff --git a/video/out/opengl/common.c b/video/out/opengl/common.c
index 949c385a61..3d98d39381 100644
--- a/video/out/opengl/common.c
+++ b/video/out/opengl/common.c
@@ -143,6 +143,7 @@ static const struct gl_functions gl_functions[] = {
.ver_core = 210,
.provides = MPGL_CAP_ROW_LENGTH | MPGL_CAP_1D_TEX,
.functions = (const struct gl_function[]) {
+ DEF_FN(DrawBuffer),
DEF_FN(GetTexLevelParameteriv),
DEF_FN(ReadBuffer),
DEF_FN(TexImage1D),
diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h
index 38414fe18b..f89fcc953b 100644
--- a/video/out/opengl/common.h
+++ b/video/out/opengl/common.h
@@ -111,6 +111,7 @@ struct GL {
void (GLAPIENTRY *ReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum,
GLenum, GLvoid *);
void (GLAPIENTRY *ReadBuffer)(GLenum);
+ void (GLAPIENTRY *DrawBuffer)(GLenum);
void (GLAPIENTRY *DrawArrays)(GLenum, GLint, GLsizei);
GLenum (GLAPIENTRY *GetError)(void);
void (GLAPIENTRY *GetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *);
diff --git a/video/out/opengl/context_wayland.c b/video/out/opengl/context_wayland.c
index e019f5fc8e..a7a8f4f3b4 100644
--- a/video/out/opengl/context_wayland.c
+++ b/video/out/opengl/context_wayland.c
@@ -144,6 +144,13 @@ static void egl_create_window(struct ra_ctx *ctx)
}
eglMakeCurrent(p->egl_display, p->egl_surface, p->egl_surface, p->egl_context);
+ // eglMakeCurrent may not configure the draw or read buffers if the context
+ // has been made current previously. On nvidia GL_NONE is bound because EGL_NO_SURFACE
+ // is used initially and we must bind the read and draw buffers here.
+ if(!p->gl.es) {
+ p->gl.ReadBuffer(GL_BACK);
+ p->gl.DrawBuffer(GL_BACK);
+ }
eglSwapInterval(p->egl_display, 0);
}