[Piglit] [PATCH] s3tc-errors: test GL error checking with s3tc textures
Eric Anholt
eric at anholt.net
Thu Sep 27 10:17:50 PDT 2012
Brian Paul <brian.e.paul at gmail.com> writes:
> From: Brian Paul <brianp at vmware.com>
>
> 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 <eric at anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20120927/7b50f4b5/attachment.pgp>
More information about the Piglit
mailing list