[Piglit] [v4 07/11] util: buffer object probe

Topi Pohjolainen topi.pohjolainen at intel.com
Thu Nov 14 04:20:30 PST 2013


Make feedback buffer probe accessible also for other tests.
Original behavior is altered not to print matching values
anymore.

v2:
   - call piglit_probe_buffer() instead of thin wrapper (Ian)
   - use bool instead of GLboolean

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 tests/spec/ext_transform_feedback/separate.c | 35 +++++++---------------------
 tests/util/piglit-util-gl-common.h           |  4 ++++
 tests/util/piglit-util-gl.c                  | 24 +++++++++++++++++++
 3 files changed, 37 insertions(+), 26 deletions(-)

diff --git a/tests/spec/ext_transform_feedback/separate.c b/tests/spec/ext_transform_feedback/separate.c
index e410be8..5c4d617 100644
--- a/tests/spec/ext_transform_feedback/separate.c
+++ b/tests/spec/ext_transform_feedback/separate.c
@@ -116,30 +116,9 @@ void piglit_init(int argc, char **argv)
 	glEnableClientState(GL_VERTEX_ARRAY);
 }
 
-static GLboolean probe_buffer(GLuint buf, int bufindex, unsigned comps, const float *expected)
-{
-	float *ptr;
-	unsigned i;
-	GLboolean status = GL_TRUE;
-
-	glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, buf);
-	ptr = glMapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, GL_READ_ONLY);
-	for (i = 0; i < NUM_OUT_VERTICES*comps; i++) {
-		if (fabs(ptr[i] - expected[i % comps]) > 0.01) {
-			printf("Buffer[%i][%i]: %f,  Expected: %f\n", bufindex, i, ptr[i], expected[i % comps]);
-			status = GL_FALSE;
-		} else {
-			printf("Buffer[%i][%i]: %f,  Expected: %f -- OK\n", bufindex, i, ptr[i], expected[i % comps]);
-
-		}
-	}
-	glUnmapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT);
-	return status;
-}
-
 enum piglit_result piglit_display(void)
 {
-	GLboolean pass = GL_TRUE;
+	bool pass = true;
 	static const float verts[] = {
 		10, 10,
 		10, 20,
@@ -165,10 +144,14 @@ enum piglit_result piglit_display(void)
 
 	assert(glGetError() == 0);
 
-	pass = probe_buffer(buf[0], 0, 3, v3) && pass;
-	pass = probe_buffer(buf[1], 1, 4, frontcolor) && pass;
-	pass = probe_buffer(buf[2], 2, 2, v2) && pass;
-	pass = probe_buffer(buf[3], 3, 4, texcoord1) && pass;
+	pass = piglit_probe_buffer(buf[0], GL_TRANSFORM_FEEDBACK_BUFFER_EXT,
+			"Buffer[0]", NUM_OUT_VERTICES, 3, v3) && pass;
+	pass = piglit_probe_buffer(buf[1], GL_TRANSFORM_FEEDBACK_BUFFER_EXT,
+			"Buffer[1]", NUM_OUT_VERTICES, 4, frontcolor)&& pass;
+	pass = piglit_probe_buffer(buf[2], GL_TRANSFORM_FEEDBACK_BUFFER_EXT,
+			"Buffer[2]", NUM_OUT_VERTICES, 2, v2) && pass;
+	pass = piglit_probe_buffer(buf[3], GL_TRANSFORM_FEEDBACK_BUFFER_EXT,
+			"Buffer[3]", NUM_OUT_VERTICES, 4, texcoord1) && pass;
 
 	assert(glGetError() == 0);
 
diff --git a/tests/util/piglit-util-gl-common.h b/tests/util/piglit-util-gl-common.h
index c4bca65..73f2f83 100644
--- a/tests/util/piglit-util-gl-common.h
+++ b/tests/util/piglit-util-gl-common.h
@@ -155,6 +155,10 @@ int piglit_probe_pixel_stencil(int x, int y, unsigned expected);
 int piglit_probe_rect_stencil(int x, int y, int w, int h, unsigned expected);
 int piglit_probe_rect_halves_equal_rgba(int x, int y, int w, int h);
 
+bool piglit_probe_buffer(GLuint buf, GLenum target, const char *label,
+			 unsigned n, unsigned num_components,
+			 const float *expected);
+
 int piglit_use_fragment_program(void);
 int piglit_use_vertex_program(void);
 void piglit_require_fragment_program(void);
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 587c290..f4267c7 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -706,6 +706,30 @@ int piglit_probe_texel_rgb(int target, int level, int x, int y,
 	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)
+{
+	float *ptr;
+	unsigned i;
+	bool status = true;
+
+	glBindBuffer(target, buf);
+	ptr = glMapBuffer(target, GL_READ_ONLY);
+
+	for (i = 0; i < n * num_components; i++) {
+		if (fabs(ptr[i] - expected[i % num_components]) > 0.01) {
+			printf("%s[%i]: %f, Expected: %f\n", label, i, ptr[i],
+				expected[i % num_components]);
+			status = false;
+		}
+	}
+
+	glUnmapBuffer(target);
+
+	return status;
+}
+
 int piglit_use_fragment_program(void)
 {
 	static const char source[] =
-- 
1.8.3.1



More information about the Piglit mailing list