[Piglit] [PATCH 1/4] ARB_texture_view: Test for API coverage of subset of input params
Brian Paul
brianp at vmware.com
Sat Oct 19 01:55:08 CEST 2013
On 10/18/2013 05:06 PM, Jon Ashburn wrote:
> Tests GL_ARB_texture_view and validity of input parameters.
> Use both valid and invalid parameters, although mostly invalid
> parameters are tested since other tests will use valid parameters.
> Only the parameters "texture", "origtexture", "minlevel", "numlevels",
> "minlayer", "numlayers" are tested for validity as per section 8.18 of
> OpenGL 4.3 Core spec.
>
> Tested on Nvidia Quadro 600 and it passes.
> ---
> tests/all.tests | 5 +
> tests/spec/arb_texture_view/CMakeLists.gl.txt | 1 +
> tests/spec/arb_texture_view/params.c | 341 ++++++++++++++++++++++++++
> 3 files changed, 347 insertions(+)
> create mode 100644 tests/spec/arb_texture_view/params.c
>
> diff --git a/tests/all.tests b/tests/all.tests
> index c919f19..2bb6aed 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -1469,6 +1469,11 @@ spec['ARB_texture_storage_multisample'] = arb_texture_storage_multisample
> arb_texture_storage_multisample['tex-storage'] = concurrent_test('arb_texture_storage_multisample-tex-storage')
> arb_texture_storage_multisample['tex-param'] = concurrent_test('arb_texture_storage_multisample-tex-param')
>
> +arb_texture_view = Group()
> +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')
> +
> tdfx_texture_compression_fxt1 = Group()
> spec['3DFX_texture_compression_FXT1'] = tdfx_texture_compression_fxt1
> add_concurrent_test(tdfx_texture_compression_fxt1, 'compressedteximage GL_COMPRESSED_RGB_FXT1_3DFX')
> diff --git a/tests/spec/arb_texture_view/CMakeLists.gl.txt b/tests/spec/arb_texture_view/CMakeLists.gl.txt
> index c400759..4f2b1ef 100644
> --- a/tests/spec/arb_texture_view/CMakeLists.gl.txt
> +++ b/tests/spec/arb_texture_view/CMakeLists.gl.txt
> @@ -10,5 +10,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)
>
> # vim: ft=cmake:
> diff --git a/tests/spec/arb_texture_view/params.c b/tests/spec/arb_texture_view/params.c
> new file mode 100644
> index 0000000..35de9b2
> --- /dev/null
> +++ b/tests/spec/arb_texture_view/params.c
> @@ -0,0 +1,341 @@
> +/*
> + * 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>
> + */
> +
> +/**
> + * Tests GL_ARB_texture_view and validity of input parameters.
> + * Use both valid and invalid parameters, although mostly invalid
> + * parameters are tested since other tests use valid parameters.
> + * Only the parameters "texture", "origtexture", "minlevel", "numlevels",
> + * "minlayer", "numlayers" are tested for validity as per section 8.18 of
> + * OpenGL 4.3 Core spec.
> + * Tests formats.c and targets.c test the valid and invalid "format" and
> + * "target" input parameters respectively.
> + *
> + */
> +
> +#include "piglit-util-gl-common.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> + config.supports_gl_compat_version = 10;
> + 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-params";
> +
> +/**
> + * Test TextureView with various invalid arguments for "texture"
> + * and "origtexture".
> + * Errors as per OpenGL core 4.3 spec section 8.18:
> + * "An INVALID_VALUE error is generated if origtexture is not the
> + * name of a texture."
> + * "An INVALID_OPERATION error is generated if the value of
> + * TEXTURE_IMMUTABLE_FORMAT for origtexture is not TRUE."
> + * "An INVALID_VALUE error is generated if texture is zero."
> + * "An INVALID_OPERATION error is generated if texture is not a valid name
> + * returned by GenTextures, or if texture has already been bound and
> + * given a target."
> + */
> +static bool
> +invalid_texture_param()
I think MSVC might complain about (). (void) would be better.
> +{
> + bool pass = true;
> + GLuint tex[2];
> +
> + /* invalid original texture param (origtexture) */
> + glGenTextures(2, tex);
> + glBindTexture(GL_TEXTURE_2D, tex[0]);
> + if (!piglit_check_gl_error(GL_NO_ERROR)) {
> + printf("%s:%s Found gl errors prior to testing glTextureView\n",
> + TestName, __func__);
I think you need to use __FUNCTION__ for MSVC. Though, I thought
piglit_check_gl_error() already prints the file/func/line info when it
fails. So maybe you don't need to print the function name. We usually
don't do that.
> + pass = false;
> + goto err_out;
> + }
> + /* origtexture IMMUTABLE_FORMAT == FALSE */
> + glTextureView(tex[1], GL_TEXTURE_2D, tex[0], GL_R8, 0, 1, 0, 1);
> + pass = pass && piglit_check_gl_error(GL_INVALID_OPERATION);
> + glDeleteTextures(1, &tex[1]);
> + glTexStorage2D(GL_TEXTURE_2D,2, GL_RGBA32F, 16, 16);
> + pass = pass && piglit_check_gl_error(GL_NO_ERROR);
> +
> + glGenTextures(1, &tex[1]);
> + /* origtexture is not the name of a texture */
> + glTextureView(tex[1], GL_TEXTURE_2D, 0, GL_RGBA32UI, 0, 1, 0, 1);
> + pass = pass && piglit_check_gl_error(GL_INVALID_VALUE);
> + glDeleteTextures(1, &tex[1]);
> +
> + /* invalid texture param (value is 0)*/
> + glTextureView(0, GL_TEXTURE_2D, tex[0], GL_RGBA32I, 0, 1, 0 ,1);
> + pass = pass && piglit_check_gl_error(GL_INVALID_VALUE);
> +
> + glGenTextures(1, &tex[1]);
> + glBindTexture(GL_TEXTURE_2D, tex[1]);
> + glTextureView(tex[1], GL_TEXTURE_2D, tex[0],GL_RGBA32F, 0, 1, 0, 1);
> + pass = pass && piglit_check_gl_error(GL_INVALID_OPERATION);
> + glDeleteTextures(2, tex);
> +
> + /* invalid texture param (value not a valid name from GenTextures)*/
> + glGenTextures(1, tex);
> + glBindTexture(GL_TEXTURE_2D, tex[0]);
> + glTexStorage2D(GL_TEXTURE_2D, 3, GL_RG16F, 16, 16);
> + glTextureView(~tex[0],GL_TEXTURE_2D, tex[0], GL_RGBA8, 0,1,0,1);
> + pass = pass && piglit_check_gl_error(GL_INVALID_OPERATION);
> + glDeleteTextures(1, tex);
> +
> + /* orig texture not immutable */
> + glGenTextures(2, tex);
> + glBindTexture(GL_TEXTURE_2D, tex[0]);
> + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16, 32, 32, 0, GL_RGB,
> + GL_SHORT, NULL);
> + glTexImage2D(GL_TEXTURE_2D, 1, GL_RGB16, 16, 16, 0, GL_RGB,
> + GL_SHORT, NULL);
> + glTextureView(tex[1], GL_TEXTURE_2D, tex[0], GL_RGBA32F, 0,1,0,1);
> + pass = pass && piglit_check_gl_error(GL_INVALID_OPERATION);
> +
> +err_out:
> + glDeleteTextures(2, tex);
> + return pass;
> +
You could remove that blank line.
> +}
> +
> +/**
> + * Test TextureView with invalid arguments for "minlayer"
> + * and "numlayers".
> + * Errors as per OpenGL core 4.3 spec section 8.18:
> + * "An INVALID_VALUE error is generated if minlevel or minlayer are larger
> + * than the greatest level or layer, respectively, of origtexture."
> + * "An INVALID_VALUE error is generated if target is TEXTURE_1D,
> + * TEXTURE_2D, TEXTURE_3D, TEXTURE_RECTANGLE, or TEXTURE_2D_-
> + * MULTISAMPLE and numlayers does not equal 1."
> +
> + */
> +static bool
> +invalid_layer_param(GLenum target)
> +{
> + bool pass = true;
> + GLenum tar;
> + GLuint tex[2];
> +
> +
Extra blank line
> + /* invalid minlayer param */
> + glGenTextures(2, tex);
> + glBindTexture(target, tex[0]);
> + if (target == GL_TEXTURE_1D_ARRAY) {
> + tar = GL_TEXTURE_1D;
> + glTexStorage2D(target, 7, GL_RGB16I, 64, 4);
> + } else if (target == GL_TEXTURE_2D_ARRAY) {
> + tar = GL_TEXTURE_2D;
> + glTexStorage3D(target, 7, GL_RGB16F, 64, 64, 4);
> + } else {
> + printf("%s: %s: called with invalid target\n",TestName,
> + __func__);
__FUNCTION__
> + return false;
> + }
> + glTextureView(tex[1],target, tex[0], GL_RGB16UI, 0, 7, 4,
> + 2);
> + pass = pass && piglit_check_gl_error(GL_INVALID_VALUE);
> + glDeleteTextures(1, &tex[1]);
> +
> + /* invalid numlayer param */
> + glGenTextures(1, &tex[1]);
> + glTextureView(tex[1],tar, tex[0], GL_RGB16I, 1, 5, 0, 4);
> + pass = pass && piglit_check_gl_error(GL_INVALID_OPERATION);
> +
> + glDeleteTextures(2, tex);
> + return pass;
> +}
> +
> +/**
> + * Test TextureView with invalid argument for "minlevel"
> + * Errors as per OpenGL core 4.3 spec section 8.18:
> + * "An INVALID_VALUE error is generated if minlevel or minlayer are larger
> + * than the greatest level or layer, respectively, of origtexture."
> + */
> +static bool
> +invalid_level_param()
> +{
> + bool pass = true;
> + GLuint tex[2];
> +
> + /* invalid minlevel param */
> + glGenTextures(2, tex);
> + glBindTexture(GL_TEXTURE_1D, tex[0]);
> + glTexStorage1D(GL_TEXTURE_1D, 6, GL_RGB16F, 32);
> + glTextureView(tex[1],GL_TEXTURE_1D, tex[0], GL_RGB16UI, 7, 5, 1, 1);
> + if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
> + pass = false;
> + }
> + glDeleteTextures(2, tex);
> + return pass;
> +}
> +
> +/**
> + * Test TextureView with "minlevel" range over legal values and
> + * with "numlevels" clamped correctly.
> + * As per OpenGL 4.3 Core spec section 8.18:
> + * "TEXTURE_VIEW_MIN_LEVEL is set to minlevel plus the value of
> + * TEXTURE_VIEW_MIN_LEVEL for origtexture."
> + *
> + * "The minlevel and minlayer parameters are relative to the view
> + * of origtexture. If numlayers or numlevels extend beyond origtexture,
> + * they are clamped to the maximum extent of the original texture."
> + */
> +static bool levels_clamping()
Put function name on next line. () again.
> +{
> + GLuint tex[2];
> + GLint level, i;
> + bool pass = true;
> +
> + glGenTextures(1, tex);
> + glBindTexture(GL_TEXTURE_1D, tex[0]);
> + glTexStorage1D(GL_TEXTURE_1D, 7, GL_RG16, 64);
> + for (i = 0; i < 7; i++) {
> + glGenTextures(1, &tex[1]);
> + glTextureView(tex[1],GL_TEXTURE_1D_ARRAY, tex[0], GL_RG16I,
> + i, 8-i, 0, 3);
Maybe have const int num_levels = 8 and use for (i = 0; i < num_levels -
1; i++) above to avoid magic numbers 7 and 8.
> + if (!piglit_check_gl_error(GL_NO_ERROR)) {
> + pass = false;
> + break;
> + }
> + glBindTexture(GL_TEXTURE_1D_ARRAY, tex[1]);
> + glGetTexParameteriv(GL_TEXTURE_1D_ARRAY,
> + GL_TEXTURE_VIEW_MIN_LEVEL, &level);
> + if (level != i) {
> + printf("failed at min_level=%d, queried view_min_level=%d\n",
> + i, level);
> + pass = false;
> + break;
> + }
> + glGetTexParameteriv(GL_TEXTURE_1D_ARRAY,
> + GL_TEXTURE_VIEW_NUM_LEVELS, &level);
> + if (level != (7-i)) {
> + printf("failed at min_level=%d, queried view_num_level=%d\n",
> + i, level);
> + pass = false;
> + break;
> + }
> + glDeleteTextures(1, &tex[1]);
> + glBindTexture(GL_TEXTURE_1D, tex[0]);
> + }
> +
> + glDeleteTextures(2, tex);
> + return pass;
> +}
> +
> +/**
> + * Test TextureView with "minlayer" range over legal values and
> + * with "numlayers" clamped correctly.
> + * As per OpenGL 4.3 Core spec section 8.18:
> + * "TEXTURE_VIEW_MIN_LAYER is set to minlayer plus the value of
> + * TEXTURE_VIEW_MIN_LAYER for origtexture."
> + *
> + * "The minlevel and minlayer parameters are relative to the view
> + * of origtexture. If numlayers or numlevels extend beyond origtexture,
> + * they are clamped to the maximum extent of the original texture."
> + */
> +static bool layers_clamping()
static bool
layers_clamping(void)
> +{
> + bool pass = true;
> + GLuint tex[2];
> + GLint layer, i;
> +
> + glGenTextures(1, tex);
> + glBindTexture(GL_TEXTURE_1D_ARRAY, tex[0]);
> + glTexStorage2D(GL_TEXTURE_1D_ARRAY, 5, GL_RGBA16F, 16, 4);
> + for (i = 0; i < 4; i++) {
> + glGenTextures(1, &tex[1]);
> + glTextureView(tex[1],GL_TEXTURE_1D_ARRAY, tex[0], GL_RGBA16I,
> + 0, 7, i, 5-i);
> + if (!piglit_check_gl_error(GL_NO_ERROR)) {
> + pass = false;
> + break;
> + }
> + glBindTexture(GL_TEXTURE_1D_ARRAY, tex[1]);
> + glGetTexParameteriv(GL_TEXTURE_1D_ARRAY,
> + GL_TEXTURE_VIEW_MIN_LAYER, &layer);
> + if (layer != i) {
> + printf("failed at min_layer=%d, queried view_min_layer=%d\n",
> + i, layer);
> + pass = false;
> + break;
> + }
> + glGetTexParameteriv(GL_TEXTURE_1D_ARRAY,
> + GL_TEXTURE_VIEW_NUM_LAYERS, &layer);
> + if (layer != (4-i)) {
> + printf("failed at min_layer=%d, queried view_num_layer=%d\n",
> + i, layer);
> + pass = false;
> + break;
> + }
> + glDeleteTextures(1, &tex[1]);
> + glBindTexture(GL_TEXTURE_1D_ARRAY, tex[0]);
> + }
> +
> + glDeleteTextures(2, tex);
> + return pass;
> +
> +}
> +
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> + return PIGLIT_FAIL;
> +}
> +
> +#define X(f, desc) \
> + do { \
> + const bool subtest_pass = (f); \
> + piglit_report_subtest_result(subtest_pass \
> + ? PIGLIT_PASS : PIGLIT_FAIL, \
> + (desc)); \
> + pass = pass && subtest_pass; \
> + } while (0)
> +
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> + bool pass = true;
> +
> + piglit_require_extension("GL_ARB_texture_storage");
> + piglit_require_extension("GL_ARB_texture_view");
> + piglit_require_extension("GL_EXT_texture_integer");
> + piglit_require_extension("GL_ARB_texture_float");
> + piglit_require_extension("GL_EXT_texture_array");
> +
> + X(invalid_texture_param(), "Invalid texture or origtexture");
> + X(invalid_layer_param(GL_TEXTURE_1D_ARRAY), "Invalid layer param 1D");
> + X(invalid_layer_param(GL_TEXTURE_2D_ARRAY), "Invalid layer param 2D");
> + X(invalid_level_param(), "Invalid level param");
> + X(levels_clamping(), "Minlevel range and numlevel clamp");
> + X(layers_clamping(), "Minlayer range and numlayer clamp");
> +
> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
>
More information about the Piglit
mailing list