11#ifndef _NBL_BUILTIN_HLSL_CPP_COMPAT_VECTOR_INCLUDED_
22#define _NBL_BUILTIN_HLSL_CPP_COMPAT_VECTOR_INCLUDED_
33
4+ // stuff for C++
45#ifndef __HLSL_VERSION
6+ #include <stdint.h>
7+
8+ #include <half .h>
59
610#define GLM_FORCE_SWIZZLE
711#include <glm/glm.hpp>
812#include <glm/detail/_swizzle.hpp>
9- #include <stdint.h>
10- #include <half .h>
1113
1214namespace nbl::hlsl
1315{
14-
1516template<typename T, uint16_t N>
1617using vector = glm::vec<N, T>;
1718
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-
5419template<typename T, uint16_t N>
5520glm::vec<N, bool > operator<(const glm::vec<N, T>& lhs, const glm::vec<N, T>& rhs)
5621{
@@ -77,4 +42,38 @@ glm::vec<N, bool> operator>=(const glm::vec<N, T>& lhs, const glm::vec<N, T>& rh
7742}
7843#endif
7944
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+
8079#endif
0 commit comments