diff options
author | Mathias Fröhlich <[email protected]> | 2019-03-01 09:27:53 +0100 |
---|---|---|
committer | Mathias Fröhlich <[email protected]> | 2019-03-15 06:06:42 +0100 |
commit | 80e319485a5ba653856c107e7c84ee60d28251b1 (patch) | |
tree | 7f5eb3c7ae56536a877f0e2ecbd951d51f357432 | |
parent | 85fd380878619ee03453b4e85ebf5b4e9648b496 (diff) |
mesa: Factor out _mesa_array_element.
The factored out function handles emitting the vertex attributes
at the given index. The now public accessible function gets used
in the following patches.
Reviewed-by: Brian Paul <[email protected]>
Signed-off-by: Mathias Fröhlich <[email protected]>
-rw-r--r-- | src/mesa/main/api_arrayelt.c | 49 | ||||
-rw-r--r-- | src/mesa/main/api_arrayelt.h | 2 |
2 files changed, 32 insertions, 19 deletions
diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c index 2b59c478d9e..cb0d2a28a6c 100644 --- a/src/mesa/main/api_arrayelt.c +++ b/src/mesa/main/api_arrayelt.c @@ -1751,6 +1751,35 @@ _ae_unmap_vbos(struct gl_context *ctx) } +void +_mesa_array_element(struct gl_context *ctx, + struct _glapi_table *disp, GLint elt) +{ + const AEcontext *actx = AE_CONTEXT(ctx); + + if (actx->dirty_state) + _ae_update_state(ctx); + + /* emit generic attribute elements */ + for (const AEattrib *at = actx->attribs; at->func; at++) { + const GLubyte *src + = ADD_POINTERS(at->binding->BufferObj->Mappings[MAP_INTERNAL].Pointer, + _mesa_vertex_attrib_address(at->array, at->binding)) + + elt * at->binding->Stride; + at->func(at->index, src); + } + + /* emit conventional arrays elements */ + for (const AEarray *aa = actx->arrays; aa->offset != -1 ; aa++) { + const GLubyte *src + = ADD_POINTERS(aa->binding->BufferObj->Mappings[MAP_INTERNAL].Pointer, + _mesa_vertex_attrib_address(aa->array, aa->binding)) + + elt * aa->binding->Stride; + CALL_by_offset(disp, (array_func), aa->offset, ((const void *) src)); + } +} + + /** * Called via glArrayElement() and glDrawArrays(). * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions @@ -1762,8 +1791,6 @@ _ae_ArrayElement(GLint elt) { GET_CURRENT_CONTEXT(ctx); const AEcontext *actx = AE_CONTEXT(ctx); - const AEarray *aa; - const AEattrib *at; const struct _glapi_table * const disp = GET_DISPATCH(); GLboolean do_map; @@ -1786,23 +1813,7 @@ _ae_ArrayElement(GLint elt) if (do_map) _ae_map_vbos(ctx); - /* emit generic attribute elements */ - for (at = actx->attribs; at->func; at++) { - const GLubyte *src - = ADD_POINTERS(at->binding->BufferObj->Mappings[MAP_INTERNAL].Pointer, - _mesa_vertex_attrib_address(at->array, at->binding)) - + elt * at->binding->Stride; - at->func(at->index, src); - } - - /* emit conventional arrays elements */ - for (aa = actx->arrays; aa->offset != -1 ; aa++) { - const GLubyte *src - = ADD_POINTERS(aa->binding->BufferObj->Mappings[MAP_INTERNAL].Pointer, - _mesa_vertex_attrib_address(aa->array, aa->binding)) - + elt * aa->binding->Stride; - CALL_by_offset(disp, (array_func), aa->offset, ((const void *) src)); - } + _mesa_array_element(ctx, (struct _glapi_table *)disp, elt); if (do_map) _ae_unmap_vbos(ctx); diff --git a/src/mesa/main/api_arrayelt.h b/src/mesa/main/api_arrayelt.h index 6543a58f724..d0412806153 100644 --- a/src/mesa/main/api_arrayelt.h +++ b/src/mesa/main/api_arrayelt.h @@ -36,6 +36,8 @@ extern GLboolean _ae_create_context( struct gl_context *ctx ); extern void _ae_destroy_context( struct gl_context *ctx ); extern void _ae_invalidate_state(struct gl_context *ctx); extern bool _ae_is_state_dirty(struct gl_context *ctx); +extern void _mesa_array_element(struct gl_context *ctx, + struct _glapi_table *disp, GLint elt); extern void GLAPIENTRY _ae_ArrayElement( GLint elt ); /* May optionally be called before a batch of element calls: |