diff options
author | Anuj Phogat <anuj.phogat@gmail.com> | 2012-11-13 16:01:00 -0800 |
---|---|---|
committer | Anuj Phogat <anuj.phogat@gmail.com> | 2012-11-13 16:49:14 -0800 |
commit | 1bd872a1347bc7ad9a1042c379bd0d0dfe9ace5c (patch) | |
tree | 025ce6f1c254fc60c377bb280197d4d2b2c992c0 | |
parent | c799e84bd5adf397b25658143d11e9b3cd916f31 (diff) |
Add test to verify GL errors in glGenerateMipmap
It does error checking for glGenerateMipmap() with integer and
packed depth-stencil texture internal formats.
V2: Don't test formats which generate no error. They are covered
in other piglit tests.
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r-- | tests/all.tests | 1 | ||||
-rw-r--r-- | tests/spec/gl-3.0/api/CMakeLists.gl.txt | 1 | ||||
-rw-r--r-- | tests/spec/gl-3.0/api/genmipmap-errors.c | 154 |
3 files changed, 156 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests index 70dca352..306473ba 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -676,6 +676,7 @@ add_concurrent_test(gl30, 'clearbuffer-invalid-drawbuffer') add_concurrent_test(gl30, 'clearbuffer-invalid-buffer') add_concurrent_test(gl30, 'clearbuffer-mixed-format') add_concurrent_test(gl30, 'clearbuffer-stencil') +add_concurrent_test(gl30, 'genmipmap-errors') add_concurrent_test(gl30, 'getfragdatalocation') add_concurrent_test(gl30, 'integer-errors') gl30['minmax'] = concurrent_test('gl-3.0-minmax') diff --git a/tests/spec/gl-3.0/api/CMakeLists.gl.txt b/tests/spec/gl-3.0/api/CMakeLists.gl.txt index 7d967897..4d61691a 100644 --- a/tests/spec/gl-3.0/api/CMakeLists.gl.txt +++ b/tests/spec/gl-3.0/api/CMakeLists.gl.txt @@ -19,6 +19,7 @@ piglit_add_executable (clearbuffer-invalid-drawbuffer clearbuffer-invalid-drawbu piglit_add_executable (clearbuffer-invalid-buffer clearbuffer-invalid-buffer.c) piglit_add_executable (clearbuffer-mixed-format clearbuffer-common.c clearbuffer-mixed-format.c) piglit_add_executable (clearbuffer-stencil clearbuffer-common.c clearbuffer-stencil.c) +piglit_add_executable (genmipmap-errors genmipmap-errors.c) piglit_add_executable (getfragdatalocation getfragdatalocation.c) piglit_add_executable (integer-errors integer-errors.c) diff --git a/tests/spec/gl-3.0/api/genmipmap-errors.c b/tests/spec/gl-3.0/api/genmipmap-errors.c new file mode 100644 index 00000000..e3e7ccda --- /dev/null +++ b/tests/spec/gl-3.0/api/genmipmap-errors.c @@ -0,0 +1,154 @@ +/* Copyright 2012 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 genmipmap-errors.c + * Do error checking for glGenerateMipmap() with various texture internal formats. + * GL_INVALID_OPERATION is expected in case of integer or depth-stencil textures. + */ + + +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_ALPHA | PIGLIT_GL_VISUAL_DOUBLE; + +PIGLIT_GL_TEST_CONFIG_END + +/** + * Test textures having integer or depth-stencil internalFormat with + * glGenerateMipmap. GL_INVALID_OPERATION should be thrown by the + * implementation. + */ +static bool +test_genmipmap_errors(void) +{ + GLuint tex; + static const struct { + GLenum intFormat, srcFormat, srcType; + const char *extension[2]; + } formats[] = { + /* Integer internal formats */ + { GL_RGBA8I_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_RGBA16I_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_RGBA32I_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_RGB8I_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_RGB16I_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL } }, + { GL_RGB32I, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_RG32I, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", "GL_ARB_texture_rg"} }, + { GL_R32I, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", "GL_ARB_texture_rg"} }, + { GL_ALPHA8I_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_LUMINANCE8I_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_INTENSITY8I_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_LUMINANCE_ALPHA8I_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + + { GL_RGBA8UI_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_RGBA16UI_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_RGBA32UI_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_RGB8UI_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_RGB16UI_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer" } }, + { GL_RGB32UI_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_RG32UI, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", "GL_ARB_texture_rg"} }, + { GL_R32UI, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", "GL_ARB_texture_rg"} }, + { GL_ALPHA8UI_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_LUMINANCE8UI_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_INTENSITY8UI_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + { GL_LUMINANCE_ALPHA8UI_EXT, GL_RGBA_INTEGER, GL_INT, + {"GL_EXT_texture_integer", NULL} }, + + /* Packed depth / stencil formats */ + { GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, + {NULL, NULL} }, + { GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, + {"GL_ARB_texture_float", NULL} } + }; + int i, j; + bool pass = true; + + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D, tex); + + for (i = 0; i < ARRAY_SIZE(formats); i++) { + + bool is_ext_supported = true; + for (j = 0; j < ARRAY_SIZE(formats[i].extension); j++) { + if ((formats[i].extension[j] != NULL) && + !piglit_is_extension_supported(formats[i].extension[j])) + { + printf("Skipping %s\n", + piglit_get_gl_enum_name(formats[i].intFormat)); + is_ext_supported = false; + } + } + if (!is_ext_supported) + continue; + + glTexImage2D(GL_TEXTURE_2D, 0, formats[i].intFormat, + 16, 16, 0, + formats[i].srcFormat, formats[i].srcType, NULL); + + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + glGenerateMipmap(GL_TEXTURE_2D); + pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + } + glDeleteTextures(1, &tex); + return pass; +} + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_PASS; +} + + +void +piglit_init(int argc, char **argv) +{ + bool pass = test_genmipmap_errors(); + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} |