panfrost: Copy resources when necessary

If the map doesn't set MAP_DISCARD_RANGE, we do have to copy the existing
contents over. MAP_WRITE on its only gives permission to replace the contents,
unfortunately it does not require that the application actually do so.

Closes: #7640
Fixes: 0b26a9f773 ("panfrost: Don't copy resources if replaced")
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reported-by: Roman Elshin
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19576>
This commit is contained in:
Alyssa Rosenzweig
2022-11-07 10:45:08 -05:00
committed by Marge Bot
parent 59cc628c06
commit cf7a3906b0

View File

@@ -941,10 +941,9 @@ panfrost_box_covers_resource(const struct pipe_resource *resource,
const struct pipe_box *box)
{
return resource->last_level == 0 &&
resource->width0 == box->width &&
resource->height0 == box->height &&
resource->depth0 == box->depth &&
resource->array_size == 1;
util_texrange_covers_whole_level(resource, 0, box->x, box->y,
box->z, box->width, box->height,
box->depth);
}
static void *
@@ -1048,7 +1047,7 @@ panfrost_ptr_map(struct pipe_context *pctx,
panfrost_bo_wait(bo, INT64_MAX, false);
create_new_bo = true;
copy_resource = !panfrost_box_covers_resource(resource, box);
copy_resource = !(usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE);
}
/* Shadowing with separate stencil may require additional accounting.