panfrost: factor out method to check whether we can discard resource
The logic is gonna be re-used to determine whether we need to
unpack a AFBC-packed texture before updating it (when unmapping).
Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Fixes: 33b48a5585 ("panfrost: Add debug flag to force packing of AFBC textures on upload")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27208>
(cherry picked from commit 22a7637b08255acc998e67bbdbc1ed34daf21465)
This commit is contained in:
parent
6ffceb7138
commit
dc7b4111fd
2 changed files with 15 additions and 6 deletions
|
|
@ -954,7 +954,7 @@
|
|||
"description": "panfrost: factor out method to check whether we can discard resource",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "33b48a55857b15f7e7b892a89cad2f0ad2399ba6",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -1077,6 +1077,19 @@ panfrost_box_covers_resource(const struct pipe_resource *resource,
|
|||
box->width, box->height, box->depth);
|
||||
}
|
||||
|
||||
static bool
|
||||
panfrost_can_discard(struct pipe_resource *resource, const struct pipe_box *box,
|
||||
unsigned usage)
|
||||
{
|
||||
struct panfrost_resource *rsrc = pan_resource(resource);
|
||||
|
||||
return ((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));
|
||||
}
|
||||
|
||||
static void *
|
||||
panfrost_ptr_map(struct pipe_context *pctx, struct pipe_resource *resource,
|
||||
unsigned level,
|
||||
|
|
@ -1161,11 +1174,7 @@ panfrost_ptr_map(struct pipe_context *pctx, struct pipe_resource *resource,
|
|||
/* 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)) {
|
||||
|
||||
if (panfrost_can_discard(resource, box, usage)) {
|
||||
usage |= PIPE_MAP_DISCARD_WHOLE_RESOURCE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue