mirror of
https://gitee.com/openharmony/third_party_mesa3d
synced 2024-11-23 07:19:50 +00:00
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> (cherry picked from commit 0b26a9f773956fc00a77b0d4a7aafee5795ce935)
This commit is contained in:
parent
6bba416efa
commit
7dee5d7dec
@ -2074,7 +2074,7 @@
|
||||
"description": "panfrost: Don't copy resources if replaced",
|
||||
"nominated": true,
|
||||
"nomination_type": 0,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null
|
||||
},
|
||||
|
@ -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;
|
||||
|
||||
@ -1024,7 +1047,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) {
|
||||
|
Loading…
Reference in New Issue
Block a user