[Mesa-dev] [PATCH 2/2] ext_packed_depth_stencil/readpixels-24_8: New test for packed fbo readpixels.
Eric Anholt
eric at anholt.net
Wed Jun 15 13:28:20 PDT 2011
The existing glean test only covers window system framebuffers, not an
actual packed depth/stencil FBO like this.
---
tests/all.tests | 1 +
tests/spec/CMakeLists.txt | 1 +
.../ext_packed_depth_stencil/CMakeLists.gl.txt | 17 ++
tests/spec/ext_packed_depth_stencil/CMakeLists.txt | 1 +
.../ext_packed_depth_stencil/readpixels-24_8.c | 162 ++++++++++++++++++++
5 files changed, 182 insertions(+), 0 deletions(-)
create mode 100644 tests/spec/ext_packed_depth_stencil/CMakeLists.gl.txt
create mode 100644 tests/spec/ext_packed_depth_stencil/CMakeLists.txt
create mode 100644 tests/spec/ext_packed_depth_stencil/readpixels-24_8.c
diff --git a/tests/all.tests b/tests/all.tests
index f74b74b..69c6477 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -881,6 +881,7 @@ add_fbo_depth_test(ext_packed_depth_stencil, 'GL_DEPTH24_STENCIL8')
add_fbo_generatemipmap_extension(ext_packed_depth_stencil, 'GL_EXT_packed_depth_stencil', 'fbo-generatemipmap-formats')
add_fbo_clear_extension(ext_packed_depth_stencil, 'GL_EXT_packed_depth_stencil', 'fbo-clear-formats')
add_texwrap_test2(ext_packed_depth_stencil, '2D', 'GL_DEPTH24_STENCIL8')
+ext_packed_depth_stencil['readpixels-24_8'] = PlainExecTest(['ext_packed_depth_stencil-readpixels-24_8', '-auto'])
ext_texture_compression_latc = Group()
spec['EXT_texture_compression_latc'] = ext_texture_compression_latc
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 3b57487..e17a09a 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -10,6 +10,7 @@ add_subdirectory (ati_draw_buffers)
add_subdirectory (arb_texture_float)
add_subdirectory (ati_envmap_bumpmap)
add_subdirectory (ext_fog_coord)
+add_subdirectory (ext_packed_depth_stencil)
add_subdirectory (nv_conditional_render)
add_subdirectory (nv_texture_barrier)
add_subdirectory (arb_draw_elements_base_vertex)
diff --git a/tests/spec/ext_packed_depth_stencil/CMakeLists.gl.txt b/tests/spec/ext_packed_depth_stencil/CMakeLists.gl.txt
new file mode 100644
index 0000000..7fd1cc1
--- /dev/null
+++ b/tests/spec/ext_packed_depth_stencil/CMakeLists.gl.txt
@@ -0,0 +1,17 @@
+include_directories(
+ ${GLEXT_INCLUDE_DIR}
+ ${OPENGL_INCLUDE_PATH}
+ ${GLUT_INCLUDE_DIR}
+ ${piglit_SOURCE_DIR}/tests/util
+)
+
+link_libraries (
+ piglitutil
+ ${OPENGL_gl_LIBRARY}
+ ${OPENGL_glu_LIBRARY}
+ ${GLUT_glut_LIBRARY}
+)
+
+add_executable (ext_packed_depth_stencil-readpixels-24_8 readpixels-24_8.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/ext_packed_depth_stencil/CMakeLists.txt b/tests/spec/ext_packed_depth_stencil/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/ext_packed_depth_stencil/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/ext_packed_depth_stencil/readpixels-24_8.c b/tests/spec/ext_packed_depth_stencil/readpixels-24_8.c
new file mode 100644
index 0000000..2e8c7a8
--- /dev/null
+++ b/tests/spec/ext_packed_depth_stencil/readpixels-24_8.c
@@ -0,0 +1,162 @@
+/*
+ * 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.
+ */
+
+/** @file fbo-readpixels-depth-formats.c
+ *
+ * Tests that various formats of depth renderbuffers can be read
+ * correctly using glReadPixels() with various format/type
+ * combinations.
+ */
+
+#include "piglit-util.h"
+
+#define BUF_WIDTH 15
+#define BUF_HEIGHT 15
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
+int piglit_width = BUF_WIDTH;
+int piglit_height = BUF_WIDTH;
+
+/* Width of our stripes of z = 0.0, 0.5, 1.0 */
+static int w = BUF_WIDTH / 3;
+
+int depth_bits;
+
+static bool
+test_pixel(int x, int y, uint32_t value)
+{
+ uint32_t expected;
+
+ if (x < w)
+ expected = 0x00000000;
+ else if (x < w * 2)
+ expected = 0x80000001;
+ else
+ expected = 0xffffff02;
+
+ if (value - expected != 0) {
+ fprintf(stderr,
+ "Expected 0x%08x at (%d,%d), found 0x%08x\n",
+ expected, x, y, value);
+ return false;
+ }
+
+ return true;
+}
+
+static bool
+test()
+{
+ GLuint tex, fb;
+ GLenum status;
+ bool pass = true;
+ uint32_t values[BUF_WIDTH * BUF_HEIGHT];
+ int x, y;
+
+ glGenFramebuffersEXT(1, &fb);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, fb);
+ assert(glGetError() == 0);
+
+ glGenTexturesEXT(1, &tex);
+ glBindTexture(GL_TEXTURE_2D, tex);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8,
+ BUF_WIDTH, BUF_HEIGHT, 0,
+ GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
+ GL_DEPTH_ATTACHMENT_EXT,
+ GL_TEXTURE_2D,
+ tex,
+ 0);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
+ GL_STENCIL_ATTACHMENT_EXT,
+ GL_TEXTURE_2D,
+ tex,
+ 0);
+
+ glDrawBuffer(GL_NONE);
+ glReadBuffer(GL_NONE);
+
+ status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER);
+ if (status != GL_FRAMEBUFFER_COMPLETE) {
+ fprintf(stderr, "framebuffer incomplete\n");
+ goto done;
+ }
+
+ glGetIntegerv(GL_DEPTH_BITS, &depth_bits);
+
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_ALWAYS);
+
+ glEnable(GL_STENCIL_TEST);
+ glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+
+ glViewport(0, 0, BUF_WIDTH, BUF_HEIGHT);
+ piglit_ortho_projection(BUF_WIDTH, BUF_HEIGHT, false);
+ glStencilFunc(GL_ALWAYS, 0, ~0);
+ piglit_draw_rect_z(1.0, 0, 0, w, BUF_HEIGHT);
+ glStencilFunc(GL_ALWAYS, 1, ~0);
+ piglit_draw_rect_z(0.0, w, 0, w * 2, BUF_HEIGHT);
+ glStencilFunc(GL_ALWAYS, 2, ~0);
+ piglit_draw_rect_z(-1.0, w * 2, 0, w * 3, BUF_HEIGHT);
+
+ glReadPixels(0, 0, BUF_WIDTH, BUF_HEIGHT,
+ GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, values);
+
+ for (y = 0; y < BUF_HEIGHT; y++) {
+ for (x = 0; x < BUF_WIDTH; x++) {
+ if (!test_pixel(x, y, values[y * BUF_WIDTH + x])) {
+ pass = false;
+ break;
+ }
+ }
+ if (x != BUF_WIDTH)
+ break;
+
+ }
+
+done:
+ glDeleteFramebuffersEXT(1, &fb);
+ glDeleteTextures(1, &tex);
+ return pass;
+}
+
+void piglit_init(int argc, char **argv)
+{
+ bool pass = true;
+
+ piglit_require_extension("GL_EXT_framebuffer_object");
+ piglit_require_extension("GL_EXT_packed_depth_stencil");
+
+ pass = test();
+
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ /* UNREACHED */
+ return PIGLIT_FAIL;
+}
--
1.7.5.3
More information about the mesa-dev
mailing list