[Piglit] [PATCH] Add tests arb_conditional_render_inverted

Tobias Klausmann tobias.johannes.klausmann at mni.thm.de
Sun Aug 17 12:11:40 PDT 2014


Adopted tests from NV_conditional_render

Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
---
 tests/all.py                                       |  15 ++
 tests/spec/CMakeLists.txt                          |   1 +
 .../CMakeLists.gl.txt                              |  23 ++++
 .../arb_conditional_render_inverted/CMakeLists.txt |   1 +
 .../begin-while-active.c                           |  77 +++++++++++
 .../arb_conditional_render_inverted/begin-zero.c   |  70 ++++++++++
 .../spec/arb_conditional_render_inverted/bitmap.c  | 111 +++++++++++++++
 .../blitframebuffer.c                              | 151 +++++++++++++++++++++
 tests/spec/arb_conditional_render_inverted/clear.c | 103 ++++++++++++++
 .../arb_conditional_render_inverted/copypixels.c   | 104 ++++++++++++++
 .../arb_conditional_render_inverted/copyteximage.c | 127 +++++++++++++++++
 .../copytexsubimage.c                              | 127 +++++++++++++++++
 tests/spec/arb_conditional_render_inverted/dlist.c |  98 +++++++++++++
 .../arb_conditional_render_inverted/drawpixels.c   | 121 +++++++++++++++++
 .../generatemipmap.c                               | 126 +++++++++++++++++
 .../arb_conditional_render_inverted/vertex_array.c | 102 ++++++++++++++
 16 files changed, 1357 insertions(+)
 create mode 100644 tests/spec/arb_conditional_render_inverted/CMakeLists.gl.txt
 create mode 100644 tests/spec/arb_conditional_render_inverted/CMakeLists.txt
 create mode 100644 tests/spec/arb_conditional_render_inverted/begin-while-active.c
 create mode 100644 tests/spec/arb_conditional_render_inverted/begin-zero.c
 create mode 100644 tests/spec/arb_conditional_render_inverted/bitmap.c
 create mode 100644 tests/spec/arb_conditional_render_inverted/blitframebuffer.c
 create mode 100644 tests/spec/arb_conditional_render_inverted/clear.c
 create mode 100644 tests/spec/arb_conditional_render_inverted/copypixels.c
 create mode 100644 tests/spec/arb_conditional_render_inverted/copyteximage.c
 create mode 100644 tests/spec/arb_conditional_render_inverted/copytexsubimage.c
 create mode 100644 tests/spec/arb_conditional_render_inverted/dlist.c
 create mode 100644 tests/spec/arb_conditional_render_inverted/drawpixels.c
 create mode 100644 tests/spec/arb_conditional_render_inverted/generatemipmap.c
 create mode 100644 tests/spec/arb_conditional_render_inverted/vertex_array.c

diff --git a/tests/all.py b/tests/all.py
index 12f57c8..4ddd0ce 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3355,6 +3355,21 @@ arb_copy_buffer['overlap'] = concurrent_test('arb_copy_buffer-overlap')
 arb_copy_buffer['targets'] = concurrent_test('arb_copy_buffer-targets')
 arb_copy_buffer['subdata-sync'] = concurrent_test('arb_copy_buffer-subdata-sync')
 
+arb_conditional_render_inverted = {}
+spec['ARB_conditional_render_inverted'] = arb_conditional_render_inverted
+arb_conditional_render_inverted['begin-while-active'] = concurrent_test('arb_conditional_render_inverted-begin-while-active')
+arb_conditional_render_inverted['begin-zero'] = concurrent_test('arb_conditional_render_inverted-begin-zero')
+arb_conditional_render_inverted['bitmap'] = PiglitTest(['arb_conditional_render_inverted-bitmap', '-auto'])
+arb_conditional_render_inverted['blitframebuffer'] = PiglitTest(['arb_conditional_render_inverted-blitframebuffer', '-auto'])
+arb_conditional_render_inverted['clear'] = PiglitTest(['arb_conditional_render_inverted-clear', '-auto'])
+arb_conditional_render_inverted['copypixels'] = PiglitTest(['arb_conditional_render_inverted-copypixels', '-auto'])
+arb_conditional_render_inverted['copyteximage'] = PiglitTest(['arb_conditional_render_inverted-copyteximage', '-auto'])
+arb_conditional_render_inverted['copytexsubimage'] = PiglitTest(['arb_conditional_render_inverted-copytexsubimage', '-auto'])
+arb_conditional_render_inverted['dlist'] = PiglitTest(['arb_conditional_render_inverted-dlist', '-auto'])
+arb_conditional_render_inverted['drawpixels'] = PiglitTest(['arb_conditional_render_inverted-drawpixels', '-auto'])
+arb_conditional_render_inverted['generatemipmap'] = PiglitTest(['arb_conditional_render_inverted-generatemipmap', '-auto'])
+arb_conditional_render_inverted['vertex_array'] = PiglitTest(['arb_conditional_render_inverted-vertex_array', '-auto'])
+
 arb_half_float_vertex = {}
 spec['ARB_half_float_vertex'] = arb_half_float_vertex
 add_plain_test(arb_half_float_vertex, 'draw-vertices-half-float')
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 5148412..eba0f45 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -5,6 +5,7 @@ add_subdirectory (arb_clear_buffer_object)
 add_subdirectory (arb_clear_texture)
 add_subdirectory (arb_color_buffer_float)
 add_subdirectory (arb_compute_shader)
+add_subdirectory (arb_conditional_render_inverted)
 add_subdirectory (arb_debug_output)
 add_subdirectory (khr_debug)
 add_subdirectory (arb_depth_clamp)
diff --git a/tests/spec/arb_conditional_render_inverted/CMakeLists.gl.txt b/tests/spec/arb_conditional_render_inverted/CMakeLists.gl.txt
new file mode 100644
index 0000000..931b9e1
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/CMakeLists.gl.txt
@@ -0,0 +1,23 @@
+include_directories(
+	${GLEXT_INCLUDE_DIR}
+	${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+	piglitutil_${piglit_target_api}
+	${OPENGL_gl_LIBRARY}
+	${OPENGL_glu_LIBRARY}
+)
+
+piglit_add_executable (arb_conditional_render_inverted-begin-while-active begin-while-active.c)
+piglit_add_executable (arb_conditional_render_inverted-begin-zero begin-zero.c)
+piglit_add_executable (arb_conditional_render_inverted-bitmap bitmap.c)
+piglit_add_executable (arb_conditional_render_inverted-blitframebuffer blitframebuffer.c)
+piglit_add_executable (arb_conditional_render_inverted-clear clear.c)
+piglit_add_executable (arb_conditional_render_inverted-copypixels copypixels.c)
+piglit_add_executable (arb_conditional_render_inverted-copyteximage copyteximage.c)
+piglit_add_executable (arb_conditional_render_inverted-copytexsubimage copytexsubimage.c)
+piglit_add_executable (arb_conditional_render_inverted-dlist dlist.c)
+piglit_add_executable (arb_conditional_render_inverted-drawpixels drawpixels.c)
+piglit_add_executable (arb_conditional_render_inverted-generatemipmap generatemipmap.c)
+piglit_add_executable (arb_conditional_render_inverted-vertex_array vertex_array.c)
diff --git a/tests/spec/arb_conditional_render_inverted/CMakeLists.txt b/tests/spec/arb_conditional_render_inverted/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_conditional_render_inverted/begin-while-active.c b/tests/spec/arb_conditional_render_inverted/begin-while-active.c
new file mode 100644
index 0000000..31a1eeb
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/begin-while-active.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ * Copyright © 2014 Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file begin-while-active.c
+ *
+ * Tests that starting conditional rendering on a query object that is
+ * active results in INVALID_OPERATION.
+ *
+ * From the ARB_conditional_render_inverted:
+ *
+ *     If <mode> is QUERY_WAIT_INVERTED, QUERY_NO_WAIT_INVERTED,
+ *   QUERY_BY_REGION_WAIT_INVERTED, or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   then the condition used to determine whether or not to render subsequent
+ *   drawing commands is negated with respect to QUERY_WAIT, QUERY_NO_WAIT,
+ *   QUERY_BY_REGION_WAIT, or QUERY_BY_REGION_NO_WAIT, respectively. If <mode>
+ *   is QUERY_NO_WAIT_INVERTED or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   the GL may choose to unconditionally execute the subsequent rendering
+ *   commands without waiting for the query to complete.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+
+	config.window_visual = PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint q;
+
+	piglit_require_gl_version(30);
+
+	piglit_require_extension("GL_ARB_conditional_render_inverted");
+
+	glGenQueries(1, &q);
+	glBeginQuery(GL_SAMPLES_PASSED, q);
+	glBeginConditionalRender(q, GL_QUERY_WAIT_INVERTED);
+	if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+		piglit_report_result(PIGLIT_FAIL);
+	glEndQuery(GL_SAMPLES_PASSED);
+	glDeleteQueries(1, &q);
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/arb_conditional_render_inverted/begin-zero.c b/tests/spec/arb_conditional_render_inverted/begin-zero.c
new file mode 100644
index 0000000..9157804
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/begin-zero.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ * Copyright © 2014 Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file begin-zero.c
+ *
+ * Tests that starting conditional rendering on a 0 query object
+ * results in INVALID_VALUE.
+ *
+ * From the ARB_conditional_render_inverted:
+ *
+ *     If <mode> is QUERY_WAIT_INVERTED, QUERY_NO_WAIT_INVERTED,
+ *   QUERY_BY_REGION_WAIT_INVERTED, or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   then the condition used to determine whether or not to render subsequent
+ *   drawing commands is negated with respect to QUERY_WAIT, QUERY_NO_WAIT,
+ *   QUERY_BY_REGION_WAIT, or QUERY_BY_REGION_NO_WAIT, respectively. If <mode>
+ *   is QUERY_NO_WAIT_INVERTED or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   the GL may choose to unconditionally execute the subsequent rendering
+ *   commands without waiting for the query to complete.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_gl_version(30);
+
+	piglit_require_extension("GL_ARB_conditional_render_inverted");
+
+	glBeginConditionalRender(0, GL_QUERY_WAIT_INVERTED);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/arb_conditional_render_inverted/bitmap.c b/tests/spec/arb_conditional_render_inverted/bitmap.c
new file mode 100644
index 0000000..ac4e9be
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/bitmap.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ * Copyright © 2014 Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file bitmap.c
+ *
+ * Tests that conditional rendering appropriately affects glBitmap().
+ *
+ * From the ARB_conditional_render_inverted:
+ *
+ *     If <mode> is QUERY_WAIT_INVERTED, QUERY_NO_WAIT_INVERTED,
+ *   QUERY_BY_REGION_WAIT_INVERTED, or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   then the condition used to determine whether or not to render subsequent
+ *   drawing commands is negated with respect to QUERY_WAIT, QUERY_NO_WAIT,
+ *   QUERY_BY_REGION_WAIT, or QUERY_BY_REGION_NO_WAIT, respectively. If <mode>
+ *   is QUERY_NO_WAIT_INVERTED or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   the GL may choose to unconditionally execute the subsequent rendering
+ *   commands without waiting for the query to complete.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	float green[4] = {0.0, 1.0, 0.0, 0.0};
+	void *buf;
+	GLuint qfail, qpass;
+
+	glClearColor(0.5, 0.5, 0.5, 0.5);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	/* Massively overallocate the bitmap, and set it to all on */
+	buf = malloc(piglit_width * piglit_height);
+	memset(buf, 0xff, piglit_width * piglit_height);
+
+	glGenQueries(1, &qfail);
+
+	/* Generate query fail. */
+	glBeginQuery(GL_SAMPLES_PASSED, qfail);
+	glEndQuery(GL_SAMPLES_PASSED);
+	
+	glGenQueries(1, &qpass);
+	/* Generate query pass: draw top half of screen. */
+	glColor4f(0.0, 0.0, 1.0, 0.0);
+	glBeginQuery(GL_SAMPLES_PASSED, qpass);
+	piglit_draw_rect(-1, 0, 2, 1);
+	glEndQuery(GL_SAMPLES_PASSED);
+
+	/* Conditional render that should draw the whole screen. */
+	glBeginConditionalRender(qfail, GL_QUERY_WAIT_INVERTED);
+	glColor4f(0.0, 1.0, 0.0, 0.0);
+	glRasterPos2i(-1, -1);
+	glBitmap(piglit_width, piglit_height, 0, 0, 0, 0, buf);
+	glEndConditionalRender();
+
+	/* Conditional render that should not draw full screen. */
+	glBeginConditionalRender(qpass, GL_QUERY_WAIT_INVERTED);
+	glColor4f(1.0, 0.0, 0.0, 0.0);
+	glRasterPos2i(-1, -1);
+	glBitmap(piglit_width, piglit_height, 0, 0, 0, 0, buf);
+	glEndConditionalRender();
+
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      green);
+
+	piglit_present_results();
+
+	glDeleteQueries(1, &qfail);
+	glDeleteQueries(1, &qpass);
+	free(buf);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_gl_version(30);
+
+	piglit_require_extension("GL_ARB_conditional_render_inverted");
+}
diff --git a/tests/spec/arb_conditional_render_inverted/blitframebuffer.c b/tests/spec/arb_conditional_render_inverted/blitframebuffer.c
new file mode 100644
index 0000000..0946d9b
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/blitframebuffer.c
@@ -0,0 +1,151 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ * Copyright © 2014 Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file blitframebuffer.c
+ *
+ * Tests that conditional rendering also affects glBlitFramebuffer().
+ *
+ * From the ARB_conditional_render_inverted:
+ *
+ *     If <mode> is QUERY_WAIT_INVERTED, QUERY_NO_WAIT_INVERTED,
+ *   QUERY_BY_REGION_WAIT_INVERTED, or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   then the condition used to determine whether or not to render subsequent
+ *   drawing commands is negated with respect to QUERY_WAIT, QUERY_NO_WAIT,
+ *   QUERY_BY_REGION_WAIT, or QUERY_BY_REGION_NO_WAIT, respectively. If <mode>
+ *   is QUERY_NO_WAIT_INVERTED or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   the GL may choose to unconditionally execute the subsequent rendering
+ *   commands without waiting for the query to complete.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static void fill_tex(int level, int w, int h, const GLfloat *color)
+{
+	GLfloat *data;
+	int i;
+
+	data = malloc(w * h * 4 * sizeof(GLfloat));
+	for (i = 0; i < 4 * w * h; i += 4) {
+		data[i + 0] = color[0];
+		data[i + 1] = color[1];
+		data[i + 2] = color[2];
+		data[i + 3] = color[3];
+	}
+        glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0,
+		     GL_RGBA, GL_FLOAT, data);
+	free(data);
+}
+
+static void blit_window_to_tex(GLuint tex, int w, int h)
+{
+	GLuint fb;
+
+	glGenFramebuffersEXT(1, &fb);
+	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb);
+	glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0);
+
+	assert(glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT);
+
+	glBlitFramebufferEXT(0, h, w, 2 * h, 0, 0, w, h, GL_COLOR_BUFFER_BIT, GL_LINEAR);
+
+	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo);
+	glDeleteFramebuffersEXT(1, &fb);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	float green[4] = {0.0, 1.0, 0.0, 0.0};
+	GLuint q, texture;
+
+	glClearColor(0.5, 0.5, 0.5, 0.5);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	glGenQueries(1, &q);
+	
+	/* Generate query pass: draw bottom half of screen. */
+	glColor4f(0.0, 0.0, 1.0, 0.0);
+	glBeginQuery(GL_SAMPLES_PASSED, q);
+	piglit_draw_rect(-1, -1, 2, 1);
+	glEndQuery(GL_SAMPLES_PASSED);
+	
+	/* Draw bottom half of window to green. */
+	glColor4fv(green);
+	piglit_draw_rect(-1, -1, 2, 1);
+	glColor4f(1, 1, 1, 1);
+
+	/* Set up a green texture. */
+	glGenTextures(1, &texture);
+	glBindTexture(GL_TEXTURE_2D, texture);
+
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+			GL_LINEAR_MIPMAP_NEAREST);
+	glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
+
+	fill_tex(0, piglit_width, piglit_height / 2, green);
+
+	/* BlitFramebuffer() should not be affected by inverted conditional rendering. */
+	glBeginConditionalRender(q, GL_QUERY_WAIT_INVERTED);
+	/* Blit top half of the window to texture. */
+	blit_window_to_tex(texture, piglit_width, piglit_height / 2);
+	glEndConditionalRender();
+
+	/* Draw the texture to top half of the window. */
+	glEnable(GL_TEXTURE_2D);
+	piglit_draw_rect_tex(-1, 0, 2, 1,
+			     0, 0, 1, 1);
+	glDisable(GL_TEXTURE_2D);
+
+	pass = piglit_probe_rect_rgba(0, piglit_width / 2,
+				      piglit_width, piglit_height / 2,
+				      green);
+
+	piglit_present_results();
+
+	glDeleteQueries(1, &q);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_gl_version(30);
+
+	piglit_require_extension("GL_ARB_conditional_render_inverted");
+	piglit_require_extension("GL_EXT_framebuffer_object");
+	piglit_require_extension("GL_EXT_framebuffer_blit");
+}
diff --git a/tests/spec/arb_conditional_render_inverted/clear.c b/tests/spec/arb_conditional_render_inverted/clear.c
new file mode 100644
index 0000000..1515990
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/clear.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ * Copyright © 2014 Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file clear.c
+ *
+ * Tests that conditional rendering appropriately affects glClear().
+ *
+ * From the ARB_conditional_render_inverted:
+ *
+ *     If <mode> is QUERY_WAIT_INVERTED, QUERY_NO_WAIT_INVERTED,
+ *   QUERY_BY_REGION_WAIT_INVERTED, or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   then the condition used to determine whether or not to render subsequent
+ *   drawing commands is negated with respect to QUERY_WAIT, QUERY_NO_WAIT,
+ *   QUERY_BY_REGION_WAIT, or QUERY_BY_REGION_NO_WAIT, respectively. If <mode>
+ *   is QUERY_NO_WAIT_INVERTED or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   the GL may choose to unconditionally execute the subsequent rendering
+ *   commands without waiting for the query to complete.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	float green[4] = {0.0, 1.0, 0.0, 0.0};
+	GLuint qpass,qfail;
+
+	glClearColor(0.5, 0.5, 0.5, 0.5);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	glGenQueries(1, &qfail);
+
+	/* Generate query fail. */
+	glBeginQuery(GL_SAMPLES_PASSED, qfail);
+	glEndQuery(GL_SAMPLES_PASSED);
+	
+	glGenQueries(1, &qpass);
+	/* Generate query pass: draw top half of screen. */
+	glColor4f(0.0, 0.0, 1.0, 0.0);
+	glBeginQuery(GL_SAMPLES_PASSED, qpass);
+	piglit_draw_rect(-1, 0, 2, 1);
+	glEndQuery(GL_SAMPLES_PASSED);
+
+	/* Conditional render that should draw bottom full screen. */
+	glBeginConditionalRender(qfail, GL_QUERY_WAIT_INVERTED);
+	glClearColor(0.0, 1.0, 0.0, 0.0);
+	glClear(GL_COLOR_BUFFER_BIT);
+	glEndConditionalRender();
+
+	/* Conditional render that should not draw full screen. */
+	glBeginConditionalRender(qpass, GL_QUERY_WAIT_INVERTED);
+	glClearColor(1.0, 0.0, 0.0, 0.0);
+	glClear(GL_COLOR_BUFFER_BIT);
+	glEndConditionalRender();
+	
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      green);
+
+	piglit_present_results();
+
+	glDeleteQueries(1, &qfail);
+	glDeleteQueries(1, &qpass);
+	
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_gl_version(30);
+
+	piglit_require_extension("GL_ARB_conditional_render_inverted");
+}
diff --git a/tests/spec/arb_conditional_render_inverted/copypixels.c b/tests/spec/arb_conditional_render_inverted/copypixels.c
new file mode 100644
index 0000000..a9f8cc4
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/copypixels.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ * Copyright © 2014 Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file copypixels.c
+ *
+ * Tests that conditional rendering appropriately affects glCopyPixels().
+ *
+ * From the ARB_conditional_render_inverted:
+ *
+ *     If <mode> is QUERY_WAIT_INVERTED, QUERY_NO_WAIT_INVERTED,
+ *   QUERY_BY_REGION_WAIT_INVERTED, or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   then the condition used to determine whether or not to render subsequent
+ *   drawing commands is negated with respect to QUERY_WAIT, QUERY_NO_WAIT,
+ *   QUERY_BY_REGION_WAIT, or QUERY_BY_REGION_NO_WAIT, respectively. If <mode>
+ *   is QUERY_NO_WAIT_INVERTED or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   the GL may choose to unconditionally execute the subsequent rendering
+ *   commands without waiting for the query to complete.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	float green[4] = {0.0, 1.0, 0.0, 0.0};
+	GLuint qpass, qfail;
+
+	glClearColor(1.0, 0.0, 0.0, 0.0);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	glGenQueries(1, &qpass);
+	glGenQueries(1, &qfail);
+
+	/* Generate query pass: draw top half of screen. */
+	glColor4f(0.0, 1.0, 0.0, 0.0);
+	glBeginQuery(GL_SAMPLES_PASSED, qpass);
+	piglit_draw_rect(-1, 0, 2, 1);
+	glEndQuery(GL_SAMPLES_PASSED);
+
+	/* Generate query fail */
+	glBeginQuery(GL_SAMPLES_PASSED, qfail);
+	glEndQuery(GL_SAMPLES_PASSED);
+
+	/* Conditional render that should not copy red over the green. */
+	glBeginConditionalRender(qpass, GL_QUERY_WAIT_INVERTED);
+	glRasterPos2i(-1, 0);
+	glCopyPixels(0, 0, piglit_width, piglit_height / 2, GL_COLOR);
+	glEndConditionalRender();
+
+	/* Conditional render that should copy green over remaining red. */
+	glBeginConditionalRender(qfail, GL_QUERY_WAIT_INVERTED);
+	glRasterPos2i(-1, -1);
+	glCopyPixels(0, piglit_height / 2, piglit_width, piglit_height / 2,
+		     GL_COLOR);
+	glEndConditionalRender();
+
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      green);
+
+	piglit_present_results();
+
+	glDeleteQueries(1, &qfail);
+	glDeleteQueries(1, &qpass);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_gl_version(30);
+
+	piglit_require_extension("GL_ARB_conditional_render_inverted");
+}
diff --git a/tests/spec/arb_conditional_render_inverted/copyteximage.c b/tests/spec/arb_conditional_render_inverted/copyteximage.c
new file mode 100644
index 0000000..033ba9b
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/copyteximage.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ * Copyright © 2014 Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file copyteximage.c
+ *
+ * Tests that conditional rendering does not affect glCopyTexImage2D().
+ *
+ * From the ARB_conditional_render_inverted:
+ *
+ *     If <mode> is QUERY_WAIT_INVERTED, QUERY_NO_WAIT_INVERTED,
+ *   QUERY_BY_REGION_WAIT_INVERTED, or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   then the condition used to determine whether or not to render subsequent
+ *   drawing commands is negated with respect to QUERY_WAIT, QUERY_NO_WAIT,
+ *   QUERY_BY_REGION_WAIT, or QUERY_BY_REGION_NO_WAIT, respectively. If <mode>
+ *   is QUERY_NO_WAIT_INVERTED or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   the GL may choose to unconditionally execute the subsequent rendering
+ *   commands without waiting for the query to complete.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static void
+fill_tex(int level, int w, int h, const GLfloat *color)
+{
+	GLfloat *data;
+	int i;
+
+	data = malloc(w * h * 4 * sizeof(GLfloat));
+	for (i = 0; i < 4 * w * h; i += 4) {
+		data[i + 0] = color[0];
+		data[i + 1] = color[1];
+		data[i + 2] = color[2];
+		data[i + 3] = color[3];
+	}
+        glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0,
+		     GL_RGBA, GL_FLOAT, data);
+	free(data);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	float red[4] = {1.0, 0.0, 0.0, 0.0};
+	float green[4] = {0.0, 1.0, 0.0, 0.0};
+	GLuint q, texture;
+
+	glClearColor(0.5, 0.5, 0.5, 0.5);
+	glClear(GL_COLOR_BUFFER_BIT);
+	
+	glGenQueries(1, &q);
+	/* Generate query pass: draw bottom half of screen. */
+	glColor4f(0.0, 1.0, 0.0, 0.0);
+	glBeginQuery(GL_SAMPLES_PASSED, q);
+	piglit_draw_rect(-1, -1, 2, 1);
+	glEndQuery(GL_SAMPLES_PASSED);
+
+	/* Set up a red texture. */
+	glGenTextures(1, &texture);
+	glBindTexture(GL_TEXTURE_2D, texture);
+
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+			GL_LINEAR_MIPMAP_NEAREST);
+	glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
+
+	fill_tex(0, piglit_width, piglit_height / 2, red);
+
+	/* This should not be affected by inverted conditional rendering. */
+	glBeginConditionalRender(q, GL_QUERY_WAIT_INVERTED);
+	glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, piglit_width, piglit_height / 2, 0);
+	glEndConditionalRender();
+
+	/* Draw the texture. */
+	glEnable(GL_TEXTURE_2D);
+	piglit_draw_rect_tex(-1, 0, 2, 1,
+			     0, 0, 1, 1);
+	glDisable(GL_TEXTURE_2D);
+
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      green);
+
+	piglit_present_results();
+
+	glDeleteQueries(1, &q);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_gl_version(30);
+
+	piglit_require_extension("GL_ARB_conditional_render_inverted");
+}
diff --git a/tests/spec/arb_conditional_render_inverted/copytexsubimage.c b/tests/spec/arb_conditional_render_inverted/copytexsubimage.c
new file mode 100644
index 0000000..8886803
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/copytexsubimage.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ * Copyright © 2014 Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file copytexsubimage.c
+ *
+ * Tests that conditional rendering does not affect glCopyTexSubImage2D().
+ *
+ * From the ARB_conditional_render_inverted:
+ *
+ *     If <mode> is QUERY_WAIT_INVERTED, QUERY_NO_WAIT_INVERTED,
+ *   QUERY_BY_REGION_WAIT_INVERTED, or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   then the condition used to determine whether or not to render subsequent
+ *   drawing commands is negated with respect to QUERY_WAIT, QUERY_NO_WAIT,
+ *   QUERY_BY_REGION_WAIT, or QUERY_BY_REGION_NO_WAIT, respectively. If <mode>
+ *   is QUERY_NO_WAIT_INVERTED or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   the GL may choose to unconditionally execute the subsequent rendering
+ *   commands without waiting for the query to complete.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static void
+fill_tex(int level, int w, int h, const GLfloat *color)
+{
+	GLfloat *data;
+	int i;
+
+	data = malloc(w * h * 4 * sizeof(GLfloat));
+	for (i = 0; i < 4 * w * h; i += 4) {
+		data[i + 0] = color[0];
+		data[i + 1] = color[1];
+		data[i + 2] = color[2];
+		data[i + 3] = color[3];
+	}
+        glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0,
+		     GL_RGBA, GL_FLOAT, data);
+	free(data);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	float red[4] = {1.0, 0.0, 0.0, 0.0};
+	float green[4] = {0.0, 1.0, 0.0, 0.0};
+	GLuint q, texture;
+
+	glClearColor(0.5, 0.5, 0.5, 0.5);
+	glClear(GL_COLOR_BUFFER_BIT);
+	
+	glGenQueries(1, &q);
+	/* Generate query pass: draw top half of screen. */
+	glColor4f(0.0, 1.0, 0.0, 0.0);
+	glBeginQuery(GL_SAMPLES_PASSED, q);
+	piglit_draw_rect(-1, -1, 2, 1);
+	glEndQuery(GL_SAMPLES_PASSED);
+
+	/* Set up a red texture. */
+	glGenTextures(1, &texture);
+	glBindTexture(GL_TEXTURE_2D, texture);
+
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+			GL_LINEAR_MIPMAP_NEAREST);
+	glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
+
+	fill_tex(0, piglit_width*2, piglit_height / 2, red);
+
+	/* This should not be affected by inverted conditional rendering. */
+	glBeginConditionalRender(q, GL_QUERY_WAIT_INVERTED);
+	glCopyTexSubImage2D(GL_TEXTURE_2D, 0, piglit_width, 0, 0, 0, piglit_width, piglit_height / 2);
+	glEndConditionalRender();
+
+	/* Draw the right half of the texture. */
+	glEnable(GL_TEXTURE_2D);
+	piglit_draw_rect_tex(-1, 0, 2, 1,
+			     0.5, 0, 1, 1);
+	glDisable(GL_TEXTURE_2D);
+
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      green);
+
+	piglit_present_results();
+
+	glDeleteQueries(1, &q);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_gl_version(30);
+
+	piglit_require_extension("GL_ARB_conditional_render_inverted");
+}
diff --git a/tests/spec/arb_conditional_render_inverted/dlist.c b/tests/spec/arb_conditional_render_inverted/dlist.c
new file mode 100644
index 0000000..f6c2707
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/dlist.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ * Copyright © 2014 Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file dlist.c
+ *
+ * Tests that conditional rendering appropriately affects commands
+ * inside of display lists.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	float green[4] = {0.0, 1.0, 0.0, 0.0};
+	GLuint qfail, qpass;
+	GLuint list;
+
+	list = glGenLists(1);
+	glNewList(list, GL_COMPILE);
+	glClearColor(0.5, 0.5, 0.5, 0.5);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	glGenQueries(1, &qfail);
+	/* Generate query fail. */
+	glBeginQuery(GL_SAMPLES_PASSED, qfail);
+	glEndQuery(GL_SAMPLES_PASSED);
+	
+	glGenQueries(1, &qpass);
+	/* Generate query pass: draw top half of screen. */
+	glColor4f(0.0, 0.0, 1.0, 0.0);
+	glBeginQuery(GL_SAMPLES_PASSED, qpass);
+	piglit_draw_rect(-1, 0, 2, 1);
+	glEndQuery(GL_SAMPLES_PASSED);
+
+	/* Conditional render that should draw full screen. */
+	glBeginConditionalRender(qfail, GL_QUERY_WAIT_INVERTED);
+	glColor4f(0.0, 1.0, 0.0, 0.0);
+	piglit_draw_rect(-1, -1, 2, 2);
+	glEndConditionalRender();
+
+	/* Conditional render that should not draw full screen. */
+	glBeginConditionalRender(qpass, GL_QUERY_WAIT_INVERTED);
+	glColor4f(1.0, 0.0, 0.0, 0.0);
+	piglit_draw_rect(-1, -1, 2, 2);
+	glEndConditionalRender();
+	glEndList();
+
+	glCallList(list);
+
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      green);
+
+	piglit_present_results();
+
+	glDeleteQueries(1, &qfail);
+	glDeleteQueries(1, &qpass);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_gl_version(30);
+
+	piglit_require_extension("GL_ARB_conditional_render_inverted");
+}
diff --git a/tests/spec/arb_conditional_render_inverted/drawpixels.c b/tests/spec/arb_conditional_render_inverted/drawpixels.c
new file mode 100644
index 0000000..3bffe1c
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/drawpixels.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ * Copyright © 2014 Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file drawpixels.c
+ *
+ * Tests that conditional rendering appropriately affects glDrawPixels().
+ *
+ * From the ARB_conditional_render_inverted:
+ *
+ *     If <mode> is QUERY_WAIT_INVERTED, QUERY_NO_WAIT_INVERTED,
+ *   QUERY_BY_REGION_WAIT_INVERTED, or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   then the condition used to determine whether or not to render subsequent
+ *   drawing commands is negated with respect to QUERY_WAIT, QUERY_NO_WAIT,
+ *   QUERY_BY_REGION_WAIT, or QUERY_BY_REGION_NO_WAIT, respectively. If <mode>
+ *   is QUERY_NO_WAIT_INVERTED or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   the GL may choose to unconditionally execute the subsequent rendering
+ *   commands without waiting for the query to complete.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	float green[4] = {0.0, 1.0, 0.0, 0.0};
+	float *buf;
+	int i;
+	GLuint qfail, qpass;
+
+	glClearColor(0.5, 0.5, 0.5, 0.5);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	buf = malloc(sizeof(float) * 4 * piglit_width * piglit_height);
+
+	glGenQueries(1, &qpass);
+
+	/* Generate query pass: draw top half of screen. */
+	glColor4f(0.0, 1.0, 0.0, 0.0);
+	glBeginQuery(GL_SAMPLES_PASSED, qpass);
+	piglit_draw_rect(-1, 0, 2, 1);
+	glEndQuery(GL_SAMPLES_PASSED);
+	
+	glGenQueries(1, &qfail);
+	
+	/* Generate query fail */
+	glBeginQuery(GL_SAMPLES_PASSED, qfail);
+	glEndQuery(GL_SAMPLES_PASSED);
+
+	/* Conditional render that should draw bottom half of screen. */
+	for (i = 0; i < piglit_width * piglit_height / 2; i++) {
+		buf[i * 4 + 0] = 0.0;
+		buf[i * 4 + 1] = 1.0;
+		buf[i * 4 + 2] = 0.0;
+		buf[i * 4 + 3] = 0.0;
+	}
+	glBeginConditionalRender(qfail, GL_QUERY_WAIT_INVERTED);
+	glRasterPos2i(-1, -1);
+	glDrawPixels(piglit_width, piglit_height / 2, GL_RGBA, GL_FLOAT, buf);
+	glEndConditionalRender();
+
+	/* Conditional render that should not draw full screen. */
+	for (i = 0; i < piglit_width * piglit_height; i++) {
+		buf[i * 4 + 0] = 1.0;
+		buf[i * 4 + 1] = 0.0;
+		buf[i * 4 + 2] = 0.0;
+		buf[i * 4 + 3] = 0.0;
+	}
+	glBeginConditionalRender(qpass, GL_QUERY_WAIT_INVERTED);
+	glRasterPos2i(-1, -1);
+	glDrawPixels(piglit_width, piglit_height, GL_RGBA, GL_FLOAT, buf);
+	glEndConditionalRender();
+
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      green);
+
+	piglit_present_results();
+
+	glDeleteQueries(1, &qpass);
+	glDeleteQueries(1, &qfail);
+	free(buf);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_gl_version(30);
+
+	piglit_require_extension("GL_ARB_conditional_render_inverted");
+}
diff --git a/tests/spec/arb_conditional_render_inverted/generatemipmap.c b/tests/spec/arb_conditional_render_inverted/generatemipmap.c
new file mode 100644
index 0000000..8332e40
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/generatemipmap.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ * Copyright © 2014 Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file generatemipmap.c
+ *
+ * Tests that conditional rendering does not affect glGenerateMipmap().
+ *
+ * It's something that would be likely to be implemented through
+ * normal rendering inside of the driver, and thus easy to
+ * accidentally disable during conditional rendering.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static void
+fill_level(int level, int size, const GLfloat *color)
+{
+	GLfloat *data;
+	int i;
+
+	data = malloc(size * size * 4 * sizeof(GLfloat));
+	for (i = 0; i < 4 * size * size; i += 4) {
+		data[i + 0] = color[0];
+		data[i + 1] = color[1];
+		data[i + 2] = color[2];
+		data[i + 3] = color[3];
+	}
+        glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, size, size, 0,
+		     GL_RGBA, GL_FLOAT, data);
+	free(data);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	float red[4] = {1.0, 0.0, 0.0, 0.0};
+	float green[4] = {0.0, 1.0, 0.0, 0.0};
+	GLuint q, texture;
+	int tex_size = 64;
+	int i;
+
+	glGenQueries(1, &q);
+	/* Generate query pass: draw bottom half of screen. */
+	glColor4f(0.0, 1.0, 1.0, 0.0);
+	glBeginQuery(GL_SAMPLES_PASSED, q);
+	piglit_draw_rect(-1, -1, 2, 1);
+	glEndQuery(GL_SAMPLES_PASSED);
+	
+	glClearColor(0.5, 0.5, 0.5, 0.5);
+	glClear(GL_COLOR_BUFFER_BIT);
+	
+	/* Set up a texture object with green at level 0, red elsewhere */
+	glGenTextures(1, &texture);
+	glBindTexture(GL_TEXTURE_2D, texture);
+
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+			GL_LINEAR_MIPMAP_NEAREST);
+	glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
+
+	for (i = 0; tex_size / (1 << i) > 0; i++)
+		fill_level(i, tex_size / (1 << i), i == 0 ? green : red);
+
+	/* Mipmap generation should not be affected by inverted conditional rendering. */
+	glBeginConditionalRender(q, GL_QUERY_WAIT_INVERTED);
+	glGenerateMipmapEXT(GL_TEXTURE_2D);
+	glEndConditionalRender();
+
+	/* This should draw level 1, since starting window size is 32
+	 * and texture is 64.
+	 */
+	glEnable(GL_TEXTURE_2D);
+	piglit_draw_rect_tex(-1, -1, 2, 2,
+			     0, 0, 1, 1);
+	glDisable(GL_TEXTURE_2D);
+
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      green);
+
+	piglit_present_results();
+
+	glDeleteQueries(1, &q);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_gl_version(30);
+
+	piglit_require_extension("GL_ARB_conditional_render_inverted");
+	piglit_require_extension("GL_EXT_framebuffer_object");
+}
diff --git a/tests/spec/arb_conditional_render_inverted/vertex_array.c b/tests/spec/arb_conditional_render_inverted/vertex_array.c
new file mode 100644
index 0000000..a399a4d
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/vertex_array.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ * Copyright © 2014 Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file vertex_array.c
+ *
+ * Tests that conditional rendering appropriately affects vertex array
+ * commands.
+ *
+ * From the ARB_conditional_render_inverted:
+ *
+ *     If <mode> is QUERY_WAIT_INVERTED, QUERY_NO_WAIT_INVERTED,
+ *   QUERY_BY_REGION_WAIT_INVERTED, or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   then the condition used to determine whether or not to render subsequent
+ *   drawing commands is negated with respect to QUERY_WAIT, QUERY_NO_WAIT,
+ *   QUERY_BY_REGION_WAIT, or QUERY_BY_REGION_NO_WAIT, respectively. If <mode>
+ *   is QUERY_NO_WAIT_INVERTED or QUERY_BY_REGION_NO_WAIT_INVERTED
+ *   the GL may choose to unconditionally execute the subsequent rendering
+ *   commands without waiting for the query to complete.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	float green[4] = {0.0, 1.0, 0.0, 0.0};
+	GLuint qpass, qfail;
+
+	glClearColor(0.5, 0.5, 0.5, 0.5);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	/* Generate query fail. */
+	glBeginQuery(GL_SAMPLES_PASSED, qfail);
+	glEndQuery(GL_SAMPLES_PASSED);
+	
+	glGenQueries(1, &qpass);
+	/* Generate query pass: draw top half of screen. */
+	glColor4f(0.0, 0.0, 1.0, 0.0);
+	glBeginQuery(GL_SAMPLES_PASSED, qpass);
+	piglit_draw_rect(-1, 0, 2, 1);
+	glEndQuery(GL_SAMPLES_PASSED);
+
+	/* Conditional render that should draw full screen. */
+	glBeginConditionalRender(qfail, GL_QUERY_WAIT_INVERTED);
+	glColor4f(0.0, 1.0, 0.0, 0.0);
+	piglit_draw_rect(-1, -1, 2, 2);
+	glEndConditionalRender();
+
+	/* Conditional render that should not draw full screen. */
+	glBeginConditionalRender(qpass, GL_QUERY_WAIT_INVERTED);
+	glColor4f(1.0, 0.0, 0.0, 0.0);
+	piglit_draw_rect(-1, -1, 2, 2);
+	glEndConditionalRender();
+
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      green);
+
+	piglit_present_results();
+
+	glDeleteQueries(1, &qpass);
+	glDeleteQueries(1, &qfail);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_gl_version(30);
+
+	piglit_require_extension("GL_ARB_conditional_render_inverted");
+}
-- 
1.8.4.5



More information about the Piglit mailing list