summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2018-03-07 20:36:20 -0800
committerIan Romanick <ian.d.romanick@intel.com>2018-06-26 17:13:44 -0700
commit2f74fd3f9b1ba39749496aba036dd4455de43a4a (patch)
tree66d288b4ca0ec4818d5e57a8964f439abeca4250
parent4fded61f979eb5d7300a3e13b16853fc39472c38 (diff)
WIP: gl 1.1 testsold-driver-work
-rw-r--r--tests/spec/gl-1.1/CMakeLists.gl.txt2
-rw-r--r--tests/spec/gl-1.1/drawpixels-fog.c108
-rw-r--r--tests/spec/gl-1.1/drawpixels-texturing.c123
3 files changed, 233 insertions, 0 deletions
diff --git a/tests/spec/gl-1.1/CMakeLists.gl.txt b/tests/spec/gl-1.1/CMakeLists.gl.txt
index a08f6d4ad..d8d059e24 100644
--- a/tests/spec/gl-1.1/CMakeLists.gl.txt
+++ b/tests/spec/gl-1.1/CMakeLists.gl.txt
@@ -12,6 +12,8 @@ piglit_add_executable (gl-1.1-color-material-array color-material-array.c)
piglit_add_executable (gl-1.1-copypixels-fog copypixels-fog.c)
piglit_add_executable (gl-1.1-copypixels-texturing copypixels-texturing.c)
piglit_add_executable (gl-1.1-draw-arrays-start draw-arrays-start.c)
+piglit_add_executable (gl-1.1-drawpixels-fog drawpixels-fog.c)
+piglit_add_executable (gl-1.1-drawpixels-texturing drawpixels-texturing.c)
piglit_add_executable (gl-1.1-read-pixels-after-display-list read-pixels-after-display-list.c)
piglit_add_executable (gl-1.1-set-vertex-color-after-draw set-vertex-color-after-draw.c)
piglit_add_executable (gl-1.1-xor xor.c)
diff --git a/tests/spec/gl-1.1/drawpixels-fog.c b/tests/spec/gl-1.1/drawpixels-fog.c
new file mode 100644
index 000000000..a1dcc5eeb
--- /dev/null
+++ b/tests/spec/gl-1.1/drawpixels-fog.c
@@ -0,0 +1,108 @@
+/* Copyright © 2017 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 copypixels-texturing.c
+ * use glCopyPixels with texturing enabled
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 11;
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+
+static const float red[3] = {1.0, 0.0, 0.0};
+static const float green[3] = {0.0, 1.0, 0.0};
+static const float yellow[3] = {0.5, 0.5, 0.0};
+static const float magenta[3] = {0.5, 0.0, 0.5};
+
+enum piglit_result
+piglit_display(void)
+{
+ bool pass = true;
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1, 1, -1, 1, -1, 1);
+
+ glViewport(0, 0, piglit_width, piglit_height);
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ /* Draw a shape on the top half of the window. */
+ glDisable(GL_FOG);
+ glColor3fv(red);
+ glBegin(GL_TRIANGLE_FAN);
+ glVertex2f(-0.2, 1.0);
+ glVertex2f(-1.0, 0.7);
+ glVertex2f( 0.2, 0.0);
+ glVertex2f( 1.0, 0.3);
+ glEnd();
+
+ /* Enable texturing and copy the top half of the window to the bottom
+ * half.
+ */
+ glEnable(GL_FOG);
+ glWindowPos3f(0.0, 0.0, 0.5);
+
+ void *pixels = malloc(piglit_width * (piglit_height/2) * 4);
+ glReadPixels(0, (piglit_height+1)/2, piglit_width, piglit_height/2,
+ GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+ glDrawPixels(piglit_width, piglit_height/2, GL_RGBA, GL_UNSIGNED_BYTE,
+ pixels);
+ free(pixels);
+
+ /* Probe the corners of the bottom half. These should be 50% blue +
+ * 50% red = magenta.
+ */
+ pass = piglit_probe_pixel_rgb(0, 0, magenta) && pass;
+ pass = piglit_probe_pixel_rgb(0, piglit_height / 2 - 1, magenta) && pass;
+ pass = piglit_probe_pixel_rgb(piglit_width - 1, 0, magenta) && pass;
+ pass = piglit_probe_pixel_rgb(piglit_width - 1, piglit_height / 2 - 1, magenta) && pass;
+
+ /* Probe the middle of the bottom half. These should be 50% green +
+ * 50% red = yellow.
+ */
+ pass = piglit_probe_pixel_rgb(piglit_width / 2, piglit_height / 4, yellow) &&
+ pass;
+
+ piglit_present_results();
+
+ piglit_check_gl_error(GL_NO_ERROR);
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+ glClearColor(0.0, 0.0, 0.5, 1.0);
+ glFogi(GL_FOG_MODE, GL_LINEAR);
+ glFogf(GL_FOG_START, 0.0);
+ glFogf(GL_FOG_END, 1.0);
+ glFogfv(GL_FOG_COLOR, green);
+}
diff --git a/tests/spec/gl-1.1/drawpixels-texturing.c b/tests/spec/gl-1.1/drawpixels-texturing.c
new file mode 100644
index 000000000..fe55f61ff
--- /dev/null
+++ b/tests/spec/gl-1.1/drawpixels-texturing.c
@@ -0,0 +1,123 @@
+/* Copyright © 2017 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 copypixels-texturing.c
+ * use glCopyPixels with texturing enabled
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 11;
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+
+static const float magenta[3] = {1.0, 0.0, 1.0};
+static const float green[3] = {0.0, 1.0, 0.0};
+static const float white[3] = {1.0, 1.0, 1.0};
+
+enum piglit_result
+piglit_display(void)
+{
+ bool pass = true;
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1, 1, -1, 1, -1, 1);
+
+ glViewport(0, 0, piglit_width, piglit_height);
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ /* Draw a shape on the top half of the window. */
+ glDisable(GL_TEXTURE_2D);
+ glColor3fv(magenta);
+ glBegin(GL_TRIANGLE_FAN);
+ glVertex2f(-0.2, 1.0);
+ glVertex2f(-1.0, 0.7);
+ glVertex2f( 0.2, 0.0);
+ glVertex2f( 1.0, 0.3);
+ glEnd();
+
+ /* Enable texturing and copy the top half of the window to the bottom
+ * half.
+ */
+ glEnable(GL_TEXTURE_2D);
+
+ glColor3f(0.0, 0.0, 0.0);
+ glWindowPos2i(0, 0);
+
+ void *pixels = malloc(piglit_width * (piglit_height/2) * 4);
+ glReadPixels(0, (piglit_height+1)/2, piglit_width, piglit_height/2,
+ GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+ glDrawPixels(piglit_width, piglit_height/2, GL_RGBA, GL_UNSIGNED_BYTE,
+ pixels);
+ free(pixels);
+
+ /* Probe the corners of the bottom half. These should all be the
+ * color of the texture.
+ */
+ pass = piglit_probe_pixel_rgb(0, 0, green) && pass;
+ pass = piglit_probe_pixel_rgb(0, piglit_height / 2 - 1, green) && pass;
+ pass = piglit_probe_pixel_rgb(piglit_width - 1, 0, green) && pass;
+ pass = piglit_probe_pixel_rgb(piglit_width - 1, piglit_height / 2 - 1, green) && pass;
+
+ /* Probe the middle of the bottom half. These should be green + blue
+ * = white.
+ */
+ pass = piglit_probe_pixel_rgb(piglit_width / 2, piglit_height / 4, white) &&
+ pass;
+
+ piglit_present_results();
+
+ piglit_check_gl_error(GL_NO_ERROR);
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+ static const GLubyte texels[] = {
+ 0x00, 0xff, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff
+ };
+
+ GLuint tex;
+
+ piglit_require_extension("GL_ARB_texture_env_add");
+
+ glGenTextures(1, &tex);
+ glBindTexture(GL_TEXTURE_2D, tex);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, texels);
+}