xserver: Branch 'master' - 10 commits

Adam Jackson ajax at kemper.freedesktop.org
Tue Apr 10 19:43:27 UTC 2018


 dri3/dri3.c                   |    2 
 dri3/dri3.h                   |    8 +--
 dri3/dri3_priv.h              |    8 ++-
 dri3/dri3_screen.c            |   99 +++++++++++++++++++-----------------------
 glamor/glamor.h               |    6 +-
 glamor/glamor_egl.c           |   38 ++++++----------
 hw/xwayland/xwayland-glamor.c |   40 +++++++---------
 7 files changed, 92 insertions(+), 109 deletions(-)

New commits:
commit a42992a4cca49cedd3930f5694c7a16e4f614b36
Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Mon Apr 2 16:41:24 2018 +0100

    dri3: rework format/modifier caching
    
    Cut down the unnecessary malloc/memcpy/free by utilising the explicit
    copy provided by the client.
    
    But above all: do so, after ensuring we get valid data from the
    implementation.
    
    Fixes: cef12efc15c ("glamor: Implement GetSupportedModifiers")
    Cc: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
    Cc: Daniel Stone <daniels at collabora.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Emil Velikov <emil.velikov at collabora.com>

diff --git a/dri3/dri3_screen.c b/dri3/dri3_screen.c
index a9d2e01db..23e33f401 100644
--- a/dri3/dri3_screen.c
+++ b/dri3/dri3_screen.c
@@ -159,8 +159,10 @@ cache_formats_and_modifiers(ScreenPtr screen)
 {
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
     const dri3_screen_info_rec *info = ds->info;
-    CARD32                     *formats = NULL;
-    CARD64                     *modifiers = NULL;
+    CARD32                      num_formats;
+    CARD32                     *formats;
+    CARD32                      num_modifiers;
+    CARD64                     *modifiers;
     int                         i;
 
     if (ds->formats_cached)
@@ -176,34 +178,36 @@ cache_formats_and_modifiers(ScreenPtr screen)
         return Success;
     }
 
-    (*info->get_formats) (screen, &ds->num_formats, &formats);
-    ds->formats = calloc(ds->num_formats, sizeof(dri3_dmabuf_format_rec));
+    if (!info->get_formats(screen, &num_formats, &formats))
+        return BadAlloc;
+
+    if (!num_formats) {
+        ds->num_formats = 0;
+        ds->formats_cached = TRUE;
+        return Success;
+    }
+
+    ds->formats = calloc(num_formats, sizeof(dri3_dmabuf_format_rec));
     if (!ds->formats)
         return BadAlloc;
 
-    for (i = 0; i < ds->num_formats; i++) {
+    for (i = 0; i < num_formats; i++) {
         dri3_dmabuf_format_ptr iter = &ds->formats[i];
 
+        if (!info->get_modifiers(screen, formats[i],
+                                 &num_modifiers,
+                                 &modifiers))
+            continue;
+
+        if (!num_modifiers)
+            continue;
+
         iter->format = formats[i];
-        (*info->get_modifiers) (screen, formats[i],
-                                &iter->num_modifiers,
-                                &modifiers);
-
-        iter->modifiers = malloc(iter->num_modifiers * sizeof(CARD64));
-        if (iter->modifiers == NULL)
-            goto error;
-
-        memcpy(iter->modifiers, modifiers,
-               iter->num_modifiers * sizeof(CARD64));
-        goto done;
-
-error:
-        iter->num_modifiers = 0;
-        free(iter->modifiers);
-done:
-        free(modifiers);
+        iter->num_modifiers = num_modifiers;
+        iter->modifiers = modifiers;
     }
-    free(formats);
+
+    ds->num_formats = i;
     ds->formats_cached = TRUE;
 
     return Success;
commit 71a069fd7fbe815d386fc1b3c44cda732cff7af0
Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Mon Apr 2 16:41:23 2018 +0100

    glamor: zero num_formats from the start
    
    The caller may ignore the return value (will be addressed with later
    commit) so simply zero the count from the get-go. We're pretty much do
    so, in all cases but one :-\
    
    Fixes: cef12efc15c ("glamor: Implement GetSupportedModifiers")
    Cc: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
    Cc: Daniel Stone <daniels at collabora.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Emil Velikov <emil.velikov at collabora.com>

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 7050bd001..9edb50967 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -596,30 +596,26 @@ glamor_get_formats(ScreenPtr screen,
     struct glamor_egl_screen_private *glamor_egl;
     EGLint num;
 
+    /* Explicitly zero the count as the caller may ignore the return value */
+    *num_formats = 0;
+
     glamor_egl = glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
 
     if (!glamor_egl->dmabuf_capable)
         return FALSE;
 
-    if (!eglQueryDmaBufFormatsEXT(glamor_egl->display, 0, NULL, &num)) {
-        *num_formats = 0;
+    if (!eglQueryDmaBufFormatsEXT(glamor_egl->display, 0, NULL, &num))
         return FALSE;
-    }
 
-    if (num == 0) {
-        *num_formats = 0;
+    if (num == 0)
         return TRUE;
-    }
 
     *formats = calloc(num, sizeof(CARD32));
-    if (*formats == NULL) {
-        *num_formats = 0;
+    if (*formats == NULL)
         return FALSE;
-    }
 
     if (!eglQueryDmaBufFormatsEXT(glamor_egl->display, num,
                                   (EGLint *) *formats, &num)) {
-        *num_formats = 0;
         free(*formats);
         return FALSE;
     }
commit ac48724639e0a6a9e421b3b4e545d8506fd6bf5d
Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Mon Apr 2 16:41:22 2018 +0100

    xwayland: zero num_formats from the start
    
    The caller may ignore the return value (will be addressed with later
    commit) so simply zero the count from the get-go. We're pretty much do
    so, in all cases but one :-\
    
    Fixes: cef12efc15c ("glamor: Implement GetSupportedModifiers")
    Cc: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
    Cc: Daniel Stone <daniels at collabora.com>
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Emil Velikov <emil.velikov at collabora.com>

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 59461be1f..1b9a6b030 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -750,19 +750,18 @@ glamor_get_formats(ScreenPtr screen,
     struct xwl_screen *xwl_screen = xwl_screen_get(screen);
     int i;
 
+    /* Explicitly zero the count as the caller may ignore the return value */
+    *num_formats = 0;
+
     if (!xwl_screen->dmabuf_capable || !xwl_screen->dmabuf)
         return FALSE;
 
-    if (xwl_screen->num_formats == 0) {
-       *num_formats = 0;
+    if (xwl_screen->num_formats == 0)
        return TRUE;
-    }
 
     *formats = calloc(xwl_screen->num_formats, sizeof(CARD32));
-    if (*formats == NULL) {
-        *num_formats = 0;
+    if (*formats == NULL)
         return FALSE;
-    }
 
     for (i = 0; i < xwl_screen->num_formats; i++)
        (*formats)[i] = xwl_screen->formats[i].format;
commit e2f45002fc3c53c6196935447b8fe77d0850175b
Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Mon Apr 2 16:41:20 2018 +0100

    dri3: check for ::get_drawable_modifiers failure
    
    Currently if the function fails, we'll fall into two false assumptions:
     - the the count is zero
     - that the storage pointer is safe for free()
    
    I've just fixed the former (in glamor + xwayland) and have no
    plans on adding yet another workaround for the latter.
    
    Simply zero both variables. Regardless if the implementation is missing
    the callback or it foobars with output variables (normally a bad idea).
    
    Bonus points - this fixes a bug where we feed garbage to free() further
    down ;-)
    
    Fixes: cef12efc15c ("glamor: Implement GetSupportedModifiers")
    Cc: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
    Cc: Daniel Stone <daniels at collabora.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Emil Velikov <emil.velikov at collabora.com>

diff --git a/dri3/dri3_screen.c b/dri3/dri3_screen.c
index 1257c0ef4..a9d2e01db 100644
--- a/dri3/dri3_screen.c
+++ b/dri3/dri3_screen.c
@@ -253,10 +253,13 @@ dri3_get_supported_modifiers(ScreenPtr screen, DrawablePtr drawable,
         return Success;
     }
 
-    if (info->get_drawable_modifiers)
-        (*info->get_drawable_modifiers) (drawable, format,
-                                         &num_drawable_mods,
-                                         &drawable_mods);
+    if (!info->get_drawable_modifiers ||
+        !info->get_drawable_modifiers(drawable, format,
+                                      &num_drawable_mods,
+                                      &drawable_mods)) {
+        num_drawable_mods = 0;
+        drawable_mods = NULL;
+    }
 
     /* We're allocating slightly more memory than necessary but it reduces
      * the complexity of finding the intersection set.
commit 150e4b12ad160b093899107ed586aa0cb258879e
Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Mon Apr 2 16:41:19 2018 +0100

    glamor: zero num_modifiers from the start
    
    The caller may ignore the return value (will be addressed with later
    commit) so simply zero the count from the get-go. We're pretty much do
    so, in all cases but one :-\
    
    Fixes: cef12efc15c ("glamor: Implement GetSupportedModifiers")
    Cc: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
    Cc: Daniel Stone <daniels at collabora.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Emil Velikov <emil.velikov at collabora.com>

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 3d102ad22..7050bd001 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -640,31 +640,27 @@ glamor_get_modifiers(ScreenPtr screen, CARD32 format,
     struct glamor_egl_screen_private *glamor_egl;
     EGLint num;
 
+    /* Explicitly zero the count as the caller may ignore the return value */
+    *num_modifiers = 0;
+
     glamor_egl = glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
 
     if (!glamor_egl->dmabuf_capable)
         return FALSE;
 
     if (!eglQueryDmaBufModifiersEXT(glamor_egl->display, format, 0, NULL,
-                                    NULL, &num)) {
-        *num_modifiers = 0;
+                                    NULL, &num))
         return FALSE;
-    }
 
-    if (num == 0) {
-        *num_modifiers = 0;
+    if (num == 0)
         return TRUE;
-    }
 
     *modifiers = calloc(num, sizeof(uint64_t));
-    if (*modifiers == NULL) {
-        *num_modifiers = 0;
+    if (*modifiers == NULL)
         return FALSE;
-    }
 
     if (!eglQueryDmaBufModifiersEXT(glamor_egl->display, format, num,
                                     (EGLuint64KHR *) *modifiers, NULL, &num)) {
-        *num_modifiers = 0;
         free(*modifiers);
         return FALSE;
     }
commit b36a14c0b0e7e38406622eb5ff0666a8b8bc50f4
Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Mon Apr 2 16:41:18 2018 +0100

    xwayland: zero num_modifiers from the start
    
    The caller may ignore the return value (will be addressed with later
    commit) so simply zero the count from the get-go. We're pretty much do
    so, in all cases but one :-\
    
    Fixes: cef12efc15c ("glamor: Implement GetSupportedModifiers")
    Cc: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
    Cc: Daniel Stone <daniels at collabora.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Emil Velikov <emil.velikov at collabora.com>

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 339420e05..59461be1f 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -779,13 +779,14 @@ glamor_get_modifiers(ScreenPtr screen, CARD32 format,
     struct xwl_format *xwl_format = NULL;
     int i;
 
+    /* Explicitly zero the count as the caller may ignore the return value */
+    *num_modifiers = 0;
+
     if (!xwl_screen->dmabuf_capable || !xwl_screen->dmabuf)
         return FALSE;
 
-    if (xwl_screen->num_formats == 0) {
-       *num_modifiers = 0;
-       return TRUE;
-    }
+    if (xwl_screen->num_formats == 0)
+        return TRUE;
 
     for (i = 0; i < xwl_screen->num_formats; i++) {
        if (xwl_screen->formats[i].format == format) {
@@ -794,16 +795,12 @@ glamor_get_modifiers(ScreenPtr screen, CARD32 format,
        }
     }
 
-    if (!xwl_format) {
-	*num_modifiers = 0;
+    if (!xwl_format)
         return FALSE;
-    }
 
     *modifiers = calloc(xwl_format->num_modifiers, sizeof(uint64_t));
-    if (*modifiers == NULL) {
-        *num_modifiers = 0;
+    if (*modifiers == NULL)
         return FALSE;
-    }
 
     for (i = 0; i < xwl_format->num_modifiers; i++)
        (*modifiers)[i] = xwl_format->modifiers[i];
commit a83ceec868a6d544bc7775a753b67aa40d0d0efc
Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Mon Apr 2 16:41:15 2018 +0100

    dri3: simplify dri3_open() implementation
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Emil Velikov <emil.velikov at collabora.com>

diff --git a/dri3/dri3_screen.c b/dri3/dri3_screen.c
index 58f5ff71d..1257c0ef4 100644
--- a/dri3/dri3_screen.c
+++ b/dri3/dri3_screen.c
@@ -32,33 +32,21 @@
 #include <drm_fourcc.h>
 #include <unistd.h>
 
-static inline Bool has_open(const dri3_screen_info_rec *info) {
-    if (info == NULL)
-        return FALSE;
-
-    return info->open != NULL ||
-        (info->version >= 1 && info->open_client != NULL);
-}
-
 int
 dri3_open(ClientPtr client, ScreenPtr screen, RRProviderPtr provider, int *fd)
 {
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
     const dri3_screen_info_rec *info = ds->info;
-    int                         rc;
 
-    if (!has_open(info))
+    if (info == NULL)
         return BadMatch;
 
     if (info->version >= 1 && info->open_client != NULL)
-        rc = (*info->open_client) (client, screen, provider, fd);
-    else
-        rc = (*info->open) (screen, provider, fd);
-
-    if (rc != Success)
-        return rc;
+        return (*info->open_client) (client, screen, provider, fd);
+    if (info->open != NULL)
+        return (*info->open) (screen, provider, fd);
 
-    return Success;
+    return BadMatch;
 }
 
 int
commit 9a159f37e00ed47ec8cbff7c57d8787b8f5685f5
Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Mon Apr 2 16:41:14 2018 +0100

    dri3: annotate fds/strides/offsets arrays as const
    
    It makes it perfectly clear that we should not be modifying them.
    Should help highlight issues like the one fixed with previous commit.
    
    Fixes: cef12efc15c ("glamor: Implement GetSupportedModifiers")
    Cc: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
    Cc: Daniel Stone <daniels at collabora.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Emil Velikov <emil.velikov at collabora.com>

diff --git a/dri3/dri3.h b/dri3/dri3.h
index bd17522b0..fc76908e1 100644
--- a/dri3/dri3.h
+++ b/dri3/dri3.h
@@ -49,11 +49,11 @@ typedef PixmapPtr (*dri3_pixmap_from_fd_proc) (ScreenPtr screen,
 
 typedef PixmapPtr (*dri3_pixmap_from_fds_proc) (ScreenPtr screen,
                                                 CARD8 num_fds,
-                                                int *fds,
+                                                const int *fds,
                                                 CARD16 width,
                                                 CARD16 height,
-                                                CARD32 *strides,
-                                                CARD32 *offsets,
+                                                const CARD32 *strides,
+                                                const CARD32 *offsets,
                                                 CARD8 depth,
                                                 CARD8 bpp,
                                                 CARD64 modifier);
diff --git a/dri3/dri3_priv.h b/dri3/dri3_priv.h
index f0400a78a..168b87cbb 100644
--- a/dri3/dri3_priv.h
+++ b/dri3/dri3_priv.h
@@ -79,8 +79,10 @@ int
 dri3_open(ClientPtr client, ScreenPtr screen, RRProviderPtr provider, int *fd);
 
 int
-dri3_pixmap_from_fds(PixmapPtr *ppixmap, ScreenPtr screen, CARD8 num_fds, int *fds,
-                     CARD16 width, CARD16 height, CARD32 *strides, CARD32 *offsets,
+dri3_pixmap_from_fds(PixmapPtr *ppixmap, ScreenPtr screen,
+                     CARD8 num_fds, const int *fds,
+                     CARD16 width, CARD16 height,
+                     const CARD32 *strides, const CARD32 *offsets,
                      CARD8 depth, CARD8 bpp, CARD64 modifier);
 
 int
diff --git a/dri3/dri3_screen.c b/dri3/dri3_screen.c
index 8d3744977..58f5ff71d 100644
--- a/dri3/dri3_screen.c
+++ b/dri3/dri3_screen.c
@@ -63,9 +63,9 @@ dri3_open(ClientPtr client, ScreenPtr screen, RRProviderPtr provider, int *fd)
 
 int
 dri3_pixmap_from_fds(PixmapPtr *ppixmap, ScreenPtr screen,
-                     CARD8 num_fds, int *fds,
+                     CARD8 num_fds, const int *fds,
                      CARD16 width, CARD16 height,
-                     CARD32 *strides, CARD32 *offsets,
+                     const CARD32 *strides, const CARD32 *offsets,
                      CARD8 depth, CARD8 bpp, CARD64 modifier)
 {
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
diff --git a/glamor/glamor.h b/glamor/glamor.h
index b0b23d3a3..5d0659099 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -264,11 +264,11 @@ extern _X_EXPORT struct gbm_bo *glamor_gbm_bo_from_pixmap(ScreenPtr screen,
  * */
 extern _X_EXPORT PixmapPtr glamor_pixmap_from_fds(ScreenPtr screen,
                                                   CARD8 num_fds,
-                                                  int *fds,
+                                                  const int *fds,
                                                   CARD16 width,
                                                   CARD16 height,
-                                                  CARD32 *strides,
-                                                  CARD32 *offsets,
+                                                  const CARD32 *strides,
+                                                  const CARD32 *offsets,
                                                   CARD8 depth,
                                                   CARD8 bpp,
                                                   uint64_t modifier);
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 091d51d98..3d102ad22 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -514,9 +514,9 @@ gbm_format_for_depth(CARD8 depth)
 
 _X_EXPORT PixmapPtr
 glamor_pixmap_from_fds(ScreenPtr screen,
-                       CARD8 num_fds, int *fds,
+                       CARD8 num_fds, const int *fds,
                        CARD16 width, CARD16 height,
-                       CARD32 *strides, CARD32 *offsets,
+                       const CARD32 *strides, const CARD32 *offsets,
                        CARD8 depth, CARD8 bpp,
                        uint64_t modifier)
 {
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 6ba716263..339420e05 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -647,10 +647,10 @@ xwl_dri3_open_client(ClientPtr client,
 
 _X_EXPORT PixmapPtr
 glamor_pixmap_from_fds(ScreenPtr screen,
-                         CARD8 num_fds, int *fds,
-                         CARD16 width, CARD16 height,
-                         CARD32 *strides, CARD32 *offsets,
-                         CARD8 depth, CARD8 bpp, uint64_t modifier)
+                       CARD8 num_fds, const int *fds,
+                       CARD16 width, CARD16 height,
+                       const CARD32 *strides, const CARD32 *offsets,
+                       CARD8 depth, CARD8 bpp, uint64_t modifier)
 {
     struct xwl_screen *xwl_screen = xwl_screen_get(screen);
     struct gbm_bo *bo = NULL;
commit 877fa0c66469628748dbd01506f15ddc4f11b849
Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Mon Apr 2 16:41:13 2018 +0100

    xwayland: don't close() fds we don't own
    
    The glamor_pixmap_from_fds error path erroneously closes the fds.
    We don't own them, plus the caller closes them after the function in
    called.
    
    Fixes: cef12efc15c ("glamor: Implement GetSupportedModifiers")
    Cc: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
    Cc: Daniel Stone <daniels at collabora.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Emil Velikov <emil.velikov at collabora.com>

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 7f64483bf..6ba716263 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -704,8 +704,6 @@ glamor_pixmap_from_fds(ScreenPtr screen,
     return pixmap;
 
 error:
-    for (i = 0; i < num_fds; i++)
-       close(fds[i]);
     return NULL;
 }
 
commit 66b632bb068672f507212b00bd313b5040bf1a39
Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Mon Apr 2 16:41:12 2018 +0100

    dri3: annotate the dri3_screen_info data as const
    
    dri3_screen_info is the user provide dispatch. Something that we do
    not and should not change.
    
    When using the _ptr typecast + const the compiler barfs at us
    (rightfully so), so use the _rec one.
    
    [Silence a new const mismatch warning too - ajax]
    
    Fixes: 56313829886 ("dri3: Add DRI3 extension")
    Cc: Keith Packard <keithp at keithp.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Emil Velikov <emil.velikov at collabora.com>

diff --git a/dri3/dri3.c b/dri3/dri3.c
index 8ac0f3ae2..ba32facd7 100644
--- a/dri3/dri3.c
+++ b/dri3/dri3.c
@@ -45,7 +45,7 @@ dri3_close_screen(ScreenPtr screen)
 }
 
 Bool
-dri3_screen_init(ScreenPtr screen, dri3_screen_info_ptr info)
+dri3_screen_init(ScreenPtr screen, const dri3_screen_info_rec *info)
 {
     dri3_screen_generation = serverGeneration;
 
diff --git a/dri3/dri3.h b/dri3/dri3.h
index 89ad13ad9..bd17522b0 100644
--- a/dri3/dri3.h
+++ b/dri3/dri3.h
@@ -104,7 +104,7 @@ typedef struct dri3_screen_info {
 } dri3_screen_info_rec, *dri3_screen_info_ptr;
 
 extern _X_EXPORT Bool
-dri3_screen_init(ScreenPtr screen, dri3_screen_info_ptr info);
+dri3_screen_init(ScreenPtr screen, const dri3_screen_info_rec *info);
 
 extern _X_EXPORT int
 dri3_send_open_reply(ClientPtr client, int fd);
diff --git a/dri3/dri3_priv.h b/dri3/dri3_priv.h
index d86f06be0..f0400a78a 100644
--- a/dri3/dri3_priv.h
+++ b/dri3/dri3_priv.h
@@ -49,7 +49,7 @@ typedef struct dri3_screen_priv {
     CARD32                      num_formats;
     dri3_dmabuf_format_ptr      formats;
 
-    dri3_screen_info_ptr        info;
+    const dri3_screen_info_rec *info;
 } dri3_screen_priv_rec, *dri3_screen_priv_ptr;
 
 #define wrap(priv,real,mem,func) {\
diff --git a/dri3/dri3_screen.c b/dri3/dri3_screen.c
index 8ccbeb40c..8d3744977 100644
--- a/dri3/dri3_screen.c
+++ b/dri3/dri3_screen.c
@@ -32,7 +32,7 @@
 #include <drm_fourcc.h>
 #include <unistd.h>
 
-static inline Bool has_open(dri3_screen_info_ptr info) {
+static inline Bool has_open(const dri3_screen_info_rec *info) {
     if (info == NULL)
         return FALSE;
 
@@ -44,7 +44,7 @@ int
 dri3_open(ClientPtr client, ScreenPtr screen, RRProviderPtr provider, int *fd)
 {
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
-    dri3_screen_info_ptr        info = ds->info;
+    const dri3_screen_info_rec *info = ds->info;
     int                         rc;
 
     if (!has_open(info))
@@ -69,7 +69,7 @@ dri3_pixmap_from_fds(PixmapPtr *ppixmap, ScreenPtr screen,
                      CARD8 depth, CARD8 bpp, CARD64 modifier)
 {
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
-    dri3_screen_info_ptr        info = ds->info;
+    const dri3_screen_info_rec *info = ds->info;
     PixmapPtr                   pixmap;
 
     if (!info)
@@ -100,7 +100,7 @@ dri3_fds_from_pixmap(PixmapPtr pixmap, int *fds,
 {
     ScreenPtr                   screen = pixmap->drawable.pScreen;
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
-    dri3_screen_info_ptr        info = ds->info;
+    const dri3_screen_info_rec *info = ds->info;
 
     if (!info)
         return 0;
@@ -130,7 +130,7 @@ dri3_fd_from_pixmap(PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
 {
     ScreenPtr                   screen = pixmap->drawable.pScreen;
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
-    dri3_screen_info_ptr        info = ds->info;
+    const dri3_screen_info_rec  *info = ds->info;
     CARD32                      strides[4];
     CARD32                      offsets[4];
     CARD64                      modifier;
@@ -170,7 +170,7 @@ static int
 cache_formats_and_modifiers(ScreenPtr screen)
 {
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
-    dri3_screen_info_ptr        info = ds->info;
+    const dri3_screen_info_rec *info = ds->info;
     CARD32                     *formats = NULL;
     CARD64                     *modifiers = NULL;
     int                         i;
@@ -230,7 +230,7 @@ dri3_get_supported_modifiers(ScreenPtr screen, DrawablePtr drawable,
                              CARD64 **screen_modifiers)
 {
     dri3_screen_priv_ptr        ds = dri3_screen_priv(screen);
-    dri3_screen_info_ptr        info = ds->info;
+    const dri3_screen_info_rec *info = ds->info;
     int                         i, j;
     int                         ret;
     CARD32                      num_drawable_mods;
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 5a47dbd91..091d51d98 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -797,7 +797,7 @@ glamor_dri3_open_client(ClientPtr client,
     return Success;
 }
 
-static dri3_screen_info_rec glamor_dri3_info = {
+static const dri3_screen_info_rec glamor_dri3_info = {
     .version = 2,
     .open_client = glamor_dri3_open_client,
     .pixmap_from_fds = glamor_pixmap_from_fds,
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 7e9815626..7f64483bf 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -815,7 +815,7 @@ glamor_get_modifiers(ScreenPtr screen, CARD32 format,
 }
 
 
-static dri3_screen_info_rec xwl_dri3_info = {
+static const dri3_screen_info_rec xwl_dri3_info = {
     .version = 2,
     .open = NULL,
     .pixmap_from_fds = glamor_pixmap_from_fds,


More information about the xorg-commit mailing list