rework to correctly respect _ac_import_range()

This commit is contained in:
Keith Whitwell 2001-02-04 00:47:28 +00:00
parent 6e9f8b7cdb
commit 71270195d5
3 changed files with 226 additions and 194 deletions

View File

@ -1,4 +1,4 @@
/* $Id: ac_context.c,v 1.1 2000/12/26 15:14:04 keithw Exp $ */ /* $Id: ac_context.c,v 1.2 2001/02/04 00:47:28 keithw Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@ -188,30 +188,30 @@ static void _ac_elts_init( GLcontext *ctx )
ac->elt_size = size; ac->elt_size = size;
} }
static void _ac_current_init( GLcontext *ctx ) static void _ac_raw_init( GLcontext *ctx )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
GLuint i; GLuint i;
ac->Current.Color = &ac->Fallback.Color; ac->Raw.Color = ac->Fallback.Color;
ac->Current.EdgeFlag = &ac->Fallback.EdgeFlag; ac->Raw.EdgeFlag = ac->Fallback.EdgeFlag;
ac->Current.FogCoord = &ac->Fallback.FogCoord; ac->Raw.FogCoord = ac->Fallback.FogCoord;
ac->Current.Index = &ac->Fallback.Index; ac->Raw.Index = ac->Fallback.Index;
ac->Current.Normal = &ac->Fallback.Normal; ac->Raw.Normal = ac->Fallback.Normal;
ac->Current.SecondaryColor = &ac->Fallback.SecondaryColor; ac->Raw.SecondaryColor = ac->Fallback.SecondaryColor;
ac->Current.Vertex = &ctx->Array.Vertex; ac->Raw.Vertex = ctx->Array.Vertex;
ac->Writeable.Color = GL_FALSE; ac->IsCached.Color = GL_FALSE;
ac->Writeable.EdgeFlag = GL_FALSE; ac->IsCached.EdgeFlag = GL_FALSE;
ac->Writeable.FogCoord = GL_FALSE; ac->IsCached.FogCoord = GL_FALSE;
ac->Writeable.Index = GL_FALSE; ac->IsCached.Index = GL_FALSE;
ac->Writeable.Normal = GL_FALSE; ac->IsCached.Normal = GL_FALSE;
ac->Writeable.SecondaryColor = GL_FALSE; ac->IsCached.SecondaryColor = GL_FALSE;
ac->Writeable.Vertex = GL_FALSE; ac->IsCached.Vertex = GL_FALSE;
for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++) { for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++) {
ac->Current.TexCoord[i] = &ac->Fallback.TexCoord[i]; ac->Raw.TexCoord[i] = ac->Fallback.TexCoord[i];
ac->Writeable.TexCoord[i] = GL_FALSE; ac->IsCached.TexCoord[i] = GL_FALSE;
} }
} }
@ -222,7 +222,7 @@ GLboolean _ac_CreateContext( GLcontext *ctx )
if (ctx->acache_context) { if (ctx->acache_context) {
_ac_cache_init( ctx ); _ac_cache_init( ctx );
_ac_fallbacks_init( ctx ); _ac_fallbacks_init( ctx );
_ac_current_init( ctx ); _ac_raw_init( ctx );
_ac_elts_init( ctx ); _ac_elts_init( ctx );
return GL_TRUE; return GL_TRUE;
} }

View File

@ -1,5 +1,5 @@
/* $Id: ac_context.h,v 1.1 2000/12/26 15:14:04 keithw Exp $ */ /* $Id: ac_context.h,v 1.2 2001/02/04 00:47:28 keithw Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@ -81,8 +81,8 @@ typedef struct {
*/ */
struct ac_arrays Fallback; struct ac_arrays Fallback;
struct ac_arrays Cache; struct ac_arrays Cache;
struct ac_array_pointers Current; struct ac_arrays Raw;
struct ac_array_flags Writeable; struct ac_array_flags IsCached;
GLuint start; GLuint start;
GLuint count; GLuint count;

View File

@ -1,4 +1,4 @@
/* $Id: ac_import.c,v 1.4 2001/01/24 00:04:59 brianp Exp $ */ /* $Id: ac_import.c,v 1.5 2001/02/04 00:47:28 keithw Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@ -35,9 +35,14 @@
#include "math/m_translate.h" #include "math/m_translate.h"
#include "array_cache/ac_context.h" #include "array_cache/ac_context.h"
#include "math/m_translate.h" #include "math/m_translate.h"
#define STRIDE_ARRAY( array, offset ) \
do { \
char *tmp = (array).Ptr; \
tmp += (offset) * (array).StrideB; \
(array).Ptr = tmp; \
} while (0)
/* Set the array pointer back to its source when the cached data is /* Set the array pointer back to its source when the cached data is
* invalidated: * invalidated:
@ -47,22 +52,22 @@ static void reset_texcoord( GLcontext *ctx, GLuint unit )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
/* fprintf(stderr, "%s %d\n", __FUNCTION__, unit); */ if (ctx->Array._Enabled & _NEW_ARRAY_TEXCOORD(unit)) {
ac->Raw.TexCoord[unit] = ctx->Array.TexCoord[unit];
if (ctx->Array._Enabled & _NEW_ARRAY_TEXCOORD(unit)) STRIDE_ARRAY(ac->Raw.TexCoord[unit], ac->start);
ac->Current.TexCoord[unit] = &ctx->Array.TexCoord[unit]; }
else { else {
ac->Current.TexCoord[unit] = &ac->Fallback.TexCoord[unit]; ac->Raw.TexCoord[unit] = ac->Fallback.TexCoord[unit];
if (ctx->Current.Texcoord[unit][4] != 1.0) if (ctx->Current.Texcoord[unit][4] != 1.0)
ac->Current.TexCoord[unit]->Size = 4; ac->Raw.TexCoord[unit].Size = 4;
else if (ctx->Current.Texcoord[unit][3] != 0.0) else if (ctx->Current.Texcoord[unit][3] != 0.0)
ac->Current.TexCoord[unit]->Size = 3; ac->Raw.TexCoord[unit].Size = 3;
else else
ac->Current.TexCoord[unit]->Size = 2; ac->Raw.TexCoord[unit].Size = 2;
} }
ac->Writeable.TexCoord[unit] = GL_FALSE; ac->IsCached.TexCoord[unit] = GL_FALSE;
ac->NewArrayState &= ~_NEW_ARRAY_TEXCOORD(unit); ac->NewArrayState &= ~_NEW_ARRAY_TEXCOORD(unit);
} }
@ -70,11 +75,10 @@ static void reset_vertex( GLcontext *ctx )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
ASSERT(ctx->Array.Vertex.Enabled); ASSERT(ctx->Array.Vertex.Enabled);
ac->Current.Vertex = &ctx->Array.Vertex; ac->Raw.Vertex = ctx->Array.Vertex;
ac->Writeable.Vertex = GL_FALSE; STRIDE_ARRAY(ac->Raw.Vertex, ac->start);
ac->IsCached.Vertex = GL_FALSE;
ac->NewArrayState &= ~_NEW_ARRAY_VERTEX; ac->NewArrayState &= ~_NEW_ARRAY_VERTEX;
/* fprintf(stderr, "%s\n", __FUNCTION__); */
} }
@ -83,17 +87,14 @@ static void reset_normal( GLcontext *ctx )
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
if (ctx->Array._Enabled & _NEW_ARRAY_NORMAL) { if (ctx->Array._Enabled & _NEW_ARRAY_NORMAL) {
/* fprintf(stderr, "reset normal: using client array enab %d\n", */ ac->Raw.Normal = ctx->Array.Normal;
/* ctx->Array.Normal.Enabled); */ STRIDE_ARRAY(ac->Raw.Normal, ac->start);
ac->Current.Normal = &ctx->Array.Normal;
} }
else { else {
/* fprintf(stderr, "reset normal: using fallback enab %d\n", */ ac->Raw.Normal = ac->Fallback.Normal;
/* ctx->Array.Normal.Enabled); */
ac->Current.Normal = &ac->Fallback.Normal;
} }
ac->Writeable.Normal = GL_FALSE; ac->IsCached.Normal = GL_FALSE;
ac->NewArrayState &= ~_NEW_ARRAY_NORMAL; ac->NewArrayState &= ~_NEW_ARRAY_NORMAL;
} }
@ -103,14 +104,14 @@ static void reset_color( GLcontext *ctx )
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
if (ctx->Array._Enabled & _NEW_ARRAY_COLOR) if (ctx->Array._Enabled & _NEW_ARRAY_COLOR) {
ac->Current.Color = &ctx->Array.Color; ac->Raw.Color = ctx->Array.Color;
STRIDE_ARRAY(ac->Raw.Color, ac->start);
}
else else
ac->Current.Color = &ac->Fallback.Color; ac->Raw.Color = ac->Fallback.Color;
/* fprintf(stderr, "reset_color, stride now %d\n", ac->Current.Color->StrideB); */ ac->IsCached.Color = GL_FALSE;
ac->Writeable.Color = GL_FALSE;
ac->NewArrayState &= ~_NEW_ARRAY_COLOR; ac->NewArrayState &= ~_NEW_ARRAY_COLOR;
} }
@ -119,12 +120,14 @@ static void reset_secondarycolor( GLcontext *ctx )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
if (ctx->Array._Enabled & _NEW_ARRAY_SECONDARYCOLOR) if (ctx->Array._Enabled & _NEW_ARRAY_SECONDARYCOLOR) {
ac->Current.SecondaryColor = &ctx->Array.SecondaryColor; ac->Raw.SecondaryColor = ctx->Array.SecondaryColor;
STRIDE_ARRAY(ac->Raw.SecondaryColor, ac->start);
}
else else
ac->Current.SecondaryColor = &ac->Fallback.SecondaryColor; ac->Raw.SecondaryColor = ac->Fallback.SecondaryColor;
ac->Writeable.SecondaryColor = GL_FALSE; ac->IsCached.SecondaryColor = GL_FALSE;
ac->NewArrayState &= ~_NEW_ARRAY_SECONDARYCOLOR; ac->NewArrayState &= ~_NEW_ARRAY_SECONDARYCOLOR;
} }
@ -133,12 +136,14 @@ static void reset_index( GLcontext *ctx )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
if (ctx->Array._Enabled & _NEW_ARRAY_INDEX) if (ctx->Array._Enabled & _NEW_ARRAY_INDEX) {
ac->Current.Index = &ctx->Array.Index; ac->Raw.Index = ctx->Array.Index;
STRIDE_ARRAY(ac->Raw.Index, ac->start);
}
else else
ac->Current.Index = &ac->Fallback.Index; ac->Raw.Index = ac->Fallback.Index;
ac->Writeable.Index = GL_FALSE; ac->IsCached.Index = GL_FALSE;
ac->NewArrayState &= ~_NEW_ARRAY_INDEX; ac->NewArrayState &= ~_NEW_ARRAY_INDEX;
} }
@ -146,12 +151,14 @@ static void reset_fogcoord( GLcontext *ctx )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
if (ctx->Array._Enabled & _NEW_ARRAY_FOGCOORD) if (ctx->Array._Enabled & _NEW_ARRAY_FOGCOORD) {
ac->Current.FogCoord = &ctx->Array.FogCoord; ac->Raw.FogCoord = ctx->Array.FogCoord;
STRIDE_ARRAY(ac->Raw.FogCoord, ac->start);
}
else else
ac->Current.FogCoord = &ac->Fallback.FogCoord; ac->Raw.FogCoord = ac->Fallback.FogCoord;
ac->Writeable.FogCoord = GL_FALSE; ac->IsCached.FogCoord = GL_FALSE;
ac->NewArrayState &= ~_NEW_ARRAY_FOGCOORD; ac->NewArrayState &= ~_NEW_ARRAY_FOGCOORD;
} }
@ -159,12 +166,14 @@ static void reset_edgeflag( GLcontext *ctx )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
if (ctx->Array._Enabled & _NEW_ARRAY_EDGEFLAG) if (ctx->Array._Enabled & _NEW_ARRAY_EDGEFLAG) {
ac->Current.EdgeFlag = &ctx->Array.EdgeFlag; ac->Raw.EdgeFlag = ctx->Array.EdgeFlag;
STRIDE_ARRAY(ac->Raw.EdgeFlag, ac->start);
}
else else
ac->Current.EdgeFlag = &ac->Fallback.EdgeFlag; ac->Raw.EdgeFlag = ac->Fallback.EdgeFlag;
ac->Writeable.EdgeFlag = GL_FALSE; ac->IsCached.EdgeFlag = GL_FALSE;
ac->NewArrayState &= ~_NEW_ARRAY_EDGEFLAG; ac->NewArrayState &= ~_NEW_ARRAY_EDGEFLAG;
} }
@ -175,7 +184,7 @@ static void import_texcoord( GLcontext *ctx, GLuint unit,
GLenum type, GLuint stride ) GLenum type, GLuint stride )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
struct gl_client_array *from = ac->Current.TexCoord[unit]; struct gl_client_array *from = &ac->Raw.TexCoord[unit];
struct gl_client_array *to = &ac->Cache.TexCoord[unit]; struct gl_client_array *to = &ac->Cache.TexCoord[unit];
/* Limited choices at this stage: /* Limited choices at this stage:
@ -183,8 +192,6 @@ static void import_texcoord( GLcontext *ctx, GLuint unit,
ASSERT(type == GL_FLOAT); ASSERT(type == GL_FLOAT);
ASSERT(stride == 4*sizeof(GLfloat) || stride == 0); ASSERT(stride == 4*sizeof(GLfloat) || stride == 0);
ASSERT(ac->count - ac->start < ctx->Const.MaxArrayLockSize); ASSERT(ac->count - ac->start < ctx->Const.MaxArrayLockSize);
/* fprintf(stderr, "%s %d old ptr %p\n", __FUNCTION__, unit, from->Ptr); */
_math_trans_4f( to->Ptr, _math_trans_4f( to->Ptr,
from->Ptr, from->Ptr,
@ -197,21 +204,16 @@ static void import_texcoord( GLcontext *ctx, GLuint unit,
to->Size = from->Size; to->Size = from->Size;
to->StrideB = 4 * sizeof(GLfloat); to->StrideB = 4 * sizeof(GLfloat);
to->Type = GL_FLOAT; to->Type = GL_FLOAT;
ac->Current.TexCoord[unit] = to; ac->IsCached.TexCoord[unit] = GL_TRUE;
ac->Writeable.TexCoord[unit] = GL_TRUE;
/* fprintf(stderr, "%s %d new ptr %p\n", __FUNCTION__, unit, to->Ptr); */
} }
static void import_vertex( GLcontext *ctx, static void import_vertex( GLcontext *ctx,
GLenum type, GLuint stride ) GLenum type, GLuint stride )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
struct gl_client_array *from = ac->Current.Vertex; struct gl_client_array *from = &ac->Raw.Vertex;
struct gl_client_array *to = &ac->Cache.Vertex; struct gl_client_array *to = &ac->Cache.Vertex;
/* fprintf(stderr, "(ac) %s\n", __FUNCTION__); */
/* Limited choices at this stage: /* Limited choices at this stage:
*/ */
ASSERT(type == GL_FLOAT); ASSERT(type == GL_FLOAT);
@ -222,26 +224,22 @@ static void import_vertex( GLcontext *ctx,
from->StrideB, from->StrideB,
from->Type, from->Type,
from->Size, from->Size,
ac->start, 0,
ac->count); ac->count - ac->start);
to->Size = from->Size; to->Size = from->Size;
to->StrideB = 4 * sizeof(GLfloat); to->StrideB = 4 * sizeof(GLfloat);
to->Type = GL_FLOAT; to->Type = GL_FLOAT;
ac->Current.Vertex = to; ac->IsCached.Vertex = GL_TRUE;
ac->Writeable.Vertex = GL_TRUE;
} }
static void import_normal( GLcontext *ctx, static void import_normal( GLcontext *ctx,
GLenum type, GLuint stride ) GLenum type, GLuint stride )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
struct gl_client_array *from = ac->Current.Normal; struct gl_client_array *from = &ac->Raw.Normal;
struct gl_client_array *to = &ac->Cache.Normal; struct gl_client_array *to = &ac->Cache.Normal;
/* fprintf(stderr, "ac: import_normal\n"); */
/* Limited choices at this stage: /* Limited choices at this stage:
*/ */
ASSERT(type == GL_FLOAT); ASSERT(type == GL_FLOAT);
@ -251,24 +249,21 @@ static void import_normal( GLcontext *ctx,
from->Ptr, from->Ptr,
from->StrideB, from->StrideB,
from->Type, from->Type,
ac->start, 0,
ac->count); ac->count - ac->start);
to->StrideB = 3 * sizeof(GLfloat); to->StrideB = 3 * sizeof(GLfloat);
to->Type = GL_FLOAT; to->Type = GL_FLOAT;
ac->Current.Normal = to; ac->IsCached.Normal = GL_TRUE;
ac->Writeable.Normal = GL_TRUE;
} }
static void import_color( GLcontext *ctx, static void import_color( GLcontext *ctx,
GLenum type, GLuint stride ) GLenum type, GLuint stride )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
struct gl_client_array *from = ac->Current.Color; struct gl_client_array *from = &ac->Raw.Color;
struct gl_client_array *to = &ac->Cache.Color; struct gl_client_array *to = &ac->Cache.Color;
/* fprintf(stderr, "(ac) %s\n", __FUNCTION__); */
/* Limited choices at this stage: /* Limited choices at this stage:
*/ */
/* XXX GLchan: is this right for GLchan? */ /* XXX GLchan: is this right for GLchan? */
@ -277,42 +272,41 @@ static void import_color( GLcontext *ctx,
#if CHAN_TYPE == GL_UNSIGNED_BYTE #if CHAN_TYPE == GL_UNSIGNED_BYTE
_math_trans_4ub( to->Ptr, _math_trans_4ub( to->Ptr,
from->Ptr, from->Ptr,
from->StrideB, from->StrideB,
from->Type, from->Type,
from->Size, from->Size,
ac->start, 0,
ac->count); ac->count - ac->start);
#elif CHAN_TYPE == GL_UNSIGNED_SHORT #elif CHAN_TYPE == GL_UNSIGNED_SHORT
_math_trans_4us( to->Ptr, _math_trans_4us( to->Ptr,
from->Ptr, from->Ptr,
from->StrideB, from->StrideB,
from->Type, from->Type,
from->Size, from->Size,
ac->start, 0,
ac->count); ac->count - ac->start);
#elif CHAN_TYPE == GL_FLOAT #elif CHAN_TYPE == GL_FLOAT
_math_trans_4f( to->Ptr, _math_trans_4f( to->Ptr,
from->Ptr, from->Ptr,
from->StrideB, from->StrideB,
from->Type, from->Type,
from->Size, from->Size,
ac->start, 0,
ac->count); ac->count - ac->start);
#endif #endif
to->Size = from->Size; to->Size = from->Size;
to->StrideB = 4 * sizeof(GLchan); to->StrideB = 4 * sizeof(GLchan);
to->Type = CHAN_TYPE; to->Type = CHAN_TYPE;
ac->Current.Color = to; ac->IsCached.Color = GL_TRUE;
ac->Writeable.Color = GL_TRUE;
} }
static void import_index( GLcontext *ctx, static void import_index( GLcontext *ctx,
GLenum type, GLuint stride ) GLenum type, GLuint stride )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
struct gl_client_array *from = ac->Current.Index; struct gl_client_array *from = &ac->Raw.Index;
struct gl_client_array *to = &ac->Cache.Index; struct gl_client_array *to = &ac->Cache.Index;
/* Limited choices at this stage: /* Limited choices at this stage:
@ -324,20 +318,19 @@ static void import_index( GLcontext *ctx,
from->Ptr, from->Ptr,
from->StrideB, from->StrideB,
from->Type, from->Type,
ac->start, 0,
ac->count); ac->count - ac->start);
to->StrideB = sizeof(GLuint); to->StrideB = sizeof(GLuint);
to->Type = GL_UNSIGNED_INT; to->Type = GL_UNSIGNED_INT;
ac->Current.Index = to; ac->IsCached.Index = GL_TRUE;
ac->Writeable.Index = GL_TRUE;
} }
static void import_secondarycolor( GLcontext *ctx, static void import_secondarycolor( GLcontext *ctx,
GLenum type, GLuint stride ) GLenum type, GLuint stride )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
struct gl_client_array *from = ac->Current.SecondaryColor; struct gl_client_array *from = &ac->Raw.SecondaryColor;
struct gl_client_array *to = &ac->Cache.SecondaryColor; struct gl_client_array *to = &ac->Cache.SecondaryColor;
/* Limited choices at this stage: /* Limited choices at this stage:
@ -351,37 +344,36 @@ static void import_secondarycolor( GLcontext *ctx,
from->StrideB, from->StrideB,
from->Type, from->Type,
from->Size, from->Size,
ac->start, 0,
ac->count); ac->count - ac->start);
#elif CHAN_TYPE == GL_UNSIGNED_SHORT #elif CHAN_TYPE == GL_UNSIGNED_SHORT
_math_trans_4us( to->Ptr, _math_trans_4us( to->Ptr,
from->Ptr, from->Ptr,
from->StrideB, from->StrideB,
from->Type, from->Type,
from->Size, from->Size,
ac->start, 0,
ac->count); ac->count - ac->start);
#elif CHAN_TYPE == GL_FLOAT #elif CHAN_TYPE == GL_FLOAT
_math_trans_4f( to->Ptr, _math_trans_4f( to->Ptr,
from->Ptr, from->Ptr,
from->StrideB, from->StrideB,
from->Type, from->Type,
from->Size, from->Size,
ac->start, 0,
ac->count); ac->count - ac->start);
#endif #endif
to->StrideB = 4 * sizeof(GLchan); to->StrideB = 4 * sizeof(GLchan);
to->Type = CHAN_TYPE; to->Type = CHAN_TYPE;
ac->Current.SecondaryColor = to; ac->IsCached.SecondaryColor = GL_TRUE;
ac->Writeable.SecondaryColor = GL_TRUE;
} }
static void import_fogcoord( GLcontext *ctx, static void import_fogcoord( GLcontext *ctx,
GLenum type, GLuint stride ) GLenum type, GLuint stride )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
struct gl_client_array *from = ac->Current.FogCoord; struct gl_client_array *from = &ac->Raw.FogCoord;
struct gl_client_array *to = &ac->Cache.FogCoord; struct gl_client_array *to = &ac->Cache.FogCoord;
/* Limited choices at this stage: /* Limited choices at this stage:
@ -393,20 +385,19 @@ static void import_fogcoord( GLcontext *ctx,
from->Ptr, from->Ptr,
from->StrideB, from->StrideB,
from->Type, from->Type,
ac->start, 0,
ac->count); ac->count - ac->start);
to->StrideB = sizeof(GLfloat); to->StrideB = sizeof(GLfloat);
to->Type = GL_FLOAT; to->Type = GL_FLOAT;
ac->Current.FogCoord = to; ac->IsCached.FogCoord = GL_TRUE;
ac->Writeable.FogCoord = GL_TRUE;
} }
static void import_edgeflag( GLcontext *ctx, static void import_edgeflag( GLcontext *ctx,
GLenum type, GLuint stride ) GLenum type, GLuint stride )
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
struct gl_client_array *from = ac->Current.EdgeFlag; struct gl_client_array *from = &ac->Raw.EdgeFlag;
struct gl_client_array *to = &ac->Cache.EdgeFlag; struct gl_client_array *to = &ac->Cache.EdgeFlag;
/* Limited choices at this stage: /* Limited choices at this stage:
@ -418,13 +409,12 @@ static void import_edgeflag( GLcontext *ctx,
from->Ptr, from->Ptr,
from->StrideB, from->StrideB,
from->Type, from->Type,
ac->start, 0,
ac->count); ac->count - ac->start);
to->StrideB = sizeof(GLfloat); to->StrideB = sizeof(GLfloat);
to->Type = GL_FLOAT; to->Type = GL_FLOAT;
ac->Current.EdgeFlag = to; ac->IsCached.EdgeFlag = GL_TRUE;
ac->Writeable.EdgeFlag = GL_TRUE;
} }
@ -448,18 +438,24 @@ struct gl_client_array *_ac_import_texcoord( GLcontext *ctx,
/* Is the request impossible? /* Is the request impossible?
*/ */
if (reqsize != 0 && ac->Current.TexCoord[unit]->Size > reqsize) if (reqsize != 0 && ac->Raw.TexCoord[unit].Size > reqsize)
return 0; return 0;
/* Do we need to pull in a copy of the client data: /* Do we need to pull in a copy of the client data:
*/ */
if (ac->Current.TexCoord[unit]->Type != type || if (ac->Raw.TexCoord[unit].Type != type ||
(reqstride != 0 && ac->Current.TexCoord[unit]->StrideB != reqstride) || (reqstride != 0 && ac->Raw.TexCoord[unit].StrideB != reqstride) ||
(reqwriteable && !ac->Writeable.TexCoord[unit])) reqwriteable)
import_texcoord(ctx, unit, type, reqstride ); {
if (!ac->IsCached.TexCoord[unit])
*writeable = ac->Writeable.TexCoord[unit]; import_texcoord(ctx, unit, type, reqstride );
return ac->Current.TexCoord[unit]; *writeable = GL_TRUE;
return &ac->Cache.TexCoord[unit];
}
else {
*writeable = GL_FALSE;
return &ac->Raw.TexCoord[unit];
}
} }
struct gl_client_array *_ac_import_vertex( GLcontext *ctx, struct gl_client_array *_ac_import_vertex( GLcontext *ctx,
@ -478,18 +474,24 @@ struct gl_client_array *_ac_import_vertex( GLcontext *ctx,
/* Is the request impossible? /* Is the request impossible?
*/ */
if (reqsize != 0 && ac->Current.Vertex->Size > reqsize) if (reqsize != 0 && ac->Raw.Vertex.Size > reqsize)
return 0; return 0;
/* Do we need to pull in a copy of the client data: /* Do we need to pull in a copy of the client data:
*/ */
if (ac->Current.Vertex->Type != type || if (ac->Raw.Vertex.Type != type ||
(reqstride != 0 && ac->Current.Vertex->StrideB != reqstride) || (reqstride != 0 && ac->Raw.Vertex.StrideB != reqstride) ||
(reqwriteable && !ac->Writeable.Vertex)) reqwriteable)
import_vertex(ctx, type, reqstride ); {
if (!ac->IsCached.Vertex)
*writeable = ac->Writeable.Vertex; import_vertex(ctx, type, reqstride );
return ac->Current.Vertex; *writeable = GL_TRUE;
return &ac->Cache.Vertex;
}
else {
*writeable = GL_FALSE;
return &ac->Raw.Vertex;
}
} }
struct gl_client_array *_ac_import_normal( GLcontext *ctx, struct gl_client_array *_ac_import_normal( GLcontext *ctx,
@ -500,8 +502,6 @@ struct gl_client_array *_ac_import_normal( GLcontext *ctx,
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
/* fprintf(stderr, "%s %d\n", __FUNCTION__, ac->NewArrayState & _NEW_ARRAY_NORMAL); */
/* Can we keep the existing version? /* Can we keep the existing version?
*/ */
if (ac->NewArrayState & _NEW_ARRAY_NORMAL) if (ac->NewArrayState & _NEW_ARRAY_NORMAL)
@ -509,13 +509,19 @@ struct gl_client_array *_ac_import_normal( GLcontext *ctx,
/* Do we need to pull in a copy of the client data: /* Do we need to pull in a copy of the client data:
*/ */
if (ac->Current.Normal->Type != type || if (ac->Raw.Normal.Type != type ||
(reqstride != 0 && ac->Current.Normal->StrideB != reqstride) || (reqstride != 0 && ac->Raw.Normal.StrideB != reqstride) ||
(reqwriteable && !ac->Writeable.Normal)) reqwriteable)
import_normal(ctx, type, reqstride ); {
if (!ac->IsCached.Normal)
*writeable = ac->Writeable.Normal; import_normal(ctx, type, reqstride );
return ac->Current.Normal; *writeable = GL_TRUE;
return &ac->Cache.Normal;
}
else {
*writeable = GL_FALSE;
return &ac->Raw.Normal;
}
} }
struct gl_client_array *_ac_import_color( GLcontext *ctx, struct gl_client_array *_ac_import_color( GLcontext *ctx,
@ -527,9 +533,6 @@ struct gl_client_array *_ac_import_color( GLcontext *ctx,
{ {
ACcontext *ac = AC_CONTEXT(ctx); ACcontext *ac = AC_CONTEXT(ctx);
/* fprintf(stderr, "%s stride %d sz %d wr %d\n", __FUNCTION__, */
/* reqstride, reqsize, reqwriteable); */
/* Can we keep the existing version? /* Can we keep the existing version?
*/ */
if (ac->NewArrayState & _NEW_ARRAY_COLOR) if (ac->NewArrayState & _NEW_ARRAY_COLOR)
@ -537,20 +540,25 @@ struct gl_client_array *_ac_import_color( GLcontext *ctx,
/* Is the request impossible? /* Is the request impossible?
*/ */
if (reqsize != 0 && ac->Current.Color->Size > reqsize) { if (reqsize != 0 && ac->Raw.Color.Size > reqsize) {
/* fprintf(stderr, "%s -- failed\n", __FUNCTION__); */
return 0; return 0;
} }
/* Do we need to pull in a copy of the client data: /* Do we need to pull in a copy of the client data:
*/ */
if (ac->Current.Color->Type != type || if (ac->Raw.Color.Type != type ||
(reqstride != 0 && ac->Current.Color->StrideB != reqstride) || (reqstride != 0 && ac->Raw.Color.StrideB != reqstride) ||
(reqwriteable && !ac->Writeable.Color)) reqwriteable)
import_color(ctx, type, reqstride ); {
if (!ac->IsCached.Color)
*writeable = ac->Writeable.Color; import_color(ctx, type, reqstride );
return ac->Current.Color; *writeable = GL_TRUE;
return &ac->Cache.Color;
}
else {
*writeable = GL_FALSE;
return &ac->Raw.Color;
}
} }
struct gl_client_array *_ac_import_index( GLcontext *ctx, struct gl_client_array *_ac_import_index( GLcontext *ctx,
@ -569,13 +577,19 @@ struct gl_client_array *_ac_import_index( GLcontext *ctx,
/* Do we need to pull in a copy of the client data: /* Do we need to pull in a copy of the client data:
*/ */
if (ac->Current.Index->Type != type || if (ac->Raw.Index.Type != type ||
(reqstride != 0 && ac->Current.Index->StrideB != reqstride) || (reqstride != 0 && ac->Raw.Index.StrideB != reqstride) ||
(reqwriteable && !ac->Writeable.Index)) reqwriteable)
import_index(ctx, type, reqstride ); {
if (!ac->IsCached.Index)
*writeable = ac->Writeable.Index; import_index(ctx, type, reqstride );
return ac->Current.Index; *writeable = GL_TRUE;
return &ac->Cache.Index;
}
else {
*writeable = GL_FALSE;
return &ac->Raw.Index;
}
} }
struct gl_client_array *_ac_import_secondarycolor( GLcontext *ctx, struct gl_client_array *_ac_import_secondarycolor( GLcontext *ctx,
@ -594,18 +608,24 @@ struct gl_client_array *_ac_import_secondarycolor( GLcontext *ctx,
/* Is the request impossible? /* Is the request impossible?
*/ */
if (reqsize != 0 && ac->Current.SecondaryColor->Size > reqsize) if (reqsize != 0 && ac->Raw.SecondaryColor.Size > reqsize)
return 0; return 0;
/* Do we need to pull in a copy of the client data: /* Do we need to pull in a copy of the client data:
*/ */
if (ac->Current.SecondaryColor->Type != type || if (ac->Raw.SecondaryColor.Type != type ||
(reqstride != 0 && ac->Current.SecondaryColor->StrideB != reqstride) || (reqstride != 0 && ac->Raw.SecondaryColor.StrideB != reqstride) ||
(reqwriteable && !ac->Writeable.SecondaryColor)) reqwriteable)
import_secondarycolor( ctx, type, reqstride ); {
if (!ac->IsCached.SecondaryColor)
*writeable = ac->Writeable.SecondaryColor; import_secondarycolor(ctx, type, reqstride );
return ac->Current.SecondaryColor; *writeable = GL_TRUE;
return &ac->Cache.SecondaryColor;
}
else {
*writeable = GL_FALSE;
return &ac->Raw.SecondaryColor;
}
} }
struct gl_client_array *_ac_import_fogcoord( GLcontext *ctx, struct gl_client_array *_ac_import_fogcoord( GLcontext *ctx,
@ -623,13 +643,19 @@ struct gl_client_array *_ac_import_fogcoord( GLcontext *ctx,
/* Do we need to pull in a copy of the client data: /* Do we need to pull in a copy of the client data:
*/ */
if (ac->Current.FogCoord->Type != type || if (ac->Raw.FogCoord.Type != type ||
(reqstride != 0 && ac->Current.FogCoord->StrideB != reqstride) || (reqstride != 0 && ac->Raw.FogCoord.StrideB != reqstride) ||
(reqwriteable && !ac->Writeable.FogCoord)) reqwriteable)
import_fogcoord(ctx, type, reqstride ); {
if (!ac->IsCached.FogCoord)
*writeable = ac->Writeable.FogCoord; import_fogcoord(ctx, type, reqstride );
return ac->Current.FogCoord; *writeable = GL_TRUE;
return &ac->Cache.FogCoord;
}
else {
*writeable = GL_FALSE;
return &ac->Raw.FogCoord;
}
} }
@ -650,13 +676,19 @@ struct gl_client_array *_ac_import_edgeflag( GLcontext *ctx,
/* Do we need to pull in a copy of the client data: /* Do we need to pull in a copy of the client data:
*/ */
if (ac->Current.EdgeFlag->Type != type || if (ac->Raw.EdgeFlag.Type != type ||
(reqstride != 0 && ac->Current.EdgeFlag->StrideB != reqstride) || (reqstride != 0 && ac->Raw.EdgeFlag.StrideB != reqstride) ||
(reqwriteable && !ac->Writeable.EdgeFlag)) reqwriteable)
import_edgeflag(ctx, type, reqstride ); {
if (!ac->IsCached.EdgeFlag)
*writeable = ac->Writeable.EdgeFlag; import_edgeflag(ctx, type, reqstride );
return ac->Current.EdgeFlag; *writeable = GL_TRUE;
return &ac->Cache.EdgeFlag;
}
else {
*writeable = GL_FALSE;
return &ac->Raw.EdgeFlag;
}
} }