xref: /aosp_15_r20/external/angle/third_party/glslang/src/Test/spv.debugInfo.frag (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1#version 450
2
3struct S {
4    int a;
5};
6
7uniform ubuf {
8    S s;
9};
10
11uniform sampler2D s2d;
12
13layout(location = 0) in vec4 inv;
14layout(location = 0) out vec4 outv;
15
16vec4 foo(S s)
17{
18    vec4 r = s.a * inv;
19    ++r;
20    if (r.x > 3.0)
21        --r;
22    else
23        r *= 2;
24
25    return r;
26}
27
28float testBranch(float x, float y)
29{
30    float result = 0;
31    bool b = x > 0;
32
33    // branch with load
34    if (b) {
35        result += 1;
36    }
37    else {
38        result -= 1;
39    }
40
41    // branch with expression
42    if (x > y) {
43        result += x - y;
44    }
45
46    // selection with load
47    result += b ?
48        1 : -1;
49
50    // selection with expression
51    result += x < y ?
52        y :
53        float(b);
54
55    return result;
56}
57
58void main()
59{
60    outv = foo(s);
61    outv += testBranch(inv.x, inv.y);
62    outv += texture(s2d, vec2(0.5));
63
64    switch (s.a) {
65    case 10:
66        ++outv;
67        break;
68    case 20:
69        outv = 2 * outv;
70        ++outv;
71        break;
72    default:
73        --outv;
74        break;
75    }
76
77    for (int i = 0; i < 10; ++i)
78        outv *= 3.0;
79
80    outv.x < 10.0 ?
81        outv = sin(outv) :
82        outv = cos(outv);
83}