Mesa (main): draw: fix stippling of fractional lines

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Aug 19 13:33:25 UTC 2021


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

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Wed Aug 11 16:53:11 2021 +0200

draw: fix stippling of fractional lines

The OpenGL 4.6 specification, section 14.5.2.1 (Line Stipple) says:

> The masking is achieved using three parameters: the 16-bit line
> stipple p, the line repeat count r, and an integer stipple counter s.

This is pretty clear that the stipple counter shouldn't carry fractional
parts. But we also don't really do anything useful with the fractional
part anyway, apart from skewing the third or later line-segments

Properly carrying over the fractional parts as the Vulkan specification
allows for rectangular lines is trickier than this and would require us
to use a shorter output-line at the start of the following
line-segments.

But let's just do what the OpenGL specification describes, and the
Vulkan specification allows for now.

This, combined with the following patch for the vulkan CTS makes the
last two rasterization-tests pass for me:

https://github.com/KhronosGroup/VK-GL-CTS/pull/279

Fixes the "spec/!opengl 1.1/linestipple/line strip" piglit-test.

Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12327>

---

 src/gallium/auxiliary/draw/draw_pipe_stipple.c        | 10 +++++-----
 src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt |  1 -
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pipe_stipple.c b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
index eff9bcf2548..dd1fc8dd701 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_stipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
@@ -47,7 +47,7 @@
 /** Subclass of draw_stage */
 struct stipple_stage {
    struct draw_stage stage;
-   float counter;
+   unsigned counter;
    ushort pattern;
    ushort factor;
    bool rectangular;
@@ -110,9 +110,9 @@ emit_segment(struct draw_stage *stage, struct prim_header *header,
 
 
 static inline bool
-stipple_test(int counter, ushort pattern, ushort factor)
+stipple_test(unsigned counter, ushort pattern, ushort factor)
 {
-   int b = (counter / factor) & 0xf;
+   unsigned b = (counter / factor) & 0xf;
    return !!((1 << b) & pattern);
 }
 
@@ -159,7 +159,7 @@ stipple_line(struct draw_stage *stage, struct prim_header *header)
    /* XXX ToDo: instead of iterating pixel-by-pixel, use a look-up table.
     */
    for (i = 0; i < intlength; i++) {
-      bool result = stipple_test((int)stipple->counter + i,
+      bool result = stipple_test(stipple->counter + i,
                                  stipple->pattern, stipple->factor);
       if (result != state) {
          /* changing from "off" to "on" or vice versa */
@@ -178,7 +178,7 @@ stipple_line(struct draw_stage *stage, struct prim_header *header)
    if (state && start < length)
       emit_segment(stage, header, start / length, 1.0);
 
-   stipple->counter += length;
+   stipple->counter += intlength;
 }
 
 
diff --git a/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt b/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt
index ba9c5785206..838d4e88f19 100644
--- a/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt
+++ b/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt
@@ -131,7 +131,6 @@ spec/!opengl 1.1/draw-pixels samples=32: skip
 spec/!opengl 1.1/draw-pixels samples=4: skip
 spec/!opengl 1.1/draw-pixels samples=6: skip
 spec/!opengl 1.1/draw-pixels samples=8: skip
-spec/!opengl 1.1/linestipple/line strip: fail
 spec/!opengl 1.1/polygon-mode-facing: fail
 spec/!opengl 1.1/polygon-mode-offset/config 3: expected white pixel on bottom edge: fail
 spec/!opengl 1.1/polygon-mode-offset/config 3: expected white pixel on left edge: fail



More information about the mesa-commit mailing list