Wayverb
boundary_coefficient_finder.h
1 #pragma once
2 
3 #include "waveguide/cl/boundary_index_array.h"
4 #include "waveguide/cl/structs.h"
5 #include "waveguide/mesh_descriptor.h"
6 
7 #include "core/cl/representation.h"
8 #include "core/program_wrapper.h"
9 #include "core/spatial_division/scene_buffers.h"
10 
11 #include "utilities/popcount.h"
12 
13 namespace wayverb {
14 namespace waveguide {
15 
16 constexpr bool is_boundary(cl_int i) {
17  return !(i & id_reentrant || i & id_inside);
18 }
19 
20 template <size_t dim>
21 constexpr bool is_boundary(cl_int i) {
22  return is_boundary(i) && util::popcount(i) == dim;
23 }
24 
25 constexpr bool is_1d_boundary_or_reentrant(cl_int i) {
26  return i == id_reentrant || is_boundary<1>(i);
27 }
28 
29 template <typename It, typename Func>
30 size_t count_boundary_type(It begin, It end, Func f) {
31  return std::count_if(
32  begin, end, [&](const auto& i) { return f(i.boundary_type); });
33 }
34 
35 // or maybe keep the buffers on the gpu?
36 struct boundary_index_data final {
37  util::aligned::vector<boundary_index_array_1> b1;
38  util::aligned::vector<boundary_index_array_2> b2;
39  util::aligned::vector<boundary_index_array_3> b3;
40 };
41 
42 boundary_index_data compute_boundary_index_data(
43  const cl::Device& device,
44  const core::scene_buffers& buffers,
45  const mesh_descriptor& descriptor,
46  util::aligned::vector<condensed_node>& nodes);
47 
48 } // namespace waveguide
49 } // namespace wayverb
Definition: scene_buffers.h:12
Definition: capsule_base.h:9
Definition: boundary_coefficient_finder.h:36
Definition: mesh_descriptor.h:14