]> git.tdb.fi Git - libs/gl.git/blob - tests/glsl/keep_spec_constants_in_module.glsl
Make ConstantConditionEliminator less trigger-happy
[libs/gl.git] / tests / glsl / keep_spec_constants_in_module.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 // Compile mode: module
28
29 /* Expected output: vertex
30 uniform mat4 mvp;
31 layout(location=0) in vec4 position;
32 layout(location=1) in vec4 color;
33 layout(location=2) in vec2 texcoord;
34 out vec4 _vs_out_color;
35 out vec2 _vs_out_texcoord;
36 void main()
37 {
38         _vs_out_color = color;
39         _vs_out_texcoord = texcoord;
40         gl_Position = mvp*position;
41 }
42 */
43
44 /* Expected output: fragment
45 layout(constant_id=0) const bool use_texture = false;
46 layout(constant_id=1) const bool use_vertex_color = false;
47 uniform sampler2D tex;
48 layout(location=0) out vec4 frag_color;
49 in vec2 _vs_out_texcoord;
50 in vec4 _vs_out_color;
51 void main()
52 {
53   frag_color = vec4(1.0);
54   if(use_texture)
55     frag_color *= texture(tex, _vs_out_texcoord);
56   if(use_vertex_color)
57     frag_color *= _vs_out_color;
58 }
59 */