[Mesa-dev] [v4 03/10] intel: replace single region with a vector of regions

Topi Pohjolainen topi.pohjolainen at intel.com
Thu May 2 00:08:20 PDT 2013


No functional change in preparation for supporting multiple planes
per image each having its own region.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/intel/intel_fbo.c       |  6 +--
 src/mesa/drivers/dri/intel/intel_regions.h   |  7 ++-
 src/mesa/drivers/dri/intel/intel_screen.c    | 69 ++++++++++++++--------------
 src/mesa/drivers/dri/intel/intel_tex_image.c |  2 +-
 4 files changed, 45 insertions(+), 39 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 6aaf6b6..8a04614 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -300,13 +300,13 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx,
    irb->mt = intel_miptree_create_for_region(intel,
                                              GL_TEXTURE_2D,
                                              image->format,
-                                             image->region);
+                                             image->regions[0]);
    if (!irb->mt)
       return;
 
    rb->InternalFormat = image->internal_format;
-   rb->Width = image->region->width;
-   rb->Height = image->region->height;
+   rb->Width = image->regions[0]->width;
+   rb->Height = image->regions[0]->height;
    rb->Format = image->format;
    rb->_BaseFormat = _mesa_base_fbo_format(&intel->ctx,
 					   image->internal_format);
diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h
index 1fb6b27..e610f6b 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.h
+++ b/src/mesa/drivers/dri/intel/intel_regions.h
@@ -129,8 +129,13 @@ struct intel_image_format {
    } planes[3];
 };
 
+/**
+ * An image representing multiple planes may come in two flavours:
+ *  - all planes in single region but in different offsets or
+ *  - each plane in its own region.
+ */
 struct __DRIimageRec {
-   struct intel_region *region;
+   struct intel_region *regions[3];
    GLenum internal_format;
    uint32_t dri_format;
    GLuint format;
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 1ba1279..3ae4473 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -315,14 +315,14 @@ intel_setup_image_from_mipmap_tree(struct intel_context *intel, __DRIimage *imag
                                                    draw_y & ~mask_y,
                                                    false);
 
-   intel_region_reference(&image->region, mt->region);
+   intel_region_reference(&image->regions[0], mt->region);
 }
 
 static void
 intel_setup_image_from_dimensions(__DRIimage *image)
 {
-   image->width    = image->region->width;
-   image->height   = image->region->height;
+   image->width    = image->regions[0]->width;
+   image->height   = image->regions[0]->height;
    image->tile_x = 0;
    image->tile_y = 0;
    image->has_depthstencil = false;
@@ -366,10 +366,10 @@ intel_create_image_from_name(__DRIscreen *screen,
        cpp = 1;
     else
        cpp = _mesa_get_format_bytes(image->format);
-    image->region = intel_region_alloc_for_handle(intelScreen,
+    image->regions[0] = intel_region_alloc_for_handle(intelScreen,
 						  cpp, width, height,
 						  pitch * cpp, name, "image");
-    if (image->region == NULL) {
+    if (image->regions[0] == NULL) {
        free(image);
        return NULL;
     }
@@ -404,7 +404,7 @@ intel_create_image_from_renderbuffer(__DRIcontext *context,
    image->format = rb->Format;
    image->offset = 0;
    image->data = loaderPrivate;
-   intel_region_reference(&image->region, irb->mt->region);
+   intel_region_reference(&image->regions[0], irb->mt->region);
    intel_setup_image_from_dimensions(image);
    image->dri_format = intel_dri_format(image->format);
    image->has_depthstencil = irb->mt->stencil_mt? true : false;
@@ -475,7 +475,7 @@ intel_create_image_from_texture(__DRIcontext *context, int target,
 static void
 intel_destroy_image(__DRIimage *image)
 {
-    intel_region_release(&image->region);
+    intel_region_release(&image->regions[0]);
     free(image);
 }
 
@@ -502,9 +502,10 @@ intel_create_image(__DRIscreen *screen,
       return NULL;
 
    cpp = _mesa_get_format_bytes(image->format);
-   image->region =
+
+   image->regions[0] =
       intel_region_alloc(intelScreen, tiling, cpp, width, height, true);
-   if (image->region == NULL) {
+   if (image->regions[0] == NULL) {
       free(image);
       return NULL;
    }
@@ -519,21 +520,21 @@ intel_query_image(__DRIimage *image, int attrib, int *value)
 {
    switch (attrib) {
    case __DRI_IMAGE_ATTRIB_STRIDE:
-      *value = image->region->pitch;
+      *value = image->regions[0]->pitch;
       return true;
    case __DRI_IMAGE_ATTRIB_HANDLE:
-      *value = image->region->bo->handle;
+      *value = image->regions[0]->bo->handle;
       return true;
    case __DRI_IMAGE_ATTRIB_NAME:
-      return intel_region_flink(image->region, (uint32_t *) value);
+      return intel_region_flink(image->regions[0], (uint32_t *) value);
    case __DRI_IMAGE_ATTRIB_FORMAT:
       *value = image->dri_format;
       return true;
    case __DRI_IMAGE_ATTRIB_WIDTH:
-      *value = image->region->width;
+      *value = image->regions[0]->width;
       return true;
    case __DRI_IMAGE_ATTRIB_HEIGHT:
-      *value = image->region->height;
+      *value = image->regions[0]->height;
       return true;
    case __DRI_IMAGE_ATTRIB_COMPONENTS:
       if (image->planar_format == NULL)
@@ -541,7 +542,7 @@ intel_query_image(__DRIimage *image, int attrib, int *value)
       *value = image->planar_format->components;
       return true;
    case __DRI_IMAGE_ATTRIB_FD:
-      if (drm_intel_bo_gem_export_to_prime(image->region->bo, value) == 0)
+      if (drm_intel_bo_gem_export_to_prime(image->regions[0]->bo, value) == 0)
          return true;
       return false;
   default:
@@ -558,8 +559,8 @@ intel_dup_image(__DRIimage *orig_image, void *loaderPrivate)
    if (image == NULL)
       return NULL;
 
-   intel_region_reference(&image->region, orig_image->region);
-   if (image->region == NULL) {
+   intel_region_reference(&image->regions[0], orig_image->regions[0]);
+   if (image->regions[0] == NULL) {
       free(image);
       return NULL;
    }
@@ -586,7 +587,7 @@ static GLboolean
 intel_validate_usage(__DRIimage *image, unsigned int use)
 {
    if (use & __DRI_IMAGE_USE_CURSOR) {
-      if (image->region->width != 64 || image->region->height != 64)
+      if (image->regions[0]->width != 64 || image->regions[0]->height != 64)
 	 return GL_FALSE;
    }
 
@@ -665,10 +666,10 @@ intel_create_image_from_fds(__DRIscreen *screen,
    if (image == NULL)
       return NULL;
 
-   image->region = intel_region_alloc_for_fd(intelScreen,
+   image->regions[0] = intel_region_alloc_for_fd(intelScreen,
                                              1, width, height,
                                              strides[0], fds[0], "image");
-   if (image->region == NULL) {
+   if (image->regions[0] == NULL) {
       free(image);
       return NULL;
    }
@@ -700,8 +701,8 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
     if (plane >= f->nplanes)
         return NULL;
 
-    width = parent->region->width >> f->planes[plane].width_shift;
-    height = parent->region->height >> f->planes[plane].height_shift;
+    width = parent->regions[0]->width >> f->planes[plane].width_shift;
+    height = parent->regions[0]->height >> f->planes[plane].height_shift;
     dri_format = f->planes[plane].dri_format;
     index = f->planes[plane].buffer_index;
     offset = parent->offsets[index];
@@ -711,30 +712,30 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
     if (image == NULL)
        return NULL;
 
-    if (offset + height * stride > parent->region->bo->size) {
+    if (offset + height * stride > parent->regions[0]->bo->size) {
        _mesa_warning(NULL, "intel_create_sub_image: subimage out of bounds");
        free(image);
        return NULL;
     }
 
-    image->region = calloc(sizeof(*image->region), 1);
-    if (image->region == NULL) {
+    image->regions[0] = calloc(sizeof(*image->regions[0]), 1);
+    if (image->regions[0] == NULL) {
        free(image);
        return NULL;
     }
 
-    image->region->cpp = _mesa_get_format_bytes(image->format);
-    image->region->width = width;
-    image->region->height = height;
-    image->region->pitch = stride;
-    image->region->refcount = 1;
-    image->region->bo = parent->region->bo;
-    drm_intel_bo_reference(image->region->bo);
-    image->region->tiling = parent->region->tiling;
+    image->regions[0]->cpp = _mesa_get_format_bytes(image->format);
+    image->regions[0]->width = width;
+    image->regions[0]->height = height;
+    image->regions[0]->pitch = stride;
+    image->regions[0]->refcount = 1;
+    image->regions[0]->bo = parent->regions[0]->bo;
+    drm_intel_bo_reference(image->regions[0]->bo);
+    image->regions[0]->tiling = parent->regions[0]->tiling;
     image->offset = offset;
     intel_setup_image_from_dimensions(image);
 
-    intel_region_get_tile_masks(image->region, &mask_x, &mask_y, false);
+    intel_region_get_tile_masks(image->regions[0], &mask_x, &mask_y, false);
     if (offset & mask_x)
        _mesa_warning(NULL,
                      "intel_create_sub_image: offset not on tile boundary");
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 4e307f8..a59d6b0 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -381,7 +381,7 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
       return;
    }
 
-   intel_set_texture_image_region(ctx, texImage, image->region,
+   intel_set_texture_image_region(ctx, texImage, image->regions[0],
 				  target, image->internal_format,
                                   image->format, image->offset,
                                   image->width,  image->height,
-- 
1.8.1.2



More information about the mesa-dev mailing list