summaryrefslogtreecommitdiffstats
path: root/tests/compute/globalTypeParamArrayShared.slang
blob: ee3caa372672a99e0c75592e49dda98394a11f72 (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
//TEST_IGNORE_FILE:
interface IBase
{
    float compute<T>(T g);
}
struct Base:IBase
{
    float b;
    float compute<T>(T g) { return b; }
};

struct Pair<T1:IBase, T2:IBase> : IBase
{
    T1 head;
    T2 tail;
    float compute<T>(T g)
    {
        return head.compute(g) + tail.compute(g);
    }
};

struct Arr<T:IBase, let N:int> : IBase
{
    T base[N];  // = 1.0
    float compute<T>(T g)
    {
        float sum = 0.0;
        for (int i = 0; i < N; i++)
            sum += base[i].compute(g);
        return sum;
    }
};