<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 30, 2014 at 8:29 AM, Dylan Baker <span dir="ltr"><<a href="mailto:baker.dylan.c@gmail.com" target="_blank">baker.dylan.c@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Friday, June 27, 2014 04:31:54 PM Jason Ekstrand wrote:<br>
> This tests glCopyTexSubImage on all of the allowed combinations of internal<br>
> texture formats.<br>
><br>
> Signed-off-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>><br>
> ---<br>
>  tests/all.py                                |  77 +++++++<br>
>  tests/spec/arb_copy_image/CMakeLists.gl.txt |   1 +<br>
>  tests/spec/arb_copy_image/formats.c         | 334<br>
> ++++++++++++++++++++++++++++ 3 files changed, 412 insertions(+)<br>
>  create mode 100644 tests/spec/arb_copy_image/formats.c<br>
><br>
> diff --git a/tests/all.py b/tests/all.py<br>
> index 8235e6e..02fc9d2 100644<br>
> --- a/tests/all.py<br>
> +++ b/tests/all.py<br>
> @@ -3188,6 +3188,83 @@ add_concurrent_test(arb_copy_image,<br>
> 'arb_copy_image-targets GL_TEXTURE_3D 32 32<br>
> add_concurrent_test(arb_copy_image, 'arb_copy_image-targets GL_TEXTURE_3D<br>
> 32 32 17 GL_TEXTURE_CUBE_MAP_ARRAY 16 16 18 11 5 2 5 9 7 5 7 11')<br>
> add_concurrent_test(arb_copy_image, 'arb_copy_image-targets GL_TEXTURE_3D<br>
> 32 32 17 GL_TEXTURE_3D 32 16 18 11 5 2 5 9 7 14 7 11')<br>
><br>
> +def arb_copy_image_add_format_tests(formats):<br>
> +    for src_format in formats:<br>
> +        for dst_format in formats:<br>
> +            add_concurrent_test(arb_copy_image,'arb_copy_image-formats ' +<br>
> +                                src_format + ' ' + dst_format)<br>
<br>
</div></div>a couple of things:<br>
1) you're missing a space after the comma in add_concurrent_test<br>
2) using str.format() is almost always more readable than concat<br>
3) itertools is your friend<br>
<br>
for src, dst, in itertools.product(formats, repeat=2):<br>
        add_concurrent_test(<br>
                arb_copy_image,<br>
         'arb_copy_image-formats {0} {1}'.format(src, dst))<br></blockquote><div><br></div><div>Thanks, I've never used itertools before.  (I've wanted it for a while)<br></div><div>--Jason<br></div><div>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
> +<br>
> +arb_copy_image_add_format_tests([<br>
> +    'GL_R8UI',<br>
> +    'GL_R8I',<br>
> +    'GL_R8',<br>
> +    'GL_R8_SNORM',<br>
> +])<br>
> +arb_copy_image_add_format_tests([<br>
> +    'GL_RG8UI',<br>
> +    'GL_RG8I',<br>
> +    'GL_RG8',<br>
> +    'GL_RG8_SNORM',<br>
> +    'GL_R16UI',<br>
> +    'GL_R16I',<br>
> +    'GL_R16',<br>
> +    'GL_R16_SNORM',<br>
> +])<br>
> +arb_copy_image_add_format_tests([<br>
> +    'GL_RGB8UI',<br>
> +    'GL_RGB8I',<br>
> +    'GL_RGB8',<br>
> +    'GL_RGB8_SNORM',<br>
> +])<br>
> +arb_copy_image_add_format_tests([<br>
> +    'GL_RGBA8UI',<br>
> +    'GL_RGBA8I',<br>
> +    'GL_RGBA8',<br>
> +    'GL_RGBA8_SNORM',<br>
> +    'GL_RG16UI',<br>
> +    'GL_RG16I',<br>
> +    'GL_RG16',<br>
> +    'GL_RG16_SNORM',<br>
> +    'GL_R32F',<br>
> +])<br>
> +arb_copy_image_add_format_tests([<br>
> +    'GL_RGB16UI',<br>
> +    'GL_RGB16I',<br>
> +    'GL_RGB16',<br>
> +    'GL_RGB16_SNORM',<br>
> +])<br>
> +arb_copy_image_add_format_tests([<br>
> +    'GL_RGBA16UI',<br>
> +    'GL_RGBA16I',<br>
> +    'GL_RGBA16',<br>
> +    'GL_RGBA16_SNORM',<br>
> +    'GL_RG32UI',<br>
> +    'GL_RG32I',<br>
> +    'GL_RG32F',<br>
> +    'GL_COMPRESSED_RGB_S3TC_DXT1_EXT',<br>
> +    'GL_COMPRESSED_SRGB_S3TC_DXT1_EXT',<br>
> +    'GL_COMPRESSED_RGBA_S3TC_DXT1_EXT',<br>
> +    'GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT',<br>
> +    'GL_COMPRESSED_RED_RGTC1',<br>
> +    'GL_COMPRESSED_SIGNED_RED_RGTC1',<br>
> +])<br>
> +arb_copy_image_add_format_tests([<br>
> +    'GL_RGB32UI',<br>
> +    'GL_RGB32I',<br>
> +    'GL_RGB32F',<br>
> +])<br>
> +arb_copy_image_add_format_tests([<br>
> +    'GL_RGBA32UI',<br>
> +    'GL_RGBA32I',<br>
> +    'GL_RGBA32F',<br>
> +    'GL_COMPRESSED_RGBA_S3TC_DXT3_EXT',<br>
> +    'GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT',<br>
> +    'GL_COMPRESSED_RGBA_S3TC_DXT5_EXT',<br>
> +    'GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT',<br>
> +    'GL_COMPRESSED_RG_RGTC2',<br>
> +    'GL_COMPRESSED_SIGNED_RG_RGTC2',<br>
> +])<br>
> +<br>
>  arb_half_float_vertex = {}<br>
>  spec['ARB_half_float_vertex'] = arb_half_float_vertex<br>
>  add_plain_test(arb_half_float_vertex, 'draw-vertices-half-float')<br>
> diff --git a/tests/spec/arb_copy_image/CMakeLists.gl.txt<br>
> b/tests/spec/arb_copy_image/CMakeLists.gl.txt index f0d631a..c8b0406 100644<br>
> --- a/tests/spec/arb_copy_image/CMakeLists.gl.txt<br>
> +++ b/tests/spec/arb_copy_image/CMakeLists.gl.txt<br>
> @@ -10,5 +10,6 @@ link_libraries (<br>
><br>
>  piglit_add_executable (arb_copy_image-simple simple.c)<br>
>  piglit_add_executable (arb_copy_image-targets targets.c)<br>
> +piglit_add_executable (arb_copy_image-formats formats.c)<br>
><br>
>  # vim: ft=cmake:<br>
> diff --git a/tests/spec/arb_copy_image/formats.c<br>
> b/tests/spec/arb_copy_image/formats.c new file mode 100644<br>
> index 0000000..fdc4584<br>
> --- /dev/null<br>
> +++ b/tests/spec/arb_copy_image/formats.c<br>
> @@ -0,0 +1,334 @@<br>
> +/*<br>
> + * Copyright 2014 Intel Corporation<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the<br>
> "Software"), + * to deal in the Software without restriction, including<br>
> without limitation + * the rights to use, copy, modify, merge, publish,<br>
> distribute, sublicense, + * and/or sell copies of the Software, and to<br>
> permit persons to whom the + * Software is furnished to do so, subject to<br>
> the following conditions: + *<br>
> + * The above copyright notice and this permission notice (including the<br>
> next + * paragraph) shall be included in all copies or substantial portions<br>
> of the + * Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS<br>
> OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
> MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.<br>
> IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY<br>
> CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT,<br>
> TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE<br>
> SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE.<br>
> + */<br>
> +<br>
> +/*<br>
> + * This tests glCopySubImageData on different (possibly compressed) texture<br>
> + * formats.  One texture is created and filled with random data.  The + *<br>
> texture is then copied to a second texture, the texture is downloaded, + *<br>
> and the data verified.  Because glCopySubImageData is supposed to be a + *<br>
> direct memcpy, the copy is verified to be bit-for-bit copy of the + *<br>
> original.<br>
> + */<br>
> +<br>
> +#include "piglit-util-gl-common.h"<br>
> +<br>
> +#define TEX_SIZE 32<br>
> +<br>
> +PIGLIT_GL_TEST_CONFIG_BEGIN<br>
> +<br>
> +     config.supports_gl_compat_version = 13;<br>
> +<br>
> +     config.window_width = TEX_SIZE * 12;<br>
> +     config.window_height = TEX_SIZE * 4;<br>
> +     config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;<br>
> +<br>
> +PIGLIT_GL_TEST_CONFIG_END<br>
> +<br>
> +struct texture_format {<br>
> +     GLenum internal_format;<br>
> +     const char *name;<br>
> +     GLenum format;<br>
> +     GLenum data_type;<br>
> +     GLuint bytes;<br>
> +     GLuint block_width;<br>
> +     GLuint block_height;<br>
> +};<br>
> +<br>
> +#define FORMAT(IF, F, D, B, W, H) { IF, #IF, F, D, B, W, H }<br>
> +<br>
> +struct texture_format formats[] = {<br>
> +     FORMAT(GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, 1, 1, 1),<br>
> +     FORMAT(GL_R8I, GL_RED_INTEGER, GL_BYTE, 1, 1, 1),<br>
> +     FORMAT(GL_R8, GL_RED, GL_UNSIGNED_BYTE, 1, 1, 1),<br>
> +     FORMAT(GL_R8_SNORM, GL_RED, GL_BYTE, 1, 1, 1),<br>
> +<br>
> +     FORMAT(GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE, 2, 1, 1),<br>
> +     FORMAT(GL_RG8I, GL_RG_INTEGER, GL_BYTE, 2, 1, 1),<br>
> +     FORMAT(GL_RG8, GL_RG, GL_UNSIGNED_BYTE, 2, 1, 1),<br>
> +     FORMAT(GL_RG8_SNORM, GL_RG, GL_BYTE, 2, 1, 1),<br>
> +     FORMAT(GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, 2, 1, 1),<br>
> +     FORMAT(GL_R16I, GL_RED_INTEGER, GL_SHORT, 2, 1, 1),<br>
> +     FORMAT(GL_R16, GL_RED, GL_UNSIGNED_SHORT, 2, 1, 1),<br>
> +     FORMAT(GL_R16_SNORM, GL_RED, GL_SHORT, 2, 1, 1),<br>
> +<br>
> +     FORMAT(GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, 3, 1, 1),<br>
> +     FORMAT(GL_RGB8I, GL_RGB_INTEGER, GL_BYTE, 3, 1, 1),<br>
> +     FORMAT(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, 3, 1, 1),<br>
> +     FORMAT(GL_RGB8_SNORM, GL_RGB, GL_BYTE, 3, 1, 1),<br>
> +<br>
> +     FORMAT(GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, 4, 1, 1),<br>
> +     FORMAT(GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE, 4, 1, 1),<br>
> +     FORMAT(GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, 1),<br>
> +     FORMAT(GL_RGBA8_SNORM, GL_RGBA, GL_BYTE, 4, 1, 1),<br>
> +     FORMAT(GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, 4, 1, 1),<br>
> +     FORMAT(GL_RG16I, GL_RG_INTEGER, GL_SHORT, 4, 1, 1),<br>
> +     FORMAT(GL_RG16, GL_RG, GL_UNSIGNED_SHORT, 4, 1, 1),<br>
> +     FORMAT(GL_RG16_SNORM, GL_RG, GL_SHORT, 4, 1, 1),<br>
> +     FORMAT(GL_R32F, GL_RED, GL_FLOAT, 4, 1, 1),<br>
> +<br>
> +     FORMAT(GL_RGB16UI, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, 6, 1, 1),<br>
> +     FORMAT(GL_RGB16I, GL_RGB_INTEGER, GL_SHORT, 6, 1, 1),<br>
> +     FORMAT(GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT, 6, 1, 1),<br>
> +     FORMAT(GL_RGB16_SNORM, GL_RGB, GL_SHORT, 6, 1, 1),<br>
> +<br>
> +     FORMAT(GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, 8, 1, 1),<br>
> +     FORMAT(GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT, 8, 1, 1),<br>
> +     FORMAT(GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, 8, 1, 1),<br>
> +     FORMAT(GL_RGBA16_SNORM, GL_RGBA, GL_SHORT, 8, 1, 1),<br>
> +     FORMAT(GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT, 8, 1, 1),<br>
> +     FORMAT(GL_RG32I, GL_RG_INTEGER, GL_INT, 8, 1, 1),<br>
> +     FORMAT(GL_RG32F, GL_RG, GL_FLOAT, 8, 1, 1),<br>
> +<br>
> +     FORMAT(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RED, GL_BYTE, 8, 4, 4),<br>
> +     FORMAT(GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, GL_RED, GL_BYTE, 8, 4, 4),<br>
> +     FORMAT(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_RED, GL_BYTE, 8, 4, 4),<br>
> +     FORMAT(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_RED, GL_BYTE, 8, 4, 4),<br>
> +     FORMAT(GL_COMPRESSED_RED_RGTC1, GL_RED, GL_BYTE, 8, 4, 4),<br>
> +     FORMAT(GL_COMPRESSED_SIGNED_RED_RGTC1, GL_RED, GL_BYTE, 8, 4, 4),<br>
> +<br>
> +     FORMAT(GL_RGB32UI, GL_RGB_INTEGER, GL_UNSIGNED_INT, 12, 1, 1),<br>
> +     FORMAT(GL_RGB32I, GL_RGB_INTEGER, GL_INT, 12, 1, 1),<br>
> +     FORMAT(GL_RGB32F, GL_RGB, GL_FLOAT, 12, 1, 1),<br>
> +<br>
> +     FORMAT(GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 16, 1, 1),<br>
> +     FORMAT(GL_RGBA32I, GL_RGBA_INTEGER, GL_INT, 16, 1, 1),<br>
> +     FORMAT(GL_RGBA32F, GL_RGBA, GL_FLOAT, 16, 1, 1),<br>
> +<br>
> +     FORMAT(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RED, GL_BYTE, 16, 4, 4),<br>
> +     FORMAT(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_RED, GL_BYTE, 16, 4,<br>
4),<br>
> +     FORMAT(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RED, GL_BYTE, 16, 4, 4),<br>
> +     FORMAT(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_RED, GL_BYTE, 16, 4,<br>
> 4), + FORMAT(GL_COMPRESSED_RG_RGTC2, GL_RED, GL_BYTE, 16, 4, 4),<br>
> +     FORMAT(GL_COMPRESSED_SIGNED_RG_RGTC2, GL_RED, GL_BYTE, 16, 4, 4),<br>
> +<br>
> +#ifdef GL_COMPRESSED_RGBA_BPTC_UNORM<br>
> +     FORMAT(GL_COMPRESSED_RGBA_BPTC_UNORM, GL_RGBA, GL_BYTE, 16, 4, 4),<br>
> +     FORMAT(GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, GL_RGB, GL_BYTE, 16, 4, 4),<br>
> +     FORMAT(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, GL_RGB, GL_BYTE, 16, 4, 4),<br>
> +     FORMAT(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, GL_RGB, GL_BYTE, 16, 4, 4),<br>
> +#endif<br>
> +};<br>
> +<br>
> +#undef FORMAT<br>
> +<br>
> +struct texture_format *<br>
> +find_format(const char *str)<br>
> +{<br>
> +     int i;<br>
> +<br>
> +     for (i = 0; i < sizeof(formats) / sizeof(*formats); ++i)<br>
> +             if (strcmp(str, formats[i].name) == 0)<br>
> +                     return &formats[i];<br>
> +<br>
> +     return NULL;<br>
> +}<br>
> +<br>
> +struct texture_format *src_format, *dst_format;<br>
> +unsigned char *src_data, *dst_data, *result;<br>
> +<br>
> +void<br>
> +piglit_init(int argc, char **argv)<br>
> +{<br>
> +     int i, seed;<br>
> +<br>
> +     if (sscanf(argv[1], "--seed=%d", &seed) > 0) {<br>
> +             srand(seed);<br>
> +             --argc;<br>
> +             ++argv;<br>
> +     } else {<br>
> +             srand(0);<br>
> +     }<br>
> +<br>
> +     if (argc < 2) {<br>
> +             printf("usage: [--seed=seed] arb_copy_image-formats src_format<br>
> dst_format"); +               exit(1);<br>
> +     }<br>
> +<br>
> +     piglit_require_extension("GL_ARB_copy_image");<br>
> +<br>
> +     src_format = find_format(argv[1]);<br>
> +     assert(src_format != NULL);<br>
> +<br>
> +     dst_format = find_format(argv[2]);<br>
> +     assert(dst_format != NULL);<br>
> +<br>
> +     assert(dst_format->bytes == src_format->bytes);<br>
> +<br>
> +     src_data = malloc(TEX_SIZE * TEX_SIZE * src_format->bytes);<br>
> +     dst_data = malloc(TEX_SIZE * TEX_SIZE * dst_format->bytes);<br>
> +     result = malloc(TEX_SIZE * TEX_SIZE * dst_format->bytes);<br>
> +<br>
> +     if (src_format->data_type == GL_FLOAT ||<br>
> +         dst_format->data_type == GL_FLOAT) {<br>
> +             /* If it's a floating-point type, let's avoid using invalid<br>
> +              * floating-point values.  That might throw things off */<br>
> +<br>
> +             for (i = 0; i < TEX_SIZE * TEX_SIZE * src_format->bytes /<br>
sizeof(float);<br>
> ++i) +                        ((float *)src_data)[i] = rand() / (float)RAND_MAX;<br>
> +<br>
> +             for (i = 0; i < TEX_SIZE * TEX_SIZE * src_format->bytes /<br>
sizeof(float);<br>
> ++i) +                        ((float *)dst_data)[i] = rand() / (float)RAND_MAX;<br>
> +     } else {<br>
> +             for (i = 0; i < TEX_SIZE * TEX_SIZE * src_format->bytes; ++i)<br>
> +                     src_data[i] = rand();<br>
> +<br>
> +             for (i = 0; i < TEX_SIZE * TEX_SIZE * src_format->bytes; ++i)<br>
> +                     dst_data[i] = rand();<br>
> +     }<br>
> +<br>
> +     memcpy(result,<br>
> +            dst_data,<br>
> +            (TEX_SIZE / 4) * TEX_SIZE * src_format->bytes);<br>
> +     for (i = TEX_SIZE / 4; i < (TEX_SIZE / 4) * 3; ++i) {<br>
> +             memcpy(result + (i * TEX_SIZE) * src_format->bytes,<br>
> +                    dst_data + (i * TEX_SIZE) * src_format->bytes,<br>
> +                    (TEX_SIZE / 4) * src_format->bytes);<br>
> +<br>
> +             memcpy(result + (i * TEX_SIZE + TEX_SIZE / 4) * src_format->bytes,<br>
> +                    src_data + (i * TEX_SIZE + TEX_SIZE / 4) * src_format->bytes,<br>
> +                    (TEX_SIZE / 2) * src_format->bytes);<br>
> +<br>
> +             memcpy(result + (i * TEX_SIZE + (TEX_SIZE / 4) * 3) * src_format-<br>
>bytes,<br>
> +                    dst_data + (i * TEX_SIZE + (TEX_SIZE / 4) * 3) *<br>
> src_format->bytes, +                 (TEX_SIZE / 4) * src_format->bytes);<br>
> +     }<br>
> +     memcpy(result + ((TEX_SIZE / 4) * 3) * TEX_SIZE * src_format->bytes,<br>
> +            dst_data + ((TEX_SIZE / 4) * 3) * TEX_SIZE * src_format->bytes,<br>
> +            (TEX_SIZE / 4) * TEX_SIZE * src_format->bytes);<br>
> +}<br>
> +<br>
> +bool<br>
> +check_texture(GLuint texture, struct texture_format *format,<br>
> +           unsigned char *data)<br>
> +{<br>
> +     int i, j, k;<br>
> +     bool pass = true;<br>
> +     unsigned char *tex_data;<br>
> +     float passrate;<br>
> +<br>
> +     tex_data = malloc(TEX_SIZE * TEX_SIZE * format->bytes);<br>
> +<br>
> +     glBindTexture(GL_TEXTURE_2D, texture);<br>
> +     if (format->block_width != 1 || format->block_height != 1) {<br>
> +             /* Compressed */<br>
> +             glGetCompressedTexImage(GL_TEXTURE_2D, 0, tex_data);<br>
> +     } else {<br>
> +             glGetTexImage(GL_TEXTURE_2D, 0, format->format,<br>
> +                           format->data_type, tex_data);<br>
> +     }<br>
> +<br>
> +     passrate = 0;<br>
> +     for (j = 0; j < TEX_SIZE; ++j) {<br>
> +             for (i = 0; i < TEX_SIZE; ++i) {<br>
> +                     if (memcmp(tex_data + ((j * TEX_SIZE) + i) * format->bytes,<br>
> +                                data + ((j * TEX_SIZE) + i) * format->bytes,<br>
> +                                format->bytes) == 0) {<br>
> +                             passrate += 1;<br>
> +                     } else {<br>
> +                             fprintf(stdout, "texel mismatch at (%d, %d); expected 0x",<br>
> +                                     i, j);<br>
> +                             for (k = format->bytes - 1; k >= 0; --k)<br>
> +                                     fprintf(stdout, "%02x", data[((j * TEX_SIZE) + i) *<br>
format->bytes +<br>
> k]); +<br>
> +                             fprintf(stdout, ", received 0x");<br>
> +                             for (k = format->bytes - 1; k >= 0; --k)<br>
> +                                     fprintf(stdout, "%02x", tex_data[((j * TEX_SIZE) + i) *<br>
format->bytes<br>
> + k]); +                              fprintf(stdout, ".\n");<br>
> +<br>
> +                             pass = false;<br>
> +                     }<br>
> +             }<br>
> +     }<br>
> +     passrate /= TEX_SIZE * TEX_SIZE;<br>
> +     printf("%0.1f%% of pixels match\n", passrate * 100);<br>
> +<br>
> +     return pass;<br>
> +}<br>
> +<br>
> +enum piglit_result<br>
> +piglit_display(void)<br>
> +{<br>
> +     bool pass = true;<br>
> +     GLuint texture[2];<br>
> +     GLuint src_width, src_height, dst_width, dst_height;<br>
> +<br>
> +     glEnable(GL_TEXTURE_2D);<br>
> +<br>
> +     glGenTextures(2, texture);<br>
> +<br>
> +     src_width = TEX_SIZE * src_format->block_width;<br>
> +     src_height = TEX_SIZE * src_format->block_height;<br>
> +<br>
> +     glBindTexture(GL_TEXTURE_2D, texture[0]);<br>
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);<br>
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);<br>
> +     if (src_format->block_width != 1 || src_format->block_height != 1) {<br>
> +             /* Compressed */<br>
> +             glCompressedTexImage2D(GL_TEXTURE_2D, 0,<br>
> +                                    src_format->internal_format,<br>
> +                                    src_width, src_height, 0,<br>
> +                                    TEX_SIZE * TEX_SIZE * src_format->bytes,<br>
> +                                    src_data);<br>
> +     } else {<br>
> +             glTexImage2D(GL_TEXTURE_2D, 0, src_format->internal_format,<br>
> +                          src_width, src_height, 0, src_format->format,<br>
> +                          src_format->data_type, src_data);<br>
> +     }<br>
> +     pass &= piglit_check_gl_error(GL_NO_ERROR);<br>
> +     pass &= check_texture(texture[0], src_format, src_data);<br>
> +<br>
> +     dst_width = TEX_SIZE * dst_format->block_width;<br>
> +     dst_height = TEX_SIZE * dst_format->block_height;<br>
> +<br>
> +     glBindTexture(GL_TEXTURE_2D, texture[1]);<br>
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);<br>
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);<br>
> +     if (dst_format->block_width != 1 || dst_format->block_height != 1) {<br>
> +             /* Compressed */<br>
> +             glCompressedTexImage2D(GL_TEXTURE_2D, 0,<br>
> +                                    dst_format->internal_format,<br>
> +                                    dst_width, dst_height, 0,<br>
> +                                    TEX_SIZE * TEX_SIZE * dst_format->bytes,<br>
> +                                    dst_data);<br>
> +     } else {<br>
> +             glTexImage2D(GL_TEXTURE_2D, 0, dst_format->internal_format,<br>
> +                          dst_width, dst_height, 0, dst_format->format,<br>
> +                          dst_format->data_type, dst_data);<br>
> +     }<br>
> +     pass &= piglit_check_gl_error(GL_NO_ERROR);<br>
> +     pass &= check_texture(texture[1], dst_format, dst_data);<br>
> +<br>
> +     glCopyImageSubData(texture[0], GL_TEXTURE_2D, 0,<br>
> +                        src_width / 4, src_height / 4, 0,<br>
> +                        texture[1], GL_TEXTURE_2D, 0,<br>
> +                        dst_width / 4, dst_height / 4, 0,<br>
> +                        src_width / 2, src_height / 2, 1);<br>
> +     pass &= piglit_check_gl_error(GL_NO_ERROR);<br>
> +     pass &= check_texture(texture[1], dst_format, result);<br>
> +<br>
> +     glDeleteTextures(2, texture);<br>
> +<br>
> +     glDisable(GL_TEXTURE_2D);<br>
> +<br>
> +     return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
> +}<br>
</div></div></blockquote></div><br></div></div>