yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Yong HeDiagnose on use of struct inheritance. (#7419)4ae6e9d8b

master
1.2 KiB56 linesraw
1
2//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
4//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj
5//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
6//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj
7
8//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
9
10#pragma warning(disable:30816)
11
12RWStructuredBuffer<int> outputBuffer;
13
14enum Enum : int8_t
15{
16};
17
18struct Hey
19{
20    double b;
21    Enum e;
22};
23
24struct Thing : Hey
25{
26    int a;
27    float b;
28};
29
30[numthreads(4, 1, 1)]
31void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
32{
33    const int idx = asint(dispatchThreadID.x);
34
35    int a = alignof(idx);
36    int b = alignof(int);
37    int c = alignof(1 + 1);
38    int d = alignof(Thing);
39
40    float g[alignof(a)];
41
42    int f[alignof(Thing) + alignof(float2) + alignof(g)]; 
43
44    int size;
45
46    switch (idx)
47    {   
48        default:
49        case 0:     size = alignof(float); break;
50        case 1:     size = alignof(float3); break;
51        case 2:     size = alignof(matrix<uint, 3, 2>); break;
52        case 3:     size = alignof(idx); break;
53    }
54
55    outputBuffer[idx] = size + a + b + c + d + alignof(f);
56}