message: Optionally build LBVHs in viewer
diff: @@ -96,7 +96,8 @@ struct renderer : viewer_type
  enum bvh_build_strategy
  {
  Binned = 0, // Binned SAH builder, no spatial splits
  - Split // Split BVH, also binned and with SAH
  + Split, // Split BVH, also binned and with SAH
  + LBVH, // LBVH builder on the CPU
  };
  enum texture_format { Ptex, UV };
  @@ -147,7 +148,8 @@ struct renderer : viewer_type
  add_cmdline_option( cl::makeOption<bvh_build_strategy&>({
  { "default", Binned, "Binned SAH" },
  - { "split", Split, "Binned SAH with spatial splits" }
  + { "split", Split, "Binned SAH with spatial splits" },
  + { "lbvh", LBVH, "LBVH (CPU)" }
  },
  "bvh",
  cl::Desc("BVH build strategy"),
  @@ -698,12 +700,21 @@ void renderer::build_bvhs()
  if (mod.scene_graph == nullptr)
  {
  // Single BVH
  + host_bvhs.resize(1);
  + if (build_strategy == LBVH)
  + {
  + lbvh_builder builder;
  +
  + host_bvhs[0] = builder.build<host_bvh_type>(mod.primitives.data(), mod.primitives.size());
  + }
  + else
  + {
  binned_sah_builder builder;
  builder.enable_spatial_splits(build_strategy == Split);
  - host_bvhs.resize(1);
  host_bvhs[0] = builder.build<host_bvh_type>(mod.primitives.data(), mod.primitives.size());
  }
  + }
  else
  {
  reset_flags_visitor reset_visitor;
  @@ -736,6 +747,17 @@ void renderer::build_bvhs()
  }
  // Single BVH
  + if (build_strategy == LBVH)
  + {
  + lbvh_builder builder;
  +
  + host_top_level_bvh = builder.build<index_bvh<host_bvh_type::bvh_inst>>(
  + host_instances.data(),
  + host_instances.size()
  + );
  + }
  + else
  + {
  binned_sah_builder builder;
  builder.enable_spatial_splits(false);
  @@ -743,6 +765,7 @@ void renderer::build_bvhs()
  host_instances.data(),
  host_instances.size()
  );
  + }
  tex_format = renderer::UV;
  