[Piglit] [PATCH 06/10] fbo-generatemipmap-cubemap: new test for cubemaps and cube arrays

Brian Paul brianp at vmware.com
Mon Mar 17 08:08:02 PDT 2014


On 03/15/2014 10:53 AM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
>   tests/all.py                           |   6 +
>   tests/fbo/CMakeLists.gl.txt            |   1 +
>   tests/fbo/fbo-generatemipmap-cubemap.c | 499 +++++++++++++++++++++++++++++++++
>   3 files changed, 506 insertions(+)
>   create mode 100644 tests/fbo/fbo-generatemipmap-cubemap.c
>
> diff --git a/tests/all.py b/tests/all.py
> index bdc4077..65963cc 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -1682,6 +1682,9 @@ add_concurrent_test(arb_framebuffer_object, 'fbo-drawbuffers-none glColorMaskInd
>   add_concurrent_test(arb_framebuffer_object, 'fbo-drawbuffers-none glBlendFunci')
>   add_concurrent_test(arb_framebuffer_object, 'fbo-drawbuffers-none glDrawPixels')
>   add_concurrent_test(arb_framebuffer_object, 'fbo-drawbuffers-none glBlitFramebuffer')
> +add_concurrent_test(arb_framebuffer_object, 'fbo-generatemipmap-cubemap')
> +add_concurrent_test(arb_framebuffer_object, 'fbo-generatemipmap-cubemap RGB9_E5')
> +add_concurrent_test(arb_framebuffer_object, 'fbo-generatemipmap-cubemap S3TC_DXT1')
>
>   # Group ARB_framebuffer_sRGB
>   arb_framebuffer_srgb = Group()
> @@ -2586,6 +2589,9 @@ add_plain_test(arb_texture_cube_map_array, 'arb_texture_cube_map_array-sampler-c
>   add_concurrent_test(arb_texture_cube_map_array, 'getteximage-targets CUBE_ARRAY')
>   add_concurrent_test(arb_texture_cube_map_array, 'glsl-resource-not-bound CubeArray')
>   textureSize_samplers_atcma = ['samplerCubeArray', 'isamplerCubeArray', 'usamplerCubeArray', 'samplerCubeArrayShadow' ];
> +add_concurrent_test(arb_texture_cube_map_array, 'fbo-generatemipmap-cubemap array')
> +add_concurrent_test(arb_texture_cube_map_array, 'fbo-generatemipmap-cubemap array RGB9_E5')
> +add_concurrent_test(arb_texture_cube_map_array, 'fbo-generatemipmap-cubemap array S3TC_DXT1')
>
>   import_glsl_parser_tests(arb_texture_cube_map_array,
>   			 os.path.join(testsDir, 'spec', 'arb_texture_cube_map_array'),
> diff --git a/tests/fbo/CMakeLists.gl.txt b/tests/fbo/CMakeLists.gl.txt
> index 588fe26..a2b9bd0 100644
> --- a/tests/fbo/CMakeLists.gl.txt
> +++ b/tests/fbo/CMakeLists.gl.txt
> @@ -55,6 +55,7 @@ piglit_add_executable (fbo-fragcoord fbo-fragcoord.c)
>   piglit_add_executable (fbo-fragcoord2 fbo-fragcoord2.c)
>   piglit_add_executable (fbo-generatemipmap fbo-generatemipmap.c)
>   piglit_add_executable (fbo-generatemipmap-array fbo-generatemipmap-array.c)
> +piglit_add_executable (fbo-generatemipmap-cubemap fbo-generatemipmap-cubemap.c)
>   piglit_add_executable (fbo-generatemipmap-filtering fbo-generatemipmap-filtering.c)
>   piglit_add_executable (fbo-generatemipmap-formats fbo-generatemipmap-formats.c)
>   piglit_add_executable (fbo-generatemipmap-scissor fbo-generatemipmap-scissor.c)
> diff --git a/tests/fbo/fbo-generatemipmap-cubemap.c b/tests/fbo/fbo-generatemipmap-cubemap.c
> new file mode 100644
> index 0000000..bcbfc37
> --- /dev/null
> +++ b/tests/fbo/fbo-generatemipmap-cubemap.c
> @@ -0,0 +1,499 @@
> +/*
> + * Copyright © 2014 Advanced Micro Devices, Inc.
> + *
> + * 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.
> + *
> + * Authors:
> + *     Marek Olšák <maraeo at gmail.com>
> + */
> +
> +#include "piglit-util-gl-common.h"
> +
> +#define TEX_SIZE 32
> +#define TEX_HALF (TEX_SIZE / 2)
> +#define TEX_LEVELS 6
> +
> +#define DRAW_SIZE 32
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +	config.supports_gl_compat_version = 10;
> +
> +	config.window_width = 680;
> +	config.window_height = 620;
> +	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +static const char *fs_cube =
> +   "uniform samplerCube tex; \n"
> +   "void main() \n"
> +   "{ \n"
> +   "   gl_FragColor = textureCube(tex, gl_TexCoord[0].xyz); \n"
> +   "} \n";
> +
> +static const char *fs_cube_array =
> +   "#version 130\n"
> +   "#extension GL_ARB_texture_cube_map_array : enable\n"
> +   "uniform samplerCubeArray tex; \n"
> +   "void main() \n"
> +   "{ \n"
> +   "   gl_FragColor = texture(tex, gl_TexCoord[0]); \n"
> +   "} \n";
> +
> +static GLboolean test_array;
> +static GLenum target;
> +static GLenum num_layers;
> +static GLuint prog;
> +static GLenum format;
> +
> +static float colors[][4] = {
> +	{0.0, 0.0, 0.0, 1.0},
> +	{1.0, 0.0, 0.0, 1.0},
> +	{0.0, 1.0, 0.0, 1.0},
> +	{1.0, 1.0, 0.0, 1.0},
> +	{0.0, 0.0, 1.0, 1.0},
> +	{1.0, 0.0, 1.0, 1.0},
> +	{0.0, 1.0, 1.0, 1.0},
> +};
> +#define NUM_COLORS ARRAY_SIZE(colors)
> +
> +static void
> +load_texcube(void)
> +{
> +	float *p = malloc(TEX_SIZE * TEX_SIZE * num_layers * 4 * sizeof(float));
> +	int x,y,z;
> +
> +	for (z = 0; z < num_layers; z++) {
> +		for (y = 0; y < TEX_SIZE; y++) {
> +			for (x = 0; x < TEX_SIZE; x++) {
> +				int quadrant = y < TEX_SIZE/2 ? (x < TEX_SIZE/2 ? 0 : 1) :
> +								(x < TEX_SIZE/2 ? 2 : 3);
> +				float *dest = &p[(z*TEX_SIZE*TEX_SIZE + y*TEX_SIZE + x)*4];
> +
> +				memcpy(dest, colors[(z + quadrant*2) % NUM_COLORS],
> +				       4 * sizeof(float));
> +			}
> +		}
> +	}
> +
> +	if (test_array) {
> +		glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, 0,
> +				TEX_SIZE, TEX_SIZE, num_layers, GL_RGBA, GL_FLOAT, p);
> +	}
> +	else {

The following code could be expressed as a loop.


> +		glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0,
> +				TEX_SIZE, TEX_SIZE, GL_RGBA, GL_FLOAT, p);
> +		glTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0,
> +				TEX_SIZE, TEX_SIZE, GL_RGBA, GL_FLOAT,
> +				p + TEX_SIZE*TEX_SIZE*4);
> +		glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0,
> +				TEX_SIZE, TEX_SIZE, GL_RGBA, GL_FLOAT,
> +				p + 2*TEX_SIZE*TEX_SIZE*4);
> +		glTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0,
> +				TEX_SIZE, TEX_SIZE, GL_RGBA, GL_FLOAT,
> +				p + 3*TEX_SIZE*TEX_SIZE*4);
> +		glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0,
> +				TEX_SIZE, TEX_SIZE, GL_RGBA, GL_FLOAT,
> +				p + 4*TEX_SIZE*TEX_SIZE*4);
> +		glTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0,
> +				TEX_SIZE, TEX_SIZE, GL_RGBA, GL_FLOAT,
> +				p + 5*TEX_SIZE*TEX_SIZE*4);
> +	}
> +	free(p);
> +}
> +





More information about the Piglit mailing list