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
2.2 KiB74 linesraw
1// for-continue-ext.slang
2
3// Test case of a `for` loop that
4// has multiple paths to continue
5// the loop (both the ordinary one
6// and an explicit `continue`)
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 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 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 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 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 4
19#define ITER_COUNT THREAD_COUNT
20#define WRITE_VAL(LOC, ITER, VAL) buffer[tid + (LOC)*THREAD_COUNT + (ITER)*THREAD_COUNT*LOC_COUNT] = 0xA0000000 | (tid << 24) | (ITER << 16) | (LOC << 8) | VAL
21#define WRITE(LOC, ITER) WRITE_VAL(LOC, ITER, WaveGetActiveMask())
22
23//TEST_INPUT:cbuffer(data=[0 1]):name C
24cbuffer C
25{
26	int alwaysFalse;
27	int alwaysTrue;
28}
29
30void test(uint tid)
31{
32	for(int ii = 0; ii < tid; ++ii)
33	{
34		WRITE(0, ii);
35		if((tid & 1) != 0)
36		{
37			if((tid & 2) != 0)
38			{
39				// Note: because of the two `if(alwaysFalse) break;` branches
40				// here, the `WRITE(3,ii)` at the end of the loop body no
41				// longer post-dominates the entry to the `if`, so that
42				// implemenations that use immediate post-dominator
43				// reconvergence will not properly reconvergence lanes
44				// one and two at that point.
45				//
46				// The Slang synthesis pass for the active mask produces
47				// the expected/desired result even in the presence of
48				// these additional control-flow edges.
49			#ifndef HACK
50				if(alwaysFalse != 0) break;
51			#endif
52
53				WRITE(1, ii);
54				continue;
55			}
56			else
57			{
58			#ifndef HACK
59				if(alwaysFalse != 0) break;
60			#endif
61
62				WRITE(2, ii);
63			}
64		}
65		WRITE(3, ii);
66	}
67	WRITE(4, 0);
68}
69
70[numthreads(THREAD_COUNT, 1, 1)]
71void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
72{
73	test(dispatchThreadID.x);
74}