xorg-x11-server/SOURCES/0001-glamor-Fix-glamor_poly...

57 lines
2.2 KiB
Diff

From 85d9f7932353b6e0986796dbb09b7f778f9cc9aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <mdaenzer@redhat.com>
Date: Fri, 24 Jul 2020 18:21:05 +0200
Subject: [PATCH xserver] glamor: Fix glamor_poly_fill_rect_gl
xRectangle::width/height handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
(Using GLSL 1.30 or newer)
The width/height members of xRectangle are unsigned, but they were
being interpreted as signed when converting to floating point for the
vertex shader, producing incorrect drawing for values > 32767.
Solve this by passing through the values as integers, and masking off
the upper 16 bits in the vertex shader (which could be 1 due to sign
extension).
Signed-off-by: Michel Dänzer <mdaenzer@redhat.com>
---
glamor/glamor_rects.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/glamor/glamor_rects.c b/glamor/glamor_rects.c
index 6cbb040c1..5cac40d49 100644
--- a/glamor/glamor_rects.c
+++ b/glamor/glamor_rects.c
@@ -27,9 +27,10 @@
static const glamor_facet glamor_facet_polyfillrect_130 = {
.name = "poly_fill_rect",
.version = 130,
- .vs_vars = "attribute vec4 primitive;\n",
- .vs_exec = (" vec2 pos = primitive.zw * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
- GLAMOR_POS(gl_Position, (primitive.xy + pos))),
+ .vs_vars = "attribute ivec4 primitive;\n",
+ .vs_exec = (" vec2 pos = vec2(primitive.zw & ivec2(0xffff));\n"
+ " pos *= vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
+ GLAMOR_POS(gl_Position, (vec2(primitive.xy) + pos))),
};
static const glamor_facet glamor_facet_polyfillrect_120 = {
@@ -81,8 +82,8 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 1);
- glVertexAttribPointer(GLAMOR_VERTEX_POS, 4, GL_SHORT, GL_FALSE,
- 4 * sizeof (short), vbo_offset);
+ glVertexAttribIPointer(GLAMOR_VERTEX_POS, 4, GL_SHORT,
+ 4 * sizeof (short), vbo_offset);
memcpy(v, prect, nrect * sizeof (xRectangle));
--
2.26.2