[Mesa-dev] [PATCH 2/4] mesa: move FLUSH_VERTICES() call to meta
Brian Paul
brianp at vmware.com
Thu Mar 30 16:34:03 UTC 2017
On 03/30/2017 05:26 AM, Timothy Arceri wrote:
> There is no need for this to be in the common code.
> ---
> src/mesa/drivers/common/meta.c | 11 ++++++-----
> src/mesa/main/varray.c | 9 ++-------
> src/mesa/main/varray.h | 2 +-
> 3 files changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
> index d8deaaf..d0f8330 100644
> --- a/src/mesa/drivers/common/meta.c
> +++ b/src/mesa/drivers/common/meta.c
> @@ -314,65 +314,66 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
>
> /* create vertex array buffer */
> *buf_obj = ctx->Driver.NewBufferObject(ctx, 0xDEADBEEF);
> if (*buf_obj == NULL)
> return;
>
> _mesa_buffer_data(ctx, *buf_obj, GL_NONE, 4 * sizeof(struct vertex), NULL,
> GL_DYNAMIC_DRAW, __func__);
>
> /* setup vertex arrays */
> + FLUSH_VERTICES(ctx, 0);
> if (use_generic_attributes) {
> assert(color_size == 0);
>
> _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_GENERIC(0),
> vertex_size, GL_FLOAT, GL_RGBA, GL_FALSE,
> GL_FALSE, GL_FALSE,
> - offsetof(struct vertex, x), true);
> + offsetof(struct vertex, x));
> _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(0),
> *buf_obj, 0, sizeof(struct vertex));
> _mesa_enable_vertex_array_attrib(ctx, array_obj,
> VERT_ATTRIB_GENERIC(0));
> if (texcoord_size > 0) {
> _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_GENERIC(1),
> texcoord_size, GL_FLOAT, GL_RGBA,
> GL_FALSE, GL_FALSE, GL_FALSE,
> - offsetof(struct vertex, tex), false);
> + offsetof(struct vertex, tex));
> _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(1),
> *buf_obj, 0, sizeof(struct vertex));
> _mesa_enable_vertex_array_attrib(ctx, array_obj,
> VERT_ATTRIB_GENERIC(1));
> }
> } else {
> _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_POS,
> vertex_size, GL_FLOAT, GL_RGBA, GL_FALSE,
> GL_FALSE, GL_FALSE,
> - offsetof(struct vertex, x), true);
> + offsetof(struct vertex, x));
> _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS,
> *buf_obj, 0, sizeof(struct vertex));
> _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS);
>
> if (texcoord_size > 0) {
> _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_TEX(0),
> vertex_size, GL_FLOAT, GL_RGBA, GL_FALSE,
> GL_FALSE, GL_FALSE,
> - offsetof(struct vertex, tex), false);
> + offsetof(struct vertex, tex));
> _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(0),
> *buf_obj, 0, sizeof(struct vertex));
> _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_TEX(0));
> }
>
> if (color_size > 0) {
> _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_COLOR0,
> vertex_size, GL_FLOAT, GL_RGBA, GL_FALSE,
> GL_FALSE, GL_FALSE,
> - offsetof(struct vertex, r), false);
> + offsetof(struct vertex, r));
> _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_COLOR0,
> *buf_obj, 0, sizeof(struct vertex));
> _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_COLOR0);
> }
> }
> } else {
> _mesa_BindVertexArray(*VAO);
> }
> }
>
> diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
> index 92e3f4d..af5abc8 100644
> --- a/src/mesa/main/varray.c
> +++ b/src/mesa/main/varray.c
> @@ -273,31 +273,27 @@ get_legal_types_mask(const struct gl_context *ctx)
> * 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)
> + GLuint relativeOffset)
> {
> struct gl_array_attributes *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;
> @@ -432,22 +428,21 @@ update_array_format(struct gl_context *ctx,
> 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,
> - false);
> + normalized, integer, doubles, relativeOffset);
>
> return true;
> }
>
>
> /**
> * Do error checking and update state for glVertex/Color/TexCoord/...Pointer
> * functions.
> *
> * \param func name of calling function used for error reporting
> diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
> index 8c30d16..9216571 100644
> --- a/src/mesa/main/varray.h
> +++ b/src/mesa/main/varray.h
> @@ -87,21 +87,21 @@ _mesa_attr_zero_aliases_vertex(struct gl_context *ctx)
> || (ctx->API == API_OPENGL_COMPAT
> && !is_forward_compatible_context));
> }
>
> 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);
> + GLuint relativeOffset);
>
> extern void
> _mesa_enable_vertex_array_attrib(struct gl_context *ctx,
> struct gl_vertex_array_object *vao,
> unsigned attrib);
>
> extern void
> _mesa_bind_vertex_buffer(struct gl_context *ctx,
> struct gl_vertex_array_object *vao,
> GLuint index,
>
Reviewed-by: Brian Paul <brianp at vmware.com>
More information about the mesa-dev
mailing list