diff options
Diffstat (limited to 'src/mesa/array_cache')
-rw-r--r-- | src/mesa/array_cache/ac_context.h | 9 | ||||
-rw-r--r-- | src/mesa/array_cache/ac_import.c | 121 | ||||
-rw-r--r-- | src/mesa/array_cache/acache.h | 33 |
3 files changed, 137 insertions, 26 deletions
diff --git a/src/mesa/array_cache/ac_context.h b/src/mesa/array_cache/ac_context.h index 18a639b3f8..55257983f6 100644 --- a/src/mesa/array_cache/ac_context.h +++ b/src/mesa/array_cache/ac_context.h @@ -1,10 +1,10 @@ -/* $Id: ac_context.h,v 1.3 2001/03/12 00:48:41 gareth Exp $ */ +/* $Id: ac_context.h,v 1.4 2002/04/21 18:49:19 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 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"), @@ -47,6 +47,7 @@ struct ac_arrays { struct gl_client_array Index; struct gl_client_array TexCoord[MAX_TEXTURE_UNITS]; struct gl_client_array EdgeFlag; + struct gl_client_array Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */ }; struct ac_array_pointers { @@ -58,6 +59,7 @@ struct ac_array_pointers { struct gl_client_array *Index; struct gl_client_array *TexCoord[MAX_TEXTURE_UNITS]; struct gl_client_array *EdgeFlag; + struct gl_client_array *Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */ }; struct ac_array_flags { @@ -69,6 +71,7 @@ struct ac_array_flags { GLboolean Index; GLboolean TexCoord[MAX_TEXTURE_UNITS]; GLboolean EdgeFlag; + GLboolean Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */ }; diff --git a/src/mesa/array_cache/ac_import.c b/src/mesa/array_cache/ac_import.c index 2fc13dc2d7..9867f9f51b 100644 --- a/src/mesa/array_cache/ac_import.c +++ b/src/mesa/array_cache/ac_import.c @@ -1,4 +1,4 @@ -/* $Id: ac_import.c,v 1.16 2002/01/05 20:51:12 brianp Exp $ */ +/* $Id: ac_import.c,v 1.17 2002/04/21 18:49:19 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -147,6 +147,7 @@ static void reset_index( GLcontext *ctx ) ac->NewArrayState &= ~_NEW_ARRAY_INDEX; } + static void reset_fogcoord( GLcontext *ctx ) { ACcontext *ac = AC_CONTEXT(ctx); @@ -162,6 +163,7 @@ static void reset_fogcoord( GLcontext *ctx ) ac->NewArrayState &= ~_NEW_ARRAY_FOGCOORD; } + static void reset_edgeflag( GLcontext *ctx ) { ACcontext *ac = AC_CONTEXT(ctx); @@ -178,7 +180,33 @@ static void reset_edgeflag( GLcontext *ctx ) } +static void reset_attrib( GLcontext *ctx, GLuint index ) +{ + ACcontext *ac = AC_CONTEXT(ctx); + + if (ctx->Array._Enabled & _NEW_ARRAY_ATTRIB(index)) { + ac->Raw.Attrib[index] = ctx->Array.VertexAttrib[index]; + STRIDE_ARRAY(ac->Raw.Attrib[index], ac->start); + } + else { + ac->Raw.Attrib[index] = ac->Fallback.Attrib[index]; + + if (ctx->Current.Attrib[index][3] != 1.0) + ac->Raw.Attrib[index].Size = 4; + else if (ctx->Current.Attrib[index][2] != 0.0) + ac->Raw.Attrib[index].Size = 3; + else + ac->Raw.Attrib[index].Size = 2; + } + + ac->IsCached.Attrib[index] = GL_FALSE; + ac->NewArrayState &= ~_NEW_ARRAY_ATTRIB(index); +} + +/* + * Generic import function for color data + */ static void import( GLcontext *ctx, GLenum type, struct gl_client_array *to, @@ -237,8 +265,12 @@ static void import( GLcontext *ctx, -/* Functions to import array ranges with specified types and strides. +/* + * Functions to import array ranges with specified types and strides. + * For example, if the vertex data is GLshort[2] and we want GLfloat[3] + * we'll use an import function to do the data conversion. */ + static void import_texcoord( GLcontext *ctx, GLuint unit, GLenum type, GLuint stride ) { @@ -246,6 +278,8 @@ static void import_texcoord( GLcontext *ctx, GLuint unit, struct gl_client_array *from = &ac->Raw.TexCoord[unit]; struct gl_client_array *to = &ac->Cache.TexCoord[unit]; + ASSERT(unit < ctx->Const.MaxTextureUnits); + /* Limited choices at this stage: */ ASSERT(type == GL_FLOAT); @@ -316,9 +350,6 @@ static void import_normal( GLcontext *ctx, ac->IsCached.Normal = GL_TRUE; } - - - static void import_color( GLcontext *ctx, GLenum type, GLuint stride ) { @@ -415,10 +446,42 @@ static void import_edgeflag( GLcontext *ctx, ac->IsCached.EdgeFlag = GL_TRUE; } +static void import_attrib( GLcontext *ctx, GLuint index, + GLenum type, GLuint stride ) +{ + ACcontext *ac = AC_CONTEXT(ctx); + struct gl_client_array *from = &ac->Raw.Attrib[index]; + struct gl_client_array *to = &ac->Cache.Attrib[index]; + ASSERT(index < VERT_ATTRIB_MAX); -/* Externals to request arrays with specific properties: + /* Limited choices at this stage: + */ + ASSERT(type == GL_FLOAT); + ASSERT(stride == 4*sizeof(GLfloat) || stride == 0); + ASSERT(ac->count - ac->start < ctx->Const.MaxArrayLockSize); + + _math_trans_4f( (GLfloat (*)[4]) to->Ptr, + from->Ptr, + from->StrideB, + from->Type, + from->Size, + 0, + ac->count - ac->start); + + to->Size = from->Size; + to->StrideB = 4 * sizeof(GLfloat); + to->Type = GL_FLOAT; + ac->IsCached.Attrib[index] = GL_TRUE; +} + + + +/* + * Externals to request arrays with specific properties: */ + + struct gl_client_array *_ac_import_texcoord( GLcontext *ctx, GLuint unit, GLenum type, @@ -429,6 +492,8 @@ struct gl_client_array *_ac_import_texcoord( GLcontext *ctx, { ACcontext *ac = AC_CONTEXT(ctx); + ASSERT(unit < ctx->Const.MaxTextureUnits); + /* Can we keep the existing version? */ if (ac->NewArrayState & _NEW_ARRAY_TEXCOORD(unit)) @@ -656,9 +721,6 @@ struct gl_client_array *_ac_import_fogcoord( GLcontext *ctx, } } - - - struct gl_client_array *_ac_import_edgeflag( GLcontext *ctx, GLenum type, GLuint reqstride, @@ -689,8 +751,45 @@ struct gl_client_array *_ac_import_edgeflag( GLcontext *ctx, } } +/* GL_NV_vertex_program */ +struct gl_client_array *_ac_import_attrib( GLcontext *ctx, + GLuint index, + GLenum type, + GLuint reqstride, + GLuint reqsize, + GLboolean reqwriteable, + GLboolean *writeable ) +{ + ACcontext *ac = AC_CONTEXT(ctx); + + ASSERT(index < VERT_ATTRIB_MAX); + /* Can we keep the existing version? + */ + if (ac->NewArrayState & _NEW_ARRAY_ATTRIB(index)) + reset_attrib( ctx, index ); + /* Is the request impossible? + */ + if (reqsize != 0 && ac->Raw.Attrib[index].Size > (GLint) reqsize) + return 0; + + /* Do we need to pull in a copy of the client data: + */ + if (ac->Raw.Attrib[index].Type != type || + (reqstride != 0 && ac->Raw.Attrib[index].StrideB != (GLint)reqstride) || + reqwriteable) + { + if (!ac->IsCached.Attrib[index]) + import_attrib(ctx, index, type, reqstride ); + *writeable = GL_TRUE; + return &ac->Cache.Attrib[index]; + } + else { + *writeable = GL_FALSE; + return &ac->Raw.Attrib[index]; + } +} /* Clients must call this function to validate state and set bounds @@ -723,8 +822,8 @@ void _ac_import_range( GLcontext *ctx, GLuint start, GLuint count ) -/* Additional convienence function for importing a the element list - * for drawelements, drawrangeelements: +/* Additional convienence function for importing the element list + * for glDrawElements() and glDrawRangeElements(). */ CONST void * _ac_import_elements( GLcontext *ctx, diff --git a/src/mesa/array_cache/acache.h b/src/mesa/array_cache/acache.h index 6cb2115354..4e0e377915 100644 --- a/src/mesa/array_cache/acache.h +++ b/src/mesa/array_cache/acache.h @@ -1,10 +1,10 @@ -/* $Id: acache.h,v 1.2 2001/03/12 00:48:41 gareth Exp $ */ +/* $Id: acache.h,v 1.3 2002/04/21 18:49:19 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 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"), @@ -43,15 +43,6 @@ extern void _ac_InvalidateState( GLcontext *ctx, GLuint new_state ); extern struct gl_client_array * -_ac_import_texcoord( GLcontext *ctx, - GLuint unit, - GLenum type, - GLuint reqstride, - GLuint reqsize, - GLboolean reqwritable, - GLboolean *writable ); - -extern struct gl_client_array * _ac_import_vertex( GLcontext *ctx, GLenum type, GLuint reqstride, @@ -103,6 +94,24 @@ _ac_import_edgeflag( GLcontext *ctx, GLboolean reqwritable, GLboolean *writable ); +extern struct gl_client_array * +_ac_import_texcoord( GLcontext *ctx, + GLuint unit, + GLenum type, + GLuint reqstride, + GLuint reqsize, + GLboolean reqwritable, + GLboolean *writable ); + +extern struct gl_client_array * +_ac_import_attrib( GLcontext *ctx, + GLuint index, + GLenum type, + GLuint reqstride, + GLuint reqsize, + GLboolean reqwritable, + GLboolean *writable ); + /* Clients must call this function to validate state and set bounds * before importing any data: |