diff options
author | Brian Paul <[email protected]> | 2006-04-25 00:21:32 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2006-04-25 00:21:32 +0000 |
commit | 095c6699f449ed4803f23e844cc0227743a9c3e1 (patch) | |
tree | 2446935d4cdb2ab45834a94e8780d90ddd66292e /src/mesa/tnl | |
parent | f12ea2d402e8f6d29dfd40c731351ff210887b58 (diff) |
No longer alias generic vertex attribs with conventional attribs for GL_ARB_vertex_program.
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r-- | src/mesa/tnl/t_context.h | 11 | ||||
-rw-r--r-- | src/mesa/tnl/t_vtx_api.c | 54 | ||||
-rw-r--r-- | src/mesa/tnl/t_vtx_api.h | 3 | ||||
-rw-r--r-- | src/mesa/tnl/t_vtx_generic.c | 160 |
4 files changed, 158 insertions, 70 deletions
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 7a0ca6f411f..7a80e3477ca 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -152,6 +152,9 @@ enum { #define _TNL_ATTRIB_TEX(u) (_TNL_ATTRIB_TEX0 + (u)) #define _TNL_ATTRIB_ATTRIBUTE(n) (_TNL_ATTRIB_ATTRIBUTE0 + (n)) +/* special index used for handing invalid glVertexAttribute() indices */ +#define _TNL_ATTRIB_ERROR (_TNL_ATTRIB_ATTRIBUTE15 + 1) + /* Define bit ranges instead of bit masks. */ #define _TNL_FIRST_PROG _TNL_ATTRIB_WEIGHT @@ -228,10 +231,11 @@ struct _tnl_dynfn_generators { struct _tnl_dynfn *(*Attribute[4])( GLcontext *ctx, int key ); }; -#define _TNL_MAX_ATTR_CODEGEN 16 +#define _TNL_MAX_ATTR_CODEGEN 32 -/* The assembly of vertices in immediate mode is separated from +/** + * The assembly of vertices in immediate mode is separated from * display list compilation. This allows a simpler immediate mode * treatment and a display list compiler better suited to * hardware-acceleration. @@ -250,7 +254,8 @@ struct tnl_vtx { GLuint counter, initial_counter; struct tnl_copied_vtx copied; - tnl_attrfv_func tabfv[_TNL_MAX_ATTR_CODEGEN+1][4]; /* plus 1 for ERROR_ATTRIB */ + /** Note extra space for error handler: */ + tnl_attrfv_func tabfv[_TNL_ATTRIB_ERROR+1][4]; struct _tnl_dynfn_lists cache; struct _tnl_dynfn_generators gen; diff --git a/src/mesa/tnl/t_vtx_api.c b/src/mesa/tnl/t_vtx_api.c index feb462ba3d9..e8f63f23ae3 100644 --- a/src/mesa/tnl/t_vtx_api.c +++ b/src/mesa/tnl/t_vtx_api.c @@ -47,7 +47,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. static void reset_attrfv( TNLcontext *tnl ); -static tnl_attrfv_func choose[_TNL_MAX_ATTR_CODEGEN+1][4]; /* +1 for ERROR_ATTRIB */ +/** Note extra space for error index: */ +static tnl_attrfv_func choose[_TNL_ATTRIB_ERROR+1][4]; static tnl_attrfv_func generic_attr_func[_TNL_MAX_ATTR_CODEGEN][4]; @@ -191,8 +192,7 @@ static void _tnl_copy_from_current( GLcontext *ctx ) /* Edgeflag requires additional treatment: */ - tnl->vtx.CurrentFloatEdgeFlag = - (GLfloat)ctx->Current.EdgeFlag; + tnl->vtx.CurrentFloatEdgeFlag = (GLfloat) ctx->Current.EdgeFlag; for (i = _TNL_ATTRIB_POS+1 ; i < _TNL_ATTRIB_MAX ; i++) switch (tnl->vtx.attrsz[i]) { @@ -435,6 +435,7 @@ static tnl_attrfv_func do_choose( GLuint attr, GLuint sz ) if (!tnl->vtx.tabfv[attr][sz-1]) tnl->vtx.tabfv[attr][sz-1] = generic_attr_func[attr][sz-1]; + ASSERT(tnl->vtx.tabfv[attr][sz-1]); return tnl->vtx.tabfv[attr][sz-1]; } @@ -444,6 +445,7 @@ static tnl_attrfv_func do_choose( GLuint attr, GLuint sz ) static void choose_##ATTR##_##N( const GLfloat *v ) \ { \ tnl_attrfv_func f = do_choose(ATTR, N); \ + ASSERT(f); \ f( v ); \ } @@ -455,11 +457,13 @@ static void choose_##ATTR##_##N( const GLfloat *v ) \ #define INIT_CHOOSERS(ATTR) \ + ASSERT(ATTR <= _TNL_ATTRIB_ERROR);\ choose[ATTR][0] = choose_##ATTR##_1; \ choose[ATTR][1] = choose_##ATTR##_2; \ choose[ATTR][2] = choose_##ATTR##_3; \ choose[ATTR][3] = choose_##ATTR##_4; +/* conventional attributes */ CHOOSERS( 0 ) CHOOSERS( 1 ) CHOOSERS( 2 ) @@ -477,6 +481,23 @@ CHOOSERS( 13 ) CHOOSERS( 14 ) CHOOSERS( 15 ) +/* generic attributes */ +CHOOSERS( 16 ) +CHOOSERS( 17 ) +CHOOSERS( 18 ) +CHOOSERS( 19 ) +CHOOSERS( 20 ) +CHOOSERS( 21 ) +CHOOSERS( 22 ) +CHOOSERS( 23 ) +CHOOSERS( 24 ) +CHOOSERS( 25 ) +CHOOSERS( 26 ) +CHOOSERS( 27 ) +CHOOSERS( 28 ) +CHOOSERS( 29 ) +CHOOSERS( 30 ) +CHOOSERS( 31 ) /** @@ -935,6 +956,7 @@ void _tnl_vtx_init( GLcontext *ctx ) if (firsttime) { firsttime = 0; + /* conventional attributes */ INIT_CHOOSERS( 0 ); INIT_CHOOSERS( 1 ); INIT_CHOOSERS( 2 ); @@ -952,10 +974,28 @@ void _tnl_vtx_init( GLcontext *ctx ) INIT_CHOOSERS( 14 ); INIT_CHOOSERS( 15 ); - choose[ERROR_ATTRIB][0] = error_attrib; - choose[ERROR_ATTRIB][1] = error_attrib; - choose[ERROR_ATTRIB][2] = error_attrib; - choose[ERROR_ATTRIB][3] = error_attrib; + /* generic attributes */ + INIT_CHOOSERS( 16 ); + INIT_CHOOSERS( 17 ); + INIT_CHOOSERS( 18 ); + INIT_CHOOSERS( 19 ); + INIT_CHOOSERS( 20 ); + INIT_CHOOSERS( 21 ); + INIT_CHOOSERS( 22 ); + INIT_CHOOSERS( 23 ); + INIT_CHOOSERS( 24 ); + INIT_CHOOSERS( 25 ); + INIT_CHOOSERS( 26 ); + INIT_CHOOSERS( 27 ); + INIT_CHOOSERS( 28 ); + INIT_CHOOSERS( 29 ); + INIT_CHOOSERS( 30 ); + INIT_CHOOSERS( 31 ); + + choose[_TNL_ATTRIB_ERROR][0] = error_attrib; + choose[_TNL_ATTRIB_ERROR][1] = error_attrib; + choose[_TNL_ATTRIB_ERROR][2] = error_attrib; + choose[_TNL_ATTRIB_ERROR][3] = error_attrib; #ifdef USE_X86_ASM if (tnl->AllowCodegen) { diff --git a/src/mesa/tnl/t_vtx_api.h b/src/mesa/tnl/t_vtx_api.h index 9818c082b80..53f57a14265 100644 --- a/src/mesa/tnl/t_vtx_api.h +++ b/src/mesa/tnl/t_vtx_api.h @@ -37,9 +37,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "t_context.h" -#define ERROR_ATTRIB 16 - - /* t_vtx_api.c: */ diff --git a/src/mesa/tnl/t_vtx_generic.c b/src/mesa/tnl/t_vtx_generic.c index d59ce90c6d7..bfae296921b 100644 --- a/src/mesa/tnl/t_vtx_generic.c +++ b/src/mesa/tnl/t_vtx_generic.c @@ -96,6 +96,7 @@ static void attrib_##ATTR##_##N( const GLfloat *v ) \ ATTRFV( ATTRIB, 3 ) \ ATTRFV( ATTRIB, 4 ) +/* conventional attribs */ ATTRS( 0 ) ATTRS( 1 ) ATTRS( 2 ) @@ -113,8 +114,28 @@ ATTRS( 13 ) ATTRS( 14 ) ATTRS( 15 ) +/* generic attribs */ +ATTRS( 16 ) +ATTRS( 17 ) +ATTRS( 18 ) +ATTRS( 19 ) +ATTRS( 20 ) +ATTRS( 21 ) +ATTRS( 22 ) +ATTRS( 23 ) +ATTRS( 24 ) +ATTRS( 25 ) +ATTRS( 26 ) +ATTRS( 27 ) +ATTRS( 28 ) +ATTRS( 29 ) +ATTRS( 30 ) +ATTRS( 31 ) + + void _tnl_generic_attr_table_init( tnl_attrfv_func (*tab)[4] ) { + /* conventional attribs */ INIT( tab, 0 ); INIT( tab, 1 ); INIT( tab, 2 ); @@ -131,6 +152,24 @@ void _tnl_generic_attr_table_init( tnl_attrfv_func (*tab)[4] ) INIT( tab, 13 ); INIT( tab, 14 ); INIT( tab, 15 ); + + /* generic attribs */ + INIT( tab, 16 ); + INIT( tab, 17 ); + INIT( tab, 18 ); + INIT( tab, 19 ); + INIT( tab, 20 ); + INIT( tab, 21 ); + INIT( tab, 22 ); + INIT( tab, 23 ); + INIT( tab, 24 ); + INIT( tab, 25 ); + INIT( tab, 26 ); + INIT( tab, 27 ); + INIT( tab, 28 ); + INIT( tab, 29 ); + INIT( tab, 30 ); + INIT( tab, 31 ); } /* These can be made efficient with codegen. Further, by adding more @@ -311,22 +350,19 @@ static void GLAPIENTRY _tnl_MultiTexCoord1f( GLenum target, GLfloat x ) DISPATCH_ATTR1F( attr, x ); } -static void GLAPIENTRY _tnl_MultiTexCoord1fv( GLenum target, - const GLfloat *v ) +static void GLAPIENTRY _tnl_MultiTexCoord1fv( GLenum target, const GLfloat *v ) { GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0; DISPATCH_ATTR1FV( attr, v ); } -static void GLAPIENTRY _tnl_MultiTexCoord2f( GLenum target, GLfloat x, - GLfloat y ) +static void GLAPIENTRY _tnl_MultiTexCoord2f( GLenum target, GLfloat x, GLfloat y ) { GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0; DISPATCH_ATTR2F( attr, x, y ); } -static void GLAPIENTRY _tnl_MultiTexCoord2fv( GLenum target, - const GLfloat *v ) +static void GLAPIENTRY _tnl_MultiTexCoord2fv( GLenum target, const GLfloat *v ) { GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0; DISPATCH_ATTR2FV( attr, v ); @@ -339,8 +375,7 @@ static void GLAPIENTRY _tnl_MultiTexCoord3f( GLenum target, GLfloat x, DISPATCH_ATTR3F( attr, x, y, z ); } -static void GLAPIENTRY _tnl_MultiTexCoord3fv( GLenum target, - const GLfloat *v ) +static void GLAPIENTRY _tnl_MultiTexCoord3fv( GLenum target, const GLfloat *v ) { GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0; DISPATCH_ATTR3FV( attr, v ); @@ -354,52 +389,59 @@ static void GLAPIENTRY _tnl_MultiTexCoord4f( GLenum target, GLfloat x, DISPATCH_ATTR4F( attr, x, y, z, w ); } -static void GLAPIENTRY _tnl_MultiTexCoord4fv( GLenum target, - const GLfloat *v ) +static void GLAPIENTRY _tnl_MultiTexCoord4fv( GLenum target, const GLfloat *v ) { GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0; DISPATCH_ATTR4FV( attr, v ); } +/** + * GL_NV_vertex_program Vertex Attributes + * Note that these attributes DO alias the conventional attributes. + * Also, calling glVertexAttribNV(0, xxx) is equivalent to glVertex(xxx). + */ + static void GLAPIENTRY _tnl_VertexAttrib1fNV( GLuint index, GLfloat x ) { - if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB; + if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) + index = _TNL_ATTRIB_ERROR; DISPATCH_ATTR1F( index, x ); } -static void GLAPIENTRY _tnl_VertexAttrib1fvNV( GLuint index, - const GLfloat *v ) +static void GLAPIENTRY _tnl_VertexAttrib1fvNV( GLuint index, const GLfloat *v ) { - if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB; + if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) + index = _TNL_ATTRIB_ERROR; DISPATCH_ATTR1FV( index, v ); } -static void GLAPIENTRY _tnl_VertexAttrib2fNV( GLuint index, GLfloat x, - GLfloat y ) +static void GLAPIENTRY _tnl_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) { - if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB; + if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) + index = _TNL_ATTRIB_ERROR; DISPATCH_ATTR2F( index, x, y ); } -static void GLAPIENTRY _tnl_VertexAttrib2fvNV( GLuint index, - const GLfloat *v ) +static void GLAPIENTRY _tnl_VertexAttrib2fvNV( GLuint index, const GLfloat *v ) { - if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB; + if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) + index = _TNL_ATTRIB_ERROR; DISPATCH_ATTR2FV( index, v ); } static void GLAPIENTRY _tnl_VertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z ) { - if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB; + if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) + index = _TNL_ATTRIB_ERROR; DISPATCH_ATTR3F( index, x, y, z ); } -static void GLAPIENTRY _tnl_VertexAttrib3fvNV( GLuint index, - const GLfloat *v ) +static void GLAPIENTRY _tnl_VertexAttrib3fvNV( GLuint index, const GLfloat *v ) { - if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB; + if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) + index = _TNL_ATTRIB_ERROR; DISPATCH_ATTR3FV( index, v ); } @@ -407,32 +449,40 @@ static void GLAPIENTRY _tnl_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) { - if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB; + if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) + index = _TNL_ATTRIB_ERROR; DISPATCH_ATTR4F( index, x, y, z, w ); } -static void GLAPIENTRY _tnl_VertexAttrib4fvNV( GLuint index, - const GLfloat *v ) +static void GLAPIENTRY _tnl_VertexAttrib4fvNV( GLuint index, const GLfloat *v ) { - if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB; + if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) + index = _TNL_ATTRIB_ERROR; DISPATCH_ATTR4FV( index, v ); } + + +/** + * GL_ARB_vertex_program Vertex Attributes + * Note that these attributes do NOT alias the conventional attributes. + * Also, calling glVertexAttribARB(0, xxx) is equivalent to glVertex(xxx). + */ + static void GLAPIENTRY _tnl_VertexAttrib1fARB( GLuint index, GLfloat x ) { if (index >= MAX_VERTEX_ATTRIBS) - index = ERROR_ATTRIB; - else + index = _TNL_ATTRIB_ERROR; + else if (index > 0) index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR1F( index, x ); } -static void GLAPIENTRY _tnl_VertexAttrib1fvARB( GLuint index, - const GLfloat *v ) +static void GLAPIENTRY _tnl_VertexAttrib1fvARB(GLuint index, const GLfloat *v) { if (index >= MAX_VERTEX_ATTRIBS) - index = ERROR_ATTRIB; - else + index = _TNL_ATTRIB_ERROR; + else if (index > 0) index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR1FV( index, v ); } @@ -441,59 +491,55 @@ static void GLAPIENTRY _tnl_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y ) { if (index >= MAX_VERTEX_ATTRIBS) - index = ERROR_ATTRIB; - else + index = _TNL_ATTRIB_ERROR; + else if (index > 0) index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR2F( index, x, y ); } -static void GLAPIENTRY _tnl_VertexAttrib2fvARB( GLuint index, - const GLfloat *v ) +static void GLAPIENTRY _tnl_VertexAttrib2fvARB(GLuint index, const GLfloat *v) { if (index >= MAX_VERTEX_ATTRIBS) - index = ERROR_ATTRIB; - else + index = _TNL_ATTRIB_ERROR; + else if (index > 0) index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR2FV( index, v ); } -static void GLAPIENTRY _tnl_VertexAttrib3fARB( GLuint index, GLfloat x, - GLfloat y, GLfloat z ) +static void GLAPIENTRY _tnl_VertexAttrib3fARB(GLuint index, GLfloat x, + GLfloat y, GLfloat z) { if (index >= MAX_VERTEX_ATTRIBS) - index = ERROR_ATTRIB; - else + index = _TNL_ATTRIB_ERROR; + else if (index > 0) index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR3F( index, x, y, z ); } -static void GLAPIENTRY _tnl_VertexAttrib3fvARB( GLuint index, - const GLfloat *v ) +static void GLAPIENTRY _tnl_VertexAttrib3fvARB(GLuint index, const GLfloat *v) { if (index >= MAX_VERTEX_ATTRIBS) - index = ERROR_ATTRIB; - else + index = _TNL_ATTRIB_ERROR; + else if (index > 0) index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR3FV( index, v ); } -static void GLAPIENTRY _tnl_VertexAttrib4fARB( GLuint index, GLfloat x, - GLfloat y, GLfloat z, - GLfloat w ) +static void GLAPIENTRY _tnl_VertexAttrib4fARB(GLuint index, GLfloat x, + GLfloat y, GLfloat z, GLfloat w) { if (index >= MAX_VERTEX_ATTRIBS) - index = ERROR_ATTRIB; - else + index = _TNL_ATTRIB_ERROR; + else if (index > 0) index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR4F( index, x, y, z, w ); } -static void GLAPIENTRY _tnl_VertexAttrib4fvARB( GLuint index, - const GLfloat *v ) +static void GLAPIENTRY _tnl_VertexAttrib4fvARB(GLuint index, const GLfloat *v) { if (index >= MAX_VERTEX_ATTRIBS) - index = ERROR_ATTRIB; - else + index = _TNL_ATTRIB_ERROR; + else if (index > 0) index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR4FV( index, v ); } |