Debian Codegraph @

clang/test/SemaHLSL/Types/Traits/IsTypedResourceElementCompatible.hlsl

raw
1 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -fnative-half-type -verify %s
2 // expected-no-diagnostics
3
4
5 _Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(int), "");
6 _Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(float), "");
7 _Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(float4), "");
8 _Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(double2), "");
9
10 // types must be complete
11 _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(RWBuffer<int>), "");
12 _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(__hlsl_resource_t), "");
13
14 struct notComplete;
15 _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(notComplete), "");
16
17
18 struct s {
19 int x;
20 };
21
22 struct Empty {};
23
24 template<typename T> struct TemplatedBuffer {
25 T a;
26 };
27
28 template<typename T> struct TemplatedVector {
29 vector<T, 4> v;
30 };
31
32 // structs not allowed
33 _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(s), "");
34 _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(Empty), "");
35 _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(TemplatedBuffer<int>), "");
36 _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(TemplatedVector<int>), "");
37
38 // arrays not allowed
39 _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(half[4]), "");
40
41 typedef vector<int, 8> int8;
42 // too many elements
43 _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(int8), "");
44
45 typedef int MyInt;
46 _Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(MyInt), "");
47
48 // bool and enums not allowed
49 _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(bool), "");
50 _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(vector<bool, 2>), "");
51
52 enum numbers { one, two, three };
53
54 _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(numbers), "");
55
56 // size exceeds 16 bytes, and exceeds element count limit after splitting 64 bit types into 32 bit types
57 _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(double3), "");
58