Mesa (master): vc4: Sanity check strides for imported BOs.

Eric Anholt anholt at kemper.freedesktop.org
Mon Apr 18 17:11:11 UTC 2016


Module: Mesa
Branch: master
Commit: 56b14adf8508edea1c2d230f5e58b9110a26545a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=56b14adf8508edea1c2d230f5e58b9110a26545a

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Apr 15 13:17:26 2016 -0700

vc4: Sanity check strides for imported BOs.

If we're going to sample from or render to them at some particular size,
we'd better make sure that they actually are that size.  Causes some tests
under simulation to generate appropriate error messages instead of
failures.

---

 src/gallium/drivers/vc4/vc4_resource.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c
index ea212af..2f89da5 100644
--- a/src/gallium/drivers/vc4/vc4_resource.c
+++ b/src/gallium/drivers/vc4/vc4_resource.c
@@ -529,20 +529,33 @@ vc4_resource_from_handle(struct pipe_screen *pscreen,
         struct vc4_resource *rsc = vc4_resource_setup(pscreen, tmpl);
         struct pipe_resource *prsc = &rsc->base.b;
         struct vc4_resource_slice *slice = &rsc->slices[0];
+        uint32_t expected_stride = align(prsc->width0 / rsc->cpp,
+                                         vc4_utile_width(rsc->cpp));
 
         if (!rsc)
                 return NULL;
 
+        if (handle->stride != expected_stride) {
+                static bool warned = false;
+                if (!warned) {
+                        warned = true;
+                        fprintf(stderr,
+                                "Attempting to import %dx%d %s with "
+                                "unsupported stride %d instead of %d\n",
+                                prsc->width0, prsc->height0,
+                                util_format_short_name(prsc->format),
+                                handle->stride,
+                                expected_stride);
+                }
+                return NULL;
+        }
+
         rsc->tiled = false;
         rsc->bo = vc4_screen_bo_from_handle(pscreen, handle);
         if (!rsc->bo)
                 goto fail;
 
-        if (!using_vc4_simulator)
-                slice->stride = handle->stride;
-        else
-                slice->stride = align(prsc->width0 * rsc->cpp, 16);
-
+        slice->stride = handle->stride;
         slice->tiling = VC4_TILING_FORMAT_LINEAR;
 
         rsc->vc4_format = get_resource_texture_format(prsc);




More information about the mesa-commit mailing list