From 741921e2ffa877500c8fb4045702dfb4dae4f16e Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Sat, 28 Nov 2020 11:22:57 +0100 Subject: [PATCH] panfrost: Update the resource layout before calling util_copy_rect() If we don't do that, the line_stride might be wrong. We also need to create a new BO if the previous one is too small to hold the linear version, which can happen with the tile alignment done on linear+renderable resources. Suggested-by: Icecream95 Fixes: d4f662a25227 ("panfrost: Update the resource layout when doing a tile -> linear conversion") Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_resource.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 4727483e44f..02e1bc3796c 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -1044,6 +1044,15 @@ panfrost_ptr_unmap(struct pipe_context *pctx, assert(transfer->box.depth == 1); if (panfrost_should_linear_convert(prsrc, transfer)) { + size_t bo_size; + + panfrost_resource_setup(dev, prsrc, &bo_size, DRM_FORMAT_MOD_LINEAR); + if (bo_size > bo->size) { + panfrost_bo_unreference(bo); + bo = prsrc->bo = panfrost_bo_create(dev, bo_size, 0); + assert(bo); + } + util_copy_rect( bo->ptr.cpu + prsrc->slices[0].offset, prsrc->base.format, @@ -1054,8 +1063,6 @@ panfrost_ptr_unmap(struct pipe_context *pctx, trans->map, transfer->stride, 0, 0); - - panfrost_resource_setup(dev, prsrc, NULL, DRM_FORMAT_MOD_LINEAR); } else { panfrost_store_tiled_image( bo->ptr.cpu + prsrc->slices[transfer->level].offset,