From 804b3a42b84efa8a8176f68766c016292309e09c Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 4 Mar 2021 14:50:46 +0200 Subject: [PATCH] Add some test cases to test shader validation --- tests/glsl/block_name_conflict.glsl | 47 +++++++++++++++++++++++++++++ tests/glsl/identifier_conflict.glsl | 31 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 tests/glsl/block_name_conflict.glsl create mode 100644 tests/glsl/identifier_conflict.glsl diff --git a/tests/glsl/block_name_conflict.glsl b/tests/glsl/block_name_conflict.glsl new file mode 100644 index 00000000..e397b551 --- /dev/null +++ b/tests/glsl/block_name_conflict.glsl @@ -0,0 +1,47 @@ +#pragma MSP stage(vertex) +layout(location=0) in vec4 position; +out Output +{ + vec2 texcoord; +} vs_out; +out vec4 Output; +void Output(); +void main() +{ + vs_out.texcoord = position.xy*0.5+0.5; + gl_Position = position; +} + +#pragma MSP stage(geometry) +layout(triangles) in; +layout(triangles, max_vertices=3) out; +in Output +{ + vec2 texcoord; +} vs_out[]; +out Output +{ + vec2 texcoord; +} gs_out; +out Output +{ + vec4 color; +}; +void main() +{ + for(int i=0; i<3; ++i) + { + gs_out.texcoord = vs_out[i].texcoord; + gl_Position = gl_in[i].gl_Position; + EmitVertex(); + } +} + +/* Expected error: +:7: Multiple definition of 'Output' +:3: Previous definition is here +:8: Multiple definition of 'Output' +:3: Previous definition is here +:26: Multiple definition of 'Output' +:22: Previous definition is here +*/ diff --git a/tests/glsl/identifier_conflict.glsl b/tests/glsl/identifier_conflict.glsl new file mode 100644 index 00000000..3e10089b --- /dev/null +++ b/tests/glsl/identifier_conflict.glsl @@ -0,0 +1,31 @@ +#pragma MSP stage(vertex) +layout(location=0) in vec4 position; +out VertexOut +{ + vec2 texcoord; +} vs_out; +vec3 normal; +out VertexOut2 +{ + vec2 texcoord; + vec3 normal; +}; +vec2 texcoord; +void main() +{ + vec2 texcoord; + gl_Position = position; +} +vec2 texcoord() +{ + return vec2(0.0); +} + +/* Expected error: +:11: Multiple definition of 'normal' +:7: Previous definition is here +:13: Multiple definition of 'texcoord' +:10: Previous definition is here +:19: Multiple definition of 'texcoord' +:10: Previous definition is here +*/ -- 2.43.0