Wayverb
structs.h
1 #pragma once
2 
3 #include "waveguide/cl/filter_structs.h"
4 
5 namespace wayverb {
6 namespace waveguide {
7 
8 typedef enum : cl_int {
9  id_success = 0,
10  id_inf_error = 1 << 0,
11  id_nan_error = 1 << 1,
12  id_outside_range_error = 1 << 2,
13  id_outside_mesh_error = 1 << 3,
14  id_suspicious_boundary_error = 1 << 4,
15 } error_code;
16 
18 
19 struct alignas(1 << 3) condensed_node final {
20  cl_int boundary_type{};
21  cl_uint boundary_index{};
22 };
23 
24 inline bool operator==(const condensed_node& a, const condensed_node& b) {
25  return std::tie(a.boundary_type, a.boundary_index) ==
26  std::tie(b.boundary_type, b.boundary_index);
27 }
28 
29 inline bool operator!=(const condensed_node& a, const condensed_node& b) {
30  return !(a == b);
31 }
32 
34 
38 struct alignas(1 << 3) boundary_data final {
39  memory_canonical filter_memory{};
40  cl_uint coefficient_index{};
41 };
42 
43 inline bool operator==(const boundary_data& a, const boundary_data& b) {
44  return std::tie(a.filter_memory, a.coefficient_index) ==
45  std::tie(b.filter_memory, b.coefficient_index);
46 }
47 
48 inline bool operator!=(const boundary_data& a, const boundary_data& b) {
49  return !(a == b);
50 }
51 
53 
54 template <size_t D>
55 struct alignas(1 << 3) boundary_data_array final {
56  static constexpr auto DIMENSIONS = D;
57  boundary_data array[DIMENSIONS]{};
58 };
59 
60 template <size_t D>
61 bool operator==(const boundary_data_array<D>& a,
62  const boundary_data_array<D>& b) {
63  return std::equal(begin(a.array), end(a.array), begin(b.array));
64 }
65 
66 template <size_t D>
67 bool operator!=(const boundary_data_array<D>& a,
68  const boundary_data_array<D>& b) {
69  return !(a == b);
70 }
71 
75 
76 } // namespace waveguide
77 
78 template <>
79 struct core::cl_representation<waveguide::error_code> final {
80  static constexpr auto value = R"(
81 typedef enum {
82  id_success = 0,
83  id_inf_error = 1 << 0,
84  id_nan_error = 1 << 1,
85  id_outside_range_error = 1 << 2,
86  id_outside_mesh_error = 1 << 3,
87  id_suspicious_boundary_error = 1 << 4,
88 } error_code;
89 )";
90 };
91 
92 template <>
93 struct core::cl_representation<waveguide::condensed_node> final {
94  static constexpr auto value = R"(
95 typedef struct {
96  int boundary_type;
97  uint boundary_index;
98 } condensed_node;
99 )";
100 };
101 
102 template <>
103 struct core::cl_representation<waveguide::boundary_data> final {
104  static constexpr auto value = R"(
105 typedef struct {
106  memory_canonical filter_memory;
107  uint coefficient_index;
108 } boundary_data;
109 )";
110 };
111 
112 template <>
113 struct core::cl_representation<waveguide::boundary_data_array_1> final {
114  static constexpr auto value = R"(
115 typedef struct { boundary_data array[1]; } boundary_data_array_1;
116 )";
117 };
118 
119 template <>
120 struct core::cl_representation<waveguide::boundary_data_array_2> final {
121  static constexpr auto value = R"(
122 typedef struct { boundary_data array[2]; } boundary_data_array_2;
123 )";
124 };
125 
126 template <>
127 struct core::cl_representation<waveguide::boundary_data_array_3> final {
128  static constexpr auto value = R"(
129 typedef struct { boundary_data array[3]; } boundary_data_array_3;
130 )";
131 };
132 
133 } // namespace wayverb
Definition: representation.h:7
Definition: structs.h:19
Definition: capsule_base.h:9
Definition: structs.h:38