[Piglit] [PATCH 2/4] add new texture swizzle API test

Ian Romanick idr at freedesktop.org
Sat Apr 26 15:30:36 PDT 2014


On 04/25/2014 06:33 PM, Eric Anholt wrote:
> Brian Paul <brianp at vmware.com> writes:
> 
>> Test for API errors and glGet for GL_EXT_texture_swizzle.
>> ---
>>  tests/all.py                                     |    1 +
>>  tests/spec/ext_texture_swizzle/CMakeLists.gl.txt |    1 +
>>  tests/spec/ext_texture_swizzle/api.c             |  122 ++++++++++++++++++++++
>>  3 files changed, 124 insertions(+)
>>  create mode 100644 tests/spec/ext_texture_swizzle/api.c
>>
>> diff --git a/tests/all.py b/tests/all.py
>> index 0665567..c613b00 100644
>> --- a/tests/all.py
>> +++ b/tests/all.py
>> @@ -2644,6 +2644,7 @@ for stage in ['vs', 'gs', 'fs']:
>>  ext_texture_swizzle = {}
>>  spec['EXT_texture_swizzle'] = ext_texture_swizzle
>>  add_plain_test(ext_texture_swizzle, 'tex-swizzle')
>> +add_concurrent_test(ext_texture_swizzle, 'ext_texture_swizzle-api')
>>  add_concurrent_test(ext_texture_swizzle, 'ext_texture_swizzle-swizzle')
>>  ext_texture_swizzle['depth_texture_mode_and_swizzle'] = concurrent_test('depth_texture_mode_and_swizzle')
>>  
>> diff --git a/tests/spec/ext_texture_swizzle/CMakeLists.gl.txt b/tests/spec/ext_texture_swizzle/CMakeLists.gl.txt
>> index 70ecb1c..98533b2 100644
>> --- a/tests/spec/ext_texture_swizzle/CMakeLists.gl.txt
>> +++ b/tests/spec/ext_texture_swizzle/CMakeLists.gl.txt
>> @@ -10,6 +10,7 @@ link_libraries (
>>  )
>>  
>>  piglit_add_executable (depth_texture_mode_and_swizzle depth_texture_mode_and_swizzle.c)
>> +piglit_add_executable (ext_texture_swizzle-api api.c)
>>  piglit_add_executable (ext_texture_swizzle-swizzle swizzle.c)
>>  
>>  # vim: ft=cmake:
>> diff --git a/tests/spec/ext_texture_swizzle/api.c b/tests/spec/ext_texture_swizzle/api.c
>> new file mode 100644
>> index 0000000..212ef08
>> --- /dev/null
>> +++ b/tests/spec/ext_texture_swizzle/api.c
>> @@ -0,0 +1,122 @@
>> +/*
>> + * Copyright © 2014 VMware, 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.
>> + */
>> +
>> +/*
>> + * Test GL_EXT_texture_swizzle API functions.
>> + * Brian Paul
>> + * 24 April 2014
>> + */
>> +
>> +
>> +#include "piglit-util-gl-common.h"
>> +
>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>> +	config.supports_gl_compat_version = 12;
>> +	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
>> +PIGLIT_GL_TEST_CONFIG_END
>> +
>> +
>> +static bool
>> +test_get(GLenum pname, GLint expected)
>> +{
>> +	GLint val;
>> +
>> +	glGetTexParameteriv(GL_TEXTURE_2D, pname, &val);
>> +
>> +	if (val != expected) {
>> +		printf("glGetTexParameteriv(%s) returned %s instead of %s\n",
>> +		       piglit_get_gl_enum_name(pname),
>> +		       piglit_get_gl_enum_name(val),
>> +		       piglit_get_gl_enum_name(expected));
>> +		return false;
>> +	}
>> +
>> +	return true;
>> +}
>> +
>> +
>> +static bool
>> +test_api(void)
>> +{
>> +	static const GLint swz[4] = { GL_BLUE, GL_GREEN, GL_ALPHA, GL_ZERO };
>> +	GLint swzOut[4];
>> +
>> +	/* test bad param value */
>> +	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R_EXT, GL_RGBA);
>> +
>> +	if (!piglit_check_gl_error(GL_INVALID_ENUM))
>> +		return false;
>> +
>> +	/* test good param values */
>> +	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R_EXT, GL_ONE);
>> +	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G_EXT, GL_ZERO);
>> +	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B_EXT, GL_RED);
>> +	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A_EXT, GL_BLUE);
>> +
>> +	if (!piglit_check_gl_error(GL_NO_ERROR))
>> +		return false;
>> +
>> +	if (!test_get(GL_TEXTURE_SWIZZLE_R_EXT, GL_ONE))
>> +		return false;
>> +
>> +	if (!test_get(GL_TEXTURE_SWIZZLE_G_EXT, GL_ZERO))
>> +		return false;
>> +
>> +	if (!test_get(GL_TEXTURE_SWIZZLE_B_EXT, GL_RED))
>> +		return false;
>> +
>> +	if (!test_get(GL_TEXTURE_SWIZZLE_A_EXT, GL_BLUE))
>> +		return false;
>> +
>> +	/* set all at once */
>> +	glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA_EXT, swz);
>> +
>> +	if (!piglit_check_gl_error(GL_NO_ERROR))
>> +		return false;
>> +
>> +	glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA_EXT, swzOut);
>> +	if (swzOut[0] != swz[0] ||
>> +		swzOut[1] != swz[1] ||
>> +		swzOut[2] != swz[2] ||
>> +		swzOut[3] != swz[3]) {
> 
> usually these would align with the inside of '('
> 
>> +		printf("glGetTexParameteriv(GL_TEXTURE_SWIZZLE_RGBA_EXT) failed\n");
>> +		return false;
>> +	}
>> +
>> +	return true;
>> +}
>> +
>> +
>> +enum piglit_result
>> +piglit_display(void)
>> +{
>> +	bool p = test_api();
>> +	return p ? PIGLIT_PASS : PIGLIT_FAIL;
>> +}
>> +
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> +	piglit_require_extension("GL_EXT_texture_swizzle");
>> +}
> 
> Given that there's nothing being rendered to the screen, I'd just move
> test_api into piglit_init with piglit_report_result(p ? PIGLIT_PASS :
> PIGLIT_FAIL), and have piglit_display be:
> 
> /* UNREACHED */
> return PIGLIT_FAIL;
> 
> Other than that and the minor comment to patch 1, this series is:
> 
> Reviewed-by: Eric Anholt <eric at anholt.net>

I was just about to say the same thing.  With Eric's suggested fix, this
patch is

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> I'm so glad to see tex-swizzle.c die.
> 
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140426/25648a7d/attachment.sig>


More information about the Piglit mailing list