summaryrefslogtreecommitdiff
path: root/tests/experiments/generic/type-inference-3.slang
blob: 82691d8c3d50b6cc29460c68a8c22925527a4512 (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
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj

/* A test of a generic functions with type inference.

.slang(5): internal error 99999: unimplemented feature in Slang compiler: swizzle on vector of unknown size
    return val.x;

Sort of plausible and in general. But .x would work for any size of vector. 
 */

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

T getFirst<T, let N : int>(vector<T, N> val)
{
    return val.x;
}
    
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{    
    int index = dispatchThreadID.x;

    float4 values = { 1, 2, 3, 4 };
    
    let val = getFirst(values);
    
	outputBuffer[index] = val;
}