summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/namespaces/multiple-namespace.slang
blob: f8ad2eda0fb673896b8839e3a73a12494e1a86a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// multiple-namespace.slang

//TEST(compute):COMPARE_COMPUTE: -shaderobj

// Multiple namespace open/closing

namespace A
{
    struct Struct1
    {
        int a;
    }
}

namespace A
{
    struct Struct2
    {
        int b;
    }
}

namespace A
{
    struct Struct3
    {
        int c;
    }
}
   
// A few more 

namespace A {}
namespace A {}
namespace A { namespace A {} }
   
int test(int val)
{
    A.Struct1 s1 = {};
    A::Struct2 s2 = { val };
    A.Struct3 s3 = { val * val };
    
    return s1.a + s2.b + s3.c;
}

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;

[numthreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
    int tid = dispatchThreadID.x;
    int inVal = tid;
    int outVal = test(inVal);
    outputBuffer[tid] = outVal;
}