critical fix with particle sorting unsigned counter underflow

This commit is contained in:
turanszkij
2018-05-07 12:08:03 +01:00
parent a39243f0da
commit cf3fdea255
2 changed files with 6 additions and 2 deletions
@@ -14,7 +14,7 @@ void main( uint3 DTid : SV_DispatchThreadID )
counterBuffer[0].aliveCount_afterSimulation = aliveCount_afterSimulation;
// calculate threadcount:
uint threadCount = ((aliveCount_afterSimulation - 1) >> 9) + 1;
uint threadCount = ((max(1, aliveCount_afterSimulation) - 1) >> 9) + 1;
// and prepare to dispatch the sort for the alive simulated particles:
indirectBuffers.Store3(ARGUMENTBUFFER_OFFSET_DISPATCHSORT, uint3(threadCount, 1, 1));
+5 -1
View File
@@ -212,6 +212,7 @@ void wiEmittedParticle::CreateSelfBuffers()
counters.aliveCount = 0;
counters.deadCount = MAX_PARTICLES;
counters.realEmitCount = 0;
counters.aliveCount_afterSimulation = 0;
data.pSysMem = &counters;
bd.ByteWidth = sizeof(counters);
@@ -394,7 +395,10 @@ void wiEmittedParticle::UpdateRenderData(GRAPHICSTHREAD threadID)
unsigned int numThreadGroups = ((MAX_PARTICLES - 1) >> 9) + 1;
if (numThreadGroups>1) bDone = false;
if (numThreadGroups > 1)
{
bDone = false;
}
// sort all buffers of size 512 (and presort bigger ones)
device->BindComputePSO(&CPSO_sort, threadID);