Skip to content

Commit a1abefd

Browse files
Make barrier conditions more apparent (part 1/3)
1 parent 653743b commit a1abefd

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

include/irr/builtin/glsl/workgroup/shuffle.glsl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,28 @@
1919
#endif
2020

2121

22+
uint irr_glsl_workgroupShuffle_noBarriers(in uint val, in uint id)
23+
{
24+
_IRR_GLSL_SCRATCH_SHARED_DEFINED_[gl_LocalInvocationIndex] = val;
25+
barrier();
26+
memoryBarrierShared();
27+
return _IRR_GLSL_SCRATCH_SHARED_DEFINED_[id];
28+
}
29+
uint irr_glsl_workgroupShuffle(in uint val, in uint id)
30+
{
31+
barrier();
32+
memoryBarrierShared();
33+
const uint retval = irr_glsl_workgroupShuffle_noBarriers(val,id);
34+
barrier();
35+
memoryBarrierShared();
36+
return retval;
37+
}
38+
39+
2240
/** TODO @Hazardu or @Przemog you can express all of them in terms of the uint variants to safe yourself the trouble of repeated code, this could also be a recruitment task.
2341
2442
bool irr_glsl_workgroupShuffle(in bool val, in uint id);
2543
float irr_glsl_workgroupShuffle(in float val, in uint id);
26-
uint irr_glsl_workgroupShuffle(in uint val, in uint id);
2744
int irr_glsl_workgroupShuffle(in int val, in uint id);
2845
2946
bool irr_glsl_workgroupShuffleXor(in bool val, in uint mask);

include/irr/builtin/glsl/workgroup/vote.glsl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#endif
2121

2222

23-
bool irr_glsl_workgroupAll(in bool value)
23+
bool irr_glsl_workgroupAll_noBarriers(in bool value)
2424
{
2525
// TODO: Optimization using subgroupAll in an ifdef IRR_GL_something (need to do feature mapping first), probably only first 2 lines need to change
2626
_IRR_GLSL_SCRATCH_SHARED_DEFINED_[0u] = 1u;
@@ -31,8 +31,16 @@ bool irr_glsl_workgroupAll(in bool value)
3131

3232
return _IRR_GLSL_SCRATCH_SHARED_DEFINED_[0u]!=0u;
3333
}
34+
bool irr_glsl_workgroupAll(in bool value)
35+
{
36+
barrier();
37+
memoryBarrierShared();
38+
const bool retval = irr_glsl_workgroupAll_noBarriers(value);
39+
barrier();
40+
return retval;
41+
}
3442

35-
bool irr_glsl_workgroupAny(in bool value)
43+
bool irr_glsl_workgroupAny_noBarriers(in bool value)
3644
{
3745
// TODO: Optimization using subgroupAny in an ifdef IRR_GL_something (need to do feature mapping first), probably only first 2 lines need to change
3846
_IRR_GLSL_SCRATCH_SHARED_DEFINED_[0u] = 0u;
@@ -43,6 +51,14 @@ bool irr_glsl_workgroupAny(in bool value)
4351

4452
return _IRR_GLSL_SCRATCH_SHARED_DEFINED_[0u]!=0u;
4553
}
54+
bool irr_glsl_workgroupAny(in bool value)
55+
{
56+
barrier();
57+
memoryBarrierShared();
58+
const bool retval = irr_glsl_workgroupAny_noBarriers(value);
59+
barrier();
60+
return retval;
61+
}
4662

4763
/** TODO @Cyprian or @Anastazluk
4864
bool irr_glsl_workgroupAllEqual(in bool val);

0 commit comments

Comments
 (0)