blob: e5c3ed00e99d403a53bc7483e2f59e73ad4a5c20 [file] [log] [blame]
John Kessenich2f21fcc2015-06-17 16:15:09 +00001#version 400
2
3uniform float u;
4
5int foo(int a, const int b, in int c, const in int d, out int e, inout int f)
6{
7 int sum = a + b + c + d + f; // no e, it is out only
8 // sum should be 47 now
9
10 a *= 64;
11 // no b, it is read only
12 c *= 64;
13 // no d, it is read only
14 e = 64 * 16; // e starts undefined
15 f *= 64;
16
17 sum += a + 64 * b + c + 64 * d + e + f; // everything has a value now, totaling of 64(1+2+4+8+16+32) = 64*63 = 4032
18 // sum should be 4032 + 47 = 4079
19
20 return sum;
21}
22
23int foo2(float a, vec3 b, out int r)
24{
25 r = int(3.0 * a);
26 return int(5.0 * b.y);
27}
28
29int foo3()
30{
31 if (u > 3.2) {
32 discard;
33 return 1000000;
34 }
35
36 return 2000000;
37}
38
39void main()
40{
41 int e;
42 int t = 2;
43 struct s {
44 ivec4 t;
45 } f;
46 f.t.y = 32;
47
48 // test the different qualifers
49 int color = foo(1, 2, t+t, 8, e, f.t.y);
50
51 color += 128 * (e + f.t.y); // right side should be 128(64(16 + 32)) = 393216
52 // sum should be 4079 + 393216 = 397295
53
54 // test conversions
55 float arg;
56 float ret;
57 ret = foo2(4, ivec3(1,2,3), arg); // ret = 10, param = 12.0
58 color += int(ret + arg); // adds 22, for total of 397317
59
60 color += foo3(); // theoretically, add 2000000, for total of 2397317
61
62 gl_FragColor = vec4(color);
63}
John Kessenich8ba301c2015-07-21 16:00:34 -060064
65vec3 m(vec2);
66void aggCall()
67{
68 float F;
69 m(ivec2(F)); // test input conversion of single argument that's an aggregate; other function tests in 120.vert
70}
John Kessenichbc17b0a2016-06-28 23:56:31 -060071
72vec4 badConv()
73{
74 return u; // ERROR, can change scalar to vector
75}