[Piglit] [PATCH 1/2] Add tests for NV_conditional_render.
Eric Anholt
eric at anholt.net
Wed Apr 20 10:13:24 PDT 2011
These test that several operations correctly are passed/not passed by
conditional rendering.
---
tests/all.tests | 9 ++
tests/spec/CMakeLists.txt | 1 +
tests/spec/nv_conditional_render/CMakeLists.gl.txt | 20 +++
tests/spec/nv_conditional_render/CMakeLists.txt | 1 +
tests/spec/nv_conditional_render/bitmap.c | 106 +++++++++++++++++
tests/spec/nv_conditional_render/clear.c | 100 ++++++++++++++++
tests/spec/nv_conditional_render/copypixels.c | 103 ++++++++++++++++
tests/spec/nv_conditional_render/drawpixels.c | 117 +++++++++++++++++++
tests/spec/nv_conditional_render/generatemipmap.c | 123 ++++++++++++++++++++
tests/spec/nv_conditional_render/vertex_array.c | 100 ++++++++++++++++
10 files changed, 680 insertions(+), 0 deletions(-)
create mode 100644 tests/spec/nv_conditional_render/CMakeLists.gl.txt
create mode 100644 tests/spec/nv_conditional_render/CMakeLists.txt
create mode 100644 tests/spec/nv_conditional_render/bitmap.c
create mode 100644 tests/spec/nv_conditional_render/clear.c
create mode 100644 tests/spec/nv_conditional_render/copypixels.c
create mode 100644 tests/spec/nv_conditional_render/drawpixels.c
create mode 100644 tests/spec/nv_conditional_render/generatemipmap.c
create mode 100644 tests/spec/nv_conditional_render/vertex_array.c
diff --git a/tests/all.tests b/tests/all.tests
index c909390..095559b 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -975,6 +975,15 @@ nv_texture_barrier = Group()
spec['NV_texture_barrier'] = nv_texture_barrier
add_plain_test(nv_texture_barrier, 'blending-in-shader')
+nv_conditional_render = Group()
+spec['NV_conditional_render'] = nv_conditional_render
+nv_conditional_render['bitmap'] = PlainExecTest(['nv_conditional_render-drawpixels', '-auto'])
+nv_conditional_render['clear'] = PlainExecTest(['nv_conditional_render-clear', '-auto'])
+nv_conditional_render['copypixels'] = PlainExecTest(['nv_conditional_render-copypixels', '-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'])
+
# group glslparsertest ------------------------------------------------------
glslparsertest = Group()
# Add all shader source files in the directories below.
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index c8d7876..333b051 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -7,4 +7,5 @@ add_subdirectory (arb_shader_texture_lod)
add_subdirectory (ati_draw_buffers)
add_subdirectory (ati_envmap_bumpmap)
add_subdirectory (ext_fog_coord)
+add_subdirectory (nv_conditional_render)
add_subdirectory (nv_texture_barrier)
diff --git a/tests/spec/nv_conditional_render/CMakeLists.gl.txt b/tests/spec/nv_conditional_render/CMakeLists.gl.txt
new file mode 100644
index 0000000..c58d7ed
--- /dev/null
+++ b/tests/spec/nv_conditional_render/CMakeLists.gl.txt
@@ -0,0 +1,20 @@
+include_directories(
+ ${OPENGL_INCLUDE_PATH}
+ ${GLUT_INCLUDE_DIR}
+ ${piglit_SOURCE_DIR}/tests/util
+)
+
+link_libraries (
+ piglitutil
+ ${OPENGL_gl_LIBRARY}
+ ${OPENGL_glu_LIBRARY}
+ ${GLUT_glut_LIBRARY}
+ ${TIFF_LIBRARY}
+)
+
+add_executable (nv_conditional_render-bitmap bitmap.c)
+add_executable (nv_conditional_render-clear clear.c)
+add_executable (nv_conditional_render-copypixels copypixels.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/CMakeLists.txt b/tests/spec/nv_conditional_render/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/nv_conditional_render/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/nv_conditional_render/bitmap.c b/tests/spec/nv_conditional_render/bitmap.c
new file mode 100644
index 0000000..118efa6
--- /dev/null
+++ b/tests/spec/nv_conditional_render/bitmap.c
@@ -0,0 +1,106 @@
+/*
+ * 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 bitmap.c
+ *
+ * Tests that conditional rendering appropriately affects glBitmap().
+ *
+ * From the NV_conditional_render spec:
+ *
+ * "If the result (SAMPLES_PASSED) of the query is zero, all
+ * rendering commands between BeginConditionalRenderNV and the
+ * corresponding EndConditionalRenderNV are discarded. In this
+ * case, Begin, End, all vertex array commands performing an
+ * implicit Begin and End, DrawPixels (section 3.6), Bitmap
+ * (section 3.7), Clear (section 4.2.3), Accum (section 4.2.4),
+ * CopyPixels (section 4.3.3), EvalMesh1, and EvalMesh2 (section
+ * 5.1) have no effect."
+ */
+
+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};
+ void *buf;
+ GLuint q;
+
+ 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, &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, 0, 2, 1);
+ glEndQuery(GL_SAMPLES_PASSED);
+
+ /* Conditional render that should draw the whole screen. */
+ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
+ glBitmap(piglit_width, piglit_height, 0, 0, 0, 0, buf);
+ 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);
+ glRasterPos2i(-1, -1);
+ glBitmap(piglit_width, piglit_height, 0, 0, 0, 0, buf);
+ glEndConditionalRenderNV();
+
+ pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+ green);
+
+ glutSwapBuffers();
+
+ glDeleteQueries(1, &q);
+ free(buf);
+
+ 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");
+}
diff --git a/tests/spec/nv_conditional_render/clear.c b/tests/spec/nv_conditional_render/clear.c
new file mode 100644
index 0000000..f2800ac
--- /dev/null
+++ b/tests/spec/nv_conditional_render/clear.c
@@ -0,0 +1,100 @@
+/*
+ * 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 clear.c
+ *
+ * Tests that conditional rendering appropriately affects glClear().
+ *
+ * From the NV_conditional_render spec:
+ *
+ * "If the result (SAMPLES_PASSED) of the query is zero, all
+ * rendering commands between BeginConditionalRenderNV and the
+ * corresponding EndConditionalRenderNV are discarded. In this
+ * case, Begin, End, all vertex array commands performing an
+ * implicit Begin and End, DrawPixels (section 3.6), Bitmap
+ * (section 3.7), Clear (section 4.2.3), Accum (section 4.2.4),
+ * CopyPixels (section 4.3.3), EvalMesh1, and EvalMesh2 (section
+ * 5.1) have no effect."
+ */
+
+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;
+
+ 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, 0, 2, 1);
+ glEndQuery(GL_SAMPLES_PASSED);
+
+ /* Conditional render that should draw bottom half of screen. */
+ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
+ glClearColor(0.0, 1.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ 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);
+ glClearColor(1.0, 0.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ glEndConditionalRenderNV();
+
+ 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");
+}
diff --git a/tests/spec/nv_conditional_render/copypixels.c b/tests/spec/nv_conditional_render/copypixels.c
new file mode 100644
index 0000000..93893b9
--- /dev/null
+++ b/tests/spec/nv_conditional_render/copypixels.c
@@ -0,0 +1,103 @@
+/*
+ * 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 copypixels.c
+ *
+ * Tests that conditional rendering appropriately affects glCopyPixels().
+ *
+ * From the NV_conditional_render spec:
+ *
+ * "If the result (SAMPLES_PASSED) of the query is zero, all
+ * rendering commands between BeginConditionalRenderNV and the
+ * corresponding EndConditionalRenderNV are discarded. In this
+ * case, Begin, End, all vertex array commands performing an
+ * implicit Begin and End, DrawPixels (section 3.6), Bitmap
+ * (section 3.7), Clear (section 4.2.3), Accum (section 4.2.4),
+ * CopyPixels (section 4.3.3), EvalMesh1, and EvalMesh2 (section
+ * 5.1) have no effect."
+ */
+
+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 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. */
+ glBeginConditionalRenderNV(qfail, GL_QUERY_WAIT_NV);
+ glRasterPos2i(-1, 0);
+ glCopyPixels(0, 0, piglit_width, piglit_height / 2, GL_COLOR);
+ glEndConditionalRenderNV();
+
+ /* Conditional render that should copy green over remaining red. */
+ glBeginConditionalRenderNV(qpass, GL_QUERY_WAIT_NV);
+ glRasterPos2i(-1, -1);
+ glCopyPixels(0, piglit_height / 2, piglit_width, piglit_height / 2,
+ GL_COLOR);
+ glEndConditionalRenderNV();
+
+ pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+ green);
+
+ glutSwapBuffers();
+
+ glDeleteQueries(1, &qfail);
+ glDeleteQueries(1, &qpass);
+
+ 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");
+}
diff --git a/tests/spec/nv_conditional_render/drawpixels.c b/tests/spec/nv_conditional_render/drawpixels.c
new file mode 100644
index 0000000..5e14661
--- /dev/null
+++ b/tests/spec/nv_conditional_render/drawpixels.c
@@ -0,0 +1,117 @@
+/*
+ * 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 drawpixels.c
+ *
+ * Tests that conditional rendering appropriately affects glDrawPixels().
+ *
+ * From the NV_conditional_render spec:
+ *
+ * "If the result (SAMPLES_PASSED) of the query is zero, all
+ * rendering commands between BeginConditionalRenderNV and the
+ * corresponding EndConditionalRenderNV are discarded. In this
+ * case, Begin, End, all vertex array commands performing an
+ * implicit Begin and End, DrawPixels (section 3.6), Bitmap
+ * (section 3.7), Clear (section 4.2.3), Accum (section 4.2.4),
+ * CopyPixels (section 4.3.3), EvalMesh1, and EvalMesh2 (section
+ * 5.1) have no effect."
+ */
+
+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};
+ float *buf;
+ int i;
+ GLuint q;
+
+ 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, &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, 0, 2, 1);
+ 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;
+ }
+ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
+ glRasterPos2i(-1, -1);
+ glDrawPixels(piglit_width, piglit_height / 2, GL_RGBA, GL_FLOAT, buf);
+ glEndConditionalRenderNV();
+
+ /* Generate query fail */
+ glBeginQuery(GL_SAMPLES_PASSED, q);
+ glEndQuery(GL_SAMPLES_PASSED);
+
+ /* 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;
+ }
+ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
+ glRasterPos2i(-1, -1);
+ glDrawPixels(piglit_width, piglit_height, GL_RGBA, GL_FLOAT, buf);
+ glEndConditionalRenderNV();
+
+ pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+ green);
+
+ glutSwapBuffers();
+
+ glDeleteQueries(1, &q);
+ free(buf);
+
+ 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");
+}
diff --git a/tests/spec/nv_conditional_render/generatemipmap.c b/tests/spec/nv_conditional_render/generatemipmap.c
new file mode 100644
index 0000000..13a1ff7
--- /dev/null
+++ b/tests/spec/nv_conditional_render/generatemipmap.c
@@ -0,0 +1,123 @@
+/*
+ * 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 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.
+ */
+
+int piglit_width = 32;
+int piglit_height = 32;
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
+
+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;
+
+ 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);
+
+ glGenQueries(1, &q);
+
+ /* Generate query fail. */
+ glBeginQuery(GL_SAMPLES_PASSED, q);
+ glEndQuery(GL_SAMPLES_PASSED);
+
+ /* Mipmap generation should not be affected by conditional rendering. */
+ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
+ glGenerateMipmapEXT(GL_TEXTURE_2D);
+ glEndConditionalRenderNV();
+
+ /* 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);
+
+ 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");
+}
diff --git a/tests/spec/nv_conditional_render/vertex_array.c b/tests/spec/nv_conditional_render/vertex_array.c
new file mode 100644
index 0000000..4de7fa6
--- /dev/null
+++ b/tests/spec/nv_conditional_render/vertex_array.c
@@ -0,0 +1,100 @@
+/*
+ * 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 vertex_array.c
+ *
+ * Tests that conditional rendering appropriately affects vertex array
+ * commands.
+ *
+ * From the NV_conditional_render spec:
+ *
+ * "If the result (SAMPLES_PASSED) of the query is zero, all
+ * rendering commands between BeginConditionalRenderNV and the
+ * corresponding EndConditionalRenderNV are discarded. In this
+ * case, Begin, End, all vertex array commands performing an
+ * implicit Begin and End, DrawPixels (section 3.6), Bitmap
+ * (section 3.7), Clear (section 4.2.3), Accum (section 4.2.4),
+ * CopyPixels (section 4.3.3), EvalMesh1, and EvalMesh2 (section
+ * 5.1) have no effect."
+ */
+
+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;
+
+ 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();
+
+ 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.4.4
More information about the Piglit
mailing list