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

Author: Mike Blumenkrantz <[email protected]>
Date:   Fri Oct 13 12:47:15 2023 -0400

zink: add flag to restrict unsynchronized texture access

this is unset any time a texture is accessed and must be explicitly
re-set to preserve unsynchronized access

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25624>

---

 src/gallium/drivers/zink/zink_batch.c    | 1 +
 src/gallium/drivers/zink/zink_context.c  | 1 +
 src/gallium/drivers/zink/zink_resource.c | 1 +
 src/gallium/drivers/zink/zink_resource.h | 1 +
 src/gallium/drivers/zink/zink_types.h    | 1 +
 5 files changed, 5 insertions(+)

diff --git a/src/gallium/drivers/zink/zink_batch.c 
b/src/gallium/drivers/zink/zink_batch.c
index 2a3012ae217..5051161fd5b 100644
--- a/src/gallium/drivers/zink/zink_batch.c
+++ b/src/gallium/drivers/zink/zink_batch.c
@@ -36,6 +36,7 @@ reset_obj(struct zink_screen *screen, struct zink_batch_state 
*bs, struct zink_r
       obj->access_stage = 0;
       obj->unordered_access_stage = 0;
       obj->copies_need_reset = true;
+      obj->unsync_access = true;
       /* also prune dead view objects */
       simple_mtx_lock(&obj->view_lock);
       if (obj->is_buffer) {
diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index 1b500b21df7..e76259aa5c3 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -4535,6 +4535,7 @@ zink_copy_image_buffer(struct zink_context *ctx, struct 
zink_resource *dst, stru
    zink_batch_reference_resource_rw(batch, buf, !buf2img);
    if (unsync) {
       ctx->batch.state->has_unsync = true;
+      img->obj->unsync_access = true;
    }
 
    /* we're using u_transfer_helper_deinterleave, which means we'll be getting 
PIPE_MAP_* usage
diff --git a/src/gallium/drivers/zink/zink_resource.c 
b/src/gallium/drivers/zink/zink_resource.c
index d0b478f3ee6..c058631e6a5 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -779,6 +779,7 @@ resource_object_create(struct zink_screen *screen, const 
struct pipe_resource *t
    u_rwlock_init(&obj->copy_lock);
    obj->unordered_read = true;
    obj->unordered_write = true;
+   obj->unsync_access = true;
    obj->last_dt_idx = obj->dt_idx = UINT32_MAX; //TODO: unionize
 
    VkMemoryRequirements reqs = {0};
diff --git a/src/gallium/drivers/zink/zink_resource.h 
b/src/gallium/drivers/zink/zink_resource.h
index 14f1bafe3e8..6bdcaa2a854 100644
--- a/src/gallium/drivers/zink/zink_resource.h
+++ b/src/gallium/drivers/zink/zink_resource.h
@@ -163,6 +163,7 @@ static inline void
 zink_resource_usage_set(struct zink_resource *res, struct zink_batch_state 
*bs, bool write)
 {
    zink_bo_usage_set(res->obj->bo, bs, write);
+   res->obj->unsync_access = false;
 }
 
 static inline bool
diff --git a/src/gallium/drivers/zink/zink_types.h 
b/src/gallium/drivers/zink/zink_types.h
index 98d3337a9bd..1c2979fed5f 100644
--- a/src/gallium/drivers/zink/zink_types.h
+++ b/src/gallium/drivers/zink/zink_types.h
@@ -1233,6 +1233,7 @@ struct zink_resource_object {
    bool ordered_access_is_copied;
    bool unordered_read;
    bool unordered_write;
+   bool unsync_access;
    bool copies_valid;
    bool copies_need_reset; //for use with batch state resets
 

Reply via email to