Wayverb
scene_structs.h
1 #pragma once
2 
3 #include "core/cl/representation.h"
4 #include "core/cl/traits.h"
5 
6 namespace wayverb {
7 namespace core {
8 
10 constexpr auto simulation_bands = 8;
11 
12 using bands_type = detail::cl_vector_constructor_t<float, simulation_bands>;
13 
14 template <>
15 struct cl_representation<bands_type> final {
16  static constexpr auto value = R"(
17 typedef float8 bands_type;
18 )";
19 };
20 
21 constexpr auto make_bands_type(float f) {
22  return construct_vector<simulation_bands>(f);
23 }
24 
26 
27 template <size_t bands>
28 struct alignas(1 << 5) surface {
29  using bands_t = std::integral_constant<size_t, bands>;
30  using container = detail::cl_vector_constructor_t<float, bands>;
31  container absorption;
32  container scattering;
33 };
34 
35 template <>
36 struct cl_representation<surface<simulation_bands>> final {
37  static constexpr auto value = R"(
38 typedef struct {
39  bands_type absorption;
40  bands_type scattering;
41 } surface;
42 )";
43 };
44 
45 template <size_t bands>
46 constexpr auto make_surface(float s, float d) {
47  return surface<bands>{construct_vector<bands>(s),
48  construct_vector<bands>(d)};
49 }
50 
51 template <size_t bands>
52 constexpr auto to_tuple(const surface<bands>& x) {
53  return std::tie(x.absorption, x.scattering);
54 }
55 
56 template <size_t bands>
57 constexpr bool operator==(const surface<bands>& a, const surface<bands>& b) {
58  return to_tuple(a) == to_tuple(b);
59 }
60 
61 template <size_t bands>
62 constexpr bool operator!=(const surface<bands>& a, const surface<bands>& b) {
63  return !(a == b);
64 }
65 
67 
68 struct alignas(1 << 4) triangle_verts final {
69  cl_float3 v0;
70  cl_float3 v1;
71  cl_float3 v2;
72 };
73 
74 template <>
76  static constexpr auto value = R"(
77 typedef struct {
78  float3 v0;
79  float3 v1;
80  float3 v2;
81 } triangle_verts;
82 )";
83 };
84 
85 constexpr auto to_tuple(const triangle_verts& x) {
86  return std::tie(x.v0, x.v1, x.v2);
87 }
88 
89 constexpr bool operator==(const triangle_verts& a, const triangle_verts& b) {
90  return to_tuple(a) == to_tuple(b);
91 }
92 
93 constexpr bool operator!=(const triangle_verts& a, const triangle_verts& b) {
94  return !(a == b);
95 }
96 
97 } // namespace core
98 } // namespace wayverb
Definition: representation.h:7
Definition: traits.cpp:2
Definition: scene_structs.h:28
Definition: scene_structs.h:68
Definition: capsule_base.h:9