Mesa (main): zink: support line stippling

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 9 13:36:43 UTC 2021


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

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Mon Oct 28 17:34:38 2019 +0100

zink: support line stippling

VK_EXT_line_rasterization allows us to specify a line-stilling pattern.
So let's do that.

While we're at it, use more bit-allocation here.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11795>

---

 src/gallium/drivers/zink/zink_pipeline.c | 13 ++++++++++---
 src/gallium/drivers/zink/zink_state.c    |  8 ++++++++
 src/gallium/drivers/zink/zink_state.h    |  2 ++
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c
index c9a01b215fa..611eebb992f 100644
--- a/src/gallium/drivers/zink/zink_pipeline.c
+++ b/src/gallium/drivers/zink/zink_pipeline.c
@@ -150,9 +150,16 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
       rast_line_state.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT;
       rast_line_state.pNext = rast_state.pNext;
       rast_line_state.lineRasterizationMode = VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT;
-      rast_line_state.stippledLineEnable = VK_FALSE;
-      rast_line_state.lineStippleFactor = 0;
-      rast_line_state.lineStipplePattern = 0;
+
+      if (state->rast_state->line_stipple_pattern != UINT16_MAX) {
+         rast_line_state.stippledLineEnable = VK_TRUE;
+         rast_line_state.lineStippleFactor = state->rast_state->line_stipple_factor + 1;
+         rast_line_state.lineStipplePattern = state->rast_state->line_stipple_pattern;
+      } else {
+         rast_line_state.stippledLineEnable = VK_FALSE;
+         rast_line_state.lineStippleFactor = 0;
+         rast_line_state.lineStipplePattern = 0;
+      }
       rast_state.pNext = &rast_line_state;
    }
 
diff --git a/src/gallium/drivers/zink/zink_state.c b/src/gallium/drivers/zink/zink_state.c
index bc9fd3e8e09..dc1cdcef0da 100644
--- a/src/gallium/drivers/zink/zink_state.c
+++ b/src/gallium/drivers/zink/zink_state.c
@@ -459,6 +459,14 @@ zink_create_rasterizer_state(struct pipe_context *pctx,
                        VK_FRONT_FACE_COUNTER_CLOCKWISE :
                        VK_FRONT_FACE_CLOCKWISE;
 
+   if (rs_state->line_stipple_enable) {
+      state->hw_state.line_stipple_factor = rs_state->line_stipple_factor;
+      state->hw_state.line_stipple_pattern = rs_state->line_stipple_pattern;
+   } else {
+      state->hw_state.line_stipple_factor = 0;
+      state->hw_state.line_stipple_pattern = UINT16_MAX;
+   }
+
    state->offset_point = rs_state->offset_point;
    state->offset_line = rs_state->offset_line;
    state->offset_tri = rs_state->offset_tri;
diff --git a/src/gallium/drivers/zink/zink_state.h b/src/gallium/drivers/zink/zink_state.h
index f27a975c445..96962ef6222 100644
--- a/src/gallium/drivers/zink/zink_state.h
+++ b/src/gallium/drivers/zink/zink_state.h
@@ -53,6 +53,8 @@ struct zink_rasterizer_hw_state {
    unsigned depth_clamp : 1;
    unsigned rasterizer_discard : 1;
    unsigned force_persample_interp : 1;
+   unsigned line_stipple_factor : 8;
+   unsigned line_stipple_pattern : 16;
 };
 
 struct zink_rasterizer_state {



More information about the mesa-commit mailing list