]> git.tdb.fi Git - libs/gl.git/blob - tests/glsl/function_overloading.glsl
Implement textureSize as a visitor function in the SPIR-V generator
[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+0.055)/1.055, vec3(2.4));
9         return mix(color/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 layout(location=0) uniform mat4 mvp;
34 layout(location=0) in vec4 position;
35 layout(location=1) in vec2 texcoord;
36 layout(location=0) 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 layout(location=4, binding=71) uniform sampler2D tex;
46 layout(location=0) out vec4 frag_color;
47 layout(location=0) in vec2 _vs_out_texcoord;
48 void main()
49 {
50         vec4 color = texture(tex, _vs_out_texcoord);
51         vec3 color_1 = color.rgb;
52         frag_color = vec4(mix(color_1/12.92, pow((color_1+0.055)/1.055, vec3(2.4)), lessThan(color_1, vec3(0.04045))), color.a);
53 }
54 */