|
1 | 1 | // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -fnative-half-type -verify %s |
2 | 2 | // expected-no-diagnostics |
3 | 3 |
|
4 | | -struct oneInt { |
5 | | - int i; |
6 | | -}; |
7 | | - |
8 | | -struct twoInt { |
9 | | - int aa; |
10 | | - int ab; |
11 | | -}; |
12 | | - |
13 | | -struct threeInts { |
14 | | - oneInt o; |
15 | | - twoInt t; |
16 | | -}; |
17 | | - |
18 | | -struct oneFloat { |
19 | | - float f; |
20 | | -}; |
21 | | -struct depthDiff { |
22 | | - int i; |
23 | | - oneInt o; |
24 | | - oneFloat f; |
25 | | -}; |
26 | | - |
27 | | -struct notHomogenous{ |
28 | | - int i; |
29 | | - float f; |
30 | | -}; |
31 | | - |
32 | | -struct EightElements { |
33 | | - twoInt x[2]; |
34 | | - twoInt y[2]; |
35 | | -}; |
36 | | - |
37 | | -struct EightHalves { |
38 | | -half x[8]; |
39 | | -}; |
40 | | - |
41 | | -struct intVec { |
42 | | - int2 i; |
43 | | -}; |
44 | | - |
45 | | -struct oneIntWithVec { |
46 | | - int i; |
47 | | - oneInt i2; |
48 | | - int2 i3; |
49 | | -}; |
50 | | - |
51 | | -struct weirdStruct { |
52 | | - int i; |
53 | | - intVec iv; |
54 | | -}; |
55 | 4 |
|
56 | 5 | _Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(int), ""); |
57 | 6 | _Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(float), ""); |
58 | 7 | _Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(float4), ""); |
59 | 8 | _Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(double2), ""); |
60 | | -_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(oneInt), ""); |
61 | | -_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(oneFloat), ""); |
62 | | -_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(twoInt), ""); |
63 | | -_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(threeInts), ""); |
64 | | -_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(notHomogenous), ""); |
65 | | -_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(depthDiff), ""); |
66 | | -_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(EightElements), ""); |
67 | | -_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(EightHalves), ""); |
68 | | -_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(oneIntWithVec), ""); |
69 | | -_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(weirdStruct), ""); |
| 9 | + |
70 | 10 | _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(RWBuffer<int>), ""); |
71 | 11 |
|
| 12 | +struct s { |
| 13 | + int x; |
| 14 | +}; |
72 | 15 |
|
73 | | -// arrays not allowed |
74 | | -_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(half[4]), ""); |
| 16 | +struct Empty {}; |
75 | 17 |
|
76 | 18 | template<typename T> struct TemplatedBuffer { |
77 | 19 | T a; |
78 | | - __hlsl_resource_t h; |
79 | 20 | }; |
80 | | -_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(TemplatedBuffer<int>), ""); |
81 | 21 |
|
82 | | -struct MyStruct1 : TemplatedBuffer<float> { |
83 | | - float x; |
| 22 | +template<typename T> struct TemplatedVector { |
| 23 | + vector<T, 4> v; |
84 | 24 | }; |
85 | | -_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(MyStruct1), ""); |
86 | 25 |
|
87 | | -struct MyStruct2 { |
88 | | - const TemplatedBuffer<float> TB[10]; |
89 | | -}; |
90 | | -_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(MyStruct2), ""); |
| 26 | +// structs not allowed |
| 27 | +_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(s), ""); |
| 28 | +_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(Empty), ""); |
| 29 | +_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(TemplatedBuffer<int>), ""); |
| 30 | +_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(TemplatedVector<int>), ""); |
91 | 31 |
|
92 | | -template<typename T> struct SimpleTemplate { |
93 | | - T a; |
94 | | -}; |
| 32 | +// arrays not allowed |
| 33 | +_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(half[4]), ""); |
95 | 34 |
|
96 | | -// though the element type is incomplete, the type trait should still technically return true |
97 | | -_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(SimpleTemplate<__hlsl_resource_t>), ""); |
| 35 | +typedef vector<int, 8> int8; |
| 36 | +// too many elements |
| 37 | +_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(int8), ""); |
98 | 38 |
|
99 | | -_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(SimpleTemplate<float>), ""); |
| 39 | +typedef int MyInt; |
| 40 | +_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(MyInt), ""); |
100 | 41 |
|
| 42 | +// bool and enums not allowed |
| 43 | +_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(bool), ""); |
| 44 | +_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(vector<bool, 2>), ""); |
101 | 45 |
|
102 | | -typedef int myInt; |
| 46 | +enum numbers { one, two, three }; |
103 | 47 |
|
104 | | -struct TypeDefTest { |
105 | | - int x; |
106 | | - myInt y; |
107 | | -}; |
| 48 | +_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(numbers), ""); |
| 49 | + |
| 50 | +// size exceeds 16 bytes, and exceeds element count limit after splitting 64 bit types into 32 bit types |
| 51 | +_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(double3), ""); |
108 | 52 |
|
109 | | -_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(TypeDefTest), ""); |
0 commit comments