yum-mirror/slang

Making it easier to work with shaders

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

kaizhangNVLower the priority of looking up the rank of scope (#5065)3240799c0

master
1.5 KiB65 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 0 0], stride=4):out,name=outputBuffer
10RWStructuredBuffer<uint> outputBuffer;
11
12namespace A1
13{
14    uint func()
15    {
16        return 1u;
17    }
18
19    namespace A2
20    {
21        uint func()
22        {
23            return 2u;
24        }
25
26        namespace A3
27        {
28            uint func()
29            {
30                return 3u;
31            }
32
33            uint test2()
34            {
35                return func();      // choose A3::func()
36            }
37        }
38
39        namespace A4
40        {
41            uint test()
42            {
43                return func();      // choose A2::func()
44            }
45        }
46    }
47}
48
49[numthreads(1, 1, 1)]
50[shader("compute")]
51void computeMain(uint3 threadID: SV_DispatchThreadID)
52{
53    using namespace A1;
54    using namespace A1::A2;
55    using namespace A1::A2::A3;
56    using namespace A1::A2::A4;
57    outputBuffer[0] = test();
58    // BUF: 2
59
60    outputBuffer[1] = func(); // choose the A1::func()
61    // BUF-NEXT: 1
62
63    outputBuffer[2] = test2();
64    // BUF-NEXT: 3
65}