<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 glVertexArrayAttribFormat,<br>
glVertexArrayAttribIFormat and glVertexArrayAttribLFormat work<br>
as expected.<br>
---<br>
 tests/all.py                                       |   1 +<br>
 .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +<br>
 .../arb_direct_state_access/vao-attrib-format.c    | 791 +++++++++++++++++++++<br>
 3 files changed, 793 insertions(+)<br>
 create mode 100644 tests/spec/arb_direct_state_access/vao-attrib-format.c<br>
<br>
diff --git a/tests/all.py b/tests/all.py<br>
index cfa2a96..9f2f3ef 100755<br>
--- a/tests/all.py<br>
+++ b/tests/all.py<br>
@@ -4282,6 +4282,7 @@ with profile.group_manager(<br>
     g(['arb_direct_state_access-create-queries'], 'create-queries')<br>
     g(['arb_direct_state_access-vao-create'], 'vao-create')<br>
     g(['arb_direct_state_access-vao-attrib-enabledisable'], 'vao-attrib-enabledisable')<br>
+    g(['arb_direct_state_access-vao-attrib-format'], 'vao-attrib-format')<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 4ee9c0c..e5596be 100644<br>
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt<br>
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt<br>
@@ -38,4 +38,5 @@ piglit_add_executable (arb_direct_state_access-create-programpipelines create-pr<br>
 piglit_add_executable (arb_direct_state_access-create-queries create-queries.c)<br>
 piglit_add_executable (arb_direct_state_access-vao-create vao-create.c)<br>
 piglit_add_executable (arb_direct_state_access-vao-attrib-enabledisable vao-attrib-enabledisable.c dsa-utils.c)<br>
+piglit_add_executable (arb_direct_state_access-vao-attrib-format vao-attrib-format.c dsa-utils.c)<br>
 # vim: ft=cmake:<br>
diff --git a/tests/spec/arb_direct_state_access/vao-attrib-format.c b/tests/spec/arb_direct_state_access/vao-attrib-format.c<br>
new file mode 100644<br>
index 0000000..807176f<br>
--- /dev/null<br>
+++ b/tests/spec/arb_direct_state_access/vao-attrib-format.c<br>
@@ -0,0 +1,791 @@<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-attrib-format.c<br>
+ *<br>
+ * Verifies that glVertexArrayAttribFormat, glVertexArrayAttribIFormat and<br>
+ * glVertexArrayAttribLFormat work as expected.<br>
+ */<br>
+<br>
+#include "piglit-util-gl.h"<br>
+#include "dsa-utils.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>
+static bool ARB_ES2_compatibility;<br>
+static bool ARB_half_float_vertex;<br>
+static bool ARB_vertex_type_2_10_10_10_rev;<br>
+static bool ARB_vertex_type_10f_11f_11f_rev;<br>
+static bool ARB_vertex_array_64bit;<br>
+static bool ARB_vertex_array_bgra;<br>
+<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       /* unreached */<br>
+       return PIGLIT_FAIL;<br>
+}<br>
+<br>
+<br>
+/**<br>
+ * Returns true if the format of attribindex matches the expected<br>
+ * format, and false otherwise.<br>
+ */<br>
+bool<br>
+check_attrib_format_(GLuint vao, GLuint attribindex, GLuint size, GLenum type,<br>
+                     GLboolean normalized, GLboolean integer, GLboolean _long,<br>
+                     GLuint relativeOffset, int line)<br>
+{<br>
+       bool ret = true;<br>
+<br>
+       ret = check_indexed_vao_param_(vao, attribindex,<br>
+                                      GL_VERTEX_ATTRIB_ARRAY_SIZE,<br>
+                                      size, __FILE__, line) && ret;<br>
+       ret = check_indexed_vao_param_(vao, attribindex,<br>
+                                      GL_VERTEX_ATTRIB_ARRAY_TYPE,<br>
+                                      type, __FILE__, line) && ret;<br>
+       ret = check_indexed_vao_param_(vao, attribindex,<br>
+                                      GL_VERTEX_ATTRIB_ARRAY_NORMALIZED,<br>
+                                      normalized, __FILE__, line) && ret;<br>
+<br>
+       if (piglit_get_gl_version() >= 30) {<br>
+               ret = check_indexed_vao_param_(vao, attribindex,<br>
+                                              GL_VERTEX_ATTRIB_ARRAY_INTEGER,<br>
+                                              integer, __FILE__, line) && ret;<br>
+       } else if (integer) {<br>
+               fprintf(stderr, "GL_VERTEX_ATTRIB_ARRAY_INTEGER[%u] expected "<br>
+                               "to be GL_TRUE, but OpenGL 3.0 "<br>
+                               "is not supported (%s:%d).",<br>
+                               attribindex, __FILE__, line);<br>
+               ret = false;<br>
+       }<br>
+<br>
+       if (ARB_vertex_array_64bit) {<br>
+               ret = check_indexed_vao_param_(vao, attribindex,<br>
+                                              GL_VERTEX_ATTRIB_ARRAY_LONG,<br>
+                                              _long, __FILE__, line) && ret;<br>
+       } else if (_long) {<br>
+               fprintf(stderr, "GL_VERTEX_ATTRIB_ARRAY_LONG[%u] expected "<br>
+                               "to be GL_TRUE, but GL_ARB_vertex_array_64bit "<br>
+                               "is not supported (%s:%d).",<br>
+                               attribindex, __FILE__, line);<br>
+               ret = false;<br>
+       }<br>
+<br>
+       ret = check_indexed_vao_param_(vao, attribindex,<br>
+                                      GL_VERTEX_ATTRIB_RELATIVE_OFFSET,<br>
+                                      relativeOffset, __FILE__, line) && ret;<br>
+<br>
+       return ret;<br>
+}<br>
+<br>
+#define check_attrib_format(vao, attribindex, size, type, normalized, \<br>
+                            integer, _long, relativeOffset) \<br>
+       check_attrib_format_(vao, attribindex, size, type, normalized, \<br>
+                            integer, _long, relativeOffset, __LINE__)<br>
+<br>
+#define check_attrib_format_default(vao, attribindex) \<br>
+       check_attrib_format_(vao, attribindex, 4, GL_FLOAT, GL_FALSE, \<br>
+                            GL_FALSE, GL_FALSE, 0, __LINE__)<br>
+<br>
+#define reset_attrib_format(vao, attribindex) \<br>
+       glVertexArrayAttribFormat(vao, attribindex, 4, GL_FLOAT, GL_FALSE, 0)<br>
+<br>
+<br>
+/**<br>
+ * Returns true if the 0 terminated array contains value, and false otherwise.<br>
+ */<br>
+static bool<br>
+find(const GLuint *array, GLuint value)<br>
+{<br>
+       int i;<br>
+       for (i = 0; array[i]; i++) {<br>
+               if (array[i] == value)<br>
+                       return true;<br>
+       }<br>
+<br>
+       return false;<br>
+}<br>
+<br>
+<br>
+/**<br>
+ * Returns true if the given type is a packed type, and false otherwise.<br>
+ */<br>
+static bool<br>
+is_packed_type(GLenum type)<br>
+{<br>
+       switch (type) {<br>
+       case GL_INT_2_10_10_10_REV:<br>
+       case GL_UNSIGNED_INT_2_10_10_10_REV:<br>
+       case GL_UNSIGNED_INT_10F_11F_11F_REV:<br>
+               return true;<br>
+<br>
+       default:<br>
+               return false;<br>
+       }<br>
+}<br>
+<br>
+<br></blockquote><div> </div><div>Since you test both vao and invalidvao with these functions, I think it would be good to print the identity of the vao in your print statements.  Maybe like this:<br></div><div>static GLuint good_vao, bad_vao;<br><br></div><div>/* In piglit_init: */<br></div><div>glCreateVertexArrays(1, &good_vao);<br></div><div>glGenVertexArrays(1, &bad_vao);<br><br></div><div>/* In the following *_format functions */<br></div><div>fprintf(stdout, "glVertexArrayAttribFormat(%s, ...", vao == good_vao ? "good_vao" : "bad_vao")<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+/**<br>
+ * Prints the parameter values and calls glVertexArrayAttribFormat.<br>
+ */<br>
+static void<br>
+vertex_attrib_format(GLuint vao, GLuint attribindex, GLuint size, GLenum type,<br>
+                     GLboolean normalized, GLuint relativeoffset)<br>
+{<br>
+       if (size == GL_BGRA)<br>
+               fprintf(stdout, "glVertexArrayAttribFormat"<br>
+                       "(%u, GL_BGRA, %s, %s, %u)\n",<br>
+                       attribindex, piglit_get_gl_enum_name(type),<br>
+                       normalized ? "GL_TRUE" : "GL_FALSE", relativeoffset);<br>
+       else<br>
+               fprintf(stdout, "glVertexArrayAttribFormat"<br>
+                       "(%u, %d, %s, %s, %u)\n",<br>
+                       attribindex, size, piglit_get_gl_enum_name(type),<br>
+                       normalized ? "GL_TRUE" : "GL_FALSE", relativeoffset);<br>
+<br>
+       glVertexArrayAttribFormat(vao, attribindex, size, type, normalized,<br>
+                                 relativeoffset);<br>
+}<br>
+<br>
+<br>
+/**<br>
+ * Prints the parameter values and calls glVertexArrayAttribIFormat.<br>
+ */<br>
+static void<br>
+vertex_attrib_iformat(GLuint vao, GLuint attribindex, GLuint size, GLenum type,<br>
+                      GLuint relativeoffset)<br>
+{<br>
+       if (size == GL_BGRA)<br>
+               fprintf(stdout, "glVertexArrayAttribIFormat"<br>
+                       "(%u, GL_BGRA, %s, %u)\n",<br>
+                       attribindex, piglit_get_gl_enum_name(type),<br>
+                       relativeoffset);<br>
+       else<br>
+               fprintf(stdout, "glVertexArrayAttribIFormat"<br>
+                       "(%u, %d, %s, %u)\n",<br>
+                       attribindex, size, piglit_get_gl_enum_name(type),<br>
+                       relativeoffset);<br>
+<br>
+       glVertexArrayAttribIFormat(vao, attribindex, size, type,<br>
+                                  relativeoffset);<br>
+}<br>
+<br>
+<br>
+/**<br>
+ * Prints the parameter values and calls glVertexArrayAttribLFormat.<br>
+ */<br>
+static void<br>
+vertex_attrib_lformat(GLuint vao, GLuint attribindex, GLuint size, GLenum type,<br>
+                      GLuint relativeoffset)<br>
+{<br>
+       if (size == GL_BGRA)<br>
+               fprintf(stdout, "glVertexArrayAttribLFormat"<br>
+                       "(%u, GL_BGRA, %s, %u)\n",<br>
+                       attribindex, piglit_get_gl_enum_name(type),<br>
+                       relativeoffset);<br>
+       else<br>
+               fprintf(stdout, "glVertexArrayAttribLFormat"<br>
+                       "(%u, %d, %s, %u)\n",<br>
+                       attribindex, size, piglit_get_gl_enum_name(type),<br>
+                       relativeoffset);<br>
+<br>
+       glVertexArrayAttribLFormat(vao, attribindex, size, type,<br>
+                                  relativeoffset);<br>
+}<br>
+<br>
+<br>
+/**<br>
+ * Calls glVertexArrayAttribFormat with the given parameters, and checks that<br>
+ * the format is set when the size/normalized parameters are valid, and that<br>
+ * the correct error is generated otherwise.<br>
+ *<br>
+ * This function expects that the given vao, type, and relativeoffset are<br>
+ * always valid.<br>
+ */<br>
+static bool<br>
+test_attribformat(GLuint vao, GLuint attribindex,<br>
+                  GLenum type, GLuint size,<br>
+                  GLboolean normalized,<br>
+                  GLuint relativeoffset,<br>
+                  bool sizeValid)<br>
+{<br>
+       bool pass = true;<br>
+<br>
+       /* Page 334 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        *    "An INVALID_VALUE error is generated if size is not<br>
+        *     one of the values shown in table 10.2 for the<br>
+        *     corresponding command.<br>
+        *     [...]<br>
+        *     An INVALID_OPERATION error is generated under any<br>
+        *     of the following conditions:<br>
+        *<br>
+        *     • size is BGRA and type is not<br>
+        *       UNSIGNED_BYTE, INT_2_10_10_10_REV<br>
+        *       or UNSIGNED_INT_2_10_10_10_REV;<br>
+        *<br>
+        *     • type is INT_2_10_10_10_REV or<br>
+        *       UNSIGNED_INT_2_10_10_10_REV, and<br>
+        *       size is neither 4 nor BGRA;<br>
+        *<br>
+        *     • type is UNSIGNED_INT_10F_11F_11F_REV and<br>
+        *       size is not 3;<br>
+        *<br>
+        *     • size is BGRA and normalized is FALSE."<br>
+        */<br>
+       GLenum err = GL_NO_ERROR;<br>
+<br>
+       if (!sizeValid) {<br>
+               if (is_packed_type(type))<br>
+                       err = GL_INVALID_OPERATION;<br>
+               else if (size == GL_BGRA && ARB_vertex_array_bgra)<br>
+                       err = GL_INVALID_OPERATION;<br>
+               else<br>
+                       err = GL_INVALID_VALUE;<br>
+       }<br>
+<br>
+       if (ARB_vertex_array_bgra && size == GL_BGRA && !normalized)<br>
+               err = GL_INVALID_OPERATION;<br>
+<br>
+       reset_attrib_format(vao, attribindex);<br>
+       vertex_attrib_format(vao, attribindex, size, type, normalized,<br>
+                            relativeoffset);<br>
+<br>
+       pass = piglit_check_gl_error(err);<br>
+<br>
+       if (err == GL_NO_ERROR) {<br>
+               /* Verify that the format was changed */<br>
+               pass = check_attrib_format(vao, attribindex, size, type,<br>
+                                          normalized, GL_FALSE,<br>
+                                          GL_FALSE, relativeoffset) && pass;<br>
+       } else {<br>
+               /* Verify that the format was not changed */<br>
+               pass = check_attrib_format_default(vao, attribindex) && pass;<br>
+       }<br>
+<br>
+       return pass;<br>
+}<br>
+<br>
+<br>
+/**<br>
+ * Tests glVertexArrayAttribFormat<br>
+ */<br>
+static bool<br>
+test_vertexarrayattribformat(GLuint vao, GLuint invalidvao, GLuint maxAttribs,<br>
+                             GLuint maxRelativeOffset)<br>
+{<br>
+       const GLuint bgra = ARB_vertex_array_bgra ? GL_BGRA : 0;<br>
+       bool pass = true;<br>
+        int i;<br></blockquote><div>Extra space before int i; ^^^^ <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+       /* See table 10.2 on page 334 of the PDF<br></blockquote><div>It's all on page 357 of the PDF now. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+        * of the OpenGL 4.5 (Core Profile) specification<br>
+        */<br>
+       struct {<br>
+               GLenum type;<br>
+               GLuint sizes[6];<br>
+               bool supported;<br>
+       } formats[] = {<br>
+               {<br>
+                       GL_BYTE,                         /* type */<br>
+                       { 1, 2, 3, 4 },                  /* sizes */<br>
+                       true                             /* supported */<br>
+               },<br>
+               {<br>
+                       GL_UNSIGNED_BYTE,                /* type */<br>
+                       { 1, 2, 3, 4, bgra },            /* sizes */<br>
+                       true,                            /* supported */<br>
+               },<br>
+               {<br>
+                       GL_SHORT,                        /* type */<br>
+                       { 1, 2, 3, 4 },                  /* sizes */<br>
+                       true,                            /* supported */<br>
+               },<br>
+               {<br>
+                       GL_UNSIGNED_SHORT,               /* type */<br>
+                       { 1, 2, 3, 4 },                  /* sizes */<br>
+                       true,                            /* supported */<br>
+               },<br>
+               {<br>
+                       GL_INT,                          /* type */<br>
+                       { 1, 2, 3, 4 },                  /* sizes */<br>
+                       true,                            /* supported */<br>
+               },<br>
+               {<br>
+                       GL_UNSIGNED_INT,                 /* type */<br>
+                       { 1, 2, 3, 4 },                  /* sizes */<br>
+                       true,                            /* supported */<br>
+               },<br>
+               {<br>
+                       GL_FIXED,                        /* type */<br>
+                       { 1, 2, 3, 4 },                  /* sizes */<br>
+                       ARB_ES2_compatibility,           /* supported */<br>
+               },<br>
+               {<br>
+                       GL_FLOAT,                        /* type */<br>
+                       { 1, 2, 3, 4 },                  /* sizes */<br>
+                       true,                            /* supported */<br>
+               },<br>
+               {<br>
+                       GL_HALF_FLOAT,                   /* type */<br>
+                       { 1, 2, 3, 4 },                  /* sizes */<br>
+                       ARB_half_float_vertex,           /* supported */<br>
+               },<br>
+               {<br>
+                       GL_DOUBLE,                       /* type */<br>
+                       { 1, 2, 3, 4 },                  /* sizes */<br>
+                       true,                            /* supported */<br>
+               },<br>
+               {<br>
+                       GL_INT_2_10_10_10_REV,           /* type */<br>
+                       { 4, bgra },                     /* sizes */<br>
+                       ARB_vertex_type_2_10_10_10_rev,  /* supported */<br>
+               },<br>
+               {<br>
+                       GL_UNSIGNED_INT_2_10_10_10_REV,  /* type */<br>
+                       { 4, bgra },                     /* sizes */<br>
+                       ARB_vertex_type_2_10_10_10_rev,  /* supported */<br>
+               },<br>
+               {<br>
+                       GL_UNSIGNED_INT_10F_11F_11F_REV, /* type */<br>
+                       { 3 },                           /* sizes */<br>
+                       ARB_vertex_type_10f_11f_11f_rev, /* supported */<br>
+               },<br>
+       };<br>
+<br>
+       /* Test each supported type */<br>
+       for (i = 0; i < ARRAY_SIZE(formats); i++) {<br>
+               const GLuint sizes[] = { 0, 1, 2, 3, 4, GL_BGRA, 5 };<br>
+               const GLenum type = formats[i].type;<br>
+               const GLuint *validSizes = formats[i].sizes;<br>
+               int j;<br>
+<br>
+               if (!formats[i].supported)<br>
+                       continue;<br>
+<br>
+               /* Test all sizes */<br>
+               for (j = 0; j < ARRAY_SIZE(sizes); j++) {<br>
+                       const GLuint size = sizes[j];<br>
+                       const bool sizeValid = find(validSizes, size);<br>
+                       const int maxOffset = maxRelativeOffset + 1;<br>
+<br>
+                       /* Normalized = GL_TRUE */<br>
+                       pass = test_attribformat(vao, rand() % maxAttribs,<br>
+                                                type, size, GL_TRUE,<br>
+                                                rand() % maxOffset,<br>
+                                                sizeValid) && pass;<br>
+<br>
+                       /* Normalized = GL_FALSE */<br>
+                       pass = test_attribformat(vao, rand() % maxAttribs,<br>
+                                                type, size, GL_FALSE,<br>
+                                                rand() % maxOffset,<br>
+                                                sizeValid) && pass;<br>
+               }<br>
+       }<br>
+<br>
+       /* Page 334 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        * "An INVALID_OPERATION error is generated by VertexArrayAttrib*Format<br>
+        *  if vaobj is not the name of an existing vertex array object.<br>
+        */<br>
+       vertex_attrib_format(invalidvao, 0, 4, GL_FLOAT, GL_FALSE, 0);<br>
+       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;<br>
+<br>
+       /* Page 334 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        *    "An INVALID_VALUE error is generated if attribindex is<br>
+        *     greater than or equal to the value of MAX_VERTEX_ATTRIBS."<br>
+        */<br>
+       vertex_attrib_format(vao, maxAttribs, 4, GL_FLOAT, GL_FALSE, 0);<br>
+       pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;<br>
+<br>
+       /* Page 334 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        *    "An INVALID_ENUM error is generated if type is not one<br>
+        *     of the parameter token names from table 8.2 corresponding<br>
+        *     to one of the allowed GL data types for that command as<br>
+        *     shown in table 10.2."<br>
+        */<br>
+       reset_attrib_format(vao, 0);<br>
+       vertex_attrib_format(vao, 0, 4, GL_4_BYTES, GL_FALSE, 0);<br>
+       pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;<br>
+       pass = check_attrib_format_default(vao, 0) && pass;<br>
+<br>
+       /* Test all invalid types */<br>
+       for (i = 0; i < ARRAY_SIZE(formats); i++) {<br>
+               if (formats[i].supported)<br>
+                       continue;<br>
+<br>
+               reset_attrib_format(vao, 0);<br>
+               vertex_attrib_format(vao, 0, formats[i].sizes[0],<br>
+                                    formats[i].type, GL_TRUE, 0);<br>
+<br>
+               pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;<br>
+               pass = check_attrib_format_default(vao, 0) && pass;<br>
+       }<br>
+<br>
+       /* Page 335 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        *    "An INVALID_VALUE error is generated if relativeoffset<br>
+        *     is larger than the value of<br>
+        *     MAX_VERTEX_ATTRIB_RELATIVE_OFFSET."<br>
+        */<br>
+       reset_attrib_format(vao, 0);<br>
+       vertex_attrib_format(vao, 0, 4, GL_FLOAT, GL_FALSE,<br>
+                            maxRelativeOffset + 1);<br>
+       pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;<br>
+       pass = check_attrib_format_default(vao, 0) && pass;<br>
+<br>
+       piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL,<br>
+                                    "glVertexArrayAttribFormat");<br>
+<br>
+       return pass;<br>
+}<br>
+<br>
+<br>
+/**<br>
+ * Tests glVertexArrayAttribIFormat<br>
+ */<br>
+static bool<br>
+test_vertexarrayattribiformat(GLuint vao, GLuint invalidvao,<br>
+                              GLuint maxAttribs, GLuint maxRelativeOffset)<br>
+{<br>
+       bool pass = true;<br>
+       int i;<br>
+<br>
+       const GLenum validTypes[] = {<br>
+               GL_BYTE, GL_UNSIGNED_BYTE,<br>
+               GL_SHORT, GL_UNSIGNED_SHORT,<br>
+               GL_INT, GL_UNSIGNED_INT<br>
+       };<br>
+<br>
+       const GLenum invalidTypes[] = {<br>
+               GL_FIXED, GL_FLOAT, GL_HALF_FLOAT, GL_DOUBLE,<br>
+               GL_INT_2_10_10_10_REV, GL_UNSIGNED_INT_2_10_10_10_REV,<br>
+               GL_UNSIGNED_INT_10F_11F_11F_REV<br>
+       };<br>
+<br>
+       for (i = 0; i < ARRAY_SIZE(validTypes); i++) {<br>
+               const GLuint validSizes[] = { 1, 2, 3, 4 };<br>
+               const GLuint invalidSizes[] = { 0, GL_BGRA, 5 };<br>
+               int j;<br>
+<br>
+               /* Test all valid sizes */<br>
+               for (j = 0; j < ARRAY_SIZE(validSizes); j++) {<br>
+                       const GLuint attribindex = rand() % maxAttribs;<br>
+                       const GLuint relativeoffset =<br>
+                               rand() % (maxRelativeOffset + 1);<br>
+<br>
+                       reset_attrib_format(vao, attribindex);<br>
+<br>
+                       vertex_attrib_iformat(vao, attribindex,<br>
+                                             validSizes[j],<br>
+                                             validTypes[i],<br>
+                                             relativeoffset);<br>
+<br>
+                       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+                       pass = check_attrib_format(vao, attribindex,<br>
+                                                  validSizes[j],<br>
+                                                  validTypes[i],<br>
+                                                  GL_FALSE, GL_TRUE,<br>
+                                                  GL_FALSE,<br>
+                                                  relativeoffset) && pass;<br>
+               }<br>
+<br>
+               /* Page 334 of the PDF of the OpenGL 4.5 (Core Profile)<br>
+                * specification says:<br>
+                *<br>
+                *    "An INVALID_VALUE error is generated if size is<br>
+                *     not one of the values shown in table 10.2 for<br>
+                *     the corresponding command."<br>
+                */<br>
+               for (j = 0; j < ARRAY_SIZE(invalidSizes); j++) {<br>
+                       reset_attrib_format(vao, 0);<br>
+                       vertex_attrib_iformat(vao, 0,<br>
+                                             invalidSizes[j],<br>
+                                             validTypes[i], 0);<br>
+<br>
+                       /* Check that GL_INVALID_VALUE was generated<br>
+                        * and that the format was not changed.<br>
+                        */<br>
+                       pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;<br>
+                       pass = check_attrib_format_default(vao, 0) && pass;<br>
+               }<br>
+       }<br>
+<br>
+       /* Page 334 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        *    "An INVALID_ENUM error is generated if type is not one of<br>
+        *     the parameter token names from table 8.2 corresponding to<br>
+        *     one of the allowed GL data types for that command as<br>
+        *     shown in table 10.2."<br>
+        */<br>
+       for (i = 0; i < ARRAY_SIZE(invalidTypes); i++) {<br>
+               /* Make sure the size is valid */<br>
+               const GLuint size = invalidTypes[i] ==<br>
+                       GL_UNSIGNED_INT_10F_11F_11F_REV ? 3 : 4;<br>
+<br>
+               reset_attrib_format(vao, 0);<br>
+               vertex_attrib_iformat(vao, 0, size,<br>
+                                     invalidTypes[i], 0);<br>
+               pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;<br>
+               pass = check_attrib_format_default(vao, 0) && pass;<br>
+       }<br>
+<br>
+       /* Page 334 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        * "An INVALID_OPERATION error is generated by VertexArrayAttrib*Format<br>
+        *  if vaobj is not the name of an existing vertex array object.<br>
+        */<br>
+       vertex_attrib_iformat(invalidvao, 0, 4, GL_INT, 0);<br>
+       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;<br>
+<br>
+       /* Page 334 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        * "An INVALID_VALUE error is generated if attribindex is<br>
+        *  greater than or equal to the value of MAX_VERTEX_ATTRIBS."<br>
+        */<br>
+       vertex_attrib_iformat(vao, maxAttribs, 4, GL_INT, 0);<br>
+       pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;<br>
+<br>
+       /* Page 335 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        * "An INVALID_VALUE error is generated if relativeoffset is<br>
+        *  larger than the value of MAX_VERTEX_ATTRIB_RELATIVE_OFFSET."<br>
+        */<br>
+       vertex_attrib_iformat(vao, 0, 4, GL_INT,<br>
+                             maxRelativeOffset + 1);<br>
+       pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;<br>
+<br>
+       piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL,<br>
+                                    "glVertexArrayAttribIFormat");<br>
+<br>
+       return pass;<br>
+}<br>
+<br>
+<br>
+/**<br>
+ * Tests glVertexArrayAttribLFormat<br>
+ */<br>
+static bool<br>
+test_vertexarrayattriblformat(GLuint vao, GLuint invalidvao,<br>
+                              GLuint maxAttribs, GLuint maxRelativeOffset)<br>
+{<br>
+       bool pass = true;<br>
+       int i;<br>
+<br>
+       const GLuint validSizes[] = { 1, 2, 3, 4 };<br>
+       const GLuint invalidSizes[] = { 0, GL_BGRA, 5 };<br>
+<br>
+       const GLenum invalidTypes[] = {<br>
+               GL_BYTE, GL_UNSIGNED_BYTE,<br>
+               GL_SHORT, GL_UNSIGNED_SHORT,<br>
+               GL_INT, GL_UNSIGNED_INT,<br>
+               GL_FIXED, GL_FLOAT, GL_HALF_FLOAT,<br>
+               GL_INT_2_10_10_10_REV,<br>
+               GL_UNSIGNED_INT_2_10_10_10_REV,<br>
+               GL_UNSIGNED_INT_10F_11F_11F_REV<br>
+       };<br>
+<br>
+       /* Test all valid sizes */<br>
+       for (i = 0; i < ARRAY_SIZE(validSizes); i++) {<br>
+               const GLuint attribindex = rand() % maxAttribs;<br>
+               const GLuint relativeoffset = rand() % (maxRelativeOffset + 1);<br>
+<br>
+               reset_attrib_format(vao, i);<br></blockquote><div>It shouldn't be i; it should be attribindex ^^^. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+               vertex_attrib_lformat(vao, attribindex, validSizes[i],<br>
+                                     GL_DOUBLE, relativeoffset);<br>
+<br>
+               pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+               pass = check_attrib_format(vao, attribindex, validSizes[i],<br>
+                                          GL_DOUBLE, GL_FALSE, GL_FALSE,<br>
+                                          GL_TRUE, relativeoffset) && pass;<br>
+       }<br>
+<br>
+       /* Page 334 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        *    "An INVALID_VALUE error is generated if size is not one of<br>
+        *     the values shown in table 10.2 for the corresponding<br>
+        *     command."<br>
+        */<br>
+       for (i = 0; i < ARRAY_SIZE(invalidSizes); i++) {<br>
+               reset_attrib_format(vao, 0);<br>
+               vertex_attrib_lformat(vao, 0, invalidSizes[i],<br>
+                                     GL_DOUBLE, 0);<br>
+               pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;<br>
+               pass = check_attrib_format_default(vao, 0) && pass;<br>
+       }<br>
+<br>
+       /* Page 334 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        *    "An INVALID_ENUM error is generated if type is not one of<br>
+        *     the parameter token names from table 8.2 corresponding to<br>
+        *     one of the allowed GL data types for that command as<br>
+        *     shown in table 10.2."<br>
+        */<br>
+       for (i = 0; i < ARRAY_SIZE(invalidTypes); i++) {<br>
+               /* Make sure the size is valid */<br>
+               const GLuint size = invalidTypes[i] ==<br>
+                       GL_UNSIGNED_INT_10F_11F_11F_REV ? 3 : 4;<br>
+<br>
+               reset_attrib_format(vao, 0);<br>
+               vertex_attrib_lformat(vao, 0, size,<br>
+                                     invalidTypes[i], 0);<br>
+               pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;<br>
+               pass = check_attrib_format_default(vao, 0) && pass;<br>
+       }<br>
+<br>
+       /* Page 334 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        * "An INVALID_OPERATION error is generated by VertexArrayAttrib*Format<br>
+        *  if vaobj is not the name of an existing vertex array object.<br>
+        */<br>
+       vertex_attrib_lformat(invalidvao, 0, 4, GL_DOUBLE, 0);<br>
+       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;<br>
+<br>
+<br>
+       /* Page 334 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        *    "An INVALID_VALUE error is generated if attribindex is<br>
+        *     greater than or equal to the value of MAX_VERTEX_ATTRIBS."<br>
+        */<br>
+       vertex_attrib_lformat(vao, maxAttribs, 4, GL_DOUBLE, 0);<br>
+       pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;<br>
+<br>
+       /* Page 335 of the PDF of the OpenGL 4.5 (Core Profile) spec says:<br>
+        *<br>
+        *    "An INVALID_VALUE error is generated if relativeoffset is<br>
+        *     larger than the value of MAX_VERTEX_ATTRIB_RELATIVE_OFFSET."<br>
+        */<br>
+       reset_attrib_format(vao, 0);<br>
+       vertex_attrib_lformat(vao, 0, 4, GL_DOUBLE,<br>
+                                  maxRelativeOffset + 1);<br></blockquote><div>Wrong indentation ^^^^^^ <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+       pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;<br>
+       pass = check_attrib_format_default(vao, 0) && pass;<br>
+<br>
+       piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL,<br>
+                                    "glVertexArrayAttribLFormat");<br>
+<br>
+       return pass;<br>
+}<br>
+<br>
+<br>
+/**<br>
+ * Checks the default formats in a newly created VAO<br>
+ */<br>
+static bool<br>
+test_defaults(GLuint vao, GLint maxAttribs)<br>
+{<br>
+       bool pass = true;<br>
+       int i;<br>
+<br>
+       for (i = 0; i < maxAttribs; i++) {<br>
+               pass = check_attrib_format_default(vao, i) && pass;<br>
+       }<br>
+<br>
+       piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL,<br>
+                                    "Defaults");<br>
+<br>
+       return pass;<br>
+}<br>
+<br>
+<br>
+void<br>
+piglit_init(int argc, char *argv[])<br>
+{<br>
+       GLint maxAttribs;<br>
+       GLint maxRelativeOffset;<br>
+       GLuint vao, invalidvao;<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>
+       ARB_ES2_compatibility =<br>
+           piglit_is_extension_supported("GL_ARB_ES2_compatibility");<br>
+       ARB_half_float_vertex =<br>
+           piglit_is_extension_supported("GL_ARB_half_float_vertex");<br>
+       ARB_vertex_type_2_10_10_10_rev =<br>
+           piglit_is_extension_supported( "GL_ARB_vertex_type_2_10_10_10_rev");<br>
+       ARB_vertex_type_10f_11f_11f_rev =<br>
+           piglit_is_extension_supported("GL_ARB_vertex_type_10f_11f_11f_rev");<br>
+       ARB_vertex_array_64bit =<br>
+           piglit_is_extension_supported("GL_ARB_vertex_array_64bit");<br>
+       ARB_vertex_array_bgra =<br>
+           piglit_is_extension_supported("GL_ARB_vertex_array_bgra");<br>
+<br>
+       glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribs);<br>
+       glGetIntegerv(GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET, &maxRelativeOffset);<br>
+<br>
+       /* Create a VAO */<br>
+       glCreateVertexArrays(1, &vao);<br>
+<br>
+       /* Generate a VAO name, but don't create the object */<br>
+       glGenVertexArrays(1, &invalidvao);<br>
+<br>
+       pass = test_defaults(vao, maxAttribs) && pass;<br>
+<br>
+       /* Test glVertexArrayAttribFormat */<br>
+       pass = test_vertexarrayattribformat(vao, invalidvao, maxAttribs,<br>
+                                           maxRelativeOffset) && pass;<br>
+<br>
+       /* Test glVertexAttribIFormat */<br>
+       if (piglit_get_gl_version() >= 30) {<br>
+               pass = test_vertexarrayattribiformat(vao, invalidvao,<br>
+                                                    maxAttribs,<br>
+                                                    maxRelativeOffset) && pass;<br>
+       } else {<br>
+               piglit_report_subtest_result(PIGLIT_SKIP,<br>
+                                            "glVertexArrayAttribIFormat");<br>
+       }<br>
+<br>
+       /* Test glVertexAttribLFormat */<br>
+       if (ARB_vertex_array_64bit) {<br>
+               pass = test_vertexarrayattriblformat(vao, invalidvao,<br>
+                                                    maxAttribs,<br>
+                                                    maxRelativeOffset) && pass;<br>
+       } else {<br>
+               piglit_report_subtest_result(PIGLIT_SKIP,<br>
+                                            "glVertexArrayAttribLFormat");<br>
+       }<br>
+<br>
+       glDeleteVertexArrays(1, &vao);<br>
+       glDeleteVertexArrays(1, &invalidvao);<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>