Skip to content

Commit c1dff94

Browse files
committed
Added array_accessors.hlsl
1 parent 62490ee commit c1dff94

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifndef _NBL_BUILTIN_HLSL_ARRAY_ACCESSORS_HLSL_INCLUDED_
2+
#define _NBL_BUILTIN_HLSL_ARRAY_ACCESSORS_HLSL_INCLUDED_
3+
4+
#include <nbl/builtin/hlsl/cpp_compat/basic.h>
5+
6+
namespace nbl
7+
{
8+
namespace hlsl
9+
{
10+
template<typename ArrayType, typename ComponentType, typename I = uint32_t>
11+
struct array_get
12+
{
13+
ComponentType operator()(NBL_CONST_REF_ARG(ArrayType) arr, const I ix) NBL_CONST_MEMBER_FUNC
14+
{
15+
return arr[ix];
16+
}
17+
};
18+
19+
template<typename ArrayType, typename ComponentType, typename I = uint32_t>
20+
struct array_set
21+
{
22+
void operator()(NBL_REF_ARG(ArrayType) arr, I index, ComponentType val) NBL_CONST_MEMBER_FUNC
23+
{
24+
arr[index] = val;
25+
}
26+
};
27+
}
28+
}
29+
30+
#endif

0 commit comments

Comments
 (0)