Skip to content

Commit

Permalink
Added non-parallel build version
Browse files Browse the repository at this point in the history
  • Loading branch information
gboisse committed Jan 19, 2018
1 parent 58d5208 commit 90cb5a6
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
50 changes: 49 additions & 1 deletion RadeonRays/src/accelerator/bvh2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,55 @@ namespace RadeonRays
auto m128_minus_inf = _mm_set_ps(-inf, -inf, -inf, -inf);

#ifndef PARALLEL_BUILD
#error TODO: implement (gboisse)
_MM_ALIGN16 SplitRequest requests[kStackSize];

auto sptr = 0u;

requests[sptr++] = SplitRequest{
scene_min,
scene_max,
centroid_scene_min,
centroid_scene_max,
0,
num_aabbs,
0u,
0u
};

while (sptr > 0u)
{
auto request = requests[--sptr];

auto &request_left{ requests[sptr++] };

if (sptr == kStackSize)
{
throw std::runtime_error("Build stack overflow");
}

auto &request_right{ requests[sptr++] };

if (sptr == kStackSize)
{
throw std::runtime_error("Build stack overflow");
}

if (HandleRequest(
request,
aabb_min,
aabb_max,
aabb_centroid,
metadata,
refs,
num_aabbs,
request_left,
request_right) ==
NodeType::kLeaf)
{
--sptr;
--sptr;
}
}
#else
std::mutex mutex;
std::condition_variable cv;
Expand Down
2 changes: 2 additions & 0 deletions RadeonRays/src/accelerator/bvh2.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ namespace RadeonRays
kMaxLeafPrimitives = 1u,
// Threshold number of primitives to disable SAH split
kMinSAHPrimitives = 32u,
// Maximum stack size for non-parallel builds
kStackSize = 1024u,
// Traversal vs intersection cost ratio
kTraversalCost = 10u
};
Expand Down

0 comments on commit 90cb5a6

Please sign in to comment.