<div dir="ltr"><div>The v2 on your Freedesktop looks good.<br><br></div>Reviewed-by: Laura Ekstrand <<a href="mailto:laura@jlekstrand.net">laura@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 1, 2015 at 6:02 PM, Laura Ekstrand <span dir="ltr"><<a href="mailto:laura@jlekstrand.net" target="_blank">laura@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">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 glVertexArrayVertexBuffers 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-buffers.c   | 351 +++++++++++++++++++++<br>
 3 files changed, 353 insertions(+)<br>
 create mode 100644 tests/spec/arb_direct_state_access/vao-vertex-buffers.c<br>
<br>
diff --git a/tests/all.py b/tests/all.py<br>
index b972610..d0730d4 100755<br>
--- a/tests/all.py<br>
+++ b/tests/all.py<br>
@@ -4287,6 +4287,7 @@ with profile.group_manager(<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>
+    g(['arb_direct_state_access-vao-vertex-buffers'], 'vao-vertex-buffers')<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 820971f..41e5c46 100644<br>
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt<br>
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt<br>
@@ -43,4 +43,5 @@ piglit_add_executable (arb_direct_state_access-vao-attrib-binding vao-attrib-bin<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>
+piglit_add_executable (arb_direct_state_access-vao-vertex-buffers vao-vertex-buffers.c dsa-utils.c)<br>
 # vim: ft=cmake:<br>
diff --git a/tests/spec/arb_direct_state_access/vao-vertex-buffers.c b/tests/spec/arb_direct_state_access/vao-vertex-buffers.c<br>
new file mode 100644<br>
index 0000000..6c47376<br>
--- /dev/null<br>
+++ b/tests/spec/arb_direct_state_access/vao-vertex-buffers.c<br>
@@ -0,0 +1,351 @@<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-buffers.c<br>
+ *<br>
+ * Verifies that glVertexArrayVertexBuffers 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>
+/**<br>
+ * Returns vertex buffer bindings first through first+count<br>
+ * in the buffers, offsets and strides parameters.<br>
+ */<br>
+static void<br>
+get_vbo_bindings(GLuint vao, GLuint first, GLuint count,<br>
+                 GLuint *buffers, GLintptr *offsets, GLsizei *strides)<br>
+{<br>
+       GLuint i;<br>
+<br>
+       for (i = 0; i < count; i++) {<br>
+               GLuint buffer, offset, stride;<br>
+               glGetVertexArrayIndexediv(vao, first + i,<br>
+                                         GL_VERTEX_BINDING_BUFFER,<br>
+                                         (GLint *) &buffer);<br>
+               glGetVertexArrayIndexediv(vao, first + i,<br>
+                                         GL_VERTEX_BINDING_OFFSET,<br>
+                                         (GLint *) &offset);<br>
+               glGetVertexArrayIndexediv(vao, first + i,<br>
+                                         GL_VERTEX_BINDING_STRIDE,<br>
+                                         (GLint *) &stride);<br>
+<br>
+               buffers[i] = buffer;<br>
+               offsets[i] = offset;<br>
+               strides[i] = stride;<br>
+       }<br>
+}<br>
+<br>
+<br>
+/**<br>
+ * Returns true if vertex buffer bindings first through first+count match<br>
+ * the values in buffers, offsets and strides, and false otherwise.<br>
+ */<br>
+static bool<br>
+check_vbo_bindings_(GLuint vao, GLuint first, GLsizei count,<br>
+                    const GLuint *buffers, const GLintptr *offsets,<br>
+                    const GLsizei *strides, int line)<br>
+{<br>
+       bool pass = true;<br>
+       int i;<br>
+<br>
+       for (i = 0; i < count; i++)<br>
+               pass = check_vbo_binding_(vao, first + i,<br>
+                                         buffers[i], offsets[i], strides[i],<br>
+                                         __FILE__, line) && pass;<br>
+<br>
+       return pass;<br>
+}<br>
+<br>
+<br>
+#define check_vbo_bindings(vao, first, count, buffers, offsets, strides) \<br>
+       check_vbo_bindings_(vao, first, count, buffers, offsets, strides, \<br>
+                           __LINE__)<br>
+<br>
+<br>
+/**<br>
+ * Returns true if vertex buffer bindings first through first+count are<br>
+ * set to their default values, and false otherwise.<br>
+ */<br>
+static bool<br>
+check_vbo_bindings_default_(GLuint vao, GLuint first, GLsizei count, int line)<br>
+{<br>
+       bool pass = true;<br>
+       int i;<br>
+<br>
+       for (i = first; i < first + count; i++)<br>
+               pass = check_vbo_binding_(vao, i, 0, 0, 16,<br>
+                                         __FILE__, line) && pass;<br>
+<br>
+       return pass;<br>
+}<br>
+<br>
+<br>
+#define check_vbo_bindings_default(vao, first, count) \<br>
+       check_vbo_bindings_default_(vao, first, count, __LINE__)<br>
+<br>
+<br>
+static GLuint validBuffers[10];<br>
+static GLuint maxStride;<br>
+<br>
+<br>
+/**<br>
+ * Generates count number of random buffer, offset and strides values,<br>
+ * storing the results in buffers, offsets and strides respectively.<br>
+ *<br>
+ * All generated values are valid.<br>
+ */<br>
+static void<br>
+generate_random_values(int count, GLuint *buffers,<br>
+                       GLintptr *offsets, GLsizei *strides)<br>
+{<br>
+       int i;<br>
+<br>
+       for (i = 0; i < count; i++) {<br>
+               buffers[i] = validBuffers[rand() % ARRAY_SIZE(validBuffers)];<br>
+               offsets[i] = rand() % INT_MAX;<br>
+               strides[i] = rand() % maxStride;<br>
+       }<br>
+}<br>
+<br>
+<br>
+void<br>
+piglit_init(int argc, char *argv[])<br>
+{<br>
+       GLuint vao, maxBindings, invalidBuffer;<br>
+<br>
+       GLuint prevBuffers[4];<br>
+       GLintptr prevOffsets[4];<br>
+       GLsizei prevStrides[4];<br>
+<br>
+       GLuint buffers[4];<br>
+       GLintptr offsets[4];<br>
+       GLsizei strides[4];<br>
+<br>
+       bool pass = true;<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></blockquote></div></div><div>Doesn't GetIntegerv for MAX_VERTEX_ATTRIB_STRIDE require gl_version > 44 as in your previous tests? <br></div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+       glGetIntegerv(GL_MAX_VERTEX_ATTRIB_STRIDE, (GLint *) &maxStride);<br>
+<br>
+       /* Create a VAO */<br>
+       glCreateVertexArrays(1, &vao);<br>
+<br>
+       /* Create a set of buffers */<br>
+       glCreateBuffers(ARRAY_SIZE(validBuffers), validBuffers);<br>
+<br>
+       /* Generate one more buffer ID, but don't create the buffer */<br>
+       glGenBuffers(1, &invalidBuffer);<br>
+<br>
+       /* Verify that no buffers are bound by default */<br>
+       pass = check_vbo_bindings_default(vao, 0, maxBindings) && pass;<br>
+<br>
+       /* Try binding four buffers */<br>
+       generate_random_values(4, buffers, offsets, strides);<br>
+       glVertexArrayVertexBuffers(vao, 0, 4, buffers, offsets, strides);<br>
+<br>
+       /* Verify that the buffers were succesfully bound */<br>
+       pass = piglit_check_gl_error(GL_NO_ERROR);<br>
+       pass = check_vbo_bindings(vao, 0, 4, buffers, offsets, strides) && pass;<br>
+<br>
+       /* Page 337 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        * "An INVALID_OPERATION error is generated if any value in buffers<br>
+        *  is not zero or the name of an existing buffer object (per binding)."<br>
+        */<br>
+       {<br>
+               int first = rand() % (maxBindings - 4);<br>
+               generate_random_values(4, buffers, offsets, strides);<br>
+               buffers[1] = invalidBuffer;<br>
+<br>
+               /* Get the current bindings */<br>
+               get_vbo_bindings(vao, first, 4,<br>
+                                prevBuffers, prevOffsets, prevStrides);<br>
+<br>
+               /* Set the new ones */<br>
+               glVertexArrayVertexBuffers(vao, first, 4,<br>
+                                          buffers, offsets, strides);<br>
+<br>
+               /* Verify that a GL_INVALID_OPERATION error was generated */<br>
+               pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;<br>
+<br></blockquote></div></div><div>Could you add a comment that explains why only the second binding is left unchanged (i.e. explains the meaning of per binding)?  Otherwise I would have assumed that only the first one was changed, and the remaining three remain unchanged. <br></div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+               /* The first binding should have been changed */<br>
+               pass = check_vbo_binding(vao, first, buffers[0],<br>
+                                        offsets[0], strides[0]) && pass;<br>
+<br>
+               /* The second binding should be unchanged */<br>
+               pass = check_vbo_binding(vao, first + 1,<br>
+                                        prevBuffers[1],<br>
+                                        prevOffsets[1],<br>
+                                        prevStrides[1]) && pass;<br>
+<br>
+               /* The next two bindings should be changed */<br>
+               pass = check_vbo_bindings(vao, first + 2, 2, buffers + 2,<br>
+                                         offsets + 2, strides + 2) && pass;<br>
+       }<br>
+<br>
+       /* Page 337 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        * "An INVALID_VALUE error is generated if any value in offsets or<br>
+        *  strides is negative, or if any value in strides is greater than<br>
+        *  the value of MAX_VERTEX_ATTRIB_STRIDE (per binding)."<br>
+        */<br>
+       {<br>
+               int first = rand() % (maxBindings - 4);<br>
+               generate_random_values(4, buffers, offsets, strides);<br>
+<br>
+               offsets[0] = -1;<br>
+               strides[1] = -1;<br>
+<br>
+               /* Get the current bindings */<br>
+               get_vbo_bindings(vao, first + 0, 4, prevBuffers,<br>
+                                prevOffsets, prevStrides);<br>
+<br>
+               /* Set the new ones */<br>
+               glVertexArrayVertexBuffers(vao, first, 4, buffers,<br>
+                                          offsets, strides);<br>
+<br>
+               /* Verify that a GL_INVALID_VALUE error was generated */<br>
+               pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;<br>
+<br>
+               /* The first two bindings should be unchanged */<br>
+               pass = check_vbo_bindings(vao, first, 2, prevBuffers,<br>
+                                         prevOffsets, prevStrides) && pass;<br>
+<br>
+               /* The next two bindings should have been changed */<br>
+               pass = check_vbo_bindings(vao, first + 2, 2, buffers + 2,<br>
+                                         offsets + 2, strides + 2) && pass;<br>
+       }<br>
+<br>
+       /* stride >= MAX_VERTEX_ATTRIB_STRIDE */<br>
+       if (piglit_get_gl_version() >= 44) {<br>
+               int first = rand() % (maxBindings - 4);<br>
+               generate_random_values(4, buffers, offsets, strides);<br>
+<br>
+               /* Make strides[1] invalid */<br>
+               strides[1] = maxStride;<br>
+<br>
+               /* Get the current bindings */<br>
+               get_vbo_bindings(vao, first, 4, prevBuffers,<br>
+                                prevOffsets, prevStrides);<br>
+<br>
+               /* Set the new ones */<br>
+               glVertexArrayVertexBuffers(vao, first, 4, buffers,<br>
+                                          offsets, strides);<br>
+<br>
+               /* Verify that a GL_INVALID_VALUE error was generated */<br>
+               pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;<br>
+<br>
+               /* The first binding should have been changed */<br>
+               pass = check_vbo_binding(vao, first, buffers[0],<br>
+                                        offsets[0], strides[0]) && pass;<br>
+<br>
+               /* The second binding should be unchanged */<br>
+               pass = check_vbo_binding(vao, first + 1,<br>
+                                        prevBuffers[1],<br>
+                                        prevOffsets[1],<br>
+                                        prevStrides[1]) && pass;<br>
+<br>
+               /* The next two bindings should have been changed */<br>
+               pass = check_vbo_bindings(vao, first + 2, 2,<br>
+                                         buffers + 2,<br>
+                                         offsets + 2,<br>
+                                         strides + 2) && pass;<br>
+       }<br>
+<br>
+       /* Page 337 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        * "An INVALID_OPERATION error is generated if first + count is greater<br>
+        *  than the value of MAX_VERTEX_ATTRIB_BINDINGS."<br>
+        */<br></blockquote></div></div><div>This is a redundant call to get maxBindings. <br></div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+       glGetIntegerv(GL_MAX_VERTEX_ATTRIB_BINDINGS, (GLint *) &maxBindings);<br>
+       glVertexArrayVertexBuffers(vao, maxBindings - 1, 2,<br>
+                                  buffers, offsets, strides);<br>
+       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;<br>
+<br>
+       /* Page 336 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        * "If buffers is NULL, each affected vertex buffer binding point<br>
+        *  from first through first + count − 1 will be reset to have no<br>
+        *  bound buffer object. In this case, the offsets and strides<br>
+        *  associated with the binding points are set to default values,<br>
+        *  ignoring offsets and strides."<br>
+        */<br>
+<br>
+       /* Bind a set of buffers first */<br>
+       generate_random_values(4, buffers, offsets, strides);<br>
+       glVertexArrayVertexBuffers(vao, 0, 4, buffers, offsets, strides);<br>
+<br>
+       /* Now unbind them */<br>
+       glVertexArrayVertexBuffers(vao, 0, 4, NULL, offsets, strides);<br>
+       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+<br>
+       /* Verify that the buffers were unbound and that<br>
+        * the offsets and strides were not used.<br>
+        */<br>
+       pass = check_vbo_bindings_default(vao, 0, 4) && pass;<br>
+<br>
+       glDeleteVertexArrays(1, &vao);<br>
+<br>
+       /* Page 336 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        * "An INVALID_OPERATION error is generated by VertexArrayVertexBuffer<br>
+        *  if vaobj is not the name of an existing vertex array object."<br>
+        */<br>
+       glGenVertexArrays(1, &vao);<br>
+       glVertexArrayVertexBuffers(vao, 0, 4, NULL, NULL, NULL);<br>
+       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;<br>
+       glDeleteVertexArrays(1, &vao);<br>
+<br></blockquote></div></div><div>There are 10 validBuffers to delete, not 4. <br></div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+       glDeleteBuffers(4, validBuffers);<br>
+       glDeleteBuffers(1, &invalidBuffer);<br>
+<br>
+       piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);<br>
+}<br>
+<br>
<span><font color="#888888">--<br>
2.1.4<br>
<br></font></span></blockquote></span><div>I'm stopping here at 10 for the evening. <br></div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><font color="#888888">
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org" target="_blank">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></span></div><br></div></div>
</blockquote></div><br></div>