yum-mirror/slang

Making it easier to work with shaders

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

Yong HeSupport all integer typed indices in StructuredBuffer Load/Store/[]. (#4311)b5cdd8322

master
776 B45 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage compute -entry main
2RWStructuredBuffer<float> result;
3
4[ForceInline]
5float myF(inout int a, int b)
6{
7    return a + b;
8}
9
10[ForceInline]
11float myF(inout uint a, uint b)
12{
13    return a - b;
14}
15
16[ForceInline]
17T myGenF<T : __BuiltinIntegerType>(inout T a, T b)
18{
19    if (__isSignedInt<T>())
20    {
21        return a + b;
22    }
23    else
24    {
25        return a - b;
26    }
27}
28// CHECK: result{{.*}}[int(0)] = 1
29// CHECK: result{{.*}}[int(1)] = 4
30// CHECK: result{{.*}}[int(2)] = 1
31// CHECK: result{{.*}}[int(3)] = 4
32[numthreads(1,1,1)]
33void main()
34{
35    int ic = 1;
36    uint a = 2;
37    result[0] = myF(a, ic);
38
39    int b = 3;
40    uint uc = 1;
41    result[1] = myF(b, uc);
42
43    result[2] = myGenF(a, ic);
44    result[3] = myGenF(b, uc);
45}