[Mesa-dev] [PATCH v3 2/6] intel: create a miptree for a region based on an offset, size, and level.

Abdiel Janulgue abdiel.janulgue at linux.intel.com
Fri Jan 11 06:27:25 PST 2013


Add intel_miptree_create_for_offset which adds support for creating a single-
level miptree based on the existing offsets and dimensions of another
mip-tree level. Use this function as well in intel_miptree_create_for_region,
but for the whole region.

Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
---
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c |   39 +++++++++++++++++++++---
 src/mesa/drivers/dri/intel/intel_mipmap_tree.h |   12 ++++++++
 src/mesa/drivers/dri/intel/intel_regions.h     |    8 +++++
 3 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 8d814bd..0a64de4 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -306,17 +306,26 @@ intel_miptree_create(struct intel_context *intel,
 }
 
 
+/**
+ * Create miptree for region based on offset, size, and level
+ */
 struct intel_mipmap_tree *
-intel_miptree_create_for_region(struct intel_context *intel,
-				GLenum target,
-				gl_format format,
-				struct intel_region *region)
+intel_miptree_create_for_offset(struct intel_context *intel,
+                                GLenum target,
+                                gl_format format,
+                                struct intel_region *region,
+                                GLuint width,
+                                GLuint height,
+                                GLuint level_x,
+                                GLuint level_y,
+                                GLuint slice_x_offset,
+                                GLuint slice_y_offset)
 {
    struct intel_mipmap_tree *mt;
 
    mt = intel_miptree_create_internal(intel, target, format,
 				      0, 0,
-				      region->width, region->height, 1,
+				      width, height, 1,
 				      true, 0 /* num_samples */,
                                       INTEL_MSAA_LAYOUT_NONE);
    if (!mt)
@@ -324,9 +333,29 @@ intel_miptree_create_for_region(struct intel_context *intel,
 
    intel_region_reference(&mt->region, region);
 
+   mt->total_width = width;
+   mt->total_height = height;
+   mt->level[0].level_x = level_x;
+   mt->level[0].level_y = level_y;
+   mt->level[0].slice[0].x_offset = slice_x_offset;
+   mt->level[0].slice[0].y_offset = slice_y_offset;
+
    return mt;
 }
 
+struct intel_mipmap_tree *
+intel_miptree_create_for_region(struct intel_context *intel,
+				GLenum target,
+				gl_format format,
+				struct intel_region *region)
+{
+   /* Use the whole region */
+   return intel_miptree_create_for_offset(intel, target, format, region,
+                                          region->width, region->height,
+                                          0, 0,
+                                          0, 0);
+}
+
 /**
  * Determine which MSAA layout should be used by the MSAA surface being
  * created, based on the chip generation and the surface type.
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
index eb4ad7f..3e76753 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -399,6 +399,18 @@ intel_miptree_create_for_dri2_buffer(struct intel_context *intel,
                                      uint32_t num_samples,
                                      struct intel_region *region);
 
+struct intel_mipmap_tree *
+intel_miptree_create_for_offset(struct intel_context *intel,
+                                GLenum target,
+                                gl_format format,
+                                struct intel_region *region,
+                                GLuint width,
+                                GLuint height,
+                                GLuint level_x,
+                                GLuint level_y,
+                                GLuint slice_x_offset,
+                                GLuint slice_y_offset);
+
 /**
  * Create a miptree appropriate as the storage for a non-texture renderbuffer.
  * The miptree has the following properties:
diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h
index 8737a6d..bb0ccef 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.h
+++ b/src/mesa/drivers/dri/intel/intel_regions.h
@@ -174,6 +174,14 @@ struct __DRIimageRec {
    uint32_t offsets[3];
    struct intel_image_format *planar_format;
 
+   /* particular miptree level */
+   GLuint width;
+   GLuint height;
+   GLuint level_x;
+   GLuint level_y;
+   GLuint slice_x_offset;
+   GLuint slice_y_offset;
+
    void *data;
 };
 
-- 
1.7.9.5



More information about the mesa-dev mailing list