[Mesa-dev] [PATCH 03/23] mesa: Refactor update_array_format to make _mesa_update_array_format_public

Anuj Phogat anuj.phogat at gmail.com
Tue Nov 10 09:52:52 PST 2015


On Mon, Nov 9, 2015 at 4:56 PM, Ian Romanick <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> Pulls the parts of update_array_format that aren't just parameter
> validation out into a function that can be called from other parts of
> Mesa (e.g., meta).
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
>  src/mesa/main/varray.c | 68 ++++++++++++++++++++++++++++++++++++--------------
>  src/mesa/main/varray.h |  8 ++++++
>  2 files changed, 57 insertions(+), 19 deletions(-)
>
> diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
> index 5e0534a..e9f78e9 100644
> --- a/src/mesa/main/varray.c
> +++ b/src/mesa/main/varray.c
> @@ -248,6 +248,52 @@ get_legal_types_mask(const struct gl_context *ctx)
>
>
>  /**
> + * \param attrib         The index of the attribute array
> + * \param size           Components per element (1, 2, 3 or 4)
> + * \param type           Datatype of each component (GL_FLOAT, GL_INT, etc)
> + * \param format         Either GL_RGBA or GL_BGRA.
> + * \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.
> + * \param flush_verties  Should \c FLUSH_VERTICES be invoked before updating
> + *                       state?
> + */
> +void
> +_mesa_update_array_format(struct gl_context *ctx,
> +                          struct gl_vertex_array_object *vao,
> +                          GLuint attrib, GLint size, GLenum type,
> +                          GLenum format, GLboolean normalized,
> +                          GLboolean integer, GLboolean doubles,
> +                          GLuint relativeOffset, bool flush_vertices)
> +{
> +   struct gl_vertex_attrib_array *const array = &vao->VertexAttrib[attrib];
> +   GLint elementSize;
> +
> +   assert(size <= 4);
> +
> +   if (flush_vertices) {
> +      FLUSH_VERTICES(ctx, 0);
> +   }
> +
> +   elementSize = _mesa_bytes_per_vertex_attrib(size, type);
> +   assert(elementSize != -1);
> +
> +   array->Size = size;
> +   array->Type = type;
> +   array->Format = format;
> +   array->Normalized = normalized;
> +   array->Integer = integer;
> +   array->Doubles = doubles;
> +   array->RelativeOffset = relativeOffset;
> +   array->_ElementSize = elementSize;
> +
> +   vao->NewArrays |= VERT_BIT(attrib);
> +   ctx->NewState |= _NEW_ARRAY;
> +}
> +
> +/**
>   * Does error checking and updates the format in an attrib array.
>   *
>   * Called by update_array() and VertexAttrib*Format().
> @@ -274,9 +320,7 @@ update_array_format(struct gl_context *ctx,
>                      GLboolean normalized, GLboolean integer, GLboolean doubles,
>                      GLuint relativeOffset)
>  {
> -   struct gl_vertex_attrib_array *array;
>     GLbitfield typeBit;
> -   GLint elementSize;
>     GLenum format = GL_RGBA;
>
>     if (ctx->Array.LegalTypesMask == 0 || ctx->Array.LegalTypesMaskAPI != ctx->API) {
> @@ -377,23 +421,9 @@ update_array_format(struct gl_context *ctx,
>        return false;
>     }
>
> -   assert(size <= 4);
> -
> -   elementSize = _mesa_bytes_per_vertex_attrib(size, type);
> -   assert(elementSize != -1);
> -
> -   array = &vao->VertexAttrib[attrib];
> -   array->Size = size;
> -   array->Type = type;
> -   array->Format = format;
> -   array->Normalized = normalized;
> -   array->Integer = integer;
> -   array->Doubles = doubles;
> -   array->RelativeOffset = relativeOffset;
> -   array->_ElementSize = elementSize;
> -
> -   vao->NewArrays |= VERT_BIT(attrib);
> -   ctx->NewState |= _NEW_ARRAY;
> +   _mesa_update_array_format(ctx, vao, attrib, size, type, format,
> +                             normalized, integer, doubles, relativeOffset,
> +                             false);
>
>     return true;
>  }
> diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
> index 1579b76..744b336 100644
> --- a/src/mesa/main/varray.h
> +++ b/src/mesa/main/varray.h
> @@ -91,6 +91,14 @@ _mesa_attr_zero_aliases_vertex(struct gl_context *ctx)
>  }
>
>  extern void
> +_mesa_update_array_format(struct gl_context *ctx,
> +                          struct gl_vertex_array_object *vao,
> +                          GLuint attrib, GLint size, GLenum type,
> +                          GLenum format, GLboolean normalized,
> +                          GLboolean integer, GLboolean doubles,
> +                          GLuint relativeOffset, bool flush_vertices);
> +
> +extern void
>  _mesa_bind_vertex_buffer(struct gl_context *ctx,
>                           struct gl_vertex_array_object *vao,
>                           GLuint index,
> --
> 2.1.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the mesa-dev mailing list