[Piglit] [PATCH] ARB_texture_view: Add test for API coverage
Jon Ashburn
jon at lunarg.com
Tue Oct 15 00:30:55 CEST 2013
Tests GL_ARB_texture_view and validity of input parameters for API calls.
Uses both valid and invalid parameters.
Ran on Nvidia Quadro 600, all subtests pass.
---
tests/spec/arb_texture_view/params.c | 643 +++++++++++++++++++++++++++++++++++
1 file changed, 643 insertions(+)
create mode 100644 tests/spec/arb_texture_view/params.c
diff --git a/tests/spec/arb_texture_view/params.c b/tests/spec/arb_texture_view/params.c
new file mode 100644
index 0000000..2714dd4
--- /dev/null
+++ b/tests/spec/arb_texture_view/params.c
@@ -0,0 +1,643 @@
+/*
+ * 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.
+ *
+ */
+
+#include "piglit-util-gl-common.h"
+#include <stdarg.h>
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 10;
+
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char *TestName = "arb_texture_view-params";
+
+
+void update_valid_arrays(GLenum *valid, GLenum *invalid, unsigned int num_invalid,
+ unsigned int num_valid, ... )
+{
+ va_list args;
+ GLenum val;
+ unsigned int i,j;
+
+ va_start(args, num_valid);
+ for (i = 0; i < num_valid; i++) {
+ val = va_arg(args, GLenum);
+ valid[i] = val;
+ // remove the valid enum from the invalid array
+ for (j= 0; j < num_invalid; j++) {
+ if (invalid[j] == val)
+ invalid[j] = 0;
+ }
+ }
+ va_end(args);
+}
+
+/**
+ * Do error-check tests for texture targets
+ */
+static enum piglit_result
+test_target_errors(GLenum target)
+{
+ GLint width = 64, height = 14, depth = 8;
+ const GLsizei levels = 1;
+ GLuint tex;
+ GLenum legal_targets[4];
+ unsigned int num_targets, i;
+ GLenum illegal_targets[] = {
+ // 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);
+ num_targets = 2;
+ update_valid_arrays(legal_targets, illegal_targets,
+ ARRAY_SIZE(illegal_targets), num_targets,
+ GL_TEXTURE_1D, GL_TEXTURE_1D_ARRAY);
+ break;
+ case GL_TEXTURE_1D_ARRAY:
+ glTexStorage2D(target, levels*2, GL_RGBA8, width, height);
+ num_targets = 2;
+ update_valid_arrays(legal_targets, illegal_targets,
+ ARRAY_SIZE(illegal_targets), num_targets,
+ GL_TEXTURE_1D, GL_TEXTURE_1D_ARRAY);
+ break;
+ case GL_TEXTURE_2D:
+ glTexStorage2D(target, levels, GL_RGBA8, width, height);
+ num_targets = 2;
+ update_valid_arrays(legal_targets, illegal_targets,
+ ARRAY_SIZE(illegal_targets), num_targets,
+ GL_TEXTURE_2D, GL_TEXTURE_2D_ARRAY);
+ break;
+ case GL_TEXTURE_RECTANGLE:
+ glTexStorage2D(target, levels, GL_RGBA8, width, height);
+ num_targets = 1;
+ update_valid_arrays(legal_targets, illegal_targets,
+ ARRAY_SIZE(illegal_targets), num_targets,
+ GL_TEXTURE_RECTANGLE);
+ break;
+ case GL_TEXTURE_CUBE_MAP:
+ width = height;
+ glTexStorage2D(target, levels, GL_RGBA8, width, height);
+ num_targets = 4;
+ update_valid_arrays(legal_targets, illegal_targets,
+ ARRAY_SIZE(illegal_targets), num_targets,
+ 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);
+ num_targets = 1;
+ update_valid_arrays(legal_targets, illegal_targets,
+ ARRAY_SIZE(illegal_targets), num_targets, 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);
+ num_targets = 4;
+ update_valid_arrays(legal_targets, illegal_targets,
+ ARRAY_SIZE(illegal_targets), num_targets,
+ 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) == GL_FALSE) {
+ printf("%s:%s Found gl errors prior to testing glTextureView\n",
+ TestName, __func__);
+ glDeleteTextures(1, &tex);
+
+ return PIGLIT_SKIP;
+ }
+
+ // ensure TextureView of legal targets works
+ for (i = 0; i < num_targets; i++) {
+ GLenum tar = legal_targets[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) == GL_FALSE) {
+ glDeleteTextures(1, &tex);
+ return PIGLIT_FAIL;
+ }
+ }
+
+ // ensure TextureView of illegal targets returns an error
+ for (i = 0; i < ARRAY_SIZE(illegal_targets); i++) {
+ GLenum tar = illegal_targets[i];
+ GLuint new_tex, layers=1;
+ if (illegal_targets[i] == 0)
+ continue;
+ 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);
+ if (piglit_check_gl_error(GL_INVALID_OPERATION) == GL_FALSE) {
+ glDeleteTextures(1, &new_tex);
+ glDeleteTextures(1, &tex);
+ return PIGLIT_FAIL;
+ }
+ glDeleteTextures(1, &new_tex);
+ }
+ glDeleteTextures(1, &tex);
+
+ return PIGLIT_PASS;
+}
+
+
+/**
+ * Do error-check tests for misc glTextureView parameters
+ */
+static enum piglit_result test_param_errors()
+{
+ GLuint tex[2] = {0, 0};
+ GLint level, layer, i;
+ unsigned char * ptr;
+
+ // invalid original texture param (origtexture)
+ glGenTextures(2, tex);
+ glBindTexture(GL_TEXTURE_3D, tex[0]);
+ if (piglit_check_gl_error(GL_NO_ERROR) == GL_FALSE) {
+ printf("%s:%s Found gl errors prior to testing glTextureView\n",
+ TestName, __func__);
+ glDeleteTextures(2, tex);
+ return PIGLIT_SKIP;
+ }
+ glTextureView(tex[1], GL_TEXTURE_3D, tex[0], GL_R8, 0, 1, 0, 1);
+ if (piglit_check_gl_error(GL_INVALID_OPERATION) == GL_FALSE) {
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ glDeleteTextures(1, &tex[1]);
+ glTexStorage3D(GL_TEXTURE_3D,2, GL_RGBA32F, 16, 16, 8);
+ if (piglit_check_gl_error(GL_NO_ERROR) == GL_FALSE) {
+ glDeleteTextures(1, tex);
+ return PIGLIT_SKIP;
+ }
+ glGenTextures(1, &tex[1]);
+ glTextureView(tex[1], GL_TEXTURE_3D, 0, GL_RGBA32UI, 0, 1, 0, 1);
+ if (piglit_check_gl_error(GL_INVALID_VALUE) == GL_FALSE) {
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ glDeleteTextures(1, &tex[1]);
+
+ // invalid texture param
+ glTextureView(0, GL_TEXTURE_3D, tex[0], GL_RGBA32I, 0, 1, 0 ,1);
+ if (piglit_check_gl_error(GL_INVALID_VALUE) == GL_FALSE) {
+ glDeleteTextures(1, tex);
+ return PIGLIT_FAIL;
+ }
+ glGenTextures(1, &tex[1]);
+ glBindTexture(GL_TEXTURE_3D, tex[1]);
+ glTextureView(tex[1], GL_TEXTURE_3D, tex[0],GL_RGBA32F, 0, 1, 0, 1);
+ if (piglit_check_gl_error(GL_INVALID_OPERATION) == GL_FALSE) {
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ glDeleteTextures(2, tex);
+
+ glGenTextures(1, tex);
+ glBindTexture(GL_TEXTURE_3D, tex[0]);
+ glTexStorage3D(GL_TEXTURE_3D, 3, GL_RG16F, 16, 16, 8);
+ glTextureView(~tex[0],GL_TEXTURE_3D, tex[0], GL_RGBA8, 0,1,0,1);
+ if (piglit_check_gl_error(GL_INVALID_OPERATION) == GL_FALSE) {
+ glDeleteTextures(1, &tex[0]);
+ return PIGLIT_FAIL;
+ }
+ glDeleteTextures(1, tex);
+
+ // orig texture not immutable
+ ptr = (unsigned char *) malloc(32 * 32 * 4 * 6);
+ if (ptr == NULL)
+ return PIGLIT_SKIP;
+ glGenTextures(2, tex);
+ glBindTexture(GL_TEXTURE_3D, tex[0]);
+ glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB16, 32, 32, 4, 0, GL_RGB,
+ GL_SHORT, ptr);
+ glTexImage3D(GL_TEXTURE_3D, 1, GL_RGB16, 16, 16, 2, 0, GL_RGB,
+ GL_SHORT, ptr);
+ free(ptr);
+ glTextureView(tex[1], GL_TEXTURE_3D, tex[0], GL_RGBA32F, 0,1,0,1);
+ if (piglit_check_gl_error(GL_INVALID_OPERATION) == GL_FALSE) {
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ 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) == GL_FALSE) {
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ 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) == GL_FALSE) {
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ 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) == GL_FALSE) {
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ 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) == GL_FALSE) {
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ 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);
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ 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);
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ 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) == GL_FALSE) {
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ 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);
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ 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);
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ glDeleteTextures(1, &tex[1]);
+ glBindTexture(GL_TEXTURE_1D_ARRAY, tex[0]);
+ }
+
+ glDeleteTextures(2, tex);
+ return PIGLIT_PASS;
+
+}
+
+/**
+ * Do error-check tests for texture targets
+ */
+static enum piglit_result
+test_format_errors(GLenum format_class)
+{
+ GLint width = 16, height = 16;
+ const GLsizei levels = 5;
+ GLenum target = GL_TEXTURE_CUBE_MAP;
+ GLuint tex;
+ GLenum legal_formats[17];
+ unsigned int num_formats, i;
+ GLenum illegal_formats[] = {
+ //skip compressed sized formats
+ //128 bit
+ GL_RGBA32F,
+ GL_RGBA32UI,
+ GL_RGBA32I,
+ // 96 bit
+ GL_RGB32F,
+ GL_RGB32UI,
+ GL_RGB32I,
+ // 64 bit
+ GL_RGBA16F,
+ GL_RG32F,
+ GL_RGBA16UI,
+ GL_RG32UI,
+ GL_RGBA16I,
+ GL_RG32I,
+ GL_RGBA16,
+ GL_RGBA16_SNORM,
+ //48 bit
+ GL_RGB16,
+ GL_RGB16_SNORM,
+ GL_RGB16F,
+ GL_RGB16UI,
+ GL_RGB16I,
+ //32 bits
+ GL_RG16F,
+ GL_R11F_G11F_B10F,
+ GL_R32F,
+ GL_RGB10_A2UI,
+ GL_RGBA8UI,
+ GL_RG16UI,
+ GL_R32UI,
+ GL_RGBA8I,
+ GL_RG16I,
+ GL_R32I,
+ GL_RGB10_A2,
+ GL_RGBA8,
+ GL_RG16,
+ GL_RGBA8_SNORM,
+ GL_RG16_SNORM,
+ GL_SRGB8_ALPHA8,
+ GL_RGB9_E5,
+ //24 bits
+ GL_RGB8,
+ GL_RGB8_SNORM,
+ GL_SRGB8,
+ GL_RGB8UI,
+ GL_RGB8I,
+ //16 bits
+ GL_R16F,
+ GL_RG8UI,
+ GL_R16UI,
+ GL_RG8I,
+ GL_R16I,
+ GL_RG8,
+ GL_R16,
+ GL_RG8_SNORM,
+ GL_R16_SNORM,
+ //8 bits
+ GL_R8UI,
+ GL_R8I,
+ GL_R8,
+ GL_R8_SNORM,
+ // a sampling of unsized formats
+ GL_ALPHA,
+ GL_LUMINANCE,
+ GL_LUMINANCE_ALPHA,
+ GL_INTENSITY,
+ GL_RGB,
+ GL_RGBA,
+ GL_DEPTH_COMPONENT,
+ GL_COMPRESSED_ALPHA,
+ GL_COMPRESSED_LUMINANCE_ALPHA,
+ GL_COMPRESSED_LUMINANCE,
+ GL_COMPRESSED_INTENSITY,
+ GL_COMPRESSED_RGB,
+ GL_COMPRESSED_RGBA,
+ GL_COMPRESSED_RGBA,
+ GL_COMPRESSED_SRGB,
+ GL_COMPRESSED_SRGB_ALPHA,
+ GL_COMPRESSED_SLUMINANCE,
+ GL_COMPRESSED_SLUMINANCE_ALPHA,
+ };
+
+ // skip compressed internal formats for now including extensions
+ assert(format_class == GL_VIEW_CLASS_128_BITS ||
+ format_class == GL_VIEW_CLASS_96_BITS ||
+ format_class == GL_VIEW_CLASS_64_BITS ||
+ format_class == GL_VIEW_CLASS_48_BITS ||
+ format_class == GL_VIEW_CLASS_32_BITS ||
+ format_class == GL_VIEW_CLASS_24_BITS ||
+ format_class == GL_VIEW_CLASS_16_BITS ||
+ format_class == GL_VIEW_CLASS_8_BITS);
+
+ glGenTextures(1, &tex); // orig tex
+ glBindTexture(target, tex);
+
+ switch (format_class) {
+ case GL_VIEW_CLASS_128_BITS:
+ glTexStorage2D(target, levels, GL_RGBA32F, width, height);
+ num_formats = 3;
+ update_valid_arrays(legal_formats, illegal_formats,
+ ARRAY_SIZE(illegal_formats), num_formats,
+ GL_RGBA32F, GL_RGBA32UI, GL_RGBA32I);
+ break;
+ case GL_VIEW_CLASS_96_BITS:
+ glTexStorage2D(target, levels, GL_RGB32F, width, height);
+ num_formats = 3;
+ update_valid_arrays(legal_formats, illegal_formats,
+ ARRAY_SIZE(illegal_formats), num_formats,
+ GL_RGB32F, GL_RGB32UI, GL_RGB32I);
+ break;
+ case GL_VIEW_CLASS_64_BITS:
+ glTexStorage2D(target, levels, GL_RGBA16F, width, height);
+ num_formats = 8;
+ update_valid_arrays(legal_formats, illegal_formats,
+ ARRAY_SIZE(illegal_formats), num_formats,
+ GL_RGBA16F, GL_RG32F, GL_RGBA16UI, GL_RG32UI,
+ GL_RGBA16I, GL_RG32I, GL_RGBA16, GL_RGBA16_SNORM);
+ break;
+ case GL_VIEW_CLASS_48_BITS:
+ glTexStorage2D(target, levels, GL_RGB16, width, height);
+ num_formats = 5;
+ update_valid_arrays(legal_formats, illegal_formats,
+ ARRAY_SIZE(illegal_formats), num_formats,
+ GL_RGB16, GL_RGB16_SNORM, GL_RGB16F, GL_RGB16UI, GL_RGB16I);
+ break;
+ case GL_VIEW_CLASS_32_BITS:
+ glTexStorage2D(target, levels, GL_RG16F, width, height);
+ num_formats = 17;
+ update_valid_arrays(legal_formats, illegal_formats,
+ ARRAY_SIZE(illegal_formats), num_formats,
+ GL_RG16F, GL_R11F_G11F_B10F, GL_R32F, GL_RGB10_A2UI,
+ GL_RGBA8UI, GL_RG16UI, GL_R32UI, GL_RGBA8I, GL_RG16I,
+ GL_R32I, GL_RGB10_A2, GL_RGBA8, GL_RG16, GL_RGBA8_SNORM,
+ GL_RG16_SNORM, GL_SRGB8_ALPHA8, GL_RGB9_E5);
+ break;
+ case GL_VIEW_CLASS_24_BITS:
+ glTexStorage2D(target, levels, GL_RGB8, width, height);
+ num_formats = 5;
+ update_valid_arrays(legal_formats, illegal_formats,
+ ARRAY_SIZE(illegal_formats), num_formats,
+ GL_RGB8, GL_RGB8_SNORM, GL_SRGB8, GL_RGB8UI, GL_RGB8I);
+ break;
+ case GL_VIEW_CLASS_16_BITS:
+ glTexStorage2D(target, levels, GL_R16F, width, height);
+ num_formats = 9;
+ update_valid_arrays(legal_formats, illegal_formats,
+ ARRAY_SIZE(illegal_formats), num_formats,
+ GL_R16F, GL_RG8UI, GL_R16UI, GL_RG8I, GL_R16I, GL_RG8,
+ GL_R16, GL_RG8_SNORM, GL_R16_SNORM);
+ break;
+ case GL_VIEW_CLASS_8_BITS:
+ glTexStorage2D(target, levels, GL_R8I, width, height);
+ num_formats = 4;
+ update_valid_arrays(legal_formats, illegal_formats,
+ ARRAY_SIZE(illegal_formats), num_formats,
+ GL_R8UI, GL_R8I, GL_R8, GL_R8_SNORM);
+ break;
+ }
+
+ if (piglit_check_gl_error(GL_NO_ERROR) == GL_FALSE) {
+ printf("%s:%s Found gl errors prior to testing glTextureView\n",
+ TestName, __func__);
+ glDeleteTextures(1, &tex);
+ return PIGLIT_SKIP;
+ }
+
+ // ensure TextureView of legal formats works
+ for (i = 0; i < num_formats; i++) {
+ GLenum format;
+ GLuint new_tex, layers=6;
+ format = legal_formats[i];
+ glGenTextures(1, &new_tex);
+ glTextureView(new_tex, target, tex, format, 0, levels, 0, layers);
+ glDeleteTextures(1, &new_tex);
+ if (piglit_check_gl_error(GL_NO_ERROR) == GL_FALSE) {
+ glDeleteTextures(1, &tex);
+ return PIGLIT_FAIL;
+ }
+ }
+
+ // ensure TextureView of illegal formats returns an error
+ for (i = 0; i < ARRAY_SIZE(illegal_formats); i++) {
+ GLenum format;
+ GLuint new_tex, layers=6;
+ format = illegal_formats[i];
+ if (format == 0)
+ continue;
+ glGenTextures(1, &new_tex);
+ glTextureView(new_tex, target, tex, format, 0, levels, 0, layers);
+ if (piglit_check_gl_error(GL_INVALID_OPERATION) == GL_FALSE) {
+ glDeleteTextures(1, &new_tex);
+ glDeleteTextures(1, &tex);
+ return PIGLIT_FAIL;
+ }
+ glDeleteTextures(1, &new_tex);
+ }
+
+ glDeleteTextures(1, &tex);
+
+ return PIGLIT_PASS;
+}
+
+
+enum piglit_result
+piglit_display(void)
+{
+ enum piglit_result pass = PIGLIT_PASS;
+ enum piglit_result tmp;
+#define X(f, n) tmp = (f); pass = tmp != PIGLIT_PASS ? PIGLIT_FAIL : pass; piglit_report_subtest_result(tmp, (n))
+ 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");
+ X(test_param_errors(), "Param texture/level/layer validity");
+ X(test_format_errors(GL_VIEW_CLASS_128_BITS), "Format 128 bits validity");
+ X(test_format_errors(GL_VIEW_CLASS_96_BITS), "Format 96 bits validity");
+ X(test_format_errors(GL_VIEW_CLASS_64_BITS), "Format 64 bits validity");
+ X(test_format_errors(GL_VIEW_CLASS_48_BITS), "Format 48 bits validity");
+ X(test_format_errors(GL_VIEW_CLASS_32_BITS), "Format 32 bits validity");
+ X(test_format_errors(GL_VIEW_CLASS_24_BITS), "Format 24 bits validity");
+ X(test_format_errors(GL_VIEW_CLASS_16_BITS), "Format 16 bits validity");
+ X(test_format_errors(GL_VIEW_CLASS_8_BITS), "Format 8 bits validity");
+#undef X
+ if (piglit_check_gl_error(GL_NO_ERROR) == GL_FALSE)
+ return PIGLIT_FAIL;
+ 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_ARB_texture_cube_map_array");
+ piglit_require_extension("GL_EXT_texture_array");
+ piglit_require_extension("GL_ARB_texture_rectangle");
+ piglit_require_extension("GL_EXT_texture3D");
+ piglit_reset_gl_error();
+}
--
1.8.1.2
More information about the Piglit
mailing list