Check if the type returned by glGetActiveUniform and glGetActiveAttrib
is correct for each type of non square matrix
---
 tests/all.py                                       |   1 +
 tests/spec/CMakeLists.txt                          |   1 +
 .../nv_non_square_matrices/CMakeLists.gles2.txt    |  13 ++
 tests/spec/nv_non_square_matrices/CMakeLists.txt   |   1 +
 .../nv_non_square_matrices/get-active-matrix.c     | 197 +++++++++++++++++++++
 5 files changed, 213 insertions(+)
 create mode 100644 tests/spec/nv_non_square_matrices/CMakeLists.gles2.txt
 create mode 100644 tests/spec/nv_non_square_matrices/CMakeLists.txt
 create mode 100644 tests/spec/nv_non_square_matrices/get-active-matrix.c

diff --git a/tests/all.py b/tests/all.py
index 3ca1c24..6698f22 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3045,6 +3045,7 @@ nv_conditional_render['vertex_array'] = 
PlainExecTest(['nv_conditional_render-ve
 
 nv_non_square_matrices = Group()
 spec['NV_non_square_matrices'] = nv_non_square_matrices
+nv_non_square_matrices['get-active-matrix'] = 
concurrent_test('nv_non_square_matrices-get-active-matrix')
 import_glsl_parser_tests(spec['NV_non_square_matrices'],
                         os.path.join(testsDir, 'spec', 
'nv_non_square_matrices'),
                         ['compiler'])
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 5de9ecc..59f6db0 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -60,6 +60,7 @@ add_subdirectory (ext_texture_swizzle)
 add_subdirectory (ext_timer_query)
 add_subdirectory (ext_transform_feedback)
 add_subdirectory (nv_conditional_render)
+add_subdirectory (nv_non_square_matrices)
 add_subdirectory (nv_texture_barrier)
 add_subdirectory (oes_compressed_etc1_rgb8_texture)
 add_subdirectory (oes_compressed_paletted_texture)
diff --git a/tests/spec/nv_non_square_matrices/CMakeLists.gles2.txt 
b/tests/spec/nv_non_square_matrices/CMakeLists.gles2.txt
new file mode 100644
index 0000000..7084944
--- /dev/null
+++ b/tests/spec/nv_non_square_matrices/CMakeLists.gles2.txt
@@ -0,0 +1,13 @@
+include_directories(
+       ${GLEXT_INCLUDE_DIR}
+       ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+       piglitutil_${piglit_target_api}
+       ${OPENGL_gles2_LIBRARY}
+)
+
+piglit_add_executable (nv_non_square_matrices-get-active-matrix 
get-active-matrix.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/nv_non_square_matrices/CMakeLists.txt 
b/tests/spec/nv_non_square_matrices/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/nv_non_square_matrices/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/nv_non_square_matrices/get-active-matrix.c 
b/tests/spec/nv_non_square_matrices/get-active-matrix.c
new file mode 100644
index 0000000..8154ecb
--- /dev/null
+++ b/tests/spec/nv_non_square_matrices/get-active-matrix.c
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2014 Rafal Mielniczuk <rafal.mielnicz...@gmail.com>
+ *
+ * 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 AUTHORS 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.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+       config.supports_gl_es_version = 20;
+
+       config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+       return PIGLIT_PASS;
+}
+
+/**
+ * gl2ext.h may not contain _NV suffixed defines.
+ * Define them to prevent build failures, they have the same value
+ */
+#if !defined GL_FLOAT_MAT2x3_NV
+#define GL_FLOAT_MAT2x3_NV GL_FLOAT_MAT2x3
+#define GL_FLOAT_MAT3x2_NV GL_FLOAT_MAT3x2
+#define GL_FLOAT_MAT2x4_NV GL_FLOAT_MAT2x4
+#define GL_FLOAT_MAT4x2_NV GL_FLOAT_MAT4x2
+#define GL_FLOAT_MAT3x4_NV GL_FLOAT_MAT3x4
+#define GL_FLOAT_MAT4x3_NV GL_FLOAT_MAT4x3
+#endif
+
+static const char * const fs_sources[] = {
+       "#version 100\n"
+       "#extension GL_NV_non_square_matrices: require\n"
+       "uniform lowp mat2x3 m;\n"
+       "void main() {\n"
+       "       gl_FragColor = vec4(m * vec2(1.0, 1.0), 1.0);\n"
+       "}\n",
+
+       "#version 100\n"
+       "#extension GL_NV_non_square_matrices: require\n"
+       "uniform lowp mat3x2 m;\n"
+       "void main() {\n"
+       "       gl_FragColor = vec4(m * vec3(1.0, 1.0, 1.0), 1.0, 1.0);\n"
+       "}\n",
+
+       "#version 100\n"
+       "#extension GL_NV_non_square_matrices: require\n"
+       "uniform lowp mat2x4 m;\n"
+       "void main() {\n"
+       "       gl_FragColor = vec4(m * vec2(1.0, 1.0));\n"
+       "}\n",
+
+       "#version 100\n"
+       "#extension GL_NV_non_square_matrices: require\n"
+       "uniform lowp mat4x2 m;\n"
+       "void main() {\n"
+       "       gl_FragColor = vec4(m * vec4(1.0, 1.0, 1.0, 1.0), 1.0, 1.0);\n"
+       "}\n",
+
+       "#version 100\n"
+       "#extension GL_NV_non_square_matrices: require\n"
+       "uniform lowp mat3x4 m;\n"
+       "void main() {\n"
+       "       gl_FragColor = vec4(m * vec3(1.0, 1.0, 1.0));\n"
+       "}\n",
+
+       "#version 100\n"
+       "#extension GL_NV_non_square_matrices: require\n"
+       "uniform lowp mat4x3 m;\n"
+       "void main() {\n"
+       "       gl_FragColor = vec4(m * vec4(1.0, 1.0, 1.0, 1.0), 1.0);\n"
+       "}\n",
+};
+
+static const char * const vs_sources[] = {
+       "#version 100\n"
+       "#extension GL_NV_non_square_matrices: require\n"
+       "attribute mat2x3 m;\n"
+       "void main() {\n"
+       "       gl_Position = vec4(m * vec2(1.0, 1.0), 1.0);\n"
+       "}\n",
+
+       "#version 100\n"
+       "#extension GL_NV_non_square_matrices: require\n"
+       "attribute mat3x2 m;\n"
+       "void main() {\n"
+       "       gl_Position = vec4(m * vec3(1.0, 1.0, 1.0), 1.0, 1.0);\n"
+       "}\n",
+
+       "#version 100\n"
+       "#extension GL_NV_non_square_matrices: require\n"
+       "attribute mat2x4 m;\n"
+       "void main() {\n"
+       "       gl_Position = vec4(m * vec2(1.0, 1.0));\n"
+       "}\n",
+
+       "#version 100\n"
+       "#extension GL_NV_non_square_matrices: require\n"
+       "attribute mat4x2 m;\n"
+       "void main() {\n"
+       "       gl_Position = vec4(m * vec4(1.0, 1.0, 1.0, 1.0), 1.0, 1.0);\n"
+       "}\n",
+
+       "#version 100\n"
+       "#extension GL_NV_non_square_matrices: require\n"
+       "attribute mat3x4 m;\n"
+       "void main() {\n"
+       "       gl_Position = vec4(m * vec3(1.0, 1.0, 1.0));\n"
+       "}\n",
+
+       "#version 100\n"
+       "#extension GL_NV_non_square_matrices: require\n"
+       "attribute mat4x3 m;\n"
+       "void main() {\n"
+       "       gl_Position = vec4(m * vec4(1.0, 1.0, 1.0, 1.0), 1.0);\n"
+       "}\n",
+};
+
+static bool
+test_get_active(const char *vs, const char *fs, GLenum expected_type,
+               const char *matrix_type)
+{
+       GLint name_len, num;
+       GLenum type = GL_ZERO;
+       GLchar name[100];
+       GLuint prog;
+
+       prog = piglit_build_simple_program(vs, fs);
+       glUseProgram(prog);
+
+       glGetActiveAttrib(prog, 0, sizeof(name)-1,
+                         &name_len, &num, &type, name);
+
+       if (type != expected_type) {
+               fprintf(stderr, "glGetActiveAttrib failed "
+                       "for matrix type %s\n",
+                       matrix_type);
+               return false;
+       }
+
+       glGetActiveUniform(prog, 0, sizeof(name)-1,
+                          &name_len, &num, &type, name);
+
+       if (type != expected_type) {
+               fprintf(stderr, "glGetActiveUniform failed "
+                       "for matrix type %s\n",
+                       matrix_type);
+               return false;
+       }
+
+       return true;
+}
+
+void piglit_init(int argc, char **argv)
+{
+       bool pass = true;
+
+       piglit_require_extension("GL_NV_non_square_matrices");
+
+       pass = test_get_active(vs_sources[0], fs_sources[0],
+                              GL_FLOAT_MAT2x3_NV, "mat2x3") && pass;
+       pass = test_get_active(vs_sources[1], fs_sources[1],
+                              GL_FLOAT_MAT3x2_NV, "mat3x2") && pass;
+       pass = test_get_active(vs_sources[2], fs_sources[2],
+                              GL_FLOAT_MAT2x4_NV, "mat2x4") && pass;
+       pass = test_get_active(vs_sources[3], fs_sources[3],
+                              GL_FLOAT_MAT4x2_NV, "mat4x2") && pass;
+       pass = test_get_active(vs_sources[4], fs_sources[4],
+                              GL_FLOAT_MAT3x4_NV, "mat3x4") && pass;
+       pass = test_get_active(vs_sources[5], fs_sources[5],
+                              GL_FLOAT_MAT4x3_NV, "mat4x3") && pass;
+
+       piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
1.9.0

_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to