File: cppPassMacroName.frag

package info (click to toggle)
glslang 16.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 51,084 kB
  • sloc: cpp: 90,714; yacc: 4,243; sh: 603; python: 305; ansic: 94; javascript: 74; makefile: 17
file content (30 lines) | stat: -rw-r--r-- 669 bytes parent folder | download | duplicates (19)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#define f1(i) ((i)*(i))
#define I2(f, n) f(n) + f(n+1)
#define I3(f, n) I2(f, n) + f(n+2)

#define FL_f1(i) ((i)*(i))
#define FL_I2(f, n) f(n) + f(n+0.2)
#define FL_I3(f, n) FL_I2(f, n) + f(n+0.5)

void main()
{
    int f1 = 4;
    int f2 = f1;
    int f3 = f1(3);
    int f4 = I2(f1, 0);
    int f5 = I3(f1, 0);

    highp float fl_f5 = FL_I3(FL_f1, 0.1);
}

// f5 = I3(f1, 0)
//    = I2(f1, 0) + f1(0 + 2)
//    = f1(0) + f1(0+1) + f1(0+2)
//    = 0*0 + 1*1 + 2*2
//    = 5

// fl_f5 = FL_I3(FL_f1, 0.1)
//       = FL_I2(FL_f1, 0.1) + FL_f1(0.1 + 0.5)
//       = FL_f1(0.1) + FL_f1(0.1 + 0.2) + FL_f1(0.1 + 0.5)
//       = 0.1*0.1 + 0.3*0.3 + 0.6*0.6
//       = 0.46