Make feedback buffer probe accessible also for other tests. Original behavior is altered not to print matching values anymore.
Signed-off-by: Topi Pohjolainen <topi.pohjolai...@intel.com> --- tests/spec/ext_transform_feedback/separate.c | 30 ++++++++-------------------- tests/util/piglit-util-gl-common.h | 4 ++++ tests/util/piglit-util-gl.c | 24 ++++++++++++++++++++++ 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/tests/spec/ext_transform_feedback/separate.c b/tests/spec/ext_transform_feedback/separate.c index e410be8..3816d76 100644 --- a/tests/spec/ext_transform_feedback/separate.c +++ b/tests/spec/ext_transform_feedback/separate.c @@ -116,25 +116,11 @@ void piglit_init(int argc, char **argv) glEnableClientState(GL_VERTEX_ARRAY); } -static GLboolean probe_buffer(GLuint buf, int bufindex, unsigned comps, const float *expected) +static GLboolean probe_buffer(GLuint buf, const char *label, 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; + return piglit_probe_buffer(buf, GL_TRANSFORM_FEEDBACK_BUFFER_EXT, label, + NUM_OUT_VERTICES, comps, expected); } enum piglit_result piglit_display(void) @@ -165,10 +151,10 @@ 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 = probe_buffer(buf[0], "Buffer[0]", 3, v3) && pass; + pass = probe_buffer(buf[1], "Buffer[1]", 4, frontcolor) && pass; + pass = probe_buffer(buf[2], "Buffer[2]", 2, v2) && pass; + pass = probe_buffer(buf[3], "Buffer[3]", 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 e7d0797..5852f01 100644 --- a/tests/util/piglit-util-gl-common.h +++ b/tests/util/piglit-util-gl-common.h @@ -150,6 +150,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); +int 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..a8f6703 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); } +int +piglit_probe_buffer(GLuint buf, GLenum target, const char *label, + unsigned n, unsigned num_components, const float *expected) +{ + float *ptr; + unsigned i; + GLboolean status = GL_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 = GL_FALSE; + } + } + + glUnmapBuffer(target); + + return status; +} + int piglit_use_fragment_program(void) { static const char source[] = -- 1.8.3.1 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit