[Piglit] [PATCH 1/2] piglit/util: add support for probing doubles in a buffer.

Dave Airlie airlied at gmail.com
Sun Feb 22 18:31:25 PST 2015


From: Dave Airlie <airlied at redhat.com>

This is needed to test transform feedback with FP64.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 tests/util/piglit-util-gl.c | 23 +++++++++++++++++++++++
 tests/util/piglit-util-gl.h |  4 +++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index aae6df0..1b54045 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -1814,6 +1814,29 @@ bool piglit_probe_buffer(GLuint buf, GLenum target, const char *label,
 	return status;
 }
 
+bool piglit_probe_buffer_doubles(GLuint buf, GLenum target, const char *label,
+				 unsigned n, unsigned num_components,
+				 const double *expected)
+{
+	double *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;
+}
 GLint piglit_ARBfp_pass_through = 0;
 
 int piglit_use_fragment_program(void)
diff --git a/tests/util/piglit-util-gl.h b/tests/util/piglit-util-gl.h
index 0f8eb81..3c7d8da 100644
--- a/tests/util/piglit-util-gl.h
+++ b/tests/util/piglit-util-gl.h
@@ -165,7 +165,9 @@ 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);
-
+bool piglit_probe_buffer_doubles(GLuint buf, GLenum target, const char *label,
+				 unsigned n, unsigned num_components,
+				 const double *expected);
 int piglit_use_fragment_program(void);
 int piglit_use_vertex_program(void);
 void piglit_require_fragment_program(void);
-- 
1.9.3



More information about the Piglit mailing list