summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2003-03-01 01:50:20 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2003-03-01 01:50:20 +0000
commit27558a160a9fe91745728d7626995cd88f8fe339 (patch)
tree0b8cbbd49d418f5ef9f10d3d721c3d4e9e925c3d /src/mesa/main
parent4e50ab5f70582f4e362c4572b22a4c3f87c71a14 (diff)
Killed mmath.[ch]. Moved low-level functions/assembly code into imports.[ch]
Moved type conversion and interpolation macros into macros.h Updated all the files that used to include mmath.h
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/Makefile.BeOS-R55
-rw-r--r--src/mesa/main/Makefile.DJ1
-rw-r--r--src/mesa/main/Makefile.OSMesa163
-rw-r--r--src/mesa/main/Makefile.X113
-rw-r--r--src/mesa/main/Makefile.ugl1
-rw-r--r--src/mesa/main/Makefile.win1
-rw-r--r--src/mesa/main/api_eval.c7
-rw-r--r--src/mesa/main/api_noop.c7
-rw-r--r--src/mesa/main/buffers.c7
-rw-r--r--src/mesa/main/clip.c5
-rw-r--r--src/mesa/main/colormac.h70
-rw-r--r--src/mesa/main/colortab.c3
-rw-r--r--src/mesa/main/context.c13
-rw-r--r--src/mesa/main/drawpix.c3
-rw-r--r--src/mesa/main/enable.c3
-rw-r--r--src/mesa/main/eval.c21
-rw-r--r--src/mesa/main/feedback.c7
-rw-r--r--src/mesa/main/get.c3
-rw-r--r--src/mesa/main/glheader.h9
-rw-r--r--src/mesa/main/histogram.c7
-rw-r--r--src/mesa/main/image.c13
-rw-r--r--src/mesa/main/imports.c161
-rw-r--r--src/mesa/main/imports.h456
-rw-r--r--src/mesa/main/light.c15
-rw-r--r--src/mesa/main/lines.c7
-rw-r--r--src/mesa/main/macros.h235
-rw-r--r--src/mesa/main/matrix.c7
-rw-r--r--src/mesa/main/mtypes.h29
-rw-r--r--src/mesa/main/nvfragparse.c18
-rw-r--r--src/mesa/main/nvvertexec.c3
-rw-r--r--src/mesa/main/points.c7
-rw-r--r--src/mesa/main/rastpos.c11
-rw-r--r--src/mesa/main/state.c12
-rw-r--r--src/mesa/main/texformat.c7
-rw-r--r--src/mesa/main/teximage.c3
-rw-r--r--src/mesa/main/texutil.c7
-rw-r--r--src/mesa/main/varray.c7
37 files changed, 959 insertions, 218 deletions
diff --git a/src/mesa/main/Makefile.BeOS-R5 b/src/mesa/main/Makefile.BeOS-R5
index 97d814c917..8ae0efcf1d 100644
--- a/src/mesa/main/Makefile.BeOS-R5
+++ b/src/mesa/main/Makefile.BeOS-R5
@@ -1,7 +1,7 @@
# Mesa 3-D graphics library
-# Version: 4.1
+# Version: 5.1
#
-# Copyright (C) 1995-2002 Brian Paul All Rights Reserved.
+# Copyright (C) 1995-2003 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"),
@@ -90,7 +90,6 @@ MESA_CORE_SRCS = \
light.c \
lines.c \
matrix.c \
- mmath.c \
pixel.c \
points.c \
polygon.c \
diff --git a/src/mesa/main/Makefile.DJ b/src/mesa/main/Makefile.DJ
index e2714f9088..2a3c6a79b7 100644
--- a/src/mesa/main/Makefile.DJ
+++ b/src/mesa/main/Makefile.DJ
@@ -130,7 +130,6 @@ CORE_SOURCES = \
light.c \
lines.c \
matrix.c \
- mmath.c \
pixel.c \
points.c \
polygon.c \
diff --git a/src/mesa/main/Makefile.OSMesa16 b/src/mesa/main/Makefile.OSMesa16
index c1899e70ac..7a7b0f11bf 100644
--- a/src/mesa/main/Makefile.OSMesa16
+++ b/src/mesa/main/Makefile.OSMesa16
@@ -1,4 +1,4 @@
-# $Id: Makefile.OSMesa16,v 1.11 2003/01/14 04:55:45 brianp Exp $
+# $Id: Makefile.OSMesa16,v 1.12 2003/03/01 01:50:20 brianp Exp $
# Mesa 3-D graphics library
# Version: 5.0
@@ -56,7 +56,6 @@ CORE_SOURCES = \
light.c \
lines.c \
matrix.c \
- mmath.c \
nvprogram.c \
nvfragparse.c \
nvvertexec.c \
diff --git a/src/mesa/main/Makefile.X11 b/src/mesa/main/Makefile.X11
index 9ccaafc9d8..7a8e8f0b41 100644
--- a/src/mesa/main/Makefile.X11
+++ b/src/mesa/main/Makefile.X11
@@ -1,4 +1,4 @@
-# $Id: Makefile.X11,v 1.73 2003/01/14 04:55:45 brianp Exp $
+# $Id: Makefile.X11,v 1.74 2003/03/01 01:50:20 brianp Exp $
# Mesa 3-D graphics library
# Version: 5.0
@@ -55,7 +55,6 @@ CORE_SOURCES = \
light.c \
lines.c \
matrix.c \
- mmath.c \
nvprogram.c \
nvfragparse.c \
nvvertexec.c \
diff --git a/src/mesa/main/Makefile.ugl b/src/mesa/main/Makefile.ugl
index 95d880984f..bcecd7afb7 100644
--- a/src/mesa/main/Makefile.ugl
+++ b/src/mesa/main/Makefile.ugl
@@ -85,7 +85,6 @@ GL_SOURCES = \
light.c \
lines.c \
matrix.c \
- mmath.c \
pixel.c \
points.c \
polygon.c \
diff --git a/src/mesa/main/Makefile.win b/src/mesa/main/Makefile.win
index ebb59e76cd..2acbce0ced 100644
--- a/src/mesa/main/Makefile.win
+++ b/src/mesa/main/Makefile.win
@@ -45,7 +45,6 @@ CORE_SRCS = \
light.c \
lines.c \
matrix.c \
- mmath.c \
nvprogram.c \
nvfragparse.c \
nvvertexec.c \
diff --git a/src/mesa/main/api_eval.c b/src/mesa/main/api_eval.c
index 3b29ac62b9..254f814988 100644
--- a/src/mesa/main/api_eval.c
+++ b/src/mesa/main/api_eval.c
@@ -1,10 +1,10 @@
-/* $Id: api_eval.c,v 1.3 2002/10/29 20:28:42 brianp Exp $ */
+/* $Id: api_eval.c,v 1.4 2003/03/01 01:50:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 5.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -31,7 +31,6 @@
#include "api_eval.h"
#include "context.h"
#include "macros.h"
-#include "mmath.h"
#include "math/m_eval.h"
static void do_EvalCoord1f(GLcontext* ctx, GLfloat u)
diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c
index 6a4226294c..ff96605f1b 100644
--- a/src/mesa/main/api_noop.c
+++ b/src/mesa/main/api_noop.c
@@ -1,10 +1,10 @@
-/* $Id: api_noop.c,v 1.11 2003/01/14 04:55:45 brianp Exp $ */
+/* $Id: api_noop.c,v 1.12 2003/03/01 01:50:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -32,7 +32,6 @@
#include "colormac.h"
#include "light.h"
#include "macros.h"
-#include "mmath.h"
#include "mtypes.h"
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 14994c61f7..ab579b3d33 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -1,10 +1,10 @@
-/* $Id: buffers.c,v 1.42 2002/10/24 23:57:19 brianp Exp $ */
+/* $Id: buffers.c,v 1.43 2003/03/01 01:50:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -33,7 +33,6 @@
#include "context.h"
#include "depth.h"
#include "enums.h"
-#include "macros.h"
#include "stencil.h"
#include "state.h"
#include "mtypes.h"
diff --git a/src/mesa/main/clip.c b/src/mesa/main/clip.c
index 79565a0fb3..8f701bb712 100644
--- a/src/mesa/main/clip.c
+++ b/src/mesa/main/clip.c
@@ -1,8 +1,8 @@
-/* $Id: clip.c,v 1.26 2002/10/24 23:57:19 brianp Exp $ */
+/* $Id: clip.c,v 1.27 2003/03/01 01:50:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 5.1
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
@@ -29,7 +29,6 @@
#include "clip.h"
#include "context.h"
#include "macros.h"
-#include "mmath.h"
#include "mtypes.h"
#include "math/m_xform.h"
diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h
index 7fdd0b3b9d..7f6b922f62 100644
--- a/src/mesa/main/colormac.h
+++ b/src/mesa/main/colormac.h
@@ -1,10 +1,10 @@
-/* $Id: colormac.h,v 1.11 2002/04/04 16:51:52 brianp Exp $ */
+/* $Id: colormac.h,v 1.12 2003/03/01 01:50:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -34,12 +34,9 @@
#define COLORMAC_H
-#include "glheader.h"
+#include "imports.h"
#include "config.h"
#include "macros.h"
-#include "mmath.h"
-/* Do not reference mtypes.h from this file.
- */
#if CHAN_BITS == 8
@@ -133,4 +130,63 @@ do { \
} while (0)
+
+/* Generic color packing macros
+ * XXX We may move these into texutil.h at some point.
+ */
+
+#define PACK_COLOR_8888( a, b, c, d ) \
+ (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
+
+#define PACK_COLOR_888( a, b, c ) \
+ (((a) << 16) | ((b) << 8) | (c))
+
+#define PACK_COLOR_565( a, b, c ) \
+ ((((a) & 0xf8) << 8) | (((b) & 0xfc) << 3) | (((c) & 0xf8) >> 3))
+
+#define PACK_COLOR_1555( a, b, c, d ) \
+ ((((b) & 0xf8) << 7) | (((c) & 0xf8) << 2) | (((d) & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+
+#define PACK_COLOR_4444( a, b, c, d ) \
+ ((((a) & 0xf0) << 8) | (((b) & 0xf0) << 4) | ((c) & 0xf0) | ((d) >> 4))
+
+#define PACK_COLOR_88( a, b ) \
+ (((a) << 8) | (b))
+
+#define PACK_COLOR_332( a, b, c ) \
+ (((a) & 0xe0) | (((b) & 0xe0) >> 3) | (((c) & 0xc0) >> 6))
+
+
+#ifdef MESA_BIG_ENDIAN
+
+#define PACK_COLOR_8888_LE( a, b, c, d ) PACK_COLOR_8888( d, c, b, a )
+
+#define PACK_COLOR_565_LE( a, b, c ) \
+ (((a) & 0xf8) | (((b) & 0xe0) >> 5) | (((b) & 0x1c) << 11) | \
+ (((c) & 0xf8) << 5))
+
+#define PACK_COLOR_1555_LE( a, b, c, d ) \
+ ((((b) & 0xf8) >> 1) | (((c) & 0xc0) >> 6) | (((c) & 0x38) << 10) | \
+ (((d) & 0xf8) << 5) | ((a) ? 0x80 : 0))
+
+#define PACK_COLOR_4444_LE( a, b, c, d ) PACK_COLOR_4444( c, d, a, b )
+
+#define PACK_COLOR_88_LE( a, b ) PACK_COLOR_88( b, a )
+
+#else /* little endian */
+
+#define PACK_COLOR_8888_LE( a, b, c, d ) PACK_COLOR_8888( a, b, c, d )
+
+#define PACK_COLOR_565_LE( a, b, c ) PACK_COLOR_565( a, b, c )
+
+#define PACK_COLOR_1555_LE( a, b, c, d ) PACK_COLOR_1555( a, b, c, d )
+
+#define PACK_COLOR_4444_LE( a, b, c, d ) PACK_COLOR_4444( a, b, c, d )
+
+#define PACK_COLOR_88_LE( a, b ) PACK_COLOR_88( a, b )
+
+#endif /* endianness */
+
+
#endif /* COLORMAC_H */
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c
index 184aa8eff2..0a785743c0 100644
--- a/src/mesa/main/colortab.c
+++ b/src/mesa/main/colortab.c
@@ -1,4 +1,4 @@
-/* $Id: colortab.c,v 1.48 2003/01/26 14:37:16 brianp Exp $ */
+/* $Id: colortab.c,v 1.49 2003/03/01 01:50:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,7 +31,6 @@
#include "context.h"
#include "image.h"
#include "macros.h"
-#include "mmath.h"
#include "state.h"
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 7430d94410..b9bbe65193 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.193 2003/01/26 14:37:15 brianp Exp $ */
+/* $Id: context.c,v 1.194 2003/03/01 01:50:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -41,7 +41,6 @@
#include "hash.h"
#include "light.h"
#include "macros.h"
-#include "mmath.h"
#include "simple_list.h"
#include "state.h"
#include "teximage.h"
@@ -81,6 +80,9 @@ int MESA_DEBUG_FLAGS = 0;
#endif
+/* ubyte -> float conversion */
+GLfloat _mesa_ubyte_to_float_color_tab[256];
+
static void
free_shared_state( GLcontext *ctx, struct gl_shared_state *ss );
@@ -556,6 +558,8 @@ one_time_init( GLcontext *ctx )
static GLboolean alreadyCalled = GL_FALSE;
_glthread_LOCK_MUTEX(OneTimeLock);
if (!alreadyCalled) {
+ GLuint i;
+
/* do some implementation tests */
assert( sizeof(GLbyte) == 1 );
assert( sizeof(GLshort) >= 2 );
@@ -567,7 +571,10 @@ one_time_init( GLcontext *ctx )
_mesa_init_lists();
_math_init();
- _mesa_init_math();
+
+ for (i = 0; i < 256; i++) {
+ _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F;
+ }
#ifdef USE_SPARC_ASM
_mesa_init_sparc_glapi_relocs();
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index 1dbeefa23b..f5d780e2ae 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: drawpix.c,v 1.63 2002/10/24 23:57:20 brianp Exp $ */
+/* $Id: drawpix.c,v 1.64 2003/03/01 01:50:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,7 +31,6 @@
#include "drawpix.h"
#include "feedback.h"
#include "macros.h"
-#include "mmath.h"
#include "state.h"
#include "mtypes.h"
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index f343c2099a..eb46976abb 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1,4 +1,4 @@
-/* $Id: enable.c,v 1.74 2003/01/26 14:37:16 brianp Exp $ */
+/* $Id: enable.c,v 1.75 2003/03/01 01:50:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -30,7 +30,6 @@
#include "enable.h"
#include "light.h"
#include "macros.h"
-#include "mmath.h"
#include "simple_list.h"
#include "mtypes.h"
#include "enums.h"
diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c
index 30767a6277..d207d14b20 100644
--- a/src/mesa/main/eval.c
+++ b/src/mesa/main/eval.c
@@ -1,10 +1,10 @@
-/* $Id: eval.c,v 1.24 2002/10/24 23:57:20 brianp Exp $ */
+/* $Id: eval.c,v 1.25 2003/03/01 01:50:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -44,7 +44,6 @@
#include "context.h"
#include "eval.h"
#include "macros.h"
-#include "mmath.h"
#include "mtypes.h"
@@ -705,7 +704,7 @@ _mesa_GetMapiv( GLenum target, GLenum query, GLint *v )
}
if (data) {
for (i=0;i<n;i++) {
- v[i] = ROUNDF(data[i]);
+ v[i] = IROUND(data[i]);
}
}
break;
@@ -720,14 +719,14 @@ _mesa_GetMapiv( GLenum target, GLenum query, GLint *v )
break;
case GL_DOMAIN:
if (map1d) {
- v[0] = ROUNDF(map1d->u1);
- v[1] = ROUNDF(map1d->u2);
+ v[0] = IROUND(map1d->u1);
+ v[1] = IROUND(map1d->u2);
}
else {
- v[0] = ROUNDF(map2d->u1);
- v[1] = ROUNDF(map2d->u2);
- v[2] = ROUNDF(map2d->v1);
- v[3] = ROUNDF(map2d->v2);
+ v[0] = IROUND(map2d->u1);
+ v[1] = IROUND(map2d->u2);
+ v[2] = IROUND(map2d->v1);
+ v[3] = IROUND(map2d->v2);
}
break;
default:
diff --git a/src/mesa/main/feedback.c b/src/mesa/main/feedback.c
index 330fd7d2be..6bd336b5f7 100644
--- a/src/mesa/main/feedback.c
+++ b/src/mesa/main/feedback.c
@@ -1,10 +1,10 @@
-/* $Id: feedback.c,v 1.27 2002/10/24 23:57:20 brianp Exp $ */
+/* $Id: feedback.c,v 1.28 2003/03/01 01:50:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -31,7 +31,6 @@
#include "enums.h"
#include "feedback.h"
#include "macros.h"
-#include "mmath.h"
#include "mtypes.h"
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 011ec4d64c..54f2832846 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1,4 +1,4 @@
-/* $Id: get.c,v 1.105 2003/01/26 14:37:16 brianp Exp $ */
+/* $Id: get.c,v 1.106 2003/03/01 01:50:21 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,7 +33,6 @@
#include "extensions.h"
#include "get.h"
#include "macros.h"
-#include "mmath.h"
#include "mtypes.h"
#include "texcompress.h"
#include "math/m_matrix.h"
diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h
index b27f8d2f78..c203b91598 100644
--- a/src/mesa/main/glheader.h
+++ b/src/mesa/main/glheader.h
@@ -1,10 +1,10 @@
-/* $Id: glheader.h,v 1.29 2002/10/30 19:44:41 brianp Exp $ */
+/* $Id: glheader.h,v 1.30 2003/03/01 01:50:21 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 5.0
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -35,11 +35,10 @@
* Other Mesa source files should _not_ directly include any system
* headers. This allows Mesa to be integrated into XFree86 and
* allows system-dependent hacks/work-arounds to be collected in one place.
+ * XXX actually, a lot of system-dependent stuff is now in imports.[ch].
*
* If you touch this file, everything gets recompiled!
*
- * This file should be included before any other header in the .c files.
- *
* Put compiler/OS/assembly pragmas and macros here to avoid
* cluttering other source files.
*/
diff --git a/src/mesa/main/histogram.c b/src/mesa/main/histogram.c
index 134463956e..2eca44f02f 100644
--- a/src/mesa/main/histogram.c
+++ b/src/mesa/main/histogram.c
@@ -1,10 +1,10 @@
-/* $Id: histogram.c,v 1.11 2002/10/24 23:57:21 brianp Exp $ */
+/* $Id: histogram.c,v 1.12 2003/03/01 01:50:21 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 5.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -30,7 +30,6 @@
#include "context.h"
#include "image.h"
#include "histogram.h"
-#include "mmath.h"
/*
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 3830b0318e..b36c804e53 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1,10 +1,10 @@
-/* $Id: image.c,v 1.69 2002/10/24 23:57:21 brianp Exp $ */
+/* $Id: image.c,v 1.70 2003/03/01 01:50:21 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -31,11 +31,16 @@
#include "imports.h"
#include "histogram.h"
#include "macros.h"
-#include "mmath.h"
#include "pixel.h"
#include "mtypes.h"
+
+/* Compute ceiling of integer quotient of A divided by B: */
+#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
+
+
+
/*
* These are the image packing parameters for Mesa's internal images.
* That is, _mesa_unpack_image() returns image data in this format.
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 80bee830da..e9d579e764 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -1,10 +1,10 @@
-/* $Id: imports.c,v 1.31 2003/02/08 15:56:34 brianp Exp $ */
+/* $Id: imports.c,v 1.32 2003/03/01 01:50:21 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -46,10 +46,8 @@
*/
-#include "glheader.h"
-#include "mtypes.h"
-#include "context.h"
#include "imports.h"
+#include "context.h"
#define MAXSTRING 4000 /* for vsnprintf() */
@@ -73,6 +71,11 @@ extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg);
* rand and RAND_MAX
*/
+
+/**********************************************************************
+ * Memory
+ */
+
void *
_mesa_malloc(size_t bytes)
{
@@ -224,6 +227,10 @@ _mesa_bzero( void *dst, size_t n )
}
+/**********************************************************************
+ * Math
+ */
+
double
_mesa_sin(double a)
{
@@ -247,7 +254,7 @@ _mesa_cos(double a)
double
-_mesa_sqrt(double x)
+_mesa_sqrtd(double x)
{
#if defined(XFree86LOADER) && defined(IN_MODULE)
return xf86sqrt(x);
@@ -257,6 +264,95 @@ _mesa_sqrt(double x)
}
+/*
+ * A High Speed, Low Precision Square Root
+ * by Paul Lalonde and Robert Dawson
+ * from "Graphics Gems", Academic Press, 1990
+ *
+ * SPARC implementation of a fast square root by table
+ * lookup.
+ * SPARC floating point format is as follows:
+ *
+ * BIT 31 30 23 22 0
+ * sign exponent mantissa
+ */
+static short sqrttab[0x100]; /* declare table of square roots */
+
+static void init_sqrt_table(void)
+{
+#if defined(USE_IEEE) && !defined(DEBUG)
+ unsigned short i;
+ fi_type fi; /* to access the bits of a float in C quickly */
+ /* we use a union defined in glheader.h */
+
+ for(i=0; i<= 0x7f; i++) {
+ fi.i = 0;
+
+ /*
+ * Build a float with the bit pattern i as mantissa
+ * and an exponent of 0, stored as 127
+ */
+
+ fi.i = (i << 16) | (127 << 23);
+ fi.f = _mesa_sqrtd(fi.f);
+
+ /*
+ * Take the square root then strip the first 7 bits of
+ * the mantissa into the table
+ */
+
+ sqrttab[i] = (fi.i & 0x7fffff) >> 16;
+
+ /*
+ * Repeat the process, this time with an exponent of
+ * 1, stored as 128
+ */
+
+ fi.i = 0;
+ fi.i = (i << 16) | (128 << 23);
+ fi.f = sqrt(fi.f);
+ sqrttab[i+0x80] = (fi.i & 0x7fffff) >> 16;
+ }
+#else
+ (void) sqrttab; /* silence compiler warnings */
+#endif /*HAVE_FAST_MATH*/
+}
+
+
+float
+_mesa_sqrtf( float x )
+{
+#if defined(USE_IEEE) && !defined(DEBUG)
+ fi_type num;
+ /* to access the bits of a float in C
+ * we use a union from glheader.h */
+
+ short e; /* the exponent */
+ if (x == 0.0F) return 0.0F; /* check for square root of 0 */
+ num.f = x;
+ e = (num.i >> 23) - 127; /* get the exponent - on a SPARC the */
+ /* exponent is stored with 127 added */
+ num.i &= 0x7fffff; /* leave only the mantissa */
+ if (e & 0x01) num.i |= 0x800000;
+ /* the exponent is odd so we have to */
+ /* look it up in the second half of */
+ /* the lookup table, so we set the */
+ /* high bit */
+ e >>= 1; /* divide the exponent by two */
+ /* note that in C the shift */
+ /* operators are sign preserving */
+ /* for signed operands */
+ /* Do the table lookup, based on the quaternary mantissa,
+ * then reconstruct the result back into a float
+ */
+ num.i = ((sqrttab[num.i >> 16]) << 16) | ((e + 127) << 23);
+ return num.f;
+#else
+ return (float) _mesa_sqrtd((double) x);
+#endif
+}
+
+
double
_mesa_pow(double x, double y)
{
@@ -268,6 +364,25 @@ _mesa_pow(double x, double y)
}
+/*
+ * Return number of bits set in given GLuint.
+ */
+unsigned int
+_mesa_bitcount(unsigned int n)
+{
+ unsigned int bits;
+ for (bits = 0; n > 0; n = n >> 1) {
+ bits += (n & 1);
+ }
+ return bits;
+}
+
+
+
+/**********************************************************************
+ * Environment vars
+ */
+
char *
_mesa_getenv( const char *var )
{
@@ -279,6 +394,10 @@ _mesa_getenv( const char *var )
}
+/**********************************************************************
+ * String
+ */
+
char *
_mesa_strstr( const char *haystack, const char *needle )
{
@@ -389,6 +508,10 @@ _mesa_strtod( const char *s, char **end )
}
+/**********************************************************************
+ * I/O
+ */
+
int
_mesa_sprintf( char *str, const char *fmt, ... )
{
@@ -421,6 +544,10 @@ _mesa_printf( const char *fmtString, ... )
}
+/**********************************************************************
+ * Diagnostics
+ */
+
void
_mesa_warning( GLcontext *ctx, const char *fmtString, ... )
{
@@ -673,12 +800,34 @@ default_GetDrawablePrivate(__GLcontext *gc)
/*
* Initialize a __GLimports object to point to the functions in
* this file. This is to be called from device drivers.
+ * Also, do some one-time initializations.
* Input: imports - the object to init
* driverCtx - pointer to device driver-specific data
*/
void
_mesa_init_default_imports(__GLimports *imports, void *driverCtx)
{
+ /* XXX maybe move this one-time init stuff into context.c */
+ static GLboolean initialized = GL_FALSE;
+ if (!initialized) {
+ init_sqrt_table();
+
+#if defined(_FPU_GETCW) && defined(_FPU_SETCW)
+ {
+ const char *debug = _mesa_getenv("MESA_DEBUG");
+ if (debug && _mesa_strcmp(debug, "FP")==0) {
+ /* die on FP exceptions */
+ fpu_control_t mask;
+ _FPU_GETCW(mask);
+ mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM
+ | _FPU_MASK_OM | _FPU_MASK_UM);
+ _FPU_SETCW(mask);
+ }
+ }
+#endif
+ initialized = GL_TRUE;
+ }
+
imports->malloc = default_malloc;
imports->calloc = default_calloc;
imports->realloc = default_realloc;
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 8ebc982172..741cdbf519 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -1,10 +1,10 @@
-/* $Id: imports.h,v 1.12 2003/02/08 15:56:34 brianp Exp $ */
+/* $Id: imports.h,v 1.13 2003/03/01 01:50:21 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -35,6 +35,25 @@
#define IMPORTS_H
+/* XXX some of the stuff in glheader.h should be moved into this file.
+ */
+#include "glheader.h"
+
+
+/**********************************************************************
+ * General macros
+ */
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+
+
+/**********************************************************************
+ * Memory macros
+ */
+
#define MALLOC(BYTES) _mesa_malloc(BYTES)
#define CALLOC(BYTES) _mesa_calloc(BYTES)
#define MALLOC_STRUCT(T) (struct T *) _mesa_malloc(sizeof(struct T))
@@ -99,6 +118,428 @@ extern void _ext_mesa_free_pixelbuffer( void *pb );
#endif
+
+/**********************************************************************
+ * Math macros
+ */
+
+#define MAX_GLUSHORT 0xffff
+#define MAX_GLUINT 0xffffffff
+
+#ifndef M_PI
+#define M_PI (3.1415926)
+#endif
+
+/* Degrees to radians conversion: */
+#define DEG2RAD (M_PI/180.0)
+
+
+/***
+ *** USE_IEEE: Determine if we're using IEEE floating point
+ ***/
+#if defined(__i386__) || defined(__sparc__) || defined(__s390x__) || \
+ defined(__powerpc__) || \
+ ( defined(__alpha__) && ( defined(__IEEE_FLOAT) || !defined(VMS) ) )
+#define USE_IEEE
+#define IEEE_ONE 0x3f800000
+#endif
+
+
+/***
+ *** SQRTF: single-precision square root
+ ***/
+#ifdef DEBUG
+# define SQRTF(X) ((float)_mesa_sqrtd((float) X))
+#elif defined(__WATCOMC__) && defined(USE_X86_ASM)
+float asm_sqrt (float x);
+#pragma aux asm_sqrt = \
+ "fsqrt" \
+ parm [8087] \
+ value [8087] \
+ modify exact [];
+# define SQRTF(X) asm_sqrt(X)
+#else
+# define SQRTF(X) _mesa_sqrtf(X)
+#endif
+
+
+/***
+ *** LOG2: Log base 2 of float
+ ***/
+#ifdef USE_IEEE
+#if 0
+/* This is pretty fast, but not accurate enough (only 2 fractional bits).
+ * Based on code from http://www.stereopsis.com/log2.html
+ */
+static INLINE GLfloat LOG2(GLfloat x)
+{
+ const GLfloat y = x * x * x * x;
+ const GLuint ix = *((GLuint *) &y);
+ const GLuint exp = (ix >> 23) & 0xFF;
+ const GLint log2 = ((GLint) exp) - 127;
+ return (GLfloat) log2 * (1.0 / 4.0); /* 4, because of x^4 above */
+}
+#endif
+/* Pretty fast, and accurate.
+ * Based on code from http://www.flipcode.com/totd/
+ */
+static INLINE GLfloat LOG2(GLfloat val)
+{
+ GLint *exp_ptr = (GLint *) &val;
+ GLint x = *exp_ptr;
+ const GLint log_2 = ((x >> 23) & 255) - 128;
+ x &= ~(255 << 23);
+ x += 127 << 23;
+ *exp_ptr = x;
+ val = ((-1.0f/3) * val + 2) * val - 2.0f/3;
+ return val + log_2;
+}
+#elif defined(XFree86LOADER) && defined(IN_MODULE)
+#define LOG2(x) ((GLfloat) (xf86log(x) * 1.442695))
+#else
+/*
+ * NOTE: log_base_2(x) = log(x) / log(2)
+ * NOTE: 1.442695 = 1/log(2).
+ */
+#define LOG2(x) ((GLfloat) (log(x) * 1.442695F))
+#endif
+
+
+/***
+ *** IS_INF_OR_NAN: test if float is infinite or NaN
+ ***/
+#ifdef USE_IEEE
+static INLINE int IS_INF_OR_NAN( float x )
+{
+ fi_type tmp;
+ tmp.f = x;
+ return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31);
+}
+#elif defined(isfinite)
+#define IS_INF_OR_NAN(x) (!isfinite(x))
+#elif defined(finite)
+#define IS_INF_OR_NAN(x) (!finite(x))
+#elif __VMS
+#define IS_INF_OR_NAN(x) (!finite(x))
+#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#define IS_INF_OR_NAN(x) (!isfinite(x))
+#else
+#define IS_INF_OR_NAN(x) (!finite(x))
+#endif
+
+
+/***
+ *** IS_NEGATIVE: test if float is negative
+ ***/
+#if defined(USE_IEEE)
+#define GET_FLOAT_BITS(x) ((fi_type *) &(x))->i
+#define IS_NEGATIVE(x) (GET_FLOAT_BITS(x) & (1<<31))
+#else
+#define IS_NEGATIVE(x) (x < 0.0F)
+#endif
+
+
+/***
+ *** DIFFERENT_SIGNS: test if two floats have opposite signs
+ ***/
+#if defined(USE_IEEE)
+#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31))
+#else
+/* Could just use (x*y<0) except for the flatshading requirements.
+ * Maybe there's a better way?
+ */
+#define DIFFERENT_SIGNS(x,y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F)
+#endif
+
+
+/***
+ *** CEILF: ceiling of float
+ *** FLOORF: floor of float
+ *** FABSF: absolute value of float
+ ***/
+#if defined(__sparc__) || defined(__NeXT__) /* XXX improve? */
+#define CEILF(x) ceil(x)
+#define FLOORF(x) floor(x)
+#define FABSF(x) fabs(x)
+#elif defined(__WIN32__) || defined(__IBMC__) || defined(__IBMCPP__)
+#define CEILF(x) ((GLfloat) ceil(x))
+#define FLOORF(x) ((GLfloat) floor(x))
+#define FABSF(x) ((GLfloat) fabs(x))
+#elif defined(XFree86LOADER) && defined(IN_MODULE)
+#define CEILF(x) ((GLfloat) xf86ceil(x))
+#define FLOORF(x) ((GLfloat) xf86floor(x))
+#define FABSF(x) ((GLfloat) xf86fabs(x))
+#else
+#define CEILF(x) ceilf(x)
+#define FLOORF(x) floorf(x)
+#define FABSF(x) fabsf(x)
+#endif
+
+
+/***
+ *** IROUND: return (as an integer) float rounded to nearest integer
+ ***/
+#if defined(USE_SPARC_ASM) && defined(__GNUC__) && defined(__sparc__)
+static INLINE int iround(float f)
+{
+ int r;
+ __asm__ ("fstoi %1, %0" : "=f" (r) : "f" (f));
+ return r;
+}
+#define IROUND(x) iround(x)
+#elif defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
+static INLINE int iround(float f)
+{
+ int r;
+ __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
+ return r;
+}
+#define IROUND(x) iround(x)
+#elif defined(USE_X86_ASM) && defined(__MSC__) && defined(__WIN32__)
+static INLINE int iround(float f)
+{
+ int r;
+ _asm {
+ fld f
+ fistp r
+ }
+ return r;
+}
+#define IROUND(x) iround(x)
+#elif defined(USE_X86_ASM) && defined(__WATCOMC__)
+long iround(float f);
+#pragma aux iround = \
+ "push eax" \
+ "fistp dword ptr [esp]" \
+ "pop eax" \
+ parm [8087] \
+ value [eax] \
+ modify exact [eax];
+
+#define IROUND(x) iround(x)
+#else
+#define IROUND(f) ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F)))
+#endif
+
+
+/***
+ *** IROUND_POS: return (as an integer) positive float rounded to nearest int
+ ***/
+#ifdef DEBUG
+#define IROUND_POS(f) (assert((f) >= 0.0F), IROUND(f))
+#else
+#define IROUND_POS(f) (IROUND(f))
+#endif
+
+
+/***
+ *** IFLOOR: return (as an integer) floor of float
+ ***/
+#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
+/*
+ * IEEE floor for computers that round to nearest or even.
+ * 'f' must be between -4194304 and 4194303.
+ * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1",
+ * but uses some IEEE specific tricks for better speed.
+ * Contributed by Josh Vanderhoof
+ */
+static INLINE int ifloor(float f)
+{
+ int ai, bi;
+ double af, bf;
+ af = (3 << 22) + 0.5 + (double)f;
+ bf = (3 << 22) + 0.5 - (double)f;
+ /* GCC generates an extra fstp/fld without this. */
+ __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
+ __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
+ return (ai - bi) >> 1;
+}
+#define IFLOOR(x) ifloor(x)
+#elif defined(USE_IEEE)
+static INLINE int ifloor(float f)
+{
+ int ai, bi;
+ double af, bf;
+ fi_type u;
+
+ af = (3 << 22) + 0.5 + (double)f;
+ bf = (3 << 22) + 0.5 - (double)f;
+ u.f = af; ai = u.i;
+ u.f = bf; bi = u.i;
+ return (ai - bi) >> 1;
+}
+#define IFLOOR(x) ifloor(x)
+#else
+static INLINE int ifloor(float f)
+{
+ int i = IROUND(f);
+ return (i > f) ? i - 1 : i;
+}
+#define IFLOOR(x) ifloor(x)
+#endif
+
+
+/***
+ *** ICEIL: return (as an integer) ceiling of float
+ ***/
+#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
+/*
+ * IEEE ceil for computers that round to nearest or even.
+ * 'f' must be between -4194304 and 4194303.
+ * This ceil operation is done by "(iround(f + .5) + iround(f - .5) + 1) >> 1",
+ * but uses some IEEE specific tricks for better speed.
+ * Contributed by Josh Vanderhoof
+ */
+static INLINE int iceil(float f)
+{
+ int ai, bi;
+ double af, bf;
+ af = (3 << 22) + 0.5 + (double)f;
+ bf = (3 << 22) + 0.5 - (double)f;
+ /* GCC generates an extra fstp/fld without this. */
+ __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
+ __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
+ return (ai - bi + 1) >> 1;
+}
+#define ICEIL(x) iceil(x)
+#elif defined(USE_IEEE)
+static INLINE int iceil(float f)
+{
+ int ai, bi;
+ double af, bf;
+ fi_type u;
+ af = (3 << 22) + 0.5 + (double)f;
+ bf = (3 << 22) + 0.5 - (double)f;
+ u.f = af; ai = u.i;
+ u.f = bf; bi = u.i;
+ return (ai - bi + 1) >> 1;
+}
+#define ICEIL(x) iceil(x)
+#else
+static INLINE int iceil(float f)
+{
+ int i = IROUND(f);
+ return (i < f) ? i + 1 : i;
+}
+#define ICEIL(x) iceil(x)
+#endif
+
+
+/***
+ *** UNCLAMPED_FLOAT_TO_UBYTE: map float from {0,1} to ubyte in [0,255]
+ *** CLAMPED_FLOAT_TO_UBYTE: map float in [0,1] to ubyte in [0,255]
+ ***/
+#if defined(USE_IEEE) && !defined(DEBUG)
+#define IEEE_0996 0x3f7f0000 /* 0.996 or so */
+/* This function/macro is sensitive to precision. Test very carefully
+ * if you change it!
+ */
+#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \
+ do { \
+ fi_type __tmp; \
+ __tmp.f = (F); \
+ UB = ((__tmp.i >= IEEE_0996) \
+ ? ((GLint)__tmp.i < 0) ? (GLubyte)0 : (GLubyte)255 \
+ : (__tmp.f = __tmp.f*(255.0F/256.0F) + 32768.0F, \
+ (GLubyte)__tmp.i)); \
+ } while (0)
+#define CLAMPED_FLOAT_TO_UBYTE(ub, f) \
+ UNCLAMPED_FLOAT_TO_UBYTE(ub, f)
+#else
+#define UNCLAMPED_FLOAT_TO_UBYTE(ub, f) \
+ ub = ((GLubyte) IROUND(CLAMP((f), 0.0F, 1.0F) * 255.0F))
+#define CLAMPED_FLOAT_TO_UBYTE(ub, f) \
+ ub = ((GLubyte) IROUND((f) * 255.0F))
+#endif
+
+
+/***
+ *** COPY_FLOAT: copy a float from src to dest, avoid slow FP regs if possible
+ ***/
+#if defined(USE_IEEE) && !defined(DEBUG)
+#define COPY_FLOAT( dst, src ) \
+ ((fi_type *) &(dst))->i = ((fi_type *) &(src))->i
+#else
+#define COPY_FLOAT( dst, src ) (dst) = (src)
+#endif
+
+
+/***
+ *** START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save
+ *** original mode to a temporary).
+ *** END_FAST_MATH: Restore x86 FPU to original mode.
+ ***/
+#if defined(__GNUC__) && defined(__i386__)
+/*
+ * Set the x86 FPU control word to guarentee only 32 bits of precision
+ * are stored in registers. Allowing the FPU to store more introduces
+ * differences between situations where numbers are pulled out of memory
+ * vs. situations where the compiler is able to optimize register usage.
+ *
+ * In the worst case, we force the compiler to use a memory access to
+ * truncate the float, by specifying the 'volatile' keyword.
+ */
+/* Hardware default: All exceptions masked, extended double precision,
+ * round to nearest (IEEE compliant):
+ */
+#define DEFAULT_X86_FPU 0x037f
+/* All exceptions masked, single precision, round to nearest:
+ */
+#define FAST_X86_FPU 0x003f
+/* The fldcw instruction will cause any pending FP exceptions to be
+ * raised prior to entering the block, and we clear any pending
+ * exceptions before exiting the block. Hence, asm code has free
+ * reign over the FPU while in the fast math block.
+ */
+#if defined(NO_FAST_MATH)
+#define START_FAST_MATH(x) \
+do { \
+ static GLuint mask = DEFAULT_X86_FPU; \
+ __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \
+ __asm__ ( "fldcw %0" : : "m" (mask) ); \
+} while (0)
+#else
+#define START_FAST_MATH(x) \
+do { \
+ static GLuint mask = FAST_X86_FPU; \
+ __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \
+ __asm__ ( "fldcw %0" : : "m" (mask) ); \
+} while (0)
+#endif
+/* Restore original FPU mode, and clear any exceptions that may have
+ * occurred in the FAST_MATH block.
+ */
+#define END_FAST_MATH(x) \
+do { \
+ __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \
+} while (0)
+
+#elif defined(__WATCOMC__) && !defined(NO_FAST_MATH)
+void _wacom_start_fast_math(unsigned short *x);
+#pragma aux _wacom_start_fast_math = \
+ "fstcw word ptr [esi]" \
+ "or word ptr [esi], 0x3f" \
+ "fldcw word ptr [esi]" \
+ parm [esi] \
+ modify exact [];
+void _wacom_end_fast_math(unsigned short *x);
+#pragma aux _wacom_end_fast_math = \
+ "fldcw word ptr [esi]" \
+ parm [esi] \
+ modify exact [];
+#define START_FAST_MATH(x) _wacom_start_fast_math(& x)
+#define END_FAST_MATH(x) _wacom_end_fast_math(& x)
+#else
+#define START_FAST_MATH(x) x = 0
+#define END_FAST_MATH(x) (void)(x)
+#endif
+
+
+
+/**********************************************************************
+ * Functions
+ */
+
extern void *
_mesa_malloc( size_t bytes );
@@ -137,11 +578,20 @@ extern double
_mesa_cos(double a);
extern double
-_mesa_sqrt(double x);
+_mesa_sqrtd(double x);
+
+extern float
+_mesa_sqrtf(float x);
extern double
_mesa_pow(double x, double y);
+extern float
+_mesa_log2(float x);
+
+extern unsigned int
+_mesa_bitcount(unsigned int n);
+
extern char *
_mesa_getenv( const char *var );
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 201938d4aa..c7fa7018d3 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -1,10 +1,10 @@
-/* $Id: light.c,v 1.54 2002/10/25 21:06:29 brianp Exp $ */
+/* $Id: light.c,v 1.55 2003/03/01 01:50:21 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -32,7 +32,6 @@
#include "enums.h"
#include "light.h"
#include "macros.h"
-#include "mmath.h"
#include "simple_list.h"
#include "mtypes.h"
#include "math/m_xform.h"
@@ -963,12 +962,12 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[3] );
break;
case GL_SHININESS:
- *params = ROUNDF( ctx->Light.Material[f].Shininess );
+ *params = IROUND( ctx->Light.Material[f].Shininess );
break;
case GL_COLOR_INDEXES:
- params[0] = ROUNDF( ctx->Light.Material[f].AmbientIndex );
- params[1] = ROUNDF( ctx->Light.Material[f].DiffuseIndex );
- params[2] = ROUNDF( ctx->Light.Material[f].SpecularIndex );
+ params[0] = IROUND( ctx->Light.Material[f].AmbientIndex );
+ params[1] = IROUND( ctx->Light.Material[f].DiffuseIndex );
+ params[2] = IROUND( ctx->Light.Material[f].SpecularIndex );
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" );
diff --git a/src/mesa/main/lines.c b/src/mesa/main/lines.c
index 0a33e1399e..821b17e0b5 100644
--- a/src/mesa/main/lines.c
+++ b/src/mesa/main/lines.c
@@ -1,10 +1,10 @@
-/* $Id: lines.c,v 1.30 2002/10/24 23:57:21 brianp Exp $ */
+/* $Id: lines.c,v 1.31 2003/03/01 01:50:21 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 5.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -30,7 +30,6 @@
#include "depth.h"
#include "lines.h"
#include "macros.h"
-#include "mmath.h"
#include "texstate.h"
#include "mtypes.h"
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index 4fc93936ac..0be9510995 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -1,4 +1,4 @@
-/* $Id: macros.h,v 1.30 2002/10/18 17:02:00 kschultz Exp $ */
+/* $Id: macros.h,v 1.31 2003/03/01 01:50:21 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -29,34 +29,79 @@
* A collection of useful macros.
*/
-
#ifndef MACROS_H
#define MACROS_H
+#include "imports.h"
+
-#include "glheader.h"
-/* Do not reference mtypes.h from this file.
+/*
+ * Integer / float conversion for colors, normals, etc.
*/
+/* Convert GLubyte in [0,255] to GLfloat in [0.0,1.0] */
+extern GLfloat _mesa_ubyte_to_float_color_tab[256];
+#define UBYTE_TO_FLOAT(u) _mesa_ubyte_to_float_color_tab[(unsigned int)(u)]
-/* Limits: */
-#define MAX_GLUSHORT 0xffff
-#define MAX_GLUINT 0xffffffff
+/* Convert GLfloat in [0.0,1.0] to GLubyte in [0,255] */
+#define FLOAT_TO_UBYTE(X) ((GLubyte) (GLint) ((X) * 255.0F))
-/* Pi */
-#ifndef M_PI
-#define M_PI (3.1415926)
-#endif
+/* Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0] */
+#define BYTE_TO_FLOAT(B) ((2.0F * (B) + 1.0F) * (1.0F/255.0F))
+/* Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127] */
+#define FLOAT_TO_BYTE(X) ( (((GLint) (255.0F * (X))) - 1) / 2 )
-/* Degrees to radians conversion: */
-#define DEG2RAD (M_PI/180.0)
+/* Convert GLushort in [0,65536] to GLfloat in [0.0,1.0] */
+#define USHORT_TO_FLOAT(S) ((GLfloat) (S) * (1.0F / 65535.0F))
-#ifndef NULL
-#define NULL 0
-#endif
+/* Convert GLfloat in [0.0,1.0] to GLushort in [0,65536] */
+#define FLOAT_TO_USHORT(X) ((GLushort) (GLint) ((X) * 65535.0F))
+
+
+/* Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0] */
+#define SHORT_TO_FLOAT(S) ((2.0F * (S) + 1.0F) * (1.0F/65535.0F))
+
+/* Convert GLfloat in [0.0,1.0] to GLshort in [-32768,32767] */
+#define FLOAT_TO_SHORT(X) ( (((GLint) (65535.0F * (X))) - 1) / 2 )
+
+
+/* Convert GLuint in [0,4294967295] to GLfloat in [0.0,1.0] */
+#define UINT_TO_FLOAT(U) ((GLfloat) (U) * (1.0F / 4294967295.0F))
+
+/* Convert GLfloat in [0.0,1.0] to GLuint in [0,4294967295] */
+#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0))
+
+
+/* Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0] */
+#define INT_TO_FLOAT(I) ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0F))
+
+/* Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647] */
+/* causes overflow:
+#define FLOAT_TO_INT(X) ( (((GLint) (4294967294.0F * (X))) - 1) / 2 )
+*/
+/* a close approximation: */
+#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) )
+
+
+#define BYTE_TO_UBYTE(b) ((GLubyte) ((b) < 0 ? 0 : (GLubyte) (b)))
+#define SHORT_TO_UBYTE(s) ((GLubyte) ((s) < 0 ? 0 : (GLubyte) ((s) >> 7)))
+#define USHORT_TO_UBYTE(s) ((GLubyte) ((s) >> 8))
+#define INT_TO_UBYTE(i) ((GLubyte) ((i) < 0 ? 0 : (GLubyte) ((i) >> 23)))
+#define UINT_TO_UBYTE(i) ((GLubyte) ((i) >> 24))
+
+
+#define BYTE_TO_USHORT(b) ((b) < 0 ? 0 : ((GLushort) (((b) * 65535) / 255)))
+#define UBYTE_TO_USHORT(b) (((GLushort) (b) << 8) | (GLushort) (b))
+#define SHORT_TO_USHORT(s) ((s) < 0 ? 0 : ((GLushort) (((s) * 65535 / 32767))))
+#define INT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 15)))
+#define UINT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 16)))
+#define UNCLAMPED_FLOAT_TO_USHORT(us, f) \
+ us = ( (GLushort) IROUND( CLAMP((f), 0.0, 1.0) * 65535.0F) )
+#define CLAMPED_FLOAT_TO_USHORT(us, f) \
+ us = ( (GLushort) IROUND( (f) * 65535.0F) )
/* Stepping a GLfloat pointer by a byte stride
@@ -389,6 +434,79 @@ do { \
+/*
+ * Linear interpolation
+ * NOTE: OUT argument is evaluated twice!
+ * NOTE: Be wary of using *coord++ as an argument to any of these macros!
+ */
+#define LINTERP(T, OUT, IN) ((OUT) + (T) * ((IN) - (OUT)))
+
+/* Can do better with integer math:
+ */
+#define INTERP_UB( t, dstub, outub, inub ) \
+do { \
+ GLfloat inf = UBYTE_TO_FLOAT( inub ); \
+ GLfloat outf = UBYTE_TO_FLOAT( outub ); \
+ GLfloat dstf = LINTERP( t, outf, inf ); \
+ UNCLAMPED_FLOAT_TO_UBYTE( dstub, dstf ); \
+} while (0)
+
+#define INTERP_CHAN( t, dstc, outc, inc ) \
+do { \
+ GLfloat inf = CHAN_TO_FLOAT( inc ); \
+ GLfloat outf = CHAN_TO_FLOAT( outc ); \
+ GLfloat dstf = LINTERP( t, outf, inf ); \
+ UNCLAMPED_FLOAT_TO_CHAN( dstc, dstf ); \
+} while (0)
+
+#define INTERP_UI( t, dstui, outui, inui ) \
+ dstui = (GLuint) (GLint) LINTERP( (t), (GLfloat) (outui), (GLfloat) (inui) )
+
+#define INTERP_F( t, dstf, outf, inf ) \
+ dstf = LINTERP( t, outf, inf )
+
+#define INTERP_4F( t, dst, out, in ) \
+do { \
+ dst[0] = LINTERP( (t), (out)[0], (in)[0] ); \
+ dst[1] = LINTERP( (t), (out)[1], (in)[1] ); \
+ dst[2] = LINTERP( (t), (out)[2], (in)[2] ); \
+ dst[3] = LINTERP( (t), (out)[3], (in)[3] ); \
+} while (0)
+
+#define INTERP_3F( t, dst, out, in ) \
+do { \
+ dst[0] = LINTERP( (t), (out)[0], (in)[0] ); \
+ dst[1] = LINTERP( (t), (out)[1], (in)[1] ); \
+ dst[2] = LINTERP( (t), (out)[2], (in)[2] ); \
+} while (0)
+
+#define INTERP_4CHAN( t, dst, out, in ) \
+do { \
+ INTERP_CHAN( (t), (dst)[0], (out)[0], (in)[0] ); \
+ INTERP_CHAN( (t), (dst)[1], (out)[1], (in)[1] ); \
+ INTERP_CHAN( (t), (dst)[2], (out)[2], (in)[2] ); \
+ INTERP_CHAN( (t), (dst)[3], (out)[3], (in)[3] ); \
+} while (0)
+
+#define INTERP_3CHAN( t, dst, out, in ) \
+do { \
+ INTERP_CHAN( (t), (dst)[0], (out)[0], (in)[0] ); \
+ INTERP_CHAN( (t), (dst)[1], (out)[1], (in)[1] ); \
+ INTERP_CHAN( (t), (dst)[2], (out)[2], (in)[2] ); \
+} while (0)
+
+#define INTERP_SZ( t, vec, to, out, in, sz ) \
+do { \
+ switch (sz) { \
+ case 4: vec[to][3] = LINTERP( (t), (vec)[out][3], (vec)[in][3] ); \
+ case 3: vec[to][2] = LINTERP( (t), (vec)[out][2], (vec)[in][2] ); \
+ case 2: vec[to][1] = LINTERP( (t), (vec)[out][1], (vec)[in][1] ); \
+ case 1: vec[to][0] = LINTERP( (t), (vec)[out][0], (vec)[in][0] ); \
+ } \
+} while(0)
+
+
+
/* Assign scalers to short vectors: */
#define ASSIGN_2V( V, V0, V1 ) \
do { \
@@ -413,22 +531,6 @@ do { \
-
-/* Absolute value (for Int, Float, Double): */
-#define ABSI(X) ((X) < 0 ? -(X) : (X))
-#define ABSF(X) ((X) < 0.0F ? -(X) : (X))
-#define ABSD(X) ((X) < 0.0 ? -(X) : (X))
-
-
-
-/* Round a floating-point value to the nearest integer: */
-#define ROUNDF(X) ( (X)<0.0F ? ((GLint) ((X)-0.5F)) : ((GLint) ((X)+0.5F)) )
-
-
-/* Compute ceiling of integer quotient of A divided by B: */
-#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
-
-
/* Clamp X to [MIN,MAX]: */
#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
@@ -465,63 +567,24 @@ do { \
} while (0)
+/* Normalize a 3-element vector to unit length. */
+#define NORMALIZE_3FV( V ) \
+do { \
+ GLfloat len = (GLfloat) LEN_SQUARED_3FV(V); \
+ if (len) { \
+ len = (GLfloat) (1.0 / SQRTF(len)); \
+ (V)[0] = (GLfloat) ((V)[0] * len); \
+ (V)[1] = (GLfloat) ((V)[1] * len); \
+ (V)[2] = (GLfloat) ((V)[2] * len); \
+ } \
+} while(0)
-/* Generic color packing macros
- * XXX We may move these into texutil.h at some point.
- */
-
-#define PACK_COLOR_8888( a, b, c, d ) \
- (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
-
-#define PACK_COLOR_888( a, b, c ) \
- (((a) << 16) | ((b) << 8) | (c))
-
-#define PACK_COLOR_565( a, b, c ) \
- ((((a) & 0xf8) << 8) | (((b) & 0xfc) << 3) | (((c) & 0xf8) >> 3))
-
-#define PACK_COLOR_1555( a, b, c, d ) \
- ((((b) & 0xf8) << 7) | (((c) & 0xf8) << 2) | (((d) & 0xf8) >> 3) | \
- ((a) ? 0x8000 : 0))
-
-#define PACK_COLOR_4444( a, b, c, d ) \
- ((((a) & 0xf0) << 8) | (((b) & 0xf0) << 4) | ((c) & 0xf0) | ((d) >> 4))
-
-#define PACK_COLOR_88( a, b ) \
- (((a) << 8) | (b))
-
-#define PACK_COLOR_332( a, b, c ) \
- (((a) & 0xe0) | (((b) & 0xe0) >> 3) | (((c) & 0xc0) >> 6))
-
-
-#ifdef MESA_BIG_ENDIAN
-
-#define PACK_COLOR_8888_LE( a, b, c, d ) PACK_COLOR_8888( d, c, b, a )
-
-#define PACK_COLOR_565_LE( a, b, c ) \
- (((a) & 0xf8) | (((b) & 0xe0) >> 5) | (((b) & 0x1c) << 11) | \
- (((c) & 0xf8) << 5))
-
-#define PACK_COLOR_1555_LE( a, b, c, d ) \
- ((((b) & 0xf8) >> 1) | (((c) & 0xc0) >> 6) | (((c) & 0x38) << 10) | \
- (((d) & 0xf8) << 5) | ((a) ? 0x80 : 0))
-
-#define PACK_COLOR_4444_LE( a, b, c, d ) PACK_COLOR_4444( c, d, a, b )
-
-#define PACK_COLOR_88_LE( a, b ) PACK_COLOR_88( b, a )
-
-#else /* little endian */
-
-#define PACK_COLOR_8888_LE( a, b, c, d ) PACK_COLOR_8888( a, b, c, d )
-
-#define PACK_COLOR_565_LE( a, b, c ) PACK_COLOR_565( a, b, c )
-
-#define PACK_COLOR_1555_LE( a, b, c, d ) PACK_COLOR_1555( a, b, c, d )
-
-#define PACK_COLOR_4444_LE( a, b, c, d ) PACK_COLOR_4444( a, b, c, d )
+#define LEN_3FV( V ) (SQRTF((V)[0]*(V)[0]+(V)[1]*(V)[1]+(V)[2]*(V)[2]))
+#define LEN_2FV( V ) (SQRTF((V)[0]*(V)[0]+(V)[1]*(V)[1]))
-#define PACK_COLOR_88_LE( a, b ) PACK_COLOR_88( a, b )
+#define LEN_SQUARED_3FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1]+(V)[2]*(V)[2])
+#define LEN_SQUARED_2FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1])
-#endif /* endianness */
#endif
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index 0b5f001402..af046a3c8f 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -1,10 +1,10 @@
-/* $Id: matrix.c,v 1.45 2002/10/24 23:57:21 brianp Exp $ */
+/* $Id: matrix.c,v 1.46 2003/03/01 01:50:21 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -42,7 +42,6 @@
#include "enums.h"
#include "macros.h"
#include "matrix.h"
-#include "mmath.h"
#include "mtypes.h"
#include "math/m_matrix.h"
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 7ca6f61118..acac82bc88 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.104 2003/02/23 04:07:28 brianp Exp $ */
+/* $Id: mtypes.h,v 1.105 2003/03/01 01:50:22 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -109,6 +109,33 @@ typedef GLuint GLdepth; /* Must be 32-bits! */
* Fixed point data type:
*/
typedef int GLfixed;
+/*
+ * Fixed point arithmetic macros
+ */
+#ifdef FIXED_14
+#define FIXED_ONE 0x00004000
+#define FIXED_HALF 0x00002000
+#define FIXED_FRAC_MASK 0x00003FFF
+#define FIXED_SCALE 16384.0f
+#define FIXED_SHIFT 14
+#else
+#define FIXED_ONE 0x00000800
+#define FIXED_HALF 0x00000400
+#define FIXED_FRAC_MASK 0x000007FF
+#define FIXED_SCALE 2048.0f
+#define FIXED_SHIFT 11
+#endif
+#define FIXED_INT_MASK (~FIXED_FRAC_MASK)
+#define FIXED_EPSILON 1
+#define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
+#define IntToFixed(I) ((I) << FIXED_SHIFT)
+#define FixedToInt(X) ((X) >> FIXED_SHIFT)
+#define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT)
+#define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
+#define FixedFloor(X) ((X) & FIXED_INT_MASK)
+#define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE))
+#define PosFloatToFixed(X) FloatToFixed(X)
+#define SignedFloatToFixed(X) FloatToFixed(X)
diff --git a/src/mesa/main/nvfragparse.c b/src/mesa/main/nvfragparse.c
index 97cc9dd6bb..f7eda38cc4 100644
--- a/src/mesa/main/nvfragparse.c
+++ b/src/mesa/main/nvfragparse.c
@@ -1,4 +1,4 @@
-/* $Id: nvfragparse.c,v 1.11 2003/02/26 01:28:15 brianp Exp $ */
+/* $Id: nvfragparse.c,v 1.12 2003/03/01 01:50:22 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -36,7 +36,6 @@
#include "hash.h"
#include "imports.h"
#include "macros.h"
-#include "mmath.h"
#include "mtypes.h"
#include "nvfragprog.h"
#include "nvfragparse.h"
@@ -201,7 +200,10 @@ MatchInstruction(const GLubyte *token)
static GLboolean IsLetter(GLubyte b)
{
- return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || (b == '_');
+ return (b >= 'a' && b <= 'z') ||
+ (b >= 'A' && b <= 'Z') ||
+ (b == '_') ||
+ (b == '$');
}
@@ -264,7 +266,7 @@ GetToken(const GLubyte *str, GLubyte *token)
return i;
}
- /* punctuation */
+ /* punctuation character */
if (str[i]) {
token[0] = str[i++];
token[1] = 0;
@@ -618,6 +620,9 @@ Parse_TextureImageId(struct parse_state *parseState,
/* update record of referenced texture units */
parseState->program->TexturesUsed[*texUnit] |= (1 << *texTargetIndex);
+ if (_mesa_bitcount(parseState->program->TexturesUsed[*texUnit]) > 1) {
+ RETURN_ERROR1("Only one texture target can be used per texture unit.");
+ }
return GL_TRUE;
}
@@ -840,6 +845,9 @@ Parse_OutputReg(struct parse_state *parseState, GLint *outputRegNum)
if (_mesa_strcmp((const char *) token, OutputRegisters[j]) == 0) {
*outputRegNum = FP_OUTPUT_REG_START + j;
parseState->outputsWritten |= (1 << j);
+ if ((parseState->outputsWritten & 0x3) == 0x3) {
+ RETURN_ERROR1("Illegal to write to both o[COLR] and o[COLH]");
+ }
break;
}
}
@@ -1138,6 +1146,7 @@ Parse_InstructionSequence(struct parse_state *parseState,
GLfloat value[7]; /* yes, 7 to be safe */
if (!Parse_Identifier(parseState, id))
RETURN_ERROR;
+ /* XXX make sure id is not a reserved identifer, like R9 */
if (!Parse_String(parseState, "="))
RETURN_ERROR1("Expected =");
if (!Parse_VectorOrScalarConstant(parseState, value))
@@ -1154,6 +1163,7 @@ Parse_InstructionSequence(struct parse_state *parseState,
GLfloat value[7] = {0, 0, 0, 0, 0, 0, 0}; /* yes, to be safe */
if (!Parse_Identifier(parseState, id))
RETURN_ERROR;
+ /* XXX make sure id is not a reserved identifer, like R9 */
if (Parse_String(parseState, "=")) {
if (!Parse_VectorOrScalarConstant(parseState, value))
RETURN_ERROR;
diff --git a/src/mesa/main/nvvertexec.c b/src/mesa/main/nvvertexec.c
index 59fc9690d0..72ebcffca9 100644
--- a/src/mesa/main/nvvertexec.c
+++ b/src/mesa/main/nvvertexec.c
@@ -1,4 +1,4 @@
-/* $Id: nvvertexec.c,v 1.1 2003/01/14 04:55:46 brianp Exp $ */
+/* $Id: nvvertexec.c,v 1.2 2003/03/01 01:50:22 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -37,7 +37,6 @@
#include "mtypes.h"
#include "nvvertexec.h"
#include "nvvertprog.h"
-#include "mmath.h"
#include "math/m_matrix.h"
diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c
index f162da4b5b..9f9e3ad554 100644
--- a/src/mesa/main/points.c
+++ b/src/mesa/main/points.c
@@ -1,10 +1,10 @@
-/* $Id: points.c,v 1.34 2002/10/24 23:57:21 brianp Exp $ */
+/* $Id: points.c,v 1.35 2003/03/01 01:50:22 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -28,7 +28,6 @@
#include "glheader.h"
#include "context.h"
#include "macros.h"
-#include "mmath.h"
#include "points.h"
#include "texstate.h"
#include "mtypes.h"
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index bb03c45697..2ca7b22a9b 100644
--- a/src/mesa/main/rastpos.c
+++ b/src/mesa/main/rastpos.c
@@ -1,10 +1,10 @@
-/* $Id: rastpos.c,v 1.39 2002/10/24 23:57:21 brianp Exp $ */
+/* $Id: rastpos.c,v 1.40 2003/03/01 01:50:22 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -32,7 +32,6 @@
#include "feedback.h"
#include "light.h"
#include "macros.h"
-#include "mmath.h"
#include "rastpos.h"
#include "state.h"
#include "simple_list.h"
@@ -321,8 +320,8 @@ raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0];
else
- ctx->Current.RasterDistance = (GLfloat)
- GL_SQRT( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] );
+ ctx->Current.RasterDistance =
+ SQRTF( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] );
/* apply projection matrix: clip = Proj * eye */
TRANSFORM_POINT( clip, ctx->ProjectionMatrixStack.Top->m, eye );
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 14b62bc434..1051bda11d 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -1,10 +1,10 @@
-/* $Id: state.c,v 1.98 2003/01/14 04:55:46 brianp Exp $ */
+/* $Id: state.c,v 1.99 2003/03/01 01:50:22 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 5.0
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -51,10 +51,10 @@
#include "fog.h"
#include "hint.h"
#include "histogram.h"
+#include "imports.h"
#include "light.h"
#include "lines.h"
#include "matrix.h"
-#include "mmath.h"
#include "pixel.h"
#include "points.h"
#include "polygon.h"
@@ -601,9 +601,9 @@ update_modelview_scale( GLcontext *ctx )
GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10];
if (f < 1e-12) f = 1.0;
if (ctx->_NeedEyeCoords)
- ctx->_ModelViewInvScale = (GLfloat) (1.0/GL_SQRT(f));
+ ctx->_ModelViewInvScale = 1.0F / SQRTF(f);
else
- ctx->_ModelViewInvScale = (GLfloat) GL_SQRT(f);
+ ctx->_ModelViewInvScale = SQRTF(f);
}
}
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 0700f85d0d..c529031f9f 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -1,10 +1,10 @@
-/* $Id: texformat.c,v 1.18 2002/10/29 20:28:47 brianp Exp $ */
+/* $Id: texformat.c,v 1.19 2003/03/01 01:50:22 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 5.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -32,7 +32,6 @@
#include "context.h"
#include "image.h"
#include "imports.h"
-#include "mmath.h"
#include "mtypes.h"
#include "texformat.h"
#include "teximage.h"
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index e7a087c0f4..3397a865cd 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1,4 +1,4 @@
-/* $Id: teximage.c,v 1.125 2003/01/08 16:24:05 brianp Exp $ */
+/* $Id: teximage.c,v 1.126 2003/03/01 01:50:22 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -30,7 +30,6 @@
#include "image.h"
#include "imports.h"
#include "macros.h"
-#include "mmath.h"
#include "state.h"
#include "texcompress.h"
#include "texformat.h"
diff --git a/src/mesa/main/texutil.c b/src/mesa/main/texutil.c
index 660f7ec63f..26eda819bf 100644
--- a/src/mesa/main/texutil.c
+++ b/src/mesa/main/texutil.c
@@ -1,10 +1,10 @@
-/* $Id: texutil.c,v 1.34 2002/10/29 20:28:53 brianp Exp $ */
+/* $Id: texutil.c,v 1.35 2003/03/01 01:50:22 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -36,6 +36,7 @@
#include "glheader.h"
+#include "colormac.h"
#include "context.h"
#include "enums.h"
#include "image.h"
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 1b540eff44..889584780f 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1,10 +1,10 @@
-/* $Id: varray.c,v 1.47 2002/10/24 23:57:21 brianp Exp $ */
+/* $Id: varray.c,v 1.48 2003/03/01 01:50:22 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -31,7 +31,6 @@
#include "dlist.h"
#include "light.h"
#include "macros.h"
-#include "mmath.h"
#include "state.h"
#include "texstate.h"
#include "mtypes.h"