replace color table FloatTable boolean with Type enum
[mesa.git] / src / mesa / main / imports.h
index df0d6d771de306fcbad42fafad052f608bb7c6fd..5cdac06ba8271efb8314aef637951ecc864d2ed1 100644 (file)
@@ -8,9 +8,9 @@
 
 /*
  * Mesa 3-D graphics library
- * Version:  5.1
+ * Version:  6.0
  *
- * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2004  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"),
@@ -209,6 +209,11 @@ extern void _ext_mesa_free_pixelbuffer( void *pb );
 #define M_PI (3.1415926536)
 #endif
 
+/* XXX this is a bit of a hack needed for compilation within XFree86 */
+#ifndef FLT_MIN
+#define FLT_MIN (1.0e-37)
+#endif
+
 /* Degrees to radians conversion: */
 #define DEG2RAD (M_PI/180.0)
 
@@ -386,9 +391,9 @@ static INLINE int iround(float f)
    return r;
 }
 #define IROUND(x)  iround(x)
-#elif defined(USE_X86_ASM) && defined(__WATCOMC__)
+#elif defined(__WATCOMC__) && defined(__386__)
 long iround(float f);
-#pragma aux iround =                        \
+#pragma aux iround =                    \
        "push   eax"                        \
        "fistp  dword ptr [esp]"            \
        "pop    eax"                        \
@@ -396,16 +401,6 @@ long iround(float f);
        value [eax]                         \
        modify exact [eax];
 #define IROUND(x)  iround(x)
-#elif defined(__OS2__)
-#ifndef FIST_MAGIC
-#define FIST_MAGIC ((((65536.0 * 65536.0 * 16)+(65536.0 * 0.5))* 65536.0))
-#endif
-static INLINE int iround(float x)
-{
-   double dtemp = FIST_MAGIC + x;
-   return ((*(int *)&dtemp) - 0x80000000);
-}
-#define IROUND(f)  iround((float)f)
 #else
 #define IROUND(f)  ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F)))
 #endif
@@ -515,8 +510,8 @@ static INLINE int iceil(float f)
 
 
 /***
- *** 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]
+ *** UNCLAMPED_FLOAT_TO_UBYTE: clamp float to [0,1] and map to ubyte in [0,255]
+ *** CLAMPED_FLOAT_TO_UBYTE: map float known to be in [0,1] to ubyte in [0,255]
  ***/
 #if defined(USE_IEEE) && !defined(DEBUG)
 #define IEEE_0996 0x3f7f0000   /* 0.996 or so */
@@ -527,13 +522,21 @@ static INLINE int iceil(float 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));                                  \
+           if (__tmp.i < 0)                                            \
+              UB = (GLubyte) 0;                                                \
+           else if (__tmp.i >= IEEE_0996)                              \
+              UB = (GLubyte) 255;                                      \
+           else {                                                      \
+              __tmp.f = __tmp.f * (255.0F/256.0F) + 32768.0F;          \
+              UB = (GLubyte) __tmp.i;                                  \
+           }                                                           \
+        } while (0)
+#define CLAMPED_FLOAT_TO_UBYTE(UB, F)                                  \
+        do {                                                           \
+           fi_type __tmp;                                              \
+           __tmp.f = (F) * (255.0F/256.0F) + 32768.0F;                 \
+           UB = (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))
@@ -610,7 +613,7 @@ void _watcom_start_fast_math(unsigned short *x,unsigned short *mask);
 #pragma aux _watcom_start_fast_math =                                   \
    "fnstcw  word ptr [eax]"                                             \
    "fldcw   word ptr [ecx]"                                             \
-   parm [eax ecx]                                                       \
+   parm [eax] [ecx]                                                     \
    modify exact [];
 void _watcom_end_fast_math(unsigned short *x);
 #pragma aux _watcom_end_fast_math =                                     \
@@ -621,7 +624,7 @@ void _watcom_end_fast_math(unsigned short *x);
 #if defined(NO_FAST_MATH)
 #define START_FAST_MATH(x)                                              \
 do {                                                                    \
-   static GLushort mask = DEFAULT_X86_FPU;                             \
+   static GLushort mask = DEFAULT_X86_FPU;                                 \
    _watcom_start_fast_math(&x,&mask);                                   \
 } while (0)
 #else
@@ -701,6 +704,12 @@ _mesa_log2(float x);
 extern unsigned int
 _mesa_bitcount(unsigned int n);
 
+extern GLhalfNV
+_mesa_float_to_half(float f);
+
+extern float
+_mesa_half_to_float(GLhalfNV h);
+
 
 extern char *
 _mesa_getenv( const char *var );