[Piglit] [PATCH 2/3] ARB_copy_image: Add a test for testing different texture target combinations
Jason Ekstrand
jason at jlekstrand.net
Mon Jun 30 10:19:05 PDT 2014
On Mon, Jun 30, 2014 at 7:49 AM, Dylan Baker <baker.dylan.c at gmail.com>
wrote:
> On Friday, June 27, 2014 04:31:53 PM Jason Ekstrand wrote:
> > This tests all of the possible different combinations of texture targets
> > such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, GL_TEXTURE_1D_ARRAY, etc.
> The
> > only targets not tested are GL_TEXTURE_2D_MULTISAMPLE and
> > GL_TEXTURE_2D_MULTISAMPLE_ARRAY but those are special.
> >
> > Signed-off-by: Jason Ekstrand <jason.ekstrand at intel.com>
> > ---
> > tests/all.py | 72 +++++
> > tests/spec/arb_copy_image/CMakeLists.gl.txt | 1 +
> > tests/spec/arb_copy_image/targets.c | 404
> > ++++++++++++++++++++++++++++ 3 files changed, 477 insertions(+)
> > create mode 100644 tests/spec/arb_copy_image/targets.c
> >
> > diff --git a/tests/all.py b/tests/all.py
> > index 9e6196e..8235e6e 100644
> > --- a/tests/all.py
> > +++ b/tests/all.py
> > @@ -3116,6 +3116,78 @@ add_concurrent_test(arb_copy_image,
> > 'arb_copy_image-simple --tex-to-tex') add_concurrent_test(arb_copy_image,
> > 'arb_copy_image-simple --rb-to-tex') add_concurrent_test(arb_copy_image,
> > 'arb_copy_image-simple --rb-to-rb')
> >
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_1D
> > 32 1 1 GL_TEXTURE_1D 32 1 1 11 0 0 5 0 0 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_1D
> > 32 1 1 GL_TEXTURE_1D_ARRAY 32 1 12 11 0 0 5 0 9 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_1D
> > 32 1 1 GL_TEXTURE_2D 32 32 1 11 0 0 5 13 0 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_1D
> > 32 1 1 GL_TEXTURE_RECTANGLE 32 32 1 11 0 0 5 13 0 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_1D
> > 32 1 1 GL_TEXTURE_2D_ARRAY 32 32 10 11 0 0 5 13 4 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_1D
> > 32 1 1 GL_TEXTURE_CUBE_MAP 32 32 6 11 0 0 5 13 4 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_1D
> > 32 1 1 GL_TEXTURE_CUBE_MAP_ARRAY 32 32 30 11 0 0 5 13 8 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_1D
> > 32 1 1 GL_TEXTURE_3D 32 32 32 11 0 0 5 13 4 14 1 1') +
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_1D_ARRAY 32 1 12 GL_TEXTURE_1D 32 1 1 11 0 7 5 0 0 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_1D_ARRAY 32 1 12 GL_TEXTURE_1D_ARRAY 32 1 16 11 0 3 5 0 7 14 1
> > 8') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_1D_ARRAY 32 1 12 GL_TEXTURE_2D 32 16 1 11 0 3 5 7 0 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_1D_ARRAY 32 1 12 GL_TEXTURE_RECTANGLE 32 16 1 11 0 3 5 7 0 14
> 1
> > 1') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_1D_ARRAY 32 1 12 GL_TEXTURE_2D_ARRAY 32 16 18 11 0 3 5 9 7 14
> 1
> > 8') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_1D_ARRAY 32 1 12 GL_TEXTURE_CUBE_MAP 32 32 6 11 0 3 5 17 2 14
> 1
> > 3') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_1D_ARRAY 32 1 12 GL_TEXTURE_CUBE_MAP_ARRAY 32 32 18 11 0 3 5
> 17
> > 2 14 1 7') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_1D_ARRAY 32 1 12 GL_TEXTURE_3D 32 16 18 11 0 3 5 9 2 14 1 7')
> +
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_2D
> > 32 32 1 GL_TEXTURE_1D 32 1 1 11 23 0 5 0 0 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_2D
> > 32 32 1 GL_TEXTURE_1D_ARRAY 32 1 16 11 2 0 5 0 7 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_2D
> > 32 32 1 GL_TEXTURE_2D 32 16 1 11 12 0 5 7 0 14 9 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_2D
> > 32 32 1 GL_TEXTURE_RECTANGLE 32 16 1 11 12 0 5 7 0 14 9 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_2D
> > 32 32 1 GL_TEXTURE_2D_ARRAY 32 16 15 11 12 0 5 7 12 14 8 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_2D
> > 32 32 1 GL_TEXTURE_CUBE_MAP 32 32 6 11 5 0 5 9 2 14 7 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_2D
> > 32 32 1 GL_TEXTURE_CUBE_MAP_ARRAY 32 32 18 11 5 0 5 9 7 14 7 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_2D
> > 32 32 1 GL_TEXTURE_3D 32 16 18 11 5 0 5 9 7 14 7 1') +
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_RECTANGLE 32 32 1 GL_TEXTURE_1D 32 1 1 11 23 0 5 0 0 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_RECTANGLE 32 32 1 GL_TEXTURE_1D_ARRAY 32 1 16 11 2 0 5 0 7 14
> 1
> > 1') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_RECTANGLE 32 32 1 GL_TEXTURE_2D 32 16 1 11 12 0 5 7 0 14 7 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_RECTANGLE 32 32 1 GL_TEXTURE_RECTANGLE 32 16 1 11 12 0 5 7 0
> 14
> > 9 1') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_RECTANGLE 32 32 1 GL_TEXTURE_2D_ARRAY 32 16 15 11 12 0 5 7 12
> 14
> > 8 1') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_RECTANGLE 32 32 1 GL_TEXTURE_CUBE_MAP 32 32 6 11 5 0 5 9 2 14
> 7
> > 1') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_RECTANGLE 32 32 1 GL_TEXTURE_CUBE_MAP_ARRAY 32 32 18 11 5 0 5
> 9
> > 7 14 7 1') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_RECTANGLE 32 32 1 GL_TEXTURE_3D 32 16 18 11 5 0 5 9 7 14 7
> 1') +
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_2D_ARRAY 32 32 15 GL_TEXTURE_1D 32 1 1 11 23 7 5 0 0 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_2D_ARRAY 32 32 15 GL_TEXTURE_1D_ARRAY 32 1 16 11 2 5 5 0 7 14
> 1
> > 7') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_2D_ARRAY 32 32 15 GL_TEXTURE_2D 32 16 1 11 12 13 5 4 0 14 10
> 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_2D_ARRAY 32 32 15 GL_TEXTURE_RECTANGLE 32 16 1 11 12 13 5 7 0
> 14
> > 7 1') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_2D_ARRAY 32 32 15 GL_TEXTURE_2D_ARRAY 32 16 15 11 12 5 5 7 2
> 14
> > 9 9') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_2D_ARRAY 32 32 15 GL_TEXTURE_CUBE_MAP 32 32 6 11 5 1 5 9 2 14
> 7
> > 3') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_2D_ARRAY 32 32 15 GL_TEXTURE_CUBE_MAP_ARRAY 32 32 18 11 5 2 5
> 9
> > 7 14 7 11') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_2D_ARRAY 32 32 15 GL_TEXTURE_3D 32 16 18 11 5 2 5 9 7 14 7
> 11')
> > +
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP 32 32 6 GL_TEXTURE_1D 32 1 1 11 23 3 5 0 0 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP 32 32 6 GL_TEXTURE_1D_ARRAY 32 1 16 11 2 3 5 0 7 14 1
> > 2') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP 32 32 6 GL_TEXTURE_2D 32 16 1 11 12 3 5 7 0 14 9 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP 32 32 6 GL_TEXTURE_RECTANGLE 32 16 1 11 12 3 5 3 0 14
> > 12 1') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP 32 32 6 GL_TEXTURE_2D_ARRAY 32 16 15 11 12 1 5 3 2 14
> > 11 4') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP 32 32 6 GL_TEXTURE_CUBE_MAP 32 32 6 11 5 1 5 9 2 14 7
> > 3') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP 32 32 6 GL_TEXTURE_CUBE_MAP_ARRAY 32 32 18 11 5 1 5
> 9 9
> > 14 7 5') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP 32 32 6 GL_TEXTURE_3D 32 16 18 11 5 0 5 9 7 14 7 4')
> +
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP_ARRAY 32 32 18 GL_TEXTURE_1D 32 1 1 11 23 7 5 0 0 14
> 1
> > 1') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP_ARRAY 32 32 18 GL_TEXTURE_1D_ARRAY 32 1 16 11 2 5 5
> 0 7
> > 14 1 7') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP_ARRAY 32 32 18 GL_TEXTURE_2D 32 16 1 11 12 13 5 7 0
> 14
> > 8 1') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP_ARRAY 32 32 18 GL_TEXTURE_RECTANGLE 32 16 1 11 12 13
> 5
> > 7 0 14 6 1') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP_ARRAY 32 32 18 GL_TEXTURE_2D_ARRAY 32 16 15 11 12 5
> 5 1
> > 2 14 15 9') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP_ARRAY 32 32 18 GL_TEXTURE_CUBE_MAP 16 16 6 11 5 1 5
> 9 2
> > 5 7 3') +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> > GL_TEXTURE_CUBE_MAP_ARRAY 32 32 18 GL_TEXTURE_CUBE_MAP_ARRAY 16 16 18 11
> 5
> > 2 5 9 7 5 7 11') +add_concurrent_test(arb_copy_image,
> > 'arb_copy_image-targets GL_TEXTURE_CUBE_MAP_ARRAY 32 32 18 GL_TEXTURE_3D
> 32
> > 16 18 11 5 2 5 9 7 14 7 11') +
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_3D
> > 32 32 17 GL_TEXTURE_1D 32 1 1 11 23 7 5 0 0 14 1 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_3D
> > 32 32 17 GL_TEXTURE_1D_ARRAY 32 1 16 11 2 5 5 0 7 14 1 7')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_3D
> > 32 32 17 GL_TEXTURE_2D 32 16 1 11 12 13 5 7 0 14 7 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_3D
> > 32 32 17 GL_TEXTURE_RECTANGLE 32 16 1 11 12 13 5 7 0 14 9 1')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_3D
> > 32 32 17 GL_TEXTURE_2D_ARRAY 32 16 15 11 12 5 5 3 2 14 13 9')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_3D
> > 32 32 17 GL_TEXTURE_CUBE_MAP 16 16 6 11 5 1 5 9 2 5 7 3')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_3D
> > 32 32 17 GL_TEXTURE_CUBE_MAP_ARRAY 16 16 18 11 5 2 5 9 7 5 7 11')
> > +add_concurrent_test(arb_copy_image, 'arb_copy_image-targets
> GL_TEXTURE_3D
> > 32 32 17 GL_TEXTURE_3D 32 16 18 11 5 2 5 9 7 14 7 11') +
> > arb_half_float_vertex = {}
> > spec['ARB_half_float_vertex'] = arb_half_float_vertex
> > add_plain_test(arb_half_float_vertex, 'draw-vertices-half-float')
>
> just a suggestion/fyi: you can use loops in tests/*py
>
Yeah, unfortuately, that one's no real loopable.
--Jason
>
> > diff --git a/tests/spec/arb_copy_image/CMakeLists.gl.txt
> > b/tests/spec/arb_copy_image/CMakeLists.gl.txt index ac8ddcc..f0d631a
> 100644
> > --- a/tests/spec/arb_copy_image/CMakeLists.gl.txt
> > +++ b/tests/spec/arb_copy_image/CMakeLists.gl.txt
> > @@ -9,5 +9,6 @@ link_libraries (
> > )
> >
> > piglit_add_executable (arb_copy_image-simple simple.c)
> > +piglit_add_executable (arb_copy_image-targets targets.c)
> >
> > # vim: ft=cmake:
> > diff --git a/tests/spec/arb_copy_image/targets.c
> > b/tests/spec/arb_copy_image/targets.c new file mode 100644
> > index 0000000..dff6554
> > --- /dev/null
> > +++ b/tests/spec/arb_copy_image/targets.c
> > @@ -0,0 +1,404 @@
> > +/*
> > + * Copyright 2014 Intel Corporation
> > + *
> > + * Permission is hereby granted, free of charge, to any person
> obtaining a
> > + * copy of this software and associated documentation files (the
> > "Software"), + * to deal in the Software without restriction, including
> > without limitation + * the rights to use, copy, modify, merge, publish,
> > distribute, sublicense, + * and/or sell copies of the Software, and to
> > permit persons to whom the + * Software is furnished to do so, subject to
> > the following conditions: + *
> > + * The above copyright notice and this permission notice (including the
> > next + * paragraph) shall be included in all copies or substantial
> portions
> > of the + * Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS
> > OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> > MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND
> NONINFRINGEMENT.
> > IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
> > CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
> > TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE
> > SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE.
> > + */
> > +
> > +/*
> > + * This tests copySubImageData on 3D targets. The maximum testable
> > + * textures size is 32x32x32 due to the way the textures are
> > + * displayed/verified. One texture is filled with a red background and
> a
> > + * green solid in the foreground. Then the green solid is copied to a
> blue
> > + * texture. The results are then verified. This can test all possible
> +
> > * combinations of texture targets.
> > + */
> > +
> > +#include "piglit-util-gl-common.h"
> > +
> > +PIGLIT_GL_TEST_CONFIG_BEGIN
> > +
> > + config.supports_gl_compat_version = 13;
> > +
> > + config.window_width = 34 * 8;
> > + config.window_height = 34 * 8;
> > + config.window_visual = PIGLIT_GL_VISUAL_RGB |
> PIGLIT_GL_VISUAL_DOUBLE;
> > +
> > +PIGLIT_GL_TEST_CONFIG_END
> > +
> > +static const float green[3] = {0.0, 1.0, 0.0};
> > +static const float red[3] = {1.0, 0.0, 0.0};
> > +static const float blue[3] = {0.0, 0.0, 1.0};
> > +
> > +GLuint prog_1d_array, prog_1D_array;
> > +
> > +struct image {
> > + GLuint texture;
> > + GLenum target;
> > + int width, height, depth;
> > +};
> > +
> > +struct volume {
> > + int x, y, z;
> > + int w, h, d;
> > +};
> > +
> > +void
> > +image_init(struct image *image, GLenum target, int width, int height,
> int
> > depth) +{
> > + switch (target) {
> > + case GL_TEXTURE_CUBE_MAP:
> > + assert(depth == 6);
> > + case GL_TEXTURE_CUBE_MAP_ARRAY_ARB:
> > + assert(width == height);
> > + assert(depth % 6 == 0);
> > + break;
> > + case GL_TEXTURE_1D:
> > + assert(height == 1);
> > + case GL_TEXTURE_2D:
> > + case GL_TEXTURE_RECTANGLE:
> > + assert(depth == 1);
> > + break;
> > + case GL_TEXTURE_1D_ARRAY:
> > + assert(height == 1);
> > + break;
> > + }
> > +
> > + /* Cube maps are always 6 deep */
> > + if (target == GL_TEXTURE_CUBE_MAP)
> > + assert(depth == 6);
> > +
> > + /* Cube map arrays always must be a multiple of 6 */
> > + if (target == GL_TEXTURE_CUBE_MAP_ARRAY_ARB)
> > + assert(depth % 6 == 0);
> > +
> > + image->target = target;
> > + image->width = width;
> > + image->height = height;
> > + image->depth = depth;
> > +
> > + glGenTextures(1, &image->texture);
> > + glBindTexture(image->target, image->texture);
> > + glTexParameteri(image->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
> > + glTexParameteri(image->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
> > +}
> > +
> > +void
> > +image_destroy(struct image *image)
> > +{
> > + glDeleteTextures(1, &image->texture);
> > +}
> > +
> > +void
> > +image_fill(struct image *img, const float *bg_color, const float
> *fg_color,
> > + const struct volume *vol)
> > +{
> > + float *img_data;
> > + int i, j, k;
> > + const float *color;
> > +
> > + assert(vol->x >= 0);
> > + assert(vol->y >= 0);
> > + assert(vol->z >= 0);
> > + assert(vol->w >= 0);
> > + assert(vol->h >= 0);
> > + assert(vol->d >= 0);
> > + assert(vol->x + vol->w <= img->width);
> > + assert(vol->y + vol->h <= img->height);
> > + assert(vol->z + vol->d <= img->depth);
> > +
> > + img_data = malloc(img->width * img->height * img->depth *
> > + 3 * sizeof(float));
> > +
> > + /* Construct the image */
> > + for (k = 0; k < img->depth; ++k) {
> > + for (j = 0; j < img->height; ++j) {
> > + for (i = 0; i < img->width; ++i) {
> > + if (i >= vol->x && i < vol->x + vol->w &&
> > + j >= vol->y && j < vol->y + vol->h &&
> > + k >= vol->z && k < vol->z + vol->d) {
> > + color = fg_color;
> > + } else {
> > + color = bg_color;
> > + }
> > +
> > + memcpy(img_data + ((k * img->height + j) *
> img->width + i) *
> 3,
> > + color, 3 * sizeof(float));
> > + }
> > + }
> > + }
> > +
> > + glBindTexture(img->target, img->texture);
> > +
> > + switch (img->target) {
> > + case GL_TEXTURE_1D:
> > + glTexImage1D(img->target, 0,
> > + GL_RGB, img->width, 0,
> > + GL_RGB, GL_FLOAT, img_data);
> > + break;
> > +
> > + case GL_TEXTURE_CUBE_MAP:
> > + for (k = 0; k < 6; ++k) {
> > + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + k, 0,
> > + GL_RGB, img->width, img->height, 0,
> > + GL_RGB, GL_FLOAT,
> > + img_data + k * img->height *
> img->width * 3);
> > + }
> > + break;
> > +
> > + case GL_TEXTURE_2D:
> > + case GL_TEXTURE_RECTANGLE:
> > + glTexImage2D(img->target, 0,
> > + GL_RGB, img->width, img->height, 0,
> > + GL_RGB, GL_FLOAT, img_data);
> > + break;
> > +
> > + case GL_TEXTURE_1D_ARRAY:
> > + glTexImage2D(img->target, 0,
> > + GL_RGB, img->width, img->depth, 0,
> > + GL_RGB, GL_FLOAT, img_data);
> > + break;
> > +
> > + case GL_TEXTURE_3D:
> > + case GL_TEXTURE_2D_ARRAY:
> > + case GL_TEXTURE_CUBE_MAP_ARRAY_ARB:
> > + glTexImage3D(img->target, 0,
> > + GL_RGB, img->width, img->height, img->depth,
> 0,
> > + GL_RGB, GL_FLOAT, img_data);
> > + break;
> > + default:
> > + assert(0);
> > + }
> > +}
> > +
> > +void
> > +image_bind_layer(struct image *img, GLenum target, int layer)
> > +{
> > + switch(img->target) {
> > + case GL_TEXTURE_1D:
> > + glFramebufferTexture1D(target,
> > + GL_COLOR_ATTACHMENT0_EXT,
> > + img->target, img->texture, 0);
> > + break;
> > + case GL_TEXTURE_2D:
> > + case GL_TEXTURE_RECTANGLE:
> > + glFramebufferTexture2D(target,
> > + GL_COLOR_ATTACHMENT0_EXT,
> > + img->target, img->texture, 0);
> > + break;
> > + case GL_TEXTURE_CUBE_MAP:
> > + glFramebufferTexture2D(target,
> > + GL_COLOR_ATTACHMENT0_EXT,
> > + GL_TEXTURE_CUBE_MAP_POSITIVE_X +
> layer,
> > + img->texture, 0);
> > + break;
> > + case GL_TEXTURE_3D:
> > + case GL_TEXTURE_1D_ARRAY:
> > + case GL_TEXTURE_2D_ARRAY:
> > + case GL_TEXTURE_CUBE_MAP_ARRAY_ARB:
> > + glFramebufferTextureLayer(target,
> > + GL_COLOR_ATTACHMENT0_EXT,
> > + img->texture, 0, layer);
> > + break;
> > + }
> > +}
> > +
> > +bool
> > +image_verify(struct image *img, const float *bg_color, const float
> > *fg_color, + const struct volume *vol)
> > +{
> > + GLuint fbo;
> > + int k;
> > + bool pass = true;
> > +
> > + glGenFramebuffersEXT(1, &fbo);
> > + glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fbo);
> > +
> > + for (k = 0; k < img->depth; ++k) {
> > + image_bind_layer(img, GL_READ_FRAMEBUFFER_EXT, k);
> > +
> > + if (k < vol->z || k >= vol->z + vol->d) {
> > + pass &= piglit_probe_rect_rgb(0, 0,
> > + img->width,
> img->height,
> > + bg_color);
> > + } else {
> > + pass &= piglit_probe_rect_rgb(vol->x,
> > + vol->y,
> > + vol->w,
> > + vol->h,
> > + fg_color);
> > + pass &= piglit_probe_rect_rgb(0, 0,
> > + img->width,
> > + vol->y,
> > + bg_color);
> > + pass &= piglit_probe_rect_rgb(0, vol->y + vol->h,
> > + img->width,
> > + img->height - vol->y
> - vol->h,
> > + bg_color);
> > + pass &= piglit_probe_rect_rgb(0, 0,
> > + vol->x,
> > + img->height,
> > + bg_color);
> > + pass &= piglit_probe_rect_rgb(vol->x + vol->w, 0,
> > + img->width - vol->x
> - vol->w,
> > + img->height,
> > + bg_color);
> > + }
> > + }
> > +
> > + return pass;
> > +}
> > +
> > +void
> > +image_display(struct image *img, int parent_x, int parent_y)
> > +{
> > + GLuint fbo;
> > + int k, off_x, off_y;
> > +
> > + glGenFramebuffersEXT(1, &fbo);
> > + glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fbo);
> > +
> > + for (k = 0; k < img->depth; ++k) {
> > + off_x = parent_x + (k % 8) * (img->width + 2) + 1;
> > + off_y = parent_y + (k / 8) * (img->height + 2) + 1;
> > +
> > + image_bind_layer(img, GL_READ_FRAMEBUFFER_EXT, k);
> > +
> > + glBlitFramebufferEXT(0, 0, img->width, img->height,
> > + off_x, off_y,
> > + off_x + img->width, off_y +
> img->height,
> > + GL_COLOR_BUFFER_BIT, GL_NEAREST);
> > + }
> > +
> > + glDeleteFramebuffersEXT(1, &fbo);
> > +}
> > +
> > +struct image src, dst;
> > +struct volume src_vol, dst_vol;
> > +int dst_x, dst_y, dst_z;
> > +
> > +void
> > +quit_with_usage()
> > +{
> > + printf("usage: arb_copy_image-targets srcTarget srcTexWidth
> srcTexHeight
> > srcTexDepth\n" + " dstTarget dstTexWidth
> dstTexHeight
> > dstTexDepth\n" + " srcVolX srcVolY srcVolZ
> dstVolX
> > dstVolY dstVolZ\n" + " volWidth volHeight
> volDepth\n");
> > + exit(1);
> > +}
> > +
> > +struct texture_target {
> > + GLenum val;
> > + const char *str;
> > +};
> > +
> > +#define TARGET(x) { x, #x }
> > +struct texture_target targets[] = {
> > + TARGET(GL_TEXTURE_1D),
> > + TARGET(GL_TEXTURE_1D_ARRAY),
> > + TARGET(GL_TEXTURE_2D),
> > +/* TARGET(GL_TEXTURE_2D_MULTISAMPLE), */
> > + TARGET(GL_TEXTURE_RECTANGLE),
> > + TARGET(GL_TEXTURE_2D_ARRAY),
> > +/* TARGET(GL_TEXTURE_2D_MULTISAMPLE_ARRAY), */
> > + TARGET(GL_TEXTURE_CUBE_MAP),
> > + TARGET(GL_TEXTURE_CUBE_MAP_ARRAY),
> > + TARGET(GL_TEXTURE_3D),
> > +};
> > +#undef TARGET
> > +
> > +GLenum
> > +parse_target(const char *target_str)
> > +{
> > + int i;
> > +
> > + for (i = 0; i < sizeof(targets) / sizeof(*targets); ++i) {
> > + if (strcmp(target_str, targets[i].str) == 0)
> > + return targets[i].val;
> > + }
> > +
> > + quit_with_usage();
> > + return 0;
> > +}
> > +
> > +void
> > +piglit_init(int argc, char **argv)
> > +{
> > + if (argc < 18)
> > + quit_with_usage();
> > +
> > + piglit_require_extension("GL_ARB_copy_image");
> > + piglit_require_extension("GL_EXT_framebuffer_object");
> > +
> > + image_init(&src, parse_target(argv[1]),
> > + atoi(argv[2]), atoi(argv[3]), atoi(argv[4]));
> > +
> > + image_init(&dst, parse_target(argv[5]),
> > + atoi(argv[6]), atoi(argv[7]), atoi(argv[8]));
> > +
> > + src_vol.x = atoi(argv[9]);
> > + src_vol.y = atoi(argv[10]);
> > + src_vol.z = atoi(argv[11]);
> > +
> > + dst_vol.x = atoi(argv[12]);
> > + dst_vol.y = atoi(argv[13]);
> > + dst_vol.z = atoi(argv[14]);
> > +
> > + dst_vol.w = src_vol.w = atoi(argv[15]);
> > + dst_vol.h = src_vol.h = atoi(argv[16]);
> > + dst_vol.d = src_vol.d = atoi(argv[17]);
> > +}
> > +
> > +enum piglit_result
> > +piglit_display(void)
> > +{
> > + bool pass = true;
> > +
> > + image_fill(&src, red, green, &src_vol);
> > + pass &= image_verify(&src, red, green, &src_vol);
> > +
> > + if (!pass) goto out;
> > +
> > + image_fill(&dst, blue, blue, &dst_vol);
> > + pass &= image_verify(&dst, blue, blue, &dst_vol);
> > +
> > + glCopyImageSubData(src.texture, src.target, 0,
> > + src_vol.x, src_vol.y, src_vol.z,
> > + dst.texture, dst.target, 0,
> > + dst_vol.x, dst_vol.y, dst_vol.z,
> > + src_vol.w, src_vol.h, src_vol.d);
> > + pass &= piglit_check_gl_error(GL_NO_ERROR);
> > +
> > + pass &= image_verify(&dst, blue, green, &dst_vol);
> > +
> > +out:
> > + if (!piglit_automatic) {
> > + glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT,
> > + piglit_winsys_fbo);
> > + glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
> > + glClear(GL_COLOR_BUFFER_BIT);
> > +
> > + image_display(&dst, 0, 0);
> > + image_display(&src, 0, 34 * 4);
> > +
> > + piglit_present_results();
> > + }
> > +
> > + return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> > +}
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140630/fa2f4834/attachment-0001.html>
More information about the Piglit
mailing list