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

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