30 #include <nih/bvh/bvh.h> 31 #include <nih/linalg/vector.h> 32 #include <nih/linalg/bbox.h> 33 #include <nih/bintree/bintree_node.h> 34 #include <nih/bintree/cuda/bintree_gen_context.h> 35 #include <thrust/device_vector.h> 45 thrust::device_vector<Bvh_node>& nodes,
46 thrust::device_vector<uint2>& leaves,
47 thrust::device_vector<uint32>& index) :
48 m_nodes( &nodes ), m_leaves( &leaves ), m_index( &index )
50 m_init_bins_time = 0.0f;
51 m_update_bins_time = 0.0f;
52 m_sah_split_time = 0.0f;
53 m_distribute_objects_time = 0.0f;
57 template <
typename Iterator>
61 const Iterator bbox_begin,
62 const Iterator bbox_end,
63 const uint32 max_leaf_size,
64 const float max_cost = 1.8f);
66 thrust::device_vector<Bvh_node>* m_nodes;
67 thrust::device_vector<uint2>* m_leaves;
68 thrust::device_vector<uint32>* m_index;
75 float m_init_bins_time;
76 float m_update_bins_time;
77 float m_sah_split_time;
78 float m_distribute_objects_time;
85 FORCE_INLINE NIH_HOST_DEVICE int32 get_size()
const {
return binary_cast<int32>( bmin.w ); }
86 FORCE_INLINE NIH_HOST_DEVICE
void set_size(
const int32 x) { bmin.w =
binary_cast<
float>(x); }
90 NIH_HOST_DEVICE
Split() {}
91 NIH_HOST_DEVICE
Split(int32
id, int32 plane) : task_id(
id), best_plane(plane) {}
119 volatile int32* size;
122 thrust::device_vector<float3> m_bin_bmin;
123 thrust::device_vector<float3> m_bin_bmax;
124 thrust::device_vector<int32> m_bin_size;
125 thrust::device_vector<Bin> m_queue_bins;
126 thrust::device_vector<Split> m_queue_splits;
127 thrust::device_vector<uint32> m_queue_offsets;
129 thrust::device_vector<int4> m_bin_ids;
130 thrust::device_vector<int32> m_split_ids;
131 thrust::device_vector<int32> m_node_ids;
132 thrust::device_vector<uint32> m_new_pos;
133 thrust::device_vector<uint32> m_counters;
139 #include <nih/bvh/cuda/sah_builder_inline.h> Sah_builder(thrust::device_vector< Bvh_node > &nodes, thrust::device_vector< uint2 > &leaves, thrust::device_vector< uint32 > &index)
constructor
Definition: sah_builder.h:44
Definition: sah_builder.h:37
Definition: sah_builder.h:115
Definition: sah_builder.h:103
Definition: sah_builder.h:110
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
Definition: sah_builder_inline.h:217
Definition: sah_builder.h:96
GPU-based SAH BVH builder.
Definition: sah_builder.h:41
Definition: sah_builder.h:80
Definition: sah_builder.h:88
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE Out binary_cast(const In in)
Definition: types.h:288