Mesa (main): zink: move dynamic state1 pipeline members into substruct

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 27 11:07:14 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Tue Jun 15 09:47:50 2021 -0400

zink: move dynamic state1 pipeline members into substruct

this is a bit easier to manage

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

---

 src/gallium/drivers/zink/zink_draw.cpp   |  2 +-
 src/gallium/drivers/zink/zink_pipeline.c | 20 ++++++++++----------
 src/gallium/drivers/zink/zink_pipeline.h |  8 +++++---
 src/gallium/drivers/zink/zink_program.c  |  8 ++++----
 src/gallium/drivers/zink/zink_state.c    |  8 ++++----
 5 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp
index 9a1ecb1cd26..edc0761ecf5 100644
--- a/src/gallium/drivers/zink/zink_draw.cpp
+++ b/src/gallium/drivers/zink/zink_draw.cpp
@@ -599,7 +599,7 @@ zink_draw_vbo(struct pipe_context *pctx,
 
    bool rast_state_changed = ctx->rast_state_changed;
    if (HAS_DYNAMIC_STATE && (BATCH_CHANGED || rast_state_changed))
-      screen->vk.CmdSetFrontFaceEXT(batch->state->cmdbuf, ctx->gfx_pipeline_state.front_face);
+      screen->vk.CmdSetFrontFaceEXT(batch->state->cmdbuf, ctx->gfx_pipeline_state.dyn_state1.front_face);
    if ((BATCH_CHANGED || rast_state_changed) &&
        screen->info.have_EXT_line_rasterization && rast_state->base.line_stipple_enable)
       screen->vk.CmdSetLineStippleEXT(batch->state->cmdbuf, rast_state->base.line_stipple_factor, rast_state->base.line_stipple_pattern);
diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c
index e0dd175a55f..8cb926e8230 100644
--- a/src/gallium/drivers/zink/zink_pipeline.c
+++ b/src/gallium/drivers/zink/zink_pipeline.c
@@ -137,7 +137,7 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
    rast_state.rasterizerDiscardEnable = state->rast_state->rasterizer_discard;
    rast_state.polygonMode = state->rast_state->polygon_mode;
    rast_state.cullMode = state->rast_state->cull_mode;
-   rast_state.frontFace = state->front_face;
+   rast_state.frontFace = state->dyn_state1.front_face;
 
    rast_state.depthBiasEnable = VK_TRUE;
    rast_state.depthBiasConstantFactor = 0.0;
@@ -156,15 +156,15 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
 
    VkPipelineDepthStencilStateCreateInfo depth_stencil_state = {0};
    depth_stencil_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
-   depth_stencil_state.depthTestEnable = state->depth_stencil_alpha_state->depth_test;
-   depth_stencil_state.depthCompareOp = state->depth_stencil_alpha_state->depth_compare_op;
-   depth_stencil_state.depthBoundsTestEnable = state->depth_stencil_alpha_state->depth_bounds_test;
-   depth_stencil_state.minDepthBounds = state->depth_stencil_alpha_state->min_depth_bounds;
-   depth_stencil_state.maxDepthBounds = state->depth_stencil_alpha_state->max_depth_bounds;
-   depth_stencil_state.stencilTestEnable = state->depth_stencil_alpha_state->stencil_test;
-   depth_stencil_state.front = state->depth_stencil_alpha_state->stencil_front;
-   depth_stencil_state.back = state->depth_stencil_alpha_state->stencil_back;
-   depth_stencil_state.depthWriteEnable = state->depth_stencil_alpha_state->depth_write;
+   depth_stencil_state.depthTestEnable = state->dyn_state1.depth_stencil_alpha_state->depth_test;
+   depth_stencil_state.depthCompareOp = state->dyn_state1.depth_stencil_alpha_state->depth_compare_op;
+   depth_stencil_state.depthBoundsTestEnable = state->dyn_state1.depth_stencil_alpha_state->depth_bounds_test;
+   depth_stencil_state.minDepthBounds = state->dyn_state1.depth_stencil_alpha_state->min_depth_bounds;
+   depth_stencil_state.maxDepthBounds = state->dyn_state1.depth_stencil_alpha_state->max_depth_bounds;
+   depth_stencil_state.stencilTestEnable = state->dyn_state1.depth_stencil_alpha_state->stencil_test;
+   depth_stencil_state.front = state->dyn_state1.depth_stencil_alpha_state->stencil_front;
+   depth_stencil_state.back = state->dyn_state1.depth_stencil_alpha_state->stencil_back;
+   depth_stencil_state.depthWriteEnable = state->dyn_state1.depth_stencil_alpha_state->depth_write;
 
    VkDynamicState dynamicStateEnables[30] = {
       VK_DYNAMIC_STATE_LINE_WIDTH,
diff --git a/src/gallium/drivers/zink/zink_pipeline.h b/src/gallium/drivers/zink/zink_pipeline.h
index 1f619a179f2..f616faa40d5 100644
--- a/src/gallium/drivers/zink/zink_pipeline.h
+++ b/src/gallium/drivers/zink/zink_pipeline.h
@@ -56,9 +56,11 @@ struct zink_gfx_pipeline_state {
    uint32_t hash;
    bool dirty;
 
-   struct zink_depth_stencil_alpha_hw_state *depth_stencil_alpha_state; //non-dynamic state
-   VkFrontFace front_face;
-   
+   struct {
+      struct zink_depth_stencil_alpha_hw_state *depth_stencil_alpha_state; //non-dynamic state
+      VkFrontFace front_face;
+   } dyn_state1;
+
    bool primitive_restart; //dynamic state2
 
    VkShaderModule modules[PIPE_SHADER_TYPES - 1];
diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c
index 597e325711a..7075db903a0 100644
--- a/src/gallium/drivers/zink/zink_program.c
+++ b/src/gallium/drivers/zink/zink_program.c
@@ -313,7 +313,7 @@ hash_gfx_pipeline_state(const void *key)
       hash = XXH32(&state->primitive_restart, 1, hash);
    if (state->have_EXT_extended_dynamic_state)
       return hash;
-   return XXH32(&state->depth_stencil_alpha_state, sizeof(void*), hash);
+   return XXH32(&state->dyn_state1, sizeof(state->dyn_state1), hash);
 }
 
 static bool
@@ -333,10 +333,10 @@ equals_gfx_pipeline_state(const void *a, const void *b)
          if (sa->vertex_strides[idx_a] != sb->vertex_strides[idx_b])
             return false;
       }
-      if (sa->front_face != sb->front_face)
+      if (sa->dyn_state1.front_face != sb->dyn_state1.front_face)
          return false;
-      if (!!sa->depth_stencil_alpha_state != !!sb->depth_stencil_alpha_state ||
-          memcmp(sa->depth_stencil_alpha_state, sb->depth_stencil_alpha_state, sizeof(struct zink_depth_stencil_alpha_hw_state)))
+      if (!!sa->dyn_state1.depth_stencil_alpha_state != !!sb->dyn_state1.depth_stencil_alpha_state ||
+          memcmp(sa->dyn_state1.depth_stencil_alpha_state, sb->dyn_state1.depth_stencil_alpha_state, sizeof(struct zink_depth_stencil_alpha_hw_state)))
          return false;
    }
    if (!sa->have_EXT_extended_dynamic_state2) {
diff --git a/src/gallium/drivers/zink/zink_state.c b/src/gallium/drivers/zink/zink_state.c
index c4713dbe9f0..24f9b0c0307 100644
--- a/src/gallium/drivers/zink/zink_state.c
+++ b/src/gallium/drivers/zink/zink_state.c
@@ -418,8 +418,8 @@ zink_bind_depth_stencil_alpha_state(struct pipe_context *pctx, void *cso)
 
    if (cso) {
       struct zink_gfx_pipeline_state *state = &ctx->gfx_pipeline_state;
-      if (state->depth_stencil_alpha_state != &ctx->dsa_state->hw_state) {
-         state->depth_stencil_alpha_state = &ctx->dsa_state->hw_state;
+      if (state->dyn_state1.depth_stencil_alpha_state != &ctx->dsa_state->hw_state) {
+         state->dyn_state1.depth_stencil_alpha_state = &ctx->dsa_state->hw_state;
          state->dirty |= !zink_screen(pctx->screen)->info.have_EXT_extended_dynamic_state;
          ctx->dsa_state_changed = true;
       }
@@ -569,8 +569,8 @@ zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
          ctx->vp_state_changed = true;
       }
 
-      if (ctx->gfx_pipeline_state.front_face != ctx->rast_state->front_face) {
-         ctx->gfx_pipeline_state.front_face = ctx->rast_state->front_face;
+      if (ctx->gfx_pipeline_state.dyn_state1.front_face != ctx->rast_state->front_face) {
+         ctx->gfx_pipeline_state.dyn_state1.front_face = ctx->rast_state->front_face;
          ctx->gfx_pipeline_state.dirty |= !zink_screen(pctx->screen)->info.have_EXT_extended_dynamic_state;
       }
       if (ctx->rast_state->base.point_quad_rasterization != point_quad_rasterization)



More information about the mesa-commit mailing list