1
+ #ifndef _NBL_BUILTIN_HLSL_MATRIX_UTILS_MATRIX_TRAITS_INCLUDED_
2
+ #define _NBL_BUILTIN_HLSL_MATRIX_UTILS_MATRIX_TRAITS_INCLUDED_
3
+
4
+ #include <nbl/builtin/hlsl/cpp_compat.hlsl>
5
+
6
+ namespace nbl
7
+ {
8
+ namespace hlsl
9
+ {
10
+
11
+ template<typename MatT>
12
+ struct matrix_traits;
13
+
14
+ // i choose to implement it this way because of this DXC bug: https://github.com/microsoft/DirectXShaderCompiler/issues/7007
15
+ #define DEFINE_MATRIX_TRAITS_TEMPLATE_SPECIALIZATION (ROW_COUNT, COLUMN_COUNT) \
16
+ template<typename T> \
17
+ struct matrix_traits<matrix <T, ROW_COUNT, COLUMN_COUNT> > \
18
+ { \
19
+ using scalar_type = T; \
20
+ using row_type = vector <T, COLUMN_COUNT>; \
21
+ NBL_CONSTEXPR_STATIC_INLINE uint32_t RowCount = ROW_COUNT; \
22
+ NBL_CONSTEXPR_STATIC_INLINE uint32_t ColumnCount = COLUMN_COUNT; \
23
+ NBL_CONSTEXPR_STATIC_INLINE bool Square = RowCount == ColumnCount; \
24
+ };
25
+
26
+ DEFINE_MATRIX_TRAITS_TEMPLATE_SPECIALIZATION (2 , 2 )
27
+ DEFINE_MATRIX_TRAITS_TEMPLATE_SPECIALIZATION (3 , 3 )
28
+ DEFINE_MATRIX_TRAITS_TEMPLATE_SPECIALIZATION (4 , 4 )
29
+ DEFINE_MATRIX_TRAITS_TEMPLATE_SPECIALIZATION (3 , 4 )
30
+
31
+ // TODO: when this bug: https://github.com/microsoft/DirectXShaderCompiler/issues/7007 is fixed, uncomment and delete template specializations
32
+ /*template<typename T, uint32_t N, uint32_t M>
33
+ struct matrix_traits<matrix<T,N,M> >
34
+ {
35
+ using scalar_type = T;
36
+ NBL_CONSTEXPR_STATIC_INLINE uint32_t RowCount = ROW_COUNT;
37
+ NBL_CONSTEXPR_STATIC_INLINE uint32_t ColumnCount = COLUMN_COUNT;
38
+ NBL_CONSTEXPR_STATIC_INLINE bool Square = RowCount == ColumnCount;
39
+ };
40
+ */
41
+
42
+ }
43
+ }
44
+
45
+ #endif
0 commit comments