Blame SOURCES/0010-xwayland-eglstream-Check-framebuffer-status.patch

4c4b8b
From 070abe64b15db831802a842aa1965403eb24679e Mon Sep 17 00:00:00 2001
4c4b8b
From: Olivier Fourdan <ofourdan@redhat.com>
4c4b8b
Date: Wed, 31 Mar 2021 09:49:35 +0200
4c4b8b
Subject: [PATCH xserver 10/27] xwayland/eglstream: Check framebuffer status
4c4b8b
MIME-Version: 1.0
4c4b8b
Content-Type: text/plain; charset=UTF-8
4c4b8b
Content-Transfer-Encoding: 8bit
4c4b8b
4c4b8b
The EGLStream backend would sometime generate GL errors trying to draw
4c4b8b
to the framebuffer, which gives an invalid buffer, which in turn would
4c4b8b
generate a Wayland error from the compositor which is fatal to the
4c4b8b
client.
4c4b8b
4c4b8b
Check the framebuffer status and bail out early if it's not complete,
4c4b8b
to avoid getting into trouble later.
4c4b8b
4c4b8b
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
4c4b8b
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
4c4b8b
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
4c4b8b
(cherry picked from commit 85244d2a2081d61a2e4a06e847041f638de01e3f)
4c4b8b
---
4c4b8b
 hw/xwayland/xwayland-glamor-eglstream.c | 18 ++++++++++++++----
4c4b8b
 1 file changed, 14 insertions(+), 4 deletions(-)
4c4b8b
4c4b8b
diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c
4c4b8b
index f64d05064..64fe93b7c 100644
4c4b8b
--- a/hw/xwayland/xwayland-glamor-eglstream.c
4c4b8b
+++ b/hw/xwayland/xwayland-glamor-eglstream.c
4c4b8b
@@ -619,6 +619,7 @@ xwl_glamor_eglstream_post_damage(struct xwl_window *xwl_window,
4c4b8b
         box->x2 - box->x1, box->y2 - box->y1
4c4b8b
     };
4c4b8b
     GLint saved_vao;
4c4b8b
+    int status;
4c4b8b
 
4c4b8b
     if (xwl_pixmap->type != XWL_PIXMAP_EGLSTREAM)
4c4b8b
         /* This can happen if a client does X11 rendering on a
4c4b8b
@@ -652,6 +653,13 @@ xwl_glamor_eglstream_post_damage(struct xwl_window *xwl_window,
4c4b8b
     glUniform1i(xwl_eglstream->blit_is_rgba_pos,
4c4b8b
                 pixmap->drawable.depth >= 32);
4c4b8b
 
4c4b8b
+    status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
4c4b8b
+    if (status != GL_FRAMEBUFFER_COMPLETE) {
4c4b8b
+        ErrorF("eglstream: Framebuffer incomplete 0x%X, not posting damage\n", status);
4c4b8b
+        status = FALSE;
4c4b8b
+        goto out;
4c4b8b
+    }
4c4b8b
+
4c4b8b
     /* Blit rendered image into EGLStream surface */
4c4b8b
     glDrawBuffer(GL_BACK);
4c4b8b
     glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
4c4b8b
@@ -662,14 +670,16 @@ xwl_glamor_eglstream_post_damage(struct xwl_window *xwl_window,
4c4b8b
     else
4c4b8b
         eglSwapBuffers(xwl_screen->egl_display, xwl_pixmap->surface);
4c4b8b
 
4c4b8b
+    /* hang onto the pixmap until the compositor has released it */
4c4b8b
+    pixmap->refcnt++;
4c4b8b
+    status = TRUE;
4c4b8b
+
4c4b8b
+out:
4c4b8b
     /* Restore previous state */
4c4b8b
     glBindVertexArray(saved_vao);
4c4b8b
     glBindTexture(GL_TEXTURE_2D, 0);
4c4b8b
 
4c4b8b
-    /* hang onto the pixmap until the compositor has released it */
4c4b8b
-    pixmap->refcnt++;
4c4b8b
-
4c4b8b
-    return TRUE;
4c4b8b
+    return status;
4c4b8b
 }
4c4b8b
 
4c4b8b
 static Bool
4c4b8b
-- 
4c4b8b
2.31.1
4c4b8b