[Piglit] [PATCH 05/15] arb_direct_state_access: Testing NamedBufferSubData.

Laura Ekstrand laura at jlekstrand.net
Fri Jan 23 11:03:29 PST 2015


---
 tests/all.py                                       |   1 +
 .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
 .../namedbuffersubdata-vbo-sync.c                  | 119 +++++++++++++++++++++
 3 files changed, 121 insertions(+)
 create mode 100644 tests/spec/arb_direct_state_access/namedbuffersubdata-vbo-sync.c

diff --git a/tests/all.py b/tests/all.py
index 7ec9d64..69a7cd7 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4423,6 +4423,7 @@ spec['ARB_direct_state_access']['texture-storage-multisample'] = PiglitGLTest(['
 spec['ARB_direct_state_access']['texture-buffer'] = PiglitGLTest(['arb_direct_state_access-texture-buffer'], run_concurrent=True)
 spec['ARB_direct_state_access']['texture-buffer-range'] = PiglitGLTest(['arb_direct_state_access-texture-buffer-range'], run_concurrent=True)
 spec['ARB_direct_state_access']['namedbufferstorage-persistent'] = PiglitGLTest(['arb_direct_state_access-namedbufferstorage-persistent'], run_concurrent=True)
+spec['ARB_direct_state_access']['namedbuffersubdata-vbo-sync'] = PiglitGLTest(['arb_direct_state_access-namedbuffersubdata-vbo-sync'], 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 9228917..eedd60d 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -10,6 +10,7 @@ link_libraries (
 )
 
 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-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/namedbuffersubdata-vbo-sync.c b/tests/spec/arb_direct_state_access/namedbuffersubdata-vbo-sync.c
new file mode 100644
index 0000000..60ebcda
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/namedbuffersubdata-vbo-sync.c
@@ -0,0 +1,119 @@
+/*
+ * 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>
+ *    Eric Anholt <eric at anholt.net>
+ *
+ * Adapted by Laura Ekstrand <laura at jlekstrand.net> to test
+ * NamedBufferSubData, January 2015.
+ */
+
+/** @file namedbuffersubdata-vbo-sync.c
+ *
+ * Test for synchronizing behavior of glNamedBufferSubData.
+ */
+
+#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_require_extension("GL_ARB_vertex_buffer_object");
+	piglit_require_extension("GL_ARB_direct_state_access");
+
+	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+	glCreateBuffers(1, &vbo);
+}
+
+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;
+}
+
+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;
+
+	glNamedBufferData(vbo, 12 * sizeof(GLfloat), varray1,
+			  GL_DYNAMIC_DRAW);
+
+	glBindBuffer(GL_ARRAY_BUFFER, vbo);
+	glEnableClientState(GL_VERTEX_ARRAY);
+	glVertexPointer(3, GL_FLOAT, 0, 0);
+
+	glClear(GL_COLOR_BUFFER_BIT);
+	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+	/* Demonstrate inserting data while not bound */
+	glBindBuffer(GL_ARRAY_BUFFER, 0);
+	glNamedBufferSubData(vbo, 0, 12 * sizeof(GLfloat), varray2);
+	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