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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
//TEST:SIMPLE(filecheck=CHK):-target hlsl -stage compute -entry computeMain
//TEST:SIMPLE(filecheck=HLSL):-target hlsl -stage compute -entry computeMain
//TEST:SIMPLE(filecheck=GLSL):-target glsl -stage compute -entry computeMain
//TEST:SIMPLE(filecheck=SPV):-target spirv -stage compute -entry computeMain
// TODO: requires changes in parser
//static_assert(true, "PASS_global");
//static_assert(false, "FAIL_global");
__generic<T:IArithmetic>
void TEST_specialize()
{
static_assert(true, "TEST_specialize true");
static_assert(T is float, "TEST_specialize T_is_float");
static_assert(T is int, "TEST_specialize T_is_int");
}
void TEST_target_switch()
{
static_assert(false, "TEST_target_switch all");
__target_switch
{
case hlsl:
static_assert(false, "TEST_target_switch hlsl");
return;
case glsl:
static_assert(false, "TEST_target_switch glsl");
return;
default:
static_assert(false, "TEST_target_switch default");
return;
}
}
__generic<T:IArithmetic>
struct MyType
{
// TODO: requires changes in parser
//static_assert(true, "PASS_struct");
//static_assert(false, "FAIL_struct");
__init()
{
static_assert(true, "MyType init true");
static_assert(false, "MyType init false");
}
};
__generic<T:IFloat>
extension MyType<T>
{
};
[numthreads(1,1,1)]
void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
{
// CHK-DAG: error {{.*}} TEST_specialize T_is_int
// CHK-DAG:{{.*}} TEST_specialize<float>
TEST_specialize<float>();
// CHK-DAG: error {{.*}} TEST_specialize T_is_float
// CHK-DAG:{{.*}} TEST_specialize<int>
TEST_specialize<int>();
//HLSL: error {{.*}} TEST_target_switch all
//HLSL: error {{.*}} TEST_target_switch hlsl
//HLSL-NOT: error {{.*}} TEST_target_switch glsl
//HLSL-NOT: error {{.*}} TEST_target_switch default
//
//GLSL: error {{.*}} TEST_target_switch all
//GLSL-NOT: error {{.*}} TEST_target_switch hlsl
//GLSL: error {{.*}} TEST_target_switch glsl
//GLSL-NOT: error {{.*}} TEST_target_switch default
//
//SPV: error {{.*}} TEST_target_switch all
//SPV-NOT: error {{.*}} TEST_target_switch hlsl
//SPV-NOT: error {{.*}} TEST_target_switch glsl
//SPV: error {{.*}} TEST_target_switch default
//
TEST_target_switch();
//CHK-NOT: error {{.*}} MyType init true
//CHK: error {{.*}} MyType init false
MyType<float> obj;
//CHK: ([[#@LINE+1]]): error
static_assert(dispatchThreadID.x == 0, "not constant");
}
|