diff options
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/api_noop.c | 53 | ||||
-rw-r--r-- | src/mesa/main/bitset.h | 194 | ||||
-rw-r--r-- | src/mesa/main/dlist.c | 48 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 44 | ||||
-rw-r--r-- | src/mesa/main/state.c | 17 | ||||
-rw-r--r-- | src/mesa/main/varray.c | 6 |
6 files changed, 232 insertions, 130 deletions
diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c index af7e1f9ac70..acb93415143 100644 --- a/src/mesa/main/api_noop.c +++ b/src/mesa/main/api_noop.c @@ -2,7 +2,7 @@ * Mesa 3-D graphics library * Version: 6.5 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 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"), @@ -391,7 +391,7 @@ void GLAPIENTRY _mesa_noop_TexCoord4fv( const GLfloat *v ) void GLAPIENTRY _mesa_noop_VertexAttrib1fNV( GLuint index, GLfloat x ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[index], x, 0, 0, 1); } else @@ -401,7 +401,7 @@ void GLAPIENTRY _mesa_noop_VertexAttrib1fNV( GLuint index, GLfloat x ) void GLAPIENTRY _mesa_noop_VertexAttrib1fvNV( GLuint index, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[index], v[0], 0, 0, 1); } else @@ -411,7 +411,7 @@ void GLAPIENTRY _mesa_noop_VertexAttrib1fvNV( GLuint index, const GLfloat *v ) void GLAPIENTRY _mesa_noop_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[index], x, y, 0, 1); } else @@ -421,7 +421,7 @@ void GLAPIENTRY _mesa_noop_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y void GLAPIENTRY _mesa_noop_VertexAttrib2fvNV( GLuint index, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], 0, 1); } else @@ -432,7 +432,7 @@ void GLAPIENTRY _mesa_noop_VertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, 1); } else @@ -442,7 +442,7 @@ void GLAPIENTRY _mesa_noop_VertexAttrib3fNV( GLuint index, GLfloat x, void GLAPIENTRY _mesa_noop_VertexAttrib3fvNV( GLuint index, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], 1); } else @@ -453,7 +453,7 @@ void GLAPIENTRY _mesa_noop_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, w); } else @@ -463,7 +463,7 @@ void GLAPIENTRY _mesa_noop_VertexAttrib4fNV( GLuint index, GLfloat x, void GLAPIENTRY _mesa_noop_VertexAttrib4fvNV( GLuint index, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], v[3]); } else @@ -471,15 +471,12 @@ void GLAPIENTRY _mesa_noop_VertexAttrib4fvNV( GLuint index, const GLfloat *v ) } -/* - * XXX Un-alias attribs here - */ void GLAPIENTRY _mesa_noop_VertexAttrib1fARB( GLuint index, GLfloat x ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { - ASSIGN_4V(ctx->Current.Attrib[index], x, 0, 0, 1); + if (index < MAX_VERTEX_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, 0, 0, 1); } else _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib1fARB" ); @@ -488,8 +485,8 @@ void GLAPIENTRY _mesa_noop_VertexAttrib1fARB( GLuint index, GLfloat x ) void GLAPIENTRY _mesa_noop_VertexAttrib1fvARB( GLuint index, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { - ASSIGN_4V(ctx->Current.Attrib[index], v[0], 0, 0, 1); + if (index < MAX_VERTEX_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], 0, 0, 1); } else _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib1fvARB" ); @@ -498,8 +495,8 @@ void GLAPIENTRY _mesa_noop_VertexAttrib1fvARB( GLuint index, const GLfloat *v ) void GLAPIENTRY _mesa_noop_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { - ASSIGN_4V(ctx->Current.Attrib[index], x, y, 0, 1); + if (index < MAX_VERTEX_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, 0, 1); } else _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib2fARB" ); @@ -508,8 +505,8 @@ void GLAPIENTRY _mesa_noop_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y void GLAPIENTRY _mesa_noop_VertexAttrib2fvARB( GLuint index, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { - ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], 0, 1); + if (index < MAX_VERTEX_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], 0, 1); } else _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib2fvARB" ); @@ -519,8 +516,8 @@ void GLAPIENTRY _mesa_noop_VertexAttrib3fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { - ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, 1); + if (index < MAX_VERTEX_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, 1); } else _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib3fARB" ); @@ -529,8 +526,8 @@ void GLAPIENTRY _mesa_noop_VertexAttrib3fARB( GLuint index, GLfloat x, void GLAPIENTRY _mesa_noop_VertexAttrib3fvARB( GLuint index, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { - ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], 1); + if (index < MAX_VERTEX_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], 1); } else _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib3fvARB" ); @@ -540,8 +537,8 @@ void GLAPIENTRY _mesa_noop_VertexAttrib4fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { - ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, w); + if (index < MAX_VERTEX_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, w); } else _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib4fARB" ); @@ -550,8 +547,8 @@ void GLAPIENTRY _mesa_noop_VertexAttrib4fARB( GLuint index, GLfloat x, void GLAPIENTRY _mesa_noop_VertexAttrib4fvARB( GLuint index, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); - if (index < VERT_ATTRIB_MAX) { - ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], v[3]); + if (index < MAX_VERTEX_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], v[3]); } else _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib4fvARB" ); diff --git a/src/mesa/main/bitset.h b/src/mesa/main/bitset.h index 1fd548bfda9..8bd4526cb6f 100644 --- a/src/mesa/main/bitset.h +++ b/src/mesa/main/bitset.h @@ -1,72 +1,122 @@ -/*
- * Mesa 3-D graphics library
- * Version: 6.5
- *
- * Copyright (C) 2006 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"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file bitset.h
- * \brief Bitset of arbitrary size definitions.
- * \author Michal Krol
- */
-
-#define BITSET_WORD GLuint
-#define BITSET_WORDBITS (sizeof (BITSET_WORD) * 8)
-
-/* bitset declarations
- */
-#define BITSET_DECLARE(name, size) \
- BITSET_WORD name[((size) + BITSET_WORDBITS - 1) / BITSET_WORDBITS]
-
-/* bitset operations
- */
-#define BITSET_COPY(x, y) _mesa_memcpy( (x), (y), sizeof (x) )
-#define BITSET_EQUAL(x, y) (_mesa_memcmp( (x), (y), sizeof (x) ) == 0)
-#define BITSET_ZERO(x) _mesa_memset( (x), 0, sizeof (x) )
-#define BITSET_ONES(x) _mesa_memset( (x), 0xff, sizeof (x) )
-
-#define BITSET_BITWORD(b) ((b) / BITSET_WORDBITS)
-#define BITSET_BIT(b) (1 << ((b) % BITSET_WORDBITS))
-
-/* single bit operations
- */
-#define BITSET_TEST(x, b) ((x)[BITSET_BITWORD(b)] & BITSET_BIT(b))
-#define BITSET_SET(x, b) ((x)[BITSET_BITWORD(b)] |= BITSET_BIT(b))
-#define BITSET_CLEAR(x, b) ((x)[BITSET_BITWORD(b)] &= ~BITSET_BIT(b))
-
-#define BITSET_MASK(b) ((b) == BITSET_WORDBITS ? ~0 : BITSET_BIT(b) - 1)
-#define BITSET_RANGE(b, e) (BITSET_MASK((e) + 1) & ~BITSET_MASK(b))
-
-/* bit range operations
- */
-#define BITSET_TEST_RANGE(x, b, e) \
- (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \
- ((x)[BITSET_BITWORD(b)] & BITSET_RANGE(b, e)) : \
- (assert (!"BITSET_TEST_RANGE: bit range crosses word boundary"), 0))
-#define BITSET_SET_RANGE(x, b, e) \
- (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \
- ((x)[BITSET_BITWORD(b)] |= BITSET_RANGE(b, e)) : \
- (assert (!"BITSET_SET_RANGE: bit range crosses word boundary"), 0))
-#define BITSET_CLEAR_RANGE(x, b, e) \
- (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \
- ((x)[BITSET_BITWORD(b)] &= ~BITSET_RANGE(b, e)) : \
- (assert (!"BITSET_CLEAR_RANGE: bit range crosses word boundary"), 0))
-
+/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * Copyright (C) 2006 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"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file bitset.h + * \brief Bitset of arbitrary size definitions. + * \author Michal Krol + */ + +/**************************************************************************** + * generic bitset implementation + */ + +#define BITSET_WORD GLuint +#define BITSET_WORDBITS (sizeof (BITSET_WORD) * 8) + +/* bitset declarations + */ +#define BITSET_DECLARE(name, size) \ + BITSET_WORD name[((size) + BITSET_WORDBITS - 1) / BITSET_WORDBITS] + +/* bitset operations + */ +#define BITSET_COPY(x, y) _mesa_memcpy( (x), (y), sizeof (x) ) +#define BITSET_EQUAL(x, y) (_mesa_memcmp( (x), (y), sizeof (x) ) == 0) +#define BITSET_ZERO(x) _mesa_memset( (x), 0, sizeof (x) ) +#define BITSET_ONES(x) _mesa_memset( (x), 0xff, sizeof (x) ) + +#define BITSET_BITWORD(b) ((b) / BITSET_WORDBITS) +#define BITSET_BIT(b) (1 << ((b) % BITSET_WORDBITS)) + +/* single bit operations + */ +#define BITSET_TEST(x, b) ((x)[BITSET_BITWORD(b)] & BITSET_BIT(b)) +#define BITSET_SET(x, b) ((x)[BITSET_BITWORD(b)] |= BITSET_BIT(b)) +#define BITSET_CLEAR(x, b) ((x)[BITSET_BITWORD(b)] &= ~BITSET_BIT(b)) + +#define BITSET_MASK(b) ((b) == BITSET_WORDBITS ? ~0 : BITSET_BIT(b) - 1) +#define BITSET_RANGE(b, e) (BITSET_MASK((e) + 1) & ~BITSET_MASK(b)) + +/* bit range operations + */ +#define BITSET_TEST_RANGE(x, b, e) \ + (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ + ((x)[BITSET_BITWORD(b)] & BITSET_RANGE(b, e)) : \ + (assert (!"BITSET_TEST_RANGE: bit range crosses word boundary"), 0)) +#define BITSET_SET_RANGE(x, b, e) \ + (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ + ((x)[BITSET_BITWORD(b)] |= BITSET_RANGE(b, e)) : \ + (assert (!"BITSET_SET_RANGE: bit range crosses word boundary"), 0)) +#define BITSET_CLEAR_RANGE(x, b, e) \ + (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ + ((x)[BITSET_BITWORD(b)] &= ~BITSET_RANGE(b, e)) : \ + (assert (!"BITSET_CLEAR_RANGE: bit range crosses word boundary"), 0)) + +/**************************************************************************** + * 64-bit bitset implementation + */ + +#define BITSET64_WORD GLuint +#define BITSET64_WORDBITS (sizeof (BITSET64_WORD) * 8) + +/* bitset declarations + */ +#define BITSET64_DECLARE(name, size) \ + GLuint name[2] + +/* bitset operations + */ +#define BITSET64_COPY(x, y) do { (x)[0] = (y)[0]; (x)[1] = (y)[1]; } while (0) +#define BITSET64_EQUAL(x, y) ( (x)[0] == (y)[0] && (x)[1] == (y)[1] ) +#define BITSET64_ZERO(x) do { (x)[0] = 0; (x)[1] = 0; } while (0) +#define BITSET64_ONES(x) do { (x)[0] = 0xFF; (x)[1] = 0xFF; } while (0) + +#define BITSET64_BITWORD(b) ((b) / BITSET64_WORDBITS) +#define BITSET64_BIT(b) (1 << ((b) % BITSET64_WORDBITS)) + +/* single bit operations + */ +#define BITSET64_TEST(x, b) ((x)[BITSET64_BITWORD(b)] & BITSET64_BIT(b)) +#define BITSET64_SET(x, b) ((x)[BITSET64_BITWORD(b)] |= BITSET64_BIT(b)) +#define BITSET64_CLEAR(x, b) ((x)[BITSET64_BITWORD(b)] &= ~BITSET64_BIT(b)) + +#define BITSET64_MASK(b) ((b) == BITSET64_WORDBITS ? ~0 : BITSET64_BIT(b) - 1) +#define BITSET64_RANGE(b, e) (BITSET64_MASK((e) + 1) & ~BITSET64_MASK(b)) + +/* bit range operations + */ +#define BITSET64_TEST_RANGE(x, b, e) \ + (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ + ((x)[BITSET64_BITWORD(b)] & BITSET64_RANGE(b, e)) : \ + (assert (!"BITSET64_TEST_RANGE: bit range crosses word boundary"), 0)) +#define BITSET64_SET_RANGE(x, b, e) \ + (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ + ((x)[BITSET64_BITWORD(b)] |= BITSET64_RANGE(b, e)) : \ + (assert (!"BITSET64_SET_RANGE: bit range crosses word boundary"), 0)) +#define BITSET64_CLEAR_RANGE(x, b, e) \ + (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ + ((x)[BITSET64_BITWORD(b)] &= ~BITSET64_RANGE(b, e)) : \ + (assert (!"BITSET64_CLEAR_RANGE: bit range crosses word boundary"), 0)) + diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index dba2008ef73..4fe1bfddcc9 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -4777,7 +4777,7 @@ save_Attr1fNV(GLenum attr, GLfloat x) n[2].f = x; } - ASSERT(attr < VERT_ATTRIB_MAX); + ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 1; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); @@ -4799,7 +4799,7 @@ save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y) n[3].f = y; } - ASSERT(attr < VERT_ATTRIB_MAX); + ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 2; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); @@ -4822,7 +4822,7 @@ save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z) n[4].f = z; } - ASSERT(attr < VERT_ATTRIB_MAX); + ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 3; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); @@ -4846,7 +4846,7 @@ save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) n[5].f = w; } - ASSERT(attr < VERT_ATTRIB_MAX); + ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 4; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); @@ -4868,7 +4868,7 @@ save_Attr1fARB(GLenum attr, GLfloat x) n[2].f = x; } - ASSERT(attr < VERT_ATTRIB_MAX); + ASSERT(attr < MAX_VERTEX_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 1; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); @@ -4890,7 +4890,7 @@ save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y) n[3].f = y; } - ASSERT(attr < VERT_ATTRIB_MAX); + ASSERT(attr < MAX_VERTEX_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 2; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); @@ -4913,7 +4913,7 @@ save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z) n[4].f = z; } - ASSERT(attr < VERT_ATTRIB_MAX); + ASSERT(attr < MAX_VERTEX_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 3; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); @@ -4937,7 +4937,7 @@ save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) n[5].f = w; } - ASSERT(attr < VERT_ATTRIB_MAX); + ASSERT(attr < MAX_VERTEX_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 4; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); @@ -5432,7 +5432,7 @@ index_error(void) static void GLAPIENTRY save_VertexAttrib1fNV(GLuint index, GLfloat x) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) save_Attr1fNV(index, x); else index_error(); @@ -5441,7 +5441,7 @@ save_VertexAttrib1fNV(GLuint index, GLfloat x) static void GLAPIENTRY save_VertexAttrib1fvNV(GLuint index, const GLfloat * v) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) save_Attr1fNV(index, v[0]); else index_error(); @@ -5450,7 +5450,7 @@ save_VertexAttrib1fvNV(GLuint index, const GLfloat * v) static void GLAPIENTRY save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) save_Attr2fNV(index, x, y); else index_error(); @@ -5459,7 +5459,7 @@ save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) static void GLAPIENTRY save_VertexAttrib2fvNV(GLuint index, const GLfloat * v) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) save_Attr2fNV(index, v[0], v[1]); else index_error(); @@ -5468,7 +5468,7 @@ save_VertexAttrib2fvNV(GLuint index, const GLfloat * v) static void GLAPIENTRY save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) save_Attr3fNV(index, x, y, z); else index_error(); @@ -5477,7 +5477,7 @@ save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) static void GLAPIENTRY save_VertexAttrib3fvNV(GLuint index, const GLfloat * v) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) save_Attr3fNV(index, v[0], v[1], v[2]); else index_error(); @@ -5487,7 +5487,7 @@ static void GLAPIENTRY save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) save_Attr4fNV(index, x, y, z, w); else index_error(); @@ -5496,7 +5496,7 @@ save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, static void GLAPIENTRY save_VertexAttrib4fvNV(GLuint index, const GLfloat * v) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) save_Attr4fNV(index, v[0], v[1], v[2], v[3]); else index_error(); @@ -5508,7 +5508,7 @@ save_VertexAttrib4fvNV(GLuint index, const GLfloat * v) static void GLAPIENTRY save_VertexAttrib1fARB(GLuint index, GLfloat x) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_ATTRIBS) save_Attr1fARB(index, x); else index_error(); @@ -5517,7 +5517,7 @@ save_VertexAttrib1fARB(GLuint index, GLfloat x) static void GLAPIENTRY save_VertexAttrib1fvARB(GLuint index, const GLfloat * v) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_ATTRIBS) save_Attr1fARB(index, v[0]); else index_error(); @@ -5526,7 +5526,7 @@ save_VertexAttrib1fvARB(GLuint index, const GLfloat * v) static void GLAPIENTRY save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_ATTRIBS) save_Attr2fARB(index, x, y); else index_error(); @@ -5535,7 +5535,7 @@ save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) static void GLAPIENTRY save_VertexAttrib2fvARB(GLuint index, const GLfloat * v) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_ATTRIBS) save_Attr2fARB(index, v[0], v[1]); else index_error(); @@ -5544,7 +5544,7 @@ save_VertexAttrib2fvARB(GLuint index, const GLfloat * v) static void GLAPIENTRY save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_ATTRIBS) save_Attr3fARB(index, x, y, z); else index_error(); @@ -5553,7 +5553,7 @@ save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) static void GLAPIENTRY save_VertexAttrib3fvARB(GLuint index, const GLfloat * v) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_ATTRIBS) save_Attr3fARB(index, v[0], v[1], v[2]); else index_error(); @@ -5563,7 +5563,7 @@ static void GLAPIENTRY save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_ATTRIBS) save_Attr4fARB(index, x, y, z, w); else index_error(); @@ -5572,7 +5572,7 @@ save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, static void GLAPIENTRY save_VertexAttrib4fvARB(GLuint index, const GLfloat * v) { - if (index < VERT_ATTRIB_MAX) + if (index < MAX_VERTEX_ATTRIBS) save_Attr4fARB(index, v[0], v[1], v[2], v[3]); else index_error(); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 7876cff2ed5..c443411b629 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -41,6 +41,7 @@ #include "glapitable.h" #include "glthread.h" #include "math/m_matrix.h" /* GLmatrix */ +#include "bitset.h" /** @@ -155,7 +156,19 @@ enum VERT_ATTRIB_GENERIC1 = 17, VERT_ATTRIB_GENERIC2 = 18, VERT_ATTRIB_GENERIC3 = 19, - VERT_ATTRIB_MAX = 16 /* XXX not counting generic attribs yet */ + VERT_ATTRIB_GENERIC4 = 20, + VERT_ATTRIB_GENERIC5 = 21, + VERT_ATTRIB_GENERIC6 = 22, + VERT_ATTRIB_GENERIC7 = 23, + VERT_ATTRIB_GENERIC8 = 24, + VERT_ATTRIB_GENERIC9 = 25, + VERT_ATTRIB_GENERIC10 = 26, + VERT_ATTRIB_GENERIC11 = 27, + VERT_ATTRIB_GENERIC12 = 28, + VERT_ATTRIB_GENERIC13 = 29, + VERT_ATTRIB_GENERIC14 = 30, + VERT_ATTRIB_GENERIC15 = 31, + VERT_ATTRIB_MAX = 32 }; /** @@ -183,12 +196,41 @@ enum #define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1) #define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2) #define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3) +#define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4) +#define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5) +#define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6) +#define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7) +#define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8) +#define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9) +#define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10) +#define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11) +#define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12) +#define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13) +#define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14) +#define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15) #define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u))) #define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g))) /*@}*/ /** + * GLSL allows shader writers to allocate vertex result attributes (varyings) in + * single float component granularity. This is in contrast to vertex / fragment + * programs, where result attributes (actually texcoords) were allocated + * in 4-component vectors of floats granularity. + * For performance reasons, it would be optimal to stick with this scheme on a scalar + * processor. Varyings will likely be allocated as 3-component vectors, so statistically + * we win 2 floats. + * The constant VARYINGS_PER_VECTOR tells us how much of float components we pack into + * one result vector. For scalar processor it would be 1, for vector processor - 4. + * + * NOTE: Currently we pack varyings into vertex attributes. + */ +#define VARYINGS_PER_VECTOR 2 +#define VARYING_EMIT_STYLE EMIT_2F +#define MAX_VARYING_VECTORS ((MAX_VARYING_FLOATS + VARYINGS_PER_VECTOR - 1) / VARYINGS_PER_VECTOR) + +/** * Indexes for vertex program result attributes */ /*@{*/ diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 7e452bdfd7f..761a45f2bd8 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -820,7 +820,11 @@ update_arrays( GLcontext *ctx ) /* find min of _MaxElement values for all enabled arrays */ /* 0 */ - if (ctx->VertexProgram._Enabled + if (ctx->ShaderObjects._VertexShaderPresent + && ctx->Array.VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) { + min = ctx->Array.VertexAttrib[VERT_ATTRIB_GENERIC0]._MaxElement; + } + else if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Enabled) { min = ctx->Array.VertexAttrib[VERT_ATTRIB_POS]._MaxElement; } @@ -888,7 +892,7 @@ update_arrays( GLcontext *ctx ) } /* 8..15 */ - for (i = VERT_ATTRIB_TEX0; i < VERT_ATTRIB_MAX; i++) { + for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++) { if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[i].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[i]._MaxElement); @@ -899,6 +903,15 @@ update_arrays( GLcontext *ctx ) } } + /* 16..31 */ + if (ctx->ShaderObjects._VertexShaderPresent) { + for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) { + if (ctx->Array.VertexAttrib[i].Enabled) { + min = MIN2(min, ctx->Array.VertexAttrib[i]._MaxElement); + } + } + } + if (ctx->Array.Index.Enabled) { min = MIN2(min, ctx->Array.Index._MaxElement); } diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index cf64fb23df7..9f8dc766c9d 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 6.5 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 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"), @@ -441,7 +441,7 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - if (index >= VERT_ATTRIB_MAX) { + if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) { _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)"); return; } |