mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-02 16:38:09 +02:00
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>
This commit is contained in:
parent
c53d0a6a6d
commit
22a7637b08
1 changed files with 14 additions and 5 deletions
|
|
@ -1081,6 +1081,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->bo->flags & PAN_BO_SHARED));
|
||||
}
|
||||
|
||||
static void *
|
||||
panfrost_ptr_map(struct pipe_context *pctx, struct pipe_resource *resource,
|
||||
unsigned level,
|
||||
|
|
@ -1165,11 +1178,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->bo->flags & PAN_BO_SHARED)) {
|
||||
|
||||
if (panfrost_can_discard(resource, box, usage)) {
|
||||
usage |= PIPE_MAP_DISCARD_WHOLE_RESOURCE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue