From fc94c8c365ebeb038af6052bf4ea0506c1220559 Mon Sep 17 00:00:00 2001 From: Kurt Kartaltepe Date: Fri, 3 Dec 2021 17:15:27 -0800 Subject: 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. --- video/out/opengl/common.c | 1 + video/out/opengl/common.h | 1 + video/out/opengl/context_wayland.c | 7 +++++++ 3 files changed, 9 insertions(+) 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); } -- cgit v1.2.3