Blame SOURCES/0002-glx-add-getImageShm2-path.patch

513365
From 74e4f90deeae466ed19d2a31d8f62f6fc5e1709b Mon Sep 17 00:00:00 2001
513365
From: Dave Airlie <airlied@redhat.com>
513365
Date: Fri, 14 Feb 2020 15:03:24 +1000
513365
Subject: [PATCH 2/2] glx: add getImageShm2 path
513365
513365
If the glx side shmid is -1 (because the X server failed to attach)
513365
then we should let the caller know to fallback.
513365
513365
Fixes: 02c3dad0f3b4 ("Call shmget() with permission 0600 instead of 0777")
513365
---
513365
 src/glx/drisw_glx.c | 25 +++++++++++++++++++------
513365
 1 file changed, 19 insertions(+), 6 deletions(-)
513365
513365
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
513365
index 069f64d5216..dfa3218d759 100644
513365
--- a/src/glx/drisw_glx.c
513365
+++ b/src/glx/drisw_glx.c
513365
@@ -288,10 +288,10 @@ swrastGetImage(__DRIdrawable * read,
513365
    swrastGetImage2(read, x, y, w, h, 0, data, loaderPrivate);
513365
 }
513365
 
513365
-static void
513365
-swrastGetImageShm(__DRIdrawable * read,
513365
-                  int x, int y, int w, int h,
513365
-                  int shmid, void *loaderPrivate)
513365
+static GLboolean
513365
+swrastGetImageShm2(__DRIdrawable * read,
513365
+                   int x, int y, int w, int h,
513365
+                   int shmid, void *loaderPrivate)
513365
 {
513365
    struct drisw_drawable *prp = loaderPrivate;
513365
    __GLXDRIdrawable *pread = &(prp->base);
513365
@@ -301,8 +301,11 @@ swrastGetImageShm(__DRIdrawable * read,
513365
 
513365
    if (!prp->ximage || shmid != prp->shminfo.shmid) {
513365
       if (!XCreateDrawable(prp, shmid, dpy))
513365
-         return;
513365
+         return GL_FALSE;
513365
    }
513365
+
513365
+   if (prp->shminfo.shmid == -1)
513365
+      return GL_FALSE;
513365
    readable = pread->xDrawable;
513365
 
513365
    ximage = prp->ximage;
513365
@@ -312,10 +315,19 @@ swrastGetImageShm(__DRIdrawable * read,
513365
    ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32);
513365
 
513365
    XShmGetImage(dpy, readable, ximage, x, y, ~0L);
513365
+   return GL_TRUE;
513365
+}
513365
+
513365
+static void
513365
+swrastGetImageShm(__DRIdrawable * read,
513365
+                  int x, int y, int w, int h,
513365
+                  int shmid, void *loaderPrivate)
513365
+{
513365
+   swrastGetImageShm2(read, x, y, w, h, shmid, loaderPrivate);
513365
 }
513365
 
513365
 static const __DRIswrastLoaderExtension swrastLoaderExtension_shm = {
513365
-   .base = {__DRI_SWRAST_LOADER, 5 },
513365
+   .base = {__DRI_SWRAST_LOADER, 6 },
513365
 
513365
    .getDrawableInfo     = swrastGetDrawableInfo,
513365
    .putImage            = swrastPutImage,
513365
@@ -325,6 +337,7 @@ static const __DRIswrastLoaderExtension swrastLoaderExtension_shm = {
513365
    .putImageShm         = swrastPutImageShm,
513365
    .getImageShm         = swrastGetImageShm,
513365
    .putImageShm2        = swrastPutImageShm2,
513365
+   .getImageShm2        = swrastGetImageShm2,
513365
 };
513365
 
513365
 static const __DRIextension *loader_extensions_shm[] = {
513365
-- 
513365
2.21.1
513365