1071
static void check_vbo( AEcontext *actx,
1072
struct gl_buffer_object *vbo )
1074
if (vbo->Name && !vbo->Pointer) {
1076
for (i = 0; i < actx->nr_vbos; i++)
1077
if (actx->vbo[i] == vbo)
1079
assert(actx->nr_vbos < VERT_ATTRIB_MAX);
1080
actx->vbo[actx->nr_vbos++] = vbo;
1068
1086
* Make a list of per-vertex functions to call for each glArrayElement call.
1077
1095
AEattrib *at = actx->attribs;
1080
1100
/* conventional vertex arrays */
1081
1101
if (ctx->Array.ArrayObj->Index.Enabled) {
1082
1102
aa->array = &ctx->Array.ArrayObj->Index;
1083
1103
aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
1104
check_vbo(actx, aa->array->BufferObj);
1086
1107
if (ctx->Array.ArrayObj->EdgeFlag.Enabled) {
1087
1108
aa->array = &ctx->Array.ArrayObj->EdgeFlag;
1088
1109
aa->offset = _gloffset_EdgeFlagv;
1110
check_vbo(actx, aa->array->BufferObj);
1091
1113
if (ctx->Array.ArrayObj->Normal.Enabled) {
1092
1114
aa->array = &ctx->Array.ArrayObj->Normal;
1093
1115
aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
1116
check_vbo(actx, aa->array->BufferObj);
1096
1119
if (ctx->Array.ArrayObj->Color.Enabled) {
1097
1120
aa->array = &ctx->Array.ArrayObj->Color;
1098
1121
aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
1122
check_vbo(actx, aa->array->BufferObj);
1101
1125
if (ctx->Array.ArrayObj->SecondaryColor.Enabled) {
1102
1126
aa->array = &ctx->Array.ArrayObj->SecondaryColor;
1103
1127
aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
1128
check_vbo(actx, aa->array->BufferObj);
1106
1131
if (ctx->Array.ArrayObj->FogCoord.Enabled) {
1107
1132
aa->array = &ctx->Array.ArrayObj->FogCoord;
1108
1133
aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
1134
check_vbo(actx, aa->array->BufferObj);
1111
1137
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
1120
1146
[at->array->Size-1]
1121
1147
[TYPE_IDX(at->array->Type)];
1122
1148
at->index = VERT_ATTRIB_TEX0 + i;
1149
check_vbo(actx, at->array->BufferObj);
1127
/* generic vertex attribute arrays */
1154
/* generic vertex attribute arrays */
1128
1155
for (i = 1; i < VERT_ATTRIB_MAX; i++) { /* skip zero! */
1129
1156
struct gl_client_array *attribArray = &ctx->Array.ArrayObj->VertexAttrib[i];
1130
1157
if (attribArray->Enabled) {
1158
1186
aa->array = &ctx->Array.ArrayObj->VertexAttrib[0];
1159
1187
assert(aa->array->Size >= 2); /* XXX fix someday? */
1160
1188
aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
1189
check_vbo(actx, aa->array->BufferObj);
1163
1192
else if (ctx->Array.ArrayObj->Vertex.Enabled) {
1164
1193
aa->array = &ctx->Array.ArrayObj->Vertex;
1165
1194
aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
1195
check_vbo(actx, aa->array->BufferObj);
1199
check_vbo(actx, ctx->Array.ElementArrayBufferObj);
1169
1201
ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
1170
1202
ASSERT(aa - actx->arrays < 32);
1171
1203
at->func = NULL; /* terminate the list */
1174
1206
actx->NewState = 0;
1209
void _ae_map_vbos( GLcontext *ctx )
1211
AEcontext *actx = AE_CONTEXT(ctx);
1214
if (actx->mapped_vbos)
1218
_ae_update_state(ctx);
1220
for (i = 0; i < actx->nr_vbos; i++)
1221
ctx->Driver.MapBuffer(ctx,
1222
GL_ARRAY_BUFFER_ARB,
1223
GL_DYNAMIC_DRAW_ARB,
1227
actx->mapped_vbos = GL_TRUE;
1230
void _ae_unmap_vbos( GLcontext *ctx )
1232
AEcontext *actx = AE_CONTEXT(ctx);
1235
if (!actx->mapped_vbos)
1238
assert (!actx->NewState);
1240
for (i = 0; i < actx->nr_vbos; i++)
1241
ctx->Driver.UnmapBuffer(ctx,
1242
GL_ARRAY_BUFFER_ARB,
1245
actx->mapped_vbos = GL_FALSE;
1179
1250
* Called via glArrayElement() and glDrawArrays().
1188
1259
const AEarray *aa;
1189
1260
const AEattrib *at;
1190
1261
const struct _glapi_table * const disp = GET_DISPATCH();
1264
if (actx->NewState) {
1265
assert(!actx->mapped_vbos);
1194
1266
_ae_update_state( ctx );
1269
do_map = actx->nr_vbos && !actx->mapped_vbos;
1196
1276
/* generic attributes */
1197
1277
for (at = actx->attribs; at->func; at++) {
1198
1278
const GLubyte *src
1199
= ADD_POINTERS(at->array->BufferObj->Data, at->array->Ptr)
1279
= ADD_POINTERS(at->array->BufferObj->Pointer, at->array->Ptr)
1200
1280
+ elt * at->array->StrideB;
1201
1281
at->func( at->index, src );
1204
1284
/* conventional arrays */
1205
1285
for (aa = actx->arrays; aa->offset != -1 ; aa++) {
1206
1286
const GLubyte *src
1207
= ADD_POINTERS(aa->array->BufferObj->Data, aa->array->Ptr)
1287
= ADD_POINTERS(aa->array->BufferObj->Pointer, aa->array->Ptr)
1208
1288
+ elt * aa->array->StrideB;
1209
1289
CALL_by_offset( disp, (array_func), aa->offset,
1210
1290
((const void *) src) );
1294
_ae_unmap_vbos(ctx);
1215
1298
void _ae_invalidate_state( GLcontext *ctx, GLuint new_state )
1217
AE_CONTEXT(ctx)->NewState |= new_state;
1300
AEcontext *actx = AE_CONTEXT(ctx);
1303
/* Only interested in this subset of mesa state. Need to prune
1304
* this down as both tnl/ and the drivers can raise statechanges
1305
* for arcane reasons in the middle of seemingly atomic operations
1306
* like DrawElements, over which we'd like to keep a known set of
1307
* arrays and vbo's mapped.
1309
* Luckily, neither the drivers nor tnl muck with the state that
1312
new_state &= _NEW_ARRAY | _NEW_PROGRAM;
1314
assert(!actx->mapped_vbos);
1315
actx->NewState |= new_state;