[Piglit] [PATCH 08/16] Move piglit_probe_texel_* functions to GL common code

Josh Triplett josh at joshtriplett.org
Thu Jul 3 12:38:05 PDT 2014


These don't need to remain in the GL-specific utility library.

Signed-off-by: Josh Triplett <josh at joshtriplett.org>
---
 tests/util/piglit-util-gl-common.c | 183 +++++++++++++++++++++++++++++++++++++
 tests/util/piglit-util-gl.c        | 183 -------------------------------------
 2 files changed, 183 insertions(+), 183 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c b/tests/util/piglit-util-gl-common.c
index 3a31e42..e05ae43 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -1497,3 +1497,186 @@ piglit_probe_image_ubyte(int x, int y, int w, int h, GLenum format,
 	free(pixels);
 	return 1;
 }
+
+/**
+ * Read a texel rectangle from the given location and compare its RGB value to
+ * the given expected values.
+ *
+ * Print a log message if the color value deviates from the expected value.
+ * \return true if the color values match, false otherwise
+ */
+int piglit_probe_texel_rect_rgb(int target, int level, int x, int y,
+				int w, int h, const float* expected)
+{
+	GLfloat *buffer;
+	GLfloat *probe;
+	int i, j, p;
+	GLint width;
+	GLint height;
+
+	glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
+	glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
+	buffer = malloc(width * height * 3 * sizeof(GLfloat));
+
+	glGetTexImage(target, level, GL_RGB, GL_FLOAT, buffer);
+
+	assert(x >= 0);
+	assert(y >= 0);
+	assert(x+w <= width);
+	assert(y+h <= height);
+
+	for (j = y; j < y+h; ++j) {
+		for (i = x; i < x+w; ++i) {
+			probe = &buffer[(j * width + i) * 3];
+
+			for (p = 0; p < 3; ++p) {
+				if (fabs(probe[p] - expected[p]) >= piglit_tolerance[p]) {
+					printf("Probe color at (%i,%i)\n", i, j);
+					printf("  Expected: %f %f %f\n",
+					       expected[0], expected[1], expected[2]);
+					printf("  Observed: %f %f %f\n",
+					       probe[0], probe[1], probe[2]);
+
+					free(buffer);
+					return 0;
+				}
+			}
+		}
+	}
+
+	free(buffer);
+	return 1;
+}
+
+/**
+ * Read a texel from the given location and compare its RGB value to the
+ * given expected values.
+ *
+ * Print a log message if the color value deviates from the expected value.
+ * \return true if the color values match, false otherwise
+ */
+int piglit_probe_texel_rgb(int target, int level, int x, int y,
+			   const float *expected)
+{
+	return piglit_probe_texel_rect_rgb(target, level, x, y, 1, 1, expected);
+}
+
+/**
+ * Read a texel rectangle from the given location and compare its RGBA value to
+ * the given expected values.
+ *
+ * Print a log message if the color value deviates from the expected value.
+ * \return true if the color values match, false otherwise
+ */
+int piglit_probe_texel_rect_rgba(int target, int level, int x, int y,
+				 int w, int h, const float* expected)
+{
+	GLfloat *buffer;
+	GLfloat *probe;
+	int i, j, p;
+	GLint width;
+	GLint height;
+
+	glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
+	glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
+	buffer = malloc(width * height * 4 * sizeof(GLfloat));
+
+	glGetTexImage(target, level, GL_RGBA, GL_FLOAT, buffer);
+
+	assert(x >= 0);
+	assert(y >= 0);
+	assert(x+w <= width);
+	assert(y+h <= height);
+
+	for (j = y; j < y+h; ++j) {
+		for (i = x; i < x+w; ++i) {
+			probe = &buffer[(j * width + i) * 4];
+
+			for (p = 0; p < 4; ++p) {
+				if (fabs(probe[p] - expected[p]) >= piglit_tolerance[p]) {
+					printf("Probe color at (%i,%i)\n", i, j);
+					printf("  Expected: %f %f %f %f\n",
+					       expected[0], expected[1], expected[2], expected[3]);
+					printf("  Observed: %f %f %f %f\n",
+					       probe[0], probe[1], probe[2], probe[3]);
+
+					free(buffer);
+					return 0;
+				}
+			}
+		}
+	}
+
+	free(buffer);
+	return 1;
+}
+
+/**
+ * Read a texel from the given location and compare its RGBA value to the
+ * given expected values.
+ *
+ * Print a log message if the color value deviates from the expected value.
+ * \return true if the color values match, false otherwise
+ */
+int piglit_probe_texel_rgba(int target, int level, int x, int y,
+			    const float* expected)
+{
+	return piglit_probe_texel_rect_rgba(target, level, x, y, 1, 1,
+					    expected);
+}
+
+/**
+ * Read a texel rectangle from the given location and compare its RGBA value to
+ * the given expected values.
+ *
+ * Print a log message if the color value deviates from the expected value.
+ * \return true if the color values match, false otherwise
+ */
+int piglit_probe_texel_volume_rgba(int target, int level, int x, int y, int z,
+				 int w, int h, int d, const float* expected)
+{
+	GLfloat *buffer;
+	GLfloat *probe;
+	int i, j, k, p;
+	GLint width;
+	GLint height;
+	GLint depth;
+
+	glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
+	glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
+	glGetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, &depth);
+	buffer = malloc(width * height * depth * 4 * sizeof(GLfloat));
+
+	glGetTexImage(target, level, GL_RGBA, GL_FLOAT, buffer);
+
+	assert(x >= 0);
+	assert(y >= 0);
+	assert(d >= 0);
+	assert(x+w <= width);
+	assert(y+h <= height);
+	assert(z+d <= depth);
+
+	for (k = z; k < z+d; ++k) {
+		for (j = y; j < y+h; ++j) {
+			for (i = x; i < x+w; ++i) {
+				probe = &buffer[(k * width * height + j * width + i) * 4];
+
+				for (p = 0; p < 4; ++p) {
+					if (fabs(probe[p] - expected[p]) >= piglit_tolerance[p]) {
+						printf("Probe color at (%i,%i,%i)\n", i, j, k);
+						printf("  Expected: %f %f %f %f\n",
+						       expected[0], expected[1], expected[2], expected[3]);
+						printf("  Observed: %f %f %f %f\n",
+						       probe[0], probe[1], probe[2], probe[3]);
+
+						free(buffer);
+						return 0;
+					}
+				}
+			}
+		}
+	}
+
+	free(buffer);
+	return 1;
+}
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index df81a63..8e4fc52 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -129,189 +129,6 @@ int piglit_probe_rect_stencil(int x, int y, int w, int h, unsigned expected)
 	return 1;
 }
 
-/**
- * Read a texel rectangle from the given location and compare its RGBA value to
- * the given expected values.
- *
- * Print a log message if the color value deviates from the expected value.
- * \return true if the color values match, false otherwise
- */
-int piglit_probe_texel_rect_rgba(int target, int level, int x, int y,
-				 int w, int h, const float* expected)
-{
-	GLfloat *buffer;
-	GLfloat *probe;
-	int i, j, p;
-	GLint width;
-	GLint height;
-
-	glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
-	glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
-	buffer = malloc(width * height * 4 * sizeof(GLfloat));
-
-	glGetTexImage(target, level, GL_RGBA, GL_FLOAT, buffer);
-
-	assert(x >= 0);
-	assert(y >= 0);
-	assert(x+w <= width);
-	assert(y+h <= height);
-
-	for (j = y; j < y+h; ++j) {
-		for (i = x; i < x+w; ++i) {
-			probe = &buffer[(j * width + i) * 4];
-
-			for (p = 0; p < 4; ++p) {
-				if (fabs(probe[p] - expected[p]) >= piglit_tolerance[p]) {
-					printf("Probe color at (%i,%i)\n", i, j);
-					printf("  Expected: %f %f %f %f\n",
-					       expected[0], expected[1], expected[2], expected[3]);
-					printf("  Observed: %f %f %f %f\n",
-					       probe[0], probe[1], probe[2], probe[3]);
-
-					free(buffer);
-					return 0;
-				}
-			}
-		}
-	}
-
-	free(buffer);
-	return 1;
-}
-
-/**
- * Read a texel rectangle from the given location and compare its RGBA value to
- * the given expected values.
- *
- * Print a log message if the color value deviates from the expected value.
- * \return true if the color values match, false otherwise
- */
-int piglit_probe_texel_volume_rgba(int target, int level, int x, int y, int z,
-				 int w, int h, int d, const float* expected)
-{
-	GLfloat *buffer;
-	GLfloat *probe;
-	int i, j, k, p;
-	GLint width;
-	GLint height;
-	GLint depth;
-
-	glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
-	glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
-	glGetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, &depth);
-	buffer = malloc(width * height * depth * 4 * sizeof(GLfloat));
-
-	glGetTexImage(target, level, GL_RGBA, GL_FLOAT, buffer);
-
-	assert(x >= 0);
-	assert(y >= 0);
-	assert(d >= 0);
-	assert(x+w <= width);
-	assert(y+h <= height);
-	assert(z+d <= depth);
-
-	for (k = z; k < z+d; ++k) {
-		for (j = y; j < y+h; ++j) {
-			for (i = x; i < x+w; ++i) {
-				probe = &buffer[(k * width * height + j * width + i) * 4];
-
-				for (p = 0; p < 4; ++p) {
-					if (fabs(probe[p] - expected[p]) >= piglit_tolerance[p]) {
-						printf("Probe color at (%i,%i,%i)\n", i, j, k);
-						printf("  Expected: %f %f %f %f\n",
-						       expected[0], expected[1], expected[2], expected[3]);
-						printf("  Observed: %f %f %f %f\n",
-						       probe[0], probe[1], probe[2], probe[3]);
-
-						free(buffer);
-						return 0;
-					}
-				}
-			}
-		}
-	}
-
-	free(buffer);
-	return 1;
-}
-
-/**
- * Read a texel from the given location and compare its RGBA value to the
- * given expected values.
- *
- * Print a log message if the color value deviates from the expected value.
- * \return true if the color values match, false otherwise
- */
-int piglit_probe_texel_rgba(int target, int level, int x, int y,
-			    const float* expected)
-{
-	return piglit_probe_texel_rect_rgba(target, level, x, y, 1, 1,
-					    expected);
-}
-
-/**
- * Read a texel rectangle from the given location and compare its RGB value to
- * the given expected values.
- *
- * Print a log message if the color value deviates from the expected value.
- * \return true if the color values match, false otherwise
- */
-int piglit_probe_texel_rect_rgb(int target, int level, int x, int y,
-				int w, int h, const float* expected)
-{
-	GLfloat *buffer;
-	GLfloat *probe;
-	int i, j, p;
-	GLint width;
-	GLint height;
-
-	glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
-	glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
-	buffer = malloc(width * height * 3 * sizeof(GLfloat));
-
-	glGetTexImage(target, level, GL_RGB, GL_FLOAT, buffer);
-
-	assert(x >= 0);
-	assert(y >= 0);
-	assert(x+w <= width);
-	assert(y+h <= height);
-
-	for (j = y; j < y+h; ++j) {
-		for (i = x; i < x+w; ++i) {
-			probe = &buffer[(j * width + i) * 3];
-
-			for (p = 0; p < 3; ++p) {
-				if (fabs(probe[p] - expected[p]) >= piglit_tolerance[p]) {
-					printf("Probe color at (%i,%i)\n", i, j);
-					printf("  Expected: %f %f %f\n",
-					       expected[0], expected[1], expected[2]);
-					printf("  Observed: %f %f %f\n",
-					       probe[0], probe[1], probe[2]);
-
-					free(buffer);
-					return 0;
-				}
-			}
-		}
-	}
-
-	free(buffer);
-	return 1;
-}
-
-/**
- * Read a texel from the given location and compare its RGB value to the
- * given expected values.
- *
- * Print a log message if the color value deviates from the expected value.
- * \return true if the color values match, false otherwise
- */
-int piglit_probe_texel_rgb(int target, int level, int x, int y,
-			   const float *expected)
-{
-	return piglit_probe_texel_rect_rgb(target, level, x, y, 1, 1, expected);
-}
-
 bool piglit_probe_buffer(GLuint buf, GLenum target, const char *label,
 		         unsigned n, unsigned num_components,
 			 const float *expected)
-- 
2.0.1



More information about the Piglit mailing list