summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/main/glheader.h12
-rw-r--r--src/mesa/main/texutil.c4
-rw-r--r--src/mesa/tnl/t_imm_api.c106
-rw-r--r--src/mesa/tnl/t_vb_render.c6
4 files changed, 70 insertions, 58 deletions
diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h
index 0324b42ffd..596bd2d01e 100644
--- a/src/mesa/main/glheader.h
+++ b/src/mesa/main/glheader.h
@@ -1,4 +1,4 @@
-/* $Id: glheader.h,v 1.20 2001/05/14 23:11:12 brianp Exp $ */
+/* $Id: glheader.h,v 1.21 2001/06/15 15:22:07 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -241,5 +241,15 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC
#endif
+/*
+ * Sometimes we treat GLfloats as GLints. On x86 systems, moving a float
+ * as a int (thereby using integer registers instead of fp registers) is
+ * a performance win. Typically, this can be done with ordinary casts.
+ * But with gcc's -fstrict-aliasing flag (which defaults to on in gcc 3.0)
+ * these casts generate warnings.
+ * The following union typedef is used to solve that.
+ */
+typedef union { GLfloat f; GLint i; } fi_type;
+
#endif /* GLHEADER_H */
diff --git a/src/mesa/main/texutil.c b/src/mesa/main/texutil.c
index e7c8fa7608..6231f589af 100644
--- a/src/mesa/main/texutil.c
+++ b/src/mesa/main/texutil.c
@@ -1,4 +1,4 @@
-/* $Id: texutil.c,v 1.24 2001/05/02 21:02:38 brianp Exp $ */
+/* $Id: texutil.c,v 1.25 2001/06/15 15:22:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -415,7 +415,7 @@ CONVERT_ARGB4444( texsubimage3d )
dst = (s >> 1) | ((s & 1) << 15); }
#define CONVERT_TEXEL_DWORD( dst, src ) \
- { const GLuint s = *(GLuint *)src; \
+ { const GLuint s = ((fi_type *)src)->i; \
dst = (((s & 0xfffefffe) >> 1) | \
((s & 0x00010001) << 15)); }
diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c
index 9c4894ada7..4063c8c3b2 100644
--- a/src/mesa/tnl/t_imm_api.c
+++ b/src/mesa/tnl/t_imm_api.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_api.c,v 1.15 2001/06/04 16:09:28 keithw Exp $ */
+/* $Id: t_imm_api.c,v 1.16 2001/06/15 15:22:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -543,12 +543,14 @@ _tnl_Indexiv( const GLint *c )
#define NORMALF( x, y, z ) \
{ \
GLuint count; \
- GLint *normal; \
+ fi_type *normal; \
GET_IMMEDIATE; \
count = IM->Count; \
IM->Flag[count] |= VERT_NORM; \
- normal = (GLint *)IM->Normal[count]; \
- ASSIGN_3V(normal, *(int*)&(x), *(int*)&(y), *(int*)&(z)); \
+ normal = (fi_type *)IM->Normal[count]; \
+ normal[0].i = ((fi_type *)&(x))->i; \
+ normal[1].i = ((fi_type *)&(y))->i; \
+ normal[2].i = ((fi_type *)&(z))->i; \
}
#else
#define NORMALF NORMAL
@@ -616,18 +618,18 @@ _tnl_Normal3fv( const GLfloat *v )
}
#if defined(USE_IEEE)
-#define TEXCOORD2F(s,t) \
-{ \
- GLuint count; \
- GLint *tc; \
- GET_IMMEDIATE; \
- count = IM->Count; \
- IM->Flag[count] |= VERT_TEX0; \
- tc = (GLint *)IM->TexCoord0[count]; \
- tc[0] = *(GLint *)&(s); \
- tc[1] = *(GLint *)&(t); \
- tc[2] = 0; \
- tc[3] = IEEE_ONE; \
+#define TEXCOORD2F(s,t) \
+{ \
+ GLuint count; \
+ fi_type *tc; \
+ GET_IMMEDIATE; \
+ count = IM->Count; \
+ IM->Flag[count] |= VERT_TEX0; \
+ tc = (fi_type *)IM->TexCoord0[count]; \
+ tc[0].i = ((fi_type *)&(s))->i; \
+ tc[1].i = ((fi_type *)&(t))->i; \
+ tc[2].i = 0; \
+ tc[3].i = IEEE_ONE; \
}
#else
#define TEXCOORD2F TEXCOORD2
@@ -721,53 +723,53 @@ _tnl_TexCoord4fv( const GLfloat *v )
}
#if defined(USE_IEEE)
-#define VERTEX2F(IM, x, y) \
-{ \
- GLuint count = IM->Count++; \
- GLint *dest = (GLint *)IM->Obj[count]; \
- IM->Flag[count] |= VERT_OBJ; \
- dest[0] = *(GLint *)&(x); \
- dest[1] = *(GLint *)&(y); \
- dest[2] = 0; \
- dest[3] = IEEE_ONE; \
+#define VERTEX2F(IM, x, y) \
+{ \
+ GLuint count = IM->Count++; \
+ fi_type *dest = (fi_type *)IM->Obj[count]; \
+ IM->Flag[count] |= VERT_OBJ; \
+ dest[0].i = ((fi_type *)&(x))->i; \
+ dest[1].i = ((fi_type *)&(y))->i; \
+ dest[2].i = 0; \
+ dest[3].i = IEEE_ONE; \
/* ASSERT(IM->Flag[IM->Count]==0); */ \
if (count == IMM_MAXDATA - 1) \
- _tnl_flush_immediate( IM ); \
+ _tnl_flush_immediate( IM ); \
}
#else
#define VERTEX2F VERTEX2
#endif
#if defined(USE_IEEE)
-#define VERTEX3F(IM, x, y, z) \
-{ \
- GLuint count = IM->Count++; \
- GLint *dest = (GLint *)IM->Obj[count]; \
- IM->Flag[count] |= VERT_OBJ_23; \
- dest[0] = *(GLint *)&(x); \
- dest[1] = *(GLint *)&(y); \
- dest[2] = *(GLint *)&(z); \
- dest[3] = IEEE_ONE; \
-/* ASSERT(IM->Flag[IM->Count]==0); */ \
+#define VERTEX3F(IM, x, y, z) \
+{ \
+ GLuint count = IM->Count++; \
+ fi_type *dest = (fi_type *)IM->Obj[count]; \
+ IM->Flag[count] |= VERT_OBJ_23; \
+ dest[0].i = ((fi_type *)&(x))->i; \
+ dest[1].i = ((fi_type *)&(y))->i; \
+ dest[2].i = ((fi_type *)&(z))->i; \
+ dest[3].i = IEEE_ONE; \
+/* ASSERT(IM->Flag[IM->Count]==0); */ \
if (count == IMM_MAXDATA - 1) \
- _tnl_flush_immediate( IM ); \
+ _tnl_flush_immediate( IM ); \
}
#else
#define VERTEX3F VERTEX3
#endif
#if defined(USE_IEEE)
-#define VERTEX4F(IM, x, y, z, w) \
-{ \
- GLuint count = IM->Count++; \
- GLint *dest = (GLint *)IM->Obj[count]; \
- IM->Flag[count] |= VERT_OBJ_234; \
- dest[0] = *(GLint *)&(x); \
- dest[1] = *(GLint *)&(y); \
- dest[2] = *(GLint *)&(z); \
- dest[3] = *(GLint *)&(w); \
+#define VERTEX4F(IM, x, y, z, w) \
+{ \
+ GLuint count = IM->Count++; \
+ fi_type *dest = (fi_type *)IM->Obj[count]; \
+ IM->Flag[count] |= VERT_OBJ_234; \
+ dest[0].i = ((fi_type *)&(x))->i; \
+ dest[1].i = ((fi_type *)&(y))->i; \
+ dest[2].i = ((fi_type *)&(z))->i; \
+ dest[3].i = ((fi_type *)&(w))->i; \
if (count == IMM_MAXDATA - 1) \
- _tnl_flush_immediate( IM ); \
+ _tnl_flush_immediate( IM ); \
}
#else
#define VERTEX4F VERTEX4
@@ -886,12 +888,12 @@ _tnl_Vertex4fv( const GLfloat *v )
GLuint texunit = target - GL_TEXTURE0_ARB; \
if (texunit < IM->MaxTextureUnits) { \
GLuint count = IM->Count; \
- GLint *tc = (GLint *)IM->TexCoord[texunit][count]; \
+ fi_type *tc = (fi_type *)IM->TexCoord[texunit][count]; \
IM->Flag[count] |= VERT_TEX(texunit); \
- tc[0] = *(int *)&(s); \
- tc[1] = *(int *)&(t); \
- tc[2] = 0; \
- tc[3] = IEEE_ONE; \
+ tc[0].i = ((fi_type *)&(s))->i; \
+ tc[1].i = ((fi_type *)&(t))->i; \
+ tc[2].i = 0; \
+ tc[3].i = IEEE_ONE; \
} \
}
#else
diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c
index 414c6bd34a..ec3cb02bb6 100644
--- a/src/mesa/tnl/t_vb_render.c
+++ b/src/mesa/tnl/t_vb_render.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_render.c,v 1.20 2001/05/11 15:53:06 keithw Exp $ */
+/* $Id: t_vb_render.c,v 1.21 2001/06/15 15:22:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -69,8 +69,8 @@
#if defined(USE_IEEE)
-#define NEGATIVE(x) ((*(GLuint *)&x) & (1<<31))
-#define DIFFERENT_SIGNS(x,y) (((*(GLuint *)&x)^(*(GLuint *)&y)) & (1<<31))
+#define NEGATIVE(x) (GET_FLOAT_BITS(x) & (1<<31))
+#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31))
#else
#define NEGATIVE(x) (x < 0)
#define DIFFERENT_SIGNS(x,y) (x * y <= 0 && x - y != 0)