yum-mirror/slang

Making it easier to work with shaders

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

kaizhangNVFeature/initialize list side branch (#6058)9ec6b9168

master
1.8 KiB67 linesraw
1// https://github.com/shader-slang/slang/issues/4476
2
3//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cuda -compute -shaderobj
4//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -shaderobj
5//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -shaderobj
6//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -dx12 -shaderobj
7//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -shaderobj
8
9//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
10RWStructuredBuffer<uint> outputBuffer;
11
12namespace A
13{
14    struct Struct1<let SIZE : uint>
15    {
16        uint data;
17    };
18
19    Struct1<Z1> myFunc<let Z0 : uint, let Z1 : uint>(Struct1<Z0> inputS1)
20    {
21        Struct1<Z1> s1;
22        s1.data = inputS1.data + 2U;
23        return s1;
24    }
25};
26
27
28A::Struct1<Z1> myFunc<let Z0 : uint, let Z1 : uint>(A::Struct1<Z0> inputS1)
29{
30    A::Struct1<Z1> s1;
31    s1.data = inputS1.data + 5U;
32    return s1;
33}
34
35namespace A
36{
37    struct Struct2<let SIZE : uint>
38    {
39        Struct1<SIZE> s1;
40    }
41
42    Struct2<Z1> myFunc<let Z0 : uint, let Z1 : uint>(Struct2<Z0> inputS2)
43    {
44        Struct2<Z1> s2;
45        // We want to cover a corner case in our compiler where:
46        // when looking up "myFunc", the compiler should find
47        //   Struct1<Z1> A::myFunc<let Z0 : uint, let Z1 : uint>(Struct1<Z0> inputS1)
48        // and it won't be ambiguous with the global "myFunc".
49        s2.s1 = myFunc<Z0, Z1>(inputS2.s1);
50        return s2;
51    }
52};
53
54[numthreads(1, 1, 1)]
55[shader("compute")]
56void computeMain(uint3 threadID: SV_DispatchThreadID)
57{
58    using namespace A;
59
60    Struct2<10> input = {{threadID.x}};
61
62    Struct2<20> output;
63    output = myFunc<10, 20>(input);
64    outputBuffer[0] = output.s1.data;
65
66    // BUF: 2
67}