summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/namespaces/using-namespace.slang
blob: d558165709594274e9410e5aa41041658cff6732 (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
// using-namespace.slang

// Test that `using` can bring declarations from a namespace into scope

//TEST(compute):COMPARE_COMPUTE: -shaderobj

namespace X
{
	struct A { int a; }
}

namespace Y
{
	// A `using` that brings one namespace into scope of declarations in another
	//
    using X;

	int b(A a) { return a.a; }
}

// A `using` that brings declarations in a namespace into the global scope
//
using Y;

int test(int value)
{
	// A `using` that brings declarations into a local scope
	// (and also uses the optional `namespace` placeholder keyword)
	//
	using namespace X;

	A a = { value };
	return b(a);
}

//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;
}