<div dir="ltr">all.py?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 21, 2015 at 8:12 PM, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On i965, the TCS writes a memory location which the TES reads. Both<br>
shader stages need to agree upon the layout. With SSO, this is tricky,<br>
as OpenGL allows developers to freely mix-and-match separate TCS and TES<br>
programs that have never been linked together.<br>
<br>
To test this, we compile two TCS programs with different outputs, and<br>
create SSO pipelines that use them with the same TES. A layout<br>
determined by the TES alone would not suffice, so this ensures that<br>
the layout is updated when the TCS changes.<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
.../arb_separate_shader_objects/CMakeLists.gl.txt | 1 +<br>
.../mix-and-match-tcs-tes.c | 209 +++++++++++++++++++++<br>
2 files changed, 210 insertions(+)<br>
create mode 100644 tests/spec/arb_separate_shader_objects/mix-and-match-tcs-tes.c<br>
<br>
Passes with Nouveau on NVE4. Initially fails on i965, but passes with my new<br>
Mesa patches to handle this case correctly.<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 3a55130..234d58d 100644<br>
--- a/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt<br>
+++ b/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt<br>
@@ -15,6 +15,7 @@ piglit_add_executable (arb_separate_shader_object-compat-builtins compat-builtin<br>
piglit_add_executable (arb_separate_shader_object-GetProgramPipelineiv GetProgramPipelineiv.c)<br>
piglit_add_executable (arb_separate_shader_object-IsProgramPipeline IsProgramPipeline.c)<br>
piglit_add_executable (arb_separate_shader_object-mixed_explicit_and_non_explicit_locations mixed_explicit_and_non_explicit_locations.c sso-common.c)<br>
+piglit_add_executable (arb_separate_shader_object-mix-and-match-tcs-tes mix-and-match-tcs-tes.c)<br>
piglit_add_executable (arb_separate_shader_object-ProgramUniform-coverage ProgramUniform-coverage.c)<br>
piglit_add_executable (arb_separate_shader_object-rendezvous_by_location rendezvous_by_location.c sso-common.c)<br>
piglit_add_executable (arb_separate_shader_object-rendezvous_by_location-3-stages rendezvous_by_location-3-stages.c)<br>
diff --git a/tests/spec/arb_separate_shader_objects/mix-and-match-tcs-tes.c b/tests/spec/arb_separate_shader_objects/mix-and-match-tcs-tes.c<br>
new file mode 100644<br>
index 0000000..6e0643e<br>
--- /dev/null<br>
+++ b/tests/spec/arb_separate_shader_objects/mix-and-match-tcs-tes.c<br>
@@ -0,0 +1,209 @@<br>
+/*<br>
+ * Copyright © 2015 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 "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>
+ * This program tests SSO pipelines where the TCS and TES are not linked<br>
+ * together, but specified in separate shaders. In particular, this means<br>
+ * that the GLSL linker won't know the interface between the TCS and TES.<br>
+ *<br>
+ * We compile two TCS programs. Both are largely the same, but the second<br>
+ * has extra unused outputs, which means the two pipelines have a different<br>
+ * number of per-patch outputs. At least on i965, this requires a re-layout<br>
+ * of the TCS/TES interface.<br>
+ *<br>
+ * The output is a single green square, but drawn in two halves, each with<br>
+ * a different SSO pipeline.<br>
+ */<br>
+<br>
+#include "piglit-util-gl.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+ config.supports_gl_compat_version = 0;<br>
+ config.supports_gl_core_version = 32;<br>
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+static GLuint pipeline[2];<br>
+<br>
+static const char *vs_code =<br>
+ "#version 150\n"<br>
+ "#extension GL_ARB_separate_shader_objects: require\n"<br>
+ "in vec4 piglit_vertex;"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " gl_Position = piglit_vertex;\n"<br>
+ "}\n"<br>
+ ;<br>
+<br>
+#define TCS(vars, extra_code) \<br>
+ "#version 150\n" \<br>
+ "#extension GL_ARB_separate_shader_objects: require\n" \<br>
+ "#extension GL_ARB_tessellation_shader: require\n" \<br>
+ "layout(vertices = 3) out;\n" \<br>
+ "\n" \<br>
+ vars \<br>
+ "\n" \<br>
+ "void main()\n" \<br>
+ "{\n" \<br>
+ " gl_out[gl_InvocationID].gl_Position = \n" \<br>
+ " gl_in[gl_InvocationID].gl_Position;\n" \<br>
+ " gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);\n" \<br>
+ " gl_TessLevelInner = float[2](0.0, 0.0);\n" \<br>
+ " patch_color = vec4(0.0, 1.0, 0.0, 1.0);\n" \<br>
+ extra_code \<br>
+ "}\n"<br>
+<br>
+static const char *tcs0_code =<br>
+ TCS("layout(location = 1) patch out vec4 patch_color;\n", "");<br>
+static const char *tcs1_code =<br>
+ TCS("layout(location = 0) patch out vec4 foo;\n"<br>
+ "layout(location = 1) patch out vec4 patch_color;\n"<br>
+ "layout(location = 2) patch out vec4 bar;\n",<br>
+<br>
+ " foo = vec4(0);\n"<br>
+ " bar = vec4(0);\n");<br>
+<br>
+static const char *tes_code =<br>
+ "#version 150\n"<br>
+ "#extension GL_ARB_separate_shader_objects: require\n"<br>
+ "#extension GL_ARB_tessellation_shader: require\n"<br>
+ "layout(triangles) in;\n"<br>
+ "\n"<br>
+ "layout(location = 1) patch in vec4 patch_color;\n"<br>
+ "layout(location = 0) out vec4 color;\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " color = patch_color;\n"<br>
+ " gl_Position = gl_in[0].gl_Position * gl_TessCoord[0]\n"<br>
+ " + gl_in[1].gl_Position * gl_TessCoord[1]\n"<br>
+ " + gl_in[2].gl_Position * gl_TessCoord[2];\n"<br>
+ "}\n"<br>
+ ;<br>
+<br>
+static const char *fs_code =<br>
+ "#version 150\n"<br>
+ "#extension GL_ARB_separate_shader_objects: require\n"<br>
+ "\n"<br>
+ "layout(location = 0) in vec4 color;"<br>
+ "out vec4 out_color;"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " out_color = color;\n"<br>
+ "}\n"<br>
+ ;<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ static const float expected[] = { 0, 1, 0, 1 };<br>
+ bool pass;<br>
+<br>
+ glClearColor(0.1f, 0.1f, 0.1f, 0.1f);<br>
+ glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+ /* Draw the left half using the first pipeline */<br>
+ glBindProgramPipeline(pipeline[0]);<br>
+ glViewport(0, 0, piglit_width / 2, piglit_height);<br>
+ glDrawArrays(GL_PATCHES, 0, 6);<br>
+<br>
+ /* Draw the right half using the second pipeline */<br>
+ glBindProgramPipeline(pipeline[1]);<br>
+ glViewport(piglit_width / 2, 0, piglit_width / 2, piglit_height);<br>
+ glDrawArrays(GL_PATCHES, 0, 6);<br>
+<br>
+ /* The result should be a green square filling the whole viewport. */<br>
+ pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,<br>
+ expected);<br>
+<br>
+ piglit_present_results();<br>
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
+<br>
+void piglit_init(int argc, char **argv)<br>
+{<br>
+ GLuint vs_prog, tcs0_prog, tcs1_prog, tes_prog, fs_prog;<br>
+ GLuint vao, buf;<br>
+ static const float verts[] = {<br>
+ -1.0, -1.0,<br>
+ 1.0, -1.0,<br>
+ -1.0, 1.0,<br>
+ -1.0, 1.0,<br>
+ 1.0, -1.0,<br>
+ 1.0, 1.0<br>
+ };<br>
+<br>
+ piglit_require_extension("GL_ARB_separate_shader_objects");<br>
+ piglit_require_extension("GL_ARB_tessellation_shader");<br>
+<br>
+ vs_prog = glCreateShaderProgramv(GL_VERTEX_SHADER, 1,<br>
+ (const GLchar *const*)&vs_code);<br>
+ piglit_link_check_status(vs_prog);<br>
+<br>
+ tcs0_prog = glCreateShaderProgramv(GL_TESS_CONTROL_SHADER, 1,<br>
+ (const GLchar *const *)&tcs0_code);<br>
+ piglit_link_check_status(tcs0_prog);<br>
+<br>
+ tcs1_prog = glCreateShaderProgramv(GL_TESS_CONTROL_SHADER, 1,<br>
+ (const GLchar *const *)&tcs1_code);<br>
+ piglit_link_check_status(tcs1_prog);<br>
+<br>
+ tes_prog = glCreateShaderProgramv(GL_TESS_EVALUATION_SHADER, 1,<br>
+ (const GLchar *const *)&tes_code);<br>
+ piglit_link_check_status(tes_prog);<br>
+<br>
+ fs_prog = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1,<br>
+ (const GLchar *const *)&fs_code);<br>
+ piglit_link_check_status(fs_prog);<br>
+<br>
+ glGenProgramPipelines(2, pipeline);<br>
+ glUseProgramStages(pipeline[0], GL_VERTEX_SHADER_BIT, vs_prog);<br>
+ glUseProgramStages(pipeline[0], GL_TESS_CONTROL_SHADER_BIT, tcs0_prog);<br>
+ glUseProgramStages(pipeline[0], GL_TESS_EVALUATION_SHADER_BIT, tes_prog);<br>
+ glUseProgramStages(pipeline[0], GL_FRAGMENT_SHADER_BIT, fs_prog);<br>
+ piglit_program_pipeline_check_status(pipeline[0]);<br>
+<br>
+ glUseProgramStages(pipeline[1], GL_VERTEX_SHADER_BIT, vs_prog);<br>
+ glUseProgramStages(pipeline[1], GL_TESS_CONTROL_SHADER_BIT, tcs1_prog);<br>
+ glUseProgramStages(pipeline[1], GL_TESS_EVALUATION_SHADER_BIT, tes_prog);<br>
+ glUseProgramStages(pipeline[1], GL_FRAGMENT_SHADER_BIT, fs_prog);<br>
+ piglit_program_pipeline_check_status(pipeline[1]);<br>
+<br>
+ /* Set up the VAOs/VBOs for drawing rectangles using the approach<br>
+ * from spec/arb_tessellation_shader/execution/sanity.shader_test.<br>
+ */<br>
+ glGenVertexArrays(1, &vao);<br>
+ glBindVertexArray(vao);<br>
+ glGenBuffers(1, &buf);<br>
+ glBindBuffer(GL_ARRAY_BUFFER, buf);<br>
+ glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);<br>
+ glVertexAttribPointer(PIGLIT_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, 0);<br>
+ glEnableVertexAttribArray(PIGLIT_ATTRIB_POS);<br>
+ glPatchParameteri(GL_PATCH_VERTICES, 3);<br>
+<br>
+ if (!piglit_check_gl_error(0))<br>
+ piglit_report_result(PIGLIT_FAIL);<br>
+}<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.6.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>
</font></span></blockquote></div><br></div>