[Mesa-dev] [PATCH 3/7] mesa: Use u_math.h from macros.h

Eric Anholt eric at anholt.net
Wed Feb 11 16:48:25 PST 2015


This avoids duplication of some macros and other definitions across the
tree.

Note that COPY_4FV switches from a memcpy-based implementation to an
assignment of 4 floats.
---
 src/mesa/drivers/dri/i915/intel_tris.c      |  6 ------
 src/mesa/drivers/dri/nouveau/nouveau_util.h |  6 ------
 src/mesa/drivers/dri/r200/r200_sanity.c     |  2 --
 src/mesa/drivers/dri/radeon/radeon_sanity.c |  2 --
 src/mesa/main/macros.h                      | 18 +-----------------
 5 files changed, 1 insertion(+), 33 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c
index 94d85ce..2c0a785 100644
--- a/src/mesa/drivers/dri/i915/intel_tris.c
+++ b/src/mesa/drivers/dri/i915/intel_tris.c
@@ -1268,12 +1268,6 @@ intelFallback(struct intel_context *intel, GLbitfield bit, bool mode)
    }
 }
 
-union fi
-{
-   GLfloat f;
-   GLint i;
-};
-
 /**********************************************************************/
 /*                            Initialization.                         */
 /**********************************************************************/
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_util.h b/src/mesa/drivers/dri/nouveau/nouveau_util.h
index e9721c3..8087445 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_util.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_util.h
@@ -129,12 +129,6 @@ log2i(unsigned i)
 	return r;
 }
 
-static inline unsigned
-align(unsigned x, unsigned m)
-{
-	return (x + m - 1) & ~(m - 1);
-}
-
 static inline void
 get_scissors(struct gl_framebuffer *fb, int *x, int *y, int *w, int *h)
 {
diff --git a/src/mesa/drivers/dri/r200/r200_sanity.c b/src/mesa/drivers/dri/r200/r200_sanity.c
index 34d83d8..8f7c0fe 100644
--- a/src/mesa/drivers/dri/r200/r200_sanity.c
+++ b/src/mesa/drivers/dri/r200/r200_sanity.c
@@ -593,8 +593,6 @@ static struct reg_names vector_names[] = {
    { 1000, "" },
 };
 
-union fi { float f; int i; };
-
 #define ISVEC   1
 #define ISFLOAT 2
 #define TOUCHED 4
diff --git a/src/mesa/drivers/dri/radeon/radeon_sanity.c b/src/mesa/drivers/dri/radeon/radeon_sanity.c
index 657a8c3..bb2a3bf 100644
--- a/src/mesa/drivers/dri/radeon/radeon_sanity.c
+++ b/src/mesa/drivers/dri/radeon/radeon_sanity.c
@@ -315,8 +315,6 @@ static struct reg_names vector_names[] = {
    { 1000, "" },
 };
 
-union fi { float f; int i; };
-
 #define ISVEC   1
 #define ISFLOAT 2
 #define TOUCHED 4
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index 2d59c6f..cf1f0e9 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -31,6 +31,7 @@
 #ifndef MACROS_H
 #define MACROS_H
 
+#include "util/u_math.h"
 #include "imports.h"
 
 
@@ -274,14 +275,6 @@ COPY_4UBV(GLubyte dst[4], const GLubyte src[4])
 #endif
 }
 
-/** Copy a 4-element float vector */
-static inline void
-COPY_4FV(GLfloat dst[4], const GLfloat src[4])
-{
-   /* memcpy seems to be most efficient */
-   memcpy(dst, src, sizeof(GLfloat) * 4);
-}
-
 /** Copy \p SZ elements into a 4-element vector */
 #define COPY_SZ_4V(DST, SZ, SRC)  \
 do {                              \
@@ -373,15 +366,6 @@ do {                                   \
       (DST)[3] *= S;                   \
 } while (0)
 
-/** Assignment */
-#define ASSIGN_4V( V, V0, V1, V2, V3 )  \
-do {                                    \
-    V[0] = V0;                          \
-    V[1] = V1;                          \
-    V[2] = V2;                          \
-    V[3] = V3;                          \
-} while(0)
-
 /*@}*/
 
 
-- 
2.1.4



More information about the mesa-dev mailing list