[Piglit] [PATCH 2/2] arb_texture_view: Test TEXTURE_IMMUTABLE_LEVELS parameter.
Matt Turner
mattst88 at gmail.com
Thu Aug 1 15:49:16 PDT 2013
... and that TEXTURE_VIEW_NUM_LEVELS is the same as
TEXTURE_IMMUTABLE_LEVELS after glTexStorage.
---
tests/spec/CMakeLists.txt | 1 +
tests/spec/arb_texture_view/CMakeLists.gl.txt | 7 ++
tests/spec/arb_texture_view/CMakeLists.txt | 1 +
.../arb_texture_view/texture-immutable-levels.c | 132 +++++++++++++++++++++
4 files changed, 141 insertions(+)
create mode 100644 tests/spec/arb_texture_view/CMakeLists.gl.txt
create mode 100644 tests/spec/arb_texture_view/CMakeLists.txt
create mode 100644 tests/spec/arb_texture_view/texture-immutable-levels.c
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 7a2213f..96987cf 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -33,6 +33,7 @@ add_subdirectory (arb_texture_rectangle)
add_subdirectory (arb_texture_multisample)
add_subdirectory (arb_texture_storage)
add_subdirectory (arb_texture_storage_multisample)
+add_subdirectory (arb_texture_view)
add_subdirectory (arb_timer_query)
add_subdirectory (arb_transform_feedback2)
add_subdirectory (ati_envmap_bumpmap)
diff --git a/tests/spec/arb_texture_view/CMakeLists.gl.txt b/tests/spec/arb_texture_view/CMakeLists.gl.txt
new file mode 100644
index 0000000..31fac0c
--- /dev/null
+++ b/tests/spec/arb_texture_view/CMakeLists.gl.txt
@@ -0,0 +1,7 @@
+link_libraries(
+ piglitutil_${piglit_target_api}
+ )
+
+piglit_add_executable(arb_texture_view-texture-immutable-levels texture-immutable-levels.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/arb_texture_view/CMakeLists.txt b/tests/spec/arb_texture_view/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_texture_view/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_texture_view/texture-immutable-levels.c b/tests/spec/arb_texture_view/texture-immutable-levels.c
new file mode 100644
index 0000000..a847eec
--- /dev/null
+++ b/tests/spec/arb_texture_view/texture-immutable-levels.c
@@ -0,0 +1,132 @@
+/* Copyright © 2013 Intel Corporation
+ *
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL VMWARE AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/**
+ * Tests the TEXTURE_IMMUTABLE_LEVELS and TEXTURE_VIEW_NUM_LEVELS parameters.
+ *
+ * The ARB_texture_view spec says:
+ *
+ * "If the command is successful, TEXTURE_IMMUTABLE_FORMAT becomes TRUE,
+ * TEXTURE_IMMUTABLE_LEVELS and TEXTURE_VIEW_NUM_LEVELS become <levels>."
+ *
+ * where <command> is glTexStorage?D.
+ *
+ * Test by calling glTexStorage*D with <levels> = 3, <width>, <height>, and
+ * <depth> = 32; and then confirming that TEXTURE_IMMUTABLE_LEVELS was
+ * correctly set to <levels>.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 12;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+ static const GLfloat data[32][32];
+ GLuint tex[3];
+ GLint level;
+ GLint num_level;
+
+ /* The GL ES 3.0 spec says:
+ *
+ * "The [initial] value of TEXTURE_IMMUTABLE_LEVELS is 0."
+ */
+ glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_LEVELS, &level);
+ if (!piglit_check_gl_error(GL_NO_ERROR)) {
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ if (level != 0) {
+ printf("Expected 0 levels initially, but glGetTexParameteriv "
+ "returned %d for GL_TEXTURE_1D.\n", level);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ glGenTextures(4, tex);
+
+ glBindTexture(GL_TEXTURE_1D, tex[0]);
+ glTexStorage1D(GL_TEXTURE_1D, 3, GL_RGBA8, 32);
+ glGetTexParameteriv(GL_TEXTURE_1D, GL_TEXTURE_IMMUTABLE_LEVELS, &level);
+ glGetTexParameteriv(GL_TEXTURE_1D, GL_TEXTURE_VIEW_NUM_LEVELS, &num_level);
+ if (level != 3) {
+ printf("Expected 3 levels, but glGetTexParameteriv returned "
+ "%d for GL_TEXTURE_1D.\n", level);
+ piglit_report_result(PIGLIT_FAIL);
+ } else if (level != num_level) {
+ printf("Expected queries of TEXTURE_IMMUTABLE_LEVELS and "
+ "TEXTURE_VIEW_NUM_LEVELS to return identical results.");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ glBindTexture(GL_TEXTURE_2D, tex[1]);
+ glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 32, 32);
+ glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_LEVELS, &level);
+ glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_VIEW_NUM_LEVELS, &num_level);
+ if (level != 3) {
+ printf("Expected 3 levels, but glGetTexParameteriv returned "
+ "%d for GL_TEXTURE_2D.\n", level);
+ piglit_report_result(PIGLIT_FAIL);
+ } else if (level != num_level) {
+ printf("Expected queries of TEXTURE_IMMUTABLE_LEVELS and "
+ "TEXTURE_VIEW_NUM_LEVELS to return identical results.");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ glBindTexture(GL_TEXTURE_3D, tex[2]);
+ glTexStorage3D(GL_TEXTURE_3D, 3, GL_RGBA8, 32, 32, 32);
+ glGetTexParameteriv(GL_TEXTURE_3D, GL_TEXTURE_IMMUTABLE_LEVELS, &level);
+ glGetTexParameteriv(GL_TEXTURE_3D, GL_TEXTURE_VIEW_NUM_LEVELS, &num_level);
+ if (level != 3) {
+ printf("Expected 3 levels, but glGetTexParameterfv returned "
+ "%d for GL_TEXTURE_3D.\n", level);
+ piglit_report_result(PIGLIT_FAIL);
+ } else if (level != num_level) {
+ printf("Expected queries of TEXTURE_IMMUTABLE_LEVELS and "
+ "TEXTURE_VIEW_NUM_LEVELS to return identical results.");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ glBindTexture(GL_TEXTURE_2D, tex[3]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_FLOAT, (const GLvoid *) data);
+ glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_LEVELS, &level);
+ if (level != 0) {
+ printf("Expected 0 levels, but glGetTexParameteriv returned "
+ "%d for GL_TEXTURE_2D.\n", level);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ glDeleteTextures(4, tex);
+
+ piglit_report_result(PIGLIT_PASS);
+ return 0;
+}
+
+void
+piglit_init(int argc, char *argv[])
+{
+ piglit_require_extension("GL_ARB_texture_view");
+}
--
1.8.1.5
More information about the Piglit
mailing list