-/* $Id: t_imm_elt.c,v 1.4 2001/02/20 18:28:52 keithw Exp $ */
+/* $Id: t_imm_elt.c,v 1.16 2002/01/22 14:35:16 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>
*/
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;
#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))
#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 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"
*/
#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_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) 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
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();
}
+#if 00
static void _tnl_trans_elt_1f(GLfloat *to,
const struct gl_client_array *from,
GLuint *flags,
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,
match,
start,
n );
-
+
}
+#endif
static void _tnl_trans_elt_1ui(GLuint *to,
const struct gl_client_array *from,
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,
match,
start,
n );
-
+
}
GLuint start,
GLuint n )
{
- _tnl_trans_elt_1ub_tab[TYPE_IDX(from->Type)]( to,
+ _tnl_trans_elt_1ub_tab[TYPE_IDX(from->Type)]( to,
from->Ptr,
from->StrideB,
flags,
match,
start,
n );
-
+
}
+#if 0
static void _tnl_trans_elt_4ub(GLubyte (*to)[4],
const struct gl_client_array *from,
GLuint *flags,
GLuint start,
GLuint n )
{
- _tnl_trans_elt_4ub_tab[from->Size][TYPE_IDX(from->Type)]( to,
+ _tnl_trans_elt_4ub_tab[from->Size][TYPE_IDX(from->Type)]( to,
from->Ptr,
from->StrideB,
flags,
match,
start,
n );
-
+
}
+#endif
+#if 0
static void _tnl_trans_elt_4us(GLushort (*to)[4],
const struct gl_client_array *from,
GLuint *flags,
GLuint start,
GLuint n )
{
- _tnl_trans_elt_4us_tab[from->Size][TYPE_IDX(from->Type)]( to,
+ _tnl_trans_elt_4us_tab[from->Size][TYPE_IDX(from->Type)]( to,
from->Ptr,
from->StrideB,
flags,
match,
start,
n );
-
+
}
+#endif
static void _tnl_trans_elt_4f(GLfloat (*to)[4],
const struct gl_client_array *from,
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,
match,
start,
n );
-
-}
-static void _tnl_trans_elt_4chan(GLubyte (*to)[4],
- const struct gl_client_array *from,
- GLuint *flags,
- GLuint *elts,
- GLuint match,
- GLuint start,
- GLuint n )
-{
-#if CHAN_TYPE == GL_UNSIGNED_BYTE
- _tnl_trans_elt_4ub( to, from, flags, elts, match, start, n );
- (void)_tnl_trans_elt_4us;
-#elif CHAN_TYPE == GL_UNSIGNED_SHORT
- _tnl_trans_elt_4us( to, from, flags, elts, match, start, n );
-#elif CHAN_TYPE == GL_FLOAT
- _tnl_trans_elt_4f( to, from, flags, elts, match, start, n );
- (void)_tnl_trans_elt_4us;
-#endif
}
+#if 0
static void _tnl_trans_elt_3f(GLfloat (*to)[3],
const struct gl_client_array *from,
GLuint *flags,
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,
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;
if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
fprintf(stderr, "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),
+ flags, elts, (VERT_BIT_ELT|VERT_BIT_EDGEFLAG),
start, count);
- if (translate & VERT_RGBA) {
- _tnl_trans_elt_4chan( IM->Color,
- &ctx->Array.Color,
- flags, elts, (VERT_ELT|VERT_RGBA),
- 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_4chan( 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;
}
-
-