[Piglit] [PATCH] ARB_texture_view: Add query tests for gl state effected by this extension
Jon Ashburn
jon at lunarg.com
Tue Oct 15 00:53:19 CEST 2013
Tests the queryable state from ARB_texture_view extension is correct.
Includes GL_TEXTURE_IMMUTABLE_LEVELS,GL_TEXTURE_VIEW_MIN_LEVEL,
GL_TEXTURE_VIEW_NUM_LEVELS, GL_TEXTURE_IMMUTABLE_FORMAT.
Tested on Nvidia Quadro 600, all subtests pass.
---
tests/all.tests | 1 +
tests/spec/arb_texture_view/CMakeLists.gl.txt | 1 +
tests/spec/arb_texture_view/queries.c | 198 ++++++++++++++++++++++++++
3 files changed, 200 insertions(+)
create mode 100644 tests/spec/arb_texture_view/queries.c
diff --git a/tests/all.tests b/tests/all.tests
index 9e46d00..b21d0a3 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1471,6 +1471,7 @@ arb_texture_storage_multisample['tex-param'] = concurrent_test('arb_texture_stor
arb_texture_view = Group()
spec['ARB_texture_view'] = arb_texture_view
arb_texture_view['params'] = plain_test('arb_texture_view-params')
+arb_texture_view['queries'] = plain_test('arb_texture_view-queries')
tdfx_texture_compression_fxt1 = Group()
spec['3DFX_texture_compression_FXT1'] = tdfx_texture_compression_fxt1
diff --git a/tests/spec/arb_texture_view/CMakeLists.gl.txt b/tests/spec/arb_texture_view/CMakeLists.gl.txt
index 1b0c196..94ddfb4 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-params params.c)
+piglit_add_executable(arb_texture_view-queries queries.c)
# vim: ft=cmake:
diff --git a/tests/spec/arb_texture_view/queries.c b/tests/spec/arb_texture_view/queries.c
new file mode 100644
index 0000000..e4bb084
--- /dev/null
+++ b/tests/spec/arb_texture_view/queries.c
@@ -0,0 +1,198 @@
+/*
+ * 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 queries of new state added by this extension
+ *
+ */
+
+#include "piglit-util-gl-common.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
+
+
+enum piglit_result
+piglit_display(void)
+{
+ GLuint tex[2], view_tex, l;
+ GLint param;
+
+ glGenTextures(2, tex);
+
+ // test the view causes immutable_format to be set
+ glBindTexture(GL_TEXTURE_2D, tex[0]);
+ glTexStorage2D(GL_TEXTURE_2D, 6, GL_R32F, 16, 32);
+ glTextureView(tex[1], GL_TEXTURE_2D, tex[0], GL_RG16F, 0, 1, 0, 1);
+ if (piglit_check_gl_error(GL_NO_ERROR) == GL_FALSE) {
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ glBindTexture(GL_TEXTURE_2D, tex[1]);
+ glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT, ¶m);
+ if (piglit_check_gl_error(GL_NO_ERROR) == GL_FALSE) {
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+
+ if (param != GL_TRUE) {
+ printf("bad query of immutable_format\n");
+ glDeleteTextures(2, tex);
+ return PIGLIT_FAIL;
+ }
+ glDeleteTextures(2,tex);
+
+ // test min_levels are additive
+ // test immutable_levels get set correctly
+ // note: see params test for more min/num level/layer query testing
+ glGenTextures(2,tex);
+ glBindTexture(GL_TEXTURE_CUBE_MAP, tex[0]);
+ glTexStorage2D(GL_TEXTURE_CUBE_MAP, 7, GL_R32F, 64, 64);
+ glTextureView(tex[1], GL_TEXTURE_CUBE_MAP, tex[0], GL_RG16I, 2, 4, 0, 6);
+ if (piglit_check_gl_error(GL_NO_ERROR) == GL_FALSE) {
+ glDeleteTextures(2,tex);
+ return PIGLIT_FAIL;
+ }
+ glBindTexture(GL_TEXTURE_CUBE_MAP, tex[1]);
+ glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_IMMUTABLE_LEVELS,
+ ¶m);
+ if (param != 7) {
+ glDeleteTextures(2, tex);
+ printf("bad query of immutable_levels, expected 7 got %u\n", param);
+ return PIGLIT_FAIL;
+ }
+ for (l = 0; l < 3; l++) {
+ glGenTextures(1, &view_tex);
+ glTextureView(view_tex, GL_TEXTURE_CUBE_MAP, tex[1], GL_RG16F, l, 4,
+ 0, 6);
+ glBindTexture(GL_TEXTURE_CUBE_MAP, view_tex);
+ glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_VIEW_MIN_LEVEL,
+ ¶m);
+ if (param != (2 + l)) {
+ glDeleteTextures(2, tex);
+ glDeleteTextures(1, &view_tex);
+ printf("bad query of view_min_level expected %u got %u\n", 2+l,
+ param);
+ return PIGLIT_FAIL;
+ }
+ glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_IMMUTABLE_LEVELS,
+ ¶m);
+ glDeleteTextures(1, &view_tex);
+ if (param != 7) {
+ glDeleteTextures(2, tex);
+ printf("query of immutable_levels not tracking orig, expected 7 got %u\n", param);
+ return PIGLIT_FAIL;
+ }
+ }
+ glDeleteTextures(2, tex);
+
+ // make sure default intial state is correct
+ // view_tex which is bound to GL_TEXTURE_CUBE_MAP is deleted
+ glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_VIEW_MIN_LEVEL,
+ ¶m);
+ if (param != 0) {
+ printf("bad default of min_level, expected 0 got %u\n", param);
+ return PIGLIT_FAIL;
+ }
+ glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_VIEW_NUM_LEVELS,
+ ¶m);
+ if (param != 0) {
+ printf("bad default of num_levels, expected 0 got %u\n", param);
+ return PIGLIT_FAIL;
+ }
+ glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_VIEW_MIN_LAYER,
+ ¶m);
+ if (param != 0) {
+ printf("bad default of min_layer, expected 0 got %u\n", param);
+ return PIGLIT_FAIL;
+ }
+ glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_VIEW_NUM_LAYERS,
+ ¶m);
+ if (param != 0) {
+ printf("bad default of num_layers, expected 0 got %u\n", param);
+ return PIGLIT_FAIL;
+ }
+ glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_IMMUTABLE_FORMAT,
+ ¶m);
+ if (param != 0) {
+ printf("bad default of immutable_format, expected 0 got %u\n", param);
+ return PIGLIT_FAIL;
+ }
+ glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_IMMUTABLE_LEVELS,
+ ¶m);
+ if (param != 0) {
+ printf("bad default of immutable_levels, expected 0 got %u\n", param);
+ return PIGLIT_FAIL;
+ }
+
+ // test min_layers are additive
+ glGenTextures(2, tex);
+ glBindTexture(GL_TEXTURE_2D_ARRAY, tex[0]);
+ glTexStorage3D(GL_TEXTURE_2D_ARRAY, 7, GL_RG16F, 64, 64, 8);
+ glTextureView(tex[1], GL_TEXTURE_2D_ARRAY, tex[0], GL_RG16I, 0, 3, 1, 8);
+ if (piglit_check_gl_error(GL_NO_ERROR) == GL_FALSE) {
+ glDeleteTextures(2,tex);
+ return PIGLIT_FAIL;
+ }
+ for (l = 0; l < 4; l++) {
+ glGenTextures(1, &view_tex);
+ glTextureView(view_tex, GL_TEXTURE_2D_ARRAY, tex[1], GL_RG16UI, 0, 4,
+ l, 7);
+ glBindTexture(GL_TEXTURE_2D_ARRAY, view_tex);
+ glGetTexParameteriv(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_VIEW_MIN_LAYER,
+ ¶m);
+ if (param != (1 + l)) {
+ glDeleteTextures(2, tex);
+ glDeleteTextures(1, &view_tex);
+ printf("bad query of view_min_layer expected %u got %u\n", 1+l,
+ param);
+ return PIGLIT_FAIL;
+ }
+ glDeleteTextures(1, &view_tex);
+ }
+ glDeleteTextures(2, tex);
+
+
+ if (piglit_check_gl_error(GL_NO_ERROR) == GL_FALSE)
+ return PIGLIT_FAIL;
+
+ return PIGLIT_PASS;
+
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+
+ piglit_require_extension("GL_ARB_texture_storage");
+ piglit_require_extension("GL_ARB_texture_view");
+ piglit_reset_gl_error();
+}
--
1.8.1.2
More information about the Piglit
mailing list