yum-mirror/slang

Making it easier to work with shaders

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

skallweitNVenable more metal tests (#4326)712ce653d

master
918 B42 linesraw
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -output-using-type
2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -output-using-type
3
4interface IFoo<let n: uint>
5{
6    static int sum(int arr[n]);
7}
8
9struct MyType<let n:uint> : IFoo<n>
10{
11    static int sum(int arr[n])
12    {
13        int rs = 0;
14        for (int i = 0; i < n; i++)
15            rs += arr[i];
16        return rs;
17    }
18}
19
20int test<let n:uint>(IFoo<n> foo)
21{
22    int arr[n];
23    for (int i =0; i < n; i++)
24        arr[i] = i;
25    return foo.sum(arr);
26}
27
28//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
29RWStructuredBuffer<int> outputBuffer;
30
31[numthreads(1, 1, 1)]
32void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
33{
34    MyType<3> t;
35    test(t);
36    // CHECK: 3
37    outputBuffer[0] = test(t);
38
39    int arr[3] = {1,2,3};
40    // CHECK: 3
41    outputBuffer[1] = MyType<3>.sum(arr);
42}