intel/blorp: Fix the early return condition in convert_to_single_slice
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 31 Aug 2016 19:58:54 +0000 (12:58 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 13 Sep 2016 02:42:57 +0000 (19:42 -0700)
The convert_to_single_slice operation is *mostly* idempotent.  The only
non-repeatable thing it does is that, when it sets the intratile offset
fields, it just overwrites them instead of doing a += operation.  This is
supposed to be ok because we have an early return at the top that should
make it bail of the surface is already a single slice.  Unfortunately, the
if condition has been broken ever since it was first added in 96fa98c18.
This commit fixes the condition and adds an assert to ensure we don't stomp
any non-zero intratile offsets.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/intel/blorp/blorp_blit.c

index 9108e5db4ddd5a76a49a6e610903605da83d584c..0a276284674e5a6354154f1537c662abe99324ee 100644 (file)
@@ -1254,9 +1254,14 @@ surf_convert_to_single_slice(const struct isl_device *isl_dev,
    /* Just bail if we have nothing to do. */
    if (info->surf.dim == ISL_SURF_DIM_2D &&
        info->view.base_level == 0 && info->view.base_array_layer == 0 &&
-       info->surf.levels == 0 && info->surf.logical_level0_px.array_len == 0)
+       info->surf.levels == 1 && info->surf.logical_level0_px.array_len == 1)
       return;
 
+   /* If this gets triggered then we've gotten here twice which.  This
+    * shouldn't happen thanks to the above early return.
+    */
+   assert(info->tile_x_sa == 0 && info->tile_y_sa == 0);
+
    uint32_t x_offset_sa, y_offset_sa;
    isl_surf_get_image_offset_sa(&info->surf, info->view.base_level,
                                 info->view.base_array_layer, 0,