From: Erik Faye-Lund Date: Wed, 11 Aug 2021 14:53:11 +0000 (+0200) Subject: draw: fix stippling of fractional lines X-Git-Tag: upstream/22.3.5~19035 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d37aa08f61169f498ec5dd01f740d7bd3ff421bf;p=platform%2Fupstream%2Fmesa.git 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 Part-of: --- diff --git a/src/gallium/auxiliary/draw/draw_pipe_stipple.c b/src/gallium/auxiliary/draw/draw_pipe_stipple.c index eff9bcf..dd1fc8d 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 ba9c578..838d4e8 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