zink: track whether there's any transient attachments bound
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 10 May 2022 16:25:43 +0000 (12:25 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 20 May 2022 16:42:21 +0000 (16:42 +0000)
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16476>

src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_context.h

index d49461e..541e7bc 100644 (file)
@@ -2384,10 +2384,14 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
    zink_update_fbfetch(ctx);
    unsigned prev_void_alpha_attachments = ctx->gfx_pipeline_state.void_alpha_attachments;
    ctx->gfx_pipeline_state.void_alpha_attachments = 0;
+   ctx->transient_attachments = 0;
+
    for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
       struct pipe_surface *psurf = ctx->fb_state.cbufs[i];
       if (psurf) {
          struct zink_surface *transient = zink_transient_surface(psurf);
+         if (transient)
+            ctx->transient_attachments |= BITFIELD_BIT(i);
          if (!samples)
             samples = MAX3(transient ? transient->base.nr_samples : 1, psurf->texture->nr_samples, 1);
          struct zink_resource *res = zink_resource(psurf->texture);
@@ -2410,6 +2414,8 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
    if (ctx->fb_state.zsbuf) {
       struct pipe_surface *psurf = ctx->fb_state.zsbuf;
       struct zink_surface *transient = zink_transient_surface(psurf);
+      if (transient)
+         ctx->transient_attachments |= BITFIELD_BIT(PIPE_MAX_COLOR_BUFS);
       if (!samples)
          samples = MAX3(transient ? transient->base.nr_samples : 1, psurf->texture->nr_samples, 1);
       zink_resource(psurf->texture)->fb_binds++;
index fcf3d03..8956870 100644 (file)
@@ -214,6 +214,7 @@ struct zink_context {
    uint32_t writable_ssbos[PIPE_SHADER_TYPES];
    struct zink_image_view image_views[PIPE_SHADER_TYPES][ZINK_MAX_SHADER_IMAGES];
 
+   uint32_t transient_attachments;
    struct pipe_framebuffer_state fb_state;
    struct hash_table framebuffer_cache;