summaryrefslogtreecommitdiffstats
path: root/tests/bugs/gh-3818.slang
blob: 5b2c4db78142259b93a32c4d0fef24682401a4ac (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
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-shaderobj -output-using-type

interface IOperation
{
    [mutating]
    void Store(float v);

    float Load();
};

struct TOperationMax : IOperation
{
    float result;

    [mutating]
    void Store(float v)
    {
        result = v;
    }

    float Load()
    {
        return result;
    }
};

float Run(inout IOperation op, float val)
{
    op.Store(val);
    return op.Load();
}

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

[numthreads(4, 1, 1)]
[shader("compute")]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    TOperationMax opMax;
    opMax.result = 0.f;
    float val = 2.f;
    IOperation op = opMax;
    float result = Run(op, val);
    // CHECK: 2.0
    outputBuffer[0] = result;
}