diff options
author | Laura Ekstrand <laura@jlekstrand.net> | 2015-01-13 16:08:46 -0800 |
---|---|---|
committer | Laura Ekstrand <laura@jlekstrand.net> | 2015-03-09 16:20:43 -0700 |
commit | 3d6c6f02156fe6e26d565f528314258886b9ec2b (patch) | |
tree | 083edc660f23c4f35ffeaa175e1d044672f7722a | |
parent | 7751100fe013d9deb01df64e06f3b5be00f137d4 (diff) |
arb_direct_state_access: Testing glClearNamedBufferData.
-rw-r--r-- | tests/all.py | 1 | ||||
-rw-r--r-- | tests/spec/arb_direct_state_access/CMakeLists.gl.txt | 1 | ||||
-rw-r--r-- | tests/spec/arb_direct_state_access/clearnamedbufferdata-invalid-internal-format.c | 165 |
3 files changed, 167 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py index 733c17c53..11e188d67 100644 --- a/tests/all.py +++ b/tests/all.py @@ -4241,6 +4241,7 @@ with profile.group_manager( g(['arb_direct_state_access-texture-buffer-range'], 'texture-buffer-range') g(['arb_direct_state_access-namedbufferstorage-persistent'], 'namedbufferstorage-persistent') g(['arb_direct_state_access-namedbuffersubdata-vbo-sync'], 'namedbuffersubdata-vbo-sync') + g(['arb_direct_state_access-clearnamedbufferdata-invalid-internal-format'], 'clearnamedbufferdata-invalid-internal-format') with profile.group_manager( PiglitGLTest, diff --git a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt index fef404987..042673a93 100644 --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt @@ -17,6 +17,7 @@ piglit_add_executable (arb_direct_state_access-create-renderbuffers create-rende piglit_add_executable (arb_direct_state_access-namedrenderbuffer namedrenderbuffer.c) piglit_add_executable (arb_direct_state_access-namedbufferstorage-persistent namedbufferstorage.c) piglit_add_executable (arb_direct_state_access-namedbuffersubdata-vbo-sync namedbuffersubdata-vbo-sync.c) +piglit_add_executable (arb_direct_state_access-clearnamedbufferdata-invalid-internal-format clearnamedbufferdata-invalid-internal-format.c) piglit_add_executable (arb_direct_state_access-dsa-textures dsa-textures.c dsa-utils.c) piglit_add_executable (arb_direct_state_access-texturesubimage texturesubimage.c) piglit_add_executable (arb_direct_state_access-bind-texture-unit bind-texture-unit.c) diff --git a/tests/spec/arb_direct_state_access/clearnamedbufferdata-invalid-internal-format.c b/tests/spec/arb_direct_state_access/clearnamedbufferdata-invalid-internal-format.c new file mode 100644 index 000000000..535c48b2b --- /dev/null +++ b/tests/spec/arb_direct_state_access/clearnamedbufferdata-invalid-internal-format.c @@ -0,0 +1,165 @@ +/* + * Copyright © 2014, 2015 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 clearnamedbufferdata-invalid-internal-format.c + * + * From the GL_ARB_clear_buffer_object spec: + * "<internalformat> must be set to one of the format tokens listed in + * Table 3.15, "Internal formats for buffer textures"." + * + * This table only includes a subset of available internal formats. In + * particular, the table does not include: + * -- unsized formats (e.g.: GL_RGBA) + * -- depth or stencil formats + * -- compressed formats + * -- formats with a component with a bitwidth that is not a multiple of 8 + * (e.g.: GL_RGB5_A1). + * -- formats with a total bitwidth that is not a multiple of 32 + * (e.g.: GL_RGB8). + * + * Test that the required GL_INVALID_ENUM error is generated for these formats. + * + * Adapted to test glClearNamedBufferData by Laura Ekstrand + * <laura@jlekstrand.net>, January 2015. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 15; + +PIGLIT_GL_TEST_CONFIG_END + + +static const struct { + GLenum internal_format; + GLenum format; + GLenum type; +} formats[] = { + /* legacy OpenGL 1.0 "formats" */ + {1, GL_ALPHA, GL_UNSIGNED_BYTE}, + {2, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE}, + {3, GL_RGB, GL_UNSIGNED_BYTE}, + {4, GL_RGBA, GL_UNSIGNED_BYTE}, + + /* unsized formats */ + {GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE}, + {GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE}, + {GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE}, + {GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE}, + {GL_INTENSITY, GL_INTENSITY, GL_UNSIGNED_BYTE}, + {GL_RGB, GL_RGB, GL_UNSIGNED_BYTE}, + {GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE}, + + /* depth formats */ + {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT}, + {GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT}, + {GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT}, + + /* component not multiple of 8 bit wide */ + {GL_ALPHA4, GL_ALPHA, GL_UNSIGNED_BYTE}, + {GL_ALPHA12, GL_ALPHA, GL_UNSIGNED_SHORT}, + {GL_LUMINANCE4, GL_LUMINANCE, GL_UNSIGNED_BYTE}, + {GL_LUMINANCE12, GL_LUMINANCE, GL_UNSIGNED_SHORT}, + {GL_LUMINANCE12_ALPHA4, GL_LUMINANCE_ALPHA, GL_UNSIGNED_INT}, + {GL_LUMINANCE12_ALPHA12, GL_LUMINANCE_ALPHA, GL_UNSIGNED_INT}, + {GL_INTENSITY4, GL_INTENSITY, GL_UNSIGNED_BYTE}, + {GL_INTENSITY12, GL_INTENSITY, GL_UNSIGNED_SHORT}, + {GL_R3_G3_B2, GL_RGB, GL_UNSIGNED_BYTE_3_3_2}, + {GL_RGB4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4}, + {GL_RGB5, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1}, + {GL_RGB10, GL_RGB, GL_UNSIGNED_INT_10_10_10_2}, + {GL_RGB12, GL_RGB, GL_UNSIGNED_SHORT}, + {GL_RGBA2, GL_RGBA, GL_UNSIGNED_BYTE}, + {GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4}, + {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1}, + {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_10_10_10_2}, + {GL_RGBA12, GL_RGBA, GL_UNSIGNED_SHORT}, + + /* format not multiple of 32 bit wide */ + {GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE}, + + /* compressed formats */ + {GL_COMPRESSED_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE}, + {GL_COMPRESSED_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE}, + {GL_COMPRESSED_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE}, + {GL_COMPRESSED_INTENSITY, GL_INTENSITY, GL_UNSIGNED_BYTE}, + {GL_COMPRESSED_RGB, GL_RGB, GL_UNSIGNED_BYTE}, + {GL_COMPRESSED_RGBA, GL_RGBA, GL_UNSIGNED_BYTE}, +}; + +static GLuint buffer; + +static bool +test_format(const int i) +{ + printf("Testing %s...\t", + piglit_get_gl_enum_name(formats[i].internal_format)); + + glClearNamedBufferData(buffer, formats[i].internal_format, + formats[i].format, formats[i].type, NULL); + + if (!piglit_check_gl_error(GL_INVALID_ENUM)) { + printf("Failed!\n"); + return false; + } + printf("Passed.\n"); + return true; +} + + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + int i; + const int buffer_size = 3<<20; + + piglit_require_extension("GL_ARB_clear_buffer_object"); + piglit_require_extension("GL_ARB_direct_state_access"); + + glCreateBuffers(1, &buffer); + glNamedBufferData(buffer, buffer_size, NULL, GL_STREAM_READ); + + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + /* Notice that I never bind the buffer. */ + for (i = 0; i < ARRAY_SIZE(formats); ++i) + test_format(i); + + glDeleteBuffers(1, &buffer); + + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} + + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_PASS; +} + |