zink: use an extra pipeline state bit to track coherent fbfetch usage for gpl outputs
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Sun, 25 Sep 2022 16:40:57 +0000 (12:40 -0400)
committerMarge Bot <emma+marge@anholt.net>
Sat, 1 Oct 2022 02:18:39 +0000 (02:18 +0000)
bringing parity to non-gpl codepath

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18911>

src/gallium/drivers/zink/zink_pipeline.c
src/gallium/drivers/zink/zink_program.c
src/gallium/drivers/zink/zink_types.h

index 4ffa5ee..6d911c7 100644 (file)
@@ -107,8 +107,7 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
       blend_state.logicOpEnable = state->blend_state->logicop_enable;
       blend_state.logicOp = state->blend_state->logicop_func;
    }
-   if (screen->info.have_EXT_rasterization_order_attachment_access &&
-       prog->nir[MESA_SHADER_FRAGMENT]->info.fs.uses_fbfetch_output)
+   if (state->rast_attachment_order)
       blend_state.flags |= VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_EXT;
 
    VkPipelineMultisampleStateCreateInfo ms_state = {0};
@@ -458,6 +457,8 @@ zink_create_gfx_pipeline_output(struct zink_screen *screen, struct zink_gfx_pipe
 
    VkPipelineColorBlendStateCreateInfo blend_state = {0};
    blend_state.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
+   if (state->rast_attachment_order)
+      blend_state.flags |= VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_EXT;
    blend_state.attachmentCount = state->rendering_info.colorAttachmentCount;
    if (state->blend_state)
       blend_state.logicOp = state->blend_state->logicop_func;
index fdbe00e..3751a86 100644 (file)
@@ -1385,6 +1385,11 @@ zink_bind_fs_state(struct pipe_context *pctx,
          }
       }
       zink_update_fs_key_samples(ctx);
+      if (zink_screen(pctx->screen)->info.have_EXT_rasterization_order_attachment_access) {
+         if (ctx->gfx_pipeline_state.rast_attachment_order != nir->info.fs.uses_fbfetch_output)
+            ctx->gfx_pipeline_state.dirty = true;
+         ctx->gfx_pipeline_state.rast_attachment_order = nir->info.fs.uses_fbfetch_output;
+      }
    }
    zink_update_fbfetch(ctx);
 }
index cee6576..4f857ce 100644 (file)
@@ -662,10 +662,11 @@ struct zink_pipeline_dynamic_state3 {
 struct zink_gfx_pipeline_state {
    /* order matches zink_gfx_output_key */
    unsigned force_persample_interp:1;
-   uint32_t rast_samples:7; //1 extra bit
+   uint32_t rast_samples:6;
    uint32_t min_samples:6;
    uint32_t feedback_loop : 1;
    uint32_t feedback_loop_zs : 1;
+   uint32_t rast_attachment_order : 1;
    uint32_t rp_state : 16;
    VkSampleMask sample_mask;
    uint32_t blend_id;
@@ -815,10 +816,11 @@ struct zink_gfx_output_key {
    union {
       struct {
          unsigned force_persample_interp:1;
-         uint32_t rast_samples:7; //1 extra bit
+         uint32_t rast_samples:6;
          uint32_t min_samples:6;
          uint32_t feedback_loop : 1;
          uint32_t feedback_loop_zs : 1;
+         uint32_t rast_attachment_order : 1;
          uint32_t rp_state : 16;
       };
       uint32_t key;