summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/bufferobj.c
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2006-06-12 16:26:29 +0000
committerIan Romanick <[email protected]>2006-06-12 16:26:29 +0000
commitee34e6ef716bb630440299ac1efbc2055ef09ffd (patch)
tree561a6314f8115c8dfafc7a3336c89d43f21a301a /src/mesa/main/bufferobj.c
parent6254d5904366ae17cb707ee70ff1ce76092f9c81 (diff)
Add support for GL_APPLE_vertex_array_object. Several test programs
and demos are also added. Adding basic support to drivers should be as easy as just enabling the extension, though thorough test would also be required.
Diffstat (limited to 'src/mesa/main/bufferobj.c')
-rw-r--r--src/mesa/main/bufferobj.c80
1 files changed, 37 insertions, 43 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index d6cc78e18d5..6deb823f348 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -169,6 +169,22 @@ _mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
}
+void
+_mesa_unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
+{
+ if (bufObj != ctx->Array.NullBufferObj) {
+ bufObj->RefCount--;
+ if (bufObj->RefCount <= 0) {
+ ASSERT(ctx->Array.ArrayBufferObj != bufObj);
+ ASSERT(ctx->Array.ElementArrayBufferObj != bufObj);
+ ASSERT(ctx->Array.ArrayObj->Vertex.BufferObj != bufObj);
+ ASSERT(ctx->Driver.DeleteBuffer);
+ ctx->Driver.DeleteBuffer(ctx, bufObj);
+ }
+ }
+}
+
+
/**
* Initialize a buffer object to default values.
*/
@@ -389,21 +405,6 @@ _mesa_init_buffer_objects( GLcontext *ctx )
ctx->Array.ArrayBufferObj = ctx->Array.NullBufferObj;
ctx->Array.ElementArrayBufferObj = ctx->Array.NullBufferObj;
-
- /* Vertex array buffers */
- ctx->Array.Vertex.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.Normal.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.Color.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.SecondaryColor.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.FogCoord.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.Index.BufferObj = ctx->Array.NullBufferObj;
- for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- ctx->Array.TexCoord[i].BufferObj = ctx->Array.NullBufferObj;
- }
- ctx->Array.EdgeFlag.BufferObj = ctx->Array.NullBufferObj;
- for (i = 0; i < VERT_ATTRIB_MAX; i++) {
- ctx->Array.VertexAttrib[i].BufferObj = ctx->Array.NullBufferObj;
- }
}
@@ -585,52 +586,52 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
ASSERT(bufObj->Name == ids[i]);
- if (ctx->Array.Vertex.BufferObj == bufObj) {
+ if (ctx->Array.ArrayObj->Vertex.BufferObj == bufObj) {
bufObj->RefCount--;
- ctx->Array.Vertex.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.ArrayObj->Vertex.BufferObj = ctx->Array.NullBufferObj;
ctx->Array.NullBufferObj->RefCount++;
}
- if (ctx->Array.Normal.BufferObj == bufObj) {
+ if (ctx->Array.ArrayObj->Normal.BufferObj == bufObj) {
bufObj->RefCount--;
- ctx->Array.Normal.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.ArrayObj->Normal.BufferObj = ctx->Array.NullBufferObj;
ctx->Array.NullBufferObj->RefCount++;
}
- if (ctx->Array.Color.BufferObj == bufObj) {
+ if (ctx->Array.ArrayObj->Color.BufferObj == bufObj) {
bufObj->RefCount--;
- ctx->Array.Color.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.ArrayObj->Color.BufferObj = ctx->Array.NullBufferObj;
ctx->Array.NullBufferObj->RefCount++;
}
- if (ctx->Array.SecondaryColor.BufferObj == bufObj) {
+ if (ctx->Array.ArrayObj->SecondaryColor.BufferObj == bufObj) {
bufObj->RefCount--;
- ctx->Array.SecondaryColor.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.ArrayObj->SecondaryColor.BufferObj = ctx->Array.NullBufferObj;
ctx->Array.NullBufferObj->RefCount++;
}
- if (ctx->Array.FogCoord.BufferObj == bufObj) {
+ if (ctx->Array.ArrayObj->FogCoord.BufferObj == bufObj) {
bufObj->RefCount--;
- ctx->Array.FogCoord.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.ArrayObj->FogCoord.BufferObj = ctx->Array.NullBufferObj;
ctx->Array.NullBufferObj->RefCount++;
}
- if (ctx->Array.Index.BufferObj == bufObj) {
+ if (ctx->Array.ArrayObj->Index.BufferObj == bufObj) {
bufObj->RefCount--;
- ctx->Array.Index.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.ArrayObj->Index.BufferObj = ctx->Array.NullBufferObj;
ctx->Array.NullBufferObj->RefCount++;
}
- if (ctx->Array.EdgeFlag.BufferObj == bufObj) {
+ if (ctx->Array.ArrayObj->EdgeFlag.BufferObj == bufObj) {
bufObj->RefCount--;
- ctx->Array.EdgeFlag.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.ArrayObj->EdgeFlag.BufferObj = ctx->Array.NullBufferObj;
ctx->Array.NullBufferObj->RefCount++;
}
for (j = 0; j < MAX_TEXTURE_UNITS; j++) {
- if (ctx->Array.TexCoord[j].BufferObj == bufObj) {
+ if (ctx->Array.ArrayObj->TexCoord[j].BufferObj == bufObj) {
bufObj->RefCount--;
- ctx->Array.TexCoord[j].BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.ArrayObj->TexCoord[j].BufferObj = ctx->Array.NullBufferObj;
ctx->Array.NullBufferObj->RefCount++;
}
}
for (j = 0; j < VERT_ATTRIB_MAX; j++) {
- if (ctx->Array.VertexAttrib[j].BufferObj == bufObj) {
+ if (ctx->Array.ArrayObj->VertexAttrib[j].BufferObj == bufObj) {
bufObj->RefCount--;
- ctx->Array.VertexAttrib[j].BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.ArrayObj->VertexAttrib[j].BufferObj = ctx->Array.NullBufferObj;
ctx->Array.NullBufferObj->RefCount++;
}
}
@@ -649,16 +650,9 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
_mesa_BindBufferARB( GL_PIXEL_UNPACK_BUFFER_EXT, 0 );
}
- /* The ID is immediately freed for re-use */
- _mesa_remove_buffer_object(ctx, bufObj);
- bufObj->RefCount--;
- if (bufObj->RefCount <= 0) {
- ASSERT(ctx->Array.ArrayBufferObj != bufObj);
- ASSERT(ctx->Array.ElementArrayBufferObj != bufObj);
- ASSERT(ctx->Array.Vertex.BufferObj != bufObj);
- ASSERT(ctx->Driver.DeleteBuffer);
- ctx->Driver.DeleteBuffer(ctx, bufObj);
- }
+ /* The ID is immediately freed for re-use */
+ _mesa_remove_buffer_object(ctx, bufObj);
+ _mesa_unbind_buffer_object(ctx, bufObj);
}
}