diff --git a/.pick_status.json b/.pick_status.json index f330617916c..5152001f8fd 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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 diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 38f43cadf10..17fc51a04e9 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -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; }