summaryrefslogtreecommitdiffstats
path: root/tests/compute/empty-struct2.slang
blob: 303cfd234e7d4e9b2dc6fa2672a94c84696aa258 (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
//TEST(smoke,compute):COMPARE_COMPUTE: -shaderobj
//TEST(smoke,compute):COMPARE_COMPUTE:-cpu -shaderobj

// This is a basic test for Slang compute shader.

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<uint> outputBuffer;

interface IInterface
{
    associatedtype T;
    T getT();
    [mutating]
    void setT(T val);
}
interface IEmptyS
{
    float emptyFunc();
};
struct EmptyS : IEmptyS
{
    float emptyFunc() {return 0.0;}    
};

struct Empty<TT : IEmptyS> : IInterface
{
    typedef TT T;
    TT value = TT();
    float a = 0;
    TT getT()
    {
        return value;
    }
    [mutating]
    void setT(TT val)
    {
        value = val;
        a = value.emptyFunc();
    }
}

void test<Obj : IInterface>(Obj obj)
{
    Obj.T v = obj.getT();
    obj.setT(v);
}

[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    Empty<EmptyS> obj;
    test(obj);
    outputBuffer[dispatchThreadID.x] = dispatchThreadID.x;
}