Example code that produces the bug:
ComputeBuffer tempBuffer0 = null;
ComputeBuffer tempBuffer1 = null;
// 4 elements
ComputeBuffer prefixSumIn = new(1, 16);
ComputeBuffer prefixSumOut = new(1, 16);
ComputeShader compute = [code that gets compute shader];
ChainedScanDecoupledLookbackDecoupledFallback prefixSum = new(compute, 4, ref tempBuffer0, ref tempBuffer1);
prefixSum.PrefixSumInclusive(4, prefixSumIn, prefixSumOut, tempBuffer0, tempBuffer1);
This throws AssertionException from line 127 in ChainedScanDecoupledLookbackDecoupledFallback.
|
Assert.IsTrue( |
|
m_isValid && |
|
IsAligned(prefixSumIn.stride) && |
|
IsAligned(prefixSumOut.stride) && |
|
size < m_allocatedSize && |
|
size > k_minSize); |
I believe this is caused by the size being equal to the maxElements parameter in the constructor of ChainedScanDecoupledLookbackDecoupledFallback. In the constructor, m_allocatedSize is set to 4...
|
m_allocatedSize = AlignFour(maxElements); |
When PrefixSumInclusive is called, the check in line 131 fails (4 < 4 is false), so an exception is raised.
But I expected maxElements to really be the maximum number of elements. If the input size is 4, the code will run. If the size is 5, it throws an error.
Example code that produces the bug:
This throws
AssertionExceptionfrom line 127 inChainedScanDecoupledLookbackDecoupledFallback.GPUPrefixSums/GPUPrefixSumsUnity/Runtime/ChainedScanDecoupledLookbackDecoupledFallback.cs
Lines 127 to 132 in 98d93a4
I believe this is caused by the size being equal to the maxElements parameter in the constructor of
ChainedScanDecoupledLookbackDecoupledFallback. In the constructor, m_allocatedSize is set to 4...GPUPrefixSums/GPUPrefixSumsUnity/Runtime/ChainedScanDecoupledLookbackDecoupledFallback.cs
Line 53 in 98d93a4
When
PrefixSumInclusiveis called, the check in line 131 fails (4 < 4 is false), so an exception is raised.But I expected maxElements to really be the maximum number of elements. If the input size is 4, the code will run. If the size is 5, it throws an error.