forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverload-ambiguous.slang
63 lines (51 loc) · 1.4 KB
/
overload-ambiguous.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
// https://github.com/shader-slang/slang/issues/4476
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cuda -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -dx12 -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -shaderobj
//TEST_INPUT:ubuffer(data=[0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<uint> outputBuffer;
uint getData()
{
return 1u;
}
struct DataObtainer
{
uint data;
uint getData()
{
return data;
}
uint getValue()
{
return getData(); // will call DataObtainer::getData()
}
uint getValue2()
{
return ::getData(); // will call global getData()
}
}
uint myFunc(uint a)
{
return a + 1u;
}
__generic<T: __BuiltinIntegerType>
uint myFunc(T a)
{
uint b = __intCast<uint, T>(a);
return b + 2u;
}
[numthreads(1, 1, 1)]
[shader("compute")]
void computeMain(uint3 threadID: SV_DispatchThreadID)
{
DataObtainer obtainer = {2u};
outputBuffer[0] = obtainer.getValue();
outputBuffer[1] = obtainer.getValue2();
uint a = 1u;
outputBuffer[2] = myFunc(a); // will call myFunc(uint) which more specialized
// BUF: 2
// BUF-NEXT: 1
// BUF-NEXT: 2
}