[Piglit] [PATCH V2] Add test to verify GL errors in glGenerateMipmap

Brian Paul brianp at vmware.com
Tue Nov 13 14:50:23 PST 2012


On 11/13/2012 03:13 PM, Anuj Phogat wrote:
> It does error checking for glGenerateMipmap() with integer and
> packed depth-stencil texture internal formats.
>
> V2: Don't test formats which generate no error. They are covered
> in other piglit tests.
>
> Signed-off-by: Anuj Phogat<anuj.phogat at gmail.com>
> ---
>   tests/all.tests                    |   85 +++++++++++++++++++
>   tests/texturing/CMakeLists.gl.txt  |    1 +
>   tests/texturing/genmipmap-errors.c |  159 ++++++++++++++++++++++++++++++++++++
>   3 files changed, 245 insertions(+), 0 deletions(-)
>   create mode 100644 tests/texturing/genmipmap-errors.c
>
> diff --git a/tests/all.tests b/tests/all.tests
> index 9eae003..5b92f93 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -440,6 +440,91 @@ oml_sync_control['swapbuffersmsc-return swap_interval 0'] = concurrent_test('glx
>   oml_sync_control['swapbuffersmsc-return swap_interval 1'] = concurrent_test('glx-oml-sync-control-swapbuffersmsc-return 1')
>   oml_sync_control['waitformsc'] = concurrent_test('glx-oml-sync-control-waitformsc')
>
> +texturing = Group()
> +add_concurrent_test(texturing, '1-1-linear-texture')
> +add_plain_test(texturing, 'array-depth-roundtrip')
> +add_plain_test(texturing, 'array-texture')
> +add_plain_test(texturing, 'copytexsubimage')
> +add_plain_test(texturing, 'copyteximage-border')
> +add_plain_test(texturing, 'copyteximage-clipping')
> +add_plain_test(texturing, 'cubemap')
> +texturing['cubemap npot'] = PlainExecTest(['cubemap', '-auto', 'npot'])
> +add_plain_test(texturing, 'depth-level-clamp')
> +add_plain_test(texturing, 'depth-tex-modes')
> +add_plain_test(texturing, 'depth-tex-modes-glsl')
> +add_plain_test(texturing, 'depth-tex-modes-rg')
> +add_plain_test(texturing, 'depth-tex-compare')
> +add_plain_test(texturing, 'depth-cube-map')
> +add_plain_test(texturing, 'fragment-and-vertex-texturing')
> +add_plain_test(texturing, 'fxt1-teximage')
> +add_plain_test(texturing, 'gen-teximage')
> +add_plain_test(texturing, 'genmipmap-errors')
> +add_plain_test(texturing, 'gen-compressed-teximage')
> +add_plain_test(texturing, 'gen-nonzero-unit')
> +add_plain_test(texturing, 'gen-texsubimage')
> +add_plain_test(texturing, 'getteximage-formats')
> +add_plain_test(texturing, 'getteximage-simple')
> +add_plain_test(texturing, 'getteximage-luminance')
> +
> +texturing['incomplete-texture-fixed'] = concurrent_test('incomplete-texture -auto fixed')
> +texturing['incomplete-texture-arb_fp'] = concurrent_test('incomplete-texture -auto arb_fp')
> +texturing['incomplete-texture-glsl'] = concurrent_test('incomplete-texture -auto glsl')
> +
> +add_plain_test(texturing, 'levelclamp')
> +add_plain_test(texturing, 'lodbias')
> +add_plain_test(texturing, 'lodclamp')
> +add_plain_test(texturing, 'lodclamp-between')
> +add_plain_test(texturing, 'lodclamp-between-max')
> +add_plain_test(texturing, 'mipmap-setup')
> +add_plain_test(texturing, 'max-texture-size')
> +add_concurrent_test(texturing, 'max-texture-size-level')
> +add_concurrent_test(texturing, 'proxy-texture')
> +add_plain_test(texturing, 'rg-draw-pixels')
> +add_plain_test(texturing, 'rg-teximage-01')
> +add_plain_test(texturing, 'rg-teximage-02')
> +add_plain_test(texturing, 'rgtc-teximage-01')
> +add_plain_test(texturing, 'rgtc-teximage-02')
> +add_concurrent_test(texturing, 's3tc-errors')
> +add_plain_test(texturing, 's3tc-teximage')
> +add_plain_test(texturing, 's3tc-texsubimage')
> +add_plain_test(texturing, 'sampler-cube-shadow')
> +add_concurrent_test(texturing, 'sized-texture-format-channels')
> +add_plain_test(texturing, 'streaming-texture-leak')
> +add_plain_test(texturing, 'tex-border-1')
> +texturing['tex-miplevel-selection'] = PlainExecTest(['tex-miplevel-selection', '-auto', '-nobias', '-nolod'])
> +texturing['tex-miplevel-selection-lod'] = PlainExecTest(['tex-miplevel-selection', '-auto', '-nobias'])
> +texturing['tex-miplevel-selection-lod-bias'] = PlainExecTest(['tex-miplevel-selection', '-auto'])
> +add_plain_test(texturing, 'tex-skipped-unit')
> +add_plain_test(texturing, 'tex-swizzle')
> +add_plain_test(texturing, 'tex3d')
> +add_concurrent_test(texturing, 'tex3d-depth1')
> +add_plain_test(texturing, 'tex3d-maxsize')
> +add_plain_test(texturing, 'tex3d-npot')
> +add_plain_test(texturing, 'texdepth')
> +add_plain_test(texturing, 'teximage-errors')
> +add_plain_test(texturing, 'texrect-many')
> +add_plain_test(texturing, 'texredefine')
> +add_plain_test(texturing, 'texsubimage')
> +add_plain_test(texturing, 'texture-al')
> +add_plain_test(texturing, 'texture-packed-formats')
> +add_plain_test(texturing, 'texture-rg')
> +add_plain_test(texturing, 'tex-srgb')
> +
> +# Note: the buffer sizes of 146, 292, 585, and 1024 hav been chosen to
> +# exercise all possible combinations of buffer alignments on i965.
> +for texture_size in (146, 292, 585, 1024):
> +        for test_type in ('s=z24_s8', 'd=z24_s8', 'd=z24', 'd=z32f_s8',
> +                          'd=z32f', 'd=z16', 'd=z24_s8_s=z24_s8',
> +                          'd=z24_s=z24_s8', 's=z24_s8_d=z24_s8',
> +                          's=z24_s8_d=z24', 'd=s=z24_s8', 's=d=z24_s8',
> +                          'ds=z24_s8', 'd=z32f_s8_s=z24_s8', 'd=z32f_s=z24_s8',
> +                          's=z24_s8_d=z32f_s8', 's=z24_s8_d=z32f',
> +                          'd=s=z32f_s8', 's=d=z32f_s8', 'ds=z32f_s8'):
> +                test_name = 'depthstencil-render-miplevels {0} {1}'.format(
> +                        texture_size, test_type)
> +                texturing[test_name] = PlainExecTest(test_name + ' -auto')
> +>>>>>>>  Add test to verify GL errors in glGenerateMipmap
> +

What's going on there?  A bad merge?



>   def texwrap_test(args):
>   	test = PlainExecTest(['texwrap', '-fbo', '-auto'] + args)
>   	test.runConcurrent = True
> diff --git a/tests/texturing/CMakeLists.gl.txt b/tests/texturing/CMakeLists.gl.txt
> index 9a9ac62..030336c 100644
> --- a/tests/texturing/CMakeLists.gl.txt
> +++ b/tests/texturing/CMakeLists.gl.txt
> @@ -27,6 +27,7 @@ piglit_add_executable (gen-compressed-teximage gen-compressed-teximage.c)
>   piglit_add_executable (gen-nonzero-unit gen-nonzero-unit.c)
>   piglit_add_executable (gen-teximage gen-teximage.c)
>   piglit_add_executable (gen-texsubimage gen-texsubimage.c)
> +piglit_add_executable (genmipmap-errors genmipmap-errors.c)
>   piglit_add_executable (getteximage-formats getteximage-formats.c)
>   piglit_add_executable (getteximage-simple getteximage-simple.c)
>   piglit_add_executable (getteximage-luminance getteximage-luminance.c)
> diff --git a/tests/texturing/genmipmap-errors.c b/tests/texturing/genmipmap-errors.c
> new file mode 100644
> index 0000000..9f4e835
> --- /dev/null
> +++ b/tests/texturing/genmipmap-errors.c
> @@ -0,0 +1,159 @@
> +/* Copyright 2012 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.
> + */
> +
> +/**
> + * \file genmipmap-errors.c
> + * Do error checking for glGenerateMipmap() with various texture internal formats.
> + * GL_INVALID_OPERATION is expected in case of integer or depth-stencil textures.
> + */
> +
> +
> +#include "piglit-util-gl-common.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +	config.supports_gl_compat_version = 10;
> +
> +	config.window_width = 100;
> +	config.window_height = 100;

I think you can omit the window size.  As-is, this won't work on Windows.


> +	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_ALPHA | PIGLIT_GL_VISUAL_DOUBLE;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +/**
> + * Test textures having integer or depth-stencil internalFormat with
> + * glGenerateMipmap. GL_INVALID_OPERATION should be thrown by the
> + * implementation.
> + */
> +static bool
> +test_genmipmap_errors(void)
> +{
> +	GLuint tex;
> +	struct {

Count be static const.


> +		GLenum intFormat, srcFormat, srcType;
> +		const char *extension[2];
> +	} formats[] = {
> +		/* Integer internal formats */
> +		{ GL_RGBA8I_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_RGBA16I_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_RGBA32I_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_RGB8I_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_RGB16I_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL } },
> +		{ GL_RGB32I, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_RG32I, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", "GL_ARB_texture_rg"} },
> +		{ GL_R32I, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", "GL_ARB_texture_rg"} },
> +		{ GL_ALPHA8I_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_LUMINANCE8I_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_INTENSITY8I_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_LUMINANCE_ALPHA8I_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +
> +		{ GL_RGBA8UI_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_RGBA16UI_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_RGBA32UI_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_RGB8UI_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_RGB16UI_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer" } },
> +		{ GL_RGB32UI_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_RG32UI, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", "GL_ARB_texture_rg"} },
> +		{ GL_R32UI, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", "GL_ARB_texture_rg"} },
> +		{ GL_ALPHA8UI_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_LUMINANCE8UI_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_INTENSITY8UI_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +		{ GL_LUMINANCE_ALPHA8UI_EXT, GL_RGBA_INTEGER, GL_INT,
> +		  {"GL_EXT_texture_integer", NULL} },
> +
> +		/* Packed depth / stencil formats */
> +		{ GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8,
> +		  {NULL, NULL} },
> +		{ GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL,
> +		  GL_FLOAT_32_UNSIGNED_INT_24_8_REV,
> +		  {"GL_ARB_texture_float", NULL} }

Indentation?


> +	};
> +	int i, j;
> +	bool pass = GL_TRUE;

bool pass = true;


> +
> +	glGenTextures(1,&tex);
> +	glBindTexture(GL_TEXTURE_2D, tex);
> +
> +	for (i = 0; i<  ARRAY_SIZE(formats); i++) {
> +
> +		bool is_ext_supported = true;
> +		for(j = 0; j<  ARRAY_SIZE(formats[i].extension); j++) {
> +			if((formats[i].extension[j] != NULL)&&

Space after for and if.


> +			   !piglit_is_extension_supported(formats[i].extension[j]))
> +			{
> +				printf("Skipping %s\n",
> +				piglit_get_gl_enum_name(formats[i].intFormat));
> +				is_ext_supported = false;
> +			}
> +		}
> +		if (!is_ext_supported)
> +			continue;
> +
> +		glTexImage2D(GL_TEXTURE_2D, 0, formats[i].intFormat,
> +			     16, 16, 0,
> +			     formats[i].srcFormat, formats[i].srcType, NULL);
> +
> +		pass = piglit_check_gl_error(GL_NO_ERROR)&&  pass;
> +		glGenerateMipmap(GL_TEXTURE_2D);
> +		pass = piglit_check_gl_error(GL_INVALID_OPERATION)&&  pass;
> +	}
> +
> +	return pass;
> +}
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +	return PIGLIT_PASS;
> +}
> +
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +	bool pass = true;
> +	pass = test_genmipmap_errors()&&  pass;

bool pass = test_genmipmap_errors();


> +	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}



More information about the Piglit mailing list