[Piglit] [PATCH] arb_texture_storage: add some cube map error tests

Ian Romanick idr at freedesktop.org
Wed Oct 16 23:25:01 CEST 2013


On 10/14/2013 09:45 AM, Brian Paul wrote:
> Test error checking for width != height and depth % 6 != 0 for cube arrays.
> ---
>  tests/spec/arb_texture_storage/texture-storage.c |   66 ++++++++++++++++++++++
>  1 file changed, 66 insertions(+)
> 
> diff --git a/tests/spec/arb_texture_storage/texture-storage.c b/tests/spec/arb_texture_storage/texture-storage.c
> index 201929d..a9db70e 100644
> --- a/tests/spec/arb_texture_storage/texture-storage.c
> +++ b/tests/spec/arb_texture_storage/texture-storage.c
> @@ -221,6 +221,68 @@ test_mipmap_errors(GLenum target)
>  }
>  
>  
> +static enum piglit_result
> +test_cube_texture(void)
> +{
> +	const GLint width = 16, height = 16;
> +	const GLenum target = GL_TEXTURE_CUBE_MAP;
> +	GLuint tex;
> +
> +	/* Test valid cube dimensions */
> +	glGenTextures(1, &tex);
> +	glBindTexture(target, tex);
> +	glTexStorage2D(target, 1, GL_RGBA8, width, height);
> +	if (!piglit_check_gl_error(GL_NO_ERROR))
> +		return PIGLIT_FAIL;
> +	glDeleteTextures(1, &tex);
> +
> +	/* Test invalid cube dimensions */
> +	glGenTextures(1, &tex);
> +	glBindTexture(target, tex);
> +	glTexStorage2D(target, 1, GL_RGBA8, width, height+2);
> +	if (!piglit_check_gl_error(GL_INVALID_VALUE))
> +		return PIGLIT_FAIL;
> +	glDeleteTextures(1, &tex);
> +
> +	return PIGLIT_PASS;
> +}
> +
> +
> +static enum piglit_result
> +test_cube_array_texture(void)
> +{
> +	const GLint width = 16, height = 16;
> +	const GLenum target = GL_TEXTURE_CUBE_MAP_ARRAY;
> +	GLuint tex;
> +
> +	/* Test valid cube array dimensions */
> +	glGenTextures(1, &tex);
> +	glBindTexture(target, tex);
> +	glTexStorage3D(target, 1, GL_RGBA8, width, height, 12);
> +	if (!piglit_check_gl_error(GL_NO_ERROR))
> +		return PIGLIT_FAIL;

Other piglit tests do not work like this.  If part of a test fails in a
way that won't affect later tests, the later tests are still run.  This
has advantages when you're trying to fix a failure:  you see all the
things that are broken up front.

This is also why almost all piglit tests use bool to hold the partial
test result.  Then you can easily do things like:

	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

Finally, if one of these partial tests fails, it will leak a texture
object.  Since this gets called from piglit_display, you'll leak a
texture object every re-draw.

> +	glDeleteTextures(1, &tex);
> +
> +	/* Test invalid cube array width, height dimensions */
> +	glGenTextures(1, &tex);
> +	glBindTexture(target, tex);
> +	glTexStorage3D(target, 1, GL_RGBA8, width, height+3, 12);
> +	if (!piglit_check_gl_error(GL_INVALID_VALUE))
> +		return PIGLIT_FAIL;
> +	glDeleteTextures(1, &tex);
> +
> +	/* Test invalid cube array depth */
> +	glGenTextures(1, &tex);
> +	glBindTexture(target, tex);
> +	glTexStorage3D(target, 1, GL_RGBA8, width, height, 12+2);
> +	if (!piglit_check_gl_error(GL_INVALID_VALUE))
> +		return PIGLIT_FAIL;
> +	glDeleteTextures(1, &tex);
> +
> +	return PIGLIT_PASS;
> +}
> +
> +
>  /**
>   * Create a single-color image.
>   */
> @@ -484,6 +546,10 @@ piglit_display(void)
>  	X(test_2d_mipmap_rendering(), "2D mipmap rendering");
>  	X(test_internal_formats(), "internal formats");
>  	X(test_immutablity(GL_TEXTURE_2D), "immutability");
> +	X(test_cube_texture(), "cube texture");

This should also test for GL_ARB_texture_cube_map.

I have a couple patches for this test coming out in a few minutes that
will conflict with this patch.  It will be easy to resolve once one set
(yours or mine) lands.

> +	if (piglit_is_extension_supported("GL_ARB_texture_cube_map_array")) {
> +		X(test_cube_array_texture(), "cube array texture");
> +	}
>  #undef X
>  	return pass;
>  }
> 



More information about the Piglit mailing list