clang 24.0.0git
hlsl_detail.h
Go to the documentation of this file.
1//===----- hlsl_detail.h - HLSL definitions for intrinsics ----------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _HLSL_HLSL_DETAILS_H_
10#define _HLSL_HLSL_DETAILS_H_
11
12namespace hlsl {
13
14namespace __detail {
15
16constexpr double Pi = 3.14159265358979323846L;
17
18template <typename T, typename U> struct is_same {
19 static const bool value = false;
20};
21
22template <typename T> struct is_same<T, T> {
23 static const bool value = true;
24};
25
26template <bool B, typename T> struct enable_if {};
27
28template <typename T> struct enable_if<true, T> {
29 using Type = T;
30};
31
32template <bool B, class T = void>
34
35template <typename T> struct type_identity {
36 using Type = T;
37};
38
39template <typename T> using type_identity_t = typename type_identity<T>::Type;
40
41template <typename T> struct is_arithmetic {
42 static const bool Value = __is_arithmetic(T);
43};
44
45template <typename T> struct elem_type {
46 using Type = T;
47};
48template <typename T, int N> struct elem_type<vector<T, N>> {
49 using Type = T;
50};
51template <typename T, int R, int C> struct elem_type<matrix<T, R, C>> {
52 using Type = T;
53};
54template <typename T> using elem_type_t = typename elem_type<T>::Type;
55
57 heap_resource_info operator[](uint32_t Index) {
58 return heap_resource_info{Index};
59 }
60};
61
63 heap_sampler_info operator[](uint32_t Index) {
64 return heap_sampler_info{Index};
65 }
66};
67
68} // namespace __detail
69
70template <typename U, typename T, int R, int C>
71constexpr __detail::enable_if_t<sizeof(U) == sizeof(T), matrix<U, R, C>>
72bit_cast(matrix<T, R, C> M) {
73 return __builtin_bit_cast(matrix<U, R, C>, M);
74}
75
76template <typename U, typename T, int N>
77constexpr __detail::enable_if_t<sizeof(U) == sizeof(T), vector<U, N>>
78bit_cast(vector<T, N> V) {
79 return __builtin_bit_cast(vector<U, N>, V);
80}
81
82template <typename U, typename T>
83constexpr __detail::enable_if_t<sizeof(U) == sizeof(T), U> bit_cast(T F) {
84 return __builtin_bit_cast(U, F);
85}
86
87} // namespace hlsl
88#endif //_HLSL_HLSL_DETAILS_H_
#define V(N, I)
constexpr double Pi
Definition hlsl_detail.h:16
typename type_identity< T >::Type type_identity_t
Definition hlsl_detail.h:39
typename elem_type< T >::Type elem_type_t
Definition hlsl_detail.h:54
typename enable_if< B, T >::Type enable_if_t
Definition hlsl_detail.h:33
constexpr __detail::enable_if_t< sizeof(U)==sizeof(T), matrix< U, R, C > > bit_cast(matrix< T, R, C > M)
Definition hlsl_detail.h:72
unsigned int uint32_t
#define true
Definition stdbool.h:25
static const bool value
Definition hlsl_detail.h:19
heap_resource_info operator[](uint32_t Index)
Definition hlsl_detail.h:57
heap_sampler_info operator[](uint32_t Index)
Definition hlsl_detail.h:63