summaryrefslogtreecommitdiff
path: root/tests/hlsl-intrinsic/size-of/align-of.slang
blob: 537949375d0d0846c184d6d687fded769db8118a (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer

#pragma warning(disable:30816)

RWStructuredBuffer<int> outputBuffer;

enum Enum : int8_t
{
};

struct Hey
{
    double b;
    Enum e;
};

struct Thing : Hey
{
    int a;
    float b;
};

[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    const int idx = asint(dispatchThreadID.x);

    int a = alignof(idx);
    int b = alignof(int);
    int c = alignof(1 + 1);
    int d = alignof(Thing);

    float g[alignof(a)];

    int f[alignof(Thing) + alignof(float2) + alignof(g)]; 

    int size;

    switch (idx)
    {   
        default:
        case 0:     size = alignof(float); break;
        case 1:     size = alignof(float3); break;
        case 2:     size = alignof(matrix<uint, 3, 2>); break;
        case 3:     size = alignof(idx); break;
    }

    outputBuffer[idx] = size + a + b + c + d + alignof(f);
}