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.2 KiB53 linesraw
1// switch-no-default.slang
2
3// Test active mask synthesis for a `switch` statement
4// with no `default` case (such that unhandled values
5// branch directly to the `break` target after the
6// `switch`).
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 -xslang -DHACK
11//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -xslang -DHACK
12//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -capability cuda_sm_7_0
13
14//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
15RWStructuredBuffer<int> buffer;
16
17#define THREAD_COUNT 4
18#define LOC_COUNT 5
19#define WRITE(LOC) buffer[tid + (LOC)*THREAD_COUNT] = 0xA0000000 | (tid << 24) | (LOC << 8) | WaveGetActiveMask()
20
21//TEST_INPUT:cbuffer(data=[0 1]):name C
22cbuffer C
23{
24	int alwaysFalse;
25	int alwaysTrue;
26}
27
28void test(int tid)
29{
30	switch(tid)
31	{
32	case 0:
33		WRITE(0);
34		break;
35
36	case 1:
37		WRITE(1);
38		break;
39
40	case 2:
41		WRITE(2);
42		break;
43
44	// NOTE: no `default:`
45	}
46	WRITE(4);
47}
48
49[numthreads(THREAD_COUNT, 1, 1)]
50void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
51{
52	test(dispatchThreadID.x);
53}