Path: blob/master/thirdparty/embree/kernels/bvh/bvh_builder.h
9906 views
// Copyright 2009-2021 Intel Corporation1// SPDX-License-Identifier: Apache-2.023#include "bvh.h"4#include "../builders/bvh_builder_sah.h"5#include "../builders/bvh_builder_msmblur.h"67namespace embree8{9namespace isa10{11/************************************************************************************/12/************************************************************************************/13/************************************************************************************/14/************************************************************************************/1516template<int N>17struct BVHNBuilderVirtual18{19typedef BVHN<N> BVH;20typedef typename BVH::NodeRef NodeRef;21typedef FastAllocator::CachedAllocator Allocator;2223struct BVHNBuilderV {24NodeRef build(FastAllocator* allocator, BuildProgressMonitor& progress, PrimRef* prims, const PrimInfo& pinfo, GeneralBVHBuilder::Settings settings);25virtual NodeRef createLeaf (const PrimRef* prims, const range<size_t>& set, const Allocator& alloc) = 0;26};2728template<typename CreateLeafFunc>29struct BVHNBuilderT : public BVHNBuilderV30{31BVHNBuilderT (CreateLeafFunc createLeafFunc)32: createLeafFunc(createLeafFunc) {}3334NodeRef createLeaf (const PrimRef* prims, const range<size_t>& set, const Allocator& alloc) {35return createLeafFunc(prims,set,alloc);36}3738private:39CreateLeafFunc createLeafFunc;40};4142template<typename CreateLeafFunc>43static NodeRef build(FastAllocator* allocator, CreateLeafFunc createLeaf, BuildProgressMonitor& progress, PrimRef* prims, const PrimInfo& pinfo, GeneralBVHBuilder::Settings settings) {44return BVHNBuilderT<CreateLeafFunc>(createLeaf).build(allocator,progress,prims,pinfo,settings);45}46};4748template<int N>49struct BVHNBuilderQuantizedVirtual50{51typedef BVHN<N> BVH;52typedef typename BVH::NodeRef NodeRef;53typedef FastAllocator::CachedAllocator Allocator;5455struct BVHNBuilderV {56NodeRef build(FastAllocator* allocator, BuildProgressMonitor& progress, PrimRef* prims, const PrimInfo& pinfo, GeneralBVHBuilder::Settings settings);57virtual NodeRef createLeaf (const PrimRef* prims, const range<size_t>& set, const Allocator& alloc) = 0;58};5960template<typename CreateLeafFunc>61struct BVHNBuilderT : public BVHNBuilderV62{63BVHNBuilderT (CreateLeafFunc createLeafFunc)64: createLeafFunc(createLeafFunc) {}6566NodeRef createLeaf (const PrimRef* prims, const range<size_t>& set, const Allocator& alloc) {67return createLeafFunc(prims,set,alloc);68}6970private:71CreateLeafFunc createLeafFunc;72};7374template<typename CreateLeafFunc>75static NodeRef build(FastAllocator* allocator, CreateLeafFunc createLeaf, BuildProgressMonitor& progress, PrimRef* prims, const PrimInfo& pinfo, GeneralBVHBuilder::Settings settings) {76return BVHNBuilderT<CreateLeafFunc>(createLeaf).build(allocator,progress,prims,pinfo,settings);77}78};7980template<int N>81struct BVHNBuilderMblurVirtual82{83typedef BVHN<N> BVH;84typedef typename BVH::AABBNodeMB AABBNodeMB;85typedef typename BVH::NodeRef NodeRef;86typedef typename BVH::NodeRecordMB NodeRecordMB;87typedef FastAllocator::CachedAllocator Allocator;8889struct BVHNBuilderV {90NodeRecordMB build(FastAllocator* allocator, BuildProgressMonitor& progress, PrimRef* prims, const PrimInfo& pinfo, GeneralBVHBuilder::Settings settings, const BBox1f& timeRange);91virtual NodeRecordMB createLeaf (const PrimRef* prims, const range<size_t>& set, const Allocator& alloc) = 0;92};9394template<typename CreateLeafFunc>95struct BVHNBuilderT : public BVHNBuilderV96{97BVHNBuilderT (CreateLeafFunc createLeafFunc)98: createLeafFunc(createLeafFunc) {}99100NodeRecordMB createLeaf (const PrimRef* prims, const range<size_t>& set, const Allocator& alloc) {101return createLeafFunc(prims,set,alloc);102}103104private:105CreateLeafFunc createLeafFunc;106};107108template<typename CreateLeafFunc>109static NodeRecordMB build(FastAllocator* allocator, CreateLeafFunc createLeaf, BuildProgressMonitor& progress, PrimRef* prims, const PrimInfo& pinfo, GeneralBVHBuilder::Settings settings, const BBox1f& timeRange) {110return BVHNBuilderT<CreateLeafFunc>(createLeaf).build(allocator,progress,prims,pinfo,settings,timeRange);111}112};113}114}115116117