[Piglit] [PATCH 2/2] spec: add a new arb_map_buffer_range test case
Yuanhan Liu
yuanhan.liu at linux.intel.com
Thu Sep 22 19:34:57 PDT 2011
Currently, this patch contains one simple test case which just care the
error handling check while calling glMapBufferRange function.
v2: suggested by Ian, replace the error check function the one provided
by piglit util help function: piglit_check_gl_error
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 | 123 ++++++++++++++++++++
5 files changed, 145 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 2cce8cc..2fcf8c5 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1248,6 +1248,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 87ec477..62a10c5 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..1ece105
--- /dev/null
+++ b/tests/spec/arb_map_buffer_range/map_buffer_range_error_check.c
@@ -0,0 +1,123 @@
+/*
+ * 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;
+}
+
+
+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);
+ piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+ /* length < 0 */
+ ptr = glMapBufferRange(target, 0, -1, access);
+ piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+ /* offset + lenght > GL_BUFFER_SIZE */
+ ptr = glMapBufferRange(target, 1, GL_BUFFER_SIZE, access);
+ piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+ /* undefined access bits */
+ ptr = glMapBufferRange(target, 0, 10, 0xffffffff);
+ piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+
+ /*
+ * 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);
+ piglit_check_gl_error(GL_INVALID_OPERATION, PIGLIT_FAIL);
+ glUnmapBuffer(target);
+
+ /* for (b) case */
+ ptr = glMapBufferRange(target, 0, 10, 0);
+ piglit_check_gl_error(GL_INVALID_OPERATION, PIGLIT_FAIL);
+
+ /* 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);
+ piglit_check_gl_error(GL_INVALID_OPERATION, PIGLIT_FAIL);
+
+ /* for (d) case */
+ ptr = glMapBufferRange(target, 0, 10, GL_MAP_FLUSH_EXPLICIT_BIT |
+ GL_MAP_READ_BIT);
+ piglit_check_gl_error(GL_INVALID_OPERATION, PIGLIT_FAIL);
+
+
+ piglit_report_result(PIGLIT_PASS);
+}
--
1.7.4.4
More information about the Piglit
mailing list