yum-mirror/slang

Making it easier to work with shaders

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

Yong HeImplement explciit binding for metal and wgsl. (#5778)7dabfa76c

master
922 B40 linesraw
1//TEST(compute):COMPARE_COMPUTE: -shaderobj
2//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
3
4// Test that a loop with multiple `continue` sites works.
5//
6// The current Slang codegen strategy for `continue` ends
7// up duplicating the "continue clause" for a `for` loop
8// at each `continue` site, so it will stress-test any
9// code that assumes a given instruction/block only
10// appears once in the region tree.
11//
12
13int test(int inVal)
14{
15	int ii = inVal;
16	for(;!bool(ii & 0x20); ii += 0x10)
17	{
18		if(ii == 2)
19		{
20			continue;
21		}
22
23		ii += 0x100;
24		// there is an implicit `continue` here
25	}
26
27	return ii;
28}
29
30//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer
31RWStructuredBuffer<int> outputBuffer;
32
33[numthreads(4, 1, 1)]
34void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
35{
36	uint tid = dispatchThreadID.x;
37	int inVal = outputBuffer[tid];
38	int outVal = test(inVal);
39	outputBuffer[tid] = outVal;
40}