message: Add some code to build LBVH on the device
diff: @@ -1238,19 +1238,37 @@ void renderer::build_scene()
  if (mod.scene_graph == nullptr)
  {
  // Single BVH
  - host_bvhs.resize(1);
  - if (build_strategy == LBVH)
  + if (build_strategy == LBVH && rt.mode() == host_device_rt::CPU)
  {
  + host_bvhs.resize(1);
  +
  lbvh_builder builder;
  + //timer t;
  host_bvhs[0] = builder.build(host_bvh_type{}, mod.primitives.data(), mod.primitives.size());
  + //std::cout << t.elapsed() << '\n';
  + }
  + else if (build_strategy == LBVH && rt.mode() == host_device_rt::GPU)
  + {
  + device_bvhs.resize(1);
  +
  + lbvh_builder builder;
  +
  + //cuda::timer t;
  + thrust::device_vector<primitive_type> primitives(mod.primitives);
  + device_bvhs[0] = builder.build(device_bvh_type{}, thrust::raw_pointer_cast(primitives.data()), mod.primitives.size());
  + //std::cout << t.elapsed() << '\n';
  }
  else
  {
  + host_bvhs.resize(1);
  +
  binned_sah_builder builder;
  builder.enable_spatial_splits(build_strategy == Split);
  + //timer t;
  host_bvhs[0] = builder.build(host_bvh_type{}, mod.primitives.data(), mod.primitives.size());
  + //std::cout << t.elapsed() << '\n';
  }
  if (!env_map_filename.empty() && boost::filesystem::exists(env_map_filename))
  @@ -1539,6 +1557,8 @@ void renderer::render_hud()
  float focal_dist = cam.get_focal_distance();
  float lens_radius = cam.get_lens_radius();
  + if (!host_bvhs.empty())
  + {
  traverse_depth_first(
  host_bvhs[0],
  [&](renderer::host_bvh_type::node_type const& node)
  @@ -1551,6 +1571,7 @@ void renderer::render_hud()
  }
  }
  );
  + }
  static const std::string camera_file_base = "visionaray-camera";
  @@ -2699,6 +2720,8 @@ int main(int argc, char** argv)
  #ifdef __CUDACC__
  // Copy data to GPU
  try
  + {
  + if (rend.build_strategy != renderer::LBVH)
  {
  // Build up lower level bvhs first
  rend.device_bvhs.resize(rend.host_bvhs.size());
  @@ -2706,6 +2729,7 @@ int main(int argc, char** argv)
  {
  rend.device_bvhs[i] = renderer::device_bvh_type(rend.host_bvhs[i]);
  }
  + }
  // Make a deep copy of the top level bvh
  if (rend.host_top_level_bvh.num_primitives() > 0)
  