[Piglit] [PATCH 4/5] Move CLAMP, MIN2, and MAX2 macros to piglit-util.h.

Paul Berry stereotype441 at gmail.com
Wed Jan 25 17:56:47 PST 2012


This patch consolidates all of the definitions of CLAMP(), MIN2(), and
MAX2() into piglit-util.h, with the exception of those used by glean.
---
 tests/fbo/fbo-draw-buffers-blend.c                 |    2 --
 tests/general/hiz.c                                |    2 --
 tests/general/texunits.c                           |    3 ---
 tests/mesa/util/readtex.c                          |    2 --
 tests/shaders/fp-unpack-01.c                       |    3 ---
 tests/spec/ext_transform_feedback/max-varyings.c   |    2 --
 .../ext_transform_feedback/overflow-edge-cases.c   |    2 --
 .../oes_compressed_etc1_rgb8_texture-basic.c       |    2 --
 tests/texturing/tex-miplevel-selection.c           |    4 ----
 tests/util/piglit-util.h                           |    4 ++++
 10 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/tests/fbo/fbo-draw-buffers-blend.c b/tests/fbo/fbo-draw-buffers-blend.c
index 02e9e72..a20f2e9 100644
--- a/tests/fbo/fbo-draw-buffers-blend.c
+++ b/tests/fbo/fbo-draw-buffers-blend.c
@@ -45,8 +45,6 @@ static GLint maxBuffers;
 static GLuint FBO;
 
 
-#define CLAMP( X, MIN, MAX )  ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
-
 #define MY_ASSERT(x) my_assert(x, #x)
 
 static void
diff --git a/tests/general/hiz.c b/tests/general/hiz.c
index aebe684..90211cb 100644
--- a/tests/general/hiz.c
+++ b/tests/general/hiz.c
@@ -123,8 +123,6 @@ GLboolean pix_equal(int x, int y, const float probe[3], const float expected[3])
 	return ret;
 }
 
-#define MIN2(a, b) ((a) > (b) ? (b) : (a))
-
 GLboolean test_less()
 {
 	const float bg[3] = {0.1, 0.1, 0.1};
diff --git a/tests/general/texunits.c b/tests/general/texunits.c
index 72351e6..394e7f5 100644
--- a/tests/general/texunits.c
+++ b/tests/general/texunits.c
@@ -31,9 +31,6 @@
 #include "piglit-util.h"
 
 
-#define MAX2( A, B )   ( (A)>(B) ? (A) : (B) )
-
-
 static int Width = 128, Height = 128;
 static int Automatic = 0;
 
diff --git a/tests/mesa/util/readtex.c b/tests/mesa/util/readtex.c
index 00506d6..cc5a364 100644
--- a/tests/mesa/util/readtex.c
+++ b/tests/mesa/util/readtex.c
@@ -369,8 +369,6 @@ GLubyte *LoadRGBImage( const char *imageFile, GLint *width, GLint *height,
    return buffer;
 }
 
-#define CLAMP( X, MIN, MAX )  ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
-
 
 static void ConvertRGBtoYUV(GLint w, GLint h, GLint texel_bytes,
 			    const GLubyte *src,
diff --git a/tests/shaders/fp-unpack-01.c b/tests/shaders/fp-unpack-01.c
index 20f1da2..d5c2e44 100644
--- a/tests/shaders/fp-unpack-01.c
+++ b/tests/shaders/fp-unpack-01.c
@@ -47,9 +47,6 @@ int piglit_width = (((BOX_SIZE+1)*TEST_COLS)+1);
 int piglit_height = (((BOX_SIZE+1)*TEST_ROWS)+1);
 
 #define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-#define MAX2(a, b) ((a) > (b) ? (a) : (b))
-#define MIN2(a, b) ((a) > (b) ? (b) : (a))
-#define CLAMP(x, l, h) MIN2(MAX2(x, l), h)
 
 static char shader_source[64 * 1024];
 static GLfloat colors[TEST_COLS][4];
diff --git a/tests/spec/ext_transform_feedback/max-varyings.c b/tests/spec/ext_transform_feedback/max-varyings.c
index e77bca8..64e05a3 100644
--- a/tests/spec/ext_transform_feedback/max-varyings.c
+++ b/tests/spec/ext_transform_feedback/max-varyings.c
@@ -48,8 +48,6 @@ int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
 static const char *xfb_varying_array[MAX_VARYING];
 static GLuint xfb_buf;
 
-#define MIN2(A, B) ((A) < (B) ? (A) : (B))
-
 /* Generate a VS that writes to a varying vec4[num_varyings] called
  * "v".  The values written are v[0] = (0.0, 1.0, 2.0, 3.0), v[1] =
  * (4.0, 5.0, 6.0, 7.0), and so on.
diff --git a/tests/spec/ext_transform_feedback/overflow-edge-cases.c b/tests/spec/ext_transform_feedback/overflow-edge-cases.c
index ea8f0b6..4507ed4 100644
--- a/tests/spec/ext_transform_feedback/overflow-edge-cases.c
+++ b/tests/spec/ext_transform_feedback/overflow-edge-cases.c
@@ -50,8 +50,6 @@ int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB;
 #define XFB_BUFFER_SIZE 12
 #define MAX_VERTICES 9
 
-#define MIN2(A, B) ((A) < (B) ? (A) : (B))
-
 static const char *vstext =
 	"attribute float vertex_num;\n"
 	"varying float varying1;\n"
diff --git a/tests/spec/oes_compressed_etc1_rgb8_texture/oes_compressed_etc1_rgb8_texture-basic.c b/tests/spec/oes_compressed_etc1_rgb8_texture/oes_compressed_etc1_rgb8_texture-basic.c
index fb0d3de..2079d45 100644
--- a/tests/spec/oes_compressed_etc1_rgb8_texture/oes_compressed_etc1_rgb8_texture-basic.c
+++ b/tests/spec/oes_compressed_etc1_rgb8_texture/oes_compressed_etc1_rgb8_texture-basic.c
@@ -27,8 +27,6 @@
 #define GL_ETC1_RGB8_OES                                        0x8D64
 #endif
 
-#define CLAMP(x, min, max) ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x)))
-
 int piglit_width = 100;
 int piglit_height = 100;
 int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
diff --git a/tests/texturing/tex-miplevel-selection.c b/tests/texturing/tex-miplevel-selection.c
index 44579d8..1b252e7 100644
--- a/tests/texturing/tex-miplevel-selection.c
+++ b/tests/texturing/tex-miplevel-selection.c
@@ -181,10 +181,6 @@ draw_quad(int x, int y, int w, int h, int level)
 	glEnd();
 }
 
-#define CLAMP( X, MIN, MAX )  ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
-#define MIN2( A, B )   ( (A)<(B) ? (A) : (B) )
-#define MAX2( A, B )   ( (A)>(B) ? (A) : (B) )
-
 enum piglit_result
 piglit_display(void)
 {
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 1c8c740..c0bb92d 100755
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -117,6 +117,10 @@ enum piglit_result {
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
 
+#define CLAMP( X, MIN, MAX )  ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
+#define MIN2(a, b) ((a) > (b) ? (b) : (a))
+#define MAX2(a, b) ((a) > (b) ? (a) : (b))
+
 extern const uint8_t fdo_bitmap[];
 extern const unsigned int fdo_bitmap_width;
 extern const unsigned int fdo_bitmap_height;
-- 
1.7.7.6



More information about the Piglit mailing list