summaryrefslogtreecommitdiffstats
path: root/tests/spirv/large-struct-pack.slang
blob: df15ac67c0c36b84182d8c539d5875cdcc9009ac (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
//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -profile glsl_460
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute

// Check that when generating spirv directly, we use a loop
// to copy large arrays in a local variable to a buffer, instead of emitting
// unrolled code that reads each element of the array individually.

struct WorkData
{
    int B[1024];
};

//TEST_INPUT:set resultBuffer = out ubuffer(data=[0 0 0 0], stride=4, count=1024)
RWStructuredBuffer<WorkData> resultBuffer;

// CHECK: OpLoopMerge
// CHECK: OpLoopMerge

// BUF: 0
// BUF: 1
[numthreads(1, 1, 1)]
void computeMain(uint3 tid: SV_DispatchThreadID)
{
    WorkData wd;
    for (int i = 0; i < 1024; i++)
        wd.B[i] = i;
    resultBuffer[0] = wd;
}