[Piglit] [PATCH v4] Add tests arb_conditional_render_inverted

Tobias Klausmann tobias.johannes.klausmann at mni.thm.de
Sat Nov 15 19:56:59 PST 2014


Adopted tests from NV_conditional_render

Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
---
V3:
  Rebase on top of current head
V4:
  Run tests without -auto

 tests/all.py                                       |  15 +++
 tests/spec/CMakeLists.txt                          |   1 +
 .../CMakeLists.gl.txt                              |  23 ++++
 .../arb_conditional_render_inverted/CMakeLists.txt |   1 +
 .../begin-while-active.c                           |  75 +++++++++++
 .../arb_conditional_render_inverted/begin-zero.c   |  69 ++++++++++
 .../spec/arb_conditional_render_inverted/bitmap.c  | 110 ++++++++++++++++
 .../blitframebuffer.c                              | 144 +++++++++++++++++++++
 tests/spec/arb_conditional_render_inverted/clear.c | 102 +++++++++++++++
 .../arb_conditional_render_inverted/copypixels.c   | 103 +++++++++++++++
 .../arb_conditional_render_inverted/copyteximage.c | 120 +++++++++++++++++
 .../copytexsubimage.c                              | 120 +++++++++++++++++
 tests/spec/arb_conditional_render_inverted/dlist.c |  98 ++++++++++++++
 .../arb_conditional_render_inverted/drawpixels.c   | 120 +++++++++++++++++
 .../generatemipmap.c                               | 128 ++++++++++++++++++
 .../arb_conditional_render_inverted/vertex_array.c | 101 +++++++++++++++
 16 files changed, 1330 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 f2c5c1f..fba8c23 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3434,6 +3434,21 @@ arb_copy_buffer['overlap'] = PiglitGLTest('arb_copy_buffer-overlap', run_concurr
 arb_copy_buffer['targets'] = PiglitGLTest('arb_copy_buffer-targets', run_concurrent=True)
 arb_copy_buffer['subdata-sync'] = PiglitGLTest('arb_copy_buffer-subdata-sync', run_concurrent=True)
 
+arb_conditional_render_inverted = {}
+spec['ARB_conditional_render_inverted'] = arb_conditional_render_inverted
+add_concurrent_test(arb_conditional_render_inverted, 'arb_conditional_render_inverted-begin-while-active')
+add_concurrent_test(arb_conditional_render_inverted, 'arb_conditional_render_inverted-begin-zero')
+arb_conditional_render_inverted['bitmap'] = PiglitGLTest('arb_conditional_render_inverted-bitmap')
+arb_conditional_render_inverted['blitframebuffer'] = PiglitGLTest('arb_conditional_render_inverted-blitframebuffer')
+arb_conditional_render_inverted['clear'] = PiglitGLTest('arb_conditional_render_inverted-clear')
+arb_conditional_render_inverted['copypixels'] = PiglitGLTest('arb_conditional_render_inverted-copypixels')
+arb_conditional_render_inverted['copyteximage'] = PiglitGLTest('arb_conditional_render_inverted-copyteximage')
+arb_conditional_render_inverted['copytexsubimage'] = PiglitGLTest('arb_conditional_render_inverted-copytexsubimage')
+arb_conditional_render_inverted['dlist'] = PiglitGLTest('arb_conditional_render_inverted-dlist')
+arb_conditional_render_inverted['drawpixels'] = PiglitGLTest('arb_conditional_render_inverted-drawpixels')
+arb_conditional_render_inverted['generatemipmap'] = PiglitGLTest('arb_conditional_render_inverted-generatemipmap')
+arb_conditional_render_inverted['vertex_array'] = PiglitGLTest('arb_conditional_render_inverted-vertex_array')
+
 arb_copy_image = {}
 spec['ARB_copy_image'] = arb_copy_image
 add_concurrent_test(arb_copy_image, 'arb_copy_image-simple --tex-to-tex')
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index b2da115..ea17e3e 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -6,6 +6,7 @@ add_subdirectory (arb_clear_texture)
 add_subdirectory (arb_color_buffer_float)
 add_subdirectory (arb_copy_image)
 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..6df0392
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/begin-while-active.c
@@ -0,0 +1,75 @@
+/*
+ * 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 OpenGL 3.0 spec (page 61):
+ *
+ * "BeginQuery sets the active query object name for the query type given by
+ * <target> to <id>. If BeginQuery is called with an <id> of zero, if the active
+ * query object name for <target> is non-zero, if <id> is the active query
+ * object name for any query type, or if <id> is the active query object for
+ * condtional rendering (see section 2.X), the error INVALID OPERATION is
+ * generated."
+ */
+
+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..cb94526
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/begin-zero.c
@@ -0,0 +1,69 @@
+/*
+ * 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 OpenGL 3.0 spec (page 63):
+ *
+ * "If BeginConditionalRender is called while conditional rendering is in
+ *  progress, or if EndConditionalRender is called while conditional rendering
+ * is not in progress, the error INVALID OPERATION is generated. The error
+ * INVALID VALUE is generated if <id> is not the name of an existing query object
+ * query. The error INVALID OPERATION is generated if <id> is the name of a query
+ * object with a target other than SAMPLES PASSED , or <id> is the name of a
+ * query currently in progress."
+ */
+
+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..edd6ec3
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/bitmap.c
@@ -0,0 +1,110 @@
+/*
+ * 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 OpenGL 3.0 spec (page 62):
+ *
+ * If the result (SAMPLES PASSED) of the query is zero, all rendering commands
+ * between BeginConditionalRender and the corresponding EndConditionalRender
+ * are discarded. In this case, Begin, End, all vertex array commands
+ * performing an implicit Begin and End, Draw-Pixels (see section 3.7.4),
+ * Bitmap (see section 3.8), Clear (see section 4.2.3), Accum (see section
+ * 4.2.4), CopyPixels (see section 4.3.3), and EvalMesh1 and EvalMesh2
+ * (see section 5.1) have no effect."
+ */
+
+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..f86f302
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/blitframebuffer.c
@@ -0,0 +1,144 @@
+/*
+ * 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().
+ *
+ * It is clarified on page 679 of OpenGL 4.4 spec:
+ *    "Added BlitFramebuffer to commands affected by conditional rendering in
+ *     section 10.10 (Bug 9562)."
+ */
+
+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 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..94bdcdd
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/clear.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 clear.c
+ *
+ * Tests that conditional rendering appropriately affects glClear().
+ *
+ * From the OpenGL 3.0 spec (page 62):
+ *
+ * If the result (SAMPLES PASSED) of the query is zero, all rendering commands
+ * between BeginConditionalRender and the corresponding EndConditionalRender
+ * are discarded. In this case, Begin, End, all vertex array commands
+ * performing an implicit Begin and End, Draw-Pixels (see section 3.7.4),
+ * Bitmap (see section 3.8), Clear (see section 4.2.3), Accum (see section
+ * 4.2.4), CopyPixels (see section 4.3.3), and EvalMesh1 and EvalMesh2
+ * (see section 5.1) have no effect."
+ */
+
+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..c991528
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/copypixels.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 copypixels.c
+ *
+ * Tests that conditional rendering appropriately affects glCopyPixels().
+ *
+ * From the OpenGL 3.0 spec (page 62):
+ *
+ * If the result (SAMPLES PASSED) of the query is zero, all rendering commands
+ * between BeginConditionalRender and the corresponding EndConditionalRender
+ * are discarded. In this case, Begin, End, all vertex array commands
+ * performing an implicit Begin and End, Draw-Pixels (see section 3.7.4),
+ * Bitmap (see section 3.8), Clear (see section 4.2.3), Accum (see section
+ * 4.2.4), CopyPixels (see section 4.3.3), and EvalMesh1 and EvalMesh2
+ * (see section 5.1) have no effect."
+ */
+
+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..cb53788
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/copyteximage.c
@@ -0,0 +1,120 @@
+/*
+ * 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().
+ *
+ * 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_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 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..0ea5712
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/copytexsubimage.c
@@ -0,0 +1,120 @@
+/*
+ * 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().
+ *
+ * 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_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 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..9dd18c5
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/drawpixels.c
@@ -0,0 +1,120 @@
+/*
+ * 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 OpenGL 3.0 spec (page 62):
+ *
+ * If the result (SAMPLES PASSED) of the query is zero, all rendering commands
+ * between BeginConditionalRender and the corresponding EndConditionalRender
+ * are discarded. In this case, Begin, End, all vertex array commands
+ * performing an implicit Begin and End, Draw-Pixels (see section 3.7.4),
+ * Bitmap (see section 3.8), Clear (see section 4.2.3), Accum (see section
+ * 4.2.4), CopyPixels (see section 4.3.3), and EvalMesh1 and EvalMesh2
+ * (see section 5.1) have no effect."
+ */
+
+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..75e5953
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/generatemipmap.c
@@ -0,0 +1,128 @@
+/*
+ * 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;
+	config.window_width = 32;
+	config.window_height = 32;
+
+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..89b5cc5
--- /dev/null
+++ b/tests/spec/arb_conditional_render_inverted/vertex_array.c
@@ -0,0 +1,101 @@
+/*
+ * 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 OpenGL 3.0 spec (page 62):
+ *
+ * If the result (SAMPLES PASSED) of the query is zero, all rendering commands
+ * between BeginConditionalRender and the corresponding EndConditionalRender
+ * are discarded. In this case, Begin, End, all vertex array commands
+ * performing an implicit Begin and End, Draw-Pixels (see section 3.7.4),
+ * Bitmap (see section 3.8), Clear (see section 4.2.3), Accum (see section
+ * 4.2.4), CopyPixels (see section 4.3.3), and EvalMesh1 and EvalMesh2
+ * (see section 5.1) have no effect."
+ */
+
+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");
+}
-- 
2.1.3



More information about the Piglit mailing list