summaryrefslogtreecommitdiffstats
path: root/src/mesa/math/m_translate.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2001-01-24 00:04:58 +0000
committerBrian Paul <[email protected]>2001-01-24 00:04:58 +0000
commit74b493a5e61237de081a438e774e5d8139d4c6b7 (patch)
treea8bc94a65bacc67b9b1473f91a2bd84cd2b25937 /src/mesa/math/m_translate.c
parent125fddc31dc9959901d9f1ece693b09f04426d48 (diff)
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
Diffstat (limited to 'src/mesa/math/m_translate.c')
-rw-r--r--src/mesa/math/m_translate.c75
1 files changed, 61 insertions, 14 deletions
diff --git a/src/mesa/math/m_translate.c b/src/mesa/math/m_translate.c
index 1f22b5a0bcb..0eb2ee8281f 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,