Header file clean-up:
[mesa.git] / src / mesa / tnl / t_imm_elt.c
index ec79c7e52be9a61e2f1068235c1bb43897026215..f435dc9db03f03c4db969d12e5f83506947edd5e 100644 (file)
@@ -1,10 +1,10 @@
-/* $Id: t_imm_elt.c,v 1.2 2001/01/02 22:02:53 brianp Exp $ */
+/* $Id: t_imm_elt.c,v 1.19 2002/10/24 23:57:25 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  4.1
  *
- * Copyright (C) 1999  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"),
  * 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.
  *
- * Author:
+ * Authors:
  *    Keith Whitwell <keithw@valinux.com>
  */
 
 #include "glheader.h"
 #include "colormac.h"
-#include "mem.h"
+#include "context.h"
+#include "imports.h"
 #include "mmath.h"
 #include "mtypes.h"
 
@@ -68,13 +69,22 @@ typedef void (*trans_elt_1ub_func)(GLubyte *to,
                                   GLuint n );
 
 typedef void (*trans_elt_4ub_func)(GLubyte (*to)[4],
-                                  CONST void *ptr,
-                                  GLuint stride,
-                                  GLuint *flags,
-                                  GLuint *elts,
-                                  GLuint match,
-                                  GLuint start,
-                                  GLuint n );
+                                   CONST void *ptr,
+                                   GLuint stride,
+                                   GLuint *flags,
+                                   GLuint *elts,
+                                   GLuint match,
+                                   GLuint start,
+                                   GLuint n );
+
+typedef void (*trans_elt_4us_func)(GLushort (*to)[4],
+                                   CONST void *ptr,
+                                   GLuint stride,
+                                   GLuint *flags,
+                                   GLuint *elts,
+                                   GLuint match,
+                                   GLuint start,
+                                   GLuint n );
 
 typedef void (*trans_elt_4f_func)(GLfloat (*to)[4],
                                  CONST void *ptr,
@@ -102,6 +112,7 @@ static trans_elt_1ui_func _tnl_trans_elt_1ui_tab[MAX_TYPES];
 static trans_elt_1ub_func _tnl_trans_elt_1ub_tab[MAX_TYPES];
 static trans_elt_3f_func  _tnl_trans_elt_3f_tab[MAX_TYPES];
 static trans_elt_4ub_func _tnl_trans_elt_4ub_tab[5][MAX_TYPES];
+static trans_elt_4us_func _tnl_trans_elt_4us_tab[5][MAX_TYPES];
 static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 
 
@@ -128,8 +139,7 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
                GLuint start, GLuint n
 #define SRC_START  0
 #define DST_START  start
-#undef CHECK
-#define CHECK  if ((flags[i]&match) == VERT_ELT)
+#define CHECK  if ((flags[i]&match) == VERT_BIT_ELT)
 #define NEXT_F  (void)1
 #define NEXT_F2 f = first + elts[i] * stride;
 
@@ -139,8 +149,9 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #define SRC GLbyte
 #define SRC_IDX TYPE_IDX(GL_BYTE)
 #define TRX_3F(f,n)   BYTE_TO_FLOAT( PTR_ELT(f,n) )
-#define TRX_4F(f,n)   (GLfloat)( PTR_ELT(f,n) )
+#define TRX_4F(f,n)   BYTE_TO_FLOAT( PTR_ELT(f,n) )
 #define TRX_UB(ub, f,n)  ub = BYTE_TO_UBYTE( PTR_ELT(f,n) )
+#define TRX_US(us, f,n)  us = BYTE_TO_USHORT( PTR_ELT(f,n) )
 #define TRX_UI(f,n)  (PTR_ELT(f,n) < 0 ? 0 : (GLuint)  PTR_ELT(f,n))
 
 
@@ -148,12 +159,14 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #define INIT init_trans_4_GLbyte_elt
 #define DEST_4F trans_4_GLbyte_4f_elt
 #define DEST_4UB trans_4_GLbyte_4ub_elt
+#define DEST_4US trans_4_GLbyte_4us_elt
 #include "math/m_trans_tmp.h"
 
 #define SZ 3
 #define INIT init_trans_3_GLbyte_elt
 #define DEST_4F trans_3_GLbyte_4f_elt
 #define DEST_4UB trans_3_GLbyte_4ub_elt
+#define DEST_4US trans_3_GLbyte_4us_elt
 #define DEST_3F trans_3_GLbyte_3f_elt
 #include "math/m_trans_tmp.h"
 
@@ -173,6 +186,7 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #undef TRX_3F
 #undef TRX_4F
 #undef TRX_UB
+#undef TRX_US
 #undef TRX_UI
 #undef SRC_IDX
 
@@ -180,17 +194,26 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
  */
 #define SRC GLubyte
 #define SRC_IDX TYPE_IDX(GL_UNSIGNED_BYTE)
-#define TRX_3F(f,n)            /* unused */
-#define TRX_4F(f,n)            /* unused */
+#define TRX_3F(f,n)         UBYTE_TO_FLOAT( PTR_ELT(f,n) )
+#define TRX_4F(f,n)         UBYTE_TO_FLOAT( PTR_ELT(f,n) )
 #define TRX_UB(ub, f,n)             ub = PTR_ELT(f,n)
+#define TRX_US(us, f,n)             us = PTR_ELT(f,n)
 #define TRX_UI(f,n)          (GLuint)PTR_ELT(f,n)
 
 /* 4ub->4ub handled in special case below.
  */
+#define SZ 4
+#define INIT init_trans_4_GLubyte_elt
+#define DEST_4F trans_4_GLubyte_4f_elt
+#define DEST_4US trans_4_GLubyte_4us_elt
+#include "math/m_trans_tmp.h"
 
 #define SZ 3
 #define INIT init_trans_3_GLubyte_elt
+#define DEST_4F trans_3_GLubyte_4f_elt
+#define DEST_3F trans_3_GLubyte_3f_elt
 #define DEST_4UB trans_3_GLubyte_4ub_elt
+#define DEST_4US trans_3_GLubyte_4us_elt
 #include "math/m_trans_tmp.h"
 
 
@@ -205,6 +228,7 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #undef TRX_3F
 #undef TRX_4F
 #undef TRX_UB
+#undef TRX_US
 #undef TRX_UI
 
 
@@ -215,6 +239,7 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #define TRX_3F(f,n)   SHORT_TO_FLOAT( PTR_ELT(f,n) )
 #define TRX_4F(f,n)   (GLfloat)( PTR_ELT(f,n) )
 #define TRX_UB(ub, f,n)  ub = SHORT_TO_UBYTE(PTR_ELT(f,n))
+#define TRX_US(us, f,n)  us = SHORT_TO_USHORT(PTR_ELT(f,n))
 #define TRX_UI(f,n)  (PTR_ELT(f,n) < 0 ? 0 : (GLuint)  PTR_ELT(f,n))
 
 
@@ -222,12 +247,14 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #define INIT init_trans_4_GLshort_elt
 #define DEST_4F trans_4_GLshort_4f_elt
 #define DEST_4UB trans_4_GLshort_4ub_elt
+#define DEST_4US trans_4_GLshort_4us_elt
 #include "math/m_trans_tmp.h"
 
 #define SZ 3
 #define INIT init_trans_3_GLshort_elt
 #define DEST_4F trans_3_GLshort_4f_elt
 #define DEST_4UB trans_3_GLshort_4ub_elt
+#define DEST_4US trans_3_GLshort_4us_elt
 #define DEST_3F trans_3_GLshort_3f_elt
 #include "math/m_trans_tmp.h"
 
@@ -249,6 +276,7 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #undef TRX_3F
 #undef TRX_4F
 #undef TRX_UB
+#undef TRX_US
 #undef TRX_UI
 
 
@@ -259,6 +287,7 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #define TRX_3F(f,n)   USHORT_TO_FLOAT( PTR_ELT(f,n) )
 #define TRX_4F(f,n)   (GLfloat)( PTR_ELT(f,n) )
 #define TRX_UB(ub,f,n)  ub = (GLubyte) (PTR_ELT(f,n) >> 8)
+#define TRX_US(us,f,n)  us = PTR_ELT(f,n)
 #define TRX_UI(f,n)  (GLuint)   PTR_ELT(f,n)
 
 
@@ -266,12 +295,14 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #define INIT init_trans_4_GLushort_elt
 #define DEST_4F trans_4_GLushort_4f_elt
 #define DEST_4UB trans_4_GLushort_4ub_elt
+#define DEST_4US trans_4_GLushort_4us_elt
 #include "math/m_trans_tmp.h"
 
 #define SZ 3
 #define INIT init_trans_3_GLushort_elt
 #define DEST_4F trans_3_GLushort_4f_elt
 #define DEST_4UB trans_3_GLushort_4ub_elt
+#define DEST_4US trans_3_GLushort_4us_elt
 #define DEST_3F trans_3_GLushort_3f_elt
 #include "math/m_trans_tmp.h"
 
@@ -292,6 +323,7 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #undef TRX_3F
 #undef TRX_4F
 #undef TRX_UB
+#undef TRX_US
 #undef TRX_UI
 
 
@@ -302,6 +334,7 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #define TRX_3F(f,n)   INT_TO_FLOAT( PTR_ELT(f,n) )
 #define TRX_4F(f,n)   (GLfloat)( PTR_ELT(f,n) )
 #define TRX_UB(ub, f,n)  ub = INT_TO_UBYTE(PTR_ELT(f,n))
+#define TRX_US(us, f,n)  us = INT_TO_USHORT(PTR_ELT(f,n))
 #define TRX_UI(f,n)  (PTR_ELT(f,n) < 0 ? 0 : (GLuint)  PTR_ELT(f,n))
 
 
@@ -309,12 +342,14 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #define INIT init_trans_4_GLint_elt
 #define DEST_4F trans_4_GLint_4f_elt
 #define DEST_4UB trans_4_GLint_4ub_elt
+#define DEST_4US trans_4_GLint_4us_elt
 #include "math/m_trans_tmp.h"
 
 #define SZ 3
 #define INIT init_trans_3_GLint_elt
 #define DEST_4F trans_3_GLint_4f_elt
 #define DEST_4UB trans_3_GLint_4ub_elt
+#define DEST_4US trans_3_GLint_4us_elt
 #define DEST_3F trans_3_GLint_3f_elt
 #include "math/m_trans_tmp.h"
 
@@ -336,6 +371,7 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #undef TRX_3F
 #undef TRX_4F
 #undef TRX_UB
+#undef TRX_US
 #undef TRX_UI
 
 
@@ -346,6 +382,7 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #define TRX_3F(f,n)   UINT_TO_FLOAT( PTR_ELT(f,n) )
 #define TRX_4F(f,n)   (GLfloat)( PTR_ELT(f,n) )
 #define TRX_UB(ub, f,n)  ub = (GLubyte) (PTR_ELT(f,n) >> 24)
+#define TRX_US(us, f,n)  us = (GLushort) (PTR_ELT(f,n) >> 16)
 #define TRX_UI(f,n)            PTR_ELT(f,n)
 
 
@@ -353,12 +390,14 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #define INIT init_trans_4_GLuint_elt
 #define DEST_4F trans_4_GLuint_4f_elt
 #define DEST_4UB trans_4_GLuint_4ub_elt
+#define DEST_4US trans_4_GLuint_4us_elt
 #include "math/m_trans_tmp.h"
 
 #define SZ 3
 #define INIT init_trans_3_GLuint_elt
 #define DEST_4F trans_3_GLuint_4f_elt
 #define DEST_4UB trans_3_GLuint_4ub_elt
+#define DEST_4US trans_3_GLuint_4us_elt
 #define DEST_3F trans_3_GLuint_3f_elt
 #include "math/m_trans_tmp.h"
 
@@ -379,6 +418,7 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #undef TRX_3F
 #undef TRX_4F
 #undef TRX_UB
+#undef TRX_US
 #undef TRX_UI
 
 
@@ -386,23 +426,26 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
  */
 #define SRC GLdouble
 #define SRC_IDX TYPE_IDX(GL_DOUBLE)
-#define TRX_3F(f,n)   PTR_ELT(f,n)
-#define TRX_4F(f,n)   PTR_ELT(f,n)
-#define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_CHAN(ub, PTR_ELT(f,n))
-#define TRX_UI(f,n)  (GLuint) (GLint) PTR_ELT(f,n)
-#define TRX_1F(f,n)   PTR_ELT(f,n)
+#define TRX_3F(f,n)    (GLfloat) PTR_ELT(f,n)
+#define TRX_4F(f,n)    (GLfloat) PTR_ELT(f,n)
+#define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_UBYTE(ub, PTR_ELT(f,n))
+#define TRX_US(us,f,n) UNCLAMPED_FLOAT_TO_USHORT(us, PTR_ELT(f,n))
+#define TRX_UI(f,n)    (GLuint) (GLint) PTR_ELT(f,n)
+#define TRX_1F(f,n)    (GLfloat) PTR_ELT(f,n)
 
 
 #define SZ 4
 #define INIT init_trans_4_GLdouble_elt
 #define DEST_4F trans_4_GLdouble_4f_elt
 #define DEST_4UB trans_4_GLdouble_4ub_elt
+#define DEST_4US trans_4_GLdouble_4us_elt
 #include "math/m_trans_tmp.h"
 
 #define SZ 3
 #define INIT init_trans_3_GLdouble_elt
 #define DEST_4F trans_3_GLdouble_4f_elt
 #define DEST_4UB trans_3_GLdouble_4ub_elt
+#define DEST_4US trans_3_GLdouble_4us_elt
 #define DEST_3F trans_3_GLdouble_3f_elt
 #include "math/m_trans_tmp.h"
 
@@ -429,6 +472,7 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #define SZ 4
 #define INIT init_trans_4_GLfloat_elt
 #define DEST_4UB trans_4_GLfloat_4ub_elt
+#define DEST_4US trans_4_GLfloat_4us_elt
 #define DEST_4F  trans_4_GLfloat_4f_elt
 #include "math/m_trans_tmp.h"
 
@@ -436,6 +480,7 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #define INIT init_trans_3_GLfloat_elt
 #define DEST_4F  trans_3_GLfloat_4f_elt
 #define DEST_4UB trans_3_GLfloat_4ub_elt
+#define DEST_4US trans_3_GLfloat_4us_elt
 #define DEST_3F trans_3_GLfloat_3f_elt
 #include "math/m_trans_tmp.h"
 
@@ -457,13 +502,14 @@ static trans_elt_4f_func  _tnl_trans_elt_4f_tab[5][MAX_TYPES];
 #undef TRX_3F
 #undef TRX_4F
 #undef TRX_UB
+#undef TRX_US
 #undef TRX_UI
 
 
 static void trans_4_GLubyte_4ub(GLubyte (*t)[4],
-                               CONST void *Ptr,
-                               GLuint stride,
-                               ARGS )
+                                CONST void *Ptr,
+                                GLuint stride,
+                                ARGS )
 {
    const GLubyte *f = (GLubyte *) Ptr + SRC_START * stride;
    const GLubyte *first = f;
@@ -498,6 +544,7 @@ static void init_translate_elt(void)
    MEMSET( TAB(_1ub), 0, sizeof(TAB(_1ub)) );
    MEMSET( TAB(_3f),  0, sizeof(TAB(_3f)) );
    MEMSET( TAB(_4ub), 0, sizeof(TAB(_4ub)) );
+   MEMSET( TAB(_4us), 0, sizeof(TAB(_4us)) );
    MEMSET( TAB(_4f),  0, sizeof(TAB(_4f)) );
 
    TAB(_4ub)[4][TYPE_IDX(GL_UNSIGNED_BYTE)] = trans_4_GLubyte_4ub;
@@ -508,6 +555,7 @@ static void init_translate_elt(void)
    init_trans_1_GLbyte_elt();
    init_trans_1_GLubyte_elt();
    init_trans_3_GLubyte_elt();
+   init_trans_4_GLubyte_elt();
    init_trans_4_GLshort_elt();
    init_trans_3_GLshort_elt();
    init_trans_2_GLshort_elt();
@@ -550,6 +598,7 @@ void _tnl_imm_elt_init( void )
 }
 
 
+#if 00
 static void _tnl_trans_elt_1f(GLfloat *to,
                       const struct gl_client_array *from,
                       GLuint *flags,
@@ -558,7 +607,7 @@ static void _tnl_trans_elt_1f(GLfloat *to,
                       GLuint start,
                       GLuint n )
 {
-   _tnl_trans_elt_1f_tab[TYPE_IDX(from->Type)]( to, 
+   _tnl_trans_elt_1f_tab[TYPE_IDX(from->Type)]( to,
                                              from->Ptr,
                                              from->StrideB,
                                              flags,
@@ -566,8 +615,9 @@ static void _tnl_trans_elt_1f(GLfloat *to,
                                              match,
                                              start,
                                              n );
-                                       
+
 }
+#endif
 
 static void _tnl_trans_elt_1ui(GLuint *to,
                        const struct gl_client_array *from,
@@ -577,7 +627,7 @@ static void _tnl_trans_elt_1ui(GLuint *to,
                        GLuint start,
                        GLuint n )
 {
-   _tnl_trans_elt_1ui_tab[TYPE_IDX(from->Type)]( to, 
+   _tnl_trans_elt_1ui_tab[TYPE_IDX(from->Type)]( to,
                                               from->Ptr,
                                               from->StrideB,
                                               flags,
@@ -585,7 +635,7 @@ static void _tnl_trans_elt_1ui(GLuint *to,
                                               match,
                                               start,
                                               n );
-                                       
+
 }
 
 
@@ -597,46 +647,69 @@ static void _tnl_trans_elt_1ub(GLubyte *to,
                        GLuint start,
                        GLuint n )
 {
-   _tnl_trans_elt_1ub_tab[TYPE_IDX(from->Type)]( to, 
-                                             from->Ptr,
-                                             from->StrideB,
-                                             flags,
-                                             elts,
-                                             match,
-                                             start,
-                                             n );
-                                       
+   _tnl_trans_elt_1ub_tab[TYPE_IDX(from->Type)]( to,
+                                                 from->Ptr,
+                                                 from->StrideB,
+                                                 flags,
+                                                 elts,
+                                                 match,
+                                                 start,
+                                                 n );
+
 }
 
 
+#if 0
 static void _tnl_trans_elt_4ub(GLubyte (*to)[4],
-                       const struct gl_client_array *from,
-                       GLuint *flags,
-                       GLuint *elts,
-                       GLuint match,
-                       GLuint start,
-                       GLuint n )
+                               const struct gl_client_array *from,
+                               GLuint *flags,
+                               GLuint *elts,
+                               GLuint match,
+                               GLuint start,
+                               GLuint n )
 {
-   _tnl_trans_elt_4ub_tab[from->Size][TYPE_IDX(from->Type)]( to, 
-                                             from->Ptr,
-                                             from->StrideB,
-                                             flags,
-                                             elts,
-                                             match,
-                                             start,
-                                             n );
-                                       
+   _tnl_trans_elt_4ub_tab[from->Size][TYPE_IDX(from->Type)]( to,
+                                                             from->Ptr,
+                                                             from->StrideB,
+                                                             flags,
+                                                             elts,
+                                                             match,
+                                                             start,
+                                                             n );
+
+}
+#endif
+
+#if 0
+static void _tnl_trans_elt_4us(GLushort (*to)[4],
+                               const struct gl_client_array *from,
+                               GLuint *flags,
+                               GLuint *elts,
+                               GLuint match,
+                               GLuint start,
+                               GLuint n )
+{
+   _tnl_trans_elt_4us_tab[from->Size][TYPE_IDX(from->Type)]( to,
+                                                             from->Ptr,
+                                                             from->StrideB,
+                                                             flags,
+                                                             elts,
+                                                             match,
+                                                             start,
+                                                             n );
+
 }
+#endif
 
 static void _tnl_trans_elt_4f(GLfloat (*to)[4],
-                      const struct gl_client_array *from,
-                      GLuint *flags,
-                      GLuint *elts,
-                      GLuint match,
-                      GLuint start,
-                      GLuint n )
+                              const struct gl_client_array *from,
+                              GLuint *flags,
+                              GLuint *elts,
+                              GLuint match,
+                              GLuint start,
+                              GLuint n )
 {
-   _tnl_trans_elt_4f_tab[from->Size][TYPE_IDX(from->Type)]( to, 
+   _tnl_trans_elt_4f_tab[from->Size][TYPE_IDX(from->Type)]( to,
                                              from->Ptr,
                                              from->StrideB,
                                              flags,
@@ -644,9 +717,12 @@ static void _tnl_trans_elt_4f(GLfloat (*to)[4],
                                              match,
                                              start,
                                              n );
-                                       
+
 }
 
+
+
+#if 0
 static void _tnl_trans_elt_3f(GLfloat (*to)[3],
                       const struct gl_client_array *from,
                       GLuint *flags,
@@ -655,7 +731,7 @@ static void _tnl_trans_elt_3f(GLfloat (*to)[3],
                       GLuint start,
                       GLuint n )
 {
-   _tnl_trans_elt_3f_tab[TYPE_IDX(from->Type)]( to, 
+   _tnl_trans_elt_3f_tab[TYPE_IDX(from->Type)]( to,
                                              from->Ptr,
                                              from->StrideB,
                                              flags,
@@ -664,96 +740,95 @@ static void _tnl_trans_elt_3f(GLfloat (*to)[3],
                                              start,
                                              n );
 }
-
+#endif
 
 
 
 /* Batch function to translate away all the array elements in the
  * input buffer prior to transform.  Done only the first time a vertex
- * buffer is executed or compiled.  
+ * buffer is executed or compiled.
  *
- * KW: Have to do this after each glEnd if arrays aren't locked.  
+ * KW: Have to do this after each glEnd if arrays aren't locked.
  */
 void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM,
-                               GLuint start, GLuint count ) 
+                               GLuint start, GLuint count )
 {
    GLuint *flags = IM->Flag;
    GLuint *elts = IM->Elt;
    GLuint translate = ctx->Array._Enabled;
    GLuint i;
 
-   if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
-      fprintf(stderr, "exec_array_elements %d .. %d\n", start, count);
+   if (MESA_VERBOSE & VERBOSE_IMMEDIATE)
+      _mesa_debug(ctx, "exec_array_elements %d .. %d\n", start, count);
 
-   if (translate & VERT_OBJ) {
-      _tnl_trans_elt_4f( IM->Obj,
+   if (translate & VERT_BIT_POS) {
+      _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_POS],
                         &ctx->Array.Vertex,
-                        flags, elts, (VERT_ELT|VERT_OBJ),
+                        flags, elts, (VERT_BIT_ELT|VERT_BIT_POS),
                         start, count);
 
       if (ctx->Array.Vertex.Size == 4)
-        translate |= VERT_OBJ_234;
+        translate |= VERT_BITS_OBJ_234;
       else if (ctx->Array.Vertex.Size == 3)
-        translate |= VERT_OBJ_23;
+        translate |= VERT_BITS_OBJ_23;
    }
 
 
-   if (translate & VERT_NORM)
-      _tnl_trans_elt_3f( IM->Normal,
+   if (translate & VERT_BIT_NORMAL)
+      _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_NORMAL],
                         &ctx->Array.Normal,
-                        flags, elts, (VERT_ELT|VERT_NORM),
+                        flags, elts, (VERT_BIT_ELT|VERT_BIT_NORMAL),
                         start, count);
 
-   if (translate & VERT_EDGE)
+   if (translate & VERT_BIT_EDGEFLAG)
       _tnl_trans_elt_1ub( IM->EdgeFlag,
                          &ctx->Array.EdgeFlag,
-                         flags, elts, (VERT_ELT|VERT_EDGE),
-                         start, count);
-
-   if (translate & VERT_RGBA)
-      _tnl_trans_elt_4ub( IM->Color,
-                         &ctx->Array.Color,
-                         flags, elts, (VERT_ELT|VERT_RGBA),
+                         flags, elts, (VERT_BIT_ELT|VERT_BIT_EDGEFLAG),
                          start, count);
 
+   if (translate & VERT_BIT_COLOR0) {
+      _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_COLOR0],
+                        &ctx->Array.Color,
+                        flags, elts, (VERT_BIT_ELT|VERT_BIT_COLOR0),
+                        start, count);
+   }
 
-   if (translate & VERT_SPEC_RGB)
-      _tnl_trans_elt_4ub( IM->SecondaryColor,
-                         &ctx->Array.SecondaryColor,
-                         flags, elts, (VERT_ELT|VERT_SPEC_RGB),
-                         start, count);
+   if (translate & VERT_BIT_COLOR1) {
+      _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_COLOR1],
+                        &ctx->Array.SecondaryColor,
+                        flags, elts, (VERT_BIT_ELT|VERT_BIT_COLOR1),
+                        start, count);
+   }
 
-   if (translate & VERT_FOG_COORD)
-      _tnl_trans_elt_1f( IM->FogCoord,
+   if (translate & VERT_BIT_FOG)
+      _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_FOG],
                         &ctx->Array.FogCoord,
-                        flags, elts, (VERT_ELT|VERT_FOG_COORD),
+                        flags, elts, (VERT_BIT_ELT|VERT_BIT_FOG),
                         start, count);
 
-   if (translate & VERT_INDEX)
+   if (translate & VERT_BIT_INDEX)
       _tnl_trans_elt_1ui( IM->Index,
                          &ctx->Array.Index,
-                         flags, elts, (VERT_ELT|VERT_INDEX),
+                         flags, elts, (VERT_BIT_ELT|VERT_BIT_INDEX),
                          start, count);
 
-   if (translate & VERT_TEX_ANY) {
+   if (translate & VERT_BITS_TEX_ANY) {
       for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
-        if (translate & VERT_TEX(i)) {
-           _tnl_trans_elt_4f( IM->TexCoord[i],
+        if (translate & VERT_BIT_TEX(i)) {
+           _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_TEX0 + i],
                               &ctx->Array.TexCoord[i],
-                              flags, elts, (VERT_ELT|VERT_TEX(i)),
+                              flags, elts, (VERT_BIT_ELT|VERT_BIT_TEX(i)),
                               start, count);
 
            if (ctx->Array.TexCoord[i].Size == 4)
               IM->TexSize |= TEX_SIZE_4(i);
            else if (ctx->Array.TexCoord[i].Size == 3)
-              IM->TexSize |= TEX_SIZE_3(i);           
+              IM->TexSize |= TEX_SIZE_3(i);
         }
    }
 
-   for (i = start ; i < count ; i++) 
-      if (flags[i] & VERT_ELT) flags[i] |= translate;
+   for (i = start ; i < count ; i++)
+      if (flags[i] & VERT_BIT_ELT) flags[i] |= translate;
 
-   IM->CopyOrFlag |= translate;
+   IM->FlushElt = 0;
 }
-
-