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

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