From 88c1c336c50b113c69dcc7cab4d45f259c52cfb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B6glund?= Date: Thu, 23 Jan 2014 18:47:44 +0100 Subject: [PATCH 1/2] mesa: Don't use derived vertex state in api_arrayelt.c --- src/mesa/main/api_arrayelt.c | 103 +++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c index f439b70..76efe5a 100644 --- a/src/mesa/main/api_arrayelt.c +++ b/src/mesa/main/api_arrayelt.c @@ -43,18 +43,21 @@ #include "macros.h" #include "mtypes.h" #include "main/dispatch.h" +#include "varray.h" typedef void (GLAPIENTRY *array_func)( const void * ); typedef struct { - const struct gl_client_array *array; + const struct gl_vertex_attrib_array *array; + const struct gl_vertex_buffer_binding *binding; int offset; } AEarray; typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data ); typedef struct { - const struct gl_client_array *array; + const struct gl_vertex_attrib_array *array; + const struct gl_vertex_buffer_binding *binding; attrib_func func; GLuint index; } AEattrib; @@ -1469,18 +1472,6 @@ check_vbo(AEcontext *actx, struct gl_buffer_object *vbo) } -static inline void -update_derived_client_arrays(struct gl_context *ctx) -{ - struct gl_array_object *arrayObj = ctx->Array.ArrayObj; - - if (arrayObj->NewArrays) { - _mesa_update_array_object_client_arrays(ctx, arrayObj); - arrayObj->NewArrays = 0; - } -} - - /** * Make a list of per-vertex functions to call for each glArrayElement call. * These functions access the array data (i.e. glVertex, glColor, glNormal, @@ -1499,67 +1490,75 @@ _ae_update_state(struct gl_context *ctx) actx->nr_vbos = 0; /* conventional vertex arrays */ - if (arrayObj->_VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) { - aa->array = &arrayObj->_VertexAttrib[VERT_ATTRIB_COLOR_INDEX]; + if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) { + aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]; + aa->binding = &arrayObj->VertexBinding[aa->array->VertexBinding]; aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); + check_vbo(actx, aa->binding->BufferObj); aa++; } - if (arrayObj->_VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) { - aa->array = &arrayObj->_VertexAttrib[VERT_ATTRIB_EDGEFLAG]; + if (arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) { + aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]; + aa->binding = &arrayObj->VertexBinding[aa->array->VertexBinding]; aa->offset = _gloffset_EdgeFlagv; - check_vbo(actx, aa->array->BufferObj); + check_vbo(actx, aa->binding->BufferObj); aa++; } - if (arrayObj->_VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { - aa->array = &arrayObj->_VertexAttrib[VERT_ATTRIB_NORMAL]; + if (arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { + aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]; + aa->binding = &arrayObj->VertexBinding[aa->array->VertexBinding]; aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); + check_vbo(actx, aa->binding->BufferObj); aa++; } - if (arrayObj->_VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) { - aa->array = &arrayObj->_VertexAttrib[VERT_ATTRIB_COLOR0]; + if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) { + aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]; + aa->binding = &arrayObj->VertexBinding[aa->array->VertexBinding]; aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); + check_vbo(actx, aa->binding->BufferObj); aa++; } - if (arrayObj->_VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) { - aa->array = &arrayObj->_VertexAttrib[VERT_ATTRIB_COLOR1]; + if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) { + aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1]; + aa->binding = &arrayObj->VertexBinding[aa->array->VertexBinding]; aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); + check_vbo(actx, aa->binding->BufferObj); aa++; } - if (arrayObj->_VertexAttrib[VERT_ATTRIB_FOG].Enabled) { - aa->array = &arrayObj->_VertexAttrib[VERT_ATTRIB_FOG]; + if (arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) { + aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_FOG]; + aa->binding = &arrayObj->VertexBinding[aa->array->VertexBinding]; aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); + check_vbo(actx, aa->binding->BufferObj); aa++; } for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { - struct gl_client_array *attribArray = - &arrayObj->_VertexAttrib[VERT_ATTRIB_TEX(i)]; + struct gl_vertex_attrib_array *attribArray = + &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)]; if (attribArray->Enabled) { /* NOTE: we use generic glVertexAttribNV functions here. * If we ever remove GL_NV_vertex_program this will have to change. */ at->array = attribArray; + at->binding = &arrayObj->VertexBinding[attribArray->VertexBinding]; ASSERT(!at->array->Normalized); at->func = AttribFuncsNV[at->array->Normalized] [at->array->Size-1] [TYPE_IDX(at->array->Type)]; at->index = VERT_ATTRIB_TEX0 + i; - check_vbo(actx, at->array->BufferObj); + check_vbo(actx, at->binding->BufferObj); at++; } } /* generic vertex attribute arrays */ for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) { /* skip zero! */ - struct gl_client_array *attribArray = - &arrayObj->_VertexAttrib[VERT_ATTRIB_GENERIC(i)]; + struct gl_vertex_attrib_array *attribArray = + &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)]; if (attribArray->Enabled) { GLint intOrNorm; at->array = attribArray; + at->binding = &arrayObj->VertexBinding[attribArray->VertexBinding]; /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV * function pointer here (for float arrays) since the pointer may * change from one execution of _ae_ArrayElement() to @@ -1577,26 +1576,28 @@ _ae_update_state(struct gl_context *ctx) [TYPE_IDX(at->array->Type)]; at->index = i; - check_vbo(actx, at->array->BufferObj); + check_vbo(actx, at->binding->BufferObj); at++; } } /* finally, vertex position */ - if (arrayObj->_VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) { + if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) { /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's * issued as the last (provoking) attribute). */ - aa->array = &arrayObj->_VertexAttrib[VERT_ATTRIB_GENERIC0]; + aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0]; + aa->binding = &arrayObj->VertexBinding[aa->array->VertexBinding]; assert(aa->array->Size >= 2); /* XXX fix someday? */ aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); + check_vbo(actx, aa->binding->BufferObj); aa++; } - else if (arrayObj->_VertexAttrib[VERT_ATTRIB_POS].Enabled) { - aa->array = &arrayObj->_VertexAttrib[VERT_ATTRIB_POS]; + else if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) { + aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_POS]; + aa->binding = &arrayObj->VertexBinding[aa->array->VertexBinding]; aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); + check_vbo(actx, aa->binding->BufferObj); aa++; } @@ -1624,8 +1625,6 @@ _ae_map_vbos(struct gl_context *ctx) if (actx->mapped_vbos) return; - update_derived_client_arrays(ctx); - if (actx->NewState) _ae_update_state(ctx); @@ -1677,8 +1676,6 @@ _ae_ArrayElement(GLint elt) const struct _glapi_table * const disp = GET_DISPATCH(); GLboolean do_map; - update_derived_client_arrays(ctx); - /* If PrimitiveRestart is enabled and the index is the RestartIndex * then we call PrimitiveRestartNV and return. */ @@ -1701,16 +1698,18 @@ _ae_ArrayElement(GLint elt) /* emit generic attribute elements */ for (at = actx->attribs; at->func; at++) { const GLubyte *src - = ADD_POINTERS(at->array->BufferObj->Pointer, at->array->Ptr) - + elt * at->array->StrideB; + = ADD_POINTERS(at->binding->BufferObj->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->array->BufferObj->Pointer, aa->array->Ptr) - + elt * aa->array->StrideB; + = ADD_POINTERS(aa->binding->BufferObj->Pointer, + _mesa_vertex_attrib_address(aa->array, aa->binding)) + + elt * aa->binding->Stride; CALL_by_offset(disp, (array_func), aa->offset, ((const void *) src)); } -- 1.8.5.3