1
1
#ifndef _NBL_BUILTIN_HLSL_CPP_COMPAT_VECTOR_INCLUDED_
2
2
#define _NBL_BUILTIN_HLSL_CPP_COMPAT_VECTOR_INCLUDED_
3
3
4
+ // stuff for C++
4
5
#ifndef __HLSL_VERSION
6
+ #include <stdint.h>
7
+
8
+ #include <half .h>
5
9
6
10
#define GLM_FORCE_SWIZZLE
7
11
#include <glm/glm.hpp>
8
12
#include <glm/detail/_swizzle.hpp>
9
- #include <stdint.h>
10
- #include <half .h>
11
13
12
14
namespace nbl::hlsl
13
15
{
14
-
15
16
template<typename T, uint16_t N>
16
17
using vector = glm::vec<N, T>;
17
18
18
- // ideally we should have sized bools, but no idea what they'd be
19
- using bool4 = vector <bool , 4 >;
20
- using bool3 = vector <bool , 3 >;
21
- using bool2 = vector <bool , 2 >;
22
- using bool1 = vector <bool , 1 >;
23
-
24
- using int32_t4 = vector <int32_t, 4 >;
25
- using int32_t3 = vector <int32_t, 3 >;
26
- using int32_t2 = vector <int32_t, 2 >;
27
- using int32_t1 = vector <int32_t, 1 >;
28
-
29
- using uint32_t4 = vector <uint32_t, 4 >;
30
- using uint32_t3 = vector <uint32_t, 3 >;
31
- using uint32_t2 = vector <uint32_t, 2 >;
32
- using uint32_t1 = vector <uint32_t, 1 >;
33
-
34
- // TODO: halfN -> needs class implementation or C++23 std:float16_t
35
-
36
- using float16_t = half ;
37
- using float16_t4 = vector <float16_t, 4 >;
38
- using float16_t3 = vector <float16_t, 3 >;
39
- using float16_t2 = vector <float16_t, 2 >;
40
- using float16_t1 = vector <float16_t, 1 >;
41
-
42
- using float32_t = float ;
43
- using float32_t4 = vector <float32_t, 4 >;
44
- using float32_t3 = vector <float32_t, 3 >;
45
- using float32_t2 = vector <float32_t, 2 >;
46
- using float32_t1 = vector <float32_t, 1 >;
47
-
48
- using float64_t = double ;
49
- using float64_t4 = vector <float64_t, 4 >;
50
- using float64_t3 = vector <float64_t, 3 >;
51
- using float64_t2 = vector <float64_t, 2 >;
52
- using float64_t1 = vector <float64_t, 1 >;
53
-
54
19
template<typename T, uint16_t N>
55
20
glm::vec<N, bool > operator<(const glm::vec<N, T>& lhs, const glm::vec<N, T>& rhs)
56
21
{
@@ -77,4 +42,38 @@ glm::vec<N, bool> operator>=(const glm::vec<N, T>& lhs, const glm::vec<N, T>& rh
77
42
}
78
43
#endif
79
44
45
+ // general typedefs for both langs
46
+ namespace nbl
47
+ {
48
+ namespace hlsl
49
+ {
50
+ typedef half float16_t;
51
+ typedef float float32_t;
52
+ typedef double float64_t;
53
+
54
+ #define NBL_TYPEDEF_VECTORS (T) \
55
+ typedef vector <T,4 > T ## 4 ; \
56
+ typedef vector <T,3 > T ## 3 ; \
57
+ typedef vector <T,2 > T ## 2 ; \
58
+ typedef vector <T,1 > T ## 1
59
+
60
+ // ideally we should have sized bools, but no idea what they'd be
61
+ NBL_TYPEDEF_VECTORS (bool );
62
+
63
+ NBL_TYPEDEF_VECTORS (int16_t);
64
+ NBL_TYPEDEF_VECTORS (int32_t);
65
+ NBL_TYPEDEF_VECTORS (int64_t);
66
+
67
+ NBL_TYPEDEF_VECTORS (uint16_t);
68
+ NBL_TYPEDEF_VECTORS (uint32_t);
69
+ NBL_TYPEDEF_VECTORS (uint64_t);
70
+
71
+ NBL_TYPEDEF_VECTORS (float16_t);
72
+ NBL_TYPEDEF_VECTORS (float32_t);
73
+ NBL_TYPEDEF_VECTORS (float64_t);
74
+
75
+ #undef NBL_TYPEDEF_VECTORS
76
+ }
77
+ }
78
+
80
79
#endif
0 commit comments