[Mesa-dev] [PATCH V5 4/7] intel: add pixel offset calculator for miptree levels

Abdiel Janulgue abdiel.janulgue at linux.intel.com
Thu Jan 17 07:48:58 PST 2013


Add helper to calculate fine-grained x and y adjustment pixels
to an image within a miptree level for tiled regions.

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

diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index cc74d3c..435f12f 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -688,6 +688,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, GLuint slice,
+                               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].slice[slice].x_offset & mask_x;
+   *tile_y = mt->level[level].slice[slice].y_offset & mask_y;
+}
+
 static void
 intel_miptree_copy_slice(struct intel_context *intel,
 			 struct intel_mipmap_tree *dst_mt,
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
index 1b2270a..d822491 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -460,6 +460,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, GLuint slice,
+                               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,
-- 
1.7.9.5



More information about the mesa-dev mailing list