Mesa (main): zink: repack zink_rasterizer_hw_state

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


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Tue Jun 15 10:23:38 2021 -0400

zink: repack zink_rasterizer_hw_state

this is now 11 bits

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 |  7 ++++---
 src/gallium/drivers/zink/zink_state.c    |  8 ++++----
 src/gallium/drivers/zink/zink_state.h    | 16 ++++++++--------
 4 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp
index edc0761ecf5..7ee6a595005 100644
--- a/src/gallium/drivers/zink/zink_draw.cpp
+++ b/src/gallium/drivers/zink/zink_draw.cpp
@@ -213,7 +213,7 @@ update_gfx_program(struct zink_context *ctx)
 
 static bool
 line_width_needed(enum pipe_prim_type reduced_prim,
-                  VkPolygonMode polygon_mode)
+                  unsigned polygon_mode)
 {
    switch (reduced_prim) {
    case PIPE_PRIM_POINTS:
diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c
index b25674648e9..9794d1cad4e 100644
--- a/src/gallium/drivers/zink/zink_pipeline.c
+++ b/src/gallium/drivers/zink/zink_pipeline.c
@@ -147,9 +147,10 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
 
    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.provokingVertexMode = state->rast_state->pv_last ?
+                                  VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT :
+                                  VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT;
+   if (screen->info.have_EXT_provoking_vertex && state->rast_state->pv_last) {
       pv_state.pNext = rast_state.pNext;
       rast_state.pNext = &pv_state;
    }
diff --git a/src/gallium/drivers/zink/zink_state.c b/src/gallium/drivers/zink/zink_state.c
index 24f9b0c0307..f7f469b02ae 100644
--- a/src/gallium/drivers/zink/zink_state.c
+++ b/src/gallium/drivers/zink/zink_state.c
@@ -473,13 +473,13 @@ 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;
+   state->hw_state.pv_last = !rs_state->flatshade_first;
 
    assert(rs_state->fill_front <= PIPE_POLYGON_MODE_POINT);
    if (rs_state->fill_back != rs_state->fill_front)
       debug_printf("BUG: vulkan doesn't support different front and back fill modes\n");
-   state->hw_state.polygon_mode = (VkPolygonMode)rs_state->fill_front; // same values
-   state->hw_state.cull_mode = (VkCullModeFlags)rs_state->cull_face; // same bits
+   state->hw_state.polygon_mode = rs_state->fill_front; // same values
+   state->hw_state.cull_mode = rs_state->cull_face; // same bits
 
    state->front_face = rs_state->front_ccw ?
                        VK_FRONT_FACE_COUNTER_CLOCKWISE :
@@ -555,7 +555,7 @@ zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
       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) &&
+              ctx->gfx_pipeline_state.rast_state->pv_last != ctx->rast_state->hw_state.pv_last) &&
              /* without this prop, change in pv mode requires new rp */
              !screen->info.pv_props.provokingVertexModePerPipeline)
             zink_batch_no_rp(ctx);
diff --git a/src/gallium/drivers/zink/zink_state.h b/src/gallium/drivers/zink/zink_state.h
index 599514ad3fa..34885d01137 100644
--- a/src/gallium/drivers/zink/zink_state.h
+++ b/src/gallium/drivers/zink/zink_state.h
@@ -55,14 +55,14 @@ struct zink_vertex_elements_state {
 };
 
 struct zink_rasterizer_hw_state {
-   VkPolygonMode polygon_mode;
-   VkCullModeFlags cull_mode;
-   VkProvokingVertexModeEXT pv_mode;
-   VkLineRasterizationModeEXT line_mode;
-   unsigned depth_clamp : 1;
-   unsigned rasterizer_discard : 1;
-   unsigned force_persample_interp : 1;
-   bool line_stipple_enable;
+   unsigned polygon_mode : 2; //VkPolygonMode
+   unsigned cull_mode : 2; //VkCullModeFlags
+   unsigned line_mode : 2; //VkLineRasterizationModeEXT
+   bool depth_clamp:1;
+   bool rasterizer_discard:1;
+   bool pv_last:1;
+   bool line_stipple_enable:1;
+   bool force_persample_interp:1;
 };
 
 struct zink_rasterizer_state {



More information about the mesa-commit mailing list