5 #include "raytracer/cl/structs.h" 7 #include "core/cl/common.h" 8 #include "core/conversions.h" 9 #include "core/pressure_intensity.h" 10 #include "core/spatial_division/scene_buffers.h" 12 #include "utilities/aligned/vector.h" 16 namespace stochastic {
18 constexpr
auto compute_ray_energy(
size_t total_rays,
24 return 2.0 / (4 * M_PI * total_rays * dist * dist * (1 - open_angle));
27 float compute_ray_energy(
size_t total_rays,
28 const glm::vec3& source,
29 const glm::vec3& receiver,
30 float receiver_radius);
38 const glm::vec3& source,
39 const glm::vec3& receiver,
40 float receiver_radius,
41 float starting_energy);
44 util::aligned::vector<impulse<core::simulation_bands>> specular;
45 util::aligned::vector<impulse<core::simulation_bands>> stochastic;
48 template <
typename It>
51 cl::copy(queue_, b, e, reflections_buffer_);
54 kernel_(cl::EnqueueArgs(queue_, cl::NDRange(rays_)),
58 scene_buffers.get_triangles_buffer(),
59 scene_buffers.get_vertices_buffer(),
60 scene_buffers.get_surfaces_buffer(),
61 stochastic_path_buffer_,
62 stochastic_output_buffer_,
63 specular_output_buffer_);
65 const auto read_out_impulses = [&](
const auto& buffer) {
66 auto raw = core::read_from_buffer<impulse<core::simulation_bands>>(
68 raw.erase(std::remove_if(begin(raw),
77 return results{read_out_impulses(specular_output_buffer_),
78 read_out_impulses(stochastic_output_buffer_)};
82 using kernel_t = decltype(std::declval<program>().get_kernel());
85 cl::CommandQueue queue_;
88 cl_float receiver_radius_;
91 cl::Buffer reflections_buffer_;
92 cl::Buffer stochastic_path_buffer_;
93 cl::Buffer stochastic_output_buffer_;
94 cl::Buffer specular_output_buffer_;
Definition: scene_buffers.h:12
Definition: pressure.h:22
Definition: capsule_base.h:9
invariant: device is a valid device for the context
Definition: common.h:13