[Piglit] [PATCH 11/15] arb_direct_state_access: Testing UnmapNamedBuffer.
Laura Ekstrand
laura at jlekstrand.net
Fri Jan 23 11:03:35 PST 2015
---
tests/all.py | 1 +
.../spec/arb_direct_state_access/CMakeLists.gl.txt | 1 +
.../mapnamedbuffer-pbo-readpixels.c | 6 +-
.../arb_direct_state_access/unmapnamedbuffer-vbo.c | 128 +++++++++++++++++++++
4 files changed, 133 insertions(+), 3 deletions(-)
create mode 100644 tests/spec/arb_direct_state_access/unmapnamedbuffer-vbo.c
diff --git a/tests/all.py b/tests/all.py
index 76c4070..e7d0843 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4427,6 +4427,7 @@ spec['ARB_direct_state_access']['namedbuffersubdata-vbo-sync'] = PiglitGLTest(['
spec['ARB_direct_state_access']['clearnamedbufferdata-invalid-internal-format'] = PiglitGLTest(['arb_direct_state_access-clearnamedbufferdata-invalid-internal-format'], run_concurrent=True)
spec['ARB_direct_state_access']['clearnamedbuffersubdata-invalid-size'] = PiglitGLTest(['arb_direct_state_access-clearnamedbuffersubdata-invalid-size'], run_concurrent=True)
spec['ARB_direct_state_access']['mapnamedbuffer-pbo-readpixels'] = PiglitGLTest(['arb_direct_state_access-mapnamedbuffer-pbo-readpixels'], run_concurrent=True)
+spec['ARB_direct_state_access']['unmapnamedbuffer-vbo'] = PiglitGLTest(['arb_direct_state_access-unmapnamedbuffer-vbo'], run_concurrent=True)
profile.tests['hiz'] = hiz
profile.tests['fast_color_clear'] = fast_color_clear
diff --git a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
index 37396e4..d0b92aa 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -14,6 +14,7 @@ piglit_add_executable (arb_direct_state_access-namedbuffersubdata-vbo-sync named
piglit_add_executable (arb_direct_state_access-clearnamedbufferdata-invalid-internal-format clearnamedbufferdata-invalid-internal-format.c)
piglit_add_executable (arb_direct_state_access-clearnamedbuffersubdata-invalid-size clearnamedbuffersubdata-invalid-size.c)
piglit_add_executable (arb_direct_state_access-mapnamedbuffer-pbo-readpixels mapnamedbuffer-pbo-readpixels.c)
+piglit_add_executable (arb_direct_state_access-unmapnamedbuffer-vbo unmapnamedbuffer-vbo.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/mapnamedbuffer-pbo-readpixels.c b/tests/spec/arb_direct_state_access/mapnamedbuffer-pbo-readpixels.c
index 6e94a96..cf7fc6f 100644
--- a/tests/spec/arb_direct_state_access/mapnamedbuffer-pbo-readpixels.c
+++ b/tests/spec/arb_direct_state_access/mapnamedbuffer-pbo-readpixels.c
@@ -87,21 +87,21 @@ piglit_display(void)
pass &= probe(1, 0, 0x0000ff00, addr[1]);
pass &= probe(0, 1, 0x000000ff, addr[2]);
pass &= probe(1, 1, 0x000000ff, addr[3]);
- glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
+ glUnmapNamedBuffer(pbo);
/* Read with an offset. */
glReadPixels(1, 0, 1, 1,
GL_BGRA, GL_UNSIGNED_BYTE, (void *)(uintptr_t)4);
addr = glMapNamedBuffer(pbo, GL_READ_ONLY);
pass &= probe(1, 0, 0x0000ff00, addr[1]);
- glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
+ glUnmapNamedBuffer(pbo);
/* Read with an offset. */
glReadPixels(1, 1, 1, 1,
GL_BGRA, GL_UNSIGNED_BYTE, (void *)(uintptr_t)4);
addr = glMapNamedBuffer(pbo, GL_READ_ONLY);
pass &= probe(1, 1, 0x000000ff, addr[1]);
- glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
+ glUnmapNamedBuffer(pbo);
piglit_present_results();
diff --git a/tests/spec/arb_direct_state_access/unmapnamedbuffer-vbo.c b/tests/spec/arb_direct_state_access/unmapnamedbuffer-vbo.c
new file mode 100644
index 0000000..eac88ae
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/unmapnamedbuffer-vbo.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright © 2009, 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.
+ *
+ * Authors:
+ * Ben Holmes <shranzel at hotmail.com>
+ *
+ * Adapted to test glUnmapNamedBuffer by Laura Ekstrand
+ * <laura at jlekstrand.net>, January 2015
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 10;
+
+ config.window_width = 400;
+ config.window_height = 300;
+ config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static GLuint vbo;
+#define RECT_WIDTH 200
+#define RECT_HEIGHT 150
+
+void
+piglit_init(int argc, char **argv)
+{
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+ piglit_require_extension("GL_ARB_vertex_buffer_object");
+ piglit_require_extension("GL_ARB_direct_state_access");
+
+ glCreateBuffers(1, &vbo);
+ glNamedBufferData(vbo, 12 * sizeof(GLfloat), NULL, GL_DYNAMIC_DRAW);
+}
+
+static void
+verify_rect(GLboolean *pass, int hpos, int vpos, const float *expected)
+{
+ *pass = piglit_probe_rect_rgb(hpos * RECT_WIDTH, vpos * RECT_HEIGHT,
+ RECT_WIDTH, RECT_HEIGHT,
+ expected) && *pass;
+}
+
+static void
+vbo_write_floats_mapped(const float *varray, size_t count)
+{
+ float *ptr = glMapNamedBuffer(vbo, GL_WRITE_ONLY);
+
+ if (ptr == NULL)
+ piglit_report_result(PIGLIT_FAIL);
+
+ memcpy(ptr, varray, count * sizeof(GLfloat));
+
+ if (!glUnmapNamedBuffer(vbo))
+ piglit_report_result(PIGLIT_FAIL);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ GLfloat white[4] = {1.0, 1.0, 1.0, 0.0};
+ GLfloat black[4] = {0.0, 0.0, 0.0, 0.0};
+ GLboolean pass = GL_TRUE;
+ GLfloat varray1[12] = {1 * RECT_WIDTH, 0 * RECT_HEIGHT, 0,
+ 1 * RECT_WIDTH, 1 * RECT_HEIGHT, 0,
+ 0 * RECT_WIDTH, 0 * RECT_HEIGHT, 0,
+ 0 * RECT_WIDTH, 1 * RECT_HEIGHT, 0};
+ GLfloat varray2[12] = {2 * RECT_WIDTH, 1 * RECT_HEIGHT, 0,
+ 2 * RECT_WIDTH, 2 * RECT_HEIGHT, 0,
+ 1 * RECT_WIDTH, 1 * RECT_HEIGHT, 0,
+ 1 * RECT_WIDTH, 2 * RECT_HEIGHT, 0};
+ GLenum err;
+
+ glBindBuffer(GL_ARRAY_BUFFER, vbo);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(3, GL_FLOAT, 0, 0);
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ vbo_write_floats_mapped(varray1, 12);
+ glBindBuffer(GL_ARRAY_BUFFER, vbo);
+
+ glClear(GL_COLOR_BUFFER_BIT);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ vbo_write_floats_mapped(varray2, 12);
+ glBindBuffer(GL_ARRAY_BUFFER, vbo);
+
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ if ((err = glGetError()) != 0) {
+ printf("gl error: 0x%08x\n", err);
+ pass = GL_FALSE;
+ }
+
+ verify_rect(&pass, 0, 0, white);
+ verify_rect(&pass, 1, 0, black);
+ verify_rect(&pass, 1, 1, white);
+ verify_rect(&pass, 0, 1, black);
+
+ piglit_present_results();
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
--
2.1.0
More information about the Piglit
mailing list