<div dir="ltr"><div>Acked-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>></div><div><br></div><div>Marek<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 25, 2018 at 3:03 AM, Timothy Arceri <span dir="ltr"><<a href="mailto:tarceri@itsqueeze.com" target="_blank">tarceri@itsqueeze.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This extends the fogscale test to test a gl_FogFragCoord value<br>
passed via a geometry shader.<br>
---<br>
tests/shaders/glsl-fs-<wbr>fogscale.c | 100 +++++++++++++++++++++++++-----<wbr>-<br>
1 file changed, 82 insertions(+), 18 deletions(-)<br>
<br>
diff --git a/tests/shaders/glsl-fs-<wbr>fogscale.c b/tests/shaders/glsl-fs-<wbr>fogscale.c<br>
index e5f28eaf7..076092d07 100644<br>
--- a/tests/shaders/glsl-fs-<wbr>fogscale.c<br>
+++ b/tests/shaders/glsl-fs-<wbr>fogscale.c<br>
@@ -39,13 +39,34 @@ PIGLIT_GL_TEST_CONFIG_BEGIN<br>
<br>
PIGLIT_GL_TEST_CONFIG_END<br>
<br>
-enum piglit_result<br>
-piglit_display(void)<br>
+static const char vs_source[] =<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " gl_Position = gl_Vertex;\n"<br>
+ " gl_FogFragCoord = gl_Position.x;\n"<br>
+ "}\n";<br>
+<br>
+static const char *dummy_vs_source =<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " gl_Position = gl_Vertex;\n"<br>
+ "}\n";<br>
+<br>
+static const char fs_source[] =<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " gl_FragColor = vec4(gl_FogFragCoord * gl_Fog.scale * vec2(1.0, -1.0), 0.0, 1.0);\n"<br>
+ "}\n";<br>
+<br>
+static bool<br>
+test_prog(unsigned prog, const char *test_name)<br>
{<br>
static const float green[] = {0.0f, 1.0f, 0.0f, 1.0f};<br>
static const float red[] = {1.0f, 0.0f, 0.0f, 1.0f};<br>
bool pass = true;<br>
<br>
+ glUseProgram(prog);<br>
+<br>
glClearColor(0.0, 0.0, 1.0, 0.0);<br>
glClear(GL_COLOR_BUFFER_BIT);<br>
<br>
@@ -57,30 +78,73 @@ piglit_display(void)<br>
piglit_width / 2, piglit_height,<br>
red) && pass;<br>
<br>
- piglit_present_results();<br>
+ piglit_report_subtest_result(<wbr>pass ? PIGLIT_PASS : PIGLIT_FAIL, "%s",<br>
+ test_name);<br>
<br>
- return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+ return pass;<br>
}<br>
<br>
-void<br>
-piglit_init(int argc, char **argv)<br>
+static void<br>
+create_gs_source(char **gs_source, char *fogFragCoordValue)<br>
{<br>
- static const char vs_source[] =<br>
+ (void)!asprintf(gs_source,<br>
+ "#version 150 compatibility\n"<br>
+ "layout(triangles) in;\n"<br>
+ "layout(triangle_strip, max_vertices = 3) out;\n"<br>
+ "\n"<br>
"void main()\n"<br>
"{\n"<br>
- " gl_Position = gl_Vertex;\n"<br>
- " gl_FogFragCoord = gl_Position.x;\n"<br>
- "}\n";<br>
- static const char fs_source[] =<br>
- "void main()\n"<br>
- "{\n"<br>
- " gl_FragColor = vec4(gl_FogFragCoord * gl_Fog.scale * vec2(1.0, -1.0), 0.0, 1.0);\n"<br>
- "}\n";<br>
- GLuint prog;<br>
+ " for (int i = 0; i < 3; i++) {\n"<br>
+ " gl_Position = gl_in[i].gl_Position;\n"<br>
+ " gl_FogFragCoord = %s;\n"<br>
+ " EmitVertex();\n"<br>
+ " }\n"<br>
+ "}\n",<br>
+ fogFragCoordValue);<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ bool pass = true;<br>
+ char *gs_source;<br>
+ char *gs_source2;<br>
+<br>
+ /* Test simple vs and fs program */<br>
+ GLuint prog = piglit_build_simple_program(<wbr>vs_source, fs_source);<br>
+ test_prog(prog, "vs and fs");<br>
+<br>
+ /* Test passing gl_FogFragCoord via the Geometry Shader */<br>
+ if (piglit_get_gl_version() >= 32) {<br>
+ /* Test gl_FogFragCoord gs output only */<br>
+ create_gs_source(&gs_source, "gl_Position.x");<br>
+ prog = piglit_build_simple_program_<wbr>multiple_shaders(<br>
+ GL_VERTEX_SHADER, dummy_vs_source,<br>
+ GL_GEOMETRY_SHADER, gs_source,<br>
+ GL_FRAGMENT_SHADER, fs_source,<br>
+ 0);<br>
+ pass = pass && test_prog(prog, "gs-out and fs");<br>
+<br>
+ /* Test gl_FogFragCoord both as a gs output and input */<br>
+ create_gs_source(&gs_source2, "gl_in[i].gl_FogFragCoord");<br>
+ prog = piglit_build_simple_program_<wbr>multiple_shaders(<br>
+ GL_VERTEX_SHADER, vs_source,<br>
+ GL_GEOMETRY_SHADER, gs_source2,<br>
+ GL_FRAGMENT_SHADER, fs_source,<br>
+ 0);<br>
+ pass = pass && test_prog(prog, "vs, gs and fs");<br>
<br>
- prog = piglit_build_simple_program(<wbr>vs_source, fs_source);<br>
+ } else {<br>
+ piglit_report_subtest_result(<wbr>PIGLIT_SKIP, "gs-out and fs");<br>
+ piglit_report_subtest_result(<wbr>PIGLIT_SKIP, "vs, gs and fs");<br>
+ }<br>
<br>
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
glFogf(GL_FOG_START, 0.0f);<br>
glFogf(GL_FOG_END, 0.0f);<br>
- glUseProgram(prog);<br>
}<br>
<span class="HOEnZb"><font color="#888888">-- <br>
2.17.0<br>
<br>
______________________________<wbr>_________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/piglit" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div>