Skip to content

Commit 10274a7

Browse files
committed
Barrier: allow specifying thread count in barrier() and threadElectOne()
1 parent 41d7cf0 commit 10274a7

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/engine/renderer-vulkan/Sync/Barrier.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,24 @@ struct Barrier {
5151
bool operator()();
5252
};
5353

54-
#define barrier() { \
54+
#define barrier( ... ) { \
5555
static Barrier syncBarrier; \
56-
syncBarrier(); \
56+
syncBarrier( __VA_ARGS__ ); \
5757
}
5858

59-
#define threadElectOne( ... ) { \
59+
#define _threadElectOne2( targetThreadCount, ... ) { \
6060
static Barrier syncBarrier; \
61-
const bool thisThreadElected = syncBarrier(); \
61+
const bool thisThreadElected = syncBarrier( targetThreadCount ); \
6262
\
6363
if ( thisThreadElected ) { \
6464
__VA_ARGS__ \
6565
} \
6666
}
6767

68+
#define _threadElectOne( ... ) _threadElectOne2( TLM.currentMaxThreads, __VA_ARGS__ )
69+
70+
#define EXPAND( x ) x
71+
#define GET_MACRO( _0, _1, name, ... ) name
72+
#define threadElectOne( ... ) EXPAND( GET_MACRO( __VA_ARGS__, _threadElectOne2, _threadElectOne ) ( __VA_ARGS__ ) )
73+
6874
#endif // BARRIER_H

0 commit comments

Comments
 (0)