i965/miptree: Tell when brw_miptree_layout() fails
authorTopi Pohjolainen <topi.pohjolainen@intel.com>
Tue, 17 Jan 2017 08:10:17 +0000 (10:10 +0200)
committerTopi Pohjolainen <topi.pohjolainen@intel.com>
Fri, 27 Jan 2017 06:57:25 +0000 (08:57 +0200)
In addition, let intel_miptree_create_layout() release the
miptree - it is the allocator.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_tex_layout.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.h

index 684ae769c5656fcb456b45bd73f02a4f453eb429..8a528e088a49995b9df68e9ed8afb29786e0fdb8 100644 (file)
@@ -763,7 +763,7 @@ intel_miptree_set_alignment(struct brw_context *brw,
    }
 }
 
-void
+bool
 brw_miptree_layout(struct brw_context *brw,
                    struct intel_mipmap_tree *mt,
                    uint32_t layout_flags)
@@ -773,10 +773,8 @@ brw_miptree_layout(struct brw_context *brw,
    intel_miptree_set_alignment(brw, mt, layout_flags);
    intel_miptree_set_total_width_height(brw, mt);
 
-   if (!mt->total_width || !mt->total_height) {
-      intel_miptree_release(&mt);
-      return;
-   }
+   if (!mt->total_width || !mt->total_height)
+      return false;
 
    /* On Gen9+ the alignment values are expressed in multiples of the block
     * size
@@ -790,5 +788,7 @@ brw_miptree_layout(struct brw_context *brw,
 
    if ((layout_flags & MIPTREE_LAYOUT_FOR_BO) == 0)
       mt->tiling = brw_miptree_choose_tiling(brw, mt, layout_flags);
+
+   return true;
 }
 
index ed514239e2116b62b4d863f2141a93e1af003ef2..f2debae444a546a240a4c65ee3c80380f338e35e 100644 (file)
@@ -526,7 +526,10 @@ intel_miptree_create_layout(struct brw_context *brw,
              (layout_flags & MIPTREE_LAYOUT_FORCE_HALIGN16) == 0);
    }
 
-   brw_miptree_layout(brw, mt, layout_flags);
+   if (!brw_miptree_layout(brw, mt, layout_flags)) {
+      intel_miptree_release(&mt);
+      return NULL;
+   }
 
    if (mt->aux_disable & INTEL_AUX_DISABLE_MCS)
       assert(mt->msaa_layout != INTEL_MSAA_LAYOUT_CMS);
index 476c46b135541a217dda3ece16ce801de0535177..27bcdfbe334fe086738ff5e3082cb2fe9e069e0e 100644 (file)
@@ -983,7 +983,7 @@ brw_miptree_get_vertical_slice_pitch(const struct brw_context *brw,
                                      const struct intel_mipmap_tree *mt,
                                      unsigned level);
 
-void
+bool
 brw_miptree_layout(struct brw_context *brw,
                    struct intel_mipmap_tree *mt,
                    uint32_t layout_flags);