blob: b7e8d6fa2f7c272972499497b18f9091f07247bb (
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
|
// generic-func-param-default-arg.slang
// Test that generic functions can have default argument values on their parameters.
//TEST(compute):COMPARE_COMPUTE: -shaderobj
//TEST_DISABLED:SIMPLE:-target hlsl -entry computeMain -dump-ir
interface IValue
{
__init();
This plusA(This other);
This plusB(int other);
}
T sum<T : IValue>(T value, T other = T(), int extra = 0)
{
return value.plusA(other).plusB(extra);
}
struct Simple : IValue
{
int val;
__init() { val = 0; }
__init(int val) { this.val = val; }
Simple plusA(Simple other) { return Simple(val + other.val); }
Simple plusB(int other) { return Simple(val + other); }
}
int test(int val)
{
let s = Simple(val);
return sum<Simple>(s).val + 16*sum(s).val;
}
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gBuffer
RWStructuredBuffer<int> gBuffer;
[shader("compute")]
[numthreads(4)]
void computeMain(int tid : SV_DispatchThreadID)
{
gBuffer[tid] = test(tid);
}
|