diff options
author | Rob Clark <[email protected]> | 2020-04-29 15:23:26 -0700 |
---|---|---|
committer | Eric Engestrom <[email protected]> | 2020-05-04 22:00:02 +0200 |
commit | 8229d22234eb2788953dc8db52c500dbb5e52aa0 (patch) | |
tree | 04997dc3ef80164e821fad71eeecd21b08a2315d /src | |
parent | 6236c9769930f2bc54871dba68c5da86e926a5bf (diff) |
freedreno: fix buffer import
`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 <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4818>
(cherry picked from commit a0fe98b478767e90cc5ed976e4e953117fe38308)
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_resource.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 25793a71859..519cfbc1a5b 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -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; |