[Piglit] [PATCH 1/3] ARB_texture_view: Test for API coverage of subset of input params

Jon Ashburn jon at lunarg.com
Thu Oct 17 01:37:45 CEST 2013


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          | 241 ++++++++++++++++++++++++++
 3 files changed, 247 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..b458a03
--- /dev/null
+++ b/tests/spec/arb_texture_view/params.c
@@ -0,0 +1,241 @@
+/*
+ * 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";
+
+
+/**
+ * Do error-check tests for misc glTextureView parameters
+ */
+enum piglit_result
+piglit_display(void)
+{
+	enum piglit_result pass = PIGLIT_PASS;
+	GLuint tex[2];
+	GLint level, layer, i;
+	unsigned char * ptr;
+
+	/* 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__);
+		pass = PIGLIT_FAIL;
+		goto err_out;
+	}
+	glTextureView(tex[1], GL_TEXTURE_2D, tex[0], GL_R8, 0, 1, 0, 1);
+	if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {
+		pass = PIGLIT_FAIL;
+		goto err_out;
+	}
+	glDeleteTextures(1, &tex[1]);
+	glTexStorage2D(GL_TEXTURE_2D,2, GL_RGBA32F, 16, 16);
+	if (!piglit_check_gl_error(GL_NO_ERROR)) {
+		pass = PIGLIT_FAIL;
+		goto err_out1;
+	}
+	glGenTextures(1, &tex[1]);
+	glTextureView(tex[1], GL_TEXTURE_2D, 0, GL_RGBA32UI, 0, 1, 0, 1);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
+		pass = PIGLIT_FAIL;
+		goto err_out;
+	}
+	glDeleteTextures(1, &tex[1]);
+
+	/* invalid  texture param */
+	glTextureView(0, GL_TEXTURE_2D, tex[0], GL_RGBA32I, 0, 1, 0 ,1);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
+		pass = PIGLIT_FAIL;
+		goto err_out1;
+	}
+	glGenTextures(1, &tex[1]);
+	glBindTexture(GL_TEXTURE_2D, tex[1]);
+	glTextureView(tex[1], GL_TEXTURE_2D, tex[0],GL_RGBA32F, 0, 1, 0, 1);
+	if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {
+		pass = PIGLIT_FAIL;
+		goto err_out;
+	}
+	glDeleteTextures(2, tex);
+
+	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);
+	if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {
+		pass = PIGLIT_FAIL;
+		goto err_out1;
+	}
+	glDeleteTextures(1, tex);
+
+	/* orig texture not immutable */
+	ptr = (unsigned char *) malloc(32 * 32 * 2 * 6);
+	if (ptr == NULL)
+		return PIGLIT_SKIP;
+	glGenTextures(2, tex);
+	glBindTexture(GL_TEXTURE_2D, tex[0]);
+	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16, 32, 32, 0, GL_RGB,
+		     GL_SHORT, ptr);
+	glTexImage2D(GL_TEXTURE_2D, 1, GL_RGB16, 16, 16, 0, GL_RGB,
+		     GL_SHORT, ptr);
+	free(ptr);
+	glTextureView(tex[1], GL_TEXTURE_2D, tex[0], GL_RGBA32F, 0,1,0,1);
+	if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {
+		pass = PIGLIT_FAIL;
+		goto err_out;
+	}
+	glDeleteTextures(2, tex);
+
+	/* invalid layer param */
+	glGenTextures(2, tex);
+	glBindTexture(GL_TEXTURE_1D_ARRAY, tex[0]);
+	glTexStorage2D(GL_TEXTURE_1D_ARRAY, 7, GL_RGB16I, 64, 4);
+	glTextureView(tex[1],GL_TEXTURE_1D_ARRAY, tex[0], GL_RGB16UI, 0, 7, 4,
+		      2);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
+		pass = PIGLIT_FAIL;
+		goto err_out;
+	}
+	glDeleteTextures(1, &tex[1]);
+	glGenTextures(1, &tex[1]);
+	glTextureView(tex[1],GL_TEXTURE_1D, tex[0], GL_RGB16I, 1, 5, 0, 4);
+	if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {
+		pass = PIGLIT_FAIL;
+		goto err_out;
+	}
+	glDeleteTextures(1, &tex[1]);
+
+	/* invalid level param */
+	glGenTextures(1, &tex[1]);
+	glTextureView(tex[1],GL_TEXTURE_1D, tex[0], GL_RGB16UI, 7, 5, 1, 1);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
+		pass = PIGLIT_FAIL;
+		goto err_out;
+	}
+	glDeleteTextures(1, &tex[1]);
+
+	/* numlevels clamping, minlevel range over legal values */
+	for (i = 0; i < 7; i++) {
+		glGenTextures(1, &tex[1]);
+		glTextureView(tex[1],GL_TEXTURE_1D_ARRAY, tex[0], GL_RGB16F,
+			      i, 8-i, 0, 5);
+		if (!piglit_check_gl_error(GL_NO_ERROR)) {
+			pass = PIGLIT_FAIL;
+			goto err_out;
+		}
+		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 = PIGLIT_FAIL;
+			goto err_out;
+		}
+		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 = PIGLIT_FAIL;
+			goto err_out;
+		}
+		glDeleteTextures(1, &tex[1]);
+		glBindTexture(GL_TEXTURE_1D_ARRAY, tex[0]);
+	}
+
+	/* numlayers clamping, minlayers range over legal values */
+	for (i = 0; i < 4; i++) {
+		glGenTextures(1, &tex[1]);
+		glTextureView(tex[1],GL_TEXTURE_1D_ARRAY, tex[0], GL_RGB16I,
+			      0, 7, i, 5-i);
+		if (!piglit_check_gl_error(GL_NO_ERROR)) {
+			pass = PIGLIT_FAIL;
+			goto err_out;
+		}
+		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 = PIGLIT_FAIL;
+			goto err_out;
+		}
+		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 = PIGLIT_FAIL;
+			goto err_out;
+		}
+		glDeleteTextures(1, &tex[1]);
+		glBindTexture(GL_TEXTURE_1D_ARRAY, tex[0]);
+	}
+
+err_out1:
+	glDeleteTextures(1, tex);
+	piglit_report_result(pass);
+	return pass;
+err_out:
+	glDeleteTextures(2, tex);
+	piglit_report_result(pass);
+	return pass;
+
+}
+
+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_EXT_texture_integer");
+	piglit_require_extension("GL_ARB_texture_float");
+	piglit_require_extension("GL_EXT_texture_array");
+}
-- 
1.8.1.2



More information about the Piglit mailing list