[Piglit] [PATCH v2 2/4] util: Add a piglit_probe_rects_equal_rgba() function

Chad Versace chad.versace at intel.com
Mon Aug 31 16:06:02 PDT 2015


On Fri 28 Aug 2015, Nanley Chery wrote:
> From: Nanley Chery <nanley.g.chery at intel.com>
> 
> This function compares two rectangles for equality. This is useful
> to compare the rendering of individual miplevels in a miptree while
> avoiding too much resource consumption.
> 
> Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
> ---
>  tests/util/piglit-util-gl.c | 81 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/util/piglit-util-gl.h | 31 +++++++++++++++++
>  2 files changed, 112 insertions(+)

There's a small typo below. Other than that, this patch is
Reviewed-by: Chad Versace <chad.versace at intel.com>

> 
> diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
> index db17b83..82a6862 100644
> --- a/tests/util/piglit-util-gl.c
> +++ b/tests/util/piglit-util-gl.c
> @@ -1242,6 +1242,41 @@ piglit_probe_rect_rgb(int x, int y, int w, int h, const float *expected)
>  }
>  
>  int
> +piglit_probe_rects_equal(int x1, int y1, int x2, int y2,
> +			int w, int h, GLenum format)
> +{
> +	int retval;
> +	GLfloat *pixels;
> +	int ncomponents, rect_size;
> +
> +	/* Allocate buffer large enough for two rectangles */
> +	ncomponents = piglit_num_components(format);
> +	rect_size = w * h * ncomponents;
> +	pixels = malloc(2 * rect_size * sizeof(GLfloat));
> +
> +	/* Load the pixels into the buffer and compare */
> +	/* We only need to do one glReadPixels if the images are adjacent */
> +	if ((x1 + w) == x2 && y1 == y2) {
> +		piglit_read_pixels_float(x1, y1, 2*w, h, format, pixels);
> +		retval = piglit_compare_image_halves_color(2*w, h,
> +						       ncomponents,
> +						       piglit_tolerance,
> +						       pixels);
> +	} else {
> +		piglit_read_pixels_float(x1, y1, w, h, format, pixels);
> +		piglit_read_pixels_float(x2, y2, w, h, format,
> +					pixels +rect_size);
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                Need a space after '+'.


More information about the Piglit mailing list