summaryrefslogtreecommitdiffstats
path: root/tests/metal/groupshared.slang
blob: d5fe3107e7fd85fece04eff328fb653ec59d3fa3 (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
//TEST:SIMPLE(filecheck=METAL): -target metal
//TEST:SIMPLE(filecheck=METALLIB): -target metallib
//TEST(compute, metal):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -output-using-type
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -output-using-type

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

struct MyBlock
{
    StructuredBuffer<float> b1;
    StructuredBuffer<float> b2;
}
ParameterBlock<MyBlock> block;

groupshared int myArr[16];

void func(float v)
{
    // BUF: 0.000000
    outputBuffer[0] = myArr[0];
}

// METAL: array<int, int(16)> threadgroup* myArr{{.*}};
// METAL: {{\[\[}}kernel{{\]\]}} void computeMain
// METAL: threadgroup array<int, int(16)> myArr{{.*}};
// METAL: (&kernelContext{{.*}})->myArr{{.*}} = &myArr{{.*}};
// METALLIB: define void @computeMain

[numthreads(1,1,1)]
void computeMain(uint3 tid: SV_DispatchThreadID)
{
    myArr[tid.x] = tid.x;
    func(3.0f);
}