[Mesa-dev] [PATCH 15/23] meta: Use internal functions for buffer object and VAO access

Anuj Phogat anuj.phogat at gmail.com
Tue Nov 10 10:43:41 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>
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
>  src/mesa/drivers/common/meta.c | 76 ++++++++++++++++++++++++------------------
>  1 file changed, 43 insertions(+), 33 deletions(-)
>
> diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
> index 8cf0bf9..3507927 100644
> --- a/src/mesa/drivers/common/meta.c
> +++ b/src/mesa/drivers/common/meta.c
> @@ -342,12 +342,16 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
>     GLuint VBO;
>
>     if (*VAO == 0) {
> +      struct gl_vertex_array_object *array_obj;
>        assert(*buf_obj == NULL);
>
>        /* create vertex array object */
>        _mesa_GenVertexArrays(1, VAO);
>        _mesa_BindVertexArray(*VAO);
>
> +      array_obj = _mesa_lookup_vao(ctx, *VAO);
> +      assert(array_obj != NULL);
> +
>        /* create vertex array buffer */
>        _mesa_CreateBuffers(1, &VBO);
>        *buf_obj = _mesa_lookup_bufferobj(ctx, VBO);
> @@ -360,8 +364,8 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
>        assert(*buf_obj != NULL && (*buf_obj)->Name == VBO);
>        assert(*buf_obj != ctx->Array.ArrayBufferObj);
>
> -      _mesa_NamedBufferData(VBO, 4 * sizeof(struct vertex), NULL,
> -                            GL_DYNAMIC_DRAW);
> +      _mesa_buffer_data(ctx, *buf_obj, GL_NONE, 4 * sizeof(struct vertex), NULL,
> +                        GL_DYNAMIC_DRAW, __func__);
>
>        assert((*buf_obj)->Size == 4 * sizeof(struct vertex));
>
> @@ -369,45 +373,51 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
>        if (use_generic_attributes) {
>           assert(color_size == 0);
>
> -         _mesa_VertexArrayAttribFormat(*VAO, 0, vertex_size, GL_FLOAT,
> -                                       GL_FALSE, OFFSET(x));
> -         _mesa_VertexArrayVertexBuffer(*VAO, 0, VBO, 0,
> -                                       sizeof(struct vertex));
> -         _mesa_EnableVertexAttribArray(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);
> +         _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_VertexArrayAttribFormat(*VAO, 1, texcoord_size, GL_FLOAT,
> -                                          GL_FALSE, OFFSET(tex));
> -            _mesa_VertexArrayVertexBuffer(*VAO, 1, VBO, 0,
> -                                          sizeof(struct vertex));
> -            _mesa_EnableVertexAttribArray(1);
> +            _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);
> +            _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_BindBuffer(GL_ARRAY_BUFFER, VBO);
> -         _mesa_VertexPointer(vertex_size, GL_FLOAT, sizeof(struct vertex),
> -                             OFFSET(x));
> -         _mesa_EnableClientState(GL_VERTEX_ARRAY);
> +         _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);
> +         _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_TexCoordPointer(texcoord_size, GL_FLOAT,
> -                                  sizeof(struct vertex), OFFSET(tex));
> -            _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY);
> +            _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);
> +            _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_ColorPointer(color_size, GL_FLOAT,
> -                               sizeof(struct vertex), OFFSET(r));
> -            _mesa_EnableClientState(GL_COLOR_ARRAY);
> -         }
> -
> -         /* Restore the old VBO.  This is done because we don't want the new VBO
> -          * to be bound on exit.  It would be nicer to use DSA type functions,
> -          * but there are no DSA functions to bind a VBO to a VAO for
> -          * fixed-function vertex attributes.
> -          */
> -         {
> -            struct save_state *save = &ctx->Meta->Save[ctx->Meta->SaveStackDepth - 1];
> -            _mesa_BindBuffer(GL_ARRAY_BUFFER, save->ArrayBufferObj->Name);
> +            _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);
> +            _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 {
> --
> 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