forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpointer-emit.slang
71 lines (59 loc) · 1.33 KB
/
pointer-emit.slang
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
// Test emitting logic of pointer types.
struct Something
{
int4 field0;
int field1;
};
struct ArrayType
{
Something data[2];
};
ArrayType getArray()
{
ArrayType rs;
rs.data[0].field0 = int4(1,2,3,4);
rs.data[0].field1 = 1;
rs.data[1].field0 = int4(2,3,4,5);
rs.data[1].field1 = 2;
return rs;
}
int inoutFunc(in out int param,
int[2] arrayParam,
out int[2] arrayOut,
Something s0,
out Something s1)
{
int v = 1;
param = v + 1;
arrayOut[0] = arrayParam[0];
arrayOut[1] = arrayParam[1];
s1.field1 = s0.field1 + 1;
return param;
}
static int globalVar = 1;
int test(int inVal)
{
int p = inVal;
int t1[2] = {1, 2};
int t2[2] = {0, 0};
Something s, s_out;
s.field1 = -1;
s.field1 = s.field1 - 1;
s.field0[0] = 1;
int4 localVector = int4(1,2,3,4);
localVector.x = 2;
var array = getArray();
return inoutFunc(p, t1, t2, s, s_out) + t2[0] + s_out.field1 +
s.field0[0] + localVector.x + array.data[1].field1 + globalVar;
}
//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer : register(u0);
[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;
}