[Mesa-dev] [PATCH 19/22] i965/miptree: Prepare 3D surfaces with physical 2D layout

Topi Pohjolainen topi.pohjolainen at gmail.com
Tue Jul 18 08:46:29 UTC 2017


Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 39 +++++++++++++++------------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index fafd0c1e59..702dcd8635 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -668,6 +668,21 @@ intel_lower_compressed_format(struct brw_context *brw, mesa_format format)
    }
 }
 
+static unsigned
+get_num_phys_layers(const struct isl_surf *surf, unsigned level)
+{
+   /* In case of physical dimensions one needs to consider also the layout.
+    * See isl_calc_phys_level0_extent_sa().
+    */
+   if (surf->dim != ISL_SURF_DIM_3D)
+      return surf->phys_level0_sa.array_len;
+
+   if (surf->dim_layout == ISL_DIM_LAYOUT_GEN4_2D)
+      return minify(surf->phys_level0_sa.array_len, level);
+
+   return minify(surf->phys_level0_sa.depth, level);
+}
+
 /** \brief Assert that the level and layer are valid for the miptree. */
 void
 intel_miptree_check_level_layer(const struct intel_mipmap_tree *mt,
@@ -682,9 +697,7 @@ intel_miptree_check_level_layer(const struct intel_mipmap_tree *mt,
    assert(level <= mt->last_level);
 
    if (mt->surf.size > 0)
-      assert(layer < (mt->surf.dim == ISL_SURF_DIM_3D ?
-                         minify(mt->surf.phys_level0_sa.depth, level) :
-                         mt->surf.phys_level0_sa.array_len));
+      assert(layer < get_num_phys_layers(&mt->surf, level));
    else
       assert(layer < mt->level[level].depth);
 }
@@ -698,9 +711,7 @@ create_aux_state_map(struct intel_mipmap_tree *mt,
    uint32_t total_slices = 0;
    for (uint32_t level = 0; level < levels; level++) {
       if (mt->surf.size > 0)
-         total_slices += (mt->surf.dim == ISL_SURF_DIM_3D ?
-                             minify(mt->surf.phys_level0_sa.depth, level) :
-                             mt->surf.phys_level0_sa.array_len);
+         total_slices += get_num_phys_layers(&mt->surf, level);
       else
          total_slices += mt->level[level].depth;
    }
@@ -724,9 +735,7 @@ create_aux_state_map(struct intel_mipmap_tree *mt,
 
       unsigned level_depth;
       if (mt->surf.size > 0)
-         level_depth = mt->surf.dim == ISL_SURF_DIM_3D ?
-                          minify(mt->surf.phys_level0_sa.depth, level) :
-                          mt->surf.phys_level0_sa.array_len;
+         level_depth = get_num_phys_layers(&mt->surf, level);
       else
          level_depth = mt->level[level].depth;
               
@@ -1680,11 +1689,9 @@ intel_miptree_copy_slice(struct brw_context *brw,
       height = minify(src_mt->surf.phys_level0_sa.height,
                       src_level - src_mt->first_level);
 
-      if (src_mt->surf.dim == ISL_SURF_DIM_3D)
-         assert(src_layer < minify(src_mt->surf.phys_level0_sa.depth,
-                                   src_level - src_mt->first_level));
-      else
-         assert(src_layer < src_mt->surf.phys_level0_sa.array_len);
+      assert(src_layer <
+             get_num_phys_layers(&src_mt->surf,
+                                 src_level - src_mt->first_level));
    } else {
       width = minify(src_mt->physical_width0,
                      src_level - src_mt->first_level);
@@ -2475,9 +2482,7 @@ miptree_layer_range_length(const struct intel_mipmap_tree *mt, uint32_t level,
    uint32_t total_num_layers;
 
    if (mt->surf.size > 0)
-      total_num_layers = mt->surf.dim == ISL_SURF_DIM_3D ?
-         minify(mt->surf.phys_level0_sa.depth, level) :
-         mt->surf.phys_level0_sa.array_len;
+      total_num_layers = get_num_phys_layers(&mt->surf, level);
    else 
       total_num_layers = mt->level[level].depth;
 
-- 
2.11.0



More information about the mesa-dev mailing list