yum-mirror/slang

Making it easier to work with shaders

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

James Helferty (NVIDIA)render-test: Change D3D12 default to sm_6_5 (#8320)f02b08490

master
1.1 KiB45 linesraw
1// if-conditional-exit.slang
2
3// Test active mask synthesis for an `if` where one side
4// conditionally exits the current function/scope,
5// and thus may or may not "re-converge" after the
6// conditional.
7
8//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute 
9//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
10//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0
11//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute
12//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -capability cuda_sm_7_0
13
14
15//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
16RWStructuredBuffer<int> buffer;
17
18#define THREAD_COUNT 4
19#define WRITE(IDX) buffer[IDX*THREAD_COUNT + tid] = WaveGetActiveMask()
20
21void test(int tid)
22{
23	WRITE(0);
24	if((tid & 1) != 0)
25	{
26		WRITE(1);
27		if((tid & 2) != 0)
28		{
29			WRITE(2);
30			return;
31		}
32		WRITE(3);
33	}
34	else
35	{
36		WRITE(4);
37	}
38	WRITE(5);
39}
40
41[numthreads(THREAD_COUNT, 1, 1)]
42void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
43{
44	test(dispatchThreadID.x);
45}