diff options
author | Chad Versace <chad.versace@linux.intel.com> | 2011-11-10 10:35:16 -0800 |
---|---|---|
committer | Chad Versace <chad.versace@linux.intel.com> | 2011-11-10 10:35:16 -0800 |
commit | 34a565327bad17fcb1d69d40e14c52d8a1500623 (patch) | |
tree | ec22fd508ebf22a299813f53936ad9abaab463f3 | |
parent | acb99ccdded53fc26a06c04f133ef1cf42a522ef (diff) |
arb_framebuffer_object: Add tests to check GL_DEPTH_STENCIL_ATTACHMENT
Add the following tests:
specs/ARB_framebuffer_object/same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT
specs/ARB_framebuffer_object/same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT
The tests check that if an object is attached to the
GL_DEPTH_STENCIL_ATTACHMENT point, then it is also attached to the
GL_STENCIL_ATTACHMENT and GL_DEPTH_ATTACHMENT points.
v2:
- Make tests run concurrently.
- Move test body from piglit_display() to piglit_init().
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
6 files changed, 294 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests index d428ae4a8..fde99ba1b 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -943,6 +943,12 @@ add_shader_test_dir(arb_draw_instanced, os.path.dirname(__file__) + '/spec/arb_draw_instanced/execution', recursive=True) +# Group ARB_framebuffer_object +arb_framebuffer_object = Group() +spec['ARB_framebuffer_object'] = arb_framebuffer_object +add_concurrent_test(arb_framebuffer_object, 'same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT') +add_concurrent_test(arb_framebuffer_object, 'same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT') + # Group ARB_sampler_objects arb_sampler_objects = Group() spec['ARB_sampler_objects'] = arb_sampler_objects diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt index e625282d1..23893dd15 100644 --- a/tests/spec/CMakeLists.txt +++ b/tests/spec/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory (arb_color_buffer_float) add_subdirectory (arb_es2_compatibility) +add_subdirectory (arb_framebuffer_object) add_subdirectory (arb_instanced_arrays) add_subdirectory (arb_map_buffer_range) add_subdirectory (arb_robustness) diff --git a/tests/spec/arb_framebuffer_object/CMakeLists.gl.txt b/tests/spec/arb_framebuffer_object/CMakeLists.gl.txt new file mode 100644 index 000000000..3b9fec3cc --- /dev/null +++ b/tests/spec/arb_framebuffer_object/CMakeLists.gl.txt @@ -0,0 +1,19 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} + ${GLUT_INCLUDE_DIR} + ${piglit_SOURCE_DIR}/tests/mesa/util + ${piglit_SOURCE_DIR}/tests/util +) + +link_libraries ( + piglitutil + ${OPENGL_gl_LIBRARY} + ${OPENGL_glu_LIBRARY} + ${GLUT_glut_LIBRARY} +) + +add_executable(same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT.c) +add_executable(same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT.c) + +# vim: ft=cmake: diff --git a/tests/spec/arb_framebuffer_object/CMakeLists.txt b/tests/spec/arb_framebuffer_object/CMakeLists.txt new file mode 100644 index 000000000..144a306f4 --- /dev/null +++ b/tests/spec/arb_framebuffer_object/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/arb_framebuffer_object/same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT.c b/tests/spec/arb_framebuffer_object/same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT.c new file mode 100644 index 000000000..d45397cb5 --- /dev/null +++ b/tests/spec/arb_framebuffer_object/same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT.c @@ -0,0 +1,130 @@ +/* + * 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. + */ + +/** + * Attach a renderbuffer to the GL_DEPTH_STENCIL_ATTACHMENT point, then verify + * with glGetFramebufferAttachmentParameteriv() that all three of + * GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT, and GL_DEPTH_STENCIL_ATTACHMENT + * point to the renderbuffer. + */ + +#include <stdio.h> +#include "piglit-util.h" + +int piglit_width = 200; +int piglit_height = 200; +int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB; + +const char* +get_attachment_string(GLint attach) +{ + switch (attach) { + case GL_DEPTH_ATTACHMENT: return "GL_DEPTH_ATTACHMENT"; + case GL_STENCIL_ATTACHMENT: return "GL_STENCIL_ATTACHMENT"; + case GL_DEPTH_STENCIL_ATTACHMENT: return "GL_DEPTH_STENICL"; + default: return NULL; + } +} + +bool +check_attachment(GLenum attach, GLint expect_name) +{ + GLint actual_type; + GLint actual_name; + + glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, + attach, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, + &actual_type); + + if (actual_type != GL_RENDERBUFFER) { + char actual_type_str[16]; + + if (actual_type == GL_NONE) { + sprintf(actual_type_str, "GL_NONE"); + } else { + snprintf(actual_type_str, 16, "0x%x", actual_type); + } + + fprintf(stderr, + "error: expected GL_RENDERBUFFER for %s attachment type, but found %s\n", + get_attachment_string(attach), actual_type_str); + + /* Return now and don't query the attachment name, because + * that would generate a GL error. + */ + return false; + } + + glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, + attach, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, + &actual_name); + + if (actual_name != expect_name) { + fprintf(stderr, + "error: expected %d for %s attachment name, but found %d\n", + expect_name, get_attachment_string(attach), actual_name); + return false; + } + + return true; +} + +enum piglit_result +piglit_display() +{ + /* Never reach here. */ + return PIGLIT_FAIL; +} + +void piglit_init(int argc, char **argv) +{ + bool pass = true; + + GLuint fb; + GLuint rb; + + piglit_require_extension("GL_ARB_framebuffer_object"); + + glGenRenderbuffers(1, &rb); + glGenFramebuffers(1, &fb); + glBindRenderbuffer(GL_RENDERBUFFER, rb); + glBindFramebuffer(GL_FRAMEBUFFER, fb); + + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, 200, 200); + glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, + GL_DEPTH_STENCIL_ATTACHMENT, + GL_RENDERBUFFER, + rb); + + piglit_check_gl_error(0, PIGLIT_FAIL); + + pass = check_attachment(GL_DEPTH_ATTACHMENT, rb) && pass; + pass = check_attachment(GL_STENCIL_ATTACHMENT, rb) && pass; + pass = check_attachment(GL_DEPTH_STENCIL_ATTACHMENT, rb) && pass; + + piglit_check_gl_error(0, PIGLIT_FAIL); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/arb_framebuffer_object/same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT.c b/tests/spec/arb_framebuffer_object/same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT.c new file mode 100644 index 000000000..9dae18b17 --- /dev/null +++ b/tests/spec/arb_framebuffer_object/same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT.c @@ -0,0 +1,137 @@ +/* + * 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. + */ + +/** + * Attach a GL_TEXTURE_2D to the GL_DEPTH_STENCIL_ATTACHMENT point with + * glFramebufferTexture2D(), then verify with + * glGetFramebufferAttachmentParameteriv() that all three of + * GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT, and GL_DEPTH_STENCIL_ATTACHMENT + * point to the texture. + */ + +#include <stdio.h> +#include "piglit-util.h" + +int piglit_width = 200; +int piglit_height = 200; +int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB; + +const char* +get_attachment_string(GLint attach) +{ + switch (attach) { + case GL_DEPTH_ATTACHMENT: return "GL_DEPTH_ATTACHMENT"; + case GL_STENCIL_ATTACHMENT: return "GL_STENCIL_ATTACHMENT"; + case GL_DEPTH_STENCIL_ATTACHMENT: return "GL_DEPTH_STENICL"; + default: return NULL; + } +} + +bool +check_attachment(GLenum attach, GLint expect_name) +{ + GLint actual_type; + GLint actual_name; + + glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, + attach, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, + &actual_type); + + if (actual_type != GL_TEXTURE) { + char actual_type_str[16]; + + if (actual_type == GL_NONE) { + sprintf(actual_type_str, "GL_NONE"); + } else { + snprintf(actual_type_str, 16, "0x%x", actual_type); + } + + fprintf(stderr, + "error: expected GL_TEXTURE for %s attachment type, but found %s\n", + get_attachment_string(attach), actual_type_str); + + /* Return now and don't query the attachment name, because + * that would generate a GL error. + */ + return false; + } + + glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, + attach, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, + &actual_name); + + if (actual_name != expect_name) { + fprintf(stderr, + "error: expected %d for %s attachment name, but found %d\n", + expect_name, get_attachment_string(attach), actual_name); + return false; + } + + return true; +} + +enum piglit_result +piglit_display() +{ +} + +void piglit_init(int argc, char **argv) +{ + bool pass = true; + + GLuint fb; + GLuint tex; + + piglit_require_extension("GL_ARB_framebuffer_object"); + + glGenTextures(1, &tex); + glGenFramebuffers(1, &fb); + glBindTexture(GL_TEXTURE_2D, tex); + glBindFramebuffer(GL_FRAMEBUFFER, fb); + + glTexImage2D(GL_TEXTURE_2D, + 0, /*level*/ + GL_DEPTH_STENCIL, + 200, 200, /*width, height*/ + 0, /*border*/ + GL_DEPTH_STENCIL, + GL_UNSIGNED_INT_24_8, + NULL); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, + GL_DEPTH_STENCIL_ATTACHMENT, + GL_TEXTURE_2D, + tex, + 0); /*level*/ + + piglit_check_gl_error(0, PIGLIT_FAIL); + + pass = check_attachment(GL_DEPTH_ATTACHMENT, tex) && pass; + pass = check_attachment(GL_STENCIL_ATTACHMENT, tex) && pass; + pass = check_attachment(GL_DEPTH_STENCIL_ATTACHMENT, tex) && pass; + + piglit_check_gl_error(0, PIGLIT_FAIL); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} |