On 16-12-10 16:05:12, Pohjolainen, Topi wrote:
On Thu, Dec 01, 2016 at 02:10:01PM -0800, Ben Widawsky wrote:
From: Ben Widawsky <b...@bwidawsk.net>

Signed-off-by: Ben Widawsky <b...@bwidawsk.net>
---
 src/mesa/drivers/dri/i965/intel_screen.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 91eb7ec..f40761a 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -747,7 +747,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 = image->aux_offset ? 2: 1;
       return true;
    case __DRI_IMAGE_ATTRIB_OFFSET:
       *value = image->offset;
@@ -956,9 +956,17 @@ intel_from_planar(__DRIimage *parent, int plane, void 
*loaderPrivate)
     int width, height, offset, stride, dri_format, index;
     struct intel_image_format *f;
     __DRIimage *image;
-
-    if (parent == NULL || parent->planar_format == NULL)
-        return NULL;
+    bool is_aux = parent->aux_offset && plane == 1;
+
+    if (parent == NULL || parent->planar_format == NULL) {
+       if (is_aux) {
+          offset = parent->aux_offset;
+          stride = ALIGN(parent->pitch / 32, 128);
+          dri_format = parent->dri_format;
+          goto done;
+       }
+       return NULL;
+    }

     f = parent->planar_format;

@@ -972,11 +980,13 @@ intel_from_planar(__DRIimage *parent, int plane, void 
*loaderPrivate)
     offset = parent->offsets[index];
     stride = parent->strides[index];

+done:
     image = intel_allocate_image(parent->screen, dri_format, loaderPrivate);
     if (image == NULL)
        return NULL;

-    if (offset + height * stride > parent->bo->size) {
+    if (!is_aux &&
+        offset + height * stride > parent->bo->size) {

This means that parent->bo->size is set to the size of the color region and
not to the full size of color+aux. I don't think I saw yet logic in this
series doing this...

Anyway, small comment would probably prevent other people wondering about the
same thing. What do you think?


No. You caught a bug. parent->bo->size should be the full size (it's allocated
in create_image_with_modifier). Originally I had height defined as well so I
could keep the assertion. I think I should go back and set height and keep the
assertion as it was.

diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 49adb1d2ff..501520bbf0 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -975,6 +975,7 @@ intel_from_planar(__DRIimage *parent, int plane, void 
*loaderPrivate)
       if (is_aux) {
          offset = parent->aux_offset;
          stride = ALIGN(parent->pitch / 32, 128);
+          height = ALIGN(DIV_ROUND_UP(parent->height, 16), 32);
          dri_format = parent->dri_format;
          goto done;
       }
@@ -998,8 +999,7 @@ done:
    if (image == NULL)
       return NULL;

-    if (!is_aux &&
-        offset + height * stride > parent->bo->size) {
+    if (offset + height * stride > parent->bo->size) {
       _mesa_warning(NULL, "intel_create_sub_image: subimage out of bounds");
       free(image);
       return NULL;

        _mesa_warning(NULL, "intel_create_sub_image: subimage out of bounds");
        free(image);
        return NULL;
--
2.10.2

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to