[Piglit] Add a test of varying handling

Stuart Abercrombie sabercrombie at chromium.org
Fri Sep 16 15:07:10 PDT 2011


I'm hoping this is the right way to submit a patch.

Add test glsl-vs-varying-writes.

This test fails on Sandy Bridge but not i915 or Nvidia Quadro FX 380.

The vec2 set up as (1.0, 0.0) in the vertex shader ends up as (0.0, 0.0) in
the fragment shader.  (The problem was originally found with texture
coordinates.)

The issue apparently relates to declarations of varyings in the vertex
shader and fragment shader. If the (unneeded) var1 varying declaration isn't
present in the fragment shader, the test passes.

diff --git a/tests/all.tests b/tests/all.tests
index 03dcd59..ed78c88 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -413,6 +413,7 @@ add_plain_test(shaders, 'glsl-vs-arrays')
 add_plain_test(shaders, 'glsl-vs-normalscale')
 add_plain_test(shaders, 'glsl-vs-functions')
 add_plain_test(shaders, 'glsl-vs-user-varying-ff')
+add_plain_test(shaders, 'glsl-vs-varying-writes')
 add_plain_test(shaders, 'glsl-vs-texturematrix-1')
 add_plain_test(shaders, 'glsl-vs-texturematrix-2')
 add_plain_test(shaders, 'glsl-sin')
diff --git a/tests/shaders/CMakeLists.gl.txt
b/tests/shaders/CMakeLists.gl.txt
index d0e3005..2a5309b 100644
--- a/tests/shaders/CMakeLists.gl.txt
+++ b/tests/shaders/CMakeLists.gl.txt
@@ -110,6 +110,7 @@ ENDIF (NOT MSVC)
 add_executable (glsl-vs-sqrt-zero glsl-vs-sqrt-zero.c)
 add_executable (glsl-vs-statechange-1 glsl-vs-statechange-1.c)
 add_executable (glsl-vs-user-varying-ff glsl-vs-user-varying-ff.c)
+add_executable (glsl-vs-varying-writes glsl-vs-varying-writes.c)
 add_executable (glsl-light-model glsl-light-model.c)
 add_executable (glsl-link-bug30552 glsl-link-bug30552.c)
 add_executable (glsl-link-bug38015 glsl-link-bug38015.c)
diff --git a/tests/shaders/glsl-vs-varying-writes.c
b/tests/shaders/glsl-vs-varying-writes.c
new file mode 100644
index 0000000..a3b0dc1
--- /dev/null
+++ b/tests/shaders/glsl-vs-varying-writes.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright © 2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
"Software"),
+ * to deal in the Software without restriction, including without
limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
next
+ * paragraph) shall be included in all copies or substantial portions of
the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file glsl-vs-varying-writes
+ * Test varying writes broken on Sandy Bridge / Gallium.
+ *
+ * \author Stuart Abercrombie <sabercrombie at chromium.org>
+ */
+#include "piglit-util.h"
+
+int piglit_width = 30, piglit_height = 30;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+static const char vs_text[] =
+    "varying vec2 var1;\n"
+ "varying vec2 var2;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+    "  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;"
+ "  var1.x = 1.0;\n"
+ "  var1.y = 0.0;\n"
+ "  var2 = var1;\n"
+ "}\n"
+ ;
+
+static const char fs_text[] =
+ "varying vec2 var1;\n"
+ "varying vec2 var2;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ "  gl_FragColor = vec4(var2, 0.0, 1.0);\n"
+ "}\n"
+ ;
+
+GLuint prog;
+
+static const float blue[] = { 0.0, 0.0, 1.0, 1.0 };
+
+enum piglit_result
+piglit_display(void)
+{
+ static const float red[3] = { 1.0, 0.0, 0.0 };
+ enum piglit_result result = PIGLIT_PASS;
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ piglit_draw_rect(0.0f, 0.0f, 30.0f, 30.0f);
+
+ if (!piglit_probe_pixel_rgb(15, 15, red))
+ result = PIGLIT_FAIL;
+
+ if (!piglit_automatic)
+ glutSwapBuffers();
+
+ return result;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLuint vs;
+ GLuint fs;
+
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
+ fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_text);
+ prog = piglit_link_simple_program(vs, fs);
+
+ if (!piglit_link_check_status(prog))
+        piglit_report_result(PIGLIT_FAIL);
+
+ piglit_UseProgram(prog);
+
+ glClearColor(blue[0], blue[1], blue[2], blue[3]);
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20110916/e22e979f/attachment.htm>


More information about the Piglit mailing list