<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 31, 2015 at 10:26 AM, Fredrik Höglund <span dir="ltr"><<a href="mailto:fredrik@kde.org" target="_blank">fredrik@kde.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This test verifies that glVertexArrayVertexBuffer works as expected.<br>
---<br>
tests/all.py | 1 +<br>
.../spec/arb_direct_state_access/CMakeLists.gl.txt | 1 +<br>
.../arb_direct_state_access/vao-vertex-buffer.c | 140 +++++++++++++++++++++<br>
3 files changed, 142 insertions(+)<br>
create mode 100644 tests/spec/arb_direct_state_access/vao-vertex-buffer.c<br>
<br>
diff --git a/tests/all.py b/tests/all.py<br>
index 6b44069..b972610 100755<br>
--- a/tests/all.py<br>
+++ b/tests/all.py<br>
@@ -4286,6 +4286,7 @@ with profile.group_manager(<br>
g(['arb_direct_state_access-vao-attrib-binding'], 'vao-attrib-binding')<br>
g(['arb_direct_state_access-vao-binding-divisor'], 'vao-binding-divisor')<br>
g(['arb_direct_state_access-vao-element-array-buffer'], 'vao-element-array-buffer')<br>
+ g(['arb_direct_state_access-vao-vertex-buffer'], 'vao-vertex-buffer')<br>
<br>
with profile.group_manager(<br>
PiglitGLTest,<br>
diff --git a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt<br>
index fe17530..820971f 100644<br>
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt<br>
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt<br>
@@ -42,4 +42,5 @@ piglit_add_executable (arb_direct_state_access-vao-attrib-format vao-attrib-form<br>
piglit_add_executable (arb_direct_state_access-vao-attrib-binding vao-attrib-binding.c dsa-utils.c)<br>
piglit_add_executable (arb_direct_state_access-vao-binding-divisor vao-binding-divisor.c dsa-utils.c)<br>
piglit_add_executable (arb_direct_state_access-vao-element-array-buffer vao-element-array-buffer.c)<br>
+piglit_add_executable (arb_direct_state_access-vao-vertex-buffer vao-vertex-buffer.c dsa-utils.c)<br>
# vim: ft=cmake:<br>
diff --git a/tests/spec/arb_direct_state_access/vao-vertex-buffer.c b/tests/spec/arb_direct_state_access/vao-vertex-buffer.c<br>
new file mode 100644<br>
index 0000000..dde03fb<br>
--- /dev/null<br>
+++ b/tests/spec/arb_direct_state_access/vao-vertex-buffer.c<br>
@@ -0,0 +1,140 @@<br>
+/*<br>
+ * Copyright (C) 2015 Fredrik Höglund<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * on the rights to use, copy, modify, merge, publish, distribute, sub<br>
+ * license, and/or sell copies of the Software, and to permit persons to whom<br>
+ * the Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL<br>
+ * THE AUTHORS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,<br>
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR<br>
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE<br>
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
+ */<br>
+<br>
+/**<br>
+ * @file vao-vertex-buffer.c<br>
+ *<br>
+ * Verifies that glVertexArrayVertexBuffer works as expected.<br>
+ */<br>
+<br>
+#include "piglit-util-gl.h"<br>
+#include "dsa-utils.h"<br>
+<br>
+#include <limits.h><br>
+<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+ config.supports_gl_core_version = 31;<br>
+ config.supports_gl_compat_version = 20;<br>
+<br>
+ config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ /* unreached */<br>
+ return PIGLIT_FAIL;<br>
+}<br>
+<br>
+<br>
+void<br>
+piglit_init(int argc, char *argv[])<br>
+{<br>
+ GLuint vao, buffers[4];<br>
+ bool pass = true;<br>
+ int i;<br>
+<br>
+ /* See table 23.55 in the OpenGL 4.5 (Core Profile) spec */<br>
+ GLuint maxStride = 2048;<br>
+ GLuint maxBindings;<br>
+<br>
+ piglit_require_extension("GL_ARB_direct_state_access");<br>
+ piglit_require_extension("GL_ARB_vertex_array_object");<br>
+ piglit_require_extension("GL_ARB_vertex_attrib_binding");<br>
+<br>
+ glGetIntegerv(GL_MAX_VERTEX_ATTRIB_BINDINGS, (GLint *) &maxBindings);<br>
+<br>
+ if (piglit_get_gl_version() >= 44)<br>
+ glGetIntegerv(GL_MAX_VERTEX_ATTRIB_STRIDE, (GLint *) &maxStride);<br>
+<br>
+ /* Create a VAO */<br>
+ glCreateVertexArrays(1, &vao);<br>
+<br>
+ /* Create a set of buffer objects */<br>
+ glCreateBuffers(ARRAY_SIZE(buffers), buffers);<br>
+<br>
+ for (i = 0; i < maxBindings; i++) {<br>
+ const GLintptr offset = rand() % INT_MAX;<br>
+ const GLsizeiptr stride = rand() % (maxStride + 1);<br>
+ const GLuint vbo = buffers[rand() % ARRAY_SIZE(buffers)];<br>
+<br>
+ /* Verify that no VBO is bound by default */<br>
+ pass = check_vbo_binding(vao, i, 0, 0, 16) && pass;<br>
+<br>
+ /* Change the VBO binding and verify that it was changed */<br>
+ glVertexArrayVertexBuffer(vao, i, vbo, offset, stride);<br>
+ pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+ pass = check_vbo_binding(vao, i, vbo, offset, stride) && pass;<br>
+ }<br>
+<br>
+ /* The ARB_direct_state_access specification says:<br>
+ *<br>
+ * "An INVALID_VALUE error is generated if <bindingindex> is greater<br>
+ * than or equal to the value of MAX_VERTEX_ATTRIB_BINDINGS.<br>
+ *<br>
+ * An INVALID_VALUE error is generated if <stride> or <offset> is<br>
+ * negative, or if <stride> is greater than the value of<br>
+ * MAX_VERTEX_ATTRIB_STRIDE."<br>
+ */<br>
+<br>
+ /* bindingindex >= MAX_VERTEX_ATTRIB_BINDINGS */<br>
+ glVertexArrayVertexBuffer(vao, maxBindings, buffers[0], 0, 0);<br>
+ pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;<br>
+<br>
+ /* Negative offset */<br>
+ glVertexArrayVertexBuffer(vao, 0, buffers[0], -1, 0);<br>
+ pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;<br>
+<br>
+ /* Negative stride */<br>
+ glVertexArrayVertexBuffer(vao, 0, buffers[0], 0, -1);<br>
+ pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;<br>
+<br>
+ if (piglit_get_gl_version() >= 44) {<br>
+ /* Stride >= MAX_VERTEX_ATTRIB_STRIDE */<br></blockquote><div>This doesn't match the comment above, which says "greater than" rather than >=. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ glVertexArrayVertexBuffer(vao, 0, buffers[0], 0, maxStride);<br>
+ pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;<br>
+ }<br>
+<br>
+ glDeleteVertexArrays(1, &vao);<br>
+<br>
+ /* The ARB_direct_state_access specification says:<br>
+ *<br>
+ * "An INVALID_OPERATION error is generated by<br>
+ * VertexArrayVertexBuffer if <vaobj> is not<br>
+ * [compatibility profile: zero or] the name of an<br>
+ * existing vertex array object."<br>
+ */<br>
+ glGenVertexArrays(1, &vao);<br>
+ glVertexArrayVertexBuffer(vao, 0, buffers[0], 0, 0);<br>
+ pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;<br>
+ glDeleteVertexArrays(1, &vao);<br>
+<br>
+ glDeleteBuffers(ARRAY_SIZE(buffers), buffers);<br>
+<br>
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);<br>
+}<br>
+<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.4<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div></div>