From 74b493a5e61237de081a438e774e5d8139d4c6b7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Jan 2001 00:04:58 +0000 Subject: Lots of GLchan datatype changes. Added GLvector4us datatype in math/m_vector.[ch] Added _math_trans_4us() in math/m_translate.[ch] Choose GLvector4ub, GLvector4us, GLvector4f at compile time based on CHAN_BITS. Made Driver.ClearColor() and Driver.ClearIndex() optional driver functions. Changed args to Driver.ClearColor(), updated drivers. Reordered files in Makefile.X11 --- src/mesa/tnl/t_imm_elt.c | 177 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 130 insertions(+), 47 deletions(-) (limited to 'src/mesa/tnl/t_imm_elt.c') diff --git a/src/mesa/tnl/t_imm_elt.c b/src/mesa/tnl/t_imm_elt.c index ec79c7e52b..83a76294b6 100644 --- a/src/mesa/tnl/t_imm_elt.c +++ b/src/mesa/tnl/t_imm_elt.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_elt.c,v 1.2 2001/01/02 22:02:53 brianp Exp $ */ +/* $Id: t_imm_elt.c,v 1.3 2001/01/24 00:04:59 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -68,13 +68,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 +111,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]; @@ -141,6 +151,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES]; #define TRX_3F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) ) #define TRX_4F(f,n) (GLfloat)( 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)) @@ -154,6 +165,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES]; #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 +185,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 @@ -183,6 +196,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES]; #define TRX_3F(f,n) /* unused */ #define TRX_4F(f,n) /* unused */ #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. @@ -191,6 +205,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES]; #define SZ 3 #define INIT init_trans_3_GLubyte_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 +220,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 +231,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 +239,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 +268,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 +279,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 +287,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 +315,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 +326,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 +334,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 +363,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 +374,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 +382,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 +410,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 @@ -388,7 +420,8 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES]; #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_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) @@ -397,12 +430,14 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES]; #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 +464,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 +472,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 +494,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 +536,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; @@ -598,43 +637,62 @@ static void _tnl_trans_elt_1ub(GLubyte *to, GLuint n ) { _tnl_trans_elt_1ub_tab[TYPE_IDX(from->Type)]( to, - from->Ptr, - from->StrideB, - flags, - elts, - match, - start, - n ); + from->Ptr, + from->StrideB, + flags, + elts, + match, + start, + n ); } 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 ); + from->Ptr, + from->StrideB, + flags, + elts, + match, + start, + n ); + +} + +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 ); } 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, from->Ptr, @@ -710,18 +768,43 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM, flags, elts, (VERT_ELT|VERT_EDGE), start, count); - if (translate & VERT_RGBA) + if (translate & VERT_RGBA) { +#if CHAN_TYPE == GL_UNSIGNED_BYTE _tnl_trans_elt_4ub( IM->Color, - &ctx->Array.Color, - flags, elts, (VERT_ELT|VERT_RGBA), - start, count); - + &ctx->Array.Color, + flags, elts, (VERT_ELT|VERT_RGBA), + start, count); +#elif CHAN_TYPE == GL_UNSIGNED_SHORT + _tnl_trans_elt_4us( IM->Color, + &ctx->Array.Color, + flags, elts, (VERT_ELT|VERT_RGBA), + start, count); +#elif CHAN_TYPE == GL_FLOAT + _tnl_trans_elt_4f( IM->Color, + &ctx->Array.Color, + flags, elts, (VERT_ELT|VERT_RGBA), + start, count); +#endif + } - if (translate & VERT_SPEC_RGB) + if (translate & VERT_SPEC_RGB) { +#if CHAN_TYPE == GL_UNSIGNED_BYTE _tnl_trans_elt_4ub( IM->SecondaryColor, - &ctx->Array.SecondaryColor, - flags, elts, (VERT_ELT|VERT_SPEC_RGB), - start, count); + &ctx->Array.SecondaryColor, + flags, elts, (VERT_ELT|VERT_SPEC_RGB), + start, count); +#elif CHAN_TYPE == GL_UNSIGNED_SHORT + _tnl_trans_elt_4us( IM->SecondaryColor, + &ctx->Array.SecondaryColor, + flags, elts, (VERT_ELT|VERT_SPEC_RGB), + start, count); +#elif CHAN_TYPE == GL_FLOAT + _tnl_trans_elt_4f( IM->SecondaryColor, + &ctx->Array.SecondaryColor, + flags, elts, (VERT_ELT|VERT_SPEC_RGB), + start, count); +#endif + } if (translate & VERT_FOG_COORD) _tnl_trans_elt_1f( IM->FogCoord, -- cgit v1.2.3