summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/all.tests4
-rw-r--r--tests/bugs/fdo28551.c2
-rw-r--r--tests/general/CMakeLists.txt1
-rw-r--r--tests/general/line-aa-width.c199
-rw-r--r--tests/glslparsertest/glsl2/uniform-01.vert3
-rw-r--r--tests/glslparsertest/glsl2/uniform-02.vert2
-rw-r--r--tests/texturing/CMakeLists.txt5
-rw-r--r--tests/texturing/tex-border-1.c101
8 files changed, 316 insertions, 1 deletions
diff --git a/tests/all.tests b/tests/all.tests
index b22e6e7e0..4ba6576f7 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -109,6 +109,7 @@ add_plain_test(general, 'draw-elements-base-vertex')
add_plain_test(general, 'draw-elements-vs-inputs')
add_plain_test(general, 'draw-vertices')
add_plain_test(general, 'draw-vertices-half-float')
+add_plain_test(general, 'line-aa-width')
add_plain_test(general, 'linestipple')
add_plain_test(general, 'object_purgeable-api-pbo')
add_plain_test(general, 'object_purgeable-api-texture')
@@ -364,6 +365,7 @@ add_plain_test(texturing, 'rg-draw-pixels')
add_plain_test(texturing, 's3tc-teximage')
add_plain_test(texturing, 's3tc-texsubimage')
add_plain_test(texturing, 'streaming-texture-leak')
+add_plain_test(texturing, 'tex-border-1')
add_plain_test(texturing, 'tex-swizzle')
add_plain_test(texturing, 'tex3d')
add_plain_test(texturing, 'texdepth')
@@ -674,6 +676,8 @@ add_otherglslparsertest('glsl2/swiz-01.vert', 'pass')
add_otherglslparsertest('glsl2/swiz-02.vert', 'fail')
add_otherglslparsertest('glsl2/tex_rect-01.frag', 'pass')
add_otherglslparsertest('glsl2/tex_rect-02.frag', 'fail')
+add_otherglslparsertest('glsl2/uniform-01.vert', 'pass')
+add_otherglslparsertest('glsl2/uniform-02.vert', 'fail')
add_otherglslparsertest('glsl2/void-01.vert', 'fail')
# All the GST shaders should pass.
diff --git a/tests/bugs/fdo28551.c b/tests/bugs/fdo28551.c
index 26b044391..1257933ca 100644
--- a/tests/bugs/fdo28551.c
+++ b/tests/bugs/fdo28551.c
@@ -50,6 +50,8 @@ piglit_display(void)
void piglit_init(int argc, char **argv)
{
+ piglit_require_extension("GL_ARB_framebuffer_object");
+
piglit_ortho_projection(1.0, 1.0, GL_FALSE);
piglit_automatic = GL_TRUE;
diff --git a/tests/general/CMakeLists.txt b/tests/general/CMakeLists.txt
index 8484d3340..3718367cf 100644
--- a/tests/general/CMakeLists.txt
+++ b/tests/general/CMakeLists.txt
@@ -37,6 +37,7 @@ add_executable (draw-elements-vs-inputs draw-elements-vs-inputs.c)
add_executable (draw-vertices draw-vertices.c)
add_executable (draw-vertices-half-float draw-vertices-half-float.c)
add_executable (linestipple linestipple.c)
+add_executable (line-aa-width line-aa-width.c)
add_executable (pbo-drawpixels pbo-drawpixels.c)
add_executable (pbo-read-argb8888 pbo-read-argb8888.c)
add_executable (pbo-readpixels-small pbo-readpixels-small.c)
diff --git a/tests/general/line-aa-width.c b/tests/general/line-aa-width.c
new file mode 100644
index 000000000..d8312ed30
--- /dev/null
+++ b/tests/general/line-aa-width.c
@@ -0,0 +1,199 @@
+/*
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+/**
+ * @file line-aa-width.c
+ *
+ * Tests that width 1.0 AA lines are of the appropriate thickness.
+ *
+ * The 965 driver was rendering them so that when the line was
+ * centered on a pixel it was fullly lit and when it was off the pixel
+ * center neither of the neighbors would be lit at all. It's quite
+ * ugly.
+ */
+
+#ifdef _MSC_VER
+#define _USE_MATH_DEFINES
+#endif
+#include "piglit-util.h"
+
+int piglit_width = 300, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+static float
+y_from_x(float x)
+{
+ return 2.0 + (piglit_height - 4.0) *
+ (1.0 - cos(x / piglit_width * M_PI / 2));
+}
+
+/* Check that the color is approximately gray. There was a report that
+ * Gen3 Intel is failing at this.
+ */
+static GLboolean
+check_color(float *color)
+{
+ float max = 0.0;
+ static GLboolean reported = GL_FALSE;
+
+ if (fabs(color[1] - color[0]) > max)
+ max = fabs(color[1] - color[0]) > 0.01;
+ if (fabs(color[2] - color[0]) > max)
+ max = fabs(color[2] - color[0]) > 0.01;
+
+ if (max > 0.02) {
+ if (!reported) {
+ printf("Found color %f, %f, %f, expected %f, %f, %f\n",
+ color[0], color[1], color[2],
+ color[0], color[0], color[0]);
+ reported = GL_TRUE;
+ }
+
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ int x1;
+ int seg_width = 30;
+ float *screen;
+ GLboolean pass = GL_TRUE;
+
+ /* The coverage checking assumes that we'll be sampling along
+ * the major axis, so a tall window will break that.
+ */
+ if (piglit_width / piglit_height < 3)
+ return PIGLIT_SKIP;
+
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+ glClearColor(0.0, 0.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glColor4f(1.0, 1.0, 1.0, 1.0);
+ glEnable(GL_LINE_SMOOTH);
+ /* GL AA lines produce an alpha value */
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ZERO);
+
+ /* Draw a bunch of line segments with varying slopes across
+ * the window. They're separated by a bit of space so that we
+ * can see which regions we're going to sample in while
+ * avoiding any need to worry about end caps. */
+ for (x1 = 0; x1 < piglit_width; x1 += seg_width) {
+ int x2 = x1 + seg_width - 2;
+ float y1, y2;
+
+ if (x2 > piglit_width)
+ x2 = piglit_width;
+
+ y1 = y_from_x(x1);
+ y2 = y_from_x(x2);
+
+ glBegin(GL_LINES);
+ glVertex2f(x1, y1);
+ glVertex2f(x2, y2);
+ glEnd();
+ }
+
+ screen = malloc(piglit_width * piglit_height * 4 * sizeof(float));
+ glReadPixels(0, 0, piglit_width, piglit_height,
+ GL_RGBA, GL_FLOAT, screen);
+
+ /* Now, sample the middles of the segments and compare the total
+ * coverage in each column
+ */
+ for (x1 = 2; x1 < piglit_width; x1 += seg_width) {
+ int x2 = x1 + seg_width - 4;
+ int sample_x;
+ float y1, y2;
+ float avg = 0.0;
+ float min = 100.0;
+ float max = -100.0;
+
+ if (x2 > piglit_width - 4)
+ x2 = piglit_width - 4;
+
+ /* If we don't have a couple of pixels to sample because we've
+ * hit the edge of the window, we're done.
+ */
+ if (x2 - x1 < 2)
+ break;
+
+ y1 = y_from_x(x1) - 2;
+ y2 = y_from_x(x2) + 2;
+
+ avg = 0;
+ for (sample_x = x1; sample_x < x2; sample_x++) {
+ int y;
+ float col_total = 0.0;
+
+ for (y = y1; y < y2; y++) {
+ if (y < 0 || y >= piglit_height)
+ continue;
+
+ pass = pass &&
+ check_color(&screen[(y * piglit_width +
+ sample_x) * 4]);
+
+ col_total += screen[(y * piglit_width +
+ sample_x) * 4];
+ }
+ if (col_total > max)
+ max = col_total;
+ if (col_total < min)
+ min = col_total;
+ avg += col_total / (x2 - x1);
+ }
+
+ if (min < 0.25 ||
+ avg / min > 2.0 ||
+ max / avg > 2.0 ||
+ max > 1.5) {
+ printf("Line from %d,%d-%d,%d had bad thickness:\n",
+ x1 - 2, (int)y_from_x(x1 - 2),
+ x2 + 2, (int)y_from_x(x2 + 2));
+ printf("min coverage: %f\n", min);
+ printf("avg coverage: %f\n", avg);
+ printf("max coverage: %f\n", max);
+ pass = GL_FALSE;
+ }
+ }
+
+ glutSwapBuffers();
+
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+}
diff --git a/tests/glslparsertest/glsl2/uniform-01.vert b/tests/glslparsertest/glsl2/uniform-01.vert
new file mode 100644
index 000000000..2b0499c38
--- /dev/null
+++ b/tests/glslparsertest/glsl2/uniform-01.vert
@@ -0,0 +1,3 @@
+/* PASS */
+#version 120
+uniform vec2 a = vec2(1.0, 2.0);
diff --git a/tests/glslparsertest/glsl2/uniform-02.vert b/tests/glslparsertest/glsl2/uniform-02.vert
new file mode 100644
index 000000000..2c2edd551
--- /dev/null
+++ b/tests/glslparsertest/glsl2/uniform-02.vert
@@ -0,0 +1,2 @@
+/* FAIL - uniform initializers not allowed in GLSL 1.10 */
+uniform vec2 a = vec2(1.0, 2.0);
diff --git a/tests/texturing/CMakeLists.txt b/tests/texturing/CMakeLists.txt
index 4aafc0bda..731e4727a 100644
--- a/tests/texturing/CMakeLists.txt
+++ b/tests/texturing/CMakeLists.txt
@@ -21,7 +21,9 @@ link_libraries (
add_executable (array-texture array-texture.c)
add_executable (copytexsubimage copytexsubimage.c)
-add_executable (crossbar crossbar.c)
+IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+ add_executable (crossbar crossbar.c)
+ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_executable (cubemap cubemap.c)
add_executable (depth-level-clamp depth-level-clamp.c)
add_executable (gen-compressed-teximage gen-compressed-teximage.c)
@@ -48,6 +50,7 @@ add_executable (depth-tex-modes depth-tex-modes.c depth-tex-modes-common.c)
add_executable (depth-tex-modes-rg depth-tex-modes-rg.c depth-tex-modes-common.c)
add_executable (depth-tex-modes-glsl depth-tex-modes-glsl.c)
add_executable (depth-tex-compare depth-tex-compare.c)
+add_executable (tex-border-1 tex-border-1.c)
add_executable (tex-swizzle tex-swizzle.c)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
diff --git a/tests/texturing/tex-border-1.c b/tests/texturing/tex-border-1.c
new file mode 100644
index 000000000..9c2d3dc7d
--- /dev/null
+++ b/tests/texturing/tex-border-1.c
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+/** @file tex-border-1.c
+ *
+ * Tests that the texture border color on a GL_RGBA texture is sampled
+ * correctly.
+ *
+ * This is intended to be the first test in a series. Other tests
+ * that could be used are behavior of sampling texture border color
+ * for GL_RGB textures, and sampling the border color depending on the
+ * texture format (gen5 Intel hardware and up stores format-dependent
+ * border colors.).
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 50;
+int piglit_height = 50;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+enum piglit_result
+piglit_display(void)
+{
+ float black[4] = {0.0, 0.0, 0.0, 0.0};
+ float white[4] = {1.0, 1.0, 1.0, 0.0};
+ float red[4] = {1.0, 0.0, 0.0, 0.0};
+ float green[4] = {0.0, 1.0, 0.0, 0.0};
+ float blue[4] = {0.0, 0.0, 1.0, 0.0};
+ GLboolean pass = GL_TRUE;
+ GLuint tex;
+
+ tex = piglit_checkerboard_texture(0, /* name */
+ 0, /* level */
+ 2, 2, /* width/height */
+ 1, 1, /* checkerboard size */
+ black, white);
+
+ glEnable(GL_TEXTURE_2D);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+
+ glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, red);
+ piglit_draw_rect_tex(-1, -1, 1, 1,
+ -2, -2, 0, 0);
+
+ glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, green);
+ piglit_draw_rect_tex( 0, -1, 1, 1,
+ -2, -2, 0, 0);
+
+ glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, blue);
+ piglit_draw_rect_tex(-1, 0, 1, 1,
+ -2, -2, 0, 0);
+
+ glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, white);
+ piglit_draw_rect_tex( 0, 0, 1, 1,
+ -2, -2, 0, 0);
+
+ pass = piglit_probe_pixel_rgb(piglit_width * 1 / 4,
+ piglit_height * 1 / 4, red) && pass;
+ pass = piglit_probe_pixel_rgb(piglit_width * 3 / 4,
+ piglit_height * 1 / 4, green) && pass;
+ pass = piglit_probe_pixel_rgb(piglit_width * 1 / 4,
+ piglit_height * 3 / 4, blue) && pass;
+ pass = piglit_probe_pixel_rgb(piglit_width * 3 / 4,
+ piglit_height * 3 / 4, white) && pass;
+
+ glDeleteTextures(1, &tex);
+
+ glutSwapBuffers();
+
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+}