summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBen Skeggs <[email protected]>2008-09-11 06:09:05 +1000
committerBen Skeggs <[email protected]>2008-09-11 06:09:05 +1000
commit7158203b081ad34c03382f07e0df748eae235e9b (patch)
treeee61efebbafb5464ec090c21b5e05533588789a1 /src/mesa/main
parent02025148c28d03d644e3d66dde1a423fe21e1c44 (diff)
parenteb5b16d278e0f7ee0121049e43dfee1d52f2b0f7 (diff)
Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
Conflicts: configs/default
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/arrayobj.c33
-rw-r--r--src/mesa/main/attrib.c89
-rw-r--r--src/mesa/main/bufferobj.c188
-rw-r--r--src/mesa/main/bufferobj.h11
-rw-r--r--src/mesa/main/context.c4
-rw-r--r--src/mesa/main/context.h3
-rw-r--r--src/mesa/main/ffvertex_prog.c54
-rw-r--r--src/mesa/main/framebuffer.c12
-rw-r--r--src/mesa/main/points.c4
-rw-r--r--src/mesa/main/texobj.c101
-rw-r--r--src/mesa/main/texstore.c4
-rw-r--r--src/mesa/main/varray.c15
12 files changed, 292 insertions, 226 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index d62661e2b52..14612393176 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 7.2
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* (C) Copyright IBM Corporation 2006
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -77,7 +77,7 @@ lookup_arrayobj(GLcontext *ctx, GLuint id)
struct gl_array_object *
_mesa_new_array_object( GLcontext *ctx, GLuint name )
{
- struct gl_array_object *obj = MALLOC_STRUCT(gl_array_object);
+ struct gl_array_object *obj = CALLOC_STRUCT(gl_array_object);
if (obj)
_mesa_initialize_array_object(ctx, obj, name);
return obj;
@@ -219,6 +219,15 @@ _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) {
+ _mesa_reference_buffer_object(ctx, &bufObj, NULL);
+ }
+}
+
+
/**********************************************************************/
/* API Functions */
/**********************************************************************/
@@ -320,18 +329,18 @@ _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids)
/* Unbind any buffer objects that might be bound to arrays in
* this array object.
*/
- _mesa_unbind_buffer_object( ctx, obj->Vertex.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->Normal.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->Color.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->SecondaryColor.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->FogCoord.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->Index.BufferObj );
+ unbind_buffer_object( ctx, obj->Vertex.BufferObj );
+ unbind_buffer_object( ctx, obj->Normal.BufferObj );
+ unbind_buffer_object( ctx, obj->Color.BufferObj );
+ unbind_buffer_object( ctx, obj->SecondaryColor.BufferObj );
+ unbind_buffer_object( ctx, obj->FogCoord.BufferObj );
+ unbind_buffer_object( ctx, obj->Index.BufferObj );
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- _mesa_unbind_buffer_object( ctx, obj->TexCoord[i].BufferObj );
+ unbind_buffer_object( ctx, obj->TexCoord[i].BufferObj );
}
- _mesa_unbind_buffer_object( ctx, obj->EdgeFlag.BufferObj );
+ unbind_buffer_object( ctx, obj->EdgeFlag.BufferObj );
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
- _mesa_unbind_buffer_object( ctx, obj->VertexAttrib[i].BufferObj );
+ unbind_buffer_object( ctx, obj->VertexAttrib[i].BufferObj );
}
#endif
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index b990369a9e8..7179fba3db3 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
+ * Version: 7.2
*
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -1269,6 +1269,29 @@ adjust_buffer_object_ref_counts(struct gl_array_attrib *array, GLint step)
}
+/**
+ * Copy gl_pixelstore_attrib from src to dst, updating buffer
+ * object refcounts.
+ */
+static void
+copy_pixelstore(GLcontext *ctx,
+ struct gl_pixelstore_attrib *dst,
+ const struct gl_pixelstore_attrib *src)
+{
+ dst->Alignment = src->Alignment;
+ dst->RowLength = src->RowLength;
+ dst->SkipPixels = src->SkipPixels;
+ dst->SkipRows = src->SkipRows;
+ dst->ImageHeight = src->ImageHeight;
+ dst->SkipImages = src->SkipImages;
+ dst->SwapBytes = src->SwapBytes;
+ dst->LsbFirst = src->LsbFirst;
+ dst->ClientStorage = src->ClientStorage;
+ dst->Invert = src->Invert;
+ _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj);
+}
+
+
#define GL_CLIENT_PACK_BIT (1<<20)
#define GL_CLIENT_UNPACK_BIT (1<<21)
@@ -1287,31 +1310,29 @@ _mesa_PushClientAttrib(GLbitfield mask)
return;
}
- /* Build linked list of attribute nodes which save all attribute */
- /* groups specified by the mask. */
+ /* Build linked list of attribute nodes which save all attribute
+ * groups specified by the mask.
+ */
head = NULL;
if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
struct gl_pixelstore_attrib *attr;
-#if FEATURE_EXT_pixel_buffer_object
- ctx->Pack.BufferObj->RefCount++;
- ctx->Unpack.BufferObj->RefCount++;
-#endif
/* packing attribs */
- attr = MALLOC_STRUCT( gl_pixelstore_attrib );
- MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) );
+ attr = CALLOC_STRUCT( gl_pixelstore_attrib );
+ copy_pixelstore(ctx, attr, &ctx->Pack);
newnode = new_attrib_node( GL_CLIENT_PACK_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
/* unpacking attribs */
- attr = MALLOC_STRUCT( gl_pixelstore_attrib );
- MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) );
+ attr = CALLOC_STRUCT( gl_pixelstore_attrib );
+ copy_pixelstore(ctx, attr, &ctx->Unpack);
newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
+
if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
struct gl_array_attrib *attr;
struct gl_array_object *obj;
@@ -1348,7 +1369,7 @@ _mesa_PushClientAttrib(GLbitfield mask)
void GLAPIENTRY
_mesa_PopClientAttrib(void)
{
- struct gl_attrib_node *attr, *next;
+ struct gl_attrib_node *node, *next;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -1359,37 +1380,31 @@ _mesa_PopClientAttrib(void)
}
ctx->ClientAttribStackDepth--;
- attr = ctx->ClientAttribStack[ctx->ClientAttribStackDepth];
+ node = ctx->ClientAttribStack[ctx->ClientAttribStackDepth];
- while (attr) {
- switch (attr->kind) {
+ while (node) {
+ switch (node->kind) {
case GL_CLIENT_PACK_BIT:
-#if FEATURE_EXT_pixel_buffer_object
- ctx->Pack.BufferObj->RefCount--;
- if (ctx->Pack.BufferObj->RefCount <= 0) {
- _mesa_remove_buffer_object( ctx, ctx->Pack.BufferObj );
- (*ctx->Driver.DeleteBuffer)( ctx, ctx->Pack.BufferObj );
+ {
+ struct gl_pixelstore_attrib *store =
+ (struct gl_pixelstore_attrib *) node->data;
+ copy_pixelstore(ctx, &ctx->Pack, store);
+ _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL);
}
-#endif
- MEMCPY( &ctx->Pack, attr->data,
- sizeof(struct gl_pixelstore_attrib) );
ctx->NewState |= _NEW_PACKUNPACK;
break;
case GL_CLIENT_UNPACK_BIT:
-#if FEATURE_EXT_pixel_buffer_object
- ctx->Unpack.BufferObj->RefCount--;
- if (ctx->Unpack.BufferObj->RefCount <= 0) {
- _mesa_remove_buffer_object( ctx, ctx->Unpack.BufferObj );
- (*ctx->Driver.DeleteBuffer)( ctx, ctx->Unpack.BufferObj );
+ {
+ struct gl_pixelstore_attrib *store =
+ (struct gl_pixelstore_attrib *) node->data;
+ copy_pixelstore(ctx, &ctx->Unpack, store);
+ _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL);
}
-#endif
- MEMCPY( &ctx->Unpack, attr->data,
- sizeof(struct gl_pixelstore_attrib) );
ctx->NewState |= _NEW_PACKUNPACK;
break;
case GL_CLIENT_VERTEX_ARRAY_BIT: {
struct gl_array_attrib * data =
- (struct gl_array_attrib *) attr->data;
+ (struct gl_array_attrib *) node->data;
adjust_buffer_object_ref_counts(&ctx->Array, -1);
@@ -1424,10 +1439,10 @@ _mesa_PopClientAttrib(void)
break;
}
- next = attr->next;
- FREE( attr->data );
- FREE( attr );
- attr = next;
+ next = node->next;
+ FREE( node->data );
+ FREE( node );
+ node = next;
}
}
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index dc0307feb56..f1e0932b077 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
+ * Version: 7.2
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
@@ -166,22 +166,75 @@ _mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
if (bufObj->Data)
_mesa_free(bufObj->Data);
+
+ /* assign strange values here to help w/ debugging */
+ bufObj->RefCount = -1000;
+ bufObj->Name = ~0;
+
_mesa_free(bufObj);
}
+
+/**
+ * Set ptr to bufObj w/ reference counting.
+ */
void
-_mesa_unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
+_mesa_reference_buffer_object(GLcontext *ctx,
+ struct gl_buffer_object **ptr,
+ struct gl_buffer_object *bufObj)
{
- if (bufObj != ctx->Array.NullBufferObj) {
- bufObj->RefCount--;
- if (bufObj->RefCount <= 0) {
+ if (*ptr == bufObj)
+ return;
+
+ if (*ptr) {
+ /* Unreference the old texture */
+ GLboolean deleteFlag = GL_FALSE;
+ struct gl_buffer_object *oldObj = *ptr;
+
+ /*_glthread_LOCK_MUTEX(oldObj->Mutex);*/
+ ASSERT(oldObj->RefCount > 0);
+ oldObj->RefCount--;
+#if 0
+ printf("BufferObj %p %d DECR to %d\n",
+ (void *) oldObj, oldObj->Name, oldObj->RefCount);
+#endif
+ deleteFlag = (oldObj->RefCount == 0);
+ /*_glthread_UNLOCK_MUTEX(oldObj->Mutex);*/
+
+ if (deleteFlag) {
+
+ /* some sanity checking: don't delete a buffer still in use */
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);
+
+ ctx->Driver.DeleteBuffer(ctx, oldObj);
}
+
+ *ptr = NULL;
+ }
+ ASSERT(!*ptr);
+
+ if (bufObj) {
+ /* reference new texture */
+ /*_glthread_LOCK_MUTEX(tex->Mutex);*/
+ if (bufObj->RefCount == 0) {
+ /* this buffer's being deleted (look just above) */
+ /* Not sure this can every really happen. Warn if it does. */
+ _mesa_problem(NULL, "referencing deleted buffer object");
+ *ptr = NULL;
+ }
+ else {
+ bufObj->RefCount++;
+#if 0
+ printf("BufferObj %p %d INCR to %d\n",
+ (void *) bufObj, bufObj->Name, bufObj->RefCount);
+#endif
+ *ptr = bufObj;
+ }
+ /*_glthread_UNLOCK_MUTEX(tex->Mutex);*/
}
}
@@ -204,33 +257,6 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj,
/**
- * Add the given buffer object to the buffer object pool.
- */
-void
-_mesa_save_buffer_object( GLcontext *ctx, struct gl_buffer_object *obj )
-{
- if (obj->Name > 0) {
- /* insert into hash table */
- _mesa_HashInsert(ctx->Shared->BufferObjects, obj->Name, obj);
- }
-}
-
-
-/**
- * Remove the given buffer object from the buffer object pool.
- * Do not deallocate the buffer object though.
- */
-void
-_mesa_remove_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
-{
- if (bufObj->Name > 0) {
- /* remove from hash table */
- _mesa_HashRemove(ctx->Shared->BufferObjects, bufObj->Name);
- }
-}
-
-
-/**
* Allocate space for and store data in a buffer object. Any data that was
* previously stored in the buffer object is lost. If \c data is \c NULL,
* memory will be allocated, but no copy will occur.
@@ -400,6 +426,7 @@ _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)
@@ -621,6 +648,23 @@ _mesa_lookup_bufferobj(GLcontext *ctx, GLuint buffer)
}
+/**
+ * If *ptr points to obj, set ptr = the Null/default buffer object.
+ * This is a helper for buffer object deletion.
+ * The GL spec says that deleting a buffer object causes it to get
+ * unbound from all arrays in the current context.
+ */
+static void
+unbind(GLcontext *ctx,
+ struct gl_buffer_object **ptr,
+ struct gl_buffer_object *obj)
+{
+ if (*ptr == obj) {
+ _mesa_reference_buffer_object(ctx, ptr, ctx->Array.NullBufferObj);
+ }
+}
+
+
/**********************************************************************/
/* API Functions */
@@ -678,28 +722,16 @@ _mesa_BindBufferARB(GLenum target, GLuint buffer)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB");
return;
}
- _mesa_save_buffer_object(ctx, newBufObj);
+ _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, newBufObj);
}
}
- /* Make new binding */
- *bindTarget = newBufObj;
- newBufObj->RefCount++;
+ /* bind new buffer */
+ _mesa_reference_buffer_object(ctx, bindTarget, newBufObj);
/* Pass BindBuffer call to device driver */
if (ctx->Driver.BindBuffer && newBufObj)
ctx->Driver.BindBuffer( ctx, target, newBufObj );
-
- /* decr ref count on old buffer obj, delete if needed */
- if (oldBufObj) {
- oldBufObj->RefCount--;
- assert(oldBufObj->RefCount >= 0);
- if (oldBufObj->RefCount == 0) {
- assert(oldBufObj->Name != 0);
- ASSERT(ctx->Driver.DeleteBuffer);
- ctx->Driver.DeleteBuffer( ctx, oldBufObj );
- }
- }
}
@@ -731,54 +763,18 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
ASSERT(bufObj->Name == ids[i]);
- if (ctx->Array.ArrayObj->Vertex.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->Vertex.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->Normal.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->Normal.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->Color.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->Color.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->SecondaryColor.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->SecondaryColor.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->FogCoord.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->FogCoord.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->Index.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->Index.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->EdgeFlag.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->EdgeFlag.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
+ unbind(ctx, &ctx->Array.ArrayObj->Vertex.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->Normal.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->Color.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->SecondaryColor.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->FogCoord.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->Index.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->EdgeFlag.BufferObj, bufObj);
for (j = 0; j < MAX_TEXTURE_UNITS; j++) {
- if (ctx->Array.ArrayObj->TexCoord[j].BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->TexCoord[j].BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
+ unbind(ctx, &ctx->Array.ArrayObj->TexCoord[j].BufferObj, bufObj);
}
for (j = 0; j < VERT_ATTRIB_MAX; j++) {
- if (ctx->Array.ArrayObj->VertexAttrib[j].BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->VertexAttrib[j].BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
+ unbind(ctx, &ctx->Array.ArrayObj->VertexAttrib[j].BufferObj, bufObj);
}
if (ctx->Array.ArrayBufferObj == bufObj) {
@@ -796,8 +792,8 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
}
/* The ID is immediately freed for re-use */
- _mesa_remove_buffer_object(ctx, bufObj);
- _mesa_unbind_buffer_object(ctx, bufObj);
+ _mesa_HashRemove(ctx->Shared->BufferObjects, bufObj->Name);
+ _mesa_reference_buffer_object(ctx, &bufObj, NULL);
}
}
@@ -846,7 +842,7 @@ _mesa_GenBuffersARB(GLsizei n, GLuint *buffer)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenBuffersARB");
return;
}
- _mesa_save_buffer_object(ctx, bufObj);
+ _mesa_HashInsert(ctx->Shared->BufferObjects, first + i, bufObj);
buffer[i] = first + i;
}
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index 024e5a8c3c8..2f908c5c35d 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
+ * Version: 7.2
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
@@ -52,10 +52,9 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj,
GLuint name, GLenum target );
extern void
-_mesa_save_buffer_object( GLcontext *ctx, struct gl_buffer_object *obj );
-
-extern void
-_mesa_remove_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj );
+_mesa_reference_buffer_object(GLcontext *ctx,
+ struct gl_buffer_object **ptr,
+ struct gl_buffer_object *bufObj);
extern void
_mesa_buffer_data( GLcontext *ctx, GLenum target, GLsizeiptrARB size,
@@ -115,8 +114,6 @@ _mesa_unmap_readpix_pbo(GLcontext *ctx,
const struct gl_pixelstore_attrib *pack);
-extern void
-_mesa_unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj );
/*
* API functions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 32460e92c3c..ed3faecf0db 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1214,6 +1214,10 @@ _mesa_initialize_context(GLcontext *ctx,
ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
}
+#ifdef FEATURE_extra_context_init
+ _mesa_initialize_context_extra(ctx);
+#endif
+
ctx->FirstTimeCurrent = GL_TRUE;
return GL_TRUE;
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 099912aa152..9423b66a7d8 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -115,6 +115,9 @@ _mesa_initialize_context( GLcontext *ctx,
void *driverContext );
extern void
+_mesa_initialize_context_extra(GLcontext *ctx);
+
+extern void
_mesa_free_context_data( GLcontext *ctx );
extern void
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index 5f3def257de..787672be9f1 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -319,7 +319,6 @@ static struct state_key *make_state_key( GLcontext *ctx )
*/
#define PREFER_DP4 0
-#define MAX_INSN 256
/* Use uregs to represent registers internally, translate to Mesa's
* expected formats on emit.
@@ -335,16 +334,18 @@ static struct state_key *make_state_key( GLcontext *ctx )
*/
struct ureg {
GLuint file:4;
- GLint idx:8; /* relative addressing may be negative */
+ GLint idx:9; /* relative addressing may be negative */
+ /* sizeof(idx) should == sizeof(prog_src_reg::Index) */
GLuint negate:1;
GLuint swz:12;
- GLuint pad:7;
+ GLuint pad:6;
};
struct tnl_program {
const struct state_key *state;
struct gl_vertex_program *program;
+ GLint max_inst; /** number of instructions allocated for program */
GLuint temp_in_use;
GLuint temp_reserved;
@@ -362,7 +363,7 @@ struct tnl_program {
static const struct ureg undef = {
PROGRAM_UNDEFINED,
- ~0,
+ 0,
0,
0,
0
@@ -558,6 +559,8 @@ static void emit_arg( struct prog_src_register *src,
src->Abs = 0;
src->NegateAbs = 0;
src->RelAddr = 0;
+ /* Check that bitfield sizes aren't exceeded */
+ ASSERT(src->Index == reg.idx);
}
static void emit_dst( struct prog_dst_register *dst,
@@ -571,6 +574,8 @@ static void emit_dst( struct prog_dst_register *dst,
dst->CondSwizzle = SWIZZLE_NOOP;
dst->CondSrc = 0;
dst->pad = 0;
+ /* Check that bitfield sizes aren't exceeded */
+ ASSERT(dst->Index == reg.idx);
}
static void debug_insn( struct prog_instruction *inst, const char *fn,
@@ -600,14 +605,37 @@ static void emit_op3fn(struct tnl_program *p,
const char *fn,
GLuint line)
{
- GLuint nr = p->program->Base.NumInstructions++;
- struct prog_instruction *inst = &p->program->Base.Instructions[nr];
+ GLuint nr;
+ struct prog_instruction *inst;
- if (p->program->Base.NumInstructions > MAX_INSN) {
- _mesa_problem(0, "Out of instructions in emit_op3fn\n");
- return;
+ assert((GLint) p->program->Base.NumInstructions <= p->max_inst);
+
+ if (p->program->Base.NumInstructions == p->max_inst) {
+ /* need to extend the program's instruction array */
+ struct prog_instruction *newInst;
+
+ /* double the size */
+ p->max_inst *= 2;
+
+ newInst = _mesa_alloc_instructions(p->max_inst);
+ if (!newInst) {
+ _mesa_error(NULL, GL_OUT_OF_MEMORY, "vertex program build");
+ return;
+ }
+
+ _mesa_copy_instructions(newInst,
+ p->program->Base.Instructions,
+ p->program->Base.NumInstructions);
+
+ _mesa_free_instructions(p->program->Base.Instructions,
+ p->program->Base.NumInstructions);
+
+ p->program->Base.Instructions = newInst;
}
+ nr = p->program->Base.NumInstructions++;
+
+ inst = &p->program->Base.Instructions[nr];
inst->Opcode = (enum prog_opcode) op;
inst->StringPos = 0;
inst->Data = 0;
@@ -1621,6 +1649,8 @@ static void build_tnl_program( struct tnl_program *p )
#if 0
else
build_constant_pointsize(p);
+#else
+ (void) build_constant_pointsize;
#endif
/* Finish up:
@@ -1657,7 +1687,11 @@ create_new_program( const struct state_key *key,
else
p.temp_reserved = ~((1<<max_temps)-1);
- p.program->Base.Instructions = _mesa_alloc_instructions(MAX_INSN);
+ /* Start by allocating 32 instructions.
+ * If we need more, we'll grow the instruction array as needed.
+ */
+ p.max_inst = 32;
+ p.program->Base.Instructions = _mesa_alloc_instructions(p.max_inst);
p.program->Base.String = NULL;
p.program->Base.NumInstructions =
p.program->Base.NumTemporaries =
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index dab449fc09a..494743f1349 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.1
+ * Version: 7.2
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -565,13 +565,13 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
if (fb->Attachment[BUFFER_ACCUM].Renderbuffer) {
fb->Visual.haveAccumBuffer = GL_TRUE;
fb->Visual.accumRedBits
- = fb->Attachment[BUFFER_DEPTH].Renderbuffer->RedBits;
+ = fb->Attachment[BUFFER_ACCUM].Renderbuffer->RedBits;
fb->Visual.accumGreenBits
- = fb->Attachment[BUFFER_DEPTH].Renderbuffer->GreenBits;
+ = fb->Attachment[BUFFER_ACCUM].Renderbuffer->GreenBits;
fb->Visual.accumBlueBits
- = fb->Attachment[BUFFER_DEPTH].Renderbuffer->BlueBits;
+ = fb->Attachment[BUFFER_ACCUM].Renderbuffer->BlueBits;
fb->Visual.accumAlphaBits
- = fb->Attachment[BUFFER_DEPTH].Renderbuffer->AlphaBits;
+ = fb->Attachment[BUFFER_ACCUM].Renderbuffer->AlphaBits;
}
compute_depth_max(fb);
diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c
index d16344a42c3..fbedbcb22c4 100644
--- a/src/mesa/main/points.c
+++ b/src/mesa/main/points.c
@@ -244,11 +244,7 @@ _mesa_init_point(GLcontext *ctx)
ctx->Point.MaxSize
= MAX2(ctx->Const.MaxPointSize, ctx->Const.MaxPointSizeAA);
ctx->Point.Threshold = 1.0;
-#if FEATURE_es2_glsl
- ctx->Point.PointSprite = GL_TRUE; /* GL_ARB/NV_point_sprite */
-#else
ctx->Point.PointSprite = GL_FALSE; /* GL_ARB/NV_point_sprite */
-#endif
ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */
ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index c163a8158fe..2a54ff7ff90 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -142,6 +142,34 @@ _mesa_initialize_texture_object( struct gl_texture_object *obj,
/**
+ * Some texture initialization can't be finished until we know which
+ * target it's getting bound to (GL_TEXTURE_1D/2D/etc).
+ */
+static void
+finish_texture_init(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *obj)
+{
+ assert(obj->Target == 0);
+
+ if (target == GL_TEXTURE_RECTANGLE_NV) {
+ /* have to init wrap and filter state here - kind of klunky */
+ obj->WrapS = GL_CLAMP_TO_EDGE;
+ obj->WrapT = GL_CLAMP_TO_EDGE;
+ obj->WrapR = GL_CLAMP_TO_EDGE;
+ obj->MinFilter = GL_LINEAR;
+ if (ctx->Driver.TexParameter) {
+ static const GLfloat fparam_wrap[1] = {(GLfloat) GL_CLAMP_TO_EDGE};
+ static const GLfloat fparam_filter[1] = {(GLfloat) GL_LINEAR};
+ ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_S, fparam_wrap);
+ ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_T, fparam_wrap);
+ ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_R, fparam_wrap);
+ ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_MIN_FILTER, fparam_filter);
+ }
+ }
+}
+
+
+/**
* Deallocate a texture object struct. It should have already been
* removed from the texture object pool.
* Called via ctx->Driver.DeleteTexture() if not overriden by a driver.
@@ -830,44 +858,45 @@ _mesa_BindTexture( GLenum target, GLuint texName )
GET_CURRENT_CONTEXT(ctx);
const GLuint unit = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
- struct gl_texture_object *newTexObj = NULL;
+ struct gl_texture_object *newTexObj = NULL, *defaultTexObj = NULL;
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
_mesa_debug(ctx, "glBindTexture %s %d\n",
_mesa_lookup_enum_by_nr(target), (GLint) texName);
+ switch (target) {
+ case GL_TEXTURE_1D:
+ defaultTexObj = ctx->Shared->Default1D;
+ break;
+ case GL_TEXTURE_2D:
+ defaultTexObj = ctx->Shared->Default2D;
+ break;
+ case GL_TEXTURE_3D:
+ defaultTexObj = ctx->Shared->Default3D;
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ defaultTexObj = ctx->Shared->DefaultCubeMap;
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ defaultTexObj = ctx->Shared->DefaultRect;
+ break;
+ case GL_TEXTURE_1D_ARRAY_EXT:
+ defaultTexObj = ctx->Shared->Default1DArray;
+ break;
+ case GL_TEXTURE_2D_ARRAY_EXT:
+ defaultTexObj = ctx->Shared->Default2DArray;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBindTexture(target)");
+ return;
+ }
+
/*
* Get pointer to new texture object (newTexObj)
*/
if (texName == 0) {
- /* newTexObj = a default texture object */
- switch (target) {
- case GL_TEXTURE_1D:
- newTexObj = ctx->Shared->Default1D;
- break;
- case GL_TEXTURE_2D:
- newTexObj = ctx->Shared->Default2D;
- break;
- case GL_TEXTURE_3D:
- newTexObj = ctx->Shared->Default3D;
- break;
- case GL_TEXTURE_CUBE_MAP_ARB:
- newTexObj = ctx->Shared->DefaultCubeMap;
- break;
- case GL_TEXTURE_RECTANGLE_NV:
- newTexObj = ctx->Shared->DefaultRect;
- break;
- case GL_TEXTURE_1D_ARRAY_EXT:
- newTexObj = ctx->Shared->Default1DArray;
- break;
- case GL_TEXTURE_2D_ARRAY_EXT:
- newTexObj = ctx->Shared->Default2DArray;
- break;
- default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glBindTexture(target)");
- return;
- }
+ newTexObj = defaultTexObj;
}
else {
/* non-default texture object */
@@ -880,20 +909,8 @@ _mesa_BindTexture( GLenum target, GLuint texName )
"glBindTexture(target mismatch)" );
return;
}
- if (newTexObj->Target == 0 && target == GL_TEXTURE_RECTANGLE_NV) {
- /* have to init wrap and filter state here - kind of klunky */
- newTexObj->WrapS = GL_CLAMP_TO_EDGE;
- newTexObj->WrapT = GL_CLAMP_TO_EDGE;
- newTexObj->WrapR = GL_CLAMP_TO_EDGE;
- newTexObj->MinFilter = GL_LINEAR;
- if (ctx->Driver.TexParameter) {
- static const GLfloat fparam_wrap[1] = {(GLfloat) GL_CLAMP_TO_EDGE};
- static const GLfloat fparam_filter[1] = {(GLfloat) GL_LINEAR};
- (*ctx->Driver.TexParameter)( ctx, target, newTexObj, GL_TEXTURE_WRAP_S, fparam_wrap );
- (*ctx->Driver.TexParameter)( ctx, target, newTexObj, GL_TEXTURE_WRAP_T, fparam_wrap );
- (*ctx->Driver.TexParameter)( ctx, target, newTexObj, GL_TEXTURE_WRAP_R, fparam_wrap );
- (*ctx->Driver.TexParameter)( ctx, target, newTexObj, GL_TEXTURE_MIN_FILTER, fparam_filter );
- }
+ if (newTexObj->Target == 0) {
+ finish_texture_init(ctx, target, newTexObj);
}
}
else {
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index e821d9f367f..0fd6a2daae2 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -2522,7 +2522,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
for (row = 0; row < srcHeight; row++) {
GLubyte stencil[MAX_WIDTH];
GLint i;
- /* the 24 depth bits will be in the high position: */
+ /* the 24 depth bits will be in the low position: */
_mesa_unpack_depth_span(ctx, srcWidth,
GL_UNSIGNED_INT, /* dst type */
dstRow, /* dst addr */
@@ -2536,7 +2536,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
ctx->_ImageTransferState);
/* merge stencil values into depth values */
for (i = 0; i < srcWidth; i++)
- dstRow[i] = stencil[i] << 24;
+ dstRow[i] |= stencil[i] << 24;
src += srcRowStride;
dstRow += dstRowStride / sizeof(GLuint);
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index a6aa9c34b25..9f1fcd9d262 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.1
+ * Version: 7.2
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -62,14 +62,9 @@ update_array(GLcontext *ctx, struct gl_client_array *array,
array->Normalized = normalized;
array->Ptr = (const GLubyte *) ptr;
#if FEATURE_ARB_vertex_buffer_object
- array->BufferObj->RefCount--;
- if (array->BufferObj->RefCount <= 0) {
- ASSERT(array->BufferObj->Name);
- _mesa_remove_buffer_object( ctx, array->BufferObj );
- (*ctx->Driver.DeleteBuffer)( ctx, array->BufferObj );
- }
- array->BufferObj = ctx->Array.ArrayBufferObj;
- array->BufferObj->RefCount++;
+ _mesa_reference_buffer_object(ctx, &array->BufferObj,
+ ctx->Array.ArrayBufferObj);
+
/* Compute the index of the last array element that's inside the buffer.
* Later in glDrawArrays we'll check if start + count > _MaxElement to
* be sure we won't go out of bounds.