From: Alyssa Rosenzweig Date: Mon, 7 Nov 2022 15:45:08 +0000 (-0500) Subject: panfrost: Copy resources when necessary X-Git-Tag: upstream/22.3.5~488 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c24336ea4c71774237633421119a9562d2e8436;p=platform%2Fupstream%2Fmesa.git panfrost: Copy resources when necessary If the map doesn't set MAP_DISCARD_RANGE, we do have to copy the existing contents over. MAP_WRITE on its only gives permission to replace the contents, unfortunately it does not require that the application actually do so. Closes: #7640 Fixes: 0b26a9f7739 ("panfrost: Don't copy resources if replaced") Signed-off-by: Alyssa Rosenzweig Reported-by: Roman Elshin Part-of: (cherry picked from commit cf7a3906b0629b2b6aadd3b18a39eae06b10fd6a) --- diff --git a/.pick_status.json b/.pick_status.json index 04e258f..4ca7f7e 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -121,7 +121,7 @@ "description": "panfrost: Copy resources when necessary", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "0b26a9f773956fc00a77b0d4a7aafee5795ce935" }, diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 0bb5e97..402346d 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -941,10 +941,9 @@ 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; + util_texrange_covers_whole_level(resource, 0, box->x, box->y, + box->z, box->width, box->height, + box->depth); } static void * @@ -1048,7 +1047,7 @@ panfrost_ptr_map(struct pipe_context *pctx, panfrost_bo_wait(bo, INT64_MAX, false); create_new_bo = true; - copy_resource = !panfrost_box_covers_resource(resource, box); + copy_resource = !(usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE); } /* Shadowing with separate stencil may require additional accounting.