fix bvh hang bug

This commit is contained in:
turanszkij
2018-07-03 00:47:11 +02:00
parent 3da0d52a0f
commit cee126c0f7
2 changed files with 6 additions and 22 deletions
+5 -21
View File
@@ -39,36 +39,20 @@ void main(uint3 DTid : SV_DispatchThreadID)
{
// Move up in the tree:
nodeIndex = node.ParentIndex;
node = bvhNodeBuffer[nodeIndex];
uint childCount = 0;
[flatten]
if (node.LeftChildIndex > 0)
{
childCount++;
}
[flatten]
if (node.RightChildIndex > 0)
{
childCount++;
}
if (childCount == 0)
{
return;
}
// In case of two children, an atomic flag to only allow one thread to write into parent. The other thread is discarded.
// Atomic flag to only allow one thread to write into parent. The other thread is discarded.
// If the previous value was 0, that means it's the first child to arrive here, this will be discarded, because maybe the second child is not yet computed its AABB.
// Else, this is the second child to arrive, we can continue to parent, because there was already a child that arrived here and been discarded.
uint flag;
InterlockedAdd(bvhFlagBuffer[nodeIndex], 1, flag);
if (flag < childCount - 1)
if (flag != 1)
{
return;
}
// Arrived at parent node:
node = bvhNodeBuffer[nodeIndex];
// Load up its two children's AABBs
BVHAABB leftAABB = bvhAABBBuffer[node.LeftChildIndex];
BVHAABB rightAABB = bvhAABBBuffer[node.RightChildIndex];
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wiVersion
// minor features, major updates
const int minor = 18;
// minor bug fixes, alterations, refactors, updates
const int revision = 2;
const int revision = 1;
long GetVersion()