Merge pull request #2976 from jeremy-lunarg/hayes-fix-2975
[platform/upstream/glslang.git] / Test / cppPassMacroName.frag
1 #define f1(i) ((i)*(i))
2 #define I2(f, n) f(n) + f(n+1)
3 #define I3(f, n) I2(f, n) + f(n+2)
4
5 #define FL_f1(i) ((i)*(i))
6 #define FL_I2(f, n) f(n) + f(n+0.2)
7 #define FL_I3(f, n) FL_I2(f, n) + f(n+0.5)
8
9 void main()
10 {
11     int f1 = 4;
12     int f2 = f1;
13     int f3 = f1(3);
14     int f4 = I2(f1, 0);
15     int f5 = I3(f1, 0);
16
17     highp float fl_f5 = FL_I3(FL_f1, 0.1);
18 }
19
20 // f5 = I3(f1, 0)
21 //    = I2(f1, 0) + f1(0 + 2)
22 //    = f1(0) + f1(0+1) + f1(0+2)
23 //    = 0*0 + 1*1 + 2*2
24 //    = 5
25
26 // fl_f5 = FL_I3(FL_f1, 0.1)
27 //       = FL_I2(FL_f1, 0.1) + FL_f1(0.1 + 0.5)
28 //       = FL_f1(0.1) + FL_f1(0.1 + 0.2) + FL_f1(0.1 + 0.5)
29 //       = 0.1*0.1 + 0.3*0.3 + 0.6*0.6
30 //       = 0.46