On 4 November 2011 16:34, Ian Romanick <span dir="ltr">&lt;<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
From: Ian Romanick &lt;<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>&gt;<br>
<br>
This test passes on AMD&#39;s closed-source driver.  It fails on NVIDIA&#39;s<br>
closed-source driver because after the second glLinkProgram call,<br>
glGetFragDataLocation always returns -1.<br>
<br>
Signed-off-by: Ian Romanick &lt;<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>&gt;<br>
---<br>
 tests/all.tests                             |    1 +<br>
 tests/spec/gl-3.0/api/CMakeLists.gl.txt     |    1 +<br>
 tests/spec/gl-3.0/api/getfragdatalocation.c |  172 +++++++++++++++++++++++++++<br>
 3 files changed, 174 insertions(+), 0 deletions(-)<br>
 create mode 100644 tests/spec/gl-3.0/api/getfragdatalocation.c<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index 9641281..0f712bd 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -795,6 +795,7 @@ add_concurrent_test(gl30, &#39;clearbuffer-invalid-drawbuffer&#39;)<br>
 add_concurrent_test(gl30, &#39;clearbuffer-invalid-buffer&#39;)<br>
 add_concurrent_test(gl30, &#39;clearbuffer-depth&#39;)<br>
 add_concurrent_test(gl30, &#39;clearbuffer-stencil&#39;)<br>
+add_concurrent_test(gl30, &#39;getfragdatalocation&#39;)<br>
<br>
 # Group spec/glsl-1.00<br>
 spec[&#39;glsl-1.00&#39;] = Group()<br>
diff --git a/tests/spec/gl-3.0/api/CMakeLists.gl.txt b/tests/spec/gl-3.0/api/CMakeLists.gl.txt<br>
index 51fbce4..f1b7a45 100644<br>
--- a/tests/spec/gl-3.0/api/CMakeLists.gl.txt<br>
+++ b/tests/spec/gl-3.0/api/CMakeLists.gl.txt<br>
@@ -19,5 +19,6 @@ add_executable (clearbuffer-depth-stencil clearbuffer-common.c clearbuffer-depth<br>
 add_executable (clearbuffer-invalid-drawbuffer clearbuffer-invalid-drawbuffer.c)<br>
 add_executable (clearbuffer-invalid-buffer clearbuffer-invalid-buffer.c)<br>
 add_executable (clearbuffer-stencil clearbuffer-common.c clearbuffer-stencil.c)<br>
+add_executable (getfragdatalocation getfragdatalocation.c)<br>
<br>
 # vim: ft=cmake:<br>
diff --git a/tests/spec/gl-3.0/api/getfragdatalocation.c b/tests/spec/gl-3.0/api/getfragdatalocation.c<br>
new file mode 100644<br>
index 0000000..b091238<br>
--- /dev/null<br>
+++ b/tests/spec/gl-3.0/api/getfragdatalocation.c<br>
@@ -0,0 +1,172 @@<br>
+/* Copyright © 2011 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the &quot;Software&quot;),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+/**<br>
+ * \file getfragdatalocation.c<br>
+ *<br>
+ * \author Ian Romanick<br>
+ */<br>
+#include &quot;piglit-util.h&quot;<br>
+<br>
+int piglit_width = 100, piglit_height = 100;<br>
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;<br>
+<br>
+static const char *vs_text =<br>
+       &quot;#version 130\n&quot;<br>
+       &quot;in vec4 vertex;\n&quot;<br>
+       &quot;void main() { gl_Position = vertex; }\n&quot;<br>
+       ;<br>
+<br>
+static const char *fs_text =<br>
+       &quot;#version 130\n&quot;<br>
+       &quot;out vec4 v;\n&quot;<br>
+       &quot;out vec4 a[2];\n&quot;<br>
+       &quot;void main() {\n&quot;<br>
+       &quot;    v = vec4(0.0);\n&quot;<br>
+       &quot;    a[0] = vec4(1.0);\n&quot;<br>
+       &quot;    a[1] = vec4(2.0);\n&quot;<br>
+       &quot;}\n&quot;<br>
+       ;<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       return PIGLIT_FAIL;<br>
+}<br>
+<br>
+void piglit_init(int argc, char **argv)<br>
+{<br>
+       GLint max_draw_buffers;<br>
+       GLuint prog;<br>
+       GLuint vs;<br>
+       GLuint fs;<br>
+       GLint loc;<br>
+<br>
+       piglit_require_gl_version(30);<br>
+<br>
+       /* This test needs some number of draw buffers, so make sure the<br>
+        * implementation isn&#39;t broken.  This enables the test to generate a<br>
+        * useful failure message.<br>
+        */<br>
+       glGetIntegerv(GL_MAX_DRAW_BUFFERS, &amp;max_draw_buffers);<br>
+       if (max_draw_buffers &lt; 8) {<br>
+               fprintf(stderr,<br>
+                       &quot;OpenGL 3.0 requires GL_MAX_DRAW_BUFFERS &gt;= 8.  &quot;<br>
+                       &quot;Only got %d!\n&quot;,<br>
+                       max_draw_buffers);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
+       prog = glCreateProgram();<br>
+       vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);<br>
+       fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_text);<br>
+       glAttachShader(prog, vs);<br>
+       glAttachShader(prog, fs);<br>
+       piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);<br>
+<br>
+       /* Page 237 (page 253 of the PDF) of the OpenGL 3.0 spec says:<br>
+        *<br>
+        *     &quot;If program has not been successfully linked, the error INVALID<br>
+        *     OPERATION is generated. If name is not a varying out variable,<br>
+        *     or if an error occurs, -1 will be returned.&quot;<br>
+        */<br>
+       printf(&quot;Querying location before linking...\n&quot;);<br>
+       loc = glGetFragDataLocation(prog, &quot;v&quot;);<br>
+       piglit_check_gl_error(GL_INVALID_OPERATION, PIGLIT_FAIL);<br>
+<br>
+       if (loc != -1) {<br>
+               fprintf(stderr, &quot;Expected location = -1, got %d\n&quot;, loc);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
+       glLinkProgram(prog);<br>
+       piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);<br>
+<br>
+       if (!piglit_link_check_status(prog)) {<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
+       printf(&quot;Querying location of nonexistent variable...\n&quot;);<br>
+       loc = glGetFragDataLocation(prog, &quot;waldo&quot;);<br>
+       piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);<br>
+<br>
+       if (loc != -1) {<br>
+               fprintf(stderr, &quot;Expected location = -1, got %d\n&quot;, loc);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
+       /* Page 236 (page 252 of the PDF) of the OpenGL 3.0 spec says:<br>
+        *<br>
+        *     &quot;BindFragDataLocation has no effect until the program is<br>
+        *     linked. In particular, it doesn’t modify the bindings of<br>
+        *     varying out variables in a program that has already been<br>
+        *     linked.&quot;<br>
+        */<br>
+       glBindFragDataLocation(prog, 0, &quot;v&quot;);<br>
+       glBindFragDataLocation(prog, 1, &quot;a&quot;);<br>
+       glLinkProgram(prog);<br>
+       piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);<br>
+<br>
+       if (!piglit_link_check_status(prog)) {<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
+       printf(&quot;Querying locations after binding and linking...\n&quot;);<br>
+       loc = glGetFragDataLocation(prog, &quot;v&quot;);<br>
+       piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);<br>
+<br>
+       if (loc != 0) {<br>
+               fprintf(stderr, &quot;Expected location = 0, got %d\n&quot;, loc);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
+       loc = glGetFragDataLocation(prog, &quot;a&quot;);<br>
+       piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);<br>
+<br>
+       if (loc != 1) {<br>
+               fprintf(stderr, &quot;Expected location = 1, got %d\n&quot;, loc);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
+       printf(&quot;Querying locations after just binding...\n&quot;);<br>
+       glBindFragDataLocation(prog, 2, &quot;v&quot;);<br>
+       glBindFragDataLocation(prog, 0, &quot;a&quot;);<br>
+       piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);<br>
+<br>
+       loc = glGetFragDataLocation(prog, &quot;v&quot;);<br>
+       piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);<br>
+<br>
+       if (loc != 0) {<br>
+               fprintf(stderr, &quot;Expected location = 0, got %d\n&quot;, loc);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
+       loc = glGetFragDataLocation(prog, &quot;a&quot;);<br>
+       piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);<br>
+<br>
+       if (loc != 1) {<br>
+               fprintf(stderr, &quot;Expected location = 1, got %d\n&quot;, loc);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
+       piglit_report_result(PIGLIT_PASS);<br>
+}<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.6.4</font></span><br></blockquote><div><br><br>The spec mentions one other behavior that would probably be worth testing, either in this test or elsewhere (emphasis mine):<br><br>&quot;BindFragDataLocation may be issued before any shader objects are attached to a program object. Hence it is allowed to bind any name (except a name starting with gl_) to a color number, including a name that is never used as a varying out variable in any fragment shader object. *<b>Assigned bindings for variables that do not exist are ignored</b>*.&quot;<br>
<br>Other than that, this patch is:<br><br>Reviewed-by: Paul Berry &lt;<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>&gt;<br></div></div>