Mesa (main): zink: smash dstAlphaBlendFactor to ZERO for RGBX attachments

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 16 19:55:00 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Wed Apr  7 11:00:25 2021 -0400

zink: smash dstAlphaBlendFactor to ZERO for RGBX attachments

this is a no-op

Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11391>

---

 src/gallium/drivers/zink/zink_context.c  |  8 +++++++-
 src/gallium/drivers/zink/zink_pipeline.c | 11 ++++++++++-
 src/gallium/drivers/zink/zink_pipeline.h |  1 +
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 2ebf1b2c7f2..7621b44005a 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1919,11 +1919,17 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
    unsigned h = ctx->fb_state.height;
 
    util_copy_framebuffer_state(&ctx->fb_state, state);
+   unsigned prev_void_alpha_attachments = ctx->gfx_pipeline_state.void_alpha_attachments;
+   ctx->gfx_pipeline_state.void_alpha_attachments = 0;
    for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
       struct pipe_surface *surf = ctx->fb_state.cbufs[i];
-      if (surf)
+      if (surf) {
          zink_resource(surf->texture)->fb_binds++;
+         ctx->gfx_pipeline_state.void_alpha_attachments |= util_format_has_alpha1(surf->format) ? BITFIELD_BIT(i) : 0;
+      }
    }
+   if (ctx->gfx_pipeline_state.void_alpha_attachments != prev_void_alpha_attachments)
+      ctx->gfx_pipeline_state.dirty = true;
    if (ctx->fb_state.zsbuf) {
       struct pipe_surface *surf = ctx->fb_state.zsbuf;
       zink_resource(surf->texture)->fb_binds++;
diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c
index b7c0d842fcc..fede591433a 100644
--- a/src/gallium/drivers/zink/zink_pipeline.c
+++ b/src/gallium/drivers/zink/zink_pipeline.c
@@ -74,9 +74,18 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
       primitive_state.primitiveRestartEnable = state->primitive_restart ? VK_TRUE : VK_FALSE;
    }
 
+   VkPipelineColorBlendAttachmentState blend_att[PIPE_MAX_COLOR_BUFS];
    VkPipelineColorBlendStateCreateInfo blend_state = {0};
    blend_state.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
-   blend_state.pAttachments = state->blend_state->attachments;
+   if (state->void_alpha_attachments) {
+      for (unsigned i = 0; i < state->num_attachments; i++) {
+         blend_att[i] = state->blend_state->attachments[i];
+         if (state->void_alpha_attachments & BITFIELD_BIT(i))
+            blend_att[i].dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
+      }
+      blend_state.pAttachments = blend_att;
+   } else
+      blend_state.pAttachments = state->blend_state->attachments;
    blend_state.attachmentCount = state->num_attachments;
    blend_state.logicOpEnable = state->blend_state->logicop_enable;
    blend_state.logicOp = state->blend_state->logicop_func;
diff --git a/src/gallium/drivers/zink/zink_pipeline.h b/src/gallium/drivers/zink/zink_pipeline.h
index fec7af77276..22023a2ae08 100644
--- a/src/gallium/drivers/zink/zink_pipeline.h
+++ b/src/gallium/drivers/zink/zink_pipeline.h
@@ -40,6 +40,7 @@ struct zink_vertex_elements_state;
 struct zink_gfx_pipeline_state {
    struct zink_render_pass *render_pass;
 
+   uint8_t void_alpha_attachments:PIPE_MAX_COLOR_BUFS;
    uint32_t num_attachments;
    struct zink_blend_state *blend_state;
 



More information about the mesa-commit mailing list