Mesa (master): panfrost: Only copy resources when they are in a pending batch

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 26 06:44:30 UTC 2020


Module: Mesa
Branch: master
Commit: be5d06106ffd4ec29884d7cfca660b20eeac6f5b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=be5d06106ffd4ec29884d7cfca660b20eeac6f5b

Author: Icecream95 <ixn at keemail.me>
Date:   Thu Jun 25 19:51:37 2020 +1200

panfrost: Only copy resources when they are in a pending batch

Fixes a performance regression in alacritty, and rendering is still
fine in GLQuake ports.

Fixes: 361fb38662f ("panfrost: Copy resources when mapping to avoid waiting for readers")
Reviewed-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5642>

---

 src/gallium/drivers/panfrost/pan_resource.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 9d1905d6c71..303c4a8da55 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -604,10 +604,14 @@ panfrost_transfer_map(struct pipe_context *pctx,
             !(usage & PIPE_TRANSFER_UNSYNCHRONIZED) &&
             (usage & PIPE_TRANSFER_WRITE) &&
             !(resource->target == PIPE_BUFFER
-              && !util_ranges_intersect(&rsrc->valid_buffer_range, box->x, box->x + box->width))) {
+              && !util_ranges_intersect(&rsrc->valid_buffer_range, box->x, box->x + box->width)) &&
+            panfrost_pending_batches_access_bo(ctx, bo)) {
 
-                /* It is often faster to copy the whole resource than to flush
-                 * readers */
+                /* When a resource to be modified is already being used by a
+                 * pending batch, it is often faster to copy the whole BO than
+                 * to flush and split the frame in two. This also mostly
+                 * mitigates broken depth reload.
+                 */
 
                 panfrost_flush_batches_accessing_bo(ctx, bo, PAN_BO_ACCESS_WRITE);
                 panfrost_bo_wait(bo, INT64_MAX, PAN_BO_ACCESS_WRITE);



More information about the mesa-commit mailing list