Mesa (main): zink: fill in the right line-mode based on state

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


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

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Tue Apr 20 18:28:24 2021 +0200

zink: fill in the right line-mode based on state

We need to fill in the right line-mode here based on the state to get
the correct rasterization; bresenham isn't always the right one.

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 |  2 +-
 src/gallium/drivers/zink/zink_screen.c   | 18 +++++++++++++++-
 src/gallium/drivers/zink/zink_state.c    | 37 ++++++++++++++++++++++++++++++++
 src/gallium/drivers/zink/zink_state.h    |  1 +
 4 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c
index 611eebb992f..7f5763d28a5 100644
--- a/src/gallium/drivers/zink/zink_pipeline.c
+++ b/src/gallium/drivers/zink/zink_pipeline.c
@@ -149,7 +149,7 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
    if (screen->info.have_EXT_line_rasterization) {
       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.lineRasterizationMode = state->rast_state->line_mode;
 
       if (state->rast_state->line_stipple_pattern != UINT16_MAX) {
          rast_line_state.stippledLineEnable = VK_TRUE;
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index 88e0d723fb5..f0796a66fbe 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -1706,7 +1706,14 @@ check_base_requirements(struct zink_screen *screen)
        !(screen->info.feats12.scalarBlockLayout ||
          screen->info.have_EXT_scalar_block_layout) ||
        !screen->info.have_KHR_maintenance1 ||
-       !screen->info.have_EXT_custom_border_color) {
+       !screen->info.have_EXT_custom_border_color ||
+       !screen->info.have_EXT_line_rasterization ||
+       !screen->info.line_rast_feats.rectangularLines ||
+       !screen->info.line_rast_feats.bresenhamLines ||
+       !screen->info.line_rast_feats.smoothLines ||
+       !screen->info.line_rast_feats.stippledRectangularLines ||
+       !screen->info.line_rast_feats.stippledBresenhamLines ||
+       !screen->info.line_rast_feats.stippledSmoothLines) {
       fprintf(stderr, "WARNING: Some incorrect rendering "
               "might occur because the selected Vulkan device (%s) doesn't support "
               "base Zink requirements: ", screen->info.props.deviceName);
@@ -1723,6 +1730,15 @@ check_base_requirements(struct zink_screen *screen)
          printf("scalarBlockLayout OR EXT_scalar_block_layout ");
       CHECK_OR_PRINT(have_KHR_maintenance1);
       CHECK_OR_PRINT(have_EXT_custom_border_color);
+      CHECK_OR_PRINT(have_EXT_line_rasterization);
+      if (screen->info.have_EXT_line_rasterization) {
+         CHECK_OR_PRINT(line_rast_feats.rectangularLines);
+         CHECK_OR_PRINT(line_rast_feats.bresenhamLines);
+         CHECK_OR_PRINT(line_rast_feats.smoothLines);
+         CHECK_OR_PRINT(line_rast_feats.stippledRectangularLines);
+         CHECK_OR_PRINT(line_rast_feats.stippledBresenhamLines);
+         CHECK_OR_PRINT(line_rast_feats.stippledSmoothLines);
+      }
       fprintf(stderr, "\n");
    }
 }
diff --git a/src/gallium/drivers/zink/zink_state.c b/src/gallium/drivers/zink/zink_state.c
index dc1cdcef0da..ac6a591e383 100644
--- a/src/gallium/drivers/zink/zink_state.c
+++ b/src/gallium/drivers/zink/zink_state.c
@@ -459,10 +459,47 @@ zink_create_rasterizer_state(struct pipe_context *pctx,
                        VK_FRONT_FACE_COUNTER_CLOCKWISE :
                        VK_FRONT_FACE_CLOCKWISE;
 
+   VkPhysicalDeviceLineRasterizationFeaturesEXT *line_feats =
+            &screen->info.line_rast_feats;
+   state->hw_state.line_mode =
+      VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT;
+
    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;
+
+      if (screen->info.have_EXT_line_rasterization) {
+         if (rs_state->multisample) {
+            if (line_feats->stippledRectangularLines)
+               state->hw_state.line_mode =
+                  VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT;
+         } else if (rs_state->line_smooth) {
+            if (line_feats->stippledRectangularLines)
+               state->hw_state.line_mode =
+                  VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT;
+         } else if (line_feats->stippledBresenhamLines)
+            state->hw_state.line_mode =
+               VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT;
+         else {
+            /* no suitable mode that supports line stippling */
+            state->hw_state.line_stipple_factor = 0;
+            state->hw_state.line_stipple_pattern = UINT16_MAX;
+         }
+      }
    } else {
+      if (screen->info.have_EXT_line_rasterization) {
+         if (rs_state->multisample) {
+            if (line_feats->rectangularLines)
+               state->hw_state.line_mode =
+                  VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT;
+         } else if (rs_state->line_smooth) {
+            if (line_feats->rectangularLines)
+               state->hw_state.line_mode =
+                  VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT;
+         } else if (line_feats->bresenhamLines)
+            state->hw_state.line_mode =
+               VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT;
+      }
       state->hw_state.line_stipple_factor = 0;
       state->hw_state.line_stipple_pattern = UINT16_MAX;
    }
diff --git a/src/gallium/drivers/zink/zink_state.h b/src/gallium/drivers/zink/zink_state.h
index 96962ef6222..c333afcd9ad 100644
--- a/src/gallium/drivers/zink/zink_state.h
+++ b/src/gallium/drivers/zink/zink_state.h
@@ -50,6 +50,7 @@ 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;



More information about the mesa-commit mailing list