summaryrefslogtreecommitdiffstats
path: root/tests/compute/inout.slang
blob: 5d1afaa799fdbc88348d46fc73fa5797ea36ceeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//TEST(compute):COMPARE_COMPUTE: -shaderobj
//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj

// Test that we correctly support both `out`
// and `inout` function parameters.

void testOut(int x, out int y)
{
	y = x;
}

void testInOut(int x, in out int y)
{
	y = y + x;
}

void testInout(int x, inout int y)
{
	y = y + x;	
}

int test(int inVal)
{
	int x0 = inVal;
	int x1;

	testOut(x0, x1);

	int x2 = x0;
	testInOut(x1, x2);

	int x3 = x0;
	testInout(x2, x3);

	return x3;
}

//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;

[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
	uint tid = dispatchThreadID.x;
	int inVal = outputBuffer[tid];
	int outVal = test(inVal);
	outputBuffer[tid] = outVal;
}