Mesa (main): llvmpipe: respect rectangular_lines

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 12 22:31:23 UTC 2021


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

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Wed Jul  7 11:50:45 2021 +0200

llvmpipe: respect rectangular_lines

With the new rectangular_lines state, we can now support rasterizing
wide lines correctly according to the vulkan spec, where this can be
specified independently of the rest of the state.

Because rectangular lines are orthogonal to multi-sampling, we now need
to also adjust with the pixel-offset in the rectangle code-path as well.

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11782>

---

 src/gallium/drivers/llvmpipe/lp_setup.c            |  4 +++-
 src/gallium/drivers/llvmpipe/lp_setup.h            |  3 ++-
 src/gallium/drivers/llvmpipe/lp_setup_context.h    |  1 +
 src/gallium/drivers/llvmpipe/lp_setup_line.c       | 20 ++++++++++----------
 src/gallium/drivers/llvmpipe/lp_state_rasterizer.c |  3 ++-
 5 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index b731dd6d032..f4d20bc313b 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -588,11 +588,13 @@ lp_setup_set_triangle_state( struct lp_setup_context *setup,
 
 void 
 lp_setup_set_line_state( struct lp_setup_context *setup,
-			 float line_width)
+                         float line_width,
+                         boolean line_rectangular)
 {
    LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
 
    setup->line_width = line_width;
+   setup->rectangular_lines = line_rectangular;
 }
 
 void 
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h
index da702378fa9..a3456c281ea 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.h
+++ b/src/gallium/drivers/llvmpipe/lp_setup.h
@@ -83,7 +83,8 @@ lp_setup_set_triangle_state( struct lp_setup_context *setup,
 
 void 
 lp_setup_set_line_state( struct lp_setup_context *setup,
-                         float line_width);
+                         float line_width,
+                         boolean line_rectangular);
 
 void 
 lp_setup_set_point_state( struct lp_setup_context *setup,
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h
index 891eadbc229..e65dbeb06cd 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h
@@ -103,6 +103,7 @@ struct lp_setup_context
    boolean legacy_points;
    boolean rasterizer_discard;
    boolean multisample;
+   boolean rectangular_lines;
    unsigned cullmode;
    unsigned bottom_edge_rule;
    float pixel_offset;
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_line.c b/src/gallium/drivers/llvmpipe/lp_setup_line.c
index 5762b277ecd..38ff15f213e 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_line.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_line.c
@@ -298,7 +298,7 @@ try_setup_line( struct lp_setup_context *setup,
    int nr_planes = 4;
    unsigned viewport_index = 0;
    unsigned layer = 0;
-   float pixel_offset = setup->pixel_offset;
+   float pixel_offset = setup->multisample ? 0.0 : setup->pixel_offset;
    /* linewidth should be interpreted as integer */
    int fixed_width = util_iround(width) * FIXED_ONE;
 
@@ -357,20 +357,20 @@ try_setup_line( struct lp_setup_context *setup,
    info.v2 = v2;
 
   
-   if (setup->multisample) {
+   if (setup->rectangular_lines) {
       float scale = (setup->line_width * 0.5f) / sqrtf(area);
       int tx = subpixel_snap(-dy * scale);
       int ty = subpixel_snap(+dx * scale);
 
-      x[0] = subpixel_snap(v1[0][0]) - tx;
-      x[1] = subpixel_snap(v2[0][0]) - tx;
-      x[2] = subpixel_snap(v2[0][0]) + tx;
-      x[3] = subpixel_snap(v1[0][0]) + tx;
+      x[0] = subpixel_snap(v1[0][0] - pixel_offset) - tx;
+      x[1] = subpixel_snap(v2[0][0] - pixel_offset) - tx;
+      x[2] = subpixel_snap(v2[0][0] - pixel_offset) + tx;
+      x[3] = subpixel_snap(v1[0][0] - pixel_offset) + tx;
 
-      y[0] = subpixel_snap(v1[0][1]) - ty;
-      y[1] = subpixel_snap(v2[0][1]) - ty;
-      y[2] = subpixel_snap(v2[0][1]) + ty;
-      y[3] = subpixel_snap(v1[0][1]) + ty;
+      y[0] = subpixel_snap(v1[0][1] - pixel_offset) - ty;
+      y[1] = subpixel_snap(v2[0][1] - pixel_offset) - ty;
+      y[2] = subpixel_snap(v2[0][1] - pixel_offset) + ty;
+      y[3] = subpixel_snap(v1[0][1] - pixel_offset) + ty;
    } else if (fabsf(dx) >= fabsf(dy)) {
       float dydx = dy / dx;
 
diff --git a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
index 712bd5db4e1..c9d0e17e27e 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
@@ -121,7 +121,8 @@ llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, void *handle)
       lp_setup_set_flatshade_first( llvmpipe->setup,
 				    state->lp_state.flatshade_first);
       lp_setup_set_line_state( llvmpipe->setup,
-                              state->lp_state.line_width);
+                              state->lp_state.line_width,
+                              state->lp_state.line_rectangular);
       lp_setup_set_point_state( llvmpipe->setup,
                                state->lp_state.point_size,
                                state->lp_state.point_size_per_vertex,



More information about the mesa-commit mailing list