[Piglit] [PATCH] Add a test for ARB_map_buffer_alignment
Marek Olšák
maraeo at gmail.com
Sun Oct 28 09:55:51 PDT 2012
---
tests/all.tests | 4 +
tests/spec/CMakeLists.txt | 1 +
.../arb_map_buffer_alignment/CMakeLists.gl.txt | 14 +++
tests/spec/arb_map_buffer_alignment/CMakeLists.txt | 1 +
tests/spec/arb_map_buffer_alignment/sanity_test.c | 91 ++++++++++++++++++++
5 files changed, 111 insertions(+)
create mode 100644 tests/spec/arb_map_buffer_alignment/CMakeLists.gl.txt
create mode 100644 tests/spec/arb_map_buffer_alignment/CMakeLists.txt
create mode 100644 tests/spec/arb_map_buffer_alignment/sanity_test.c
diff --git a/tests/all.tests b/tests/all.tests
index d606a4d..a6e258f 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -2091,6 +2091,10 @@ add_plain_test(sgis_generate_mipmap, 'gen-nonzero-unit')
add_plain_test(sgis_generate_mipmap, 'gen-teximage')
add_plain_test(sgis_generate_mipmap, 'gen-texsubimage')
+arb_map_buffer_alignment = Group()
+spec['ARB_map_buffer_alignment'] = arb_map_buffer_alignment
+add_plain_test(arb_map_buffer_alignment, 'arb_map_buffer_alignment-sanity_test')
+
# group glslparsertest ------------------------------------------------------
glslparsertest = Group()
# Add all shader source files in the directories below.
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index d8796b0..03757ef 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -5,6 +5,7 @@ add_subdirectory (arb_es2_compatibility)
add_subdirectory (arb_framebuffer_object)
add_subdirectory (arb_framebuffer_srgb)
add_subdirectory (arb_instanced_arrays)
+add_subdirectory (arb_map_buffer_alignment)
add_subdirectory (arb_map_buffer_range)
add_subdirectory (arb_multisample)
add_subdirectory (arb_robustness)
diff --git a/tests/spec/arb_map_buffer_alignment/CMakeLists.gl.txt b/tests/spec/arb_map_buffer_alignment/CMakeLists.gl.txt
new file mode 100644
index 0000000..12c73ae
--- /dev/null
+++ b/tests/spec/arb_map_buffer_alignment/CMakeLists.gl.txt
@@ -0,0 +1,14 @@
+include_directories(
+ ${GLEXT_INCLUDE_DIR}
+ ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+ piglitutil_${piglit_target_api}
+ ${OPENGL_gl_LIBRARY}
+ ${OPENGL_glu_LIBRARY}
+)
+
+piglit_add_executable (arb_map_buffer_alignment-sanity_test sanity_test.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/arb_map_buffer_alignment/CMakeLists.txt b/tests/spec/arb_map_buffer_alignment/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_map_buffer_alignment/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_map_buffer_alignment/sanity_test.c b/tests/spec/arb_map_buffer_alignment/sanity_test.c
new file mode 100644
index 0000000..56e3433
--- /dev/null
+++ b/tests/spec/arb_map_buffer_alignment/sanity_test.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright © Marek Olšák <maraeo at gmail.com>
+ *
+ * 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.
+ */
+
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 10;
+
+ config.window_width = 100;
+ config.window_height = 100;
+ config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char *argv[])
+{
+ GLuint b1, b2;
+ uintptr_t ptr;
+ GLint alignment = 0;
+
+ piglit_require_gl_version(15);
+
+ piglit_require_extension("GL_ARB_map_buffer_range");
+ piglit_require_extension("GL_ARB_map_buffer_alignment");
+
+ glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT, &alignment);
+
+ /* Sanity check. */
+ if (alignment < 64) {
+ printf("GL_MIN_MAP_BUFFER_ALIGNMENT must be at least 64.\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ glGenBuffers(1, &b1);
+ glBindBuffer(GL_ARRAY_BUFFER, b1);
+ glBufferData(GL_ARRAY_BUFFER, alignment + 24, NULL, GL_STATIC_DRAW);
+
+ glGenBuffers(1, &b2);
+ glBindBuffer(GL_ARRAY_BUFFER, b2);
+ glBufferData(GL_ARRAY_BUFFER, 1, NULL, GL_STATIC_DRAW);
+
+ /* glMapBufferRange, offset > 0 */
+ glBindBuffer(GL_ARRAY_BUFFER, b1);
+ ptr = (intptr_t)glMapBufferRange(GL_ARRAY_BUFFER, 24, alignment,
+ GL_MAP_READ_BIT | GL_MAP_WRITE_BIT);
+
+ if (ptr && (ptr - 24) % alignment != 0) {
+ printf("glMapBufferRange returned an unaligned pointer.\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ /* glMapBuffer. */
+ glBindBuffer(GL_ARRAY_BUFFER, b2);
+ ptr = (intptr_t)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
+
+ if (ptr % alignment != 0) {
+ printf("glMapBuffer returned an unaligned pointer.\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ piglit_report_result(PIGLIT_PASS);
+}
--
1.7.9.5
More information about the Piglit
mailing list