From: Mikko Rasa Date: Fri, 9 Apr 2021 14:44:53 +0000 (+0300) Subject: Add a couple more test cases X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=4c156a7e2ad1e15719c879e132d764d37d8edb3e;p=libs%2Fgl.git Add a couple more test cases --- diff --git a/tests/glsl/invalid_return.glsl b/tests/glsl/invalid_return.glsl new file mode 100644 index 00000000..9a252599 --- /dev/null +++ b/tests/glsl/invalid_return.glsl @@ -0,0 +1,15 @@ +#pragma MSP stage(vertex) +layout(location=0) in vec4 position; +float func() +{ +} +void main() +{ + gl_Position = position*func(); + return 0; +} + +/* Expected error: +:3: Missing return statement at the end of a function not returning 'void' +:9: Return expression type 'int' is incompatible with declared return type 'void' +*/ diff --git a/tests/glsl/swizzle_assignment.glsl b/tests/glsl/swizzle_assignment.glsl new file mode 100644 index 00000000..521a8c46 --- /dev/null +++ b/tests/glsl/swizzle_assignment.glsl @@ -0,0 +1,67 @@ +uniform sampler2D tex; +uniform Transform +{ + mat4 model_matrix; + mat4 vp_matrix; +}; +uniform Lighting +{ + vec3 light_dir; + vec3 light_color; +}; + +#pragma MSP stage(vertex) +layout(location=0) in vec4 position; +layout(location=1) in vec3 normal; +layout(location=2) in vec2 texcoord; +void main() +{ + passthrough; + out vec3 world_normal = mat3(model_matrix)*normal; + gl_Position = vp_matrix*model_matrix*position; +} + +#pragma MSP stage(fragment) +layout(location=0) out vec4 frag_color; +void main() +{ + frag_color = texture(tex, texcoord); + frag_color.rgb *= max(dot(normalize(world_normal), light_dir), 0.0)*light_color; +} + +/* Expected output: vertex +layout(binding=48) uniform Transform +{ + mat4 model_matrix; + mat4 vp_matrix; +}; +layout(location=0) in vec4 position; +layout(location=1) in vec3 normal; +layout(location=2) in vec2 texcoord; +layout(location=0) out vec2 _vs_out_texcoord; +layout(location=1) out vec3 world_normal; +void main() +{ + _vs_out_texcoord = texcoord; + mat4 _temp = model_matrix; + world_normal = mat3(_temp[0].xyz, _temp[1].xyz, _temp[2].xyz)*normal; + gl_Position = vp_matrix*model_matrix*position; +} +*/ + +/* Expected output: fragment +layout(location=0, binding=71) uniform sampler2D tex; +layout(binding=5) uniform Lighting +{ + vec3 light_dir; + vec3 light_color; +}; +layout(location=0) out vec4 frag_color; +layout(location=0) in vec2 _vs_out_texcoord; +layout(location=1) in vec3 world_normal; +void main() +{ + frag_color = texture(tex, _vs_out_texcoord); + frag_color.rgb *= max(dot(normalize(world_normal), light_dir), 0.0)*light_color; +} +*/