From 385cd3e0bed8113659f2db8976b677b090acc9d8 Mon Sep 17 00:00:00 2001 From: Anuj Phogat Date: Fri, 5 Jun 2015 10:41:24 -0700 Subject: [PATCH] i965: Make a helper function intel_miptree_release_levels() Signed-off-by: Anuj Phogat Reviewed-by: Ben Widawsky --- src/mesa/drivers/dri/i965/brw_tex_layout.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c index 45bbf7e7d0f..fc7454b7ef7 100644 --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c @@ -804,6 +804,17 @@ intel_miptree_set_alignment(struct brw_context *brw, } } +static void +intel_miptree_release_levels(struct intel_mipmap_tree *mt) +{ + unsigned int level = 0; + + for (level = mt->first_level; level <= mt->last_level; level++) { + free(mt->level[level].slice); + mt->level[level].slice = NULL; + } +} + void brw_miptree_layout(struct brw_context *brw, struct intel_mipmap_tree *mt, @@ -871,8 +882,6 @@ brw_miptree_layout(struct brw_context *brw, mt->tiling = brw_miptree_choose_tiling(brw, requested, mt); if (is_tr_mode_yf_ys_allowed) { - unsigned int level = 0; - if (mt->tiling == I915_TILING_Y || mt->tiling == (I915_TILING_Y | I915_TILING_X) || mt->tr_mode == INTEL_MIPTREE_TRMODE_NONE) { @@ -887,10 +896,7 @@ brw_miptree_layout(struct brw_context *brw, /* Failed to use selected tr_mode. Free up the memory allocated * for miptree levels in intel_miptree_total_width_height(). */ - for (level = mt->first_level; level <= mt->last_level; level++) { - free(mt->level[level].slice); - mt->level[level].slice = NULL; - } + intel_miptree_release_levels(mt); } i++; } -- 2.30.2