[Piglit] [PATCH 1/3] glsl-kwin-blur: fix regressions after default window size change

Brian Paul brianp at vmware.com
Sun Nov 11 06:48:23 PST 2012


These tests probe specific pixel locations so the 100x100 size can't
be changed.  Let the window be larger, but just draw to a 100x100 region.
---
 tests/shaders/glsl-kwin-blur-1.c |   29 +++++++++++++++++++----------
 tests/shaders/glsl-kwin-blur-2.c |   29 +++++++++++++++++++----------
 2 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/tests/shaders/glsl-kwin-blur-1.c b/tests/shaders/glsl-kwin-blur-1.c
index c3dff09..afd0982 100644
--- a/tests/shaders/glsl-kwin-blur-1.c
+++ b/tests/shaders/glsl-kwin-blur-1.c
@@ -40,6 +40,14 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 PIGLIT_GL_TEST_CONFIG_END
 
+
+/* Size of viewport and test region.  Note that there are pixel probes at
+ * specific locations.
+ */
+#define WIDTH 100
+#define HEIGHT 100
+
+
 /*
     Note: In KWin, the code for these shaders is generated at runtime,
           based on the blur radius. This is what the code looks like
@@ -140,8 +148,8 @@ static GLboolean test()
     int i;
 
     /* Pixel sizes in texture coordinates for the horizontal and vertical passes */
-    const float horizontal[2] = { 1.0 / piglit_width, 0 };
-    const float vertical[2]   = { 0, 1.0 / piglit_height };
+    const float horizontal[2] = { 1.0 / WIDTH, 0 };
+    const float vertical[2]   = { 0, 1.0 / HEIGHT };
 
     /* Texture and vertex coordinates */
     const float tc[] = { 0,1, 1,1, 0,0, 0,0, 1,1, 1,0 };
@@ -157,7 +165,7 @@ static GLboolean test()
     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, piglit_width, piglit_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, WIDTH, HEIGHT, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
 
     glUseProgram(prog);
     glUniform1i(uTexUnit, 0);
@@ -169,12 +177,12 @@ static GLboolean test()
     glVertexPointer(2, GL_FLOAT, 0, vc);
 
     /* Horizontal pass */
-    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, piglit_width, piglit_height);
+    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
     glUniform2fv(uPixelSize, 1, horizontal);
     glDrawArrays(GL_TRIANGLES, 0, 6);
 
     /* Vertical pass */
-    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, piglit_width, piglit_height);
+    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
     glUniform2fv(uPixelSize, 1, vertical);
     glDrawArrays(GL_TRIANGLES, 0, 6);
 
@@ -196,9 +204,9 @@ static GLboolean test()
         color[1] = color[0];
         color[2] = color[0];
         pass = piglit_probe_pixel_rgb(50, 18 + i, color) && pass;
-        pass = piglit_probe_pixel_rgb(50, piglit_height - 19 - i, color) && pass;
+        pass = piglit_probe_pixel_rgb(50, HEIGHT - 19 - i, color) && pass;
         pass = piglit_probe_pixel_rgb(18 + i, 50, color) && pass;
-        pass = piglit_probe_pixel_rgb(piglit_width - 19 - i, 50, color) && pass;
+        pass = piglit_probe_pixel_rgb(WIDTH - 19 - i, 50, color) && pass;
     }
 
     /* Test the corners */
@@ -208,9 +216,9 @@ static GLboolean test()
         color[1] = color[0];
         color[2] = color[0];
         pass = piglit_probe_pixel_rgb(20 + i, 20 + i, color) && pass;
-        pass = piglit_probe_pixel_rgb(20 + i, piglit_height - 21 - i, color) && pass;
-        pass = piglit_probe_pixel_rgb(piglit_width - 21 - i, 20 + i, color) && pass;
-        pass = piglit_probe_pixel_rgb(piglit_width - 21 - i, piglit_height - 21 - i, color) && pass;
+        pass = piglit_probe_pixel_rgb(20 + i, HEIGHT - 21 - i, color) && pass;
+        pass = piglit_probe_pixel_rgb(WIDTH - 21 - i, 20 + i, color) && pass;
+        pass = piglit_probe_pixel_rgb(WIDTH - 21 - i, HEIGHT - 21 - i, color) && pass;
     }
 
     return pass;
@@ -220,6 +228,7 @@ enum piglit_result piglit_display(void)
 {
     GLboolean pass;
 
+    glViewport(0, 0, WIDTH, HEIGHT);
     glClearColor(0.0, 0.0, 0.0, 0.0);
     glClear(GL_COLOR_BUFFER_BIT);
 
diff --git a/tests/shaders/glsl-kwin-blur-2.c b/tests/shaders/glsl-kwin-blur-2.c
index c58bb82..f692ebd 100644
--- a/tests/shaders/glsl-kwin-blur-2.c
+++ b/tests/shaders/glsl-kwin-blur-2.c
@@ -40,6 +40,14 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 PIGLIT_GL_TEST_CONFIG_END
 
+
+/* Size of viewport and test region.  Note that there are pixel probes at
+ * specific locations.
+ */
+#define WIDTH 100
+#define HEIGHT 100
+
+
 /*
     Note: In KWin, the code for these shaders is generated at runtime,
           based on the blur radius. This is what the code looks like
@@ -169,8 +177,8 @@ static GLboolean test()
     int i;
 
     /* Pixel sizes in texture coordinates for the horizontal and vertical passes */
-    const float horizontal[2] = { 1.0 / piglit_width, 0 };
-    const float vertical[2]   = { 0, 1.0 / piglit_height };
+    const float horizontal[2] = { 1.0 / WIDTH, 0 };
+    const float vertical[2]   = { 0, 1.0 / HEIGHT };
 
     /* Texture and vertex coordinates */
     const float tc[] = { 0,1, 1,1, 0,0, 0,0, 1,1, 1,0 };
@@ -186,7 +194,7 @@ static GLboolean test()
     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, piglit_width, piglit_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, WIDTH, HEIGHT, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
 
     glUseProgram(prog);
     glUniform1i(uTexUnit, 0);
@@ -198,12 +206,12 @@ static GLboolean test()
     glVertexPointer(2, GL_FLOAT, 0, vc);
 
     /* Horizontal pass */
-    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, piglit_width, piglit_height);
+    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
     glUniform2fv(uPixelSize, 1, horizontal);
     glDrawArrays(GL_TRIANGLES, 0, 6);
 
     /* Vertical pass */
-    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, piglit_width, piglit_height);
+    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
     glUniform2fv(uPixelSize, 1, vertical);
     glDrawArrays(GL_TRIANGLES, 0, 6);
 
@@ -225,9 +233,9 @@ static GLboolean test()
         color[1] = color[0];
         color[2] = color[0];
         pass = piglit_probe_pixel_rgb(50, 12 + i, color) && pass;
-        pass = piglit_probe_pixel_rgb(50, piglit_height - 13 - i, color) && pass;
+        pass = piglit_probe_pixel_rgb(50, HEIGHT - 13 - i, color) && pass;
         pass = piglit_probe_pixel_rgb(12 + i, 50, color) && pass;
-        pass = piglit_probe_pixel_rgb(piglit_width - 13 - i, 50, color) && pass;
+        pass = piglit_probe_pixel_rgb(WIDTH - 13 - i, 50, color) && pass;
     }
 
     /* Test the corners */
@@ -237,9 +245,9 @@ static GLboolean test()
         color[1] = color[0];
         color[2] = color[0];
         pass = piglit_probe_pixel_rgb(16 + i, 16 + i, color) && pass;
-        pass = piglit_probe_pixel_rgb(16 + i, piglit_height - 17 - i, color) && pass;
-        pass = piglit_probe_pixel_rgb(piglit_width - 17 - i, 16 + i, color) && pass;
-        pass = piglit_probe_pixel_rgb(piglit_width - 17 - i, piglit_height - 17 - i, color) && pass;
+        pass = piglit_probe_pixel_rgb(16 + i, HEIGHT - 17 - i, color) && pass;
+        pass = piglit_probe_pixel_rgb(WIDTH - 17 - i, 16 + i, color) && pass;
+        pass = piglit_probe_pixel_rgb(WIDTH - 17 - i, HEIGHT - 17 - i, color) && pass;
     }
 
     return pass;
@@ -249,6 +257,7 @@ enum piglit_result piglit_display(void)
 {
     GLboolean pass;
 
+    glViewport(0, 0, WIDTH, HEIGHT);
     glClearColor(0.0, 0.0, 0.0, 0.0);
     glClear(GL_COLOR_BUFFER_BIT);
 
-- 
1.7.3.4



More information about the Piglit mailing list