summaryrefslogtreecommitdiffstats
path: root/tests/compute/generics-overload-2.slang
blob: 8ca55ce7d847c31178bbc3be5d6ff056ee43d243 (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
//TEST(smoke,compute):COMPARE_COMPUTE: -shaderobj
//TEST(smoke,compute):COMPARE_COMPUTE:-cpu -shaderobj

// Test overload resolution for nested generic definitions

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


__generic<T : __BuiltinFloatingPointType>
struct Foo
{
	T test(uint index, T x)
    {
        return __realCast<T, float>(1.f);
	}

	__generic<let N: int>
	T test(vector<uint, N> index, T x)
    {
        return __realCast<T, float>(2.f);
	}
};


[numthreads(1, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
	uint tid = dispatchThreadID.x + 2;
	
	Foo<float> obj;

	float outVal = obj.test(tid, 0.f);
	outputBuffer[0] = outVal; // Expect: 1

	float outVal2 = obj.test(uint2(tid, tid), 0.f);
	outputBuffer[1] = outVal2; // Expect: 2
}