Mesa (master): zink: implement VK_EXT_provoking_vertex

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 26 20:30:51 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Tue Apr 20 17:04:02 2021 -0400

zink: implement VK_EXT_provoking_vertex

this only needs to be set if the mode is LAST, otherwise the normal
pipeline state can be used and this one can be omitted

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

---

 src/gallium/drivers/zink/zink_pipeline.c | 9 +++++++++
 src/gallium/drivers/zink/zink_state.c    | 8 ++++++++
 src/gallium/drivers/zink/zink_state.h    | 1 +
 3 files changed, 18 insertions(+)

diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c
index 3535f69afcb..1a1b197b059 100644
--- a/src/gallium/drivers/zink/zink_pipeline.c
+++ b/src/gallium/drivers/zink/zink_pipeline.c
@@ -114,6 +114,15 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
    rast_state.depthBiasSlopeFactor = 0.0;
    rast_state.lineWidth = 1.0f;
 
+   VkPipelineRasterizationProvokingVertexStateCreateInfoEXT pv_state;
+   pv_state.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT;
+   pv_state.provokingVertexMode = state->rast_state->pv_mode;
+   if (screen->info.have_EXT_provoking_vertex &&
+       state->rast_state->pv_mode == VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT) {
+      pv_state.pNext = rast_state.pNext;
+      rast_state.pNext = &pv_state;
+   }
+
    VkPipelineDepthStencilStateCreateInfo depth_stencil_state = {};
    depth_stencil_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
    depth_stencil_state.depthTestEnable = state->depth_stencil_alpha_state->depth_test;
diff --git a/src/gallium/drivers/zink/zink_state.c b/src/gallium/drivers/zink/zink_state.c
index a5a6e151c67..7ef71618dd9 100644
--- a/src/gallium/drivers/zink/zink_state.c
+++ b/src/gallium/drivers/zink/zink_state.c
@@ -438,6 +438,7 @@ zink_create_rasterizer_state(struct pipe_context *pctx,
    state->hw_state.depth_clamp = rs_state->depth_clip_near == 0;
    state->hw_state.rasterizer_discard = rs_state->rasterizer_discard;
    state->hw_state.force_persample_interp = rs_state->force_persample_interp;
+   state->hw_state.pv_mode = rs_state->flatshade_first ? VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT : VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT;
 
    assert(rs_state->fill_front <= PIPE_POLYGON_MODE_POINT);
    if (rs_state->fill_back != rs_state->fill_front)
@@ -467,12 +468,19 @@ static void
 zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
 {
    struct zink_context *ctx = zink_context(pctx);
+   struct zink_screen *screen = zink_screen(pctx->screen);
    bool clip_halfz = ctx->rast_state ? ctx->rast_state->base.clip_halfz : false;
    bool point_quad_rasterization = ctx->rast_state ? ctx->rast_state->base.point_quad_rasterization : false;
    ctx->rast_state = cso;
 
    if (ctx->rast_state) {
       if (ctx->gfx_pipeline_state.rast_state != &ctx->rast_state->hw_state) {
+         if (screen->info.have_EXT_provoking_vertex &&
+             (!ctx->gfx_pipeline_state.rast_state ||
+              ctx->gfx_pipeline_state.rast_state->pv_mode != ctx->rast_state->hw_state.pv_mode) &&
+             /* without this prop, change in pv mode requires new rp */
+             !screen->info.pv_props.provokingVertexModePerPipeline)
+            zink_batch_no_rp(ctx);
          ctx->gfx_pipeline_state.rast_state = &ctx->rast_state->hw_state;
          ctx->gfx_pipeline_state.dirty = true;
       }
diff --git a/src/gallium/drivers/zink/zink_state.h b/src/gallium/drivers/zink/zink_state.h
index e49c133c843..998623d80a5 100644
--- a/src/gallium/drivers/zink/zink_state.h
+++ b/src/gallium/drivers/zink/zink_state.h
@@ -49,6 +49,7 @@ struct zink_rasterizer_hw_state {
    VkFrontFace front_face;
    VkPolygonMode polygon_mode;
    VkCullModeFlags cull_mode;
+   VkProvokingVertexModeEXT pv_mode;
    bool force_persample_interp;
 };
 



More information about the mesa-commit mailing list