summaryrefslogtreecommitdiffstats
path: root/tests/hlsl-intrinsic/active-mask/switch.slang
blob: b74736677e06cea566d206aa74526aa8e2305e9d (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
// switch.slang

// Test active mask synthesis for a trivial `switch` statement

//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -xslang -DHACK -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -xslang -DHACK -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -render-features cuda_sm_7_0

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

#define THREAD_COUNT 4
#define LOC_COUNT 5
#define WRITE(LOC) buffer[tid + (LOC)*THREAD_COUNT] = 0xA0000000 | (tid << 24) | (LOC << 8) | int(WaveGetActiveMask())

//TEST_INPUT:cbuffer(data=[0 1]):name C
cbuffer C
{
	int alwaysFalse;
	int alwaysTrue;
}

void test(int tid)
{
	switch(tid)
	{
	case 0:
		WRITE(0);
		break;

	case 1:
		WRITE(1);
		break;

	case 2:
		WRITE(2);
		break;

	default:
		WRITE(3);
		break;
	}
	WRITE(4);
}

[numthreads(THREAD_COUNT, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
	test(dispatchThreadID.x);
}