Mesa (main): zink: add update flag for rasterizer state change

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 16 12:20:26 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu May  6 15:58:37 2021 -0400

zink: add update flag for rasterizer state change

this can be used to avoid updating related dynamic states too frequently

Reviewed-by: Hoe Hao Cheng <haochengho12907 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11396>

---

 src/gallium/drivers/zink/zink_context.c |  1 +
 src/gallium/drivers/zink/zink_context.h |  1 +
 src/gallium/drivers/zink/zink_draw.c    | 11 +++++++----
 src/gallium/drivers/zink/zink_state.c   |  1 +
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index f6c1d95ca63..aac8d7a4cad 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1801,6 +1801,7 @@ flush_batch(struct zink_context *ctx, bool sync)
       ctx->vertex_buffers_dirty = true;
       ctx->vp_state_changed = true;
       ctx->scissor_changed = true;
+      ctx->rast_state_changed = true;
    }
 }
 
diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h
index 43e41adf3f4..cc2296e0e73 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -166,6 +166,7 @@ struct zink_context {
    struct zink_vertex_elements_state *element_state;
    struct zink_rasterizer_state *rast_state;
    struct zink_depth_stencil_alpha_state *dsa_state;
+   bool rast_state_changed : 1;
 
    struct hash_table desc_set_layouts[ZINK_DESCRIPTOR_TYPES];
    bool pipeline_changed[2]; //gfx, compute
diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c
index 81f7f142379..614b112748e 100644
--- a/src/gallium/drivers/zink/zink_draw.c
+++ b/src/gallium/drivers/zink/zink_draw.c
@@ -639,10 +639,13 @@ zink_draw_vbo(struct pipe_context *pctx,
       ctx->sample_locations_changed = false;
    }
 
-   if (depth_bias)
-      vkCmdSetDepthBias(batch->state->cmdbuf, rast_state->offset_units, rast_state->offset_clamp, rast_state->offset_scale);
-   else
-      vkCmdSetDepthBias(batch->state->cmdbuf, 0.0f, 0.0f, 0.0f);
+   if (pipeline_changed || ctx->rast_state_changed) {
+      if (depth_bias)
+         vkCmdSetDepthBias(batch->state->cmdbuf, rast_state->offset_units, rast_state->offset_clamp, rast_state->offset_scale);
+      else
+         vkCmdSetDepthBias(batch->state->cmdbuf, 0.0f, 0.0f, 0.0f);
+      ctx->rast_state_changed = false;
+   }
 
    if (ctx->gfx_pipeline_state.blend_state->need_blend_constants)
       vkCmdSetBlendConstants(batch->state->cmdbuf, ctx->blend_constants);
diff --git a/src/gallium/drivers/zink/zink_state.c b/src/gallium/drivers/zink/zink_state.c
index 246669b2725..48e9a736548 100644
--- a/src/gallium/drivers/zink/zink_state.c
+++ b/src/gallium/drivers/zink/zink_state.c
@@ -492,6 +492,7 @@ zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
             zink_batch_no_rp(ctx);
          ctx->gfx_pipeline_state.rast_state = &ctx->rast_state->hw_state;
          ctx->gfx_pipeline_state.dirty = true;
+         ctx->rast_state_changed = true;
       }
 
       if (clip_halfz != ctx->rast_state->base.clip_halfz) {



More information about the mesa-commit mailing list