File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
include/nbl/builtin/hlsl/sort Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -84,17 +84,20 @@ struct counting
84
84
histogram.atomicAdd (tid, sum);
85
85
86
86
const bool is_last_wg_invocation = tid == (GroupSize - 1 );
87
- const uint16_t adjusted_key_bucket_count = (( KeyBucketCount - 1 ) / GroupSize + 1 ) * GroupSize ;
87
+ const static uint16_t RoundedKeyBucketCount = (KeyBucketCount - 1 ) / GroupSize + 1 ;
88
88
89
- for (uint32_t vid = tid + GroupSize; vid < adjusted_key_bucket_count; vid += GroupSize )
89
+ for (int i = 1 ; i < RoundedKeyBucketCount; i++ )
90
90
{
91
+ uint32_t keyBucketStart = GroupSize * i;
92
+ uint32_t vid = tid + keyBucketStart;
93
+
91
94
if (is_last_wg_invocation)
92
95
{
93
- uint32_t startIndex = vid - tid;
94
- sdata.set (startIndex, sdata.get (startIndex) + sum);
96
+ sdata.set (keyBucketStart, sdata.get (keyBucketStart) + sum);
95
97
}
96
98
97
- sum = inclusive_scan (sdata.get (vid), sdata);
99
+ const uint32_t val = vid < KeyBucketCount ? sdata.get (vid) : 0 ;
100
+ sum = inclusive_scan (val, sdata);
98
101
histogram.atomicAdd (vid, sum);
99
102
}
100
103
}
You can’t perform that action at this time.
0 commit comments