yum-mirror/slang

Making it easier to work with shaders

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

skallweitNVenable more metal tests (#4326)712ce653d

master
930 B47 linesraw
1// using-namespace.slang
2
3// Test that `using` can bring declarations from a namespace into scope
4
5//TEST(compute):COMPARE_COMPUTE: -shaderobj
6
7namespace X
8{
9	struct A { int a; }
10}
11
12namespace Y
13{
14	// A `using` that brings one namespace into scope of declarations in another
15	//
16    using X;
17
18	int b(A a) { return a.a; }
19}
20
21// A `using` that brings declarations in a namespace into the global scope
22//
23using Y;
24
25int test(int value)
26{
27	// A `using` that brings declarations into a local scope
28	// (and also uses the optional `namespace` placeholder keyword)
29	//
30	using namespace X;
31
32	A a = { value };
33	return b(a);
34}
35
36//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
37RWStructuredBuffer<int> outputBuffer;
38
39[numthreads(4, 1, 1)]
40void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
41{
42    int tid = dispatchThreadID.x;
43    int inVal = tid;
44    int outVal = test(inVal);
45    outputBuffer[tid] = outVal;
46}
47