summaryrefslogtreecommitdiff
path: root/tests/hlsl-intrinsic/active-mask/if-conditional-exit.slang
blob: a8d533e8ebdda58f93f32549a600780f24ad1f67 (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
// if-conditional-exit.slang

// Test active mask synthesis for an `if` where one side
// conditionally exits the current function/scope,
// and thus may or may not "re-converge" after the
// conditional.

//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute 
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0
//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute
//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -capability 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 0 0 0 0 0 0 0], stride=4):out,name buffer
RWStructuredBuffer<int> buffer;

#define THREAD_COUNT 4
#define WRITE(IDX) buffer[IDX*THREAD_COUNT + tid] = WaveGetActiveMask()

void test(int tid)
{
	WRITE(0);
	if((tid & 1) != 0)
	{
		WRITE(1);
		if((tid & 2) != 0)
		{
			WRITE(2);
			return;
		}
		WRITE(3);
	}
	else
	{
		WRITE(4);
	}
	WRITE(5);
}

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