From fbd4b2be5bff41108f2e64168d96a2bf7de0168a Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 25 Jun 2024 12:39:26 -0400 Subject: [PATCH] zink: modify some buffer mapping behavior for buffer replacement srcs if the src for a replace_buffer call is mapped after replacement: * avoid clearing access flags * update valid range the pointer access here is always safe because the only case in which this scenario can occur is if tc is forced to sync immediately after creating a replaceent buffer, and the replacement buffer's lifetime will always be exceeded by the lifetime of the real buffer cc: mesa-stable Part-of: (cherry picked from commit 70b40fd2a0cb4036f70cdc07e6d918c9876c6ea1) --- .pick_status.json | 2 +- src/gallium/drivers/zink/zink_resource.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index c09d2946ef4..7af3704d558 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -224,7 +224,7 @@ "description": "zink: modify some buffer mapping behavior for buffer replacement srcs", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index d079c0b26da..fe2ca14cece 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -2393,10 +2393,12 @@ overwrite: zink_resource_usage_wait(ctx, res, ZINK_RESOURCE_ACCESS_RW); } else zink_resource_usage_wait(ctx, res, ZINK_RESOURCE_ACCESS_WRITE); - res->obj->access = 0; - res->obj->access_stage = 0; - res->obj->last_write = 0; - zink_resource_copies_reset(res); + if (!res->real_buffer_range) { + res->obj->access = 0; + res->obj->access_stage = 0; + res->obj->last_write = 0; + zink_resource_copies_reset(res); + } } if (!ptr) { @@ -2437,6 +2439,8 @@ overwrite: struct zink_resource *orig_res = zink_resource(trans->base.b.resource); util_range_add(&orig_res->base.b, &orig_res->valid_buffer_range, box->x, box->x + box->width); + if (orig_res->real_buffer_range) + util_range_add(&orig_res->base.b, orig_res->real_buffer_range, box->x, box->x + box->width); } success: