]> git.tdb.fi Git - libs/gl.git/blob - tests/glsl/function_overloading.glsl
Fix a test case and add a couple more
[libs/gl.git] / tests / glsl / function_overloading.glsl
1 uniform mat4 mvp;
2 uniform sampler2D tex;
3 uniform vec3 ambient;
4
5 vec3 srgb_to_linear(vec3 color)
6 {
7         bvec3 near_zero = lessThan(color, vec3(0.04045));
8         vec3 gamma = pow((color.rgb+0.055)/1.055, vec3(2.4));
9         return mix(color.rgb/12.92, gamma, near_zero);
10 }
11 vec4 srgb_to_linear(vec4 color)
12 {
13         return vec4(srgb_to_linear(color.rgb), color.a);
14 }
15
16 #pragma MSP stage(vertex)
17 layout(location=0) in vec4 position;
18 layout(location=1) in vec2 texcoord;
19 void main()
20 {
21         passthrough;
22         gl_Position = mvp*position;
23 }
24
25 #pragma MSP stage(fragment)
26 layout(location=0) out vec4 frag_color;
27 void main()
28 {
29         frag_color = srgb_to_linear(texture(tex, texcoord));
30 }
31
32 /* Expected output: vertex
33 uniform mat4 mvp;
34 layout(location=0) in vec4 position;
35 layout(location=1) in vec2 texcoord;
36 out vec2 _vs_out_texcoord;
37 void main()
38 {
39   _vs_out_texcoord = texcoord;
40   gl_Position = mvp*position;
41 }
42 */
43
44 /* Expected output: fragment
45 uniform sampler2D tex;
46 vec3 srgb_to_linear(vec3 color)
47 {
48   return mix(color.rgb/12.92, pow((color.rgb+0.055)/1.055, vec3(2.4)), lessThan(color, vec3(0.04045)));
49 }
50 vec4 srgb_to_linear(vec4 color)
51 {
52   return vec4(srgb_to_linear(color.rgb), color.a);
53 }
54 layout(location=0) out vec4 frag_color;
55 in vec2 _vs_out_texcoord;
56 void main()
57 {
58   frag_color = srgb_to_linear(texture(tex, _vs_out_texcoord));
59 }
60 */