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
766 B38 linesraw
1// init-list-defaults.slang
2//TEST(compute):COMPARE_COMPUTE: -shaderobj
3//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
4
5// Confirm that initializer lists correctly default-initialize elements past those specified.
6
7struct Test
8{
9	int4 a;
10	int b[4];
11}
12
13int test(int inVal)
14{
15	Test myArray[4] = {
16		{ int4(1), { 2, 3} },
17		{ {4, 5, 6, }, { 7, } },
18	};
19
20	return myArray[0].b[inVal]
21		+ myArray[1].a[inVal]*16
22		+ myArray[inVal].a.x*256
23		+ (inVal+1)*4096;
24}
25
26//TEST_INPUT:ubuffer(data=[9 9 9 9], stride=4):out,name=outputBuffer
27RWStructuredBuffer<int> outputBuffer;
28
29[numthreads(4, 1, 1)]
30void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
31{
32	uint tid = dispatchThreadID.x;
33
34	int inVal = int(tid);
35	int outVal = test(inVal);
36
37	outputBuffer[tid] = outVal;
38}