Fermat
Classes | Public Methods | Public Members | List of all members
nih::cuda::Sah_builder Struct Reference

Detailed description

GPU-based SAH BVH builder.

GPU-based SAH BVH builder.

This builders provides the context to generate a bounding volume hierarchy using the Surface Area Heuristic out of a generic set of unsorted bounding boxes. The output is a set of nodes with the corresponding leaves and a set of primitive indices into the input set of points. The output leaves will specify contiguous ranges into this index.

The following code snippet shows how to use this builder:

#include <nih/bvh/cuda/sah_builder.h>
thrust::device_vector<Bbox4f> bboxes;
... // code to fill the input vector of bboxes
thrust::device_vector<Bvh_node> bvh_nodes;
thrust::device_vector<uint2> bvh_leaves;
thrust::device_vector<uint32> bvh_index;
nih::cuda::Sah_builder builder( bvh_nodes, bvh_leaves, bvh_index );
builder.build(
Bbox3f( Vector3f(0.0f), Vector3f(1.0f) ), // suppose all bboxes are in [0,1]^3
bboxes.begin(), // begin iterator
bboxes.end(), // end iterator
4 ); // target 4 objects per leaf

#include <sah_builder.h>

Classes

struct  Bbox
 
struct  Bin
 
struct  Bins
 
struct  Objects
 
struct  Queue
 
struct  Split
 

Public Methods

 Sah_builder (thrust::device_vector< Bvh_node > &nodes, thrust::device_vector< uint2 > &leaves, thrust::device_vector< uint32 > &index)
 constructor
 
template<typename Iterator >
void build (const uint32 BINS, const Bbox3f bbox, const Iterator bbox_begin, const Iterator bbox_end, const uint32 max_leaf_size, const float max_cost=1.8f)
 build a bvh given a set of bboxes
 
 Sah_builder (thrust::device_vector< Bvh_node > &nodes, thrust::device_vector< uint2 > &leaves, thrust::device_vector< uint32 > &index)
 
template<typename Iterator >
void build (const Bbox3f bbox, const Iterator bbox_begin, const Iterator bbox_end, const uint32 max_leaf_size, const float max_cost=1.8f)
 

Public Members

thrust::device_vector< Bvh_node > * m_nodes
 
thrust::device_vector< uint2 > * m_leaves
 
thrust::device_vector< uint32 > * m_index
 
uint32 m_levels [128]
 
uint32 m_level_count
 
Bbox3f m_bbox
 
uint32 m_node_count
 
uint32 m_leaf_count
 
float m_init_bins_time
 
float m_update_bins_time
 
float m_sah_split_time
 
float m_distribute_objects_time
 
thrust::device_vector< float3 > m_bin_bmin
 
thrust::device_vector< float3 > m_bin_bmax
 
thrust::device_vector< int32 > m_bin_size
 
thrust::device_vector< Binm_queue_bins
 
thrust::device_vector< Splitm_queue_splits
 
thrust::device_vector< uint32 > m_queue_offsets
 
thrust::device_vector< int4 > m_bin_ids
 
thrust::device_vector< int32 > m_split_ids
 
thrust::device_vector< int32 > m_node_ids
 
thrust::device_vector< uint32 > m_new_pos
 
thrust::device_vector< uint32 > m_counters
 
float m_sorting_time
 
float m_compression_time
 
uint32 m_temp_storage
 

Constructor & Destructor Documentation

◆ Sah_builder()

nih::cuda::Sah_builder::Sah_builder ( thrust::device_vector< Bvh_node > &  nodes,
thrust::device_vector< uint2 > &  leaves,
thrust::device_vector< uint32 > &  index 
)
inline

constructor

Parameters
nodesoutput nodes array
leavesoutput leaf array
indexoutput index array

Member Function Documentation

◆ build()

template<typename Iterator >
void nih::cuda::Sah_builder::build ( const Bbox3f  bbox,
const Iterator  bbox_begin,
const Iterator  bbox_end,
const uint32  max_leaf_size,
const float  max_cost = 1.8f 
)

build a bvh given a set of bboxes. The bbox iterators must be thrust-compatible (i.e. implementing dereference()).

Parameters
bboxglobal bbox
bbox_beginbeginning of the bbox sequence
bbox_endend of the bbox sequence
max_leaf_sizemaximum leaf size
max_costmaximum cost relative to the parent

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