summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/zero-initialize/struct-some-zero-init.slang
blob: 1aad2053461c7cfd84c7641a4bc8814b2a2d6ba5 (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
//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain -zero-initialize
// CHECK-COUNT-2: {{.* }}= 0;

//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize
//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl -xslang -zero-initialize
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl -xslang -zero-initialize
//DISABLE_TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -compute -entry computeMain -allow-glsl -xslang -zero-initialize

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

struct MyStruct_base
{
    int a = 1;
    int b;
};
struct MyStruct : MyStruct_base
{
    int c = 1;
    int d;
};
MyStruct getStruct()
{
    MyStruct myStruct;
    return myStruct;
}
[numthreads(1, 1, 1)]
void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
{
    MyStruct myStruct = getStruct();

// BUF: 1
    outputBuffer[0] = true
        && myStruct.a == 1
        && myStruct.b == 0
        && myStruct.c == 1
        && myStruct.d == 0
        ;
}