summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2004-03-15 14:36:16 +0000
committerKeith Whitwell <[email protected]>2004-03-15 14:36:16 +0000
commit5262dcccc87caf8083cb7867155d91ac2f38ffef (patch)
treef82651b87f85663f92b154b5bf9fd2dbbc4a4a7f
parentd83e9d9c00e0e89051bc756d58c6e227fd35f9f7 (diff)
Streamline the error path in VertexAttrib functions. Makes things
slightly easier for codegen.
-rw-r--r--src/mesa/tnl/t_context.h4
-rw-r--r--src/mesa/tnl/t_vtx_api.c130
2 files changed, 79 insertions, 55 deletions
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index 0911101c753..1293db3bf3f 100644
--- a/src/mesa/tnl/t_context.h
+++ b/src/mesa/tnl/t_context.h
@@ -248,6 +248,8 @@ struct tnl_copied_vtx {
#define VERT_BUFFER_SIZE 2048 /* 8kbytes */
+#define ERROR_ATTRIB _TNL_ATTRIB_MAX /* error path for t_vtx_api.c */
+
typedef void (*attrfv_func)( const GLfloat * );
/* The assembly of vertices in immediate mode is separated from
@@ -267,7 +269,7 @@ struct tnl_vtx {
GLfloat *current[_TNL_ATTRIB_MAX]; /* points into ctx->Current, etc */
GLuint counter, initial_counter;
struct tnl_copied_vtx copied;
- attrfv_func tabfv[_TNL_ATTRIB_MAX][4];
+ attrfv_func tabfv[_TNL_ATTRIB_MAX+1][4]; /* +1 for ERROR_ATTRIB */
struct tnl_eval eval;
GLboolean *edgeflag_tmp;
GLboolean have_materials;
diff --git a/src/mesa/tnl/t_vtx_api.c b/src/mesa/tnl/t_vtx_api.c
index a9a1c5bd5f8..4f07e2cc7e2 100644
--- a/src/mesa/tnl/t_vtx_api.c
+++ b/src/mesa/tnl/t_vtx_api.c
@@ -97,6 +97,9 @@ static void _tnl_wrap_buffers( GLcontext *ctx )
}
+/* Deal with buffer wrapping where provoked by the vertex buffer
+ * filling up, as opposed to upgrade_vertex().
+ */
static void _tnl_wrap_filled_vertex( GLcontext *ctx )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -451,6 +454,24 @@ ATTRS( 13 )
ATTRS( 14 )
ATTRS( 15 )
+
+static void error_attrib( const GLfloat *unused )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ (void) unused;
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib" );
+}
+
+static void init_error_attrib( TNLcontext *tnl )
+{
+ tnl->vtx.tabfv[ERROR_ATTRIB][0] = error_attrib;
+ tnl->vtx.tabfv[ERROR_ATTRIB][1] = error_attrib;
+ tnl->vtx.tabfv[ERROR_ATTRIB][2] = error_attrib;
+ tnl->vtx.tabfv[ERROR_ATTRIB][3] = error_attrib;
+}
+
+
+
static void init_attrfv( TNLcontext *tnl )
{
if (tnl->vtx.vertex_size) {
@@ -472,6 +493,7 @@ static void init_attrfv( TNLcontext *tnl )
init_13( tnl );
init_14( tnl );
init_15( tnl );
+ init_error_attrib( tnl );
for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++)
tnl->vtx.attrsz[i] = 0;
@@ -545,7 +567,8 @@ static void GLAPIENTRY _tnl_Vertex3fv( const GLfloat *v )
DISPATCH_ATTR3FV( _TNL_ATTRIB_POS, v );
}
-static void GLAPIENTRY _tnl_Vertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+static void GLAPIENTRY _tnl_Vertex4f( GLfloat x, GLfloat y, GLfloat z,
+ GLfloat w )
{
DISPATCH_ATTR4F( _TNL_ATTRIB_POS, x, y, z, w );
}
@@ -585,7 +608,8 @@ static void GLAPIENTRY _tnl_TexCoord3fv( const GLfloat *v )
DISPATCH_ATTR3FV( _TNL_ATTRIB_TEX0, v );
}
-static void GLAPIENTRY _tnl_TexCoord4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+static void GLAPIENTRY _tnl_TexCoord4f( GLfloat x, GLfloat y, GLfloat z,
+ GLfloat w )
{
DISPATCH_ATTR4F( _TNL_ATTRIB_TEX0, x, y, z, w );
}
@@ -625,7 +649,8 @@ static void GLAPIENTRY _tnl_Color3fv( const GLfloat *v )
DISPATCH_ATTR3FV( _TNL_ATTRIB_COLOR0, v );
}
-static void GLAPIENTRY _tnl_Color4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+static void GLAPIENTRY _tnl_Color4f( GLfloat x, GLfloat y, GLfloat z,
+ GLfloat w )
{
DISPATCH_ATTR4F( _TNL_ATTRIB_COLOR0, x, y, z, w );
}
@@ -635,7 +660,8 @@ static void GLAPIENTRY _tnl_Color4fv( const GLfloat *v )
DISPATCH_ATTR4FV( _TNL_ATTRIB_COLOR0, v );
}
-static void GLAPIENTRY _tnl_SecondaryColor3fEXT( GLfloat x, GLfloat y, GLfloat z )
+static void GLAPIENTRY _tnl_SecondaryColor3fEXT( GLfloat x, GLfloat y,
+ GLfloat z )
{
DISPATCH_ATTR3F( _TNL_ATTRIB_COLOR1, x, y, z );
}
@@ -651,45 +677,51 @@ 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 );
}
-static void GLAPIENTRY _tnl_MultiTexCoord3f( GLenum target, GLfloat x, GLfloat y,
- GLfloat z)
+static void GLAPIENTRY _tnl_MultiTexCoord3f( GLenum target, GLfloat x,
+ GLfloat y, GLfloat z)
{
GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
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 );
}
-static void GLAPIENTRY _tnl_MultiTexCoord4f( GLenum target, GLfloat x, GLfloat y,
- GLfloat z, GLfloat w )
+static void GLAPIENTRY _tnl_MultiTexCoord4f( GLenum target, GLfloat x,
+ GLfloat y, GLfloat z,
+ GLfloat w )
{
GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
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 );
@@ -697,68 +729,58 @@ static void GLAPIENTRY _tnl_MultiTexCoord4fv( GLenum target, const GLfloat *v )
static void GLAPIENTRY _tnl_VertexAttrib1fNV( GLuint index, GLfloat x )
{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR1F( index, x );
- else
- enum_error();
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ 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 < VERT_ATTRIB_MAX)
- DISPATCH_ATTR1FV( index, v );
- else
- enum_error();
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ 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 < VERT_ATTRIB_MAX)
- DISPATCH_ATTR2F( index, x, y );
- else
- enum_error();
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ 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 < VERT_ATTRIB_MAX)
- DISPATCH_ATTR2FV( index, v );
- else
- enum_error();
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR2FV( index, v );
}
-static void GLAPIENTRY _tnl_VertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y,
- GLfloat z )
+static void GLAPIENTRY _tnl_VertexAttrib3fNV( GLuint index, GLfloat x,
+ GLfloat y, GLfloat z )
{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR3F( index, x, y, z );
- else
- enum_error();
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ 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 < VERT_ATTRIB_MAX)
- DISPATCH_ATTR3FV( index, v );
- else
- enum_error();
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR3FV( index, v );
}
-static void GLAPIENTRY _tnl_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y,
- GLfloat z, GLfloat w )
+static void GLAPIENTRY _tnl_VertexAttrib4fNV( GLuint index, GLfloat x,
+ GLfloat y, GLfloat z,
+ GLfloat w )
{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR4F( index, x, y, z, w );
- else
- enum_error();
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ 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 < VERT_ATTRIB_MAX)
- DISPATCH_ATTR4FV( index, v );
- else
- enum_error();
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR4FV( index, v );
}