On 04/12/2017 05:42 PM, Timothy Arceri wrote:
We also move _mesa_update_array_format() into the caller.

This gets these functions ready for KHR_no_error support.
---
  src/mesa/main/varray.c | 68 +++++++++++++++++++++++++++++++-------------------
  1 file changed, 43 insertions(+), 25 deletions(-)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 353a614..f84b6cb 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -330,31 +330,29 @@ _mesa_update_array_format(struct gl_context *ctx,
   * \param sizeMin      Min allowable size value
   * \param sizeMax      Max allowable size value (may also be BGRA_OR_4)
   * \param size         Components per element (1, 2, 3 or 4)
   * \param type         Datatype of each component (GL_FLOAT, GL_INT, etc)
   * \param normalized   Whether integer types are converted to floats in [-1, 
1]
   * \param integer      Integer-valued values (will not be normalized to [-1, 
1])
   * \param doubles      Double values not reduced to floats
   * \param relativeOffset Offset of the first element relative to the binding 
offset.
   */
  static bool
-update_array_format(struct gl_context *ctx,
-                    const char *func,
-                    struct gl_vertex_array_object *vao,
-                    GLuint attrib, GLbitfield legalTypesMask,
-                    GLint sizeMin, GLint sizeMax,
-                    GLint size, GLenum type,
-                    GLboolean normalized, GLboolean integer, GLboolean doubles,
-                    GLuint relativeOffset)
+validate_array_format(struct gl_context *ctx, const char *func,
+                      struct gl_vertex_array_object *vao,
+                      GLuint attrib, GLbitfield legalTypesMask,
+                      GLint sizeMin, GLint sizeMax,
+                      GLint size, GLenum type, GLboolean normalized,
+                      GLboolean integer, GLboolean doubles,
+                      GLuint relativeOffset, GLenum format)

I think you need to update the comment on the function if it no longer updates/changes the array attrib info. Also, document if returning true/false means OK/error or error/OK.


  {
     GLbitfield typeBit;
-   GLenum format = get_array_format(ctx, sizeMax, &size);

     /* at most, one of these bools can be true */
     assert((int) normalized + (int) integer + (int) doubles <= 1);

     if (ctx->Array.LegalTypesMask == 0 || ctx->Array.LegalTypesMaskAPI != 
ctx->API) {
        /* Compute the LegalTypesMask only once, unless the context API has
         * changed, in which case we want to compute it again.  We can't do this
         * in _mesa_init_varrays() below because extensions are not yet enabled
         * at that point.
         */
@@ -434,23 +432,20 @@ update_array_format(struct gl_context *ctx,
                    func, relativeOffset);
        return false;
     }

     if (ctx->Extensions.ARB_vertex_type_10f_11f_11f_rev &&
           type == GL_UNSIGNED_INT_10F_11F_11F_REV && size != 3) {
        _mesa_error(ctx, GL_INVALID_OPERATION, "%s(size=%d)", func, size);
        return false;
     }

-   _mesa_update_array_format(ctx, vao, attrib, size, type, format,
-                             normalized, integer, doubles, relativeOffset);
-
     return true;
  }

  /**
   * Do error checking for glVertex/Color/TexCoord/...Pointer functions.
   *
   * \param func  name of calling function used for error reporting
   * \param attrib  the attribute array index to update
   * \param legalTypes  bitmask of *_BIT above indicating legal datatypes
   * \param sizeMin  min allowable size value
@@ -540,30 +535,35 @@ validate_array(struct gl_context *ctx, const char *func,
  static void
  update_array(struct gl_context *ctx,
               const char *func,
               GLuint attrib, GLbitfield legalTypesMask,
               GLint sizeMin, GLint sizeMax,
               GLint size, GLenum type, GLsizei stride,
               GLboolean normalized, GLboolean integer, GLboolean doubles,
               const GLvoid *ptr)
  {
     struct gl_vertex_array_object *vao = ctx->Array.VAO;
+   GLenum format = get_array_format(ctx, sizeMax, &size);

     validate_array(ctx, func, attrib, legalTypesMask, sizeMin, sizeMax,
                    size, type, stride, normalized, integer, doubles, ptr);

-   if (!update_array_format(ctx, func, vao, attrib,
-                            legalTypesMask, sizeMin, sizeMax,
-                            size, type, normalized, integer, doubles, 0)) {
+   if (!validate_array_format(ctx, func, vao, attrib,
+                              legalTypesMask, sizeMin, sizeMax,
+                              size, type, normalized, integer, doubles, 0,
+                              format)) {
        return;
     }

+   _mesa_update_array_format(ctx, vao, attrib, size, type, format,
+                             normalized, integer, doubles, 0);
+
     /* Reset the vertex attrib binding */
     vertex_attrib_binding(ctx, vao, attrib, attrib);

     /* The Stride and Ptr fields are not set by update_array_format() */
     struct gl_array_attributes *array = &vao->VertexAttrib[attrib];
     array->Stride = stride;
     array->Ptr = ptr;

     /* Update the vertex buffer binding */
     GLsizei effectiveStride = stride != 0 ? stride : array->_ElementSize;
@@ -2018,26 +2018,28 @@ _mesa_VertexArrayVertexBuffers(GLuint vaobj, GLuint 
first, GLsizei count,
     vertex_array_vertex_buffers(ctx, vao, first, count,
                                 buffers, offsets, strides,
                                 "glVertexArrayVertexBuffers");
  }


  static void
  vertex_attrib_format(GLuint attribIndex, GLint size, GLenum type,
                       GLboolean normalized, GLboolean integer,
                       GLboolean doubles, GLbitfield legalTypes,
-                     GLsizei maxSize, GLuint relativeOffset,
+                     GLsizei sizeMax, GLuint relativeOffset,
                       const char *func)
  {
     GET_CURRENT_CONTEXT(ctx);
     ASSERT_OUTSIDE_BEGIN_END(ctx);

+   GLenum format = get_array_format(ctx, sizeMax, &size);
+
     /* The ARB_vertex_attrib_binding spec says:
      *
      *    "An INVALID_OPERATION error is generated under any of the following
      *     conditions:
      *     - if no vertex array object is currently bound (see section 2.10);
      *     - ..."
      *
      * This error condition only applies to VertexAttribFormat and
      * VertexAttribIFormat in the extension spec, but we assume that this
      * is an oversight.  In the OpenGL 4.3 (Core Profile) spec, it applies
@@ -2058,24 +2060,32 @@ vertex_attrib_format(GLuint attribIndex, GLint size, 
GLenum type,
     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, ctx->Array.VAO,
-                       VERT_ATTRIB_GENERIC(attribIndex),
-                       legalTypes, 1, maxSize, size, type,
-                       normalized, integer, doubles, relativeOffset);
+   if (!validate_array_format(ctx, func, ctx->Array.VAO,
+                              VERT_ATTRIB_GENERIC(attribIndex),
+                              legalTypes, 1, sizeMax, size, type,
+                              normalized, integer, doubles, relativeOffset,
+                              format)) {
+      return;
+   }
+
+   _mesa_update_array_format(ctx, ctx->Array.VAO,
+                             VERT_ATTRIB_GENERIC(attribIndex), size, type,
+                             format, normalized, integer, doubles,
+                             relativeOffset);
  }


  void GLAPIENTRY
  _mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type,
                           GLboolean normalized, GLuint relativeOffset)
  {
     vertex_attrib_format(attribIndex, size, type, normalized,
                          GL_FALSE, GL_FALSE, ATTRIB_FORMAT_TYPES_MASK,
                          BGRA_OR_4, relativeOffset,
@@ -2100,28 +2110,30 @@ _mesa_VertexAttribLFormat(GLuint attribIndex, GLint 
size, GLenum type,
     vertex_attrib_format(attribIndex, size, type, GL_FALSE, GL_FALSE,
                          GL_TRUE, ATTRIB_LFORMAT_TYPES_MASK, 4,
                          relativeOffset, "glVertexAttribLFormat");
  }


  static void
  vertex_array_attrib_format(GLuint vaobj, GLuint attribIndex, GLint size,
                             GLenum type, GLboolean normalized,
                             GLboolean integer, GLboolean doubles,
-                           GLbitfield legalTypes, GLsizei maxSize,
+                           GLbitfield legalTypes, GLsizei sizeMax,
                             GLuint relativeOffset, const char *func)
  {
     GET_CURRENT_CONTEXT(ctx);
     struct gl_vertex_array_object *vao;

     ASSERT_OUTSIDE_BEGIN_END(ctx);

+   GLenum format = get_array_format(ctx, sizeMax, &size);
+
     /* 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;

@@ -2132,24 +2144,30 @@ vertex_array_attrib_format(GLuint vaobj, GLuint 
attribIndex, GLint size,
      */
     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);
+   if (!validate_array_format(ctx, func, vao,
+                              VERT_ATTRIB_GENERIC(attribIndex),
+                              legalTypes, 1, sizeMax, size, type, normalized,
+                              integer, doubles, relativeOffset, format)) {
+      return;
+   }
+
+   _mesa_update_array_format(ctx, vao, VERT_ATTRIB_GENERIC(attribIndex), size,
+                             type, format, 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,


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to