Skip to content

Commit 00787bf

Browse files
committed
added generic read/write accessors
1 parent d83ac5c commit 00787bf

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

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

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,61 @@ namespace accessors
1616
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)(typename)(typename)
1717
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)(V)(I)
1818
#define NBL_CONCEPT_PARAM_0 (accessor, T)
19-
#define NBL_CONCEPT_PARAM_1 (index, I)
20-
#define NBL_CONCEPT_PARAM_2 (val, V)
19+
#define NBL_CONCEPT_PARAM_1 (val, V)
20+
#define NBL_CONCEPT_PARAM_2 (index, I)
2121
NBL_CONCEPT_BEGIN(3)
2222
#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
23+
#define val NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1
24+
#define index NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_2
2525
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))
26+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.template set<V,I>(index, val)), is_same_v, void))
27+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.template get<V,I>(index, val)), is_same_v, void))
2828
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.workgroupExecutionAndMemoryBarrier()), is_same_v, void))
2929
);
3030
#undef val
3131
#undef index
3232
#undef accessor
3333
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
3434

35-
#define NBL_CONCEPT_NAME GenericDataAccessor
35+
#define NBL_CONCEPT_NAME GenericReadAccessor
3636
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)(typename)(typename)
3737
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)(V)(I)
3838
#define NBL_CONCEPT_PARAM_0 (accessor, T)
39-
#define NBL_CONCEPT_PARAM_1 (index, I)
40-
#define NBL_CONCEPT_PARAM_2 (val, V)
39+
#define NBL_CONCEPT_PARAM_1 (val, V)
40+
#define NBL_CONCEPT_PARAM_2 (index, I)
4141
NBL_CONCEPT_BEGIN(3)
4242
#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
43+
#define val NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1
44+
#define index NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_2
4545
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))
46+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.template get<V,I>(index, val)), is_same_v, void))
4847
);
4948
#undef val
5049
#undef index
5150
#undef accessor
5251
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
5352

53+
#define NBL_CONCEPT_NAME GenericWriteAccessor
54+
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)(typename)(typename)
55+
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)(V)(I)
56+
#define NBL_CONCEPT_PARAM_0 (accessor, T)
57+
#define NBL_CONCEPT_PARAM_1 (val, V)
58+
#define NBL_CONCEPT_PARAM_2 (index, I)
59+
NBL_CONCEPT_BEGIN(3)
60+
#define accessor NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0
61+
#define val NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1
62+
#define index NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_2
63+
NBL_CONCEPT_END(
64+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.template set<V,I>(index, val)), is_same_v, void))
65+
);
66+
#undef val
67+
#undef index
68+
#undef accessor
69+
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
70+
71+
template<typename T, typename V, typename I=uint32_t>
72+
NBL_BOOL_CONCEPT GenericDataAccessor = GenericWriteAccessor<T,V,I> && GenericWriteAccessor<T,V,I>;
73+
5474
}
5575
}
5676
}

0 commit comments

Comments
 (0)