[Piglit] [PATCH] spec: add a new arb_mab_buffer_range test case
Ian Romanick
idr at freedesktop.org
Thu Sep 22 15:33:39 PDT 2011
On 09/20/2011 10:32 PM, Yuanhan Liu wrote:
> Currently, this patch contains one simple test case which just care the
> error handling check while calling glMapBufferRange function.
>
> Signed-off-by: Yuanhan Liu<yuanhan.liu at linux.intel.com>
> ---
> tests/all.tests | 4 +
> tests/spec/CMakeLists.txt | 1 +
> tests/spec/arb_map_buffer_range/CMakeLists.gl.txt | 16 +++
> tests/spec/arb_map_buffer_range/CMakeLists.txt | 1 +
> .../map_buffer_range_error_check.c | 135 ++++++++++++++++++++
> 5 files changed, 157 insertions(+), 0 deletions(-)
> create mode 100644 tests/spec/arb_map_buffer_range/CMakeLists.gl.txt
> create mode 100644 tests/spec/arb_map_buffer_range/CMakeLists.txt
> create mode 100644 tests/spec/arb_map_buffer_range/map_buffer_range_error_check.c
>
> diff --git a/tests/all.tests b/tests/all.tests
> index 09146eb..1eb0945 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -1246,6 +1246,10 @@ arb_instanced_arrays = Group()
> spec['ARB_instanced_arrays'] = arb_instanced_arrays
> add_plain_test(arb_instanced_arrays, 'instanced_arrays')
>
> +arb_map_buffer_range = Group()
> +spec['ARB_map_buffer_range'] = arb_map_buffer_range
> +add_plain_test(arb_map_buffer_range, 'map_buffer_range_error_check')
> +
> arb_seamless_cube_map = Group()
> spec['ARB_seamless_cube_map'] = arb_seamless_cube_map
> add_plain_test(arb_seamless_cube_map, 'arb_seamless_cubemap')
> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
> index fb3b1de..e887b68 100644
> --- a/tests/spec/CMakeLists.txt
> +++ b/tests/spec/CMakeLists.txt
> @@ -1,6 +1,7 @@
> add_subdirectory (arb_color_buffer_float)
> add_subdirectory (arb_es2_compatibility)
> add_subdirectory (arb_instanced_arrays)
> +add_subdirectory (arb_map_buffer_range)
> add_subdirectory (arb_robustness)
> add_subdirectory (arb_sampler_objects)
> add_subdirectory (arb_seamless_cube_map)
> diff --git a/tests/spec/arb_map_buffer_range/CMakeLists.gl.txt b/tests/spec/arb_map_buffer_range/CMakeLists.gl.txt
> new file mode 100644
> index 0000000..a44d0ca
> --- /dev/null
> +++ b/tests/spec/arb_map_buffer_range/CMakeLists.gl.txt
> @@ -0,0 +1,16 @@
> +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}
> +)
> +
> +add_executable (map_buffer_range_error_check map_buffer_range_error_check.c)
> +
> +# vim: ft=cmake:
> diff --git a/tests/spec/arb_map_buffer_range/CMakeLists.txt b/tests/spec/arb_map_buffer_range/CMakeLists.txt
> new file mode 100644
> index 0000000..144a306
> --- /dev/null
> +++ b/tests/spec/arb_map_buffer_range/CMakeLists.txt
> @@ -0,0 +1 @@
> +piglit_include_target_api()
> diff --git a/tests/spec/arb_map_buffer_range/map_buffer_range_error_check.c b/tests/spec/arb_map_buffer_range/map_buffer_range_error_check.c
> new file mode 100644
> index 0000000..dc4d171
> --- /dev/null
> +++ b/tests/spec/arb_map_buffer_range/map_buffer_range_error_check.c
> @@ -0,0 +1,135 @@
> +/*
> + * 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.
> + *
> + * Authors:
> + * Yuanhan Liu<yuanhan.liu at linux.intel.com>
> + *
> + */
> +
> +
> +#include "piglit-util.h"
> +
> +int piglit_width = 100, piglit_height = 100;
> +int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> + return PIGLIT_FAIL;
> +}
> +
> +
> +#define check_expected_error(expected) do { \
> + GLenum err = glGetError(); \
> + if (err != expected) { \
> + fprintf(stderr, "%s:%d: Unexpected OpenGL error state: "\
> + "0x%04x, expected 0x%04x\n", \
> + __func__, __LINE__, err, expected); \
> + result = PIGLIT_FAIL; \
> + } \
> + if (ptr) \
> + glUnmapBuffer(target); \
> +} while (0)
piglit_check_gl_error should work for this instead.
> +
> +
> +void
> +piglit_init(int argc, char *argv[])
> +{
> + enum piglit_result result = PIGLIT_PASS;
> + void *ptr;
> + GLenum target = GL_ARRAY_BUFFER;
> + GLbitfield access = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT;
> + GLuint buffer;
> +
> + piglit_require_extension("GL_ARB_map_buffer_range");
> +
> + glGenBuffers(1,&buffer);
> + glBindBuffer(target, buffer);
> + glBufferData(target, 100, NULL, GL_STATIC_DRAW);
> + glGetError();
> +
> + /*
> + * Test cases for checking GL_INVALID_VALUE error
> + *
> + * GL_INVALID_VALUE is generated if either of offset or length is negative,
> + * or if offset + length is greater than the value of GL_BUFFER_SIZE, or if
> + * access has any bits set other than those defined bits.
> + *
> + */
> +
> + /* offset< 0 */
> + ptr = glMapBufferRange(target, -1, 1, access);
> + check_expected_error(GL_INVALID_VALUE);
> +
> + /* length< 0 */
> + ptr = glMapBufferRange(target, 0, -1, access);
> + check_expected_error(GL_INVALID_VALUE);
> +
> + /* offset + lenght> GL_BUFFER_SIZE */
> + ptr = glMapBufferRange(target, 1, GL_BUFFER_SIZE, access);
> + check_expected_error(GL_INVALID_VALUE);
> +
> + /* undefined access bits */
> + ptr = glMapBufferRange(target, 0, 10, 0xffffffff);
> + check_expected_error(GL_INVALID_VALUE);
> +
> +
> + /*
> + * Tests cases for checking GL_INVALID_OPERATION error
> + *
> + * GL_INVALID_OPERATION is generated for any of the following conditions:
> + *
> + * (a) The buffer is already in a mapped state.
> + *
> + * (b) Neither GL_MAP_READ_BIT or GL_MAP_WRITE_BIT is set.
> + *
> + * (c) GL_MAP_READ_BIT is set and any of GL_MAP_INVALIDATE_RANGE_BIT,
> + * GL_MAP_INVALIDATE_BUFFER_BIT, or GL_MAP_UNSYNCHRONIZED_BIT is set.
> + *
> + * (d) GL_MAP_FLUSH_EXPLICIT_BIT is set and GL_MAP_WRITE_BIT is not set.
> + */
> + ptr = glMapBufferRange(target, 0, 10, access);
> + assert(glGetError() == 0);
> +
> + /* (a) map again */
> + ptr = glMapBufferRange(target, 0, 10, access);
> + check_expected_error(GL_INVALID_OPERATION);
> +
> + /* for (b) case */
> + ptr = glMapBufferRange(target, 0, 10, 0);
> + check_expected_error(GL_INVALID_OPERATION);
> +
> + /* for (c) case */
> + ptr = glMapBufferRange(target, 0, 10, GL_MAP_READ_BIT |
> + GL_MAP_INVALIDATE_RANGE_BIT |
> + GL_MAP_INVALIDATE_BUFFER_BIT |
> + GL_MAP_UNSYNCHRONIZED_BIT);
> + check_expected_error(GL_INVALID_OPERATION);
> +
> + /* for (d) case */
> + ptr = glMapBufferRange(target, 0, 10, GL_MAP_FLUSH_EXPLICIT_BIT |
> + GL_MAP_READ_BIT);
> + check_expected_error(GL_INVALID_OPERATION);
> +
> +
> + piglit_report_result(result);
> +}
More information about the Piglit
mailing list