summaryrefslogtreecommitdiffstats
path: root/tests/bugs/gh-4467.slang
blob: dc97b9890d475f7e97750171c76d2878b0cb64fb (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
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK): -d3d12 -compute -shaderobj -output-using-type
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHK): -vk -compute -shaderobj -output-using-type


// Test that we can synthesize a [mutating] interface requirement from a nonmutating implementation,
// and the interface requirement signature contains an output interface-typed parameter.

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

interface IFoo
{
    int getVal();
};

interface IBar
{
    [mutating] void method(out IFoo o);
};

struct FooImpl : IFoo
{
    int x;
    int getVal() { return x; }
}

struct BarImpl : IBar
{
    void method(out IFoo o)
    {
        o = FooImpl(1);
    }
};

[numthreads(1,1,1)]
void computeMain()
{
    BarImpl bar;
    IFoo foo;
    bar.method(foo);
    // CHK: 1
    outputBuffer[0] = foo.getVal();
}