[Mesa-dev] [PATCH 04/25] i965: Add helper functions to calculate the slice pitch of an array or 3D miptree.

Francisco Jerez currojerez at riseup.net
Mon Dec 2 11:39:12 PST 2013


---
 src/mesa/drivers/dri/i965/brw_tex_layout.c    | 51 +++++++++++++++++++++------
 src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 10 ++++++
 2 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c
index 2c81eed..d13d855 100644
--- a/src/mesa/drivers/dri/i965/brw_tex_layout.c
+++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c
@@ -216,6 +216,45 @@ brw_miptree_layout_2d(struct intel_mipmap_tree *mt)
    }
 }
 
+unsigned
+brw_miptree_get_horizontal_slice_pitch(struct brw_context *brw,
+                                       struct intel_mipmap_tree *mt,
+                                       unsigned level)
+{
+   if (mt->target == GL_TEXTURE_3D ||
+       (brw->gen == 4 && mt->target == GL_TEXTURE_CUBE_MAP)) {
+      return ALIGN(minify(mt->physical_width0, level), mt->align_w);
+   } else {
+      return 0;
+   }
+}
+
+unsigned
+brw_miptree_get_vertical_slice_pitch(struct brw_context *brw,
+                                     struct intel_mipmap_tree *mt,
+                                     unsigned level)
+{
+   if (mt->target == GL_TEXTURE_3D ||
+       (brw->gen == 4 && mt->target == GL_TEXTURE_CUBE_MAP)) {
+      return ALIGN(minify(mt->physical_height0, level), mt->align_h);
+
+   } else {
+      const unsigned h0 = ALIGN(mt->physical_height0, mt->align_h);
+      const unsigned h1 = ALIGN(minify(mt->physical_height0, 1), mt->align_h);
+      unsigned qpitch;
+
+      if (mt->array_spacing_lod0)
+         qpitch = h0;
+      else
+         qpitch = (h0 + h1 + (brw->gen >= 7 ? 12 : 11) * mt->align_h);
+
+      if (mt->compressed)
+         return qpitch / 4;
+      else
+         return qpitch;
+   }
+}
+
 static void
 align_cube(struct intel_mipmap_tree *mt)
 {
@@ -232,17 +271,7 @@ static void
 brw_miptree_layout_texture_array(struct brw_context *brw,
 				 struct intel_mipmap_tree *mt)
 {
-   unsigned qpitch = 0;
-   int h0, h1;
-
-   h0 = ALIGN(mt->physical_height0, mt->align_h);
-   h1 = ALIGN(minify(mt->physical_height0, 1), mt->align_h);
-   if (mt->array_spacing_lod0)
-      qpitch = h0;
-   else
-      qpitch = (h0 + h1 + (brw->gen >= 7 ? 12 : 11) * mt->align_h);
-   if (mt->compressed)
-      qpitch /= 4;
+   const unsigned qpitch = brw_miptree_get_vertical_slice_pitch(brw, mt, 0);
 
    brw_miptree_layout_2d(mt);
 
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
index 8777a8c..34bf384 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
@@ -707,6 +707,16 @@ void
 intel_miptree_upsample(struct brw_context *brw,
                        struct intel_mipmap_tree *mt);
 
+unsigned
+brw_miptree_get_horizontal_slice_pitch(struct brw_context *brw,
+                                       struct intel_mipmap_tree *mt,
+                                       unsigned level);
+
+unsigned
+brw_miptree_get_vertical_slice_pitch(struct brw_context *brw,
+                                     struct intel_mipmap_tree *mt,
+                                     unsigned level);
+
 void brw_miptree_layout(struct brw_context *brw, struct intel_mipmap_tree *mt);
 
 void *intel_miptree_map_raw(struct brw_context *brw,
-- 
1.8.3.4



More information about the mesa-dev mailing list