Mesa (main): zink: move pipeline tcs patch_vertices value to tcs shader key

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 11 01:41:37 UTC 2022


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Wed Feb  9 15:51:53 2022 -0500

zink: move pipeline tcs patch_vertices value to tcs shader key

making this available for shader update use

no functional changes

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14976>

---

 src/gallium/drivers/zink/zink_context.c  | 5 ++++-
 src/gallium/drivers/zink/zink_draw.cpp   | 4 ----
 src/gallium/drivers/zink/zink_pipeline.h | 1 -
 src/gallium/drivers/zink/zink_program.h  | 9 +++++++++
 4 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index e3502e8de72..0b303e4e2a8 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1816,7 +1816,10 @@ static void
 zink_set_patch_vertices(struct pipe_context *pctx, uint8_t patch_vertices)
 {
    struct zink_context *ctx = zink_context(pctx);
-   ctx->gfx_pipeline_state.patch_vertices = patch_vertices;
+   if (zink_set_tcs_key_patches(ctx, patch_vertices)) {
+      ctx->gfx_pipeline_state.vertices_per_patch = patch_vertices ? patch_vertices - 1 : 0;
+      ctx->gfx_pipeline_state.dirty = true;
+   }
 }
 
 void
diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp
index 1c3c2b37330..98e0b700fbc 100644
--- a/src/gallium/drivers/zink/zink_draw.cpp
+++ b/src/gallium/drivers/zink/zink_draw.cpp
@@ -568,9 +568,6 @@ zink_draw(struct pipe_context *pctx,
    zink_batch_rp(ctx);
 
    /* these must be after renderpass start to avoid issues with recursion */
-   uint8_t vertices_per_patch = ctx->gfx_pipeline_state.patch_vertices ? ctx->gfx_pipeline_state.patch_vertices - 1 : 0;
-   if (ctx->gfx_pipeline_state.vertices_per_patch != vertices_per_patch)
-      ctx->gfx_pipeline_state.dirty = true;
    bool drawid_broken = false;
    if (reads_drawid && (!dindirect || !dindirect->buffer))
       drawid_broken = (drawid_offset != 0 ||
@@ -578,7 +575,6 @@ zink_draw(struct pipe_context *pctx,
                       (HAS_MULTIDRAW && num_draws > 1 && !dinfo->increment_draw_id));
    if (drawid_broken != zink_get_last_vertex_key(ctx)->push_drawid)
       zink_set_last_vertex_key(ctx)->push_drawid = drawid_broken;
-   ctx->gfx_pipeline_state.vertices_per_patch = vertices_per_patch;
    if (mode_changed) {
       bool points_changed = false;
       if (mode == PIPE_PRIM_POINTS) {
diff --git a/src/gallium/drivers/zink/zink_pipeline.h b/src/gallium/drivers/zink/zink_pipeline.h
index b3acb614947..80c851c5ca8 100644
--- a/src/gallium/drivers/zink/zink_pipeline.h
+++ b/src/gallium/drivers/zink/zink_pipeline.h
@@ -83,7 +83,6 @@ struct zink_gfx_pipeline_state {
    struct zink_blend_state *blend_state;
    struct zink_render_pass *render_pass;
    VkPipeline pipeline;
-   uint8_t patch_vertices;
    unsigned idx : 8;
    enum pipe_prim_type gfx_prim_mode; //pending mode
 };
diff --git a/src/gallium/drivers/zink/zink_program.h b/src/gallium/drivers/zink/zink_program.h
index 0d7a049bd38..2d186f84ccb 100644
--- a/src/gallium/drivers/zink/zink_program.h
+++ b/src/gallium/drivers/zink/zink_program.h
@@ -303,6 +303,15 @@ zink_get_fs_key(struct zink_context *ctx)
    return (const struct zink_fs_key *)&ctx->gfx_pipeline_state.shader_keys.key[PIPE_SHADER_FRAGMENT];
 }
 
+static inline bool
+zink_set_tcs_key_patches(struct zink_context *ctx, uint8_t patch_vertices)
+{
+   struct zink_tcs_key *tcs = (struct zink_tcs_key*)&ctx->gfx_pipeline_state.shader_keys.key[PIPE_SHADER_TESS_CTRL];
+   if (tcs->patch_vertices == patch_vertices)
+      return false;
+   tcs->patch_vertices = patch_vertices;
+   return true;
+}
 
 static inline const struct zink_tcs_key *
 zink_get_tcs_key(struct zink_context *ctx)



More information about the mesa-commit mailing list