summaryrefslogtreecommitdiff
path: root/src/mesa/array_cache
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2003-09-17 16:06:49 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2003-09-17 16:06:49 +0000
commit57d882b6847128fe5f72575f61a2b2dace7ac46c (patch)
tree0b8d61a758d856e9521c03e4c38ed72c29cdd3d1 /src/mesa/array_cache
parent397d1e4d5750bda09e52451cfeb0a69126602a56 (diff)
GL_ARB_vertex_buffer_object working now, at least for non-indexed
vertex arrays.
Diffstat (limited to 'src/mesa/array_cache')
-rw-r--r--src/mesa/array_cache/ac_context.c32
-rw-r--r--src/mesa/array_cache/ac_import.c32
2 files changed, 42 insertions, 22 deletions
diff --git a/src/mesa/array_cache/ac_context.c b/src/mesa/array_cache/ac_context.c
index e3c09fbd20..b259d5d071 100644
--- a/src/mesa/array_cache/ac_context.c
+++ b/src/mesa/array_cache/ac_context.c
@@ -328,28 +328,40 @@ GLboolean _ac_CreateContext( GLcontext *ctx )
void _ac_DestroyContext( GLcontext *ctx )
{
+ struct gl_buffer_object *nullObj = ctx->Array.NullBufferObj;
ACcontext *ac = AC_CONTEXT(ctx);
GLint i;
- if (ac->Cache.Vertex.Ptr) FREE( ac->Cache.Vertex.Ptr );
- if (ac->Cache.Normal.Ptr) FREE( ac->Cache.Normal.Ptr );
- if (ac->Cache.Color.Ptr) FREE( ac->Cache.Color.Ptr );
- if (ac->Cache.SecondaryColor.Ptr) FREE( ac->Cache.SecondaryColor.Ptr );
- if (ac->Cache.EdgeFlag.Ptr) FREE( ac->Cache.EdgeFlag.Ptr );
- if (ac->Cache.Index.Ptr) FREE( ac->Cache.Index.Ptr );
- if (ac->Cache.FogCoord.Ptr) FREE( ac->Cache.FogCoord.Ptr );
+ /* only free vertex data if it's really a pointer to vertex data and
+ * not an offset into a buffer object.
+ */
+ if (ac->Cache.Vertex.Ptr && ac->Cache.Vertex.BufferObj == nullObj)
+ FREE( ac->Cache.Vertex.Ptr );
+ if (ac->Cache.Normal.Ptr && ac->Cache.Normal.BufferObj == nullObj)
+ FREE( ac->Cache.Normal.Ptr );
+ if (ac->Cache.Color.Ptr && ac->Cache.Color.BufferObj == nullObj)
+ FREE( ac->Cache.Color.Ptr );
+ if (ac->Cache.SecondaryColor.Ptr && ac->Cache.SecondaryColor.BufferObj == nullObj)
+ FREE( ac->Cache.SecondaryColor.Ptr );
+ if (ac->Cache.EdgeFlag.Ptr && ac->Cache.EdgeFlag.BufferObj == nullObj)
+ FREE( ac->Cache.EdgeFlag.Ptr );
+ if (ac->Cache.Index.Ptr && ac->Cache.Index.BufferObj == nullObj)
+ FREE( ac->Cache.Index.Ptr );
+ if (ac->Cache.FogCoord.Ptr && ac->Cache.FogCoord.BufferObj == nullObj)
+ FREE( ac->Cache.FogCoord.Ptr );
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
- if (ac->Cache.TexCoord[i].Ptr)
+ if (ac->Cache.TexCoord[i].Ptr && ac->Cache.TexCoord[i].BufferObj == nullObj)
FREE( ac->Cache.TexCoord[i].Ptr );
}
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
- if (ac->Cache.Attrib[i].Ptr)
+ if (ac->Cache.Attrib[i].Ptr && ac->Cache.Attrib[i].BufferObj == nullObj)
FREE( ac->Cache.Attrib[i].Ptr );
}
- if (ac->Elts) FREE( ac->Elts );
+ if (ac->Elts)
+ FREE( ac->Elts );
/* Free the context structure itself */
FREE(ac);
diff --git a/src/mesa/array_cache/ac_import.c b/src/mesa/array_cache/ac_import.c
index b2b7eeb219..78f5435635 100644
--- a/src/mesa/array_cache/ac_import.c
+++ b/src/mesa/array_cache/ac_import.c
@@ -34,17 +34,17 @@
#include "array_cache/ac_context.h"
#include "math/m_translate.h"
-#define STRIDE_ARRAY( array, offset ) \
-do { \
- GLubyte *tmp = (array).Ptr; \
- tmp += (offset) * (array).StrideB; \
- (array).Ptr = tmp; \
+#define STRIDE_ARRAY( array, offset ) \
+do { \
+ GLubyte *tmp = ADD_POINTERS( (array).BufferObj->Data, (array).Ptr ) \
+ + (offset) * (array).StrideB; \
+ (array).Ptr = tmp; \
} while (0)
+
/* Set the array pointer back to its source when the cached data is
* invalidated:
*/
-
static void reset_texcoord( GLcontext *ctx, GLuint unit )
{
ACcontext *ac = AC_CONTEXT(ctx);
@@ -202,15 +202,23 @@ static void import( GLcontext *ctx,
struct gl_client_array *to,
struct gl_client_array *from )
{
+ GLubyte *dest;
+ const GLubyte *src;
ACcontext *ac = AC_CONTEXT(ctx);
if (type == 0)
type = from->Type;
+ /* The dest and source data addresses are the sum of the buffer
+ * object's start plus the vertex array pointer/offset.
+ */
+ dest = ADD_POINTERS(to->BufferObj->Data, to->Ptr);
+ src = ADD_POINTERS(from->BufferObj->Data, from->Ptr);
+
switch (type) {
case GL_FLOAT:
- _math_trans_4fc( (GLfloat (*)[4]) to->Ptr,
- from->Ptr,
+ _math_trans_4fc( (GLfloat (*)[4]) dest,
+ src,
from->StrideB,
from->Type,
from->Size,
@@ -222,8 +230,8 @@ static void import( GLcontext *ctx,
break;
case GL_UNSIGNED_BYTE:
- _math_trans_4ub( (GLubyte (*)[4]) to->Ptr,
- from->Ptr,
+ _math_trans_4ub( (GLubyte (*)[4]) dest,
+ src,
from->StrideB,
from->Type,
from->Size,
@@ -235,8 +243,8 @@ static void import( GLcontext *ctx,
break;
case GL_UNSIGNED_SHORT:
- _math_trans_4us( (GLushort (*)[4]) to->Ptr,
- from->Ptr,
+ _math_trans_4us( (GLushort (*)[4]) dest,
+ src,
from->StrideB,
from->Type,
from->Size,