summaryrefslogtreecommitdiffstats
path: root/tests/compute/interface-static-method.slang
blob: bdfddd938bc9262c7db99747094e5faa6f6e8910 (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
// interface-static-method.slang

//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute
//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute

interface IHideout
{
	int getAnimalCount();	
}

interface ISuperhero
{
	associatedtype Hideout : IHideout;

	static Hideout getHideout();
}

struct Batcave : IHideout
{
	int batCount;	

	int getAnimalCount() { return batCount; }
}

struct Batman : ISuperhero
{
	typedef Batcave Hideout;

	static Batcave getHideout()
	{
		Batcave batcave = { 100 };
		return batcave;
	}
}

int doIt<T:ISuperhero>()
{
	return T.getHideout().getAnimalCount();
}

int test(int val)
{
	return doIt<Batman>();
}


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

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