summaryrefslogtreecommitdiffstats
path: root/tests/compute/struct-make.slang
blob: b7adf4e838c7601fe739f3e63f32230b91624570 (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
// scope.slang
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj

// Confirm that scoping on enums and types works 

struct Thing
{
    int a;
    static Thing make(int v)
    {
        Thing thing;
        thing.a = v;
        return thing;
    }
};

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

[numthreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
    int tid = dispatchThreadID.x;

    Thing thing = Thing::make(tid);

    outputBuffer[tid] = thing.a;
}