22template<
class Tmorton,
class Tvec, u32 dim>
24 make_empty(sham::DeviceScheduler_ptr dev_sched) {
27 MortonReducedSet<Tmorton, Tvec, dim>::make_empty(dev_sched),
28 KarrasRadixTree::make_empty(dev_sched),
29 KarrasRadixTreeAABB<Tvec>::make_empty(dev_sched)};
32template<
class Tmorton,
class Tvec, u32 dim>
33void shamtree::CompressedLeafBVH<Tmorton, Tvec, dim>::internal_rebuild_from_positions_no_aabb(
37 u32 compression_level) {
42 "obj_cnt is 0, cannot build a CompressedLeafBVH");
45 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
55 std::move(reduced_morton_set.morton_codes_set.sorted_morton_codes));
60 std::move(reduced_morton_set.morton_codes_set.map_morton_id_to_obj_id));
64 std::move(sorted_set),
66 std::move(reduced_morton_set.buf_reduc_index_map),
67 std::move(reduced_morton_set.reduced_morton_codes));
71 reduced_set.reduced_morton_codes.get_size(),
72 reduced_set.reduced_morton_codes,
73 std::move(structure));
75 this->reduced_morton_set = std::move(reduced_set);
76 this->structure = std::move(tree);
79template<
class Tmorton,
class Tvec, u32 dim>
84 u32 compression_level) {
86 this->internal_rebuild_from_positions_no_aabb(
87 positions, obj_cnt, bounding_box, compression_level);
92 std::move(this->aabbs),
95 this->
aabbs = std::move(tree_aabbs);
98template<
class Tmorton,
class Tvec, u32 dim>
99void shamtree::CompressedLeafBVH<Tmorton, Tvec, dim>::rebuild_from_position_range(
104 u32 compression_level) {
106 this->internal_rebuild_from_positions_no_aabb(min, obj_cnt, bounding_box, compression_level);
110 this->reduced_morton_set.get_leaf_cell_iterator(),
111 std::move(this->aabbs),
115 this->aabbs = std::move(tree_aabbs);
118template<
class Tmorton,
class Tvec, u32 dim>
122 u32 compression_level) {
126template<
class Tmorton,
class Tvec, u32 dim>
127void shamtree::CompressedLeafBVH<Tmorton, Tvec, dim>::rebuild_from_position_range(
131 u32 compression_level) {
132 if (min.get_size() != max.get_size()) {
134 "min and max must have the same size");
136 this->rebuild_from_position_range(min, max, min.get_size(), bounding_box, compression_level);
139template<
class Tmorton,
class Tvec, u32 dim>
148 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
149 auto &q = dev_sched->get_queue();
151 u32 int_cell_count =
structure.get_internal_cell_count();
157 auto traverser =
structure.get_structure_traverser();
169 [](
u32 gid,
auto tree_traverser,
u32 *height) {
170 u32 hl = height[tree_traverser.get_left_child(gid)];
171 u32 hr = height[tree_traverser.get_right_child(gid)];
173 height[gid] = 1 + sycl::max(hl, hr);
KarrasRadixTreeAABB< Tvec > compute_tree_aabb_from_position_ranges(const KarrasRadixTree &tree, const LeafCellIterator &cell_it, KarrasRadixTreeAABB< Tvec > &&recycled_tree_aabb, sham::DeviceBuffer< Tvec > &min, sham::DeviceBuffer< Tvec > &max)
same but for position ranges
KarrasRadixTreeAABB< Tvec > compute_tree_aabb_from_positions(const KarrasRadixTree &tree, const LeafCellIterator &cell_it, KarrasRadixTreeAABB< Tvec > &&recycled_tree_aabb, sham::DeviceBuffer< Tvec > &positions)
Compute the AABB of all cells in the tree from positions.
KarrasRadixTree karras_tree_from_morton_set(sham::DeviceScheduler_ptr dev_sched, u32 morton_count, sham::DeviceBuffer< Tmorton > &morton_codes, KarrasRadixTree &&recycled_tree)
Constructs a KarrasRadixTree from a set of reduced Morton codes.
MortonCodeSet< Tmorton, Tvec, dim > morton_code_set_from_positions(const sham::DeviceScheduler_ptr &dev_sched, shammath::AABB< Tvec > bounding_box, sham::DeviceBuffer< Tvec > &pos_buf, u32 cnt_obj, u32 morton_count, sham::DeviceBuffer< Tmorton > &&cache_buf_morton_codes)
Generate a set of Morton codes from a buffer of positions.
MortonCodeSortedSet< Tmorton, Tvec, dim > sort_morton_set(const sham::DeviceScheduler_ptr &dev_sched, MortonCodeSet< Tmorton, Tvec, dim > &&morton_codes_set)
Sorts a set of Morton codes and creates a new MortonCodeSortedSet object with the sorted codes and th...
MortonReducedSet< Tmorton, Tvec, dim > reduce_morton_set(const sham::DeviceScheduler_ptr &dev_sched, MortonCodeSortedSet< Tmorton, Tvec, dim > &&morton_codes_set, u32 reduction_level)
Reduces the given Morton code set by grouping together Morton codes that are close to each other in t...
std::uint32_t u32
32 bit unsigned integer
A buffer allocated in USM (Unified Shared Memory).
void fill(T value, std::array< size_t, 2 > idx_range)
Fill a subpart of the buffer with a given value.
T get_val_at_idx(size_t idx) const
Get the value at a given index in the buffer.
size_t get_size() const
Gets the number of elements in the buffer.
A Compressed Leaf Bounding Volume Hierarchy (CLBVH) for neighborhood queries.
bool is_empty() const
is the BVH empty ?
u32 get_exact_tree_depth() const
Compute the exact depth of the tree.
KarrasRadixTreeAABB< Tvec > aabbs
The bounding box of the tree cells.
MortonReducedSet< Tmorton, Tvec, dim > reduced_morton_set
The reduced set of Morton codes.
void rebuild_from_positions(sham::DeviceBuffer< Tvec > &positions, const shammath::AABB< Tvec > &bounding_box, u32 compression_level)
rebuild the BVH from the given positions
KarrasRadixTree structure
The tree structure.
static CompressedLeafBVH make_empty(sham::DeviceScheduler_ptr dev_sched)
make an empty BVH
This header file contains utility functions related to exception handling in the code.
void kernel_call(sham::DeviceQueue &q, RefIn in, RefOut in_out, u32 n, Functor &&func, SourceLocation &&callsite=SourceLocation{})
Submit a kernel to a SYCL queue.
constexpr T roundup_pow2(T v) noexcept
round up to the next power of two Source : https://graphics.stanford.edu/~seander/bithacks....
ExcptTypes make_except_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Create an exception with a message and a location.
This file contains the definition for the stacktrace related functionality.
#define __shamrock_stack_entry()
Macro to create a stack entry.
shambase::details::BasicStackEntry StackEntry
Alias for shambase::details::BasicStackEntry.
A class that references multiple buffers or similar objects.
Axis-Aligned bounding box.