Skip to content

Commit 74b37e2

Browse files
Merge pull request #816 from Devsh-Graphics-Programming/workgroup_scan_oob_fix
Workgroup Scan OBB Scratch Access
2 parents 5bebeb7 + d6f83d4 commit 74b37e2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/nbl/builtin/hlsl/workgroup/shared_scan.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct reduce
5656
[unroll(1)]
5757
while (lastInvocationInLevel>subgroupMask)
5858
{
59-
scanLoadIndex += lastInvocationInLevel+_static_cast<uint16_t>(1);
59+
scanLoadIndex += lastInvocationInLevel-_static_cast<uint16_t>(1);
6060
// only invocations that have the final value of the subgroupOp (inclusive scan) store their results
6161
if (participate && (SubgroupContiguousIndex()==lastInvocationInLevel || isLastSubgroupInvocation))
6262
scratchAccessor.set(scanLoadIndex-loadStoreIndexDiff,scan); // For subgroupSz = 32, first 512 invocations store index is [0,15], 512-1023 [16,31] etc.
@@ -121,7 +121,7 @@ struct scan// : reduce<BinOp,ItemCount> https://github.com/microsoft/DirectXShad
121121
if (logShift!=initialLogShift) // but the top level doesn't have any level above itself
122122
{
123123
// this is fine if on the way up you also += under `if (participate)`
124-
scanStoreIndex -= __base.lastInvocationInLevel+_static_cast<uint16_t>(1);
124+
scanStoreIndex -= __base.lastInvocationInLevel-_static_cast<uint16_t>(1);
125125
type_t higherLevelEPS;
126126
scratchAccessor.get(scanStoreIndex, higherLevelEPS);
127127
__base.lastLevelScan = binop(__base.lastLevelScan,higherLevelEPS);

0 commit comments

Comments
 (0)