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

Author: Mike Blumenkrantz <[email protected]>
Date:   Mon Mar 13 07:40:03 2023 -0400

aux/tc: add a function to reset rp info

drivers should be maintaining a local copy of the rp info, and this
provides a consistent way to reset that info if a renderpass is ended
early

Acked-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21800>

---

 src/gallium/auxiliary/util/u_threaded_context.h | 17 +++++++++++++++++
 src/gallium/drivers/zink/zink_context.c         |  9 ++-------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_threaded_context.h 
b/src/gallium/auxiliary/util/u_threaded_context.h
index 50462dfb7dc..f3b31e02d0a 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.h
+++ b/src/gallium/auxiliary/util/u_threaded_context.h
@@ -487,6 +487,23 @@ tc_renderpass_info_is_zsbuf_used(const struct 
tc_renderpass_info *info)
           info->zsbuf_fbfetch;
 }
 
+/* if a driver ends a renderpass early for some reason,
+ * this function can be called to reset any stored renderpass info
+ * to a "safe" state that will avoid data loss on framebuffer attachments
+ * 
+ * note: ending a renderpass early if invalidate hints are applied will
+ * result in data loss
+ */
+static inline void
+tc_renderpass_info_reset(struct tc_renderpass_info *info)
+{
+   info->data32[0] = 0;
+   info->cbuf_load = BITFIELD_MASK(8);
+   info->zsbuf_clear_partial = true;
+   info->has_draw = true;
+   info->has_query_ends = true;
+}
+
 struct tc_batch {
    struct threaded_context *tc;
 #if !defined(NDEBUG) && TC_DEBUG >= 1
diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index 69e8b62844e..cdf9c88019d 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -2816,13 +2816,8 @@ zink_batch_no_rp(struct zink_context *ctx)
 {
    if (!ctx->batch.in_rp)
       return;
-   if (zink_screen(ctx->base.screen)->driver_workarounds.track_renderpasses && 
!ctx->blitting) {
-      ctx->dynamic_fb.tc_info.data = 0;
-      ctx->dynamic_fb.tc_info.cbuf_load = BITFIELD_MASK(8);
-      ctx->dynamic_fb.tc_info.zsbuf_clear_partial = true;
-      ctx->dynamic_fb.tc_info.has_draw = true;
-      ctx->dynamic_fb.tc_info.has_query_ends = true;
-   }
+   if (zink_screen(ctx->base.screen)->driver_workarounds.track_renderpasses && 
!ctx->blitting)
+      tc_renderpass_info_reset(&ctx->dynamic_fb.tc_info);
    zink_batch_no_rp_safe(ctx);
 }
 

Reply via email to