summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Versace <chad.versace@intel.com>2011-03-09 13:11:27 -0800
committerChad Versace <chad.versace@intel.com>2011-03-12 10:58:11 -0800
commite695117af56d59835398ddcd0917b7fab5ae71f0 (patch)
tree525717fa21b222a1a6e5be9dc88059c10a23b4b2
parent5be0666f4996e9a393b8e10d432a7583c8aa0b87 (diff)
util: Remove duplicate definitions of piglit_set_tolerance()
Replace the two identical definitions in piglit-util-gl.c and in piglit-util-gles2.c with a single definition in piglit-util.c. Signed-off-by: Chad Versace <chad@chad-versace.us>
-rw-r--r--tests/util/piglit-util-gl.c34
-rw-r--r--tests/util/piglit-util-gles2.c28
-rw-r--r--tests/util/piglit-util.c21
-rw-r--r--tests/util/piglit-util.h1
4 files changed, 33 insertions, 51 deletions
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index ed849ab72..773c1c00e 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -55,26 +55,6 @@ void piglit_require_not_extension(const char *name)
}
}
-static float tolerance[4] = { 0.01, 0.01, 0.01, 0.01 };
-
-void
-piglit_set_tolerance_for_bits(int rbits, int gbits, int bbits, int abits)
-{
- int bits[4] = {rbits, gbits, bbits, abits};
- int i;
-
- for (i = 0; i < 4; i++) {
- if (bits[i] < 2) {
- /* Don't try to validate channels when there's only 1
- * bit of precision (or none).
- */
- tolerance[i] = 1.0;
- } else {
- tolerance[i] = 3.0 / (1 << bits[i]);
- }
- }
-}
-
/**
* Read a pixel from the given location and compare its RGBA value to the
* given expected values.
@@ -91,7 +71,7 @@ int piglit_probe_pixel_rgba(int x, int y, const float* expected)
glReadPixels(x, y, 1, 1, GL_RGBA, GL_FLOAT, probe);
for(i = 0; i < 4; ++i) {
- if (fabs(probe[i] - expected[i]) > tolerance[i]) {
+ if (fabs(probe[i] - expected[i]) > piglit_tolerance[i]) {
pass = GL_FALSE;
}
}
@@ -120,7 +100,7 @@ piglit_probe_rect_rgba(int x, int y, int w, int h, const float *expected)
probe = &pixels[(j*w+i)*4];
for (p = 0; p < 4; ++p) {
- if (fabs(probe[p] - expected[p]) >= tolerance[p]) {
+ if (fabs(probe[p] - expected[p]) >= piglit_tolerance[p]) {
printf("Probe at (%i,%i)\n", x+i, y+j);
printf(" Expected: %f %f %f %f\n",
expected[0], expected[1], expected[2], expected[3]);
@@ -153,7 +133,7 @@ piglit_probe_image_rgb(int x, int y, int w, int h, const float *image)
probe = &pixels[(j*w+i)*3];
for (p = 0; p < 3; ++p) {
- if (fabs(probe[p] - expected[p]) >= tolerance[p]) {
+ if (fabs(probe[p] - expected[p]) >= piglit_tolerance[p]) {
printf("Probe at (%i,%i)\n", x+i, y+j);
printf(" Expected: %f %f %f\n",
expected[0], expected[1], expected[2]);
@@ -186,7 +166,7 @@ piglit_probe_image_rgba(int x, int y, int w, int h, const float *image)
probe = &pixels[(j*w+i)*4];
for (p = 0; p < 4; ++p) {
- if (fabs(probe[p] - expected[p]) >= tolerance[p]) {
+ if (fabs(probe[p] - expected[p]) >= piglit_tolerance[p]) {
printf("Probe at (%i,%i)\n", x+i, y+j);
printf(" Expected: %f %f %f %f\n",
expected[0], expected[1], expected[2], expected[3]);
@@ -221,7 +201,7 @@ int piglit_probe_pixel_rgb(int x, int y, const float* expected)
for(i = 0; i < 3; ++i) {
- if (fabs(probe[i] - expected[i]) > tolerance[i]) {
+ if (fabs(probe[i] - expected[i]) > piglit_tolerance[i]) {
pass = GL_FALSE;
}
}
@@ -250,7 +230,7 @@ piglit_probe_rect_rgb(int x, int y, int w, int h, const float *expected)
probe = &pixels[(j*w+i)*3];
for (p = 0; p < 3; ++p) {
- if (fabs(probe[p] - expected[p]) >= tolerance[p]) {
+ if (fabs(probe[p] - expected[p]) >= piglit_tolerance[p]) {
printf("Probe at (%i,%i)\n", x+i, y+j);
printf(" Expected: %f %f %f\n",
expected[0], expected[1], expected[2]);
@@ -424,7 +404,7 @@ int piglit_probe_rect_halves_equal_rgba(int x, int y, int w, int h)
probe2 = &pixels[(j*w+wh+i)*4];
for (p = 0; p < 4; ++p) {
- if (fabs(probe1[p] - probe2[p]) >= tolerance[p]) {
+ if (fabs(probe1[p] - probe2[p]) >= piglit_tolerance[p]) {
printf("Probe at (%i,%i)\n", x+i, y+j);
printf(" Left: %f %f %f %f\n",
probe1[0], probe1[1], probe1[2], probe1[3]);
diff --git a/tests/util/piglit-util-gles2.c b/tests/util/piglit-util-gles2.c
index 08f0f09b0..97ac871d4 100644
--- a/tests/util/piglit-util-gles2.c
+++ b/tests/util/piglit-util-gles2.c
@@ -91,26 +91,6 @@ void piglit_require_not_extension(const char *name)
}
}
-static float tolerance[4] = { 0.01, 0.01, 0.01, 0.01 };
-
-void
-piglit_set_tolerance_for_bits(int rbits, int gbits, int bbits, int abits)
-{
- int bits[4] = {rbits, gbits, bbits, abits};
- int i;
-
- for (i = 0; i < 4; i++) {
- if (bits[i] < 2) {
- /* Don't try to validate channels when there's only 1
- * bit of precision (or none).
- */
- tolerance[i] = 1.0;
- } else {
- tolerance[i] = 3.0 / (1 << bits[i]);
- }
- }
-}
-
/**
* Read a pixel from the given location and compare its RGBA value to the
* given expected values.
@@ -127,7 +107,7 @@ int piglit_probe_pixel_rgba(int x, int y, const float* expected)
glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, probe);
for(i = 0; i < 4; ++i) {
- if (fabs(probe[i]/255.0 - expected[i]) > tolerance[i]) {
+ if (fabs(probe[i]/255.0 - expected[i]) > piglit_tolerance[i]) {
pass = GL_FALSE;
}
}
@@ -156,7 +136,7 @@ piglit_probe_rect_rgba(int x, int y, int w, int h, const float *expected)
probe = &pixels[(j*w+i)*4];
for (p = 0; p < 4; ++p) {
- if (fabs(probe[p]/255.0 - expected[p]) >= tolerance[p]) {
+ if (fabs(probe[p]/255.0 - expected[p]) >= piglit_tolerance[p]) {
printf("Probe at (%i,%i)\n", x+i, y+j);
printf(" Expected: %f %f %f %f\n",
expected[0], expected[1], expected[2], expected[3]);
@@ -191,7 +171,7 @@ int piglit_probe_pixel_rgb(int x, int y, const float* expected)
for(i = 0; i < 3; ++i) {
- if (fabs(probe[i]/255.0 - expected[i]) > tolerance[i]) {
+ if (fabs(probe[i]/255.0 - expected[i]) > piglit_tolerance[i]) {
pass = GL_FALSE;
}
}
@@ -220,7 +200,7 @@ piglit_probe_rect_rgb(int x, int y, int w, int h, const float *expected)
probe = &pixels[(j*w+i)*3];
for (p = 0; p < 3; ++p) {
- if (fabs(probe[p]/255.0 - expected[p]) >= tolerance[p]) {
+ if (fabs(probe[p]/255.0 - expected[p]) >= piglit_tolerance[p]) {
printf("Probe at (%i,%i)\n", x+i, y+j);
printf(" Expected: %f %f %f\n",
expected[0], expected[1], expected[2]);
diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index eb20f6d72..d0cb6abef 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -367,6 +367,27 @@ GLint piglit_link_simple_program(GLint vs, GLint fs)
return prog;
}
+float piglit_tolerance[4] = { 0.01, 0.01, 0.01, 0.01 };
+
+void
+piglit_set_tolerance_for_bits(int rbits, int gbits, int bbits, int abits)
+{
+ int bits[4] = {rbits, gbits, bbits, abits};
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ if (bits[i] < 2) {
+ /* Don't try to validate channels when there's only 1
+ * bit of precision (or none).
+ */
+ piglit_tolerance[i] = 1.0;
+ } else {
+ piglit_tolerance[i] = 3.0 / (1 << bits[i]);
+ }
+ }
+}
+
+
#ifndef HAVE_STRCHRNUL
char *strchrnul(const char *s, int c)
{
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index c8938c967..13b4adc3a 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -142,6 +142,7 @@ GLuint piglit_checkerboard_texture(GLuint tex, unsigned level,
GLuint piglit_rgbw_texture(GLenum format, int w, int h, GLboolean mip,
GLboolean alpha, GLenum basetype);
GLuint piglit_depth_texture(GLenum format, int w, int h, GLboolean mip);
+extern float piglit_tolerance[4];
void piglit_set_tolerance_for_bits(int rbits, int gbits, int bbits, int abits);
extern GLfloat cube_face_texcoords[6][4][3];