summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-05-07 13:30:39 -0600
committerBrian Paul <brianp@vmware.com>2009-05-07 14:34:09 -0600
commit4f6b704f9796775d8d9937c3cf75a2901b99b896 (patch)
tree9a5ac7599b7e6f7148b031358b2671a78fbf01ac /src/mesa/main
parent105c8529e78db961fee832b6248c3bcf59668bad (diff)
mesa: move the NullBufferObj from GLcontext to gl_shared_state
Since shared array objects may point to the null/default buffer object, the null/default buffer object should be part of the shared state.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/arrayobj.c5
-rw-r--r--src/mesa/main/bufferobj.c16
-rw-r--r--src/mesa/main/context.c3
-rw-r--r--src/mesa/main/mtypes.h3
-rw-r--r--src/mesa/main/pixel.c12
-rw-r--r--src/mesa/main/pixelstore.c9
-rw-r--r--src/mesa/main/shared.c12
7 files changed, 33 insertions, 27 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index b04095fd16..2646c12ccc 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -112,7 +112,8 @@ init_array(GLcontext *ctx,
array->Normalized = GL_FALSE;
#if FEATURE_ARB_vertex_buffer_object
/* Vertex array buffers */
- array->BufferObj = ctx->Array.NullBufferObj;
+ _mesa_reference_buffer_object(ctx, &array->BufferObj,
+ ctx->Shared->NullBufferObj);
#endif
}
@@ -180,7 +181,7 @@ _mesa_remove_array_object( GLcontext *ctx, struct gl_array_object *obj )
static void
unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
{
- if (bufObj != ctx->Array.NullBufferObj) {
+ if (bufObj != ctx->Shared->NullBufferObj) {
_mesa_reference_buffer_object(ctx, &bufObj, NULL);
}
}
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index a983376251..1f2070ef47 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -424,16 +424,8 @@ _mesa_buffer_unmap( GLcontext *ctx, GLenum target,
void
_mesa_init_buffer_objects( GLcontext *ctx )
{
- /* Allocate the default buffer object and set refcount so high that
- * it never gets deleted.
- * XXX with recent/improved refcounting this may not longer be needed.
- */
- ctx->Array.NullBufferObj = _mesa_new_buffer_object(ctx, 0, 0);
- if (ctx->Array.NullBufferObj)
- ctx->Array.NullBufferObj->RefCount = 1000;
-
- ctx->Array.ArrayBufferObj = ctx->Array.NullBufferObj;
- ctx->Array.ElementArrayBufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.ArrayBufferObj = ctx->Shared->NullBufferObj;
+ ctx->Array.ElementArrayBufferObj = ctx->Shared->NullBufferObj;
}
@@ -477,7 +469,7 @@ bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer)
/* The spec says there's not a buffer object named 0, but we use
* one internally because it simplifies things.
*/
- newBufObj = ctx->Array.NullBufferObj;
+ newBufObj = ctx->Shared->NullBufferObj;
}
else {
/* non-default buffer object */
@@ -744,7 +736,7 @@ unbind(GLcontext *ctx,
struct gl_buffer_object *obj)
{
if (*ptr == obj) {
- _mesa_reference_buffer_object(ctx, ptr, ctx->Array.NullBufferObj);
+ _mesa_reference_buffer_object(ctx, ptr, ctx->Shared->NullBufferObj);
}
}
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index d780f91f04..1a290f251a 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1005,9 +1005,6 @@ _mesa_free_context_data( GLcontext *ctx )
_mesa_free_query_data(ctx);
#endif
-#if FEATURE_ARB_vertex_buffer_object
- _mesa_delete_buffer_object(ctx, ctx->Array.NullBufferObj);
-#endif
_mesa_delete_array_object(ctx, ctx->Array.DefaultArrayObj);
/* free dispatch tables */
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index affb000b8c..3debbe9f2d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1593,7 +1593,6 @@ struct gl_array_attrib
GLbitfield NewState; /**< mask of _NEW_ARRAY_* values */
#if FEATURE_ARB_vertex_buffer_object
- struct gl_buffer_object *NullBufferObj;
struct gl_buffer_object *ArrayBufferObj;
struct gl_buffer_object *ElementArrayBufferObj;
#endif
@@ -2064,6 +2063,8 @@ struct gl_shared_state
GLuint TextureStateStamp; /**< state notification for shared tex */
/*@}*/
+ /** Default buffer object for vertex arrays that aren't in VBOs */
+ struct gl_buffer_object *NullBufferObj;
/**
* \name Vertex/fragment programs
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 57ae9c721a..d9f3e476e8 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -170,7 +170,7 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values )
return;
}
/* restore */
- ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+ ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj;
buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
GL_READ_ONLY_ARB,
ctx->Unpack.BufferObj);
@@ -229,7 +229,7 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values )
return;
}
/* restore */
- ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+ ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj;
buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
GL_READ_ONLY_ARB,
ctx->Unpack.BufferObj);
@@ -303,7 +303,7 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values )
return;
}
/* restore */
- ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+ ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj;
buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
GL_READ_ONLY_ARB,
ctx->Unpack.BufferObj);
@@ -371,7 +371,7 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values )
return;
}
/* restore */
- ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+ ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj;
buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
GL_WRITE_ONLY_ARB,
ctx->Pack.BufferObj);
@@ -432,7 +432,7 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values )
return;
}
/* restore */
- ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+ ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj;
buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
GL_WRITE_ONLY_ARB,
ctx->Pack.BufferObj);
@@ -494,7 +494,7 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values )
return;
}
/* restore */
- ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+ ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj;
buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
GL_WRITE_ONLY_ARB,
ctx->Pack.BufferObj);
diff --git a/src/mesa/main/pixelstore.c b/src/mesa/main/pixelstore.c
index ff1a6344cc..6a641f83f2 100644
--- a/src/mesa/main/pixelstore.c
+++ b/src/mesa/main/pixelstore.c
@@ -245,7 +245,8 @@ _mesa_init_pixelstore( GLcontext *ctx )
ctx->Pack.ClientStorage = GL_FALSE;
ctx->Pack.Invert = GL_FALSE;
#if FEATURE_EXT_pixel_buffer_object
- ctx->Pack.BufferObj = ctx->Array.NullBufferObj;
+ _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj,
+ ctx->Shared->NullBufferObj);
#endif
ctx->Unpack.Alignment = 4;
ctx->Unpack.RowLength = 0;
@@ -258,7 +259,8 @@ _mesa_init_pixelstore( GLcontext *ctx )
ctx->Unpack.ClientStorage = GL_FALSE;
ctx->Unpack.Invert = GL_FALSE;
#if FEATURE_EXT_pixel_buffer_object
- ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+ _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj,
+ ctx->Shared->NullBufferObj);
#endif
/*
@@ -278,6 +280,7 @@ _mesa_init_pixelstore( GLcontext *ctx )
ctx->DefaultPacking.ClientStorage = GL_FALSE;
ctx->DefaultPacking.Invert = GL_FALSE;
#if FEATURE_EXT_pixel_buffer_object
- ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+ _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj,
+ ctx->Shared->NullBufferObj);
#endif
}
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index ae8dd2a836..759883743d 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -33,6 +33,7 @@
#include "mtypes.h"
#include "hash.h"
#include "arrayobj.h"
+#include "bufferobj.h"
#include "shared.h"
#include "shader/program.h"
#include "shader/shader_api.h"
@@ -92,6 +93,13 @@ _mesa_alloc_shared_state(GLcontext *ctx)
shared->BufferObjects = _mesa_NewHashTable();
#endif
+ /* Allocate the default buffer object and set refcount so high that
+ * it never gets deleted.
+ * XXX with recent/improved refcounting this may not longer be needed.
+ */
+ shared->NullBufferObj = _mesa_new_buffer_object(ctx, 0, 0);
+ shared->NullBufferObj->RefCount = 1000;
+
shared->ArrayObjects = _mesa_NewHashTable();
/* Create default texture objects */
@@ -341,6 +349,10 @@ _mesa_free_shared_state(GLcontext *ctx, struct gl_shared_state *shared)
_mesa_DeleteHashTable(shared->RenderBuffers);
#endif
+#if FEATURE_ARB_vertex_buffer_object
+ _mesa_delete_buffer_object(ctx, shared->NullBufferObj);
+#endif
+
/*
* Free texture objects (after FBOs since some textures might have
* been bound to FBOs).