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

Author: Mike Blumenkrantz <[email protected]>
Date:   Thu Sep  2 14:17:47 2021 -0400

zink: be smarter about fb surface rebinds

the aspect info lets us avoid unnecessary comparisons

Reviewed-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12843>

---

 src/gallium/drivers/zink/zink_context.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index 586eaf83be7..73c6a635016 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -3161,16 +3161,19 @@ zink_rebind_framebuffer(struct zink_context *ctx, 
struct zink_resource *res)
 {
    if (!ctx->framebuffer)
       return;
-   for (unsigned i = 0; i < ctx->fb_state.nr_cbufs; i++) {
-      if (!ctx->fb_state.cbufs[i] ||
-          zink_resource(ctx->fb_state.cbufs[i]->texture) != res)
-         continue;
-      zink_rebind_ctx_surface(ctx, &ctx->fb_state.cbufs[i]);
-      zink_batch_no_rp(ctx);
-   }
-   if (ctx->fb_state.zsbuf && zink_resource(ctx->fb_state.zsbuf->texture) != 
res) {
-      zink_rebind_ctx_surface(ctx, &ctx->fb_state.zsbuf);
-      zink_batch_no_rp(ctx);
+   if (res->aspect & VK_IMAGE_ASPECT_COLOR_BIT) {
+      for (unsigned i = 0; i < ctx->fb_state.nr_cbufs; i++) {
+         if (!ctx->fb_state.cbufs[i] ||
+             zink_resource(ctx->fb_state.cbufs[i]->texture) != res)
+            continue;
+         zink_rebind_ctx_surface(ctx, &ctx->fb_state.cbufs[i]);
+         zink_batch_no_rp(ctx);
+      }
+   } else {
+      if (ctx->fb_state.zsbuf && zink_resource(ctx->fb_state.zsbuf->texture) 
!= res) {
+         zink_rebind_ctx_surface(ctx, &ctx->fb_state.zsbuf);
+         zink_batch_no_rp(ctx);
+      }
    }
    if (rebind_fb_state(ctx, res, false))
       zink_batch_no_rp(ctx);

Reply via email to