diff options
author | Ian Romanick <[email protected]> | 2015-11-03 16:47:22 -0800 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2015-11-24 11:31:29 -0800 |
commit | b1b73a42c8f245d5bf6bbed04071b2c6519b2fb4 (patch) | |
tree | 63e0eb3812196832e4adf2475da032ec4d155495 /src/mesa | |
parent | 52921f8e089abbc6871060fc50f90b62aaf1e11b (diff) |
meta: Use internal functions for buffer object and VAO access
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/common/meta.c | 76 |
1 files changed, 43 insertions, 33 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index e9bffe36a69..3eaeb496b31 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 { |