mesa: Implement VertexArrayAttrib[I|L]Format
authorFredrik Höglund <fredrik@kde.org>
Mon, 2 Mar 2015 17:44:00 +0000 (18:44 +0100)
committerFredrik Höglund <fredrik@kde.org>
Fri, 8 May 2015 13:31:03 +0000 (15:31 +0200)
Reviewed-by: Laura Ekstrand <laura@jlekstrand.net>
src/mapi/glapi/gen/ARB_direct_state_access.xml
src/mesa/main/tests/dispatch_sanity.cpp
src/mesa/main/varray.c
src/mesa/main/varray.h

index 645c9cc80d7199d307ccd84fc2bff4d724c5719e..0268f5ff5b042b76731ed65ef20ddca094d9b091 100644 (file)
       <param name="strides" type="const GLsizei *" />
    </function>
 
+   <function name="VertexArrayAttribFormat" offset="assign">
+      <param name="vaobj" type="GLuint" />
+      <param name="attribindex" type="GLuint" />
+      <param name="size" type="GLint" />
+      <param name="type" type="GLenum" />
+      <param name="normalized" type="GLboolean" />
+      <param name="relativeoffset" type="GLuint" />
+   </function>
+
+   <function name="VertexArrayAttribIFormat" offset="assign">
+      <param name="vaobj" type="GLuint" />
+      <param name="attribindex" type="GLuint" />
+      <param name="size" type="GLint" />
+      <param name="type" type="GLenum" />
+      <param name="relativeoffset" type="GLuint" />
+   </function>
+
+   <function name="VertexArrayAttribLFormat" offset="assign">
+      <param name="vaobj" type="GLuint" />
+      <param name="attribindex" type="GLuint" />
+      <param name="size" type="GLint" />
+      <param name="type" type="GLenum" />
+      <param name="relativeoffset" type="GLuint" />
+   </function>
+
    <!-- Sampler object functions -->
 
    <function name="CreateSamplers" offset="assign">
index 55edadf4686ffb0171697aee1a7952e0ce29ac67..f36f5b3e402ce5e86c7abb7ffafb2a66e994b57a 100644 (file)
@@ -1023,6 +1023,9 @@ const struct function gl_core_functions_possible[] = {
    { "glVertexArrayElementBuffer", 45, -1 },
    { "glVertexArrayVertexBuffer", 45, -1 },
    { "glVertexArrayVertexBuffers", 45, -1 },
+   { "glVertexArrayAttribFormat", 45, -1 },
+   { "glVertexArrayAttribIFormat", 45, -1 },
+   { "glVertexArrayAttribLFormat", 45, -1 },
    { "glCreateSamplers", 45, -1 },
    { "glCreateProgramPipelines", 45, -1 },
    { "glCreateQueries", 45, -1 },
index 4b506ea39c4a48010396daa5020b0105268b701f..6d617caa0213eb65a74aad76725b756573beeba4 100644 (file)
@@ -1876,6 +1876,85 @@ _mesa_VertexAttribLFormat(GLuint attribIndex, GLint size, GLenum type,
 }
 
 
+static void
+vertex_array_attrib_format(GLuint vaobj, GLuint attribIndex, GLint size,
+                           GLenum type, GLboolean normalized,
+                           GLboolean integer, GLboolean doubles,
+                           GLbitfield legalTypes, GLsizei maxSize,
+                           GLuint relativeOffset, const char *func)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_vertex_array_object *vao;
+
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   /* The ARB_direct_state_access spec says:
+    *
+    *   "An INVALID_OPERATION error is generated by VertexArrayAttrib*Format
+    *    if <vaobj> is not [compatibility profile: zero or] the name of an
+    *    existing vertex array object."
+    */
+   vao = _mesa_lookup_vao_err(ctx, vaobj, func);
+   if (!vao)
+      return;
+
+   /* The ARB_vertex_attrib_binding spec says:
+    *
+    *   "The error INVALID_VALUE is generated if index is greater than or equal
+    *    to the value of MAX_VERTEX_ATTRIBS."
+    */
+   if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "%s(attribindex=%u > GL_MAX_VERTEX_ATTRIBS)",
+                  func, attribIndex);
+      return;
+   }
+
+   FLUSH_VERTICES(ctx, 0);
+
+   update_array_format(ctx, func, vao,
+                       VERT_ATTRIB_GENERIC(attribIndex),
+                       legalTypes, 1, maxSize, size, type, normalized,
+                       integer, doubles, relativeOffset);
+}
+
+
+void GLAPIENTRY
+_mesa_VertexArrayAttribFormat(GLuint vaobj, GLuint attribIndex, GLint size,
+                              GLenum type, GLboolean normalized,
+                              GLuint relativeOffset)
+{
+   vertex_array_attrib_format(vaobj, attribIndex, size, type, normalized,
+                              GL_FALSE, GL_FALSE, ATTRIB_FORMAT_TYPES_MASK,
+                              BGRA_OR_4, relativeOffset,
+                              "glVertexArrayAttribFormat");
+}
+
+
+void GLAPIENTRY
+_mesa_VertexArrayAttribIFormat(GLuint vaobj, GLuint attribIndex,
+                               GLint size, GLenum type,
+                               GLuint relativeOffset)
+{
+   vertex_array_attrib_format(vaobj, attribIndex, size, type, GL_FALSE,
+                              GL_TRUE, GL_FALSE, ATTRIB_IFORMAT_TYPES_MASK,
+                              4, relativeOffset,
+                              "glVertexArrayAttribIFormat");
+}
+
+
+void GLAPIENTRY
+_mesa_VertexArrayAttribLFormat(GLuint vaobj, GLuint attribIndex,
+                               GLint size, GLenum type,
+                               GLuint relativeOffset)
+{
+   vertex_array_attrib_format(vaobj, attribIndex, size, type, GL_FALSE,
+                              GL_FALSE, GL_TRUE, ATTRIB_LFORMAT_TYPES_MASK,
+                              4, relativeOffset,
+                              "glVertexArrayAttribLFormat");
+}
+
+
 void GLAPIENTRY
 _mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex)
 {
index df1cbeb946a62fa4051002b0008de124f7f1b721..d2234391eddc53ed472b663f3e143ca9261e0d0c 100644 (file)
@@ -307,14 +307,29 @@ extern void GLAPIENTRY
 _mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type,
                          GLboolean normalized, GLuint relativeOffset);
 
+extern void GLAPIENTRY
+_mesa_VertexArrayAttribFormat(GLuint vaobj, GLuint attribIndex, GLint size,
+                              GLenum type, GLboolean normalized,
+                              GLuint relativeOffset);
+
 extern void GLAPIENTRY
 _mesa_VertexAttribIFormat(GLuint attribIndex, GLint size, GLenum type,
                           GLuint relativeOffset);
 
+extern void GLAPIENTRY
+_mesa_VertexArrayAttribIFormat(GLuint vaobj, GLuint attribIndex,
+                               GLint size, GLenum type,
+                               GLuint relativeOffset);
+
 extern void GLAPIENTRY
 _mesa_VertexAttribLFormat(GLuint attribIndex, GLint size, GLenum type,
                           GLuint relativeOffset);
 
+extern void GLAPIENTRY
+_mesa_VertexArrayAttribLFormat(GLuint vaobj, GLuint attribIndex,
+                               GLint size, GLenum type,
+                               GLuint relativeOffset);
+
 extern void GLAPIENTRY
 _mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex);