zink: support line stippling
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 28 Oct 2019 16:34:38 +0000 (17:34 +0100)
committerMarge Bot <eric+marge@anholt.net>
Fri, 9 Jul 2021 13:18:47 +0000 (13:18 +0000)
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@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11795>

src/gallium/drivers/zink/zink_pipeline.c
src/gallium/drivers/zink/zink_state.c
src/gallium/drivers/zink/zink_state.h

index c9a01b2..611eebb 100644 (file)
@@ -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;
    }
 
index bc9fd3e..dc1cdce 100644 (file)
@@ -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;
index f27a975..96962ef 100644 (file)
@@ -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 {