Re: [Piglit] [PATCH] GL 1.50: Test that UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER is accepted by GetActiveUniformBlockiv()

2013-10-07 Thread Eric Anholt
Nicholas Mack nichm...@gmail.com writes:

 v2: Incorporate this test into referenced-by-shader.c

 @@ -40,10 +41,6 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
  
   config.supports_gl_compat_version = 10;
  
 - config.window_width = 10;
 - config.window_height = 10;
 - config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
 -

It looks like this won't ever get run on a 3.2 context on Mesa because
you need at least config.supports_gl_core_version = 31.

 + bool use_gs = piglit_get_gl_version() = 32;
 + const char *header;
 + char *temp_source;
 + int num_uniforms_used = 0;
 +
 + if(use_gs) {

There should always be a space between 'if' and '('

 - for (i = 0; i  3; i++) {
 - GLint ref_vs, ref_fs;
 + if(use_gs) {
 + num_uniforms_used = 7;
 + printf(v g f\n);
 + }
 + else {

Usually we cuddle the braces like } else {

With the one functional fix and the little style nits fixed, this would
be:

Reviewed-by: Eric Anholt e...@anholt.net


pgpHDw5ucWS4z.pgp
Description: PGP signature
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] GL 1.50: Test that UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER is accepted by GetActiveUniformBlockiv()

2013-08-28 Thread Nicholas Mack
---
 tests/spec/glsl-1.50/CMakeLists.gl.txt |  13 +++
 tests/spec/glsl-1.50/CMakeLists.txt|   1 +
 .../query-uniform-block-referenced-by-gs.c | 124 +
 3 files changed, 138 insertions(+)
 create mode 100644 tests/spec/glsl-1.50/CMakeLists.gl.txt
 create mode 100644 tests/spec/glsl-1.50/query-uniform-block-referenced-by-gs.c

diff --git a/tests/spec/glsl-1.50/CMakeLists.gl.txt 
b/tests/spec/glsl-1.50/CMakeLists.gl.txt
new file mode 100644
index 000..aad78f6
--- /dev/null
+++ b/tests/spec/glsl-1.50/CMakeLists.gl.txt
@@ -0,0 +1,13 @@
+include_directories(
+   ${GLEXT_INCLUDE_DIR}
+   ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+   piglitutil_${piglit_target_api}
+   ${OPENGL_gl_LIBRARY}
+   ${OPENGL_glu_LIBRARY}
+)
+
+piglit_add_executable (query-uniform-block-referenced-by-gs
+   query-uniform-block-referenced-by-gs.c)
diff --git a/tests/spec/glsl-1.50/CMakeLists.txt 
b/tests/spec/glsl-1.50/CMakeLists.txt
index bb76f08..e4126fc 100644
--- a/tests/spec/glsl-1.50/CMakeLists.txt
+++ b/tests/spec/glsl-1.50/CMakeLists.txt
@@ -1 +1,2 @@
 add_subdirectory (execution)
+piglit_include_target_api()
diff --git a/tests/spec/glsl-1.50/query-uniform-block-referenced-by-gs.c 
b/tests/spec/glsl-1.50/query-uniform-block-referenced-by-gs.c
new file mode 100644
index 000..76bbd15
--- /dev/null
+++ b/tests/spec/glsl-1.50/query-uniform-block-referenced-by-gs.c
@@ -0,0 +1,124 @@
+/**
+ * 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
+ * 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.
+ */
+
+/**
+ * Test that UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER is accepted by
+ * GetActiveUniformBlockiv()
+ *
+ * Section 2.11.4(Uniform Variables) of OpenGL 3.2 Core says:
+ * Information about an active uniform block can be queried by calling
+ * void GetActiveUniformBlockiv( uint program,
+ *   uint uniformBlockIndex,
+ *   enum pname, int *params );
+ *  If pname is UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER,
+ *  UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER, or
+ *  UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, then a boolean value 
indicating
+ *  whether the uniform block identified by uniformBlockIndex is referenced by
+ *  the vertex, geometry, or fragment programming stages of program,
+ *  respectively, is returned.
+ *
+ */
+
+#include piglit-util-gl-common.h
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 32;
+config.supports_gl_core_version = 32;
+
+   config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char *vstext =
+   #version 150\n
+   in vec3 vert1;\n
+   out vec3 vert;\n
+   void main() {\n
+  gl_Position = vec4(vert1, 1.);\n
+  vert = vert1;\n
+   }\n;
+
+static const char *gstext =
+   #version 150\n
+   layout(triangles) in;\n
+   layout(triangles, max_vertices=3) out;\n
+   in vec3 vert[];\n
+   uniform block {\n
+  vec4 a;\n
+  float b;\n
+  vec2 c;\n
+   } uBlock;\n
+   void main() {\n
+  uBlock.a = vec4(2.);\n
+  uBlock.b = 3.3;\n
+  uBlock.c = vec2(1., .5);\n
+  for(int i = 0; i  3; i++) {\n
+  gl_Position = vec4(vert[i], 1.);\n
+  EmitVertex();\n
+  }\n
+   }\n;
+
+static const char *fstext =
+   #version 150\n
+   void main() {\n
+  gl_FragColor = vec4(1.);\n
+   }\n;
+
+static GLuint prog;
+
+void
+piglit_init(int argc, char **argv)
+{
+   bool pass = true;
+   GLuint vs = 0, gs = 0, fs = 0;
+   GLint param = 0;
+
+   prog = glCreateProgram();
+   vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);
+   gs =