]> git.tdb.fi Git - libs/gl.git/blob - tests/glsl/specialization_constants.glsl
Make ConstantConditionEliminator less trigger-happy
[libs/gl.git] / tests / glsl / specialization_constants.glsl
1 layout(constant_id=0) const bool use_texture = false;
2 layout(constant_id=1) const bool use_vertex_color = false;
3 uniform sampler2D tex;
4 uniform mat4 mvp;
5
6 #pragma MSP stage(vertex)
7 layout(location=0) in vec4 position;
8 layout(location=1) in vec4 color;
9 layout(location=2) in vec2 texcoord;
10 void main()
11 {
12         passthrough;
13         gl_Position = mvp*position;
14 }
15
16 #pragma MSP stage(fragment)
17 layout(location=0) out vec4 frag_color;
18 void main()
19 {
20         frag_color = vec4(1.0);
21         if(use_texture)
22                 frag_color *= texture(tex, texcoord);
23         if(use_vertex_color)
24                 frag_color *= color;
25 }
26
27 // Specialize: use_texture true
28
29 /* Expected output: vertex
30 uniform mat4 mvp;
31 layout(location=0) in vec4 position;
32 layout(location=2) in vec2 texcoord;
33 out vec2 _vs_out_texcoord;
34 void main()
35 {
36         _vs_out_texcoord = texcoord;
37         gl_Position = mvp*position;
38 }
39 */
40
41 /* Expected output: fragment
42 uniform sampler2D tex;
43 layout(location=0) out vec4 frag_color;
44 in vec2 _vs_out_texcoord;
45 void main()
46 {
47         frag_color = vec4(1.0);
48         frag_color *= texture(tex, _vs_out_texcoord);
49 }
50 */