Wayverb
scene_buffers.h
1 #pragma once
2 
3 #include "core/cl/voxel_structs.h"
4 #include "core/spatial_division/voxelised_scene_data.h"
5 
6 namespace wayverb {
7 namespace core {
8 
11 template <typename Vertex, typename Surface>
12 class generic_scene_buffers final {
13 public:
15  const cl::Context& context,
16  const voxelised_scene_data<Vertex, Surface>& scene_data)
17  : context_{context}
18  , voxel_index_{load_to_buffer(
19  context_, get_flattened(scene_data.get_voxels()), true)}
20  , global_aabb_{to_cl_float3{}(scene_data.get_voxels()
21  .get_aabb()
22  .get_min()),
23  to_cl_float3{}(scene_data.get_voxels()
24  .get_aabb()
25  .get_max())}
26  , side_{static_cast<cl_uint>(scene_data.get_voxels().get_side())}
27  , triangles_{load_to_buffer(
28  context_,
29  scene_data.get_scene_data().get_triangles(),
30  true)}
31  , vertices_{load_to_buffer(
32  context_,
33  scene_data.get_scene_data().get_vertices(),
34  true)}
35  , surfaces_{
36  load_to_buffer(context_,
37  scene_data.get_scene_data().get_surfaces(),
38  true)} {}
39 
40  cl::Context get_context() const { return context_; }
41 
42  const cl::Buffer& get_voxel_index_buffer() const { return voxel_index_; }
43  aabb get_global_aabb() const { return global_aabb_; }
44  cl_uint get_side() const { return side_; }
45 
46  const cl::Buffer& get_triangles_buffer() const { return triangles_; }
47  const cl::Buffer& get_vertices_buffer() const { return vertices_; }
48  const cl::Buffer& get_surfaces_buffer() const { return surfaces_; }
49 
50 private:
51  const cl::Context context_;
52 
53  const cl::Buffer voxel_index_;
54  const aabb global_aabb_;
55  const cl_uint side_;
56 
57  const cl::Buffer triangles_;
58  const cl::Buffer vertices_;
59  const cl::Buffer surfaces_;
60 };
61 
62 template <typename Vertex, typename Surface>
63 auto make_scene_buffers(
64  const cl::Context& context,
65  const voxelised_scene_data<Vertex, Surface>& scene_data) {
66  return generic_scene_buffers<Vertex, Surface>{context, scene_data};
67 }
68 
69 using scene_buffers =
71 
72 } // namespace core
73 } // namespace wayverb
Definition: voxel_structs.h:9
Definition: traits.cpp:2
Definition: conversions.h:10
Definition: scene_buffers.h:12
Definition: capsule_base.h:9
Definition: voxelised_scene_data.h:14
Definition: pressure.h:73