blob: 35b0a3b2330ad57afdae4a343fc42b78b4757d17 (
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
|
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -vk
// Test that `is` operator works on generic type param.
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;
interface I
{
}
struct A : I
{
uint i;
};
struct B : I
{
float2 f2 = float2(0.0f);
};
func test<T : I>(T t) -> int
{
int rs = 0;
if (T is A)
{
rs++;
}
if (T is B)
{
rs+=2;
}
return rs;
}
[shader("compute")]
[numthreads(1,1, 1)]
void computeMain()
{
B b = {};
// CHECK: 2
outputBuffer[0] = test(b);
}
|