Skip to content

Commit 62490ee

Browse files
committed
Added vector_traits.hlsl
1 parent 36baa31 commit 62490ee

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#ifndef _NBL_BUILTIN_HLSL_VECTOR_UTILS_VECTOR_TRAITS_INCLUDED_
2+
#define _NBL_BUILTIN_HLSL_VECTOR_UTILS_VECTOR_TRAITS_INCLUDED_
3+
#include <nbl/builtin/hlsl/cpp_compat/basic.h>
4+
5+
namespace nbl
6+
{
7+
namespace hlsl
8+
{
9+
10+
// The whole purpose of this file is to enable the creation of partial specializations of the vector_traits for
11+
// custom types without introducing circular dependencies.
12+
13+
template<typename VecT>
14+
struct vector_traits;
15+
16+
// i choose to implement it this way because of this DXC bug: https://github.com/microsoft/DirectXShaderCom0piler/issues/7007
17+
#define DEFINE_VECTOR_TRAITS_TEMPLATE_SPECIALIZATION(DIMENSION) \
18+
template<typename T> \
19+
struct vector_traits<vector<T, DIMENSION> > \
20+
{ \
21+
using scalar_type = T; \
22+
NBL_CONSTEXPR_STATIC_INLINE uint32_t Dimension = DIMENSION; \
23+
};\
24+
25+
DEFINE_VECTOR_TRAITS_TEMPLATE_SPECIALIZATION(2)
26+
DEFINE_VECTOR_TRAITS_TEMPLATE_SPECIALIZATION(3)
27+
DEFINE_VECTOR_TRAITS_TEMPLATE_SPECIALIZATION(4)
28+
29+
}
30+
}
31+
32+
#endif

0 commit comments

Comments
 (0)