diff options
Diffstat (limited to 'src/mesa')
-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 | ||||
-rw-r--r-- | src/mesa/main/dd.h | 4 | ||||
-rw-r--r-- | src/mesa/main/enable.c | 4 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 5 | ||||
-rw-r--r-- | src/mesa/main/varray.c | 15 |
7 files changed, 151 insertions, 40 deletions
diff --git a/src/mesa/array_cache/ac_context.h b/src/mesa/array_cache/ac_context.h index 18a639b3f83..55257983f6e 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 2fc13dc2d77..9867f9f51bf 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 6cb21153546..4e0e3779150 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: diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 572bd054f3f..25b72245e40 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -1,4 +1,4 @@ -/* $Id: dd.h,v 1.67 2002/03/16 00:57:14 brianp Exp $ */ +/* $Id: dd.h,v 1.68 2002/04/21 18:49:18 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -542,6 +542,8 @@ struct dd_function_table { void (*TexCoordPointer)(GLcontext *ctx, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr); void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr); + void (*VertexAttribPointer)(GLcontext *ctx, GLuint index, GLint size, + GLenum type, GLsizei stride, const GLvoid *ptr); /*** State-query functions diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 78c200dcae4..af870e1639a 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -1,4 +1,4 @@ -/* $Id: enable.c,v 1.61 2002/04/19 08:38:23 alanh Exp $ */ +/* $Id: enable.c,v 1.62 2002/04/21 18:49:18 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -112,7 +112,7 @@ client_state( GLcontext *ctx, GLenum cap, GLboolean state ) { GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; var = &ctx->Array.VertexAttrib[n].Enabled; - flag = _NEW_ARRAY_VERT_ATTRIB0; /* XXX flag OK? */ + flag = _NEW_ARRAY_ATTRIB(n); } break; default: diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 6dde32b52c1..a14347fb553 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.71 2002/04/19 15:49:40 kschultz Exp $ */ +/* $Id: mtypes.h,v 1.72 2002/04/21 18:49:18 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1538,10 +1538,11 @@ struct matrix_stack #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7 #define _NEW_ARRAY_ALL 0xffff -#define _NEW_ARRAY_VERT_ATTRIB0 0x10000 +#define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */ #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i)) +#define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i)) /* A bunch of flags that we think might be useful to drivers. */ diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index bf783ee9707..f35e50c8724 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1,4 +1,4 @@ -/* $Id: varray.c,v 1.42 2002/04/04 23:59:14 brianp Exp $ */ +/* $Id: varray.c,v 1.43 2002/04/21 18:49:18 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -452,12 +452,12 @@ _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *vptr) void _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, - GLsizei stride, const GLvoid *pointer) + GLsizei stride, const GLvoid *ptr) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - if (index >= VP_NUM_PROG_REGS) { + if (index >= VERT_ATTRIB_MAX) { _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)"); return; } @@ -502,16 +502,13 @@ void _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, ctx->Array.VertexAttrib[index].Stride = stride; ctx->Array.VertexAttrib[index].Size = size; ctx->Array.VertexAttrib[index].Type = type; + ctx->Array.VertexAttrib[index].Ptr = (void *) ptr; - /* XXX need new flags here??? */ ctx->NewState |= _NEW_ARRAY; - /* XXX probably need new flags!!!! */ - ctx->Array.NewState |= _NEW_ARRAY_VERT_ATTRIB0; + ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index); - /* XXX - if (ctx->Driver.VertexAttribdPointer) + if (ctx->Driver.VertexAttribPointer) ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr ); - */ } |