summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/glslang/src/Test/functionSemantics.frag
blob: 780a87966c8a87ead4fe961b843f708bc33d2c6e (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#version 400

uniform float u;

int foo(int a, const int b, in int c, const in int d, out int e, inout int f)
{
    int sum = a + b + c + d + f; // no e, it is out only
	// sum should be 47 now

	a *= 64;
	// no b, it is read only
	c *= 64;
	// no d, it is read only
	e = 64 * 16; // e starts undefined
	f *= 64;

	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
	// sum should be 4032 + 47  = 4079
	
	return sum;
}

int foo2(float a, vec3 b, out int r)
{
    r = int(3.0 * a);
    return int(5.0 * b.y);
}

int foo3()
{
    if (u > 3.2) {
        discard;
        return 1000000;
    }

    return 2000000;
}

void main()
{
    int e;
	int t = 2;
	struct s {
	    ivec4 t;
	} f;
	f.t.y = 32;

    // test the different qualifers
    int color = foo(1, 2, t+t, 8, e, f.t.y);

	color += 128 * (e + f.t.y); // right side should be 128(64(16 + 32)) = 393216
	// sum should be 4079 + 393216 = 397295
    
    // test conversions
    float arg;
    float ret;
    ret = foo2(4, ivec3(1,2,3), arg);  // ret = 10, param = 12.0
    color += int(ret + arg); // adds 22, for total of 397317

    color += foo3();         // theoretically, add 2000000, for total of 2397317

    gl_FragColor = vec4(color);
}

vec3 m(vec2);
void aggCall()
{
    float F;
    m(ivec2(F));  // test input conversion of single argument that's an aggregate; other function tests in 120.vert
}