Fermat
Public Methods | Public Members | List of all members
cugar::cuda::Kd_builder< Integer > Struct Template Reference

Detailed description

template<typename Integer>
struct cugar::cuda::Kd_builder< Integer >

GPU-based middle-split k-d tree builder

This class provides the context to generate k-d trees on the GPU starting from a set of unordered points. 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.

Template Parameters
Integeran integer type that determines the number of bits used to compute the points' Morton codes. Accepted values are uint32 and uint64.
OutputTreea template class used to write the output tree, with the following interface:

struct OutputTree
{
void reserve_nodes(const uint32 n); // reserve space for n nodes
void reserve_leaves(const uint32 n); // reserve space for n leaves
Context get_context(); // get a context to write nodes/leaves
struct Context
{
void write_node(
const uint32 node, // node to write
const uint32 offset, // child offset
const uint32 skip_node, // skip node
const uint32 begin, // node range begin
const uint32 end, // node range end
const uint32 split_index, // split index
const uint32 split_dim, // splitting dimension
const uint32 split_plane); // splitting plane
void write_node(
const uint32 node, // node to write
const uint32 offset, // child offset
const uint32 skip_node, // skip node
const uint32 begin, // node range begin
const uint32 end); // node range end
void write_leaf(
const uint32 index, // leaf to write
const uint32 begin, // leaf range begin
const uint32 end); // leaf range end
};
};

The following code snippet shows how to use this builder:

... // code to fill the input vector of points
cugar::cuda::Kd_builder<uint64> builder( kd_index );
cugar::cuda::Kd_context kd_tree( &kd_nodes, &kd_leaves, &kd_ranges );
builder.build(
kd_tree, // output tree
kd_index, // output index
Bbox3f( Vector3f(0.0f), Vector3f(1.0f) ), // suppose all bboxes are in [0,1]^3
points.begin(), // begin iterator
points.end(), // end iterator
4 ); // target 4 objects per leaf

#include <kd_builder.h>

Public Methods

template<typename OutputTree , typename Iterator , typename BboxType >
void build (OutputTree &out_tree, vector< device_tag, uint32 > &out_index, const BboxType bbox, const Iterator points_begin, const Iterator points_end, const uint32 max_leaf_size)
 

Public Members

vector< device_tag, Integer > m_codes
 
caching_device_vector< Integer > m_temp_codes
 
caching_device_vector< uint32 > m_temp_index
 
uint32 m_node_count
 
uint32 m_leaf_count
 
cuda::Radixtree_context m_kd_context
 

Member Function Documentation

◆ build()

template<typename Integer >
template<typename OutputTree , typename Iterator , typename BboxType >
void cugar::cuda::Kd_builder< Integer >::build ( OutputTree &  out_tree,
vector< device_tag, uint32 > &  out_index,
const BboxType  bbox,
const Iterator  points_begin,
const Iterator  points_end,
const uint32  max_leaf_size 
)

build a bvh given a set of points that will be reordered in-place

Parameters
out_treeoutput tree
out_indexoutput index
bboxglobal bbox
points_beginbeginning of the point sequence to sort
points_endend of the point sequence to sort
max_leaf_sizemaximum leaf size

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