diff options
Diffstat (limited to 'mesalib/src/mesa/main/arrayobj.c')
-rw-r--r-- | mesalib/src/mesa/main/arrayobj.c | 100 |
1 files changed, 44 insertions, 56 deletions
diff --git a/mesalib/src/mesa/main/arrayobj.c b/mesalib/src/mesa/main/arrayobj.c index 1283940f7..0439063b1 100644 --- a/mesalib/src/mesa/main/arrayobj.c +++ b/mesalib/src/mesa/main/arrayobj.c @@ -85,24 +85,8 @@ unbind_array_object_vbos(struct gl_context *ctx, struct gl_array_object *obj) { GLuint i; - _mesa_reference_buffer_object(ctx, &obj->Vertex.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &obj->Weight.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &obj->Normal.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &obj->Color.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &obj->SecondaryColor.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &obj->FogCoord.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &obj->Index.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &obj->EdgeFlag.BufferObj, NULL); - - for (i = 0; i < Elements(obj->TexCoord); i++) - _mesa_reference_buffer_object(ctx, &obj->TexCoord[i].BufferObj, NULL); - for (i = 0; i < Elements(obj->VertexAttrib); i++) - _mesa_reference_buffer_object(ctx, &obj->VertexAttrib[i].BufferObj,NULL); - -#if FEATURE_point_size_array - _mesa_reference_buffer_object(ctx, &obj->PointSize.BufferObj, NULL); -#endif + _mesa_reference_buffer_object(ctx, &obj->VertexAttrib[i].BufferObj, NULL); } @@ -133,6 +117,7 @@ _mesa_delete_array_object( struct gl_context *ctx, struct gl_array_object *obj ) { (void) ctx; unbind_array_object_vbos(ctx, obj); + _mesa_reference_buffer_object(ctx, &obj->ElementArrayBufferObj, NULL); _glthread_DESTROY_MUTEX(obj->Mutex); free(obj); } @@ -234,24 +219,39 @@ _mesa_initialize_array_object( struct gl_context *ctx, obj->RefCount = 1; /* Init the individual arrays */ - init_array(ctx, &obj->Vertex, 4, GL_FLOAT); - init_array(ctx, &obj->Weight, 1, GL_FLOAT); - init_array(ctx, &obj->Normal, 3, GL_FLOAT); - init_array(ctx, &obj->Color, 4, GL_FLOAT); - init_array(ctx, &obj->SecondaryColor, 3, GL_FLOAT); - init_array(ctx, &obj->FogCoord, 1, GL_FLOAT); - init_array(ctx, &obj->Index, 1, GL_FLOAT); - for (i = 0; i < Elements(obj->TexCoord); i++) { - init_array(ctx, &obj->TexCoord[i], 4, GL_FLOAT); - } - init_array(ctx, &obj->EdgeFlag, 1, GL_BOOL); for (i = 0; i < Elements(obj->VertexAttrib); i++) { - init_array(ctx, &obj->VertexAttrib[i], 4, GL_FLOAT); - } - + switch (i) { + case VERT_ATTRIB_WEIGHT: + init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_WEIGHT], 1, GL_FLOAT); + break; + case VERT_ATTRIB_NORMAL: + init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_NORMAL], 3, GL_FLOAT); + break; + case VERT_ATTRIB_COLOR1: + init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_COLOR1], 3, GL_FLOAT); + break; + case VERT_ATTRIB_FOG: + init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_FOG], 1, GL_FLOAT); + break; + case VERT_ATTRIB_COLOR_INDEX: + init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX], 1, GL_FLOAT); + break; + case VERT_ATTRIB_EDGEFLAG: + init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_EDGEFLAG], 1, GL_BOOL); + break; #if FEATURE_point_size_array - init_array(ctx, &obj->PointSize, 1, GL_FLOAT); + case VERT_ATTRIB_POINT_SIZE: + init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_POINT_SIZE], 1, GL_FLOAT); + break; #endif + default: + init_array(ctx, &obj->VertexAttrib[i], 4, GL_FLOAT); + break; + } + } + + _mesa_reference_buffer_object(ctx, &obj->ElementArrayBufferObj, + ctx->Shared->NullBufferObj); } @@ -290,12 +290,9 @@ remove_array_object( struct gl_context *ctx, struct gl_array_object *obj ) static GLuint update_min(GLuint min, struct gl_client_array *array) { - if (array->Enabled) { - _mesa_update_array_max_element(array); - return MIN2(min, array->_MaxElement); - } - else - return min; + assert(array->Enabled); + _mesa_update_array_max_element(array); + return MIN2(min, array->_MaxElement); } @@ -306,23 +303,14 @@ void _mesa_update_array_object_max_element(struct gl_context *ctx, struct gl_array_object *arrayObj) { - GLuint i, min = ~0; - - min = update_min(min, &arrayObj->Vertex); - min = update_min(min, &arrayObj->Weight); - min = update_min(min, &arrayObj->Normal); - min = update_min(min, &arrayObj->Color); - min = update_min(min, &arrayObj->SecondaryColor); - min = update_min(min, &arrayObj->FogCoord); - min = update_min(min, &arrayObj->Index); - min = update_min(min, &arrayObj->EdgeFlag); -#if FEATURE_point_size_array - min = update_min(min, &arrayObj->PointSize); -#endif - for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) - min = update_min(min, &arrayObj->TexCoord[i]); - for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) - min = update_min(min, &arrayObj->VertexAttrib[i]); + GLbitfield64 enabled = arrayObj->_Enabled; + GLuint min = ~0u; + + while (enabled) { + GLint attrib = _mesa_ffsll(enabled) - 1; + enabled &= ~BITFIELD64_BIT(attrib); + min = update_min(min, &arrayObj->VertexAttrib[attrib]); + } /* _MaxElement is one past the last legal array element */ arrayObj->_MaxElement = min; @@ -380,7 +368,7 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, GLboolean genRequired) } ctx->NewState |= _NEW_ARRAY; - ctx->Array.NewState |= _NEW_ARRAY_ALL; + ctx->Array.NewState |= VERT_BIT_ALL; _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, newObj); /* Pass BindVertexArray call to device driver */ |