panfrost: Don't copy resources if replaced
If a synchronized transfer_map is going to overwrite an entire resource, there's no need to memcpy in the original contents ahead-of-time. This memcpy is particularly bad for large buffers where it's copying WC->WC, although that could be mitigated with threaded_context's cpu_storage in the future if needed. Prevents a performance regression in glmark2's buffer scenes from the next patch, hence the Cc. Cc: mesa-stable Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19361>
This commit is contained in:

committed by
Marge Bot

parent
dfa8600a2d
commit
0b26a9f773
@@ -936,6 +936,17 @@ panfrost_store_tiled_images(struct panfrost_transfer *transfer,
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
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;
|
||||
}
|
||||
|
||||
static void *
|
||||
panfrost_ptr_map(struct pipe_context *pctx,
|
||||
struct pipe_resource *resource,
|
||||
@@ -1005,6 +1016,18 @@ panfrost_ptr_map(struct pipe_context *pctx,
|
||||
if (dev->debug & (PAN_DBG_TRACE | PAN_DBG_SYNC))
|
||||
pandecode_inject_mmap(bo->ptr.gpu, bo->ptr.cpu, bo->size, NULL);
|
||||
|
||||
/* Upgrade DISCARD_RANGE to WHOLE_RESOURCE if the whole resource is
|
||||
* being mapped.
|
||||
*/
|
||||
if ((usage & PIPE_MAP_DISCARD_RANGE) &&
|
||||
!(usage & PIPE_MAP_UNSYNCHRONIZED) &&
|
||||
!(resource->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) &&
|
||||
panfrost_box_covers_resource(resource, box) &&
|
||||
!(rsrc->image.data.bo->flags & PAN_BO_SHARED)) {
|
||||
|
||||
usage |= PIPE_MAP_DISCARD_WHOLE_RESOURCE;
|
||||
}
|
||||
|
||||
bool create_new_bo = usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE;
|
||||
bool copy_resource = false;
|
||||
|
||||
@@ -1025,7 +1048,7 @@ panfrost_ptr_map(struct pipe_context *pctx,
|
||||
panfrost_bo_wait(bo, INT64_MAX, false);
|
||||
|
||||
create_new_bo = true;
|
||||
copy_resource = true;
|
||||
copy_resource = !panfrost_box_covers_resource(resource, box);
|
||||
}
|
||||
|
||||
if (create_new_bo) {
|
||||
|
Reference in New Issue
Block a user