Skip to content

Commit f025adb

Browse files
committed
Add some default barriers
1 parent efcf055 commit f025adb

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

include/nbl/builtin/hlsl/bda/bda_accessor.hlsl

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,28 @@ namespace nbl
1212
namespace hlsl
1313
{
1414

15+
namespace impl {
16+
17+
struct BdaAccessorBase
18+
{
19+
// Note: Its a funny quirk of the SPIR-V Vulkan Env spec that `MemorySemanticsUniformMemoryMask` means SSBO as well :facepalm: (and probably BDA)
20+
void workgroupExecutionAndMemoryBarrier()
21+
{
22+
// we're only barriering the workgroup and trading memory within a workgroup
23+
spirv::controlBarrier(spv::ScopeWorkgroup, spv::ScopeWorkgroup, spv::MemorySemanticsAcquireReleaseMask | spv::MemorySemanticsUniformMemoryMask);
24+
}
25+
26+
void memoryBarrier()
27+
{
28+
// By default it's device-wide access to the buffer
29+
spirv::memoryBarrier(spv::ScopeDevice, spv::MemorySemanticsAcquireReleaseMask | spv::MemorySemanticsUniformMemoryMask);
30+
}
31+
};
32+
33+
} //namespace impl
34+
1535
template<typename T>
16-
struct BdaAccessor
36+
struct BdaAccessor : impl::BdaAccessorBase
1737
{
1838
using type_t = T;
1939
static BdaAccessor<T> create(const bda::__ptr<T> ptr)
@@ -61,7 +81,7 @@ struct BdaAccessor
6181
};
6282

6383
template<typename T>
64-
struct DoubleBdaAccessor
84+
struct DoubleBdaAccessor : impl::BdaAccessorBase
6585
{
6686
using type_t = T;
6787
static DoubleBdaAccessor<T> create(const bda::__ptr<T> inputPtr, const bda::__ptr<T> outputPtr)

0 commit comments

Comments
 (0)