X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fapi_arrayelt.c;h=2dfa74f64b3571fafcd906e184dfdf6264ea9481;hb=aeade86db5761313f8b8c3c8555d3813d92e92ff;hp=c84db5f97f6eb3fb41748194364f81e108317be4;hpb=83c86e09a8d7610022eae49731ac1ed03ee4f67b;p=mesa.git diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c index c84db5f97f6..2dfa74f64b3 100644 --- a/src/mesa/main/api_arrayelt.c +++ b/src/mesa/main/api_arrayelt.c @@ -48,7 +48,7 @@ typedef void (GLAPIENTRY *array_func)( const void * ); typedef struct { - const struct gl_vertex_attrib_array *array; + const struct gl_array_attributes *array; const struct gl_vertex_buffer_binding *binding; int offset; } AEarray; @@ -56,7 +56,7 @@ typedef struct { typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data ); typedef struct { - const struct gl_vertex_attrib_array *array; + const struct gl_array_attributes *array; const struct gl_vertex_buffer_binding *binding; attrib_func func; GLuint index; @@ -65,12 +65,13 @@ typedef struct { typedef struct { AEarray arrays[32]; AEattrib attribs[VERT_ATTRIB_MAX + 1]; - GLbitfield NewState; /* List of VBOs we need to map before executing ArrayElements */ struct gl_buffer_object *vbo[VERT_ATTRIB_MAX]; GLuint nr_vbos; GLboolean mapped_vbos; /**< Any currently mapped VBOs? */ + + bool dirty_state; } AEcontext; @@ -94,6 +95,13 @@ TYPE_IDX(GLenum t) } +bool +_ae_is_state_dirty(struct gl_context *ctx) +{ + return AE_CONTEXT(ctx)->dirty_state; +} + + #define NUM_TYPES 8 @@ -1288,7 +1296,7 @@ VertexAttribL4dv(GLuint index, const GLdouble *v) * Array [unnormalized/normalized/integer][size][type] of VertexAttrib * functions */ -static attrib_func AttribFuncsARB[4][4][NUM_TYPES] = { +static const attrib_func AttribFuncsARB[4][4][NUM_TYPES] = { { /* non-normalized */ { @@ -1511,7 +1519,7 @@ _ae_create_context(struct gl_context *ctx) if (!ctx->aelt_context) return GL_FALSE; - AE_CONTEXT(ctx)->NewState = ~0; + AE_CONTEXT(ctx)->dirty_state = true; return GL_TRUE; } @@ -1566,7 +1574,7 @@ _ae_update_state(struct gl_context *ctx) /* conventional vertex arrays */ if (vao->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) { aa->array = &vao->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]; - aa->binding = &vao->VertexBinding[aa->array->VertexBinding]; + aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex]; aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)]; check_vbo(actx, aa->binding->BufferObj); aa++; @@ -1574,7 +1582,7 @@ _ae_update_state(struct gl_context *ctx) if (vao->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) { aa->array = &vao->VertexAttrib[VERT_ATTRIB_EDGEFLAG]; - aa->binding = &vao->VertexBinding[aa->array->VertexBinding]; + aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex]; aa->offset = _gloffset_EdgeFlagv; check_vbo(actx, aa->binding->BufferObj); aa++; @@ -1582,7 +1590,7 @@ _ae_update_state(struct gl_context *ctx) if (vao->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { aa->array = &vao->VertexAttrib[VERT_ATTRIB_NORMAL]; - aa->binding = &vao->VertexBinding[aa->array->VertexBinding]; + aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex]; aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)]; check_vbo(actx, aa->binding->BufferObj); aa++; @@ -1590,7 +1598,7 @@ _ae_update_state(struct gl_context *ctx) if (vao->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) { aa->array = &vao->VertexAttrib[VERT_ATTRIB_COLOR0]; - aa->binding = &vao->VertexBinding[aa->array->VertexBinding]; + aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex]; aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)]; check_vbo(actx, aa->binding->BufferObj); aa++; @@ -1598,7 +1606,7 @@ _ae_update_state(struct gl_context *ctx) if (vao->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) { aa->array = &vao->VertexAttrib[VERT_ATTRIB_COLOR1]; - aa->binding = &vao->VertexBinding[aa->array->VertexBinding]; + aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex]; aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)]; check_vbo(actx, aa->binding->BufferObj); aa++; @@ -1606,21 +1614,21 @@ _ae_update_state(struct gl_context *ctx) if (vao->VertexAttrib[VERT_ATTRIB_FOG].Enabled) { aa->array = &vao->VertexAttrib[VERT_ATTRIB_FOG]; - aa->binding = &vao->VertexBinding[aa->array->VertexBinding]; + aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex]; aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)]; check_vbo(actx, aa->binding->BufferObj); aa++; } for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { - struct gl_vertex_attrib_array *attribArray = + struct gl_array_attributes *attribArray = &vao->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 = &vao->VertexBinding[attribArray->VertexBinding]; + at->binding = &vao->BufferBinding[attribArray->BufferBindingIndex]; assert(!at->array->Normalized); at->func = AttribFuncsNV[at->array->Normalized] [at->array->Size-1] @@ -1633,12 +1641,12 @@ _ae_update_state(struct gl_context *ctx) /* generic vertex attribute arrays */ for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) { /* skip zero! */ - struct gl_vertex_attrib_array *attribArray = + struct gl_array_attributes *attribArray = &vao->VertexAttrib[VERT_ATTRIB_GENERIC(i)]; if (attribArray->Enabled) { GLint intOrNorm; at->array = attribArray; - at->binding = &vao->VertexBinding[attribArray->VertexBinding]; + at->binding = &vao->BufferBinding[attribArray->BufferBindingIndex]; /* 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 @@ -1669,7 +1677,7 @@ _ae_update_state(struct gl_context *ctx) * issued as the last (provoking) attribute). */ aa->array = &vao->VertexAttrib[VERT_ATTRIB_GENERIC0]; - aa->binding = &vao->VertexBinding[aa->array->VertexBinding]; + aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex]; assert(aa->array->Size >= 2); /* XXX fix someday? */ aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; check_vbo(actx, aa->binding->BufferObj); @@ -1677,7 +1685,7 @@ _ae_update_state(struct gl_context *ctx) } else if (vao->VertexAttrib[VERT_ATTRIB_POS].Enabled) { aa->array = &vao->VertexAttrib[VERT_ATTRIB_POS]; - aa->binding = &vao->VertexBinding[aa->array->VertexBinding]; + aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex]; aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; check_vbo(actx, aa->binding->BufferObj); aa++; @@ -1690,7 +1698,7 @@ _ae_update_state(struct gl_context *ctx) at->func = NULL; /* terminate the list */ aa->offset = -1; /* terminate the list */ - actx->NewState = 0; + actx->dirty_state = false; } @@ -1707,7 +1715,7 @@ _ae_map_vbos(struct gl_context *ctx) if (actx->mapped_vbos) return; - if (actx->NewState) + if (actx->dirty_state) _ae_update_state(ctx); for (i = 0; i < actx->nr_vbos; i++) @@ -1734,7 +1742,7 @@ _ae_unmap_vbos(struct gl_context *ctx) if (!actx->mapped_vbos) return; - assert (!actx->NewState); + assert (!actx->dirty_state); for (i = 0; i < actx->nr_vbos; i++) ctx->Driver.UnmapBuffer(ctx, actx->vbo[i], MAP_INTERNAL); @@ -1767,7 +1775,7 @@ _ae_ArrayElement(GLint elt) return; } - if (actx->NewState) { + if (actx->dirty_state) { assert(!actx->mapped_vbos); _ae_update_state(ctx); } @@ -1802,7 +1810,7 @@ _ae_ArrayElement(GLint elt) void -_ae_invalidate_state(struct gl_context *ctx, GLbitfield new_state) +_ae_invalidate_state(struct gl_context *ctx) { AEcontext *actx = AE_CONTEXT(ctx); @@ -1815,11 +1823,10 @@ _ae_invalidate_state(struct gl_context *ctx, GLbitfield new_state) * Luckily, neither the drivers nor tnl muck with the state that * concerns us here: */ - new_state &= _NEW_ARRAY | _NEW_PROGRAM; - if (new_state) { - assert(!actx->mapped_vbos); - actx->NewState |= new_state; - } + assert(ctx->NewState & (_NEW_ARRAY | _NEW_PROGRAM)); + + assert(!actx->mapped_vbos); + actx->dirty_state = true; }