summaryrefslogtreecommitdiffstats
path: root/tests/wgsl/inout.slang
blob: 57f55ae3f86e852b80b1174620099e18f2e0cb53 (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:SIMPLE(filecheck=CHECK): -target wgsl

RWStructuredBuffer<float> outputBuffer;

// CHECK: fn inner{{.*}}( x{{.*}} : ptr<function, f32>)
// CHECK: (*x{{.*}}) = (*x{{.*}}) + 1.0
void inner(inout float x)
{
    x = x + 1;
}

// CHECK: fn test{{.*}}( x{{.*}} : ptr<function, f32>)
void test(inout float x)
{
    inner(x);
}

struct MyType
{
    float myField[3];
}

[numthreads(1,1,1)]
void computeMain(int id : SV_DispatchThreadID)
{
    MyType v;
    v.myField[id] = 0.0f;
    // CHECK: test{{.*}}(&({{.*}}));
    test(v.myField[id]);
    v.myField[1] = 2.0;
    outputBuffer[0] = v.myField[id];
}