i965: Make a helper function intel_miptree_release_levels()
authorAnuj Phogat <anuj.phogat@gmail.com>
Fri, 5 Jun 2015 17:41:24 +0000 (10:41 -0700)
committerAnuj Phogat <anuj.phogat@gmail.com>
Mon, 29 Jun 2015 20:14:17 +0000 (13:14 -0700)
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
src/mesa/drivers/dri/i965/brw_tex_layout.c

index 45bbf7e7d0fc319e5f7cbb927557061c0cd92d22..fc7454b7ef7d1860e8b353f5665df8691ed6b3f6 100644 (file)
@@ -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++;
    }