From bca77b55059b7775ff97b31d4bbaded7f7916fa4 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 3 Nov 2021 19:49:57 +0100 Subject: [PATCH] egl: Set the draw buffer to GL_BACK_LEFT Instead of using GL_BACK, use GL_BACK_LEFT, because the spec demands this (many drivers don't). Also move the call from the GDK backends into the GLContext code, as this is a generic EGL issue (nvidia being the main driver in need of this call, see 9c4c4eaaa121d784f591a591b95264647eaece96 for a longer discussion). Fixes #4402 --- gdk/gdkglcontext.c | 5 +++++ gdk/wayland/gdkglcontext-wayland.c | 2 -- gdk/x11/gdkglcontext-egl.c | 13 ------------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c index 422e0a189e..a768a8c042 100644 --- a/gdk/gdkglcontext.c +++ b/gdk/gdkglcontext.c @@ -572,6 +572,11 @@ gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context, glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glViewport (0, 0, ww, wh); + +#ifdef HAVE_EGL + if (priv->egl_context) + glDrawBuffers (1, (GLenum[1]) { GL_BACK_LEFT }); +#endif } static void diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c index d631816286..a7a51c535f 100644 --- a/gdk/wayland/gdkglcontext-wayland.c +++ b/gdk/wayland/gdkglcontext-wayland.c @@ -53,8 +53,6 @@ gdk_wayland_gl_context_begin_frame (GdkDrawContext *draw_context, gdk_wayland_surface_ensure_wl_egl_window (gdk_draw_context_get_surface (draw_context)); GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->begin_frame (draw_context, prefers_high_depth, region); - - glDrawBuffers (1, (GLenum[1]) { GL_BACK }); } static void diff --git a/gdk/x11/gdkglcontext-egl.c b/gdk/x11/gdkglcontext-egl.c index 67d730fcfb..6a6bf9a08b 100644 --- a/gdk/x11/gdkglcontext-egl.c +++ b/gdk/x11/gdkglcontext-egl.c @@ -59,16 +59,6 @@ gdk_x11_display_get_egl_display (GdkDisplay *display) return gdk_display_get_egl_display (display); } -static void -gdk_x11_gl_context_egl_begin_frame (GdkDrawContext *draw_context, - gboolean prefers_high_depth, - cairo_region_t *region) -{ - GDK_DRAW_CONTEXT_CLASS (gdk_x11_gl_context_egl_parent_class)->begin_frame (draw_context, prefers_high_depth, region); - - glDrawBuffers (1, (GLenum[1]) { GL_BACK }); -} - static gboolean gdk_x11_gl_context_egl_make_current (GdkGLContext *context, gboolean surfaceless) @@ -107,13 +97,10 @@ static void gdk_x11_gl_context_egl_class_init (GdkX11GLContextEGLClass *klass) { GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS (klass); - GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (klass); context_class->backend_type = GDK_GL_EGL; context_class->make_current = gdk_x11_gl_context_egl_make_current; - - draw_context_class->begin_frame = gdk_x11_gl_context_egl_begin_frame; } static void