mesa: use MaxNumlevels in _mesa_test_texobj_completeness
[mesa.git] / src / mesa / main / macros.h
index fc6f2a28f206808b4083bcdf261b226df0d675cb..14a5d5fe16efbc09e9763ba5a148e5d4b05a6db4 100644 (file)
@@ -171,6 +171,20 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
        ub = ((GLubyte) F_TO_I((f) * 255.0F))
 #endif
 
+static inline GLfloat INT_AS_FLT(GLint i)
+{
+   fi_type tmp;
+   tmp.i = i;
+   return tmp.f;
+}
+
+static inline GLfloat UINT_AS_FLT(GLuint u)
+{
+   fi_type tmp;
+   tmp.u = u;
+   return tmp.f;
+}
+
 /*@}*/
 
 
@@ -573,6 +587,31 @@ do {                               \
 
 /*@}*/
 
+/** Copy \p sz elements into a homegeneous (4-element) vector, giving
+ * default values to the remaining components.
+ * The default values are chosen based on \p type.
+ */
+static inline void
+COPY_CLEAN_4V_TYPE_AS_FLOAT(GLfloat dst[4], int sz, const GLfloat src[4],
+                            GLenum type)
+{
+   switch (type) {
+   case GL_FLOAT:
+      ASSIGN_4V(dst, 0, 0, 0, 1);
+      break;
+   case GL_INT:
+      ASSIGN_4V(dst, INT_AS_FLT(0), INT_AS_FLT(0),
+                     INT_AS_FLT(0), INT_AS_FLT(1));
+      break;
+   case GL_UNSIGNED_INT:
+      ASSIGN_4V(dst, UINT_AS_FLT(0), UINT_AS_FLT(0),
+                     UINT_AS_FLT(0), UINT_AS_FLT(1));
+      break;
+   default:
+      ASSERT(0);
+   }
+   COPY_SZ_4V(dst, sz, src);
+}
 
 /** \name Linear interpolation functions */
 /*@{*/
@@ -693,31 +732,14 @@ NORMALIZE_3FV(GLfloat v[3])
 static inline GLboolean
 IS_NEGATIVE(float x)
 {
-#if defined(USE_IEEE)
-   fi_type fi;
-   fi.f = x;
-   return fi.i < 0;
-#else
-   return x < 0.0F;
-#endif
+   return signbit(x) != 0;
 }
 
-
 /** Test two floats have opposite signs */
 static inline GLboolean
 DIFFERENT_SIGNS(GLfloat x, GLfloat y)
 {
-#if defined(USE_IEEE)
-   fi_type xfi, yfi;
-   xfi.f = x;
-   yfi.f = y;
-   return (xfi.i ^ yfi.i) & (1u << 31);
-#else
-   /* Could just use (x*y<0) except for the flatshading requirements.
-    * Maybe there's a better way?
-    */
-   return ((x) * (y) <= 0.0F && (x) - (y) != 0.0F);
-#endif
+   return signbit(x) != signbit(y);
 }