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
794 B48 linesraw
1//TEST(compute):COMPARE_COMPUTE: -shaderobj
2//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
3
4// Test that we correctly support both `out`
5// and `inout` function parameters.
6
7void testOut(int x, out int y)
8{
9	y = x;
10}
11
12void testInOut(int x, in out int y)
13{
14	y = y + x;
15}
16
17void testInout(int x, inout int y)
18{
19	y = y + x;	
20}
21
22int test(int inVal)
23{
24	int x0 = inVal;
25	int x1;
26
27	testOut(x0, x1);
28
29	int x2 = x0;
30	testInOut(x1, x2);
31
32	int x3 = x0;
33	testInout(x2, x3);
34
35	return x3;
36}
37
38//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer
39RWStructuredBuffer<int> outputBuffer;
40
41[numthreads(4, 1, 1)]
42void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
43{
44	uint tid = dispatchThreadID.x;
45	int inVal = outputBuffer[tid];
46	int outVal = test(inVal);
47	outputBuffer[tid] = outVal;
48}