Alternative Upload geometry data in parallel to multiple GPUs using the "Multi-Device" #107552
|
@ -70,7 +70,7 @@ BVHLayout BVHParams::best_bvh_layout(BVHLayout requested_layout, BVHLayoutMask s
|
|||
BVH::BVH(const BVHParams ¶ms_,
|
||||
const vector<Geometry *> &geometry_,
|
||||
const vector<Object *> &objects_)
|
||||
: params(params_), geometry(geometry_), objects(objects_)
|
||||
: params(params_), geometry(geometry_), objects(objects_), built(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ class BVH {
|
|||
{
|
||||
this->geometry = geometry;
|
||||
this->objects = objects;
|
||||
this->built = false;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -36,7 +36,7 @@ BVH2::BVH2(const BVHParams ¶ms_,
|
|||
|
||||
void BVH2::build(Progress &progress, Stats *)
|
||||
{
|
||||
progress.set_substatus("Building BVH");
|
||||
progress.set_substatus("Building BVH2 BVH");
|
||||
|
||||
/* build nodes */
|
||||
BVHBuild bvh_build(objects,
|
||||
|
|
|
@ -58,7 +58,7 @@ void Device::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool r
|
|||
/* Has the BVH already been built */
|
||||
if (!bvh->built) {
|
||||
/* Build the BVH */
|
||||
VLOG_INFO << "Performing BVH2 build.";
|
||||
VLOG_INFO << std::this_thread::get_id() << ": Performing BVH2 build.";
|
||||
|
||||
if (refit) {
|
||||
bvh2->refit(progress);
|
||||
|
@ -67,23 +67,24 @@ void Device::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool r
|
|||
bvh2->build(progress, &stats);
|
||||
}
|
||||
bvh->built = true;
|
||||
VLOG_INFO << "done building BVH2";
|
||||
VLOG_INFO << std::this_thread::get_id() << ": done building BVH2";
|
||||
}
|
||||
else {
|
||||
VLOG_INFO << "BVH2 Already built";
|
||||
VLOG_INFO << std::this_thread::get_id() << ": BVH2 Already built";
|
||||
}
|
||||
bvh2->build_cv.notify_all();
|
||||
}
|
||||
else {
|
||||
/* Only need to wait for the top level BVH otherwise
|
||||
this thread can skip on the the next object */
|
||||
this thread can skip on to the next object */
|
||||
if (bvh2->params.top_level) {
|
||||
//thread_scoped_lock build_wait_lock(bvh2->build_mutex);
|
||||
/* wait for BVH build to complete before proceeding */
|
||||
VLOG_INFO << "Waiting on BVH2 build.";
|
||||
bvh2->build_cv.wait(build_lock, [=]() { return !(bvh2->built); });
|
||||
VLOG_INFO << "done waiting on BVH2 build";
|
||||
VLOG_INFO << std::this_thread::get_id() << ": Waiting on BVH2 build.";
|
||||
bvh2->build_cv.wait(build_lock/*wait_lock*/, [=]() { return (bvh2->built); });
|
||||
VLOG_INFO << std::this_thread::get_id() << ": done waiting on BVH2 build";
|
||||
} else {
|
||||
VLOG_INFO << "Skipping BVH2 build.";
|
||||
VLOG_INFO << std::this_thread::get_id() << ": Skipping BVH2 build.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1326,8 +1326,7 @@ size_t GeometryManager::createObjectBVHs(Device *device,
|
|||
if (geom->is_modified() || geom->need_update_bvh_for_offset) {
|
||||
need_update_scene_bvh = true;
|
||||
Object *object = &object_pool[id];
|
||||
geom->create_new_bvh_if_needed(object, device, dscene, &scene->params);
|
||||
if (geom->need_build_bvh(bvh_layout)) {
|
||||
if(geom->create_new_bvh_if_needed(object, device, dscene, &scene->params)) {
|
||||
num_bvh++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ class Geometry : public Node {
|
|||
int motion_step(float time) const;
|
||||
|
||||
/* BVH */
|
||||
void create_new_bvh_if_needed(Object *object,
|
||||
bool create_new_bvh_if_needed(Object *object,
|
||||
Device *device,
|
||||
DeviceScene *dscene,
|
||||
SceneParams *params);
|
||||
|
|
|
@ -805,11 +805,12 @@ void GeometryManager::device_update_bvh_postprocess(Device *device,
|
|||
dscene->data.device_bvh = 0;
|
||||
}
|
||||
|
||||
void Geometry::create_new_bvh_if_needed(Object *object,
|
||||
bool Geometry::create_new_bvh_if_needed(Object *object,
|
||||
Device *device,
|
||||
DeviceScene *dscene,
|
||||
SceneParams *params)
|
||||
{
|
||||
bool status = false;
|
||||
const BVHLayout bvh_layout = BVHParams::best_bvh_layout(params->bvh_layout,
|
||||
device->get_bvh_layout_mask());
|
||||
if (need_build_bvh(bvh_layout)) {
|
||||
|
@ -849,7 +850,10 @@ void Geometry::create_new_bvh_if_needed(Object *object,
|
|||
bvh = BVH::create(bparams, geometry, objects, device);
|
||||
need_update_rebuild = true;
|
||||
}
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void GeometryManager::device_update_sub_bvh(Device *device,
|
||||
|
@ -893,8 +897,13 @@ void GeometryManager::device_update_sub_bvh(Device *device,
|
|||
if (sub_bvh != NULL) {
|
||||
delete sub_bvh;
|
||||
}
|
||||
sub_bvh = BVH::create(bparams, bvh->geometry, bvh->objects, device);
|
||||
bvh->set_device_bvh(device, sub_bvh);
|
||||
VLOG_INFO << "Sub-BVH using layout " << bvh_layout_name(bparams.bvh_layout) << " from layout " << bvh_layout_name(bvh->params.bvh_layout);
|
||||
/* BVH2 should not have a sub-bvh as only 1 is built on the CPU */
|
||||
assert(bparams.bvh_layout != BVH_LAYOUT_BVH2);
|
||||
if(bparams.bvh_layout != BVH_LAYOUT_BVH2) {
|
||||
sub_bvh = BVH::create(bparams, bvh->geometry, bvh->objects, device);
|
||||
bvh->set_device_bvh(device, sub_bvh);
|
||||
}
|
||||
}
|
||||
can_refit = false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue