v3d: Add safety checks for resource_create().
authorEric Anholt <eric@anholt.net>
Fri, 30 Nov 2018 01:06:25 +0000 (17:06 -0800)
committerEric Anholt <eric@anholt.net>
Sat, 15 Dec 2018 01:48:01 +0000 (17:48 -0800)
This should ease my debugging next time I screw it up.

src/gallium/drivers/v3d/v3d_resource.c

index 33b44868bbd551a9d0737664e711b6895bae89ac..e7e149abd746165275a3b79874e0f42a787aa616 100644 (file)
@@ -432,6 +432,12 @@ v3d_setup_slices(struct v3d_resource *rsc, uint32_t winsys_stride)
          */
         bool uif_top = msaa;
 
+        /* Check some easy mistakes to make in a resource_create() call that
+         * will break our setup.
+         */
+        assert(prsc->array_size != 0);
+        assert(prsc->depth0 != 0);
+
         for (int i = prsc->last_level; i >= 0; i--) {
                 struct v3d_resource_slice *slice = &rsc->slices[i];