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.1 KiB56 linesraw
1//TEST:SIMPLE(filecheck=SPIRV): -target spirv -entry computeMain -stage compute
2
3cbuffer Test
4{
5//SPIRV: Offset 0
6    uint v0;
7
8//SPIRV: Offset 16
9    float3 v1;
10
11//SPIRV: Offset 32
12    uint3 v2;
13    
14//SPIRV: Offset 48
15    uint2 v3;
16
17//SPIRV: Offset 56
18    uint2 v4;
19
20//SPIRV: Offset 64
21    uint v5[4];
22
23//SPIRV: Offset 128
24    uint3 v6[2];
25};
26
27RWStructuredBuffer<int> outputBuffer;
28
29__generic<T : IArithmetic, let N : int>
30bool comp(vector<T,N> v1, vector<T,N> v2)
31{
32    for (uint i = 0; i < N; i++)
33        if (v1[i] != v2[i])
34            return false;
35
36    return true;
37}
38
39[shader("compute")]
40[numthreads(16, 16, 1)]
41void computeMain()
42{
43    outputBuffer[0] = (true
44            && v0 == 1
45            && comp(v1, float3( 2, 3, 4))
46            && comp(v2, uint3( 5, 6, 7))
47            && comp(v3, uint2( 8, 9 ))
48            && comp(v4, uint2( 10, 11 ))
49            && v5[0] == 12
50            && v5[1] == 13
51            && v5[2] == 14
52            && v5[3] == 15
53            && comp(v6[0], uint3( 16, 17, 18 ))
54            && comp(v6[1], uint3( 19, 20, 21 ))
55        ) ? 100 : 0;
56}