yum-mirror/slang

Making it easier to work with shaders

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

ArielG-NVImplement `-fvk-use-dx-layout` (#4912)e1c6fecd9

master
1.5 KiB73 linesraw
1//IGNORE_TEST:SIMPLE(filecheck=SPIRV): -target spirv -entry computeMain -stage compute -fvk-use-dx-layout
2
3// 'tbuffer' is not implemented for SPIRV targets currently.
4
5tbuffer Test
6{
7//SPIRV: Offset 0
8    uint v0;
9//SPIRV: Offset 4
10    float3 v1;
11
12//SPIRV: Offset 16
13    uint3 v2;
14
15//SPIRV: Offset 32
16    uint2 v3;
17//SPIRV: Offset 40
18    uint2 v4;
19
20//SPIRV: Offset 48
21    uint v5[4];
22
23// array always starts on a new register.
24//SPIRV: Offset 112
25    uint3 v6[2];
26//SPIRV: Offset 140
27// non-array can pack with a partially filled register
28    uint v7;
29
30//SPIRV: Offset 144
31    uint2 v8;
32
33// SPIRV: Offset 160
34// array always starts on a new register.
35    uint v9[2];
36};
37
38RWStructuredBuffer<int> outputBuffer;
39
40__generic<T : IArithmetic, let N : int>
41bool comp(vector<T,N> v1, vector<T,N> v2)
42{
43    for (uint i = 0; i < N; i++)
44        if (v1[i] != v2[i])
45            return false;
46
47    return true;
48}
49
50[shader("compute")]
51[numthreads(2, 2, 1)]
52void computeMain()
53{
54    // CHECK: 64
55
56    outputBuffer[0] = (true
57            && v0 == 1
58            && comp(v1, float3(2, 3, 4))
59            && comp(v2, uint3(5, 6, 7))
60            && comp(v3, uint2(8, 9))
61            && comp(v4, uint2(10, 11))
62            && v5[0] == 12
63            && v5[1] == 13
64            && v5[2] == 14
65            && v5[3] == 15
66            && comp(v6[0], uint3(16, 17, 18))
67            && comp(v6[1], uint3(19, 20, 21))
68            && v7 == 22
69            && comp(v8, uint2(23, 24))
70            && v9[0] == 25
71            && v9[1] == 26
72        ) ? 100 : 0;
73}