NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FW::SplitBVHBuilder Class Reference

Class performing SBVH build. More...

#include <SplitBVHBuilder.hpp>

Inherited by FW::OcclusionBVHBuilder.

Classes

struct  NodeSpec
 Structure holding specifications of the BVH's node. More...
 
struct  ObjectSplit
 Structure holding info about object split of a BVH node. More...
 
struct  Reference
 Structure holding triangle's index together with its bounding box. More...
 
struct  SpatialBin
 Structure holding info about a spatial bin. More...
 
struct  SpatialSplit
 Structure holding info about spatial split of a BVH node. More...
 

Public Member Functions

 SplitBVHBuilder (BVH &bvh, const BVH::BuildParams &params)
 Constructor. More...
 
 ~SplitBVHBuilder (void)
 Destructor. More...
 
BVHNoderun (void)
 Performs the actual build. More...
 
void splitReference (Reference &left, Reference &right, const Reference &ref, int dim, F32 pos)
 Splits the triangle's bounding box. More...
 

Static Public Member Functions

static bool sortCompare (void *data, int idxA, int idxB)
 Sort comparator. Sorts references according to their position in descending order. For details see framework/base.Sort.hpp. More...
 
static void sortSwap (void *data, int idxA, int idxB)
 Sort swap function. Swaps two references placed in the reference stack. For details see framework/base.Sort.hpp. More...
 

Protected Types

enum  { MaxDepth = 64, MaxSpatialDepth = 48, NumSpatialBins = 128 }
 Several tree build constrains. More...
 

Protected Member Functions

BVHNodebuildNode (NodeSpec spec, int level, F32 progressStart, F32 progressEnd)
 Builds a BVH node. The built node may be an inner node as well as a leaf node. More...
 
BVHNodecreateLeaf (const NodeSpec &spec)
 Builds a leaf node. More...
 
ObjectSplit findObjectSplit (const NodeSpec &spec, F32 nodeSAH)
 Finds best object split of the node. More...
 
void performObjectSplit (NodeSpec &left, NodeSpec &right, const NodeSpec &spec, const ObjectSplit &split)
 Performs the object split operation. More...
 
SpatialSplit findSpatialSplit (const NodeSpec &spec, F32 nodeSAH)
 Finds the best spatial split of the node. More...
 
void performSpatialSplit (NodeSpec &left, NodeSpec &right, const NodeSpec &spec, const SpatialSplit &split)
 Performs the spatial split operation. More...
 

Protected Attributes

BVHm_bvh
 BVH being built. More...
 
const Platformm_platform
 Platform settings. More...
 
const BVH::BuildParamsm_params
 Build parameters. More...
 
Array< Referencem_refStack
 Reference stack. More...
 
F32 m_minOverlap
 Minimum overlap of the left and right AABB of the object split needed to make spatial split worth finding. More...
 
Array< AABBm_rightBounds
 Bounding boxes of all the possible right children. More...
 
S32 m_sortDim
 Sort dimension. Used by sort method. More...
 
SpatialBin m_bins [3][NumSpatialBins]
 Spatial bins. More...
 
Timer m_progressTimer
 Progress timer. More...
 
S32 m_numDuplicates
 Number of duplicated references. More...
 

Detailed Description

Class performing SBVH build.

Definition at line 44 of file SplitBVHBuilder.hpp.

Member Enumeration Documentation

anonymous enum
protected

Several tree build constrains.

Enumerator
MaxDepth 

Maximum depth of the BVH tree.

MaxSpatialDepth 

Maximum depth of the BVH where spatial split will still be used.

NumSpatialBins 

Number of spatial bins per node in each axis.

Definition at line 51 of file SplitBVHBuilder.hpp.

Constructor & Destructor Documentation

SplitBVHBuilder::SplitBVHBuilder ( BVH bvh,
const BVH::BuildParams params 
)

Constructor.

Parameters
[out]bvhEmtpy BVH to be built.
[in]paramsBuild parameters.

Definition at line 35 of file SplitBVHBuilder.cpp.

SplitBVHBuilder::~SplitBVHBuilder ( void  )

Destructor.

Definition at line 46 of file SplitBVHBuilder.cpp.

Member Function Documentation

BVHNode * SplitBVHBuilder::buildNode ( NodeSpec  spec,
int  level,
F32  progressStart,
F32  progressEnd 
)
protected

Builds a BVH node. The built node may be an inner node as well as a leaf node.

Parameters
[in]specSpecifications of the node.
[in]levelLevel of the node in the tree.
[in]proggressStartPercentage of already built subtree.
[in]progressEndPercentage of already built subtree including node's subtree.
Returns
Built node.

Definition at line 114 of file SplitBVHBuilder.cpp.

BVHNode * SplitBVHBuilder::createLeaf ( const NodeSpec spec)
protected

Builds a leaf node.

Parameters
[in]specSpecifications of the node.
Returns
Built leaf node.

Definition at line 183 of file SplitBVHBuilder.cpp.

SplitBVHBuilder::ObjectSplit SplitBVHBuilder::findObjectSplit ( const NodeSpec spec,
F32  nodeSAH 
)
protected

Finds best object split of the node.

Parameters
[in]specSpecifications of the node.
[in]nodeSAHCost of the split without the cost of the triangles.
Returns
Found split.

Definition at line 193 of file SplitBVHBuilder.cpp.

SplitBVHBuilder::SpatialSplit SplitBVHBuilder::findSpatialSplit ( const NodeSpec spec,
F32  nodeSAH 
)
protected

Finds the best spatial split of the node.

Parameters
[in]specSpecifications of the node.
[in]nodeSAHCost of the split without the cost of the triangles.
Returns
Found split.

Definition at line 251 of file SplitBVHBuilder.cpp.

void SplitBVHBuilder::performObjectSplit ( NodeSpec left,
NodeSpec right,
const NodeSpec spec,
const ObjectSplit split 
)
protected

Performs the object split operation.

Parameters
[out]leftLeft child node specification.
[out]rightRight child node specification.
[in]specSpecification of the node being split.
[in]splitObject split information.

Definition at line 238 of file SplitBVHBuilder.cpp.

void SplitBVHBuilder::performSpatialSplit ( NodeSpec left,
NodeSpec right,
const NodeSpec spec,
const SpatialSplit split 
)
protected

Performs the spatial split operation.

Parameters
[out]leftLeft child node specification.
[out]rightRight child node specification.
[in]specSpecification of the node being split.
[in]splitSpatial split information.

Definition at line 334 of file SplitBVHBuilder.cpp.

BVHNode * SplitBVHBuilder::run ( void  )

Performs the actual build.

Returns
Root node of the built BVH.

Definition at line 52 of file SplitBVHBuilder.cpp.

bool SplitBVHBuilder::sortCompare ( void data,
int  idxA,
int  idxB 
)
static

Sort comparator. Sorts references according to their position in descending order. For details see framework/base.Sort.hpp.

Returns
True if idxB should go before idxA.

Definition at line 93 of file SplitBVHBuilder.cpp.

void SplitBVHBuilder::sortSwap ( void data,
int  idxA,
int  idxB 
)
static

Sort swap function. Swaps two references placed in the reference stack. For details see framework/base.Sort.hpp.

Definition at line 106 of file SplitBVHBuilder.cpp.

void SplitBVHBuilder::splitReference ( Reference left,
Reference right,
const Reference ref,
int  dim,
F32  pos 
)

Splits the triangle's bounding box.

Parameters
[out]leftLeft reference.
[out]rightRight reference.
[in]refReference being split.
[in]dimAxis of the split.
[in]posPosition of the split.

Definition at line 430 of file SplitBVHBuilder.cpp.

Member Data Documentation

SpatialBin FW::SplitBVHBuilder::m_bins[3][NumSpatialBins]
protected

Spatial bins.

Definition at line 236 of file SplitBVHBuilder.hpp.

BVH& FW::SplitBVHBuilder::m_bvh
protected

BVH being built.

Definition at line 228 of file SplitBVHBuilder.hpp.

F32 FW::SplitBVHBuilder::m_minOverlap
protected

Minimum overlap of the left and right AABB of the object split needed to make spatial split worth finding.

Definition at line 233 of file SplitBVHBuilder.hpp.

S32 FW::SplitBVHBuilder::m_numDuplicates
protected

Number of duplicated references.

Definition at line 239 of file SplitBVHBuilder.hpp.

const BVH::BuildParams& FW::SplitBVHBuilder::m_params
protected

Build parameters.

Definition at line 230 of file SplitBVHBuilder.hpp.

const Platform& FW::SplitBVHBuilder::m_platform
protected

Platform settings.

Definition at line 229 of file SplitBVHBuilder.hpp.

Timer FW::SplitBVHBuilder::m_progressTimer
protected

Progress timer.

Definition at line 238 of file SplitBVHBuilder.hpp.

Array<Reference> FW::SplitBVHBuilder::m_refStack
protected

Reference stack.

Definition at line 232 of file SplitBVHBuilder.hpp.

Array<AABB> FW::SplitBVHBuilder::m_rightBounds
protected

Bounding boxes of all the possible right children.

Definition at line 234 of file SplitBVHBuilder.hpp.

S32 FW::SplitBVHBuilder::m_sortDim
protected

Sort dimension. Used by sort method.

Definition at line 235 of file SplitBVHBuilder.hpp.


The documentation for this class was generated from the following files: