summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorMichal Krol <[email protected]>2010-02-09 14:25:41 +0100
committerMichal Krol <[email protected]>2010-02-09 14:52:52 +0100
commit01d7e3d5a25a7cc49b38f5561d00c2ff22c43e93 (patch)
treecaa96a292b385ab401544714bdb907b1d6ee478f /src/mesa/main
parenteeec2c3d951fed0d22e5dbf436d4a2d887e24221 (diff)
mesa: Enable true refcounting for NullBufferObj.
This object can be shared with another context, so we cannot just delete it when the owning context is being destroyed. Ensuring that buffer objects are properly refcounted guarantees NullBufferObj is destroyed when all references to it are removed.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/arrayobj.c4
-rw-r--r--src/mesa/main/bufferobj.c11
-rw-r--r--src/mesa/main/bufferobj.h3
-rw-r--r--src/mesa/main/context.c2
-rw-r--r--src/mesa/main/pixel.c8
-rw-r--r--src/mesa/main/shared.c6
6 files changed, 26 insertions, 8 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index fd35d4e38c9..e36137d3782 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -95,6 +95,10 @@ unbind_array_object_vbos(GLcontext *ctx, struct gl_array_object *obj)
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
}
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 2271550efe1..dabb1386ca4 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -556,6 +556,17 @@ _mesa_init_buffer_objects( GLcontext *ctx )
}
+void
+_mesa_free_buffer_objects( GLcontext *ctx )
+{
+ _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, NULL);
+ _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj, NULL);
+
+ _mesa_reference_buffer_object(ctx, &ctx->CopyReadBuffer, NULL);
+ _mesa_reference_buffer_object(ctx, &ctx->CopyWriteBuffer, NULL);
+}
+
+
/**
* Bind the specified target to buffer for the specified context.
* Called by glBindBuffer() and other functions.
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index 2931962ac08..f8bca5ff717 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -60,6 +60,9 @@ extern void
_mesa_init_buffer_objects( GLcontext *ctx );
extern void
+_mesa_free_buffer_objects( GLcontext *ctx );
+
+extern void
_mesa_update_default_objects_buffer_objects(GLcontext *ctx);
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index fccce51e852..591aa1121d1 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -955,6 +955,7 @@ _mesa_free_context_data( GLcontext *ctx )
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, NULL);
_mesa_free_attrib_data(ctx);
+ _mesa_free_buffer_objects(ctx);
_mesa_free_lighting_data( ctx );
_mesa_free_eval_data( ctx );
_mesa_free_texture_data( ctx );
@@ -974,6 +975,7 @@ _mesa_free_context_data( GLcontext *ctx )
#if FEATURE_ARB_pixel_buffer_object
_mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, NULL);
_mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, NULL);
+ _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj, NULL);
#endif
#if FEATURE_ARB_vertex_buffer_object
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index f6f9c1173a1..ca6ecd7bfb6 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -150,13 +150,17 @@ validate_pbo_access(GLcontext *ctx, struct gl_pixelstore_attrib *pack,
GLboolean ok;
/* Note, need to use DefaultPacking and Unpack's buffer object */
- ctx->DefaultPacking.BufferObj = pack->BufferObj;
+ _mesa_reference_buffer_object(ctx,
+ &ctx->DefaultPacking.BufferObj,
+ pack->BufferObj);
ok = _mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
format, type, ptr);
/* restore */
- ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj;
+ _mesa_reference_buffer_object(ctx,
+ &ctx->DefaultPacking.BufferObj,
+ ctx->Shared->NullBufferObj);
if (!ok) {
_mesa_error(ctx, GL_INVALID_OPERATION,
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index a7cf623c47d..b889364f0dc 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -95,12 +95,6 @@ _mesa_alloc_shared_state(GLcontext *ctx)
/* Allocate the default buffer object */
shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0, 0);
-#ifndef DEBUG
- /* Set refcount so high that it never gets deleted.
- * XXX with recent/improved refcounting this should be no longer be needed.
- */
- shared->NullBufferObj->RefCount = 1000 * 1000 * 1000;
-#endif
/* Create default texture objects */
for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {