freedreno: fix buffer import
authorRob Clark <robdclark@chromium.org>
Wed, 29 Apr 2020 22:23:26 +0000 (15:23 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 29 Apr 2020 22:34:25 +0000 (22:34 +0000)
`rsc->layout.cpp` is zero until we `fd_resource_layout_init()`

Fixes: 5a8718f01b3 ("freedreno: Make the slice pitch be bytes, not pixels.")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4818>

src/gallium/drivers/freedreno/freedreno_resource.c

index 68ecba242735cd188eb6a29a9fcf63754275dda0..2b89d6afb1e1687cdf5a9c5e040ffdb54926f654 100644 (file)
@@ -1092,7 +1092,6 @@ fd_resource_from_handle(struct pipe_screen *pscreen,
        struct fd_resource *rsc = CALLOC_STRUCT(fd_resource);
        struct fdl_slice *slice = fd_resource_slice(rsc, 0);
        struct pipe_resource *prsc = &rsc->base;
-       uint32_t pitchalign = fd_screen(pscreen)->gmem_alignw * rsc->layout.cpp;
 
        DBG("target=%d, format=%s, %ux%ux%u, array_size=%u, last_level=%u, "
                        "nr_samples=%u, usage=%u, bind=%x, flags=%x",
@@ -1124,6 +1123,8 @@ fd_resource_from_handle(struct pipe_screen *pscreen,
        slice->offset = handle->offset;
        slice->size0 = handle->stride * prsc->height0;
 
+       uint32_t pitchalign = fd_screen(pscreen)->gmem_alignw * rsc->layout.cpp;
+
        if ((slice->pitch < align(prsc->width0 * rsc->layout.cpp, pitchalign)) ||
                        (slice->pitch & (pitchalign - 1)))
                goto fail;