[Piglit] [PATCH 4/4] nv_conditional_render: Add some more tests of API implementation.

Eric Anholt eric at anholt.net
Thu Sep 8 23:07:40 PDT 2011


---
 tests/all.tests                                    |    1 +
 tests/spec/nv_conditional_render/CMakeLists.gl.txt |    3 +
 .../nv_conditional_render/begin-while-active.c     |   73 +++++++++++++++
 tests/spec/nv_conditional_render/begin-zero.c      |   67 ++++++++++++++
 tests/spec/nv_conditional_render/dlist.c           |   95 ++++++++++++++++++++
 5 files changed, 239 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/nv_conditional_render/begin-while-active.c
 create mode 100644 tests/spec/nv_conditional_render/begin-zero.c
 create mode 100644 tests/spec/nv_conditional_render/dlist.c

diff --git a/tests/all.tests b/tests/all.tests
index cbd40d0..cd257a3 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1270,6 +1270,7 @@ nv_conditional_render['clear'] = PlainExecTest(['nv_conditional_render-clear', '
 nv_conditional_render['copypixels'] = PlainExecTest(['nv_conditional_render-copypixels', '-auto'])
 nv_conditional_render['copyteximage'] = PlainExecTest(['nv_conditional_render-copyteximage', '-auto'])
 nv_conditional_render['copytexsubimage'] = PlainExecTest(['nv_conditional_render-copytexsubimage', '-auto'])
+nv_conditional_render['dlist'] = PlainExecTest(['nv_conditional_render-dlist', '-auto'])
 nv_conditional_render['drawpixels'] = PlainExecTest(['nv_conditional_render-drawpixels', '-auto'])
 nv_conditional_render['generatemipmap'] = PlainExecTest(['nv_conditional_render-generatemipmap', '-auto'])
 nv_conditional_render['vertex_array'] = PlainExecTest(['nv_conditional_render-vertex_array', '-auto'])
diff --git a/tests/spec/nv_conditional_render/CMakeLists.gl.txt b/tests/spec/nv_conditional_render/CMakeLists.gl.txt
index 39f23d5..175c5aa 100644
--- a/tests/spec/nv_conditional_render/CMakeLists.gl.txt
+++ b/tests/spec/nv_conditional_render/CMakeLists.gl.txt
@@ -11,12 +11,15 @@ link_libraries (
 	${GLUT_glut_LIBRARY}
 )
 
+add_executable (nv_conditional_render-begin-while-active begin-while-active.c)
+add_executable (nv_conditional_render-begin-zero begin-zero.c)
 add_executable (nv_conditional_render-bitmap bitmap.c)
 add_executable (nv_conditional_render-blitframebuffer blitframebuffer.c)
 add_executable (nv_conditional_render-clear clear.c)
 add_executable (nv_conditional_render-copypixels copypixels.c)
 add_executable (nv_conditional_render-copyteximage copyteximage.c)
 add_executable (nv_conditional_render-copytexsubimage copytexsubimage.c)
+add_executable (nv_conditional_render-dlist dlist.c)
 add_executable (nv_conditional_render-drawpixels drawpixels.c)
 add_executable (nv_conditional_render-generatemipmap generatemipmap.c)
 add_executable (nv_conditional_render-vertex_array vertex_array.c)
diff --git a/tests/spec/nv_conditional_render/begin-while-active.c b/tests/spec/nv_conditional_render/begin-while-active.c
new file mode 100644
index 0000000..9da03c8
--- /dev/null
+++ b/tests/spec/nv_conditional_render/begin-while-active.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util.h"
+
+/**
+ * @file begin-while-active.c
+ *
+ * Tests that starting conditional rendering on a query object that is
+ * active results in INVALID_OPERATION.
+ *
+ * From the NV_conditional_render spec:
+ *
+ *     "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 (Section 2.X), the error INVALID
+ *      OPERATION is generated."
+ */
+
+int piglit_width = 32;
+int piglit_height = 32;
+int piglit_window_mode = GLUT_RGB | GLUT_ALPHA;
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint q;
+
+	if (!GLEW_VERSION_2_0) {
+		printf("Requires OpenGL 2.0\n");
+		piglit_report_result(PIGLIT_SKIP);
+	}
+
+	piglit_require_extension("GL_NV_conditional_render");
+
+	glGenQueries(1, &q);
+	glBeginQuery(GL_SAMPLES_PASSED, q);
+	glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
+	piglit_check_gl_error(GL_INVALID_OPERATION, PIGLIT_FAIL);
+	glEndQuery(GL_SAMPLES_PASSED);
+	glDeleteQueries(1, &q);
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/nv_conditional_render/begin-zero.c b/tests/spec/nv_conditional_render/begin-zero.c
new file mode 100644
index 0000000..255887f
--- /dev/null
+++ b/tests/spec/nv_conditional_render/begin-zero.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util.h"
+
+/**
+ * @file begin-zero.c
+ *
+ * Tests that starting conditional rendering on a 0 query object
+ * results in INVALID_OPERATION.
+ *
+ * From the NV_conditional_render spec:
+ *
+ *     "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 (Section 2.X), the error INVALID
+ *      OPERATION is generated."
+ */
+
+int piglit_width = 32;
+int piglit_height = 32;
+int piglit_window_mode = GLUT_RGB | GLUT_ALPHA;
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	if (!GLEW_VERSION_2_0) {
+		printf("Requires OpenGL 2.0\n");
+		piglit_report_result(PIGLIT_SKIP);
+	}
+
+	piglit_require_extension("GL_NV_conditional_render");
+
+	glBeginConditionalRenderNV(0, GL_QUERY_WAIT_NV);
+	piglit_check_gl_error(GL_INVALID_OPERATION, PIGLIT_FAIL);
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/nv_conditional_render/dlist.c b/tests/spec/nv_conditional_render/dlist.c
new file mode 100644
index 0000000..b640f35
--- /dev/null
+++ b/tests/spec/nv_conditional_render/dlist.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util.h"
+
+/**
+ * @file dlist.c
+ *
+ * Tests that conditional rendering appropriately affects commands
+ * inside of display lists.
+ */
+
+int piglit_width = 32;
+int piglit_height = 32;
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	float green[4] = {0.0, 1.0, 0.0, 0.0};
+	GLuint q;
+	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, &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);
+
+	/* Conditional render that should draw top half of screen. */
+	glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
+	piglit_draw_rect(-1, 0, 2, 1);
+	glEndConditionalRenderNV();
+
+	/* Generate query fail */
+	glBeginQuery(GL_SAMPLES_PASSED, q);
+	glEndQuery(GL_SAMPLES_PASSED);
+
+	/* Conditional render that should not draw full screen. */
+	glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
+	glColor4f(1.0, 0.0, 0.0, 0.0);
+	piglit_draw_rect(-1, -1, 2, 2);
+	glEndConditionalRenderNV();
+	glEndList();
+
+	glCallList(list);
+
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      green);
+
+	glutSwapBuffers();
+
+	glDeleteQueries(1, &q);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	if (!GLEW_VERSION_2_0) {
+		printf("Requires OpenGL 2.0\n");
+		piglit_report_result(PIGLIT_SKIP);
+	}
+
+	piglit_require_extension("GL_NV_conditional_render");
+}
-- 
1.7.5.4



More information about the Piglit mailing list