bvh_builder.cpp 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // ======================================================================== //
  2. // Copyright 2009-2017 Intel Corporation //
  3. // //
  4. // Licensed under the Apache License, Version 2.0 (the "License"); //
  5. // you may not use this file except in compliance with the License. //
  6. // You may obtain a copy of the License at //
  7. // //
  8. // http://www.apache.org/licenses/LICENSE-2.0 //
  9. // //
  10. // Unless required by applicable law or agreed to in writing, software //
  11. // distributed under the License is distributed on an "AS IS" BASIS, //
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
  13. // See the License for the specific language governing permissions and //
  14. // limitations under the License. //
  15. // ======================================================================== //
  16. #include "bvh_builder.h"
  17. namespace embree
  18. {
  19. namespace isa
  20. {
  21. template<int N>
  22. typename BVHN<N>::NodeRef BVHNBuilderVirtual<N>::BVHNBuilderV::build(FastAllocator* allocator, BuildProgressMonitor& progressFunc, PrimRef* prims, const PrimInfo& pinfo, GeneralBVHBuilder::Settings settings)
  23. {
  24. auto createLeafFunc = [&] (const BVHBuilderBinnedSAH::BuildRecord& current, Allocator* alloc) -> NodeRef {
  25. return createLeaf(current,alloc);
  26. };
  27. settings.branchingFactor = N;
  28. settings.maxDepth = BVH::maxBuildDepthLeaf;
  29. return BVHBuilderBinnedSAH::build<NodeRef>
  30. (FastAllocator::CreateAlloc2(allocator),typename BVH::AlignedNode::Create2(),typename BVH::AlignedNode::Set3(allocator,prims),createLeafFunc,progressFunc,prims,pinfo,settings);
  31. }
  32. template<int N>
  33. typename BVHN<N>::NodeRef BVHNBuilderQuantizedVirtual<N>::BVHNBuilderV::build(FastAllocator* allocator, BuildProgressMonitor& progressFunc, PrimRef* prims, const PrimInfo& pinfo, GeneralBVHBuilder::Settings settings)
  34. {
  35. auto createLeafFunc = [&] (const BVHBuilderBinnedSAH::BuildRecord& current, Allocator* alloc) -> NodeRef {
  36. return createLeaf(current,alloc);
  37. };
  38. settings.branchingFactor = N;
  39. settings.maxDepth = BVH::maxBuildDepthLeaf;
  40. return BVHBuilderBinnedSAH::build<NodeRef>
  41. (FastAllocator::CreateAlloc2(allocator),typename BVH::QuantizedNode::Create2(),typename BVH::QuantizedNode::Set2(),createLeafFunc,progressFunc,prims,pinfo,settings);
  42. }
  43. template<int N>
  44. std::tuple<typename BVHN<N>::NodeRef,LBBox3fa> BVHNBuilderMblurVirtual<N>::BVHNBuilderV::build(FastAllocator* allocator, BuildProgressMonitor& progressFunc, PrimRef* prims, const PrimInfo& pinfo, GeneralBVHBuilder::Settings settings)
  45. {
  46. auto createLeafFunc = [&] (const BVHBuilderBinnedSAH::BuildRecord& current, Allocator* alloc) -> std::pair<NodeRef,LBBox3fa> {
  47. return createLeaf(current,alloc);
  48. };
  49. settings.branchingFactor = N;
  50. settings.maxDepth = BVH::maxBuildDepthLeaf;
  51. return BVHBuilderBinnedSAH::build<std::pair<NodeRef,LBBox3fa>>
  52. (FastAllocator::CreateAlloc2(allocator),typename BVH::AlignedNodeMB::Create2(),typename BVH::AlignedNodeMB::Set2(),createLeafFunc,progressFunc,prims,pinfo,settings);
  53. }
  54. template struct BVHNBuilderVirtual<4>;
  55. template struct BVHNBuilderQuantizedVirtual<4>;
  56. template struct BVHNBuilderMblurVirtual<4>;
  57. #if defined(__AVX__)
  58. template struct BVHNBuilderVirtual<8>;
  59. template struct BVHNBuilderQuantizedVirtual<8>;
  60. template struct BVHNBuilderMblurVirtual<8>;
  61. #endif
  62. }
  63. }