Signed-off-by: Samuel Iglesias Gonsalvez <sigles...@igalia.com> --- tests/all.py | 2 + tests/spec/arb_gpu_shader5/CMakeLists.txt | 3 +- .../spec/arb_gpu_shader5/linker/CMakeLists.gl.txt | 13 ++ tests/spec/arb_gpu_shader5/linker/CMakeLists.txt | 1 + .../linker/emitstreamvertex_stream_too_large.c | 133 +++++++++++++++++++++ .../linker/stream-different-zero-gs-fs.shader_test | 50 ++++++++ .../linker/stream-invalid-prim-output.shader_test | 54 +++++++++ .../linker/stream-negative-value.shader_test | 38 ++++++ .../arb_gpu_shader5/linker/tf-wrong-stream-value.c | 116 ++++++++++++++++++ 9 files changed, 409 insertions(+), 1 deletion(-) create mode 100644 tests/spec/arb_gpu_shader5/linker/CMakeLists.gl.txt create mode 100644 tests/spec/arb_gpu_shader5/linker/CMakeLists.txt create mode 100644 tests/spec/arb_gpu_shader5/linker/emitstreamvertex_stream_too_large.c create mode 100644 tests/spec/arb_gpu_shader5/linker/stream-different-zero-gs-fs.shader_test create mode 100644 tests/spec/arb_gpu_shader5/linker/stream-invalid-prim-output.shader_test create mode 100644 tests/spec/arb_gpu_shader5/linker/stream-negative-value.shader_test create mode 100644 tests/spec/arb_gpu_shader5/linker/tf-wrong-stream-value.c
diff --git a/tests/all.py b/tests/all.py index 69cedd5..e25a6a3 100644 --- a/tests/all.py +++ b/tests/all.py @@ -1870,6 +1870,8 @@ add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-invocation-id') add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-invocations_count_too_large') add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-xfb-streams') add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-stream_value_too_large') +add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-emitstreamvertex_stream_too_large') +add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-tf-wrong-stream-value') arb_shader_subroutine = {} spec['ARB_shader_subroutine'] = arb_shader_subroutine diff --git a/tests/spec/arb_gpu_shader5/CMakeLists.txt b/tests/spec/arb_gpu_shader5/CMakeLists.txt index f41c000..60d83cb 100644 --- a/tests/spec/arb_gpu_shader5/CMakeLists.txt +++ b/tests/spec/arb_gpu_shader5/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory (compiler) add_subdirectory (execution) -piglit_include_target_api() \ No newline at end of file +add_subdirectory (linker) +piglit_include_target_api() diff --git a/tests/spec/arb_gpu_shader5/linker/CMakeLists.gl.txt b/tests/spec/arb_gpu_shader5/linker/CMakeLists.gl.txt new file mode 100644 index 0000000..f955e83 --- /dev/null +++ b/tests/spec/arb_gpu_shader5/linker/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 (arb_gpu_shader5-emitstreamvertex_stream_too_large emitstreamvertex_stream_too_large.c) +piglit_add_executable (arb_gpu_shader5-tf-wrong-stream-value tf-wrong-stream-value.c) diff --git a/tests/spec/arb_gpu_shader5/linker/CMakeLists.txt b/tests/spec/arb_gpu_shader5/linker/CMakeLists.txt new file mode 100644 index 0000000..144a306 --- /dev/null +++ b/tests/spec/arb_gpu_shader5/linker/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/arb_gpu_shader5/linker/emitstreamvertex_stream_too_large.c b/tests/spec/arb_gpu_shader5/linker/emitstreamvertex_stream_too_large.c new file mode 100644 index 0000000..cd2626f --- /dev/null +++ b/tests/spec/arb_gpu_shader5/linker/emitstreamvertex_stream_too_large.c @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2014 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. + */ + +/** + * @file emitstreamvertex_stream_too_large.c + * + * Test that exceeding the implementation's maximum streams + * value (GL_MAX_VERTEX_STREAMS) when calling EmitStreamVertex + * results in a linking error. + * + * From ARB_gpu_shader5 spec: + * + * "If an implementation supports <N> vertex streams, the + * individual streams are numbered 0 through <N>-1" + * + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 32; + config.supports_gl_core_version = 32; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +static const char *vs_source = + "#version 150\n" + "\n" + "void main()\n" + "{\n" + "gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n" + "}\n"; + +static const char *gs_template = + "#version 150\n" + "#extension GL_ARB_gpu_shader5: enable\n" + "\n" + "layout(points) in;\n" + "layout(points, max_vertices=1) out;\n" + "\n" + "void main()\n" + "{\n" + "gl_Position = vec4(1.0, 1.0, 1.0, 1.0);\n" + "EmitStreamVertex(%d);\n" + "EndStreamPrimitive(%d);\n" + "}\n"; + +static const char *fs_source = + "#version 150\n" + "out vec3 color;\n" + "\n" + "void main()\n" + "{\n" + "color = vec3(0.0, 0.0, 0.0);\n" + "}\n"; + +void +piglit_init(int argc, char **argv) +{ + GLint max_streams; + GLint pass = 1; + GLint program; + GLint vs, fs, gs; + char *shader_text; + + piglit_require_extension("GL_ARB_gpu_shader5"); + + glGetIntegerv(GL_MAX_VERTEX_STREAMS, &max_streams); + + if (!piglit_check_gl_error(GL_NO_ERROR)) + piglit_report_result(PIGLIT_FAIL); + + vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, (const GLchar **) &vs_source, NULL); + glCompileShader(vs); + + fs = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fs, 1, (const GLchar **) &fs_source, NULL); + glCompileShader(fs); + + asprintf(&shader_text, gs_template, max_streams, max_streams); + gs = glCreateShader(GL_GEOMETRY_SHADER); + glShaderSource(gs, 1, (const GLchar **) &shader_text, NULL); + glCompileShader(gs); + + program = glCreateProgram(); + glAttachShader(program, vs); + glAttachShader(program, gs); + glAttachShader(program, fs); + + glLinkProgram(program); + glGetProgramiv(program, GL_LINK_STATUS, &pass); + + glDetachShader(program, fs); + glDetachShader(program, gs); + glDetachShader(program, vs); + + glDeleteProgram(program); + + glDeleteShader(vs); + glDeleteShader(gs); + glDeleteShader(fs); + /* As an error is expected, pass should be 0. */ + piglit_report_result(pass ? PIGLIT_FAIL : PIGLIT_PASS); +} diff --git a/tests/spec/arb_gpu_shader5/linker/stream-different-zero-gs-fs.shader_test b/tests/spec/arb_gpu_shader5/linker/stream-different-zero-gs-fs.shader_test new file mode 100644 index 0000000..9970814 --- /dev/null +++ b/tests/spec/arb_gpu_shader5/linker/stream-different-zero-gs-fs.shader_test @@ -0,0 +1,50 @@ +# ARB_gpu_shader5 spec says: +# "The primitives emitted to all streams but stream zero are +# discarded after transform feedback. Primitives emitted to +# stream zero are passed to subsequent pipeline stages for clipping, +# rasterization, and subsequent fragment processing." +# +# This test verifies that a link error occurs if an input FS variable +# has assigned a stream > 0 in the Geometry shader. + +[require] +GLSL >= 1.50 +GL_ARB_gpu_shader5 + +[vertex shader passthrough] + +[geometry shader] + +#extension GL_ARB_gpu_shader5 : enable + +layout(points) in; +layout(points, max_vertices=3) out; + +layout(stream=1) out vec4 var1; + +void main() +{ + var1 = vec4 (0.0, 0.0, 0.0, 0.0); + gl_Position = vec4(1.0, 1.0, 1.0, 1.0); + EmitStreamVertex(0); + EndStreamPrimitive(0); + + var1 = vec4 (0.0, 0.0, 0.0, 0.0); + gl_Position = vec4(1.0, 1.0, 1.0, 1.0); + EmitStreamVertex(1); + EndStreamPrimitive(1); +} + +[fragment shader] + +in vec4 var1; + +out vec4 color; + +void main() +{ + color = var1; +} + +[test] +link error diff --git a/tests/spec/arb_gpu_shader5/linker/stream-invalid-prim-output.shader_test b/tests/spec/arb_gpu_shader5/linker/stream-invalid-prim-output.shader_test new file mode 100644 index 0000000..dc10b61 --- /dev/null +++ b/tests/spec/arb_gpu_shader5/linker/stream-invalid-prim-output.shader_test @@ -0,0 +1,54 @@ +# ARB_gpu_shader5 spec says: +# "Geometry shaders that emit vertices to multiple vertex streams are +# currently limited to using only the "points" output primitive +# type. A program will fail to link if it includes a geometry shader +# that calls the EmitStreamVertex() built-in function and has any +# other output primitive type parameter." +# +# This test verifies that a link error occurs if EmitStreamVertex() +# is called with a output primitive type different than "points" and +# stream value bigger than zero. + +[require] +GLSL >= 1.50 +GL_ARB_gpu_shader5 + +[vertex shader passthrough] + +[geometry shader] + +#extension GL_ARB_gpu_shader5 : enable + +layout(points) in; +layout(triangle_strip, max_vertices=3) out; + +layout (stream=1) out vec4 var1; + +void main() +{ + var1 = vec4(0.0, 0.0, 0.0, 1.0); + gl_Position = var1; + EmitStreamVertex(1); + + var1 = vec4(0.0, 1.0, 0.0, 1.0); + gl_Position = var1; + EmitStreamVertex(1); + + var1 = vec4(1.0, 1.0, 0.0, 1.0); + gl_Position = var1; + EmitStreamVertex(1); + + EndStreamPrimitive(1); +} + +[fragment shader] + +out vec4 color; + +void main() +{ + color = vec4(0.0, 1.0, 0.0, 1.0); +} + +[test] +link error diff --git a/tests/spec/arb_gpu_shader5/linker/stream-negative-value.shader_test b/tests/spec/arb_gpu_shader5/linker/stream-negative-value.shader_test new file mode 100644 index 0000000..1a2c759 --- /dev/null +++ b/tests/spec/arb_gpu_shader5/linker/stream-negative-value.shader_test @@ -0,0 +1,38 @@ +# ARB_gpu_shader5 spec says: +# "If an implementation supports <N> vertex streams, the individual +# streams are numbered 0 through <N>-1" +# +# This test verifies that a link error occurs if EmitStreamVertex() +# is called with a stream value which is negative. + +[require] +GLSL >= 1.50 +GL_ARB_gpu_shader5 + +[vertex shader passthrough] + +[geometry shader] + +#extension GL_ARB_gpu_shader5 : enable + +layout(points) in; +layout(points, max_vertices=3) out; + +void main() +{ + gl_Position = vec4(1.0, 1.0, 1.0, 1.0); + EmitStreamVertex(-1); + EndStreamPrimitive(-1); +} + +[fragment shader] + +out vec4 color; + +void main() +{ + color = vec4(0.0, 1.0, 0.0, 1.0); +} + +[test] +link error diff --git a/tests/spec/arb_gpu_shader5/linker/tf-wrong-stream-value.c b/tests/spec/arb_gpu_shader5/linker/tf-wrong-stream-value.c new file mode 100644 index 0000000..afc79ad --- /dev/null +++ b/tests/spec/arb_gpu_shader5/linker/tf-wrong-stream-value.c @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2014 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. + */ + +#include "piglit-util-gl.h" + +/** + * @file tf-wrong-stream-value.c + * + * This test uses geometry shader multiple stream support from + * GL_ARB_gpu_shader5 and GL_ARB_transform_feedback3 to capture + * transform feedback from 2 streams into one buffer. + * + * This test is expected to fail when linking. + * From ARB_transform_feedback3 spec: + * + * "A program will fail to link if: + * [...] + * * the set of varyings to capture to any single binding point + * includes varyings from more than one vertex stream." + */ + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 32; + config.supports_gl_core_version = 32; + +PIGLIT_GL_TEST_CONFIG_END + +static const char vs_pass_thru_text[] = + "#version 150\n" + "void main() {\n" + " gl_Position = vec4(0.0);\n" + "}\n"; + +static const char gs_text[] = + "#version 150\n" + "#extension GL_ARB_gpu_shader5 : enable\n" + "layout(points) in;\n" + "layout(points, max_vertices = 1) out;\n" + "out float stream0_0_out;\n" + "layout(stream = 1) out vec2 stream1_0_out;\n" + "void main() {\n" + " gl_Position = gl_in[0].gl_Position;\n" + + " stream0_0_out = 0.0;\n" + " stream1_0_out = vec2(1.0, 2.0);\n" + " EmitVertex();\n" + " EndPrimitive();\n" + "}"; + +const char *stream_names[] = { "first", "second", "third", "forth" }; +int stream_float_counts[] = { 1, 5, 5, 3 }; + +#define STREAMS ARRAY_SIZE(stream_names) + +static const char *varyings[] = { + "stream0_0_out", "stream1_0_out" +}; + +void +piglit_init(int argc, char **argv) +{ + bool pass; + unsigned primitive_n; + GLint gs_invocation_n; + GLuint prog; + + + piglit_require_extension("GL_ARB_gpu_shader5"); + piglit_require_extension("GL_ARB_transform_feedback3"); + + prog = piglit_build_simple_program_multiple_shaders( + GL_VERTEX_SHADER, vs_pass_thru_text, + GL_GEOMETRY_SHADER, gs_text, 0); + + if (!piglit_check_gl_error(GL_NO_ERROR)) { + piglit_report_result(PIGLIT_FAIL); + return; + } + + glTransformFeedbackVaryings(prog, ARRAY_SIZE(varyings), varyings, + GL_INTERLEAVED_ATTRIBS); + + glLinkProgram(prog); + if (!piglit_link_check_status(prog)) + piglit_report_result(PIGLIT_PASS); + else + piglit_report_result(PIGLIT_FAIL); +} + +enum piglit_result +piglit_display(void) +{ + /* Should never be reached */ + return PIGLIT_FAIL; +} -- 2.1.0.rc1 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit