summaryrefslogtreecommitdiffstats
path: root/tests/spirv/mutating-method-syn.slang
blob: 14adc001f7e1ea55aabbb822744f030c22364e2e (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
// mutating-method-syn.slang
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute
// Test ability to directly output SPIR-V

interface IFoo
{
    [mutating]
    int bar(inout int y);
}

struct Val : IFoo
{
    int x;

    int bar(int y)
    {
        return x + y;
    }
}

int test<T:IFoo>(inout T f, inout int y)
{
    return f.bar(y);
}

//TEST_INPUT:set result = out ubuffer(data=[0 0 0 0], stride=4)

RWStructuredBuffer<int> result;
[numthreads(1,1,1)]
void computeMain()
{    
    Val v;
    int y = 0;
    v.x = 1;
    
    // CHECK: 1
    result[0] = test(v, y);
}