Merge pull request #2908 from Biswa96/cmake-spirv-remap
[platform/upstream/glslang.git] / Test / spv.1.4.OpSelect.frag
1 #version 450
2
3 struct S1 {
4     float a;
5     int b;
6 };
7
8 layout(location = 0) flat in S1 in1;
9 layout(location = 2) flat in S1 in2;
10 layout(location = 4) flat in int cond;
11
12 layout(location = 0) out float outv;
13
14 void fun1(){}
15 void fun2(){}
16
17 void main()
18 {
19     // glslang will only make OpSelect for very trivial looking expressions
20
21     float f1 = 1.0;
22     float f2 = 2.0;
23     outv = cond < 8 ? f1 : f2;           // in all versions
24
25     ivec4 iv1 = ivec4(f1);
26     ivec4 iv2 = ivec4(f2);
27     outv *= (cond > 0 ? iv1 : iv2).z;     // in all versions, but in 1.4 as scalar condition, not smeared ala mix()
28
29     mat3 m1 = mat3(1.0);
30     mat3 m2 = mat3(2.0);
31     outv *= (cond < 20 ? m1 : m2)[2][1];  // in 1.4, but not before
32
33     S1 fv = cond > 5 ? in1 : in2;         // in 1.4, but not before
34     outv *= fv.a;
35
36     cond > 0 ? fun1() : fun2();           // not allowed by any version
37 }