blob: 2bf2bb5084c0781b803ca184c33ed7401ea84085 (
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// simple-namespace.slang
//TEST(compute):COMPARE_COMPUTE: -shaderobj
// Test that simple `namespace` declarations work as expected
// Test that the global scope operator `::` works as expected
namespace A
{
static int num = 16;
struct X
{
int val;
int getVal()
{
return val;
}
}
}
namespace B
{
struct X
{
int head;
int tail;
int getHead() { return head; }
int getTail() { return tail; }
}
X makeX(int h, int t)
{
X result = { h, t };
return result;
}
}
namespace A
{
X makeX(int v)
{
X result = { v };
return result;
}
}
int test(int val)
{
A.X a = A::makeX(val);
// Use the global scope operator "::A::num" to access the static member of namespace A
// Test it with mul operator
int num = 16*::A::num;
B::X b = B.makeX(val*16, val*num);
return a.getVal() + b.getHead() + b.getTail();
}
//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;
}
|