[Mesa-dev] [PATCH 23/32] i965/miptree: Use miptree range helpers in has_color_unresolved

Jason Ekstrand jason at jlekstrand.net
Wed Jul 19 21:01:49 UTC 2017


---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 104 +++++++++++++-------------
 1 file changed, 51 insertions(+), 53 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 1bbf9a5..5696886 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -2106,6 +2106,52 @@ intel_miptree_level_has_hiz(const struct intel_mipmap_tree *mt, uint32_t level)
    return mt->level[level].has_hiz;
 }
 
+static inline uint32_t
+miptree_level_range_length(const struct intel_mipmap_tree *mt,
+                           uint32_t start_level, uint32_t num_levels)
+{
+   assert(start_level >= mt->first_level);
+   assert(start_level <= mt->last_level);
+
+   if (num_levels == INTEL_REMAINING_LAYERS)
+      num_levels = mt->last_level - start_level + 1;
+   /* Check for overflow */
+   assert(start_level + num_levels >= start_level);
+   assert(start_level + num_levels <= mt->last_level + 1);
+
+   return num_levels;
+}
+
+static inline uint32_t
+miptree_layer_range_length(const struct intel_mipmap_tree *mt, uint32_t level,
+                           uint32_t start_layer, uint32_t num_layers)
+{
+   assert(level <= mt->last_level);
+   uint32_t total_num_layers;
+
+   if (mt->surf.size > 0) {
+      total_num_layers = mt->surf.dim == ISL_SURF_DIM_3D ?
+         minify(mt->surf.logical_level0_px.depth, level) :
+         mt->surf.logical_level0_px.array_len;
+   } else {
+      total_num_layers = mt->level[level].depth;
+      if (mt->msaa_layout == INTEL_MSAA_LAYOUT_UMS ||
+          mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS) {
+         assert(total_num_layers % mt->num_samples == 0);
+         total_num_layers /= mt->num_samples;
+      }
+   }
+
+   assert(start_layer < total_num_layers);
+   if (num_layers == INTEL_REMAINING_LAYERS)
+      num_layers = total_num_layers - start_layer;
+   /* Check for overflow */
+   assert(start_layer + num_layers >= start_layer);
+   assert(start_layer + num_layers <= total_num_layers);
+
+   return num_layers;
+}
+
 bool
 intel_miptree_has_color_unresolved(const struct intel_mipmap_tree *mt,
                                    unsigned start_level, unsigned num_levels,
@@ -2117,14 +2163,12 @@ intel_miptree_has_color_unresolved(const struct intel_mipmap_tree *mt,
       return false;
 
    /* Clamp the level range to fit the miptree */
-   assert(start_level + num_levels >= start_level);
-   const uint32_t last_level =
-      MIN2(mt->last_level, start_level + num_levels - 1);
-   start_level = MAX2(mt->first_level, start_level);
-   num_levels = last_level - start_level + 1;
+   num_levels = miptree_level_range_length(mt, start_level, num_levels);
 
-   for (uint32_t level = start_level; level <= last_level; level++) {
-      const uint32_t level_layers = MIN2(num_layers, mt->level[level].depth);
+   for (uint32_t l = 0; l < num_levels; l++) {
+      const uint32_t level = start_level + l;
+      const uint32_t level_layers =
+         miptree_layer_range_length(mt, level, start_layer, num_layers);
       for (unsigned a = 0; a < level_layers; a++) {
          enum isl_aux_state aux_state =
             intel_miptree_get_aux_state(mt, level, start_layer + a);
@@ -2506,52 +2550,6 @@ intel_miptree_finish_hiz_write(struct brw_context *brw,
    }
 }
 
-static inline uint32_t
-miptree_level_range_length(const struct intel_mipmap_tree *mt,
-                           uint32_t start_level, uint32_t num_levels)
-{
-   assert(start_level >= mt->first_level);
-   assert(start_level <= mt->last_level);
-
-   if (num_levels == INTEL_REMAINING_LAYERS)
-      num_levels = mt->last_level - start_level + 1;
-   /* Check for overflow */
-   assert(start_level + num_levels >= start_level);
-   assert(start_level + num_levels <= mt->last_level + 1);
-
-   return num_levels;
-}
-
-static inline uint32_t
-miptree_layer_range_length(const struct intel_mipmap_tree *mt, uint32_t level,
-                           uint32_t start_layer, uint32_t num_layers)
-{
-   assert(level <= mt->last_level);
-   uint32_t total_num_layers;
-
-   if (mt->surf.size > 0) {
-      total_num_layers = mt->surf.dim == ISL_SURF_DIM_3D ?
-         minify(mt->surf.logical_level0_px.depth, level) :
-         mt->surf.logical_level0_px.array_len;
-   } else {
-      total_num_layers = mt->level[level].depth;
-      if (mt->msaa_layout == INTEL_MSAA_LAYOUT_UMS ||
-          mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS) {
-         assert(total_num_layers % mt->num_samples == 0);
-         total_num_layers /= mt->num_samples;
-      }
-   }
-
-   assert(start_layer < total_num_layers);
-   if (num_layers == INTEL_REMAINING_LAYERS)
-      num_layers = total_num_layers - start_layer;
-   /* Check for overflow */
-   assert(start_layer + num_layers >= start_layer);
-   assert(start_layer + num_layers <= total_num_layers);
-
-   return num_layers;
-}
-
 void
 intel_miptree_prepare_access(struct brw_context *brw,
                              struct intel_mipmap_tree *mt,
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list