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/math/m_trans_tmp.h | 38 ++++++++++++++++++++--- src/mesa/math/m_translate.c | 75 ++++++++++++++++++++++++++++++++++++--------- src/mesa/math/m_translate.h | 14 +++++++-- src/mesa/math/m_vector.c | 35 +++++++++++++++++++-- src/mesa/math/m_vector.h | 23 ++++++++++++-- 5 files changed, 159 insertions(+), 26 deletions(-) (limited to 'src/mesa/math') diff --git a/src/mesa/math/m_trans_tmp.h b/src/mesa/math/m_trans_tmp.h index e7d8a88071..1b20266fbc 100644 --- a/src/mesa/math/m_trans_tmp.h +++ b/src/mesa/math/m_trans_tmp.h @@ -1,10 +1,10 @@ -/* $Id: m_trans_tmp.h,v 1.2 2001/01/02 22:02:52 brianp Exp $ */ +/* $Id: m_trans_tmp.h,v 1.3 2001/01/24 00:04:59 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 3.5 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2001 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"), @@ -104,9 +104,9 @@ static void DEST_1F( GLfloat *t, #ifdef DEST_4UB static void DEST_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; @@ -126,6 +126,30 @@ static void DEST_4UB( GLubyte (*t)[4], #endif +#ifdef DEST_4US +static void DEST_4US( GLushort (*t)[4], + CONST void *ptr, + GLuint stride, + ARGS) +{ + const GLushort *f = (GLushort *) ptr + SRC_START * stride; + const GLushort *first = f; + GLuint i; + (void) start; + (void) first; + for (i = DST_START ; i < n ; i++, NEXT_F) { + CHECK { + NEXT_F2; + if (SZ >= 1) TRX_US(t[i][0], f, 0); + if (SZ >= 2) TRX_US(t[i][1], f, 1); + if (SZ >= 3) TRX_US(t[i][2], f, 2); + if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535; + } + } +} +#endif + + #ifdef DEST_1UB static void DEST_1UB( GLubyte *t, CONST void *ptr, @@ -190,6 +214,9 @@ static void INIT(void) #ifdef DEST_4UB TAB(_4ub)[SZ][SRC_IDX] = DEST_4UB; #endif +#ifdef DEST_4US + TAB(_4us)[SZ][SRC_IDX] = DEST_4US; +#endif #ifdef DEST_4F TAB(_4f)[SZ][SRC_IDX] = DEST_4F; #endif @@ -201,6 +228,7 @@ static void INIT(void) #undef DEST_1UI #undef DEST_1UB #undef DEST_4UB +#undef DEST_4US #undef DEST_3F #undef DEST_4F #undef DEST_1F diff --git a/src/mesa/math/m_translate.c b/src/mesa/math/m_translate.c index 1f22b5a0bc..0eb2ee8281 100644 --- a/src/mesa/math/m_translate.c +++ b/src/mesa/math/m_translate.c @@ -1,10 +1,10 @@ -/* $Id: m_translate.c,v 1.3 2001/01/02 22:02:52 brianp Exp $ */ +/* $Id: m_translate.c,v 1.4 2001/01/24 00:04:59 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.3 + * Version: 3.5 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2001 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"), @@ -57,10 +57,16 @@ typedef void (*trans_1ub_func)(GLubyte *to, GLuint n ); typedef void (*trans_4ub_func)(GLubyte (*to)[4], - CONST void *ptr, - GLuint stride, - GLuint start, - GLuint n ); + CONST void *ptr, + GLuint stride, + GLuint start, + GLuint n ); + +typedef void (*trans_4us_func)(GLushort (*to)[4], + CONST void *ptr, + GLuint stride, + GLuint start, + GLuint n ); typedef void (*trans_4f_func)(GLfloat (*to)[4], CONST void *ptr, @@ -90,6 +96,7 @@ static trans_1ui_func _math_trans_1ui_tab[MAX_TYPES]; static trans_1ub_func _math_trans_1ub_tab[MAX_TYPES]; static trans_3f_func _math_trans_3f_tab[MAX_TYPES]; static trans_4ub_func _math_trans_4ub_tab[5][MAX_TYPES]; +static trans_4us_func _math_trans_4us_tab[5][MAX_TYPES]; static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; @@ -110,13 +117,12 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; /* GL_BYTE */ -#define BYTE_TO_UBYTE(b) (b < 0 ? 0 : (GLubyte) b) - #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_UB(ub, f,n) ub = BYTE_TO_UBYTE( PTR_ELT(f,n) ) +#define TRX_US(ch, f,n) ch = BYTE_TO_USHORT( PTR_ELT(f,n) ) #define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n)) @@ -124,12 +130,14 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #define INIT init_trans_4_GLbyte_raw #define DEST_4F trans_4_GLbyte_4f_raw #define DEST_4UB trans_4_GLbyte_4ub_raw +#define DEST_4US trans_4_GLbyte_4us_raw #include "m_trans_tmp.h" #define SZ 3 #define INIT init_trans_3_GLbyte_raw #define DEST_4F trans_3_GLbyte_4f_raw #define DEST_4UB trans_3_GLbyte_4ub_raw +#define DEST_4US trans_3_GLbyte_4us_raw #define DEST_3F trans_3_GLbyte_3f_raw #include "m_trans_tmp.h" @@ -149,9 +157,11 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #undef TRX_3F #undef TRX_4F #undef TRX_UB +#undef TRX_US #undef TRX_UI #undef SRC_IDX + /* GL_UNSIGNED_BYTE */ #define SRC GLubyte @@ -159,6 +169,7 @@ static trans_4f_func _math_trans_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 = UBYTE_TO_USHORT(PTR_ELT(f,n)) #define TRX_UI(f,n) (GLuint)PTR_ELT(f,n) /* 4ub->4ub handled in special case below. @@ -167,6 +178,7 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #define SZ 3 #define INIT init_trans_3_GLubyte_raw #define DEST_4UB trans_3_GLubyte_4ub_raw +#define DEST_4US trans_3_GLubyte_4us_raw #include "m_trans_tmp.h" @@ -181,6 +193,7 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #undef TRX_3F #undef TRX_4F #undef TRX_UB +#undef TRX_US #undef TRX_UI @@ -191,6 +204,7 @@ static trans_4f_func _math_trans_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)) @@ -198,12 +212,14 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #define INIT init_trans_4_GLshort_raw #define DEST_4F trans_4_GLshort_4f_raw #define DEST_4UB trans_4_GLshort_4ub_raw +#define DEST_4US trans_4_GLshort_4us_raw #include "m_trans_tmp.h" #define SZ 3 #define INIT init_trans_3_GLshort_raw #define DEST_4F trans_3_GLshort_4f_raw #define DEST_4UB trans_3_GLshort_4ub_raw +#define DEST_4US trans_3_GLshort_4us_raw #define DEST_3F trans_3_GLshort_3f_raw #include "m_trans_tmp.h" @@ -225,6 +241,7 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #undef TRX_3F #undef TRX_4F #undef TRX_UB +#undef TRX_US #undef TRX_UI @@ -235,6 +252,7 @@ static trans_4f_func _math_trans_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 = (GLushort) (PTR_ELT(f,n) >> 8) #define TRX_UI(f,n) (GLuint) PTR_ELT(f,n) @@ -242,12 +260,14 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #define INIT init_trans_4_GLushort_raw #define DEST_4F trans_4_GLushort_4f_raw #define DEST_4UB trans_4_GLushort_4ub_raw +#define DEST_4US trans_4_GLushort_4us_raw #include "m_trans_tmp.h" #define SZ 3 #define INIT init_trans_3_GLushort_raw #define DEST_4F trans_3_GLushort_4f_raw #define DEST_4UB trans_3_GLushort_4ub_raw +#define DEST_4US trans_3_GLushort_4us_raw #define DEST_3F trans_3_GLushort_3f_raw #include "m_trans_tmp.h" @@ -268,6 +288,7 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #undef TRX_3F #undef TRX_4F #undef TRX_UB +#undef TRX_US #undef TRX_UI @@ -278,6 +299,7 @@ static trans_4f_func _math_trans_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)) @@ -285,12 +307,14 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #define INIT init_trans_4_GLint_raw #define DEST_4F trans_4_GLint_4f_raw #define DEST_4UB trans_4_GLint_4ub_raw +#define DEST_4US trans_4_GLint_4us_raw #include "m_trans_tmp.h" #define SZ 3 #define INIT init_trans_3_GLint_raw #define DEST_4F trans_3_GLint_4f_raw #define DEST_4UB trans_3_GLint_4ub_raw +#define DEST_4US trans_3_GLint_4us_raw #define DEST_3F trans_3_GLint_3f_raw #include "m_trans_tmp.h" @@ -312,6 +336,7 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #undef TRX_3F #undef TRX_4F #undef TRX_UB +#undef TRX_US #undef TRX_UI @@ -322,6 +347,7 @@ static trans_4f_func _math_trans_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 = (GLubyte) (PTR_ELT(f,n) >> 24) +#define TRX_US(us, f,n) us = (GLshort) (PTR_ELT(f,n) >> 16) #define TRX_UI(f,n) PTR_ELT(f,n) @@ -329,12 +355,14 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #define INIT init_trans_4_GLuint_raw #define DEST_4F trans_4_GLuint_4f_raw #define DEST_4UB trans_4_GLuint_4ub_raw +#define DEST_4US trans_4_GLuint_4us_raw #include "m_trans_tmp.h" #define SZ 3 #define INIT init_trans_3_GLuint_raw #define DEST_4F trans_3_GLuint_4f_raw #define DEST_4UB trans_3_GLuint_4ub_raw +#define DEST_4US trans_3_GLuint_4us_raw #define DEST_3F trans_3_GLuint_3f_raw #include "m_trans_tmp.h" @@ -355,6 +383,7 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #undef TRX_3F #undef TRX_4F #undef TRX_UB +#undef TRX_US #undef TRX_UI @@ -364,7 +393,8 @@ static trans_4f_func _math_trans_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) @@ -373,12 +403,14 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #define INIT init_trans_4_GLdouble_raw #define DEST_4F trans_4_GLdouble_4f_raw #define DEST_4UB trans_4_GLdouble_4ub_raw +#define DEST_4US trans_4_GLdouble_4us_raw #include "m_trans_tmp.h" #define SZ 3 #define INIT init_trans_3_GLdouble_raw #define DEST_4F trans_3_GLdouble_4f_raw #define DEST_4UB trans_3_GLdouble_4ub_raw +#define DEST_4US trans_3_GLdouble_4us_raw #define DEST_3F trans_3_GLdouble_3f_raw #include "m_trans_tmp.h" @@ -405,6 +437,7 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #define SZ 4 #define INIT init_trans_4_GLfloat_raw #define DEST_4UB trans_4_GLfloat_4ub_raw +#define DEST_4US trans_4_GLfloat_4us_raw #define DEST_4F trans_4_GLfloat_4f_raw #include "m_trans_tmp.h" @@ -412,6 +445,7 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #define INIT init_trans_3_GLfloat_raw #define DEST_4F trans_3_GLfloat_4f_raw #define DEST_4UB trans_3_GLfloat_4ub_raw +#define DEST_4US trans_3_GLfloat_4us_raw #define DEST_3F trans_3_GLfloat_3f_raw #include "m_trans_tmp.h" @@ -434,13 +468,14 @@ static trans_4f_func _math_trans_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_raw (GLubyte (*t)[4], - CONST void *Ptr, - GLuint stride, - ARGS ) +static void trans_4_GLubyte_4ub_raw(GLubyte (*t)[4], + CONST void *Ptr, + GLuint stride, + ARGS ) { const GLubyte *f = (GLubyte *) Ptr + SRC_START * stride; GLuint i; @@ -468,6 +503,7 @@ static void init_translate_raw(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_raw; @@ -567,6 +603,17 @@ void _math_trans_4ub(GLubyte (*to)[4], _math_trans_4ub_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n ); } +void _math_trans_4us(GLushort (*to)[4], + CONST void *ptr, + GLuint stride, + GLenum type, + GLuint size, + GLuint start, + GLuint n ) +{ + _math_trans_4us_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n ); +} + void _math_trans_4f(GLfloat (*to)[4], CONST void *ptr, GLuint stride, diff --git a/src/mesa/math/m_translate.h b/src/mesa/math/m_translate.h index b6db1f6048..3151e45817 100644 --- a/src/mesa/math/m_translate.h +++ b/src/mesa/math/m_translate.h @@ -1,10 +1,10 @@ -/* $Id: m_translate.h,v 1.3 2000/12/26 05:09:31 keithw Exp $ */ +/* $Id: m_translate.h,v 1.4 2001/01/24 00:04:59 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.5 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2001 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"), @@ -61,6 +61,14 @@ extern void _math_trans_4ub(GLubyte (*to)[4], GLuint start, GLuint n ); +extern void _math_trans_4us(GLushort (*to)[4], + CONST void *ptr, + GLuint stride, + GLenum type, + GLuint size, + GLuint start, + GLuint n ); + extern void _math_trans_4f(GLfloat (*to)[4], CONST void *ptr, GLuint stride, diff --git a/src/mesa/math/m_vector.c b/src/mesa/math/m_vector.c index e582ccce37..7fa2b726e4 100644 --- a/src/mesa/math/m_vector.c +++ b/src/mesa/math/m_vector.c @@ -1,10 +1,10 @@ -/* $Id: m_vector.c,v 1.2 2000/12/26 05:09:31 keithw Exp $ */ +/* $Id: m_vector.c,v 1.3 2001/01/24 00:04:59 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 3.5 * - * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2001 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"), @@ -115,6 +115,15 @@ void gl_vector4ub_init( GLvector4ub *v, GLuint flags, GLubyte (*storage)[4] ) v->flags = flags ; } +void gl_vector4us_init( GLvector4us *v, GLuint flags, GLushort (*storage)[4] ) +{ + v->stride = 4 * sizeof(GLushort); + v->data = storage; + v->start = (GLushort *) storage; + v->count = 0; + v->flags = flags ; +} + void gl_vector1ub_init( GLvector1ub *v, GLuint flags, GLubyte *storage ) { v->stride = 1 * sizeof(GLubyte); @@ -189,6 +198,17 @@ void gl_vector4ub_alloc( GLvector4ub *v, GLuint flags, GLuint count, v->flags = flags | VEC_MALLOC ; } +void gl_vector4us_alloc( GLvector4us *v, GLuint flags, GLuint count, + GLuint alignment ) +{ + v->stride = 4 * sizeof(GLushort); + v->storage = ALIGN_MALLOC( count * 4 * sizeof(GLushort), alignment ); + v->start = (GLushort *) v->storage; + v->data = (GLushort (*)[4]) v->storage; + v->count = 0; + v->flags = flags | VEC_MALLOC ; +} + void gl_vector1ub_alloc( GLvector1ub *v, GLuint flags, GLuint count, GLuint alignment ) { @@ -264,6 +284,17 @@ void gl_vector4ub_free( GLvector4ub *v ) } } +void gl_vector4us_free( GLvector4us *v ) +{ + if (v->flags & VEC_MALLOC) { + ALIGN_FREE( v->storage ); + v->data = NULL; + v->start = NULL; + v->storage = NULL; + v->flags &= ~VEC_MALLOC; + } +} + void gl_vector1ub_free( GLvector1ub *v ) { if (v->flags & VEC_MALLOC) { diff --git a/src/mesa/math/m_vector.h b/src/mesa/math/m_vector.h index 24a392a12b..12200f960c 100644 --- a/src/mesa/math/m_vector.h +++ b/src/mesa/math/m_vector.h @@ -1,10 +1,10 @@ -/* $Id: m_vector.h,v 1.2 2000/12/26 05:09:31 keithw Exp $ */ +/* $Id: m_vector.h,v 1.3 2001/01/24 00:04:59 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 3.5 * - * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2001 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"), @@ -133,6 +133,25 @@ extern void gl_vector4ub_free( GLvector4ub * ); +/* For 4 * GLushort rgba values. + */ +typedef struct { + GLushort (*data)[4]; + GLushort *start; + GLuint count; + GLuint stride; + GLuint flags; + void *storage; +} GLvector4us; + +extern void gl_vector4us_init( GLvector4us *v, GLuint flags, + GLushort (*storage)[4] ); +extern void gl_vector4us_alloc( GLvector4us *v, GLuint flags, GLuint count, + GLuint alignment ); +extern void gl_vector4us_free( GLvector4us * ); + + + /* For 1ub values, eg edgeflag. */ -- cgit v1.2.3