Brian Paul <[email protected]> writes:

> From: Brian Paul <[email protected]>
>
> Check for expected OpenGL errors related to texture compression.  For
> example, glCompresedTexSubImage2D() offset/size values must be multiples
> of four.
>
> This test could be expanded to cover other compression formats in the future.
>
> Also, this test contains some texture compression helper functions that could
> be made into piglit utility functions.

Testing edits of the edges of an NPOT texture would be nice, but this
looks like a great improvement in our coverage.

> +/**
> + * Compute size (in bytes) neede to store an image in the given compressed
> + * format.
> + * XXX this could be a piglit utility function someday
> + */
> +static int
> +compressed_image_size(GLenum format, int width, int height)
> +{
> +     int bw, bh, bytes;
> +     get_compressed_block_size(format, &bw, &bh, &bytes);
> +     return width / bw * height / bh * bytes;
> +}

If we're thinking someone would move this to util some day, we should
probably either round up to block size, or assert that w/h are already
aligned, like the function below.

> +static bool
> +test_formats(void)
> +{
> +     const int num_formats = ARRAY_SIZE(s3tc_formats);
> +     const int width = 128, height = 64;
> +     GLfloat *image = piglit_rgbw_image(GL_RGBA, width, height,
> +                                        GL_FALSE, /* alpha */
> +                                        GL_UNSIGNED_NORMALIZED);
> +     int i;
> +     bool pass = true;
> +
> +     for (i = 0; i < num_formats; i++) {
> +             const GLenum format = s3tc_formats[i];
> +             pass = test_format(width, height, image, format) && pass;
> +     }
> +
> +     glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
> +     glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
> +     glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
> +
> +     free(image);
> +
> +     return pass;
> +}
> +
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +     return test_formats() ? PIGLIT_PASS : PIGLIT_FAIL;
> +}

Having two separate functions here looks pretty silly.

Other than that,

Reviewed-by: Eric Anholt <[email protected]>

Attachment: pgpQhofSoGvoq.pgp
Description: PGP signature

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to