i965: Pretend that CCS modified images are two planes
authorBen Widawsky <ben@bwidawsk.net>
Tue, 30 May 2017 11:53:59 +0000 (17:23 +0530)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 14 Aug 2017 17:43:30 +0000 (10:43 -0700)
v2: move is_aux into if block. (Jason)
Use else block instead of goto (Jason)

v3: Fix up logic for is_aux (Ben)
Fix up size calculations and add FIXME (Ben)

v4 (Jason Ekstrand):
Use the aux_pitch in the image instead of calculating it

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
src/intel/isl/isl.h
src/mesa/drivers/dri/i965/intel_screen.c

index dafe952298e8876206e2607bc97e13f4e3b7f80f..0e6fc7748621f926084f962840df33433205f709 100644 (file)
@@ -1552,6 +1552,12 @@ isl_tiling_from_i915_tiling(uint32_t tiling);
 const struct isl_drm_modifier_info * ATTRIBUTE_CONST
 isl_drm_modifier_get_info(uint64_t modifier);
 
+static inline bool
+isl_drm_modifier_has_aux(uint64_t modifier)
+{
+   return isl_drm_modifier_get_info(modifier)->aux_usage != ISL_AUX_USAGE_NONE;
+}
+
 struct isl_extent2d ATTRIBUTE_CONST
 isl_get_interleaved_msaa_px_size_sa(uint32_t samples);
 
index 673fb6d75164dc434d5e722bf2f3b8e565294817..e448a2aecc69f65741e9411eb5ae6e3f33f84119 100644 (file)
@@ -763,7 +763,7 @@ intel_query_image(__DRIimage *image, int attrib, int *value)
    case __DRI_IMAGE_ATTRIB_FOURCC:
       return intel_lookup_fourcc(image->dri_format, value);
    case __DRI_IMAGE_ATTRIB_NUM_PLANES:
-      *value = 1;
+      *value = isl_drm_modifier_has_aux(image->modifier) ? 2 : 1;
       return true;
    case __DRI_IMAGE_ATTRIB_OFFSET:
       *value = image->offset;
@@ -1171,31 +1171,44 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
     const struct intel_image_format *f;
     __DRIimage *image;
 
-    if (parent == NULL || parent->planar_format == NULL)
-        return NULL;
-
-    f = parent->planar_format;
-
-    if (plane >= f->nplanes)
-        return NULL;
-
-    width = parent->width >> f->planes[plane].width_shift;
-    height = parent->height >> f->planes[plane].height_shift;
-    dri_format = f->planes[plane].dri_format;
-    index = f->planes[plane].buffer_index;
-    offset = parent->offsets[index];
-    stride = parent->strides[index];
+    if (parent == NULL) {
+       return NULL;
+    } else if (parent->planar_format == NULL) {
+       const bool is_aux =
+          isl_drm_modifier_has_aux(parent->modifier) && plane == 1;
+       if (!is_aux)
+          return NULL;
+
+       width = parent->width;
+       height = parent->height;
+       dri_format = parent->dri_format;
+       offset = parent->aux_offset;
+       stride = parent->aux_pitch;
+    } else {
+       /* Planar formats don't support aux buffers/images */
+       assert(!isl_drm_modifier_has_aux(parent->modifier));
+       f = parent->planar_format;
+
+       if (plane >= f->nplanes)
+          return NULL;
+
+       width = parent->width >> f->planes[plane].width_shift;
+       height = parent->height >> f->planes[plane].height_shift;
+       dri_format = f->planes[plane].dri_format;
+       index = f->planes[plane].buffer_index;
+       offset = parent->offsets[index];
+       stride = parent->strides[index];
+
+       if (offset + height * stride > parent->bo->size) {
+          _mesa_warning(NULL, "intel_create_sub_image: subimage out of bounds");
+          return NULL;
+       }
+    }
 
     image = intel_allocate_image(parent->screen, dri_format, loaderPrivate);
     if (image == NULL)
        return NULL;
 
-    if (offset + height * stride > parent->bo->size) {
-       _mesa_warning(NULL, "intel_create_sub_image: subimage out of bounds");
-       free(image);
-       return NULL;
-    }
-
     image->bo = parent->bo;
     brw_bo_reference(parent->bo);
     image->modifier = parent->modifier;