<p dir="ltr">You'll need to add this year to all.py</p>
<div class="gmail_quote">On Oct 25, 2015 07:08, "Gregory Hainaut" <<a href="mailto:gregory.hainaut@gmail.com">gregory.hainaut@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Related to mesa issue: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=79783" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=79783</a><br>
<br>
Mostly "Validated" on Nvidia driver. Nvidia fails to link vs_fs_prog_separate_inactive<br>
<br>
v2:<br>
* Test both output and input are still active<br>
* Test real interstage variable are still optimized<br>
* Mix rendezvous by name and location<br>
<br>
Signed-off-by: Gregory Hainaut <<a href="mailto:gregory.hainaut@gmail.com">gregory.hainaut@gmail.com</a>><br>
---<br>
.../arb_separate_shader_objects/CMakeLists.gl.txt | 1 +<br>
.../rendezvous_by_name.c | 358 +++++++++++++++++++++<br>
2 files changed, 359 insertions(+)<br>
create mode 100644 tests/spec/arb_separate_shader_objects/rendezvous_by_name.c<br>
<br>
diff --git a/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt b/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt<br>
index f1b15c0..9ab6606 100644<br>
--- a/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt<br>
+++ b/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt<br>
@@ -18,5 +18,6 @@ piglit_add_executable (arb_separate_shader_object-ProgramUniform-coverage Progra<br>
piglit_add_executable (arb_separate_shader_object-rendezvous_by_location rendezvous_by_location.c)<br>
piglit_add_executable (arb_separate_shader_object-rendezvous_by_location-3-stages rendezvous_by_location-3-stages.c)<br>
piglit_add_executable (arb_separate_shader_object-rendezvous_by_location-5-stages rendezvous_by_location-5-stages.c)<br>
+piglit_add_executable (arb_separate_shader_object-rendezvous_by_name rendezvous_by_name.c)<br>
piglit_add_executable (arb_separate_shader_object-UseProgramStages-non-separable UseProgramStages-non-separable.c)<br>
piglit_add_executable (arb_separate_shader_object-ValidateProgramPipeline ValidateProgramPipeline.c)<br>
diff --git a/tests/spec/arb_separate_shader_objects/rendezvous_by_name.c b/tests/spec/arb_separate_shader_objects/rendezvous_by_name.c<br>
new file mode 100644<br>
index 0000000..c8d3b20<br>
--- /dev/null<br>
+++ b/tests/spec/arb_separate_shader_objects/rendezvous_by_name.c<br>
@@ -0,0 +1,358 @@<br>
+/*<br>
+ * Copyright © 2015 Gregory Hainaut <<a href="mailto:gregory.hainaut@gmail.com">gregory.hainaut@gmail.com</a>><br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<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 "AS IS", 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 rendezvous_by_name.c<br>
+ * Simple test for separate shader objects that use rendezvous-by-name.<br>
+ *<br>
+ * Related to issue: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=79783" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=79783</a><br>
+ *<br>
+ * The test ensures deadcode optimization of input variables doesn't break<br>
+ * the rendezvous by name of the variables.<br>
+ */<br>
+#include "piglit-util-gl.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+ config.supports_gl_compat_version = 10;<br>
+ config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+static GLuint pipeline_3_out_1_in[2];<br>
+static GLuint pipeline_1_out_3_in[2];<br>
+static GLuint pipeline_inactive;<br>
+static GLint vs_fs_prog_inactive;<br>
+<br>
+static const char *vs_code_3_out_template =<br>
+ "#version %d\n"<br>
+ "#extension GL_ARB_separate_shader_objects: require\n"<br>
+ "#extension GL_ARB_explicit_attrib_location: require\n"<br>
+ "\n"<br>
+ "layout(location = 0) in vec4 piglit_vertex;\n"<br>
+ "\n"<br>
+ "%s out vec4 blue;\n"<br>
+ "out vec4 green;\n"<br>
+ "out vec4 red;\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " gl_Position = piglit_vertex;\n"<br>
+ " red = vec4(1, 0, 0, 0);\n"<br>
+ " green = vec4(0, 1, 0, 0);\n"<br>
+ " blue = vec4(0, 0, 1, 0);\n"<br>
+ "}\n"<br>
+ ;<br>
+<br>
+static const char *vs_code_1_out_template =<br>
+ "#version %d\n"<br>
+ "#extension GL_ARB_separate_shader_objects: require\n"<br>
+ "#extension GL_ARB_explicit_attrib_location: require\n"<br>
+ "\n"<br>
+ "layout(location = 0) in vec4 piglit_vertex;\n"<br>
+ "\n"<br>
+ "%s out vec4 blue;\n"<br>
+ "out vec4 green;\n"<br>
+ "out vec4 red;\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " gl_Position = piglit_vertex;\n"<br>
+ " green = vec4(0, 1, 0, 0);\n"<br>
+ "}\n"<br>
+ ;<br>
+<br>
+static const char *vs_code_inactive_template =<br>
+ "#version %d\n"<br>
+ "#extension GL_ARB_separate_shader_objects: require\n"<br>
+ "#extension GL_ARB_explicit_attrib_location: require\n"<br>
+ "\n"<br>
+ "layout(location = 0) in vec4 piglit_vertex;\n"<br>
+ "\n"<br>
+ "#define MAX_VARYING %d\n"<br>
+ "out vec4 a_dummy[MAX_VARYING];\n"<br>
+ "out vec4 green;\n"<br>
+ "out vec4 z_dummy[MAX_VARYING];\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " gl_Position = piglit_vertex;\n"<br>
+ " green = vec4(0, 1, 0, 0);\n"<br>
+ " for(int i = 0; i < MAX_VARYING; i++) {\n"<br>
+ " a_dummy[i] = vec4(1, 0, 0, 1);\n"<br>
+ " z_dummy[i] = vec4(0, 0, 1, 1);\n"<br>
+ " }\n"<br>
+ "}\n"<br>
+ ;<br>
+<br>
+static const char *fs_code_1_in_template =<br>
+ "#version %d\n"<br>
+ "#extension GL_ARB_separate_shader_objects: require\n"<br>
+ "#extension GL_ARB_explicit_attrib_location: enable\n"<br>
+ "\n"<br>
+ "#if __VERSION__ >= 130\n"<br>
+ "layout(location = 0) out vec4 out_color;\n"<br>
+ "#else\n"<br>
+ "#define out_color gl_FragColor\n"<br>
+ "#endif\n"<br>
+ "\n"<br>
+ "%s in vec4 blue;\n"<br>
+ "in vec4 green;\n"<br>
+ "in vec4 red;\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " out_color = vec4(<a href="http://green.xyz" rel="noreferrer" target="_blank">green.xyz</a>, 1);\n"<br>
+ "}\n"<br>
+ ;<br>
+<br>
+static const char *fs_code_3_in_template =<br>
+ "#version %d\n"<br>
+ "#extension GL_ARB_separate_shader_objects: require\n"<br>
+ "#extension GL_ARB_explicit_attrib_location: enable\n"<br>
+ "\n"<br>
+ "#if __VERSION__ >= 130\n"<br>
+ "layout(location = 0, index = 0) out vec4 out_color;\n"<br>
+ "layout(location = 0, index = 1) out vec4 avoid_opt;\n"<br>
+ "#else\n"<br>
+ "#define out_color gl_FragColor\n"<br>
+ "#endif\n"<br>
+ "\n"<br>
+ "%s in vec4 blue;\n"<br>
+ "in vec4 green;\n"<br>
+ "in vec4 red;\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " out_color = vec4(<a href="http://green.xyz" rel="noreferrer" target="_blank">green.xyz</a>, 1);\n"<br>
+ " avoid_opt = vec4(blue + red);\n"<br>
+ "}\n"<br>
+ ;<br>
+<br>
+static const char *fs_code_inactive_template =<br>
+ "#version %d\n"<br>
+ "#extension GL_ARB_separate_shader_objects: require\n"<br>
+ "#extension GL_ARB_explicit_attrib_location: enable\n"<br>
+ "\n"<br>
+ "#if __VERSION__ >= 130\n"<br>
+ "layout(location = 0) out vec4 out_color;\n"<br>
+ "#else\n"<br>
+ "#define out_color gl_FragColor\n"<br>
+ "#endif\n"<br>
+ "\n"<br>
+ "#define MAX_VARYING %d\n"<br>
+ "in vec4 a_dummy[MAX_VARYING];\n"<br>
+ "in vec4 green;\n"<br>
+ "in vec4 z_dummy[MAX_VARYING];\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " out_color = vec4(<a href="http://green.xyz" rel="noreferrer" target="_blank">green.xyz</a>, 1);\n"<br>
+ "}\n"<br>
+ ;<br>
+<br>
+static const char *qualifiers[2] = {<br>
+ "",<br>
+ "layout(location = 0)"<br>
+};<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ static const float expected[] = {<br>
+ 0.0f, 1.0f, 0.0f, 1.0f<br>
+ };<br>
+ bool pass = true;<br>
+<br>
+ glClearColor(0.1f, 0.1f, 0.1f, 0.1f);<br>
+ glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+ /*<br>
+ * Test 1: 3 active output in the VS + 1 active input in the FS. Only rendezvous by name<br>
+ * Screen location: bottom left<br>
+ */<br>
+ glBindProgramPipeline(pipeline_3_out_1_in[0]);<br>
+ piglit_draw_rect(-1, -1, 0.5, 1);<br>
+<br>
+ /*<br>
+ * Test 2: 3 active output in the VS + 1 active input in the FS. Mix rendezvous by name & location<br>
+ * Screen location: bottom middle<br>
+ */<br>
+ glBindProgramPipeline(pipeline_3_out_1_in[1]);<br>
+ piglit_draw_rect(-0.5, -1, 0.5, 1);<br>
+<br>
+ /*<br>
+ * Test 3: 1 active output in the VS + 3 active input in the FS. Only rendezvous by name<br>
+ * Screen location: top left<br>
+ */<br>
+ glBindProgramPipeline(pipeline_1_out_3_in[0]);<br>
+ piglit_draw_rect(-1, 0, 0.5, 1);<br>
+<br>
+ /*<br>
+ * Test 4: 1 active output in the VS + 3 active input in the FS. Mix rendezvous by name & location<br>
+ * Screen location: top middle<br>
+ */<br>
+ glBindProgramPipeline(pipeline_1_out_3_in[1]);<br>
+ piglit_draw_rect(-0.5, 0, 0.5, 1);<br>
+<br>
+ /*<br>
+ * Test 5: Link separate VS/FS together. Expect to optimize inactive variables<br>
+ * Screen location: bottom right<br>
+ */<br>
+ glBindProgramPipeline(pipeline_inactive);<br>
+ piglit_draw_rect(0, -1, 1, 1);<br>
+<br>
+ /*<br>
+ * Test 6: Link VS/FS together. Expect to optimize inactive variables<br>
+ * Screen location: top right<br>
+ */<br>
+ glBindProgramPipeline(0);<br>
+ glUseProgram(vs_fs_prog_inactive);<br>
+ piglit_draw_rect(0, 0, 1, 1);<br>
+<br>
+ pass &= piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,<br>
+ expected);<br>
+<br>
+ piglit_present_results();<br>
+<br>
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
+<br>
+GLuint format_and_link_program(GLenum type, const char* code, unsigned glsl_version, unsigned qualifier)<br>
+{<br>
+ char *source;<br>
+ GLuint prog;<br>
+<br>
+ asprintf(&source, code, glsl_version, qualifiers[qualifier]);<br>
+ prog = glCreateShaderProgramv(type, 1,<br>
+ (const GLchar *const *) &source);<br>
+<br>
+ piglit_link_check_status(prog);<br>
+ free(source);<br>
+<br>
+ return prog;<br>
+}<br>
+<br>
+void piglit_init(int argc, char **argv)<br>
+{<br>
+ unsigned i;<br>
+ unsigned glsl_version;<br>
+ GLuint vs_prog_3_out[2];<br>
+ GLuint vs_prog_1_out[2];<br>
+ GLuint fs_prog_3_in[2];<br>
+ GLuint fs_prog_1_in[2];<br>
+ GLuint vs_fs_prog_separate_inactive;<br>
+ bool es;<br>
+ int glsl_major;<br>
+ int glsl_minor;<br>
+ char *vs_source;<br>
+ char *fs_source;<br>
+ GLint max_varying;<br>
+ bool pass = true;<br>
+<br>
+ piglit_require_vertex_shader();<br>
+ piglit_require_fragment_shader();<br>
+ piglit_require_GLSL_version(130); /* Support layout index on output color */<br>
+ piglit_require_extension("GL_ARB_separate_shader_objects");<br>
+ piglit_require_extension("GL_ARB_explicit_attrib_location");<br>
+ piglit_require_extension("GL_ARB_blend_func_extended");<br>
+<br>
+ /* Some NVIDIA drivers have issues with layout qualifiers, 'in'<br>
+ * keywords, and 'out' keywords in "lower" GLSL versions. If the<br>
+ * driver supports GLSL >= 1.40, use 1.40. Otherwise, pick the<br>
+ * highest version that the driver supports.<br>
+ */<br>
+ piglit_get_glsl_version(&es, &glsl_major, &glsl_minor);<br>
+ glsl_version = ((glsl_major * 100) + glsl_minor) >= 140<br>
+ ? 140 : ((glsl_major * 100) + glsl_minor);<br>
+<br>
+ glGetIntegerv(GL_MAX_VARYING_COMPONENTS, &max_varying);<br>
+ max_varying = (max_varying / 4u) - 1u;<br>
+<br>
+ /*<br>
+ * Program compilation and link<br>
+ */<br>
+ for (i = 0; i < 2; i++) {<br>
+ printf("Compile vs_prog_3_out[%d]\n", i);<br>
+ vs_prog_3_out[i] = format_and_link_program(GL_VERTEX_SHADER,<br>
+ vs_code_3_out_template, glsl_version, i);<br>
+<br>
+ printf("Compile vs_prog_1_out[%d]\n", i);<br>
+ vs_prog_1_out[i] = format_and_link_program(GL_VERTEX_SHADER,<br>
+ vs_code_1_out_template, glsl_version, i);<br>
+<br>
+ printf("Compile fs_prog_3_in[%d]\n", i);<br>
+ fs_prog_3_in[i] = format_and_link_program(GL_FRAGMENT_SHADER,<br>
+ fs_code_3_in_template, glsl_version, i);<br>
+<br>
+ printf("Compile fs_prog_1_in[%d]\n", i);<br>
+ fs_prog_1_in[i] = format_and_link_program(GL_FRAGMENT_SHADER,<br>
+ fs_code_1_in_template, glsl_version, i);<br>
+ }<br>
+<br>
+ asprintf(&vs_source, vs_code_inactive_template, glsl_version, max_varying);<br>
+ asprintf(&fs_source, fs_code_inactive_template, glsl_version, max_varying);<br>
+<br>
+ printf("Compile vs_fs_prog_separate_inactive\n");<br>
+ vs_fs_prog_separate_inactive = piglit_build_simple_program_unlinked(vs_source, fs_source);<br>
+ /* Manual linking so we can pack 2 separate-aware shaders into a single program */<br>
+ glProgramParameteri(vs_fs_prog_separate_inactive, GL_PROGRAM_SEPARABLE, GL_TRUE);<br>
+ glLinkProgram(vs_fs_prog_separate_inactive);<br>
+ if (!piglit_link_check_status(vs_fs_prog_separate_inactive)) {<br>
+ piglit_report_result(PIGLIT_FAIL);<br>
+ }<br>
+<br>
+ printf("Compile vs_fs_prog_inactive\n");<br>
+ vs_fs_prog_inactive = piglit_build_simple_program(vs_source, fs_source);<br>
+<br>
+ free(vs_source);<br>
+ free(fs_source);<br>
+<br>
+ /*<br>
+ * Pipeline creation<br>
+ */<br>
+ glGenProgramPipelines(2, pipeline_3_out_1_in);<br>
+ glGenProgramPipelines(2, pipeline_1_out_3_in);<br>
+ for (i = 0; i < 2; i++) {<br>
+ glBindProgramPipeline(pipeline_3_out_1_in[i]);<br>
+ glUseProgramStages(pipeline_3_out_1_in[i],<br>
+ GL_VERTEX_SHADER_BIT, vs_prog_3_out[i]);<br>
+ glUseProgramStages(pipeline_3_out_1_in[i],<br>
+ GL_FRAGMENT_SHADER_BIT, fs_prog_1_in[i]);<br>
+<br>
+ glBindProgramPipeline(pipeline_1_out_3_in[i]);<br>
+ glUseProgramStages(pipeline_1_out_3_in[i],<br>
+ GL_VERTEX_SHADER_BIT, vs_prog_1_out[i]);<br>
+ glUseProgramStages(pipeline_1_out_3_in[i],<br>
+ GL_FRAGMENT_SHADER_BIT, fs_prog_3_in[i]);<br>
+ }<br>
+<br>
+ glGenProgramPipelines(1, &pipeline_inactive);<br>
+ glBindProgramPipeline(pipeline_inactive);<br>
+ glUseProgramStages(pipeline_inactive,<br>
+ GL_VERTEX_SHADER_BIT | GL_FRAGMENT_SHADER_BIT,<br>
+ vs_fs_prog_separate_inactive);<br>
+<br>
+ if (!piglit_check_gl_error(0) || !pass)<br>
+ piglit_report_result(PIGLIT_FAIL);<br>
+}<br>
--<br>
2.1.4<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</blockquote></div>