summaryrefslogtreecommitdiffstats
path: root/tests/bugs/op-assignment-unify-vec.slang
blob: 4cc3154a0e322aa9c6aeae3cdea450a354a69f3f (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
//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, let N : int>(vector<T, N> a, inout vector<T, N> b)
{
    b *= a;
}

void silly2<T : __BuiltinIntegerType, let N : int>(vector<T, N> a, out vector<T, N> b)
{
    b = a;
}


[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    int2 v = int2(0, 0);
    uint2 u = uint2(0, 0);

    int idx = int(dispatchThreadID.x);
    
    uint2 uidx = uint2(idx, idx * idx);

    v += uidx;
    u += idx;

    silly(u, v);
    silly(v, u);

    // Check that detects issues with undefined variables.

    int2 undef1, undef2;          // undefined
    // Downstream compilers detect this
    //silly(u, undef1);
    silly2(u, undef2);
    
    uint2 added = (u + v + undef2);

    outputBuffer[idx] = added.x + added.y;
}