From 8dae6034310feea233e43b227703ef29fd8decde Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 19 Dec 2024 17:22:52 +0100 Subject: [PATCH] panfrost: in-place map/unmap shouldn't grow If we're doing in-place map/unmap of a tiled resource, that shouldn't cause the size of the resource to grow. So let's drop this needless complexity, and just assert this assumption instead. Reviewed-by: Lars-Ivar Hesselberg Simonsen Part-of: --- src/gallium/drivers/panfrost/pan_resource.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 94980f8c580..733d16be7b8 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -1815,14 +1815,11 @@ panfrost_ptr_unmap(struct pipe_context *pctx, struct pipe_transfer *transfer) if (panfrost_should_linear_convert(ctx, prsrc, transfer)) { panfrost_resource_setup(screen, prsrc, DRM_FORMAT_MOD_LINEAR, prsrc->image.layout.format); - if (prsrc->image.layout.data_size > panfrost_bo_size(bo)) { - const char *label = bo->label; - panfrost_bo_unreference(bo); - bo = prsrc->bo = panfrost_bo_create( - dev, prsrc->image.layout.data_size, 0, label); - prsrc->image.data.base = prsrc->bo->ptr.gpu; - assert(bo); - } + + /* converting the resource from tiled to linear and back + * shouldn't increase memory usage... + */ + assert(prsrc->image.layout.data_size <= panfrost_bo_size(bo)); util_copy_rect( bo->ptr.cpu + prsrc->image.layout.slices[0].offset,