summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2021-08-11 16:53:11 +0200
committerMarge Bot <eric+marge@anholt.net>2021-08-19 09:44:16 +0000
commitd37aa08f61169f498ec5dd01f740d7bd3ff421bf (patch)
tree79aafa0fd5c3c21ecf523cd488cbe95811a9c079
parenta3d400a01640dce3325d10b529349cdbc59d38f4 (diff)
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@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12327>
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_stipple.c10
-rw-r--r--src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt1
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