[Piglit] [PATCH 2/3] util: add piglit_probe_rect_r_ubyte

Chris Forbes chrisf at ijw.co.nz
Sat Aug 23 15:44:57 PDT 2014


On Sun, Aug 24, 2014 at 4:38 AM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> This is a lot faster than RGBA FLOAT.
>
> There is a potential to speed up piglit by switching tests to ubyte
> r, rg, or rgba probing.
> ---
>  tests/util/piglit-util-gl.c | 32 ++++++++++++++++++++++++++++++++
>  tests/util/piglit-util-gl.h |  1 +
>  2 files changed, 33 insertions(+)
>
> diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
> index b711000..0858b01 100644
> --- a/tests/util/piglit-util-gl.c
> +++ b/tests/util/piglit-util-gl.c
> @@ -1145,6 +1145,38 @@ piglit_probe_rect_rgb_silent(int x, int y, int w, int h, const float *expected)
>         return 1;
>  }
>
> +/* More efficient variant if you don't know need floats and GBA channels. */
> +int
> +piglit_probe_rect_r_ubyte(int x, int y, int w, int h, GLubyte expected)
> +{
> +       int i, j, w_aligned;
> +       GLubyte *pixels;
> +       GLubyte tolerance = ceil(piglit_tolerance[0] * 255);
> +
> +       w_aligned = ALIGN(w, 4);
> +       pixels = malloc(w_aligned * h);
> +
> +       glReadPixels(x, y, w, h, GL_RED, GL_UNSIGNED_BYTE, pixels);
> +
> +       for (j = 0; j < h; j++) {
> +               for (i = 0; i < w; i++) {
> +                       GLubyte probe = pixels[j*w_aligned+i];
> +
> +                       if (probe - expected >= tolerance) {

Looks like you want abs() here?


More information about the Piglit mailing list