Blame SOURCES/0001-glamor-Fix-glamor_poly_fill_rect_gl-xRectangle-width.patch

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