More GL_EXT_framebuffer_object: rename some things, added device driver hooks.
[mesa.git] / src / mesa / main / imports.h
index 86480c82b1d8dcd8b3eba14b0496cc87829854d0..5158bcd8b252e1a66d548f3a6c969e3ea8bab1dd 100644 (file)
@@ -100,7 +100,7 @@ extern "C" {
  * this macro.
  * Both pointers/offsets are expressed in bytes.
  */
-#define ADD_POINTERS(A, B)  ( (A) + (unsigned long) (B) )
+#define ADD_POINTERS(A, B)  ( (GLubyte *) (A) + (unsigned long) (B) )
 
 
 /**********************************************************************/
@@ -198,6 +198,20 @@ extern void _ext_mesa_free_pixelbuffer( void *pb );
 /*@}*/
 
 
+/**********************************************************************/
+
+
+/**
+ * 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;
+
+
 
 /**********************************************************************
  * Math macros
@@ -326,8 +340,13 @@ static INLINE int IS_INF_OR_NAN( float x )
  *** 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))
+static INLINE int GET_FLOAT_BITS( float x )
+{
+   fi_type fi;
+   fi.f = x;
+   return fi.i;
+}
+#define IS_NEGATIVE(x) (GET_FLOAT_BITS(x) < 0)
 #else
 #define IS_NEGATIVE(x) (x < 0.0F)
 #endif
@@ -553,14 +572,9 @@ static INLINE int iceil(float f)
 
 
 /***
- *** COPY_FLOAT: copy a float from src to dest, avoid slow FP regs if possible
+ *** COPY_FLOAT: copy a float from src to dest.
  ***/
-#if defined(USE_IEEE) && !defined(DEBUG)
-#define COPY_FLOAT( dst, src )                                 \
-       ((fi_type *) &(dst))->i = ((fi_type *) (void *) &(src))->i
-#else
 #define COPY_FLOAT( dst, src )         (dst) = (src)
-#endif
 
 
 /***