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

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