diff options
author | Jason Ekstrand <[email protected]> | 2017-06-21 20:00:12 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-07-22 20:59:22 -0700 |
commit | 2ccfc0ffddd4645a6b5c7bf0c58e0570c8b4aaea (patch) | |
tree | a7aa997adb39de918cf5793de88892691518d683 | |
parent | 1c70c57aedc9cdf90061816d213f9ad2e36eea80 (diff) |
i965/miptree: Use miptree range helpers in has_color_unresolved
Reviewed-by: Topi Pohjolainen <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 81 |
1 files changed, 38 insertions, 43 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index c7efb77289e..e802affac98 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -1854,6 +1854,39 @@ 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); + + const uint32_t total_num_layers = get_num_logical_layers(mt, level); + 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, @@ -1865,17 +1898,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; - - for (uint32_t level = start_level; level <= last_level; level++) { - uint32_t level_layers = get_num_phys_layers(&mt->surf, level); - - level_layers = MIN2(num_layers, level_layers); + num_levels = miptree_level_range_length(mt, start_level, num_levels); + 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); @@ -2270,39 +2298,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); - - const uint32_t total_num_layers = get_num_logical_layers(mt, level); - 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, |