[Mesa-dev] [RFC v3 01/23] dri: fromPlanar() should never return NULL as a valid result

Louis-Francis Ratté-Boulianne lfrb at collabora.com
Thu Sep 28 07:54:41 UTC 2017


It was assumed that fromPlanar() could return NULL to mean
that the planar image is the same as the parent DRI image.
That assumption wasn't made everywhere though.

Let's simplify things and just return a new image when
requested even if it means wasting a few resources.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
---
 src/gbm/backends/dri/gbm_dri.c           | 12 ++++++------
 src/mesa/drivers/dri/i965/intel_screen.c | 11 ++++++++---
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 0a4853bf63..3fd193c597 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -785,14 +785,14 @@ gbm_dri_bo_get_stride(struct gbm_bo *_bo, int plane)
    }
 
    image = dri->image->fromPlanar(bo->image, plane, NULL);
-   if (image) {
-      dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_STRIDE, &stride);
-      dri->image->destroyImage(image);
-   } else {
-      assert(plane == 0);
-      dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE, &stride);
+   if (!image) {
+      errno = EINVAL;
+      return 0;
    }
 
+   dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_STRIDE, &stride);
+   dri->image->destroyImage(image);
+
    return (uint32_t)stride;
 }
 
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index bd1365f232..e08da9de9d 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1243,14 +1243,19 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
     } else if (parent->planar_format == NULL) {
        const bool is_aux =
           isl_drm_modifier_has_aux(parent->modifier) && plane == 1;
-       if (!is_aux)
+       if (plane > 0 && !is_aux)
           return NULL;
 
        width = parent->width;
        height = parent->height;
        dri_format = parent->dri_format;
-       offset = parent->aux_offset;
-       stride = parent->aux_pitch;
+       if (is_aux) {
+          offset = parent->aux_offset;
+          stride = parent->aux_pitch;
+       } else {
+          offset = parent->offset;
+          stride = parent->pitch;
+       }
     } else {
        /* Planar formats don't support aux buffers/images */
        assert(!isl_drm_modifier_has_aux(parent->modifier));
-- 
2.13.0



More information about the mesa-dev mailing list