Skip to content

Commit 14e5d15

Browse files
committed
added generic data/shared mem accessors
1 parent 350c6a3 commit 14e5d15

File tree

2 files changed

+64
-39
lines changed

2 files changed

+64
-39
lines changed

include/nbl/builtin/hlsl/concepts/accessors/fft.hlsl

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _NBL_BUILTIN_HLSL_CONCEPTS_ACCESSORS_FFT_INCLUDED_
22
#define _NBL_BUILTIN_HLSL_CONCEPTS_ACCESSORS_FFT_INCLUDED_
33

4-
#include "nbl/builtin/hlsl/concepts.hlsl"
4+
#include "nbl/builtin/hlsl/concepts/accessors/generic_shared_data.hlsl"
55
#include "nbl/builtin/hlsl/fft/common.hlsl"
66

77
namespace nbl
@@ -17,49 +17,15 @@ namespace fft
1717
// * void set(uint32_t index, in uint32_t value);
1818
// * void workgroupExecutionAndMemoryBarrier();
1919

20-
#define NBL_CONCEPT_NAME FFTSharedMemoryAccessor
21-
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)
22-
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)
23-
#define NBL_CONCEPT_PARAM_0 (accessor, T)
24-
#define NBL_CONCEPT_PARAM_1 (index, uint32_t)
25-
#define NBL_CONCEPT_PARAM_2 (val, uint32_t)
26-
NBL_CONCEPT_BEGIN(3)
27-
#define accessor NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0
28-
#define index NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1
29-
#define val NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_2
30-
NBL_CONCEPT_END(
31-
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.template set<uint32_t, uint32_t>(index, val)), is_same_v, void))
32-
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.template get<uint32_t, uint32_t>(index, val)), is_same_v, void))
33-
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.workgroupExecutionAndMemoryBarrier()), is_same_v, void))
34-
);
35-
#undef val
36-
#undef index
37-
#undef accessor
38-
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
39-
20+
template<typename T, typename V=uint32_t, typename I=uint32_t>
21+
NBL_BOOL_CONCEPT FFTSharedMemoryAccessor = concepts::accessors::GenericSharedMemoryAccessor<T,V,I>;
4022

4123
// The Accessor (for a small FFT) MUST provide the following methods:
4224
// * void get(uint32_t index, NBL_REF_ARG(complex_t<Scalar>) value);
4325
// * void set(uint32_t index, in complex_t<Scalar> value);
4426

45-
#define NBL_CONCEPT_NAME FFTAccessor
46-
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)(typename)
47-
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)(Scalar)
48-
#define NBL_CONCEPT_PARAM_0 (accessor, T)
49-
#define NBL_CONCEPT_PARAM_1 (index, uint32_t)
50-
#define NBL_CONCEPT_PARAM_2 (val, complex_t<Scalar>)
51-
NBL_CONCEPT_BEGIN(3)
52-
#define accessor NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0
53-
#define index NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1
54-
#define val NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_2
55-
NBL_CONCEPT_END(
56-
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.template set<complex_t<Scalar> >(index, val)), is_same_v, void))
57-
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.template get<complex_t<Scalar> >(index, val)), is_same_v, void))
58-
);
59-
#undef val
60-
#undef index
61-
#undef accessor
62-
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
27+
template<typename T, typename Scalar, typename I=uint32_t>
28+
NBL_BOOL_CONCEPT FFTAccessor = concepts::accessors::GenericDataAccessor<T,complex_t<Scalar>,I>;
6329

6430
}
6531
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#ifndef _NBL_BUILTIN_HLSL_CONCEPTS_ACCESSORS_WORKGROUP_ARITHMETIC_INCLUDED_
2+
#define _NBL_BUILTIN_HLSL_CONCEPTS_ACCESSORS_WORKGROUP_ARITHMETIC_INCLUDED_
3+
4+
#include "nbl/builtin/hlsl/concepts.hlsl"
5+
6+
namespace nbl
7+
{
8+
namespace hlsl
9+
{
10+
namespace concepts
11+
{
12+
namespace accessors
13+
{
14+
15+
#define NBL_CONCEPT_NAME GenericSharedMemoryAccessor
16+
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)(typename)(typename)
17+
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)(V)(I)
18+
#define NBL_CONCEPT_PARAM_0 (accessor, T)
19+
#define NBL_CONCEPT_PARAM_1 (index, I)
20+
#define NBL_CONCEPT_PARAM_2 (val, V)
21+
NBL_CONCEPT_BEGIN(3)
22+
#define accessor NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0
23+
#define index NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1
24+
#define val NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_2
25+
NBL_CONCEPT_END(
26+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.template set<I,V>(index, val)), is_same_v, void))
27+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.template get<I,V>(index, val)), is_same_v, void))
28+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.workgroupExecutionAndMemoryBarrier()), is_same_v, void))
29+
);
30+
#undef val
31+
#undef index
32+
#undef accessor
33+
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
34+
35+
#define NBL_CONCEPT_NAME GenericDataAccessor
36+
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)(typename)(typename)
37+
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)(V)(I)
38+
#define NBL_CONCEPT_PARAM_0 (accessor, T)
39+
#define NBL_CONCEPT_PARAM_1 (index, I)
40+
#define NBL_CONCEPT_PARAM_2 (val, V)
41+
NBL_CONCEPT_BEGIN(3)
42+
#define accessor NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0
43+
#define index NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1
44+
#define val NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_2
45+
NBL_CONCEPT_END(
46+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.template set<V>(index, val)), is_same_v, void))
47+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.template get<V>(index, val)), is_same_v, void))
48+
);
49+
#undef val
50+
#undef index
51+
#undef accessor
52+
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
53+
54+
}
55+
}
56+
}
57+
}
58+
59+
#endif

0 commit comments

Comments
 (0)