From 504a522a1ea0dc638373db970a3d9979b92f79d7 Mon Sep 17 00:00:00 2001
From: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Date: Mon, 8 Sep 2025 10:12:58 -0400
Subject: [PATCH] zink: toggle ctx->has_swapchain when flushing clears

this otherwise breaks resolve handling

Fixes: b122c3eaa9e ("zink: unify/fix clear flushing")

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13841
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13847
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37234>
---
 src/gallium/drivers/zink/zink_context.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 38d843e127d8e..46e2335efe621 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -3401,11 +3401,14 @@ zink_flush_clears(struct zink_context *ctx)
    struct zink_screen *screen = zink_screen(ctx->base.screen);
    bool general_layout = screen->driver_workarounds.general_layout;
    bool queries_disabled = ctx->queries_disabled;
+   bool has_swapchain = ctx->has_swapchain;
    bool blitting = ctx->blitting;
    struct pipe_framebuffer_state fb = ctx->fb_state;
    if (!blitting) {
       for (unsigned i = 0; i < ctx->fb_state.nr_cbufs; i++) {
          if (!ctx->fb_state.cbufs[i].texture || !zink_fb_clear_enabled(ctx, i)) {
+            if (ctx->fb_state.cbufs[i].texture && zink_is_swapchain(zink_resource(ctx->fb_state.cbufs[i].texture)))
+               ctx->has_swapchain = false;
             ctx->fb_state.cbufs[i].texture = NULL;
             continue;
          }
@@ -3439,6 +3442,7 @@ zink_flush_clears(struct zink_context *ctx)
    zink_batch_rp(ctx);
    ctx->queries_disabled = queries_disabled;
    ctx->blitting = blitting;
+   ctx->has_swapchain = has_swapchain;
    if (!blitting)
       ctx->fb_state = fb;
    zink_batch_no_rp(ctx);
-- 
GitLab

