Skip to content

Commit 111870c

Browse files
Fixed ballot inclusive and exclusive counts
1 parent deb7eac commit 111870c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/nbl/builtin/glsl/workgroup/ballot.glsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,10 @@ uint nbl_glsl_workgroupBallotExclusiveBitCount()
243243
return nbl_glsl_workgroupBallotScanBitCount_impl(true);
244244
}
245245

246-
uint nbl_glsl_workgroupBallotScanBitCount_impl_impl(in uint localBitfield)
246+
uint nbl_glsl_workgroupBallotScanBitCount_impl_impl(in uint localBitCount)
247247
{
248248
barrier();
249-
NBL_GLSL_WORKGROUP_COMMON_IMPL_HEAD(nbl_glsl_identityFunction,nbl_glsl_subgroupInclusiveAdd_impl,localBitfield,0u,nbl_glsl_identityFunction,nbl_glsl_workgroupBallot_impl_BitfieldDWORDs,true)
249+
NBL_GLSL_WORKGROUP_COMMON_IMPL_HEAD(nbl_glsl_identityFunction,nbl_glsl_subgroupInclusiveAdd_impl,localBitCount,0u,nbl_glsl_identityFunction,nbl_glsl_workgroupBallot_impl_BitfieldDWORDs,true)
250250
NBL_GLSL_WORKGROUP_SCAN_IMPL_TAIL(true,nbl_glsl_identityFunction,nbl_glsl_subgroupInclusiveAdd_impl,0u,nbl_glsl_identityFunction,nbl_glsl_add)
251251
}
252252
uint nbl_glsl_workgroupBallotScanBitCount_impl(in bool exclusive)
@@ -260,7 +260,7 @@ uint nbl_glsl_workgroupBallotScanBitCount_impl(in bool exclusive)
260260
if (gl_LocalInvocationIndex<nbl_glsl_workgroupBallot_impl_BitfieldDWORDs)
261261
localBitfieldBackup = _NBL_GLSL_SCRATCH_SHARED_DEFINED_[gl_LocalInvocationIndex];
262262
// scan hierarchically, invocations with `gl_LocalInvocationIndex>=nbl_glsl_workgroupBallot_impl_BitfieldDWORDs` will have garbage here
263-
nbl_glsl_workgroupBallotScanBitCount_impl_impl(localBitfieldBackup);
263+
nbl_glsl_workgroupBallotScanBitCount_impl_impl(bitCount(localBitfieldBackup));
264264
// fix it (abuse the fact memory is left over)
265265
globalCount = _dword!=0u ? _NBL_GLSL_SCRATCH_SHARED_DEFINED_[_dword]:0u;
266266
barrier();

0 commit comments

Comments
 (0)