[Mesa-dev] [PATCH 3/6] intel: add new miptree helper functions for linear copying of a miptree and calculating x and y offsets of a miptree level within a tiled region.

Abdiel Janulgue abdiel.janulgue at linux.intel.com
Fri Dec 14 05:28:15 PST 2012


Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
---
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c |   31 ++++++++++++++++++++++++
 src/mesa/drivers/dri/intel/intel_mipmap_tree.h |   10 ++++++++
 2 files changed, 41 insertions(+)

diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 449672c..0e1d6d8 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -680,6 +680,21 @@ intel_miptree_get_image_offset(struct intel_mipmap_tree *mt,
    *y = mt->level[level].slice[slice].y_offset;
 }
 
+void
+intel_miptree_get_tile_offsets(struct intel_mipmap_tree *mt,
+                               GLuint level,
+                               uint32_t *tile_x,
+                               uint32_t *tile_y)
+{
+   struct intel_region *region = mt->region;
+   uint32_t mask_x, mask_y;
+
+   intel_region_get_tile_masks(region, &mask_x, &mask_y, false);
+
+   *tile_x = mt->level[level].level_x & mask_x;
+   *tile_y = mt->level[level].level_y & mask_y;
+}
+
 static void
 intel_miptree_copy_slice(struct intel_context *intel,
 			 struct intel_mipmap_tree *dst_mt,
@@ -773,6 +788,22 @@ intel_miptree_copy_teximage(struct intel_context *intel,
    intel_miptree_reference(&intelImage->mt, dst_mt);
 }
 
+/**
+ * Copies all image data in from src miptree to dst miptree.
+ */
+void
+intel_miptree_copy(struct intel_context *intel,
+		   struct intel_mipmap_tree *dst_mt,
+		   struct intel_mipmap_tree *src_mt)
+{
+   for (GLuint level = src_mt->first_level; level < src_mt->last_level + 1; level++) {
+      GLuint depth = src_mt->level[level].depth;
+      for (GLuint slice = 0; slice < depth; slice++) {
+         intel_miptree_copy_slice(intel, dst_mt, src_mt, level, 0, slice);
+      }
+   }
+}
+
 bool
 intel_miptree_alloc_mcs(struct intel_context *intel,
                         struct intel_mipmap_tree *mt,
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
index 72baabe..16e6803 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -455,6 +455,12 @@ void
 intel_miptree_get_dimensions_for_image(struct gl_texture_image *image,
                                        int *width, int *height, int *depth);
 
+void
+intel_miptree_get_tile_offsets(struct intel_mipmap_tree *mt,
+                               GLuint level,
+                               uint32_t *tile_x,
+                               uint32_t *tile_y);
+
 void intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
                                   GLuint level,
                                   GLuint x, GLuint y,
@@ -469,6 +475,10 @@ intel_miptree_copy_teximage(struct intel_context *intel,
                             struct intel_texture_image *intelImage,
                             struct intel_mipmap_tree *dst_mt);
 
+void
+intel_miptree_copy(struct intel_context *intel,
+		   struct intel_mipmap_tree *dst_mt,
+		   struct intel_mipmap_tree *src_mt);
 /**
  * Copy the stencil data from \c mt->stencil_mt->region to \c mt->region for
  * the given miptree slice.
-- 
1.7.9.5



More information about the mesa-dev mailing list