forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathop-assignment-unify.slang
44 lines (31 loc) · 950 Bytes
/
op-assignment-unify.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
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -vk
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -cpu
//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0], stride=4):out,name outputBuffer
RWStructuredBuffer<uint> outputBuffer;
void silly<T : __BuiltinIntegerType>(T a, inout T b)
{
b *= a;
}
void silly2<T : __BuiltinIntegerType>(T a, out T b)
{
b = a;
}
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
int v = 0;
uint u = 0;
int idx = int(dispatchThreadID.x);
uint uidx = uint(idx);
v += uidx;
u += idx;
silly(u, v);
silly(v, u);
// Check that detects issues with undefined variables.
int undef1, undef2; // undefined
// Downstream compilers detect this...
//silly(u, undef1);
silly2(u, undef2);
outputBuffer[idx] = u + v + undef2;
}