[Piglit] [PATCH 3/8] arb_gpu_shader_fp64: test glGetUniformdv interface

Andres Gomez agomez at igalia.com
Tue Mar 15 15:50:44 UTC 2016


From: "Juan A. Suarez Romero" <jasuarez at igalia.com>

Tests this function when reading uniforms from vertex/fragment/geometry
shaders.

Signed-off-by: Andres Gomez <agomez at igalia.com>
---
 tests/all.py                                       |   4 +-
 .../execution/CMakeLists.gl.txt                    |   4 +-
 .../execution/fs-getuniformdv.c                    | 339 ++++++++++++++++++++
 .../arb_gpu_shader_fp64/execution/getuniformdv.c   | 302 ------------------
 .../execution/gs-getuniformdv.c                    | 355 +++++++++++++++++++++
 .../execution/vs-getuniformdv.c                    | 339 ++++++++++++++++++++
 6 files changed, 1039 insertions(+), 304 deletions(-)
 create mode 100644 tests/spec/arb_gpu_shader_fp64/execution/fs-getuniformdv.c
 delete mode 100644 tests/spec/arb_gpu_shader_fp64/execution/getuniformdv.c
 create mode 100644 tests/spec/arb_gpu_shader_fp64/execution/gs-getuniformdv.c
 create mode 100644 tests/spec/arb_gpu_shader_fp64/execution/vs-getuniformdv.c

diff --git a/tests/all.py b/tests/all.py
index fe88edf..c38f1e5 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2155,7 +2155,9 @@ with profile.group_manager(
      g(['arb_gpu_shader_fp64-double-gettransformfeedbackvarying'])
      g(['arb_gpu_shader_fp64-tf-interleaved'])
      g(['arb_gpu_shader_fp64-tf-interleaved-aligned'])
-     g(['arb_gpu_shader_fp64-getuniformdv'])
+     g(['arb_gpu_shader_fp64-vs-getuniformdv'])
+     g(['arb_gpu_shader_fp64-fs-getuniformdv'])
+     g(['arb_gpu_shader_fp64-gs-getuniformdv'])
      g(['arb_gpu_shader_fp64-wrong-type-setter'])
      g(['arb_gpu_shader_fp64-double_in_bool_uniform'])
 
diff --git a/tests/spec/arb_gpu_shader_fp64/execution/CMakeLists.gl.txt b/tests/spec/arb_gpu_shader_fp64/execution/CMakeLists.gl.txt
index ffb3da5..ab5618c 100644
--- a/tests/spec/arb_gpu_shader_fp64/execution/CMakeLists.gl.txt
+++ b/tests/spec/arb_gpu_shader_fp64/execution/CMakeLists.gl.txt
@@ -13,5 +13,7 @@ piglit_add_executable (arb_gpu_shader_fp64-tf-separate tf-separate.c)
 piglit_add_executable (arb_gpu_shader_fp64-tf-interleaved tf-interleaved.c)
 piglit_add_executable (arb_gpu_shader_fp64-tf-interleaved-aligned tf-interleaved-aligned.c)
 piglit_add_executable (arb_gpu_shader_fp64-double-gettransformfeedbackvarying double-gettransformfeedbackvarying.c)
-piglit_add_executable (arb_gpu_shader_fp64-getuniformdv getuniformdv.c)
+piglit_add_executable (arb_gpu_shader_fp64-vs-getuniformdv vs-getuniformdv.c)
+piglit_add_executable (arb_gpu_shader_fp64-fs-getuniformdv fs-getuniformdv.c)
+piglit_add_executable (arb_gpu_shader_fp64-gs-getuniformdv gs-getuniformdv.c)
 piglit_add_executable (arb_gpu_shader_fp64-wrong-type-setter wrong-type-setter.c)
diff --git a/tests/spec/arb_gpu_shader_fp64/execution/fs-getuniformdv.c b/tests/spec/arb_gpu_shader_fp64/execution/fs-getuniformdv.c
new file mode 100644
index 0000000..3e93917
--- /dev/null
+++ b/tests/spec/arb_gpu_shader_fp64/execution/fs-getuniformdv.c
@@ -0,0 +1,339 @@
+/*
+ * Copyright 2011 VMware, 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.
+ */
+
+/**
+ * Asst. gl[Get]Uniformdv tests.
+ * based on getunifom02.c from Brian Paul.
+ *
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_core_version = 32;
+
+	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static char *TestName = "getuniformdv";
+
+static const char vs_text[] =
+   "#version 150\n"
+   "\n"
+   "void main()\n"
+   "{\n"
+   "  gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n"
+   "}\n";
+
+static const char fs_text[] =
+   "#version 150\n"
+   "#extension GL_ARB_gpu_shader_fp64 : require\n"
+   "struct s1 { \n"
+   "   double a, b, c, d; \n"
+   "}; \n"
+   "uniform double d1; \n"
+   "uniform dvec2 u1[2]; \n"
+   "uniform dvec3 u2[4]; \n"
+   "uniform dvec4 v[3]; \n"
+   "uniform dmat2 m1; \n"
+   "uniform dmat3 m2; \n"
+   "uniform dmat4 m3[3]; \n"
+   "uniform dmat2x3 m4; \n"
+   "uniform dmat2x4 m5; \n"
+   "uniform dmat3x2 m6; \n"
+   "uniform dmat3x4 m7; \n"
+   "uniform dmat4x2 m8[2]; \n"
+   "uniform dmat4x3 m9; \n"
+   "uniform s1 s;\n"
+   "uniform double d2; \n"
+   "out vec4 fscolor;\n"
+   "void main()\n"
+   "{\n"
+   "  dvec4 t = dvec4(s.a, s.b, s.c, s.d) * d1 + d2 + u1[0]*m8[0] + u1[1]*m8[1];\n"
+   "  t += v[0]*m3[0] + v[1]*m3[1] + v[2]*m3[2]  + u2[0]*m9; \n"
+   "  t.rb += u1[0]*m1 + u1[1] + u2[0]*m4 + v[0]*m5; \n"
+   "  t.xyw += u2[0]*m2 + u2[1] + u2[2] + u2[3] + u1[1]*m6 + v[0]*m7; \n"
+   "  fscolor = vec4(t); \n"
+   "}\n";
+
+#define MAX_VALUES 16
+
+#define EXPECTED_ACTIVE_UNIFORMS 18
+
+static struct {
+   char *name;
+   char *altName;
+   GLint expectedType;
+   GLenum expectedSize;
+} uniforms[] = {
+   { "v",  "v[0]", GL_DOUBLE_VEC4,   3},
+   {"u1", "u1[0]", GL_DOUBLE_VEC2,   2},
+   {"u2", "u2[0]", GL_DOUBLE_VEC3,   4},
+   {"m1",    NULL, GL_DOUBLE_MAT2,   1},
+   {"m2",    NULL, GL_DOUBLE_MAT3,   1},
+   {"m3", "m3[0]", GL_DOUBLE_MAT4,   3},
+   {"m4",    NULL, GL_DOUBLE_MAT2x3, 1},
+   {"m5",    NULL, GL_DOUBLE_MAT2x4, 1},
+   {"m6",    NULL, GL_DOUBLE_MAT3x2, 1},
+   {"m7",    NULL, GL_DOUBLE_MAT3x4, 1},
+   {"m8", "m8[0]", GL_DOUBLE_MAT4x2, 2},
+   {"m9",    NULL, GL_DOUBLE_MAT4x3, 1},
+   {NULL,    NULL, GL_DOUBLE,        1}};  //default
+
+enum uniform_enum {
+   d1 = 0, d2, sa, sd,
+   u1_0, u1_1, u2_0, u2_2,
+   v_0, v_1,
+   m1, m2, m3, m4, m5, m6, m7, m8_0, m9, _last
+};
+
+static struct {
+   char *location;
+   GLint size;
+   GLdouble values[MAX_VALUES];
+} uniform_values[] = {
+   {    "d1",  1, { 5.0 }},
+   {    "d2",  1, {10.0}},
+   {   "s.a",  1, {15.0}},
+   {   "s.d",  1, {20.0}},
+   { "u1[0]",  2, {12.0, 14.0}},
+   { "u1[1]",  2, {5.0, 8.0}},
+   { "u2[0]",  3, {1.0, 1.0, 2.0}},
+   { "u2[2]",  3, {20.0, 20.0, 15.0}},
+   {  "v[0]",  4, {2.0, 3.0, 4.0, 5.0}},
+   {  "v[1]",  4, {1.0, 2.0, 3.0, 4.0}},
+   {    "m1",  4, {1.0, 2.0,
+                   3.0, 4.0}},
+   {    "m2",  9, {1.0, 1.0, 1.0,
+                   2.0, 2.0, 2.0,
+                   3.0, 3.0, 3.0}},
+   { "m3[1]", 16, {1.0, 2.0, 3.0, 4.0,
+                   5.0, 6.0, 7.0, 8.0,
+                   1.5, 2.5, 3.5, 4.5,
+                   5.5, 6.5, 7.5, 8.5}},
+   {    "m4",  6, {15.0, 16.0,
+                   17.0, 18.0,
+                   19.0, 20.0}},
+   {    "m5",  8, {10.0, 11.0,
+                   12.0, 13.0,
+                   14.0, 15.0,
+                   15.0, 17.0}},
+   {    "m6",  6, {51.0, 52.0, 53.0,
+                   54.0, 55.0, 56.0 }},
+   {    "m7", 12, {28.0, 29.0, 30.0,
+                   31.0, 32.0, 33.0,
+                   34.0, 35.0, 36.0,
+                   37.0, 38.0, 39.0}},
+   { "m8[0]",  8, {2.7, 3.7, 4.7, 5.7,
+                   6.7, 8.7, 9.7, 1.7}},
+   {   "m9",  12, {11.1, 12.1, 13.1, 14.1,
+                   15.1, 16.1, 17.1, 18.1,
+                   19.1, 20.1, 21.1, 22.1}}};
+
+enum piglit_result
+piglit_display(void)
+{
+   /* never called */
+   return PIGLIT_FAIL;
+}
+
+static bool
+verify_uniform(GLuint prog, enum uniform_enum u)
+{
+   GLint loc;
+   GLdouble val[MAX_VALUES];
+   bool match = true;
+   int i;
+
+   loc = glGetUniformLocation(prog, uniform_values[u].location);
+   glGetUniformdv(prog, loc, val);
+   for (i = 0; i < uniform_values[u].size; i++) {
+      match = match && (val[i] == uniform_values[u].values[i]);
+   }
+
+   if (!match) {
+      printf("%s: wrong value for %s (found ",
+             TestName, uniform_values[u].location);
+      for (i = 0; i < uniform_values[u].size; i++) {
+         printf("%g,", val[i]);
+      }
+      printf(" expected ");
+      for (i = 0; i < (uniform_values[u].size - 1); i++) {
+         printf("%g,", uniform_values[u].values[i]);
+      }
+      printf ("%g)\n", uniform_values[u].values[uniform_values[u].size - 1]);
+   }
+
+   return match;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+   bool piglit_pass = true;
+   GLuint vs, fs, prog;
+   GLint numUniforms, i;
+   GLint loc;
+   enum uniform_enum u;
+
+   piglit_require_extension("GL_ARB_gpu_shader_fp64");
+
+   vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
+   fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_text);
+   prog = piglit_link_simple_program(vs, fs);
+
+   glUseProgram(prog);
+
+   glGetProgramiv(prog, GL_ACTIVE_UNIFORMS, &numUniforms);
+   if (numUniforms != EXPECTED_ACTIVE_UNIFORMS) {
+      printf("%s: incorrect number of uniforms (found %d, expected %d)\n",
+             TestName, numUniforms, EXPECTED_ACTIVE_UNIFORMS);
+      piglit_pass = false;
+   }
+
+   /* check types, sizes */
+   for (i = 0; i < numUniforms; i++) {
+      GLcharARB name[100];
+      GLsizei len;
+      GLint size, j;
+      GLenum type;
+      GLint loc;
+
+      glGetActiveUniform(prog, i, sizeof(name), &len, &size, &type, name);
+      loc = glGetUniformLocation(prog, name);
+
+      if (loc < 0) {
+         printf("%s: bad uniform location for %s: %d\n", TestName, name, loc);
+         piglit_pass = false;
+      }
+
+      if (!piglit_automatic) {
+         printf("%d: %s loc=%d size=%d type=0x%x\n", i, name, loc, size, type);
+      }
+
+      /* OpenGL ES 3.0 and OpenGL 4.2 require that the "[0]" be appended to
+       * the name.  Earlier versions of the spec are ambiguous.  Accept either
+       * name.
+       */
+      j = 0;
+      while (uniforms[j].name != NULL) {
+         if (strcmp(name, uniforms[j].name) == 0) {
+            break;
+         }
+         if (uniforms[j].altName && strcmp(name, uniforms[j].altName) == 0) {
+            break;
+         }
+         j++;
+      }
+
+      if (type != uniforms[j].expectedType) {
+         printf("%s: wrong type for '%s' (found 0x%x, expected 0x%x)\n",
+                TestName,
+                uniforms[j].name ? uniforms[j].name : name,
+                type, uniforms[j].expectedType);
+         piglit_pass = false;
+      }
+
+      if (size != uniforms[j].expectedSize) {
+         printf("%s: wrong size for '%s' (found %d, expected %d)\n",
+                TestName,
+                uniforms[j].name ? uniforms[j].name : name,
+                size, uniforms[j].expectedSize);
+         piglit_pass = false;
+      }
+   }
+
+   /* Check setting/getting values */
+
+   loc = glGetUniformLocation(prog, uniform_values[d1].location);
+   glUniform1d(loc, uniform_values[d1].values[0]);
+
+   loc = glGetUniformLocation(prog, uniform_values[d2].location);
+   glUniform1d(loc, uniform_values[d2].values[0]);
+
+   loc = glGetUniformLocation(prog, uniform_values[sa].location);
+   glUniform1dv(loc, 1, uniform_values[sa].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[sd].location);
+   glUniform1d(loc, uniform_values[sd].values[0]);
+
+   loc = glGetUniformLocation(prog, uniform_values[u1_0].location);
+   glUniform2dv(loc, 1, uniform_values[u1_0].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[u2_0].location);
+   glUniform3dv(loc, 1, uniform_values[u2_0].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[v_1].location);
+   glUniform4dv(loc, 1, uniform_values[v_1].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m1].location);
+   glUniformMatrix2dv(loc, 1, false, uniform_values[m1].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m2].location);
+   glUniformMatrix3dv(loc, 1, false, uniform_values[m2].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m3].location);
+   glUniformMatrix4dv(loc, 1, false, uniform_values[m3].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m4].location);
+   glUniformMatrix2x3dv(loc, 1, false, uniform_values[m4].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m5].location);
+   glUniformMatrix2x4dv(loc, 1, false, uniform_values[m5].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m6].location);
+   glUniformMatrix3x2dv(loc, 1, false, uniform_values[m6].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m7].location);
+   glUniformMatrix3x4dv(loc, 1, false, uniform_values[m7].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m8_0].location);
+   glUniformMatrix4x2dv(loc, 1, false, uniform_values[m8_0].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m9].location);
+   glUniformMatrix4x3dv(loc, 1, false, uniform_values[m9].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[u1_1].location);
+   glUniform2d(loc, uniform_values[u1_1].values[0], uniform_values[u1_1].values[1]);
+
+   loc = glGetUniformLocation(prog, uniform_values[u2_2].location);
+   glUniform3d(loc,
+               uniform_values[u2_2].values[0],
+               uniform_values[u2_2].values[1],
+               uniform_values[u2_2].values[2]);
+
+   loc = glGetUniformLocation(prog, uniform_values[v_0].location);
+   glUniform4d(loc,
+               uniform_values[v_0].values[0],
+               uniform_values[v_0].values[1],
+               uniform_values[v_0].values[2],
+               uniform_values[v_0].values[3]);
+
+   for (u = 0; u < _last; u++) {
+      piglit_pass = piglit_pass && verify_uniform(prog, u);
+   }
+
+   piglit_report_result(piglit_pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
diff --git a/tests/spec/arb_gpu_shader_fp64/execution/getuniformdv.c b/tests/spec/arb_gpu_shader_fp64/execution/getuniformdv.c
deleted file mode 100644
index 5f7d85e..0000000
--- a/tests/spec/arb_gpu_shader_fp64/execution/getuniformdv.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright 2011 VMware, 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.
- */
-
-/**
- * Asst. gl[Get]Uniformdv tests.
- * based on getunifom02.c from Brian Paul.
- *
- */
-
-#include "piglit-util-gl.h"
-
-PIGLIT_GL_TEST_CONFIG_BEGIN
-
-	config.supports_gl_core_version = 32;
-
-	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
-
-PIGLIT_GL_TEST_CONFIG_END
-
-static char *TestName = "getuniformdv";
-
-static const char vs_text[] =
-   "#version 150\n"
-   "#extension GL_ARB_gpu_shader_fp64 : require\n"
-   "struct s1 { \n"
-   "   double a, b, c, d; \n"
-   "}; \n"
-   "uniform double d1; \n"
-   "uniform dvec4 v[3]; \n"
-   "uniform s1 s;\n"
-   "uniform double d2; \n"
-   "uniform float f1; \n"
-   "uniform vec4 fv1; \n"
-   "uniform uint ui1; \n"
-   "uniform int i1; \n"
-   "uniform bool b1; \n"
-   "out vec4 color; \n"
-   "\n"
-   "void main()\n"
-   "{\n"
-   "  gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n"
-   "  dvec4 t = dvec4(s.a, s.b, s.c, s.d) * d1 + d2 + double(f1) + double(ui1) + double(i1) + double(b1);\n"
-   "  t += fv1.x + fv1.y + fv1.z + fv1.w;\n"
-   "  t += v[0] + v[1] + v[2]; \n"
-   "  color = vec4(t); \n"
-   "}\n";
-
-static const char fs_text[] =
-   "#version 150\n"
-   "in vec4 color;\n"
-   "void main() { gl_FragColor = color; }";
-
-enum piglit_result
-piglit_display(void)
-{
-   /* never called */
-   return PIGLIT_FAIL;
-}
-
-
-void
-piglit_init(int argc, char **argv)
-{
-   GLuint vs, fs, prog;
-   GLint numUniforms, i;
-   GLint expectedNum = 12;
-   GLint loc_d1, loc_d2, loc_sa, loc_sd, loc_v1, loc_f1, loc_fv1, loc_ui1, loc_i1, loc_b1;
-   GLdouble v[4];
-   GLfloat f[4];
-   GLuint ui[4];
-   GLint i_val[4];
-
-   static const GLdouble vVals[4] = {30.0, 31.0, 32.0, 33.0};
-   
-   piglit_require_extension("GL_ARB_gpu_shader_fp64");
-
-   vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
-   fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_text);
-   prog = piglit_link_simple_program(vs, fs);
-
-   glUseProgram(prog);
-
-   glGetProgramiv(prog, GL_ACTIVE_UNIFORMS, &numUniforms);
-   if (numUniforms != expectedNum) {
-      printf("%s: incorrect number of uniforms (found %d, expected %d)\n",
-             TestName, numUniforms, expectedNum);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-
-   /* check types, sizes */
-   for (i = 0; i < numUniforms; i++) {
-      GLcharARB name[100];
-      GLsizei len;
-      GLint size, expectedSize;
-      GLenum type, expectedType;
-      GLint loc;
-
-      glGetActiveUniform(prog, i, sizeof(name), &len, &size, &type, name);
-      loc = glGetUniformLocation(prog, name);
-
-      if (loc < 0) {
-         printf("%s: bad uniform location for %s: %d\n", TestName, name, loc);
-         piglit_report_result(PIGLIT_FAIL);
-      }
-
-      if (!piglit_automatic) {
-         printf("%d: %s loc=%d size=%d type=0x%x\n", i, name, loc, size, type);
-      }
-
-      /* OpenGL ES 3.0 and OpenGL 4.2 require that the "[0]" be appended to
-       * the name.  Earlier versions of the spec are ambiguous.  Accept either
-       * name.
-       */
-      if (strcmp(name, "v") == 0 || strcmp(name, "v[0]") == 0) {
-         expectedType = GL_DOUBLE_VEC4;
-         expectedSize = 3;
-      } else if (name[0] == 'd' || (name[0] == 's')) {
-         expectedType = GL_DOUBLE;
-         expectedSize = 1;
-      } else if (name[0] == 'f') {
-	if (name[1] == 'v')
-	  expectedType = GL_FLOAT_VEC4;
-	else
-	  expectedType = GL_FLOAT;
-	expectedSize = 1;
-      } else if (name[0] == 'i') {
-         expectedType = GL_INT;
-         expectedSize = 1;
-      } else if (name[0] == 'u') {
-         expectedType = GL_UNSIGNED_INT;
-         expectedSize = 1;
-      } else if (name[0] == 'b') {
-	 expectedType = GL_BOOL;
-         expectedSize = 1;
-      }
-
-      if (type != expectedType) {
-         printf("%s: wrong type for 'v' (found 0x%x, expected 0x%x)\n",
-                TestName, type, expectedType);
-         piglit_report_result(PIGLIT_FAIL);
-      }
-
-      if (size != expectedSize) {
-         printf("%s: wrong size for 'v' (found %d, expected %d)\n",
-                TestName, size, expectedSize);
-         piglit_report_result(PIGLIT_FAIL);
-      }
-   }
-
-   /* Check setting/getting values */
-
-   loc_d1 = glGetUniformLocation(prog, "d1");
-   loc_d2 = glGetUniformLocation(prog, "d2");
-   loc_sa = glGetUniformLocation(prog, "s.a");
-   loc_sd = glGetUniformLocation(prog, "s.d");
-   loc_v1 = glGetUniformLocation(prog, "v[1]");
-   loc_f1 = glGetUniformLocation(prog, "f1");
-   loc_fv1 = glGetUniformLocation(prog, "fv1");
-   loc_ui1 = glGetUniformLocation(prog, "ui1");
-   loc_i1 = glGetUniformLocation(prog, "i1");
-   loc_b1 = glGetUniformLocation(prog, "b1");
-   glUniform1d(loc_d1, 5.0);
-   glUniform1d(loc_d2, 10.0);
-   glUniform1d(loc_sa, 15.0);
-   glUniform1d(loc_sd, 20.0);
-   glUniform4dv(loc_v1, 1, vVals);
-   glUniform1f(loc_f1, 40.0);
-   glUniform4f(loc_fv1, 40.0, 30.0, 20.0, 10.0);
-   glUniform1ui(loc_ui1, 100);
-   glUniform1i(loc_i1, -100);
-
-   glUniform1d(loc_b1, 1);
-   if (!piglit_check_gl_error(GL_INVALID_OPERATION))
-      piglit_report_result(PIGLIT_FAIL);
-
-   glUniform1i(loc_b1, 1);
-
-   /* double getters on doubles */
-   glGetUniformdv(prog, loc_d1, v);
-   if (v[0] != 5.0) {
-      printf("%s: wrong value for d1 (found %f, expected %f)\n",
-             TestName, v[0], 5.0);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-
-   glGetUniformdv(prog, loc_d2, v);
-   if (v[0] != 10.0) {
-      printf("%s: wrong value for d2 (found %f, expected %f)\n",
-             TestName, v[0], 10.0);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-
-   glGetUniformdv(prog, loc_sa, v);
-   if (v[0] != 15.0) {
-      printf("%s: wrong value for s.a (found %f, expected %f)\n",
-             TestName, v[0], 15.0);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-
-   glGetUniformdv(prog, loc_sd, v);
-   if (v[0] != 20.0) {
-      printf("%s: wrong value for s.d (found %f, expected %f)\n",
-             TestName, v[0], 20.0);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-
-   glGetUniformdv(prog, loc_v1, v);
-   if (v[0] != 30.0 ||
-       v[1] != 31.0 ||
-       v[2] != 32.0 ||
-       v[3] != 33.0) {
-      printf("%s: wrong value for v[1] (found %g,%g,%g,%g, expected %g,%g,%g,%g)\n",
-             TestName, v[0], v[1], v[2], v[3], 30.0, 31.0, 32.0, 33.0);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-
-   /* use non-double getters on doubles */
-   glGetUniformfv(prog, loc_d1, f);
-   if (f[0] != 5.0) {
-      printf("%s: wrong value for d1 (found %f, expected %f)\n",
-             TestName, v[0], 5.0);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-
-   glGetUniformuiv(prog, loc_d1, ui);
-   if (ui[0] != 5) {
-      printf("%s: wrong value for d1 (found %f, expected %f)\n",
-             TestName, v[0], 5.0);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-
-   glGetUniformiv(prog, loc_d1, i_val);
-   if (i_val[0] != 5) {
-      printf("%s: wrong value for d1 (found %f, expected %f)\n",
-             TestName, v[0], 5.0);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-
-   glGetUniformfv(prog, loc_v1, f);
-   if (f[0] != 30.0 ||
-       f[1] != 31.0 ||
-       f[2] != 32.0 ||
-       f[3] != 33.0) {
-      printf("%s: wrong value for v[1] (found %g,%g,%g,%g, expected %g,%g,%g,%g)\n",
-             TestName, f[0], f[1], f[2], f[3], 30.0, 31.0, 32.0, 33.0);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-   /* use double getters on non-doubles */
-   glGetUniformdv(prog, loc_f1, v);
-   if (v[0] != 40.0) {
-      printf("%s: wrong value for f1 (found %f, expected %f)\n",
-             TestName, v[0], 40.0);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-   glGetUniformdv(prog, loc_fv1, v);
-   if (v[0] != 40.0 || v[1] != 30.0 || v[2] != 20.0 || v[3] != 10.0) {
-      printf("%s: wrong value for fv1 (found %f,%f,%f,%f, expected %f,%f,%f,%f)\n",
-             TestName, v[0], v[1], v[2], v[3], 40.0, 30.0, 20.0, 10.0);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-
-   glGetUniformdv(prog, loc_ui1, v);
-   if (v[0] != 100.0) {
-      printf("%s: wrong value for ui1 (found %f, expected %f)\n",
-             TestName, v[0], 100.0);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-   glGetUniformdv(prog, loc_i1, v);
-   if (v[0] != -100.0) {
-      printf("%s: wrong value for i1 (found %f, expected %f)\n",
-             TestName, v[0], -100.0);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-   glGetUniformdv(prog, loc_b1, v);
-   if (v[0] != 1.0) {
-      printf("%s: wrong value for b1 (found %f, expected %f)\n",
-             TestName, v[0], 1.0);
-      piglit_report_result(PIGLIT_FAIL);
-   }
-
-   piglit_report_result(PIGLIT_PASS);
-}
diff --git a/tests/spec/arb_gpu_shader_fp64/execution/gs-getuniformdv.c b/tests/spec/arb_gpu_shader_fp64/execution/gs-getuniformdv.c
new file mode 100644
index 0000000..485c035
--- /dev/null
+++ b/tests/spec/arb_gpu_shader_fp64/execution/gs-getuniformdv.c
@@ -0,0 +1,355 @@
+/*
+ * Copyright 2011 VMware, 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.
+ */
+
+/**
+ * Asst. gl[Get]Uniformdv tests.
+ * based on getunifom02.c from Brian Paul.
+ *
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_core_version = 32;
+
+	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static char *TestName = "getuniformdv";
+
+static const char vs_text[] =
+   "#version 150\n"
+   "in vec4 piglit_vertex; \n"
+   "out vec4 vertex_to_gs; \n"
+   "\n"
+   "void main()\n"
+   "{\n"
+   "  vertex_to_gs = piglit_vertex; \n"
+   "}\n";
+
+static const char gs_text[] =
+   "#version 150\n"
+   "#extension GL_ARB_gpu_shader_fp64 : require\n"
+   "struct s1 { \n"
+   "   double a, b, c, d; \n"
+   "}; \n"
+   "uniform double d1; \n"
+   "uniform dvec2 u1[2]; \n"
+   "uniform dvec3 u2[4]; \n"
+   "uniform dvec4 v[3]; \n"
+   "uniform dmat2 m1; \n"
+   "uniform dmat3 m2; \n"
+   "uniform dmat4 m3[3]; \n"
+   "uniform dmat2x3 m4; \n"
+   "uniform dmat2x4 m5; \n"
+   "uniform dmat3x2 m6; \n"
+   "uniform dmat3x4 m7; \n"
+   "uniform dmat4x2 m8[2]; \n"
+   "uniform dmat4x3 m9; \n"
+   "uniform s1 s;\n"
+   "uniform double d2; \n"
+   "layout(triangles) in;\n"
+   "layout(triangle_strip, max_vertices = 3) out;\n"
+   "in vec4 vertex_to_gs[3];\n"
+   "void main()\n"
+   "{\n"
+   "  dvec4 t = dvec4(s.a, s.b, s.c, s.d) * d1 + d2 + u1[0]*m8[0] + u1[1]*m8[1];\n"
+   "  t += v[0]*m3[0] + v[1]*m3[1] + v[2]*m3[2]  + u2[0]*m9; \n"
+   "  t.rb += u1[0]*m1 + u1[1] + u2[0]*m4 + v[0]*m5; \n"
+   "  t.xyw += u2[0]*m2 + u2[1] + u2[2] + u2[3] + u1[1]*m6 + v[0]*m7; \n"
+   "  for (int i = 0; i < 3; i++) {\n"
+   "    gl_Position = vertex_to_gs[i] + vec4(t);\n"
+   "    EmitVertex();\n"
+   "  }\n"
+   "}\n";
+
+static const char fs_text[] =
+   "#version 150\n"
+   "out vec4 fscolor;\n"
+   "void main()\n"
+   "{\n"
+   "  fscolor = vec4(1, 0, 1, 0); \n"
+   "}\n";
+
+#define MAX_VALUES 16
+
+#define EXPECTED_ACTIVE_UNIFORMS 18
+
+static struct {
+   char *name;
+   char *altName;
+   GLint expectedType;
+   GLenum expectedSize;
+} uniforms[] = {
+   { "v",  "v[0]", GL_DOUBLE_VEC4,   3},
+   {"u1", "u1[0]", GL_DOUBLE_VEC2,   2},
+   {"u2", "u2[0]", GL_DOUBLE_VEC3,   4},
+   {"m1",    NULL, GL_DOUBLE_MAT2,   1},
+   {"m2",    NULL, GL_DOUBLE_MAT3,   1},
+   {"m3", "m3[0]", GL_DOUBLE_MAT4,   3},
+   {"m4",    NULL, GL_DOUBLE_MAT2x3, 1},
+   {"m5",    NULL, GL_DOUBLE_MAT2x4, 1},
+   {"m6",    NULL, GL_DOUBLE_MAT3x2, 1},
+   {"m7",    NULL, GL_DOUBLE_MAT3x4, 1},
+   {"m8", "m8[0]", GL_DOUBLE_MAT4x2, 2},
+   {"m9",    NULL, GL_DOUBLE_MAT4x3, 1},
+   {NULL,    NULL, GL_DOUBLE,        1}};  //default
+
+enum uniform_enum {
+   d1 = 0, d2, sa, sd,
+   u1_0, u1_1, u2_0, u2_2,
+   v_0, v_1,
+   m1, m2, m3, m4, m5, m6, m7, m8_0, m9, _last
+};
+
+static struct {
+   char *location;
+   GLint size;
+   GLdouble values[MAX_VALUES];
+} uniform_values[] = {
+   {    "d1",  1, { 5.0 }},
+   {    "d2",  1, {10.0}},
+   {   "s.a",  1, {15.0}},
+   {   "s.d",  1, {20.0}},
+   { "u1[0]",  2, {12.0, 14.0}},
+   { "u1[1]",  2, {5.0, 8.0}},
+   { "u2[0]",  3, {1.0, 1.0, 2.0}},
+   { "u2[2]",  3, {20.0, 20.0, 15.0}},
+   {  "v[0]",  4, {2.0, 3.0, 4.0, 5.0}},
+   {  "v[1]",  4, {1.0, 2.0, 3.0, 4.0}},
+   {    "m1",  4, {1.0, 2.0,
+                   3.0, 4.0}},
+   {    "m2",  9, {1.0, 1.0, 1.0,
+                   2.0, 2.0, 2.0,
+                   3.0, 3.0, 3.0}},
+   { "m3[1]", 16, {1.0, 2.0, 3.0, 4.0,
+                   5.0, 6.0, 7.0, 8.0,
+                   1.5, 2.5, 3.5, 4.5,
+                   5.5, 6.5, 7.5, 8.5}},
+   {    "m4",  6, {15.0, 16.0,
+                   17.0, 18.0,
+                   19.0, 20.0}},
+   {    "m5",  8, {10.0, 11.0,
+                   12.0, 13.0,
+                   14.0, 15.0,
+                   15.0, 17.0}},
+   {    "m6",  6, {51.0, 52.0, 53.0,
+                   54.0, 55.0, 56.0 }},
+   {    "m7", 12, {28.0, 29.0, 30.0,
+                   31.0, 32.0, 33.0,
+                   34.0, 35.0, 36.0,
+                   37.0, 38.0, 39.0}},
+   { "m8[0]",  8, {2.7, 3.7, 4.7, 5.7,
+                   6.7, 8.7, 9.7, 1.7}},
+   {   "m9",  12, {11.1, 12.1, 13.1, 14.1,
+                   15.1, 16.1, 17.1, 18.1,
+                   19.1, 20.1, 21.1, 22.1}}};
+
+enum piglit_result
+piglit_display(void)
+{
+   /* never called */
+   return PIGLIT_FAIL;
+}
+
+static bool
+verify_uniform(GLuint prog, enum uniform_enum u)
+{
+   GLint loc;
+   GLdouble val[MAX_VALUES];
+   bool match = true;
+   int i;
+
+   loc = glGetUniformLocation(prog, uniform_values[u].location);
+   glGetUniformdv(prog, loc, val);
+   for (i = 0; i < uniform_values[u].size; i++) {
+      match = match && (val[i] == uniform_values[u].values[i]);
+   }
+
+   if (!match) {
+      printf("%s: wrong value for %s (found ",
+             TestName, uniform_values[u].location);
+      for (i = 0; i < uniform_values[u].size; i++) {
+         printf("%g,", val[i]);
+      }
+      printf(" expected ");
+      for (i = 0; i < (uniform_values[u].size - 1); i++) {
+         printf("%g,", uniform_values[u].values[i]);
+      }
+      printf ("%g)\n", uniform_values[u].values[uniform_values[u].size - 1]);
+   }
+
+   return match;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+   bool piglit_pass = true;
+   GLuint vs, fs, prog;
+   GLint numUniforms, i;
+   GLint loc;
+   enum uniform_enum u;
+
+   piglit_require_extension("GL_ARB_gpu_shader_fp64");
+
+   prog = piglit_build_simple_program_multiple_shaders(GL_VERTEX_SHADER, vs_text,
+                                                       GL_GEOMETRY_SHADER, gs_text,
+                                                       GL_FRAGMENT_SHADER, fs_text,
+                                                       NULL);
+
+   glUseProgram(prog);
+
+   glGetProgramiv(prog, GL_ACTIVE_UNIFORMS, &numUniforms);
+   if (numUniforms != EXPECTED_ACTIVE_UNIFORMS) {
+      printf("%s: incorrect number of uniforms (found %d, expected %d)\n",
+             TestName, numUniforms, EXPECTED_ACTIVE_UNIFORMS);
+      piglit_pass = false;
+   }
+
+   /* check types, sizes */
+   for (i = 0; i < numUniforms; i++) {
+      GLcharARB name[100];
+      GLsizei len;
+      GLint size, j;
+      GLenum type;
+      GLint loc;
+
+      glGetActiveUniform(prog, i, sizeof(name), &len, &size, &type, name);
+      loc = glGetUniformLocation(prog, name);
+
+      if (loc < 0) {
+         printf("%s: bad uniform location for %s: %d\n", TestName, name, loc);
+         piglit_pass = false;
+      }
+
+      if (!piglit_automatic) {
+         printf("%d: %s loc=%d size=%d type=0x%x\n", i, name, loc, size, type);
+      }
+
+      /* OpenGL ES 3.0 and OpenGL 4.2 require that the "[0]" be appended to
+       * the name.  Earlier versions of the spec are ambiguous.  Accept either
+       * name.
+       */
+      j = 0;
+      while (uniforms[j].name != NULL) {
+         if (strcmp(name, uniforms[j].name) == 0) {
+            break;
+         }
+         if (uniforms[j].altName && strcmp(name, uniforms[j].altName) == 0) {
+            break;
+         }
+         j++;
+      }
+
+      if (type != uniforms[j].expectedType) {
+         printf("%s: wrong type for '%s' (found 0x%x, expected 0x%x)\n",
+                TestName,
+                uniforms[j].name ? uniforms[j].name : name,
+                type, uniforms[j].expectedType);
+         piglit_pass = false;
+      }
+
+      if (size != uniforms[j].expectedSize) {
+         printf("%s: wrong size for '%s' (found %d, expected %d)\n",
+                TestName,
+                uniforms[j].name ? uniforms[j].name : name,
+                size, uniforms[j].expectedSize);
+         piglit_pass = false;
+      }
+   }
+
+   /* Check setting/getting values */
+
+   loc = glGetUniformLocation(prog, uniform_values[d1].location);
+   glUniform1d(loc, uniform_values[d1].values[0]);
+
+   loc = glGetUniformLocation(prog, uniform_values[d2].location);
+   glUniform1d(loc, uniform_values[d2].values[0]);
+
+   loc = glGetUniformLocation(prog, uniform_values[sa].location);
+   glUniform1dv(loc, 1, uniform_values[sa].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[sd].location);
+   glUniform1d(loc, uniform_values[sd].values[0]);
+
+   loc = glGetUniformLocation(prog, uniform_values[u1_0].location);
+   glUniform2dv(loc, 1, uniform_values[u1_0].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[u2_0].location);
+   glUniform3dv(loc, 1, uniform_values[u2_0].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[v_1].location);
+   glUniform4dv(loc, 1, uniform_values[v_1].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m1].location);
+   glUniformMatrix2dv(loc, 1, false, uniform_values[m1].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m2].location);
+   glUniformMatrix3dv(loc, 1, false, uniform_values[m2].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m3].location);
+   glUniformMatrix4dv(loc, 1, false, uniform_values[m3].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m4].location);
+   glUniformMatrix2x3dv(loc, 1, false, uniform_values[m4].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m5].location);
+   glUniformMatrix2x4dv(loc, 1, false, uniform_values[m5].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m6].location);
+   glUniformMatrix3x2dv(loc, 1, false, uniform_values[m6].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m7].location);
+   glUniformMatrix3x4dv(loc, 1, false, uniform_values[m7].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m8_0].location);
+   glUniformMatrix4x2dv(loc, 1, false, uniform_values[m8_0].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m9].location);
+   glUniformMatrix4x3dv(loc, 1, false, uniform_values[m9].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[u1_1].location);
+   glUniform2d(loc, uniform_values[u1_1].values[0], uniform_values[u1_1].values[1]);
+
+   loc = glGetUniformLocation(prog, uniform_values[u2_2].location);
+   glUniform3d(loc,
+               uniform_values[u2_2].values[0],
+               uniform_values[u2_2].values[1],
+               uniform_values[u2_2].values[2]);
+
+   loc = glGetUniformLocation(prog, uniform_values[v_0].location);
+   glUniform4d(loc,
+               uniform_values[v_0].values[0],
+               uniform_values[v_0].values[1],
+               uniform_values[v_0].values[2],
+               uniform_values[v_0].values[3]);
+
+   for (u = 0; u < _last; u++) {
+      piglit_pass = piglit_pass && verify_uniform(prog, u);
+   }
+
+   piglit_report_result(piglit_pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
diff --git a/tests/spec/arb_gpu_shader_fp64/execution/vs-getuniformdv.c b/tests/spec/arb_gpu_shader_fp64/execution/vs-getuniformdv.c
new file mode 100644
index 0000000..d1f86b1
--- /dev/null
+++ b/tests/spec/arb_gpu_shader_fp64/execution/vs-getuniformdv.c
@@ -0,0 +1,339 @@
+/*
+ * Copyright 2011 VMware, 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.
+ */
+
+/**
+ * Asst. gl[Get]Uniformdv tests.
+ * based on getunifom02.c from Brian Paul.
+ *
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_core_version = 32;
+
+	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static char *TestName = "getuniformdv";
+
+static const char vs_text[] =
+   "#version 150\n"
+   "#extension GL_ARB_gpu_shader_fp64 : require\n"
+   "struct s1 { \n"
+   "   double a, b, c, d; \n"
+   "}; \n"
+   "uniform double d1; \n"
+   "uniform dvec2 u1[2]; \n"
+   "uniform dvec3 u2[4]; \n"
+   "uniform dvec4 v[3]; \n"
+   "uniform dmat2 m1; \n"
+   "uniform dmat3 m2; \n"
+   "uniform dmat4 m3[3]; \n"
+   "uniform dmat2x3 m4; \n"
+   "uniform dmat2x4 m5; \n"
+   "uniform dmat3x2 m6; \n"
+   "uniform dmat3x4 m7; \n"
+   "uniform dmat4x2 m8[2]; \n"
+   "uniform dmat4x3 m9; \n"
+   "uniform s1 s;\n"
+   "uniform double d2; \n"
+   "out vec4 vscolor; \n"
+   "\n"
+   "void main()\n"
+   "{\n"
+   "  gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n"
+   "  dvec4 t = dvec4(s.a, s.b, s.c, s.d) * d1 + d2 + u1[0]*m8[0] + u1[1]*m8[1];\n"
+   "  t += v[0]*m3[0] + v[1]*m3[1] + v[2]*m3[2]  + u2[0]*m9; \n"
+   "  t.rb += u1[0]*m1 + u1[1] + u2[0]*m4 + v[0]*m5; \n"
+   "  t.xyw += u2[0]*m2 + u2[1] + u2[2] + u2[3] + u1[1]*m6 + v[0]*m7; \n"
+   "  vscolor = vec4(t); \n"
+   "}\n";
+
+static const char fs_text[] =
+   "#version 150\n"
+   "in vec4 vscolor;\n"
+   "out vec4 fscolor;\n"
+   "void main() { fscolor = vscolor; }";
+
+#define MAX_VALUES 16
+
+#define EXPECTED_ACTIVE_UNIFORMS 18
+
+static struct {
+   char *name;
+   char *altName;
+   GLint expectedType;
+   GLenum expectedSize;
+} uniforms[] = {
+   { "v",  "v[0]", GL_DOUBLE_VEC4,   3},
+   {"u1", "u1[0]", GL_DOUBLE_VEC2,   2},
+   {"u2", "u2[0]", GL_DOUBLE_VEC3,   4},
+   {"m1",    NULL, GL_DOUBLE_MAT2,   1},
+   {"m2",    NULL, GL_DOUBLE_MAT3,   1},
+   {"m3", "m3[0]", GL_DOUBLE_MAT4,   3},
+   {"m4",    NULL, GL_DOUBLE_MAT2x3, 1},
+   {"m5",    NULL, GL_DOUBLE_MAT2x4, 1},
+   {"m6",    NULL, GL_DOUBLE_MAT3x2, 1},
+   {"m7",    NULL, GL_DOUBLE_MAT3x4, 1},
+   {"m8", "m8[0]", GL_DOUBLE_MAT4x2, 2},
+   {"m9",    NULL, GL_DOUBLE_MAT4x3, 1},
+   {NULL,    NULL, GL_DOUBLE,        1}};  //default
+
+enum uniform_enum {
+   d1 = 0, d2, sa, sd,
+   u1_0, u1_1, u2_0, u2_2,
+   v_0, v_1,
+   m1, m2, m3, m4, m5, m6, m7, m8_0, m9, _last
+};
+
+static struct {
+   char *location;
+   GLint size;
+   GLdouble values[MAX_VALUES];
+} uniform_values[] = {
+   {    "d1",  1, { 5.0 }},
+   {    "d2",  1, {10.0}},
+   {   "s.a",  1, {15.0}},
+   {   "s.d",  1, {20.0}},
+   { "u1[0]",  2, {12.0, 14.0}},
+   { "u1[1]",  2, {5.0, 8.0}},
+   { "u2[0]",  3, {1.0, 1.0, 2.0}},
+   { "u2[2]",  3, {20.0, 20.0, 15.0}},
+   {  "v[0]",  4, {2.0, 3.0, 4.0, 5.0}},
+   {  "v[1]",  4, {1.0, 2.0, 3.0, 4.0}},
+   {    "m1",  4, {1.0, 2.0,
+                   3.0, 4.0}},
+   {    "m2",  9, {1.0, 1.0, 1.0,
+                   2.0, 2.0, 2.0,
+                   3.0, 3.0, 3.0}},
+   { "m3[1]", 16, {1.0, 2.0, 3.0, 4.0,
+                   5.0, 6.0, 7.0, 8.0,
+                   1.5, 2.5, 3.5, 4.5,
+                   5.5, 6.5, 7.5, 8.5}},
+   {    "m4",  6, {15.0, 16.0,
+                   17.0, 18.0,
+                   19.0, 20.0}},
+   {    "m5",  8, {10.0, 11.0,
+                   12.0, 13.0,
+                   14.0, 15.0,
+                   15.0, 17.0}},
+   {    "m6",  6, {51.0, 52.0, 53.0,
+                   54.0, 55.0, 56.0 }},
+   {    "m7", 12, {28.0, 29.0, 30.0,
+                   31.0, 32.0, 33.0,
+                   34.0, 35.0, 36.0,
+                   37.0, 38.0, 39.0}},
+   { "m8[0]",  8, {2.7, 3.7, 4.7, 5.7,
+                   6.7, 8.7, 9.7, 1.7}},
+   {   "m9",  12, {11.1, 12.1, 13.1, 14.1,
+                   15.1, 16.1, 17.1, 18.1,
+                   19.1, 20.1, 21.1, 22.1}}};
+
+enum piglit_result
+piglit_display(void)
+{
+   /* never called */
+   return PIGLIT_FAIL;
+}
+
+static bool
+verify_uniform(GLuint prog, enum uniform_enum u)
+{
+   GLint loc;
+   GLdouble val[MAX_VALUES];
+   bool match = true;
+   int i;
+
+   loc = glGetUniformLocation(prog, uniform_values[u].location);
+   glGetUniformdv(prog, loc, val);
+   for (i = 0; i < uniform_values[u].size; i++) {
+      match = match && (val[i] == uniform_values[u].values[i]);
+   }
+
+   if (!match) {
+      printf("%s: wrong value for %s (found ",
+             TestName, uniform_values[u].location);
+      for (i = 0; i < uniform_values[u].size; i++) {
+         printf("%g,", val[i]);
+      }
+      printf(" expected ");
+      for (i = 0; i < (uniform_values[u].size - 1); i++) {
+         printf("%g,", uniform_values[u].values[i]);
+      }
+      printf ("%g)\n", uniform_values[u].values[uniform_values[u].size - 1]);
+   }
+
+   return match;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+   bool piglit_pass = true;
+   GLuint vs, fs, prog;
+   GLint numUniforms, i;
+   GLint loc;
+   enum uniform_enum u;
+
+   piglit_require_extension("GL_ARB_gpu_shader_fp64");
+
+   vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
+   fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_text);
+   prog = piglit_link_simple_program(vs, fs);
+
+   glUseProgram(prog);
+
+   glGetProgramiv(prog, GL_ACTIVE_UNIFORMS, &numUniforms);
+   if (numUniforms != EXPECTED_ACTIVE_UNIFORMS) {
+      printf("%s: incorrect number of uniforms (found %d, expected %d)\n",
+             TestName, numUniforms, EXPECTED_ACTIVE_UNIFORMS);
+      piglit_pass = false;
+   }
+
+   /* check types, sizes */
+   for (i = 0; i < numUniforms; i++) {
+      GLcharARB name[100];
+      GLsizei len;
+      GLint size, j;
+      GLenum type;
+      GLint loc;
+
+      glGetActiveUniform(prog, i, sizeof(name), &len, &size, &type, name);
+      loc = glGetUniformLocation(prog, name);
+
+      if (loc < 0) {
+         printf("%s: bad uniform location for %s: %d\n", TestName, name, loc);
+         piglit_pass = false;
+      }
+
+      if (!piglit_automatic) {
+         printf("%d: %s loc=%d size=%d type=0x%x\n", i, name, loc, size, type);
+      }
+
+      /* OpenGL ES 3.0 and OpenGL 4.2 require that the "[0]" be appended to
+       * the name.  Earlier versions of the spec are ambiguous.  Accept either
+       * name.
+       */
+      j = 0;
+      while (uniforms[j].name != NULL) {
+         if (strcmp(name, uniforms[j].name) == 0) {
+            break;
+         }
+         if (uniforms[j].altName && strcmp(name, uniforms[j].altName) == 0) {
+            break;
+         }
+         j++;
+      }
+
+      if (type != uniforms[j].expectedType) {
+         printf("%s: wrong type for '%s' (found 0x%x, expected 0x%x)\n",
+                TestName,
+                uniforms[j].name ? uniforms[j].name : name,
+                type, uniforms[j].expectedType);
+         piglit_pass = false;
+      }
+
+      if (size != uniforms[j].expectedSize) {
+         printf("%s: wrong size for '%s' (found %d, expected %d)\n",
+                TestName,
+                uniforms[j].name ? uniforms[j].name : name,
+                size, uniforms[j].expectedSize);
+         piglit_pass = false;
+      }
+   }
+
+   /* Check setting/getting values */
+
+   loc = glGetUniformLocation(prog, uniform_values[d1].location);
+   glUniform1d(loc, uniform_values[d1].values[0]);
+
+   loc = glGetUniformLocation(prog, uniform_values[d2].location);
+   glUniform1d(loc, uniform_values[d2].values[0]);
+
+   loc = glGetUniformLocation(prog, uniform_values[sa].location);
+   glUniform1dv(loc, 1, uniform_values[sa].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[sd].location);
+   glUniform1d(loc, uniform_values[sd].values[0]);
+
+   loc = glGetUniformLocation(prog, uniform_values[u1_0].location);
+   glUniform2dv(loc, 1, uniform_values[u1_0].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[u2_0].location);
+   glUniform3dv(loc, 1, uniform_values[u2_0].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[v_1].location);
+   glUniform4dv(loc, 1, uniform_values[v_1].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m1].location);
+   glUniformMatrix2dv(loc, 1, false, uniform_values[m1].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m2].location);
+   glUniformMatrix3dv(loc, 1, false, uniform_values[m2].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m3].location);
+   glUniformMatrix4dv(loc, 1, false, uniform_values[m3].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m4].location);
+   glUniformMatrix2x3dv(loc, 1, false, uniform_values[m4].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m5].location);
+   glUniformMatrix2x4dv(loc, 1, false, uniform_values[m5].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m6].location);
+   glUniformMatrix3x2dv(loc, 1, false, uniform_values[m6].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m7].location);
+   glUniformMatrix3x4dv(loc, 1, false, uniform_values[m7].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m8_0].location);
+   glUniformMatrix4x2dv(loc, 1, false, uniform_values[m8_0].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[m9].location);
+   glUniformMatrix4x3dv(loc, 1, false, uniform_values[m9].values);
+
+   loc = glGetUniformLocation(prog, uniform_values[u1_1].location);
+   glUniform2d(loc, uniform_values[u1_1].values[0], uniform_values[u1_1].values[1]);
+
+   loc = glGetUniformLocation(prog, uniform_values[u2_2].location);
+   glUniform3d(loc,
+               uniform_values[u2_2].values[0],
+               uniform_values[u2_2].values[1],
+               uniform_values[u2_2].values[2]);
+
+   loc = glGetUniformLocation(prog, uniform_values[v_0].location);
+   glUniform4d(loc,
+               uniform_values[v_0].values[0],
+               uniform_values[v_0].values[1],
+               uniform_values[v_0].values[2],
+               uniform_values[v_0].values[3]);
+
+   for (u = 0; u < _last; u++) {
+      piglit_pass = piglit_pass && verify_uniform(prog, u);
+   }
+
+   piglit_report_result(piglit_pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
2.1.0



More information about the Piglit mailing list