Commit e695117a authored by Chad Versace's avatar Chad Versace

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: chadversary's avatarChad Versace <chad@chad-versace.us>
parent 5be0666f
......@@ -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]);
......
......@@ -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]);
......
......@@ -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)
{
......
......@@ -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];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment