[Piglit] [PATCH 3/3] ARB_texture_view:Test valid and invalid targets for TextureView

Ian Romanick idr at freedesktop.org
Fri Oct 18 20:43:10 CEST 2013


On 10/16/2013 04:37 PM, Jon Ashburn wrote:
> The new target supplied with textureView must be compatible with the
> original textures target. This tests  valid and invalid combinations.
> 
> Tested on Nvidia Quadro 600, all tests pass.
> ---
>  tests/all.tests                               |   1 +
>  tests/spec/arb_texture_view/CMakeLists.gl.txt |   1 +
>  tests/spec/arb_texture_view/targets.c         | 234 ++++++++++++++++++++++++++
>  3 files changed, 236 insertions(+)
>  create mode 100644 tests/spec/arb_texture_view/targets.c
> 
> diff --git a/tests/all.tests b/tests/all.tests
> index 4d089b4..83d53c6 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -1474,6 +1474,7 @@ spec['ARB_texture_view'] = arb_texture_view
>  arb_texture_view['immutable_levels'] = concurrent_test('arb_texture_view-texture-immutable-levels')
>  arb_texture_view['params'] = concurrent_test('arb_texture_view-params')
>  arb_texture_view['formats'] = concurrent_test('arb_texture_view-formats')
> +arb_texture_view['targets'] = concurrent_test('arb_texture_view-targets')
>  
>  tdfx_texture_compression_fxt1 = Group()
>  spec['3DFX_texture_compression_FXT1'] = tdfx_texture_compression_fxt1
> diff --git a/tests/spec/arb_texture_view/CMakeLists.gl.txt b/tests/spec/arb_texture_view/CMakeLists.gl.txt
> index 44b6a64..193aff9 100644
> --- a/tests/spec/arb_texture_view/CMakeLists.gl.txt
> +++ b/tests/spec/arb_texture_view/CMakeLists.gl.txt
> @@ -12,5 +12,6 @@ link_libraries(
>  piglit_add_executable(arb_texture_view-texture-immutable-levels texture-immutable-levels.c)
>  piglit_add_executable(arb_texture_view-params params.c)
>  piglit_add_executable(arb_texture_view-formats formats.c common.c)
> +piglit_add_executable(arb_texture_view-targets targets.c common.c)
>  
>  # vim: ft=cmake:
> diff --git a/tests/spec/arb_texture_view/targets.c b/tests/spec/arb_texture_view/targets.c
> new file mode 100644
> index 0000000..d2c0c19
> --- /dev/null
> +++ b/tests/spec/arb_texture_view/targets.c
> @@ -0,0 +1,234 @@
> +/*
> + * Copyright © 2013 LunarG, 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.
> + *
> + * Author: Jon Ashburn <jon at lunarg.com>
> + */
> +
> +/**
> + * \file
> + * This (arb_texture_view-targets) tests valid and invalid new TextureView
> + * targets based on the original textures target.
> + *
> + * Section 8.18 (Texture Views) of OpenGL 4.3 Core says:
> + *    "The new texture’s target must be compatible with the target of
> + *     origtexture, as defined by table 8.20."
> + *
> + */
> +
> +#include "piglit-util-gl-common.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +	config.supports_gl_compat_version = 12;
> +	config.supports_gl_core_version = 31;
> +
> +	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +static const char *TestName = "arb_texture_view-targets";
> +
> +
> +/**
> + * Do error-check tests for texture targets
> + */
> +static bool
> +test_target_errors(GLenum target)
> +{
> +	GLint width = 64, height = 14, depth = 8;
> +	const GLsizei levels = 1;
> +	GLuint tex;
> +	enum piglit_result pass = true;
> +	GLenum legalTargets[4];
> +	unsigned int numTargets, i;
> +	GLenum illegalTargets[] = {
> +		/* skip multisample */
> +		GL_TEXTURE_1D,
> +		GL_TEXTURE_2D,
> +		GL_TEXTURE_3D,
> +		GL_TEXTURE_CUBE_MAP,
> +		GL_TEXTURE_RECTANGLE,
> +		GL_TEXTURE_1D_ARRAY,
> +		GL_TEXTURE_2D_ARRAY,
> +		GL_TEXTURE_CUBE_MAP_ARRAY,
> +	};
> +
> +	/* skip 2d_multisample  targets for now */
> +	assert(target == GL_TEXTURE_1D ||
> +		   target == GL_TEXTURE_2D ||
> +		   target == GL_TEXTURE_3D ||
> +		   target == GL_TEXTURE_CUBE_MAP ||
> +		   target == GL_TEXTURE_RECTANGLE ||
> +		   target == GL_TEXTURE_1D_ARRAY ||
> +		   target == GL_TEXTURE_2D_ARRAY ||
> +		   target == GL_TEXTURE_CUBE_MAP_ARRAY);
> +
> +	glGenTextures(1, &tex);   /* orig tex */
> +	glBindTexture(target, tex);
> +
> +	switch (target) {
> +	case GL_TEXTURE_1D:
> +		glTexStorage1D(target, levels, GL_RGBA8, width);
> +		numTargets = 2;
> +		update_valid_arrays(legalTargets, illegalTargets,
> +					ARRAY_SIZE(illegalTargets), numTargets,
> +							GL_TEXTURE_1D, GL_TEXTURE_1D_ARRAY);
> +		break;
> +	case GL_TEXTURE_1D_ARRAY:
> +		glTexStorage2D(target, levels*2, GL_RGBA8, width, height);

Another comment missed from the unsent mail:

Why is this one levels*2?

> +		numTargets = 2;
> +		update_valid_arrays(legalTargets, illegalTargets,
> +					ARRAY_SIZE(illegalTargets), numTargets,
> +							GL_TEXTURE_1D, GL_TEXTURE_1D_ARRAY);
> +		break;
> +	case GL_TEXTURE_2D:
> +		glTexStorage2D(target, levels, GL_RGBA8, width, height);
> +		numTargets = 2;
> +		update_valid_arrays(legalTargets, illegalTargets,
> +					ARRAY_SIZE(illegalTargets), numTargets,
> +							GL_TEXTURE_2D, GL_TEXTURE_2D_ARRAY);
> +		break;
> +	case  GL_TEXTURE_RECTANGLE:
> +		glTexStorage2D(target, levels, GL_RGBA8, width, height);
> +		numTargets = 1;
> +		update_valid_arrays(legalTargets, illegalTargets,
> +					ARRAY_SIZE(illegalTargets), numTargets,
> +							GL_TEXTURE_RECTANGLE);
> +		break;
> +	case GL_TEXTURE_CUBE_MAP:
> +		width = height;
> +		glTexStorage2D(target, levels, GL_RGBA8, width, height);
> +		numTargets = 4;
> +		update_valid_arrays(legalTargets, illegalTargets,
> +					ARRAY_SIZE(illegalTargets), numTargets,
> +							GL_TEXTURE_CUBE_MAP, GL_TEXTURE_2D,
> +							GL_TEXTURE_2D_ARRAY, GL_TEXTURE_CUBE_MAP_ARRAY);
> +		break;
> +	case GL_TEXTURE_3D:
> +		glTexStorage3D(target, levels, GL_RGBA8, width, height, depth);
> +		numTargets = 1;
> +		update_valid_arrays(legalTargets, illegalTargets,
> +					ARRAY_SIZE(illegalTargets), numTargets, GL_TEXTURE_3D);
> +		break;
> +	case GL_TEXTURE_CUBE_MAP_ARRAY:
> +	case GL_TEXTURE_2D_ARRAY:
> +		height = width;
> +		glTexStorage3D(target, levels, GL_RGBA8, width, height, depth*6);
> +		numTargets = 4;
> +		update_valid_arrays(legalTargets, illegalTargets,
> +					ARRAY_SIZE(illegalTargets), numTargets,
> +							GL_TEXTURE_CUBE_MAP, GL_TEXTURE_2D,
> +							GL_TEXTURE_2D_ARRAY, GL_TEXTURE_CUBE_MAP_ARRAY);
> +		break;
> +	}
> +
> +
> +	if (!piglit_check_gl_error(GL_NO_ERROR)) {
> +		printf("%s:%s Found gl errors prior to testing glTextureView\n",
> +				   TestName, __func__);
> +		pass = false;
> +		goto err_out;
> +	}
> +
> +	/* ensure TextureView of legal targets  works withour gl errors */
> +	for (i = 0; i < numTargets; i++) {
> +		GLenum tar = legalTargets[i];
> +		GLuint new_tex, layers=1;
> +		glGenTextures(1, &new_tex);
> +		if (tar == GL_TEXTURE_CUBE_MAP)
> +			layers = 6;
> +		else if (tar == GL_TEXTURE_CUBE_MAP_ARRAY)
> +			layers = 12;
> +		glTextureView(new_tex, tar, tex,  GL_RG16, 0, levels, 0, layers);
> +		glDeleteTextures(1, &new_tex);
> +		if (!piglit_check_gl_error(GL_NO_ERROR)) {
> +			pass = false;
> +			goto err_out;
> +		}
> +	}
> +
> +	/* ensure TextureView  of illegal targets returns an error */
> +	for (i = 0; i < ARRAY_SIZE(illegalTargets); i++) {
> +		GLenum tar = illegalTargets[i];
> +		GLuint newTex, layers=1;
> +		if (illegalTargets[i] == 0)
> +				continue;
> +		glGenTextures(1, &newTex);
> +		if (tar == GL_TEXTURE_CUBE_MAP)
> +			layers = 6;
> +		else if (tar == GL_TEXTURE_CUBE_MAP_ARRAY)
> +			layers = 12;
> +		glTextureView(newTex, tar, tex,  GL_RG16, 0, levels, 0, layers);
> +		if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {
> +			glDeleteTextures(1, &newTex);
> +			pass = false;
> +			goto err_out;
> +		}
> +		glDeleteTextures(1, &newTex);
> +	}
> +
> +err_out:
> +	glDeleteTextures(1, &tex);
> +
> +	return pass;
> +}
> +
> +#define X(f, n)										\
> +	do {											\
> +		const bool subtest_pass = (f);				\
> +		piglit_report_subtest_result(subtest_pass	\
> +					     ? PIGLIT_PASS : PIGLIT_FAIL, \
> +					     (n));						\
> +		pass = pass && subtest_pass;				\
> +	} while (0)
> +
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +	bool pass = true;
> +
> +	X(test_target_errors(GL_TEXTURE_1D), "1D tex target validity");
> +	X(test_target_errors(GL_TEXTURE_2D), "2D tex target validity");
> +	X(test_target_errors(GL_TEXTURE_3D), "3D tex target validity");
> +	X(test_target_errors(GL_TEXTURE_CUBE_MAP), "Cubemap tex target validity");
> +	X(test_target_errors(GL_TEXTURE_RECTANGLE), "Rectangle tex target validity");
> +	X(test_target_errors(GL_TEXTURE_1D_ARRAY), "1D Array tex target validity");
> +	X(test_target_errors(GL_TEXTURE_2D_ARRAY), "2D Array tex target validity");
> +	X(test_target_errors(GL_TEXTURE_CUBE_MAP_ARRAY),
> +		"Cubemap Array tex target validity");
> +#undef X
> +    pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +    return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> +
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +	piglit_require_extension("GL_ARB_texture_storage");
> +	piglit_require_extension("GL_ARB_texture_view");
> +	piglit_require_extension("GL_ARB_texture_cube_map_array");
> +	piglit_require_extension("GL_EXT_texture_array");
> +	piglit_require_extension("GL_ARB_texture_rectangle");
> +	piglit_require_extension("GL_ARB_texture_cube_map");
> +}
> 



More information about the Piglit mailing list