@woosh/meep-engine 3.74.0 → 3.75.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/CHANGELOG.md +20 -19
  2. package/package.json +1 -1
  3. package/src/core/geom/2d/hilbert/v2_hilbert_encode.d.ts +11 -0
  4. package/src/core/geom/2d/hilbert/v2_hilbert_encode.d.ts.map +1 -0
  5. package/src/core/geom/2d/hilbert/v2_hilbert_encode.js +46 -0
  6. package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts +6 -0
  7. package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts.map +1 -1
  8. package/src/engine/graphics/render/frame_graph/FrameGraph.js +9 -0
  9. package/src/engine/graphics3/GPUAcousticSystem.d.ts +29 -32
  10. package/src/engine/graphics3/GPUAcousticSystem.d.ts.map +1 -1
  11. package/src/engine/graphics3/GPUAcousticSystem.js +87 -162
  12. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  13. package/src/engine/sound/ecs/audio/AudioEmitterSystem.d.ts.map +1 -1
  14. package/src/engine/sound/ecs/audio/AudioEmitterSystem.js +35 -17
  15. package/src/engine/sound/ecs/audio/LiveEmitterSet.d.ts.map +1 -1
  16. package/src/engine/sound/ecs/audio/LiveEmitterSet.js +2 -3
  17. package/src/engine/sound/simulation/AcousticSimulator.d.ts +7 -0
  18. package/src/engine/sound/simulation/AcousticSimulator.d.ts.map +1 -1
  19. package/src/engine/sound/simulation/AcousticSimulator.js +27 -0
  20. package/src/engine/sound/simulation/README.md +121 -107
  21. package/src/engine/sound/sopra/README.md +8 -3
  22. package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.d.ts +2 -2
  23. package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.d.ts.map +1 -1
  24. package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.js +4 -3
  25. package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.d.ts +118 -0
  26. package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.d.ts.map +1 -0
  27. package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.js +472 -0
  28. package/src/engine/sound/sopra/runtime/AcousticReverbLines.d.ts +166 -0
  29. package/src/engine/sound/sopra/runtime/AcousticReverbLines.d.ts.map +1 -0
  30. package/src/engine/sound/sopra/runtime/AcousticReverbLines.js +447 -0
  31. package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.d.ts +69 -113
  32. package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.d.ts.map +1 -1
  33. package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.js +143 -491
  34. package/src/engine/sound/sopra/runtime/AcousticSpeakers.d.ts +102 -0
  35. package/src/engine/sound/sopra/runtime/AcousticSpeakers.d.ts.map +1 -0
  36. package/src/engine/sound/sopra/runtime/AcousticSpeakers.js +232 -0
  37. package/src/engine/sound/sopra/runtime/BusGraph.d.ts +17 -3
  38. package/src/engine/sound/sopra/runtime/BusGraph.d.ts.map +1 -1
  39. package/src/engine/sound/sopra/runtime/BusGraph.js +55 -5
  40. package/src/engine/sound/sopra/runtime/EventInstance.d.ts +8 -6
  41. package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -1
  42. package/src/engine/sound/sopra/runtime/EventInstance.js +113 -105
  43. package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.d.ts +13 -0
  44. package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.d.ts.map +1 -0
  45. package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.js +15 -0
  46. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.d.ts.map +1 -1
  47. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +4 -6
  48. package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.d.ts.map +1 -1
  49. package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.js +4 -5
  50. package/src/shade/playground/skinned_blas_refit/main.d.ts.map +1 -1
  51. package/src/shade/playground/skinned_blas_refit/main.js +6 -12
  52. package/src/shade/playground/skinned_mesh_soup/main.d.ts.map +1 -1
  53. package/src/shade/playground/skinned_mesh_soup/main.js +1 -2
  54. package/src/shade/playground/vgeo_scene/README.md +12 -2
  55. package/src/shade/playground/vgeo_scene/main.js +1 -1
  56. package/src/shade/playground/volumetrics_froxel/README.md +191 -191
  57. package/src/shade/playground/volumetrics_froxel/measure.d.ts +3 -3
  58. package/src/shade/playground/volumetrics_froxel/measure.d.ts.map +1 -1
  59. package/src/shade/playground/volumetrics_froxel/measure.js +11 -13
  60. package/src/shade/playground/vsm/main.d.ts.map +1 -1
  61. package/src/shade/playground/vsm/main.js +5 -6
  62. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  63. package/src/shade/renderer/Renderer.js +31 -8
  64. package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.d.ts +28 -0
  65. package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.d.ts.map +1 -0
  66. package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.js +42 -0
  67. package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.d.ts +58 -0
  68. package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.d.ts.map +1 -0
  69. package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.js +108 -0
  70. package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
  71. package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +161 -0
  72. package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts.map +1 -0
  73. package/src/shade/renderer/acoustics/GPUAcousticProbes.js +760 -0
  74. package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
  75. package/src/shade/renderer/acoustics/acoustic_listener_order.d.ts +12 -0
  76. package/src/shade/renderer/acoustics/acoustic_listener_order.d.ts.map +1 -0
  77. package/src/shade/renderer/acoustics/acoustic_listener_order.js +56 -0
  78. package/src/shade/renderer/acoustics/chunk_acoustic_direct.d.ts.map +1 -1
  79. package/src/shade/renderer/acoustics/chunk_acoustic_direct.js +5 -0
  80. package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.d.ts +57 -0
  81. package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.d.ts.map +1 -0
  82. package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.js +314 -0
  83. package/src/shade/renderer/acoustics/chunk_acoustic_finite.d.ts +15 -0
  84. package/src/shade/renderer/acoustics/chunk_acoustic_finite.d.ts.map +1 -0
  85. package/src/shade/renderer/acoustics/chunk_acoustic_finite.js +21 -0
  86. package/src/shade/renderer/acoustics/chunk_acoustic_gather.js +1 -1
  87. package/src/shade/renderer/acoustics/chunk_acoustic_lean.d.ts +27 -0
  88. package/src/shade/renderer/acoustics/chunk_acoustic_lean.d.ts.map +1 -0
  89. package/src/shade/renderer/acoustics/chunk_acoustic_lean.js +42 -0
  90. package/src/shade/renderer/acoustics/chunk_acoustic_listener.d.ts +80 -0
  91. package/src/shade/renderer/acoustics/chunk_acoustic_listener.d.ts.map +1 -0
  92. package/src/shade/renderer/acoustics/chunk_acoustic_listener.js +274 -0
  93. package/src/shade/renderer/acoustics/chunk_acoustic_partials.d.ts +2 -2
  94. package/src/shade/renderer/acoustics/chunk_acoustic_partials.js +2 -2
  95. package/src/shade/renderer/acoustics/chunk_acoustic_phonon.d.ts +7 -0
  96. package/src/shade/renderer/acoustics/chunk_acoustic_phonon.d.ts.map +1 -1
  97. package/src/shade/renderer/acoustics/chunk_acoustic_phonon.js +24 -1
  98. package/src/shade/renderer/acoustics/chunk_acoustic_resample.js +1 -1
  99. package/src/shade/renderer/acoustics/chunk_acoustic_reservoir.js +1 -1
  100. package/src/shade/renderer/acoustics/chunk_acoustic_through.d.ts +43 -0
  101. package/src/shade/renderer/acoustics/chunk_acoustic_through.d.ts.map +1 -0
  102. package/src/shade/renderer/acoustics/chunk_acoustic_through.js +153 -0
  103. package/src/shade/renderer/acoustics/chunk_acoustic_trace.d.ts +3 -1
  104. package/src/shade/renderer/acoustics/chunk_acoustic_trace.d.ts.map +1 -1
  105. package/src/shade/renderer/acoustics/chunk_acoustic_trace.js +10 -1
  106. package/src/shade/renderer/acoustics/shader_acoustic_combine.d.ts +7 -3
  107. package/src/shade/renderer/acoustics/shader_acoustic_combine.d.ts.map +1 -1
  108. package/src/shade/renderer/acoustics/shader_acoustic_combine.js +22 -6
  109. package/src/shade/renderer/acoustics/shader_acoustic_coupling.d.ts +14 -0
  110. package/src/shade/renderer/acoustics/shader_acoustic_coupling.d.ts.map +1 -0
  111. package/src/shade/renderer/acoustics/shader_acoustic_coupling.js +102 -0
  112. package/src/shade/renderer/acoustics/shader_acoustic_listener.d.ts +12 -0
  113. package/src/shade/renderer/acoustics/shader_acoustic_listener.d.ts.map +1 -0
  114. package/src/shade/renderer/acoustics/shader_acoustic_listener.js +80 -0
  115. package/src/shade/renderer/acoustics/shader_acoustic_receive.d.ts.map +1 -1
  116. package/src/shade/renderer/acoustics/shader_acoustic_receive.js +27 -6
  117. package/src/shade/renderer/acoustics/shader_acoustic_room.d.ts +11 -0
  118. package/src/shade/renderer/acoustics/shader_acoustic_room.d.ts.map +1 -0
  119. package/src/shade/renderer/acoustics/shader_acoustic_room.js +111 -0
  120. package/src/shade/renderer/acoustics/shader_acoustic_source.d.ts +18 -0
  121. package/src/shade/renderer/acoustics/shader_acoustic_source.d.ts.map +1 -0
  122. package/src/shade/renderer/acoustics/shader_acoustic_source.js +130 -0
  123. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  124. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  125. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -7
  126. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  127. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  128. package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.d.ts +2 -2
  129. package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.js +2 -2
  130. package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.d.ts +5 -2
  131. package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.d.ts.map +1 -1
  132. package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.js +5 -2
  133. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts +9 -2
  134. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts.map +1 -1
  135. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.js +48 -12
  136. package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.d.ts +0 -22
  137. package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.d.ts.map +1 -1
  138. package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.js +0 -42
  139. package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.d.ts +2 -18
  140. package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.d.ts.map +1 -1
  141. package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.js +2 -19
  142. package/src/shade/renderer/geometry/virtual/format/read/vgeo_page_worker_serve.d.ts.map +1 -1
  143. package/src/shade/renderer/geometry/virtual/format/read/vgeo_page_worker_serve.js +0 -1
  144. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts +5 -4
  145. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts.map +1 -1
  146. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.js +3 -1
  147. package/src/shade/renderer/geometry/virtual/runtime/VGeoFeedbackLoop.d.ts.map +1 -1
  148. package/src/shade/renderer/geometry/virtual/runtime/VGeoFeedbackLoop.js +3 -1
  149. package/src/shade/renderer/geometry/virtual/runtime/VGeoPageFetcher.d.ts.map +1 -1
  150. package/src/shade/renderer/geometry/virtual/runtime/VGeoPageFetcher.js +0 -1
  151. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.d.ts +60 -14
  152. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.d.ts.map +1 -1
  153. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.js +75 -39
  154. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts +0 -9
  155. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts.map +1 -1
  156. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.js +45 -17
  157. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +7 -3
  158. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
  159. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +43 -7
  160. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  161. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
@@ -0,0 +1,760 @@
1
+ import { assert } from "../../../core/assert.js";
2
+ import { BufferDescriptor } from "../../descriptor/buffer/BufferDescriptor.js";
3
+ import { GPUDatabase } from "../buffer/table/GPUDatabase.js";
4
+ import { GPUDatabaseReadback } from "../buffer/table/GPUDatabaseReadback.js";
5
+ import { GPUReadbackStatus } from "../buffer/table/GPUReadbackStatus.js";
6
+ import { gpu_table_gather_shader } from "../buffer/table/gpu_table_gather_shader.js";
7
+ import { generate_record_writer } from "../buffer/table/serde/generate_record_writer.js";
8
+ import {
9
+ WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION
10
+ } from "../gpu_primitive/indirect/WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION.js";
11
+ import { ACOUSTIC_FRAME_STRUCT } from "./ACOUSTIC_FRAME_STRUCT.js";
12
+ import {
13
+ ACOUSTIC_COUPLING_PARTIAL_VEC4S,
14
+ ACOUSTIC_LISTENER_GROUPS,
15
+ ACOUSTIC_LISTENER_PARTIAL_VEC4S
16
+ } from "./ACOUSTIC_LISTENER_RESOURCES.js";
17
+ import {
18
+ ACOUSTIC_DIRECT_DESCRIPTOR,
19
+ ACOUSTIC_DIRECT_STRUCT,
20
+ ACOUSTIC_DIRECT_TABLE,
21
+ ACOUSTIC_PROBE_DATABASE_INITIAL_SIZE,
22
+ ACOUSTIC_PROBE_DATABASE_SPEC,
23
+ ACOUSTIC_PROBE_RESULT_DESCRIPTOR,
24
+ ACOUSTIC_PROBE_RESULT_STRUCT,
25
+ ACOUSTIC_PROBE_RESULT_TABLE,
26
+ ACOUSTIC_SOURCE_STRUCT,
27
+ ACOUSTIC_SOURCE_TABLE
28
+ } from "./ACOUSTIC_PROBE_DATABASE_SPEC.js";
29
+ import { acoustic_listener_order } from "./acoustic_listener_order.js";
30
+ import { ACOUSTIC_LISTENER_HIT_STRUCT, ACOUSTIC_LISTENER_RAYS } from "./chunk_acoustic_listener.js";
31
+ import { shader_acoustic_coupling } from "./shader_acoustic_coupling.js";
32
+ import { shader_acoustic_listener } from "./shader_acoustic_listener.js";
33
+ import { shader_acoustic_room } from "./shader_acoustic_room.js";
34
+ import { shader_acoustic_source } from "./shader_acoustic_source.js";
35
+
36
+ /**
37
+ * @typedef {import("../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph} FrameGraph
38
+ * @typedef {import("../global_illumination/probe_clipmap/brick/GPUBrickClipmap.js").GPUBrickClipmap} GPUBrickClipmap
39
+ * @typedef {import("./GPUBrickAcoustics.js").GPUBrickAcoustics} GPUBrickAcoustics
40
+ * @typedef {import("../../device/pipeline/PipelineEnquiry.js").PipelineEnquiry} PipelineEnquiry
41
+ */
42
+
43
+ const SOURCE_WRITER = generate_record_writer(ACOUSTIC_SOURCE_STRUCT);
44
+ const DIRECT_WRITER = generate_record_writer(ACOUSTIC_DIRECT_STRUCT);
45
+ const ROOM_WRITER = generate_record_writer(ACOUSTIC_PROBE_RESULT_STRUCT);
46
+ const FRAME_WRITER = generate_record_writer(ACOUSTIC_FRAME_STRUCT);
47
+
48
+ const DIRECT_BYTES = ACOUSTIC_DIRECT_DESCRIPTOR.packed_element_size_bytes;
49
+ const ROOM_BYTES = ACOUSTIC_PROBE_RESULT_DESCRIPTOR.packed_element_size_bytes;
50
+
51
+ /** Floats of a source's row, and of the room, as they land. */
52
+ export const ACOUSTIC_DIRECT_FLOATS = DIRECT_BYTES / 4;
53
+ export const ACOUSTIC_ROOM_FLOATS = ROOM_BYTES / 4;
54
+
55
+ /** Where a source row's direct energy and its reverberant energy sit, in floats. */
56
+ export const ACOUSTIC_DIRECT_ENERGY = ACOUSTIC_DIRECT_STRUCT.fields.find(field => field.name === 'direct').offset / 4;
57
+ export const ACOUSTIC_DIRECT_REVERB = ACOUSTIC_DIRECT_STRUCT.fields.find(field => field.name === 'reverb').offset / 4;
58
+
59
+ /**
60
+ * Where a field of the room sits, in floats.
61
+ * @param {string} name
62
+ * @returns {number}
63
+ */
64
+ function room_float(name) {
65
+ return ACOUSTIC_PROBE_RESULT_STRUCT.fields.find(field => field.name === name).offset / 4;
66
+ }
67
+
68
+ const ROOM_ENERGY = room_float('energy');
69
+ const ROOM_INSIDE = room_float('inside');
70
+ const ROOM_CENTRE = room_float('centre');
71
+ const ROOM_ANSWERED = room_float('answered');
72
+ const ROOM_LEAN = room_float('lean');
73
+
74
+ /**
75
+ * Floats of the room about the listener ({@link GPUAcousticProbes#room}): energy per band, centre time per band, lean.
76
+ * @type {number}
77
+ */
78
+ export const ACOUSTIC_REVERB_FLOATS = 9;
79
+
80
+ /** Rows every per-row list starts with room for, doubling. */
81
+ const INITIAL_CAPACITY = 64;
82
+
83
+ /** Words of a reading in flight: handle, row, the epoch it lands in, the row's generation, and its kind. */
84
+ const FLIGHT_WORDS = 5;
85
+
86
+ const FLIGHT_SOURCE = 0;
87
+ const FLIGHT_ROOM = 1;
88
+
89
+ /**
90
+ * @param {Uint32Array|Uint8Array|Float32Array|Int32Array} array
91
+ * @param {number} length
92
+ * @returns {Uint32Array|Uint8Array|Float32Array|Int32Array} `array`, or a copy of it at least `length` long
93
+ */
94
+ function fit(array, length) {
95
+ if (array.length >= length) {
96
+ return array;
97
+ }
98
+
99
+ const grown = new array.constructor(Math.max(length, 2 * array.length));
100
+
101
+ grown.set(array);
102
+
103
+ return grown;
104
+ }
105
+
106
+ /**
107
+ * # The acoustics on the device: one probe at the listener, its hits shared by every source
108
+ *
109
+ * Every frame, from the listener:
110
+ *
111
+ * - **Its rays** (`shader_acoustic_listener`): {@link ACOUSTIC_LISTENER_RAYS} rays along a fixed Fibonacci sphere, each to
112
+ * its first hit, nothing further. Each hit stands for the piece of surface and the cone of room its solid angle
113
+ * covers.
114
+ * - **The room** (`shader_acoustic_room`): their sums by statistical room acoustics, its volume, its surface and its
115
+ * absorption, so its mean free path and Eyring's decay and diffuse level per band, and where its reflecting surface
116
+ * lies (`acoustic_room`).
117
+ * - **Each heard source** (`shader_acoustic_coupling`, `shader_acoustic_source`): one trace from every hit to the
118
+ * source, its first-order reflections at the listener through whatever walls stand between, and every order after
119
+ * as the room's absorption has them; and its direct path, a cone over its disk, a lane a cell of it: the share each
120
+ * occluder leaves open, and what the walls let through.
121
+ *
122
+ * Nothing is baked and nothing is averaged over frames; the rays are the same every frame, so a still scene reads the
123
+ * same. What the frame traced is read back: the room and the heard sources' rows.
124
+ *
125
+ * ## A frame
126
+ *
127
+ * add / move / remove the host's sources, as they start, move and stop
128
+ * set_heard(row, heard) whether a source is traced this frame
129
+ * record({ graph, ... }) the frame's pass: the rows' upload, the listener, the room, the sources, the readback
130
+ * apply() at the owner's apply point; and again whenever a mapping lands between frames
131
+ *
132
+ * Nothing is allocated per frame at steady state.
133
+ */
134
+ export class GPUAcousticProbes {
135
+ /**
136
+ * Offer the pipelines the acoustics dispatch — see {@link PipelineEnquiry}.
137
+ *
138
+ * @param {PipelineEnquiry} enquiry
139
+ */
140
+ static enquirePipelines(enquiry) {
141
+ GPUDatabase.enquirePipelines(enquiry);
142
+ enquiry.compute.push(shader_acoustic_listener.pipeline);
143
+ enquiry.compute.push(shader_acoustic_room.pipeline);
144
+ enquiry.compute.push(shader_acoustic_coupling.pipeline);
145
+ enquiry.compute.push(shader_acoustic_source.pipeline);
146
+ enquiry.compute.push(gpu_table_gather_shader.pipeline);
147
+ }
148
+
149
+ /** @type {GPUDevice} */
150
+ #device;
151
+
152
+ /** @type {GPUDatabase} */
153
+ #database;
154
+
155
+ /** @type {GPUDatabaseReadback} */
156
+ #readback;
157
+
158
+ #direct_handle;
159
+ #room_handle;
160
+
161
+ /** @type {import("../buffer/table/GPUTypedTable.js").GPUTypedTable} */
162
+ #sources;
163
+
164
+ /** @type {import("../buffer/table/GPUTypedTable.js").GPUTypedTable} */
165
+ #direct_table;
166
+
167
+ /** @type {import("../buffer/table/GPUTypedTable.js").GPUTypedTable} */
168
+ #room_table;
169
+
170
+ /** The room's row. */
171
+ #room_row;
172
+
173
+ /**
174
+ * The order the listener's rays are traced in, the listener's hits, the listener workgroups' sums, and each traced
175
+ * source's coupling sums.
176
+ * @type {GPUBuffer}
177
+ */
178
+ #order;
179
+ #hits;
180
+ #listener_partials;
181
+ #coupling_partials = null;
182
+ #coupling_capacity = 0;
183
+
184
+ /** The live source rows, dense, each row's place in it (or -1), and whether each is heard this frame. */
185
+ #live = new Uint32Array(INITIAL_CAPACITY);
186
+ #live_count = 0;
187
+ #place = new Int32Array(INITIAL_CAPACITY).fill(-1);
188
+ #heard = new Uint8Array(INITIAL_CAPACITY);
189
+
190
+ /** Each source row's result as it landed, and the same bytes; whether its current source has one; its generation. */
191
+ #direct = new Float32Array(ACOUSTIC_DIRECT_FLOATS * INITIAL_CAPACITY);
192
+ #direct_bytes = new Uint8Array(this.#direct.buffer);
193
+ #answered = new Uint8Array(INITIAL_CAPACITY);
194
+ #generation = new Uint32Array(INITIAL_CAPACITY);
195
+
196
+ /** The room as it last landed, and whether one has. */
197
+ #room = new Float32Array(ACOUSTIC_ROOM_FLOATS);
198
+ #room_bytes = new Uint8Array(this.#room.buffer);
199
+ #room_answered = false;
200
+
201
+ /** Readings in flight, {@link FLIGHT_WORDS} each. */
202
+ #flight = new Uint32Array(FLIGHT_WORDS * INITIAL_CAPACITY);
203
+ #flight_count = 0;
204
+ #epoch = 0;
205
+
206
+ /** Staging records. */
207
+ #source_record = { position: new Float32Array(3), radius: 0 };
208
+ #empty_direct = { direct: new Float32Array([1, 1, 1]), answered: 0, reverb: new Float32Array(3), reverb_rays: 0 };
209
+ #empty_room = {
210
+ energy: new Float32Array(3), inside: 0, centre: new Float32Array(3), answered: 0, lean: new Float32Array(3), escaped: 0,
211
+ absorption: new Float32Array([1, 1, 1]), mfp: 0,
212
+ };
213
+
214
+ #frame_record = {
215
+ listener: new Float32Array(3),
216
+ seed: 0,
217
+ axis_x: new Float32Array(3),
218
+ receiver_count: 0,
219
+ axis_y: new Float32Array(3),
220
+ cascade_count: 0,
221
+ axis_z: new Float32Array(3),
222
+ atlas_shift: 0,
223
+ fallback: new Uint32Array(4),
224
+ air: new Float32Array(3),
225
+ cohort: 0,
226
+ };
227
+
228
+ /** The frame uniform, and the words it is written from. */
229
+ #frame_buffer;
230
+ #frame_words = new Uint32Array(ACOUSTIC_FRAME_STRUCT.size / 4);
231
+ #frame_floats = new Float32Array(this.#frame_words.buffer);
232
+
233
+ /** What the frame's pass binds and reads, rewritten each frame. */
234
+ #pass = { acoustics: this, clipmap: null, payload: null, source_count: 0, sources: new Uint32Array(INITIAL_CAPACITY) };
235
+
236
+ #bindings = {};
237
+ #listener_dispatch = { encoder: null, group_count_x: ACOUSTIC_LISTENER_GROUPS, group_count_y: 1, bindings: this.#bindings };
238
+ #room_dispatch = { encoder: null, group_count_x: 1, group_count_y: 1, bindings: this.#bindings };
239
+ #coupling_dispatch = { encoder: null, group_count_x: ACOUSTIC_LISTENER_GROUPS, group_count_y: 0, group_count_z: 1, bindings: this.#bindings };
240
+ #source_dispatch = { encoder: null, group_count_x: 0, group_count_y: 1, bindings: this.#bindings };
241
+
242
+ #destroyed = false;
243
+
244
+ /** @type {(function(): void)|null} */
245
+ #on_landed;
246
+
247
+ /**
248
+ * @param {object} options
249
+ * @param {GPUDevice} options.device
250
+ * @param {(function(): void)|null} [options.on_landed] told when results land between frames, once applied
251
+ */
252
+ constructor({ device, on_landed = null }) {
253
+ assert.defined(device, 'device');
254
+
255
+ if (on_landed !== null) {
256
+ assert.isFunction(on_landed, 'on_landed');
257
+ }
258
+
259
+ this.#device = device;
260
+ this.#on_landed = on_landed;
261
+
262
+ this.#database = new GPUDatabase({
263
+ device,
264
+ definition: ACOUSTIC_PROBE_DATABASE_SPEC,
265
+ label: 'Acoustics',
266
+ initial_data_size_bytes: ACOUSTIC_PROBE_DATABASE_INITIAL_SIZE,
267
+ });
268
+
269
+ // its own, not the database's: the database's is encoded by its update, before the passes write the rows
270
+ this.#readback = new GPUDatabaseReadback({
271
+ database: this.#database,
272
+ device,
273
+ on_landed: this.#landed,
274
+ label: 'Acoustics / readback',
275
+ });
276
+
277
+ this.#direct_handle = this.#readback.table(ACOUSTIC_DIRECT_TABLE);
278
+ this.#room_handle = this.#readback.table(ACOUSTIC_PROBE_RESULT_TABLE);
279
+
280
+ this.#sources = this.#database.get(ACOUSTIC_SOURCE_TABLE);
281
+ this.#direct_table = this.#database.get(ACOUSTIC_DIRECT_TABLE);
282
+ this.#room_table = this.#database.get(ACOUSTIC_PROBE_RESULT_TABLE);
283
+
284
+ this.#room_row = this.#room_table.add_record(this.#empty_room, ROOM_WRITER);
285
+
286
+ this.#frame_buffer = device.createBuffer(BufferDescriptor.fromJSON({
287
+ label: 'Acoustics / frame',
288
+ size: ACOUSTIC_FRAME_STRUCT.size,
289
+ usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
290
+ }));
291
+
292
+ const order = acoustic_listener_order(ACOUSTIC_LISTENER_RAYS);
293
+
294
+ this.#order = device.createBuffer(BufferDescriptor.fromJSON({
295
+ label: 'Acoustics / listener ray order',
296
+ size: order.byteLength,
297
+ usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
298
+ }));
299
+
300
+ device.queue.writeBuffer(this.#order, 0, order);
301
+
302
+ this.#hits = device.createBuffer(BufferDescriptor.fromJSON({
303
+ label: 'Acoustics / listener hits',
304
+ size: ACOUSTIC_LISTENER_RAYS * ACOUSTIC_LISTENER_HIT_STRUCT.size,
305
+ usage: GPUBufferUsage.STORAGE,
306
+ }));
307
+
308
+ this.#listener_partials = device.createBuffer(BufferDescriptor.fromJSON({
309
+ label: 'Acoustics / listener sums',
310
+ size: ACOUSTIC_LISTENER_GROUPS * ACOUSTIC_LISTENER_PARTIAL_VEC4S * 16,
311
+ usage: GPUBufferUsage.STORAGE,
312
+ }));
313
+
314
+ this.#ensure_coupling(INITIAL_CAPACITY);
315
+ }
316
+
317
+ /**
318
+ * Sources live.
319
+ * @returns {number}
320
+ */
321
+ get count() {
322
+ return this.#live_count;
323
+ }
324
+
325
+ /**
326
+ * Each source row's result as it last landed, {@link ACOUSTIC_DIRECT_FLOATS} a row, laid out as
327
+ * `ACOUSTIC_DIRECT_STRUCT` (direct energy at {@link ACOUSTIC_DIRECT_ENERGY}, its reverberant energy at the listener
328
+ * at {@link ACOUSTIC_DIRECT_REVERB}); a row's is its current source's once {@link answered}. Replaced when the rows
329
+ * grow.
330
+ * @returns {Float32Array}
331
+ */
332
+ get direct() {
333
+ return this.#direct;
334
+ }
335
+
336
+ /**
337
+ * The readback the results travel through. For inspection.
338
+ * @returns {GPUDatabaseReadback}
339
+ */
340
+ get readback() {
341
+ return this.#readback;
342
+ }
343
+
344
+ /**
345
+ * @param {number} row
346
+ * @returns {boolean} whether a reading of the row's current source has landed
347
+ */
348
+ answered(row) {
349
+ return this.#answered[row] === 1;
350
+ }
351
+
352
+ /**
353
+ * A source starts: a row at `(x, y, z)` of radius `radius`, heard until told otherwise.
354
+ *
355
+ * @param {number} x world metres
356
+ * @param {number} y
357
+ * @param {number} z
358
+ * @param {number} radius metres, at least 0
359
+ * @returns {number} its row
360
+ */
361
+ add(x, y, z, radius) {
362
+ assert.notOk(this.#destroyed, 'destroyed');
363
+
364
+ const row = this.#sources.add_record(this.#write_source(x, y, z, radius), SOURCE_WRITER);
365
+
366
+ this.#direct_table.set_record(row, this.#empty_direct, DIRECT_WRITER);
367
+ this.#ensure_rows(row + 1);
368
+
369
+ this.#answered[row] = 0;
370
+ this.#generation[row]++;
371
+ this.#heard[row] = 1;
372
+
373
+ const place = this.#live_count++;
374
+
375
+ this.#live = fit(this.#live, this.#live_count);
376
+ this.#live[place] = row;
377
+ this.#place[row] = place;
378
+
379
+ return row;
380
+ }
381
+
382
+ /**
383
+ * The source moved, or its radius changed.
384
+ *
385
+ * @param {number} row
386
+ * @param {number} x
387
+ * @param {number} y
388
+ * @param {number} z
389
+ * @param {number} radius
390
+ */
391
+ move(row, x, y, z, radius) {
392
+ assert.greaterThanOrEqual(this.#place[row], 0, 'row is not a live source');
393
+
394
+ this.#sources.set_record(row, this.#write_source(x, y, z, radius), SOURCE_WRITER);
395
+ }
396
+
397
+ /**
398
+ * Whether the source is traced: a source out of hearing keeps its last result and costs nothing.
399
+ *
400
+ * @param {number} row
401
+ * @param {boolean} heard
402
+ */
403
+ set_heard(row, heard) {
404
+ this.#heard[row] = heard ? 1 : 0;
405
+ }
406
+
407
+ /**
408
+ * The source stopped: its rows are freed, and a reading of them in flight is dropped.
409
+ *
410
+ * @param {number} row
411
+ */
412
+ remove(row) {
413
+ const place = this.#place[row];
414
+
415
+ assert.greaterThanOrEqual(place, 0, 'row is not a live source');
416
+
417
+ const last = this.#live[--this.#live_count];
418
+
419
+ this.#live[place] = last;
420
+ this.#place[last] = place;
421
+ this.#place[row] = -1;
422
+ this.#answered[row] = 0;
423
+
424
+ this.#sources.remove(row);
425
+ this.#direct_table.remove(row);
426
+ }
427
+
428
+ #write_source(x, y, z, radius) {
429
+ const record = this.#source_record;
430
+
431
+ record.position[0] = x;
432
+ record.position[1] = y;
433
+ record.position[2] = z;
434
+ record.radius = radius;
435
+
436
+ return record;
437
+ }
438
+
439
+ /**
440
+ * @param {number} rows
441
+ */
442
+ #ensure_rows(rows) {
443
+ if (rows <= this.#answered.length) {
444
+ return;
445
+ }
446
+
447
+ const capacity = Math.max(rows, 2 * this.#answered.length);
448
+ const place = new Int32Array(capacity).fill(-1);
449
+
450
+ place.set(this.#place);
451
+
452
+ this.#place = place;
453
+ this.#answered = fit(this.#answered, capacity);
454
+ this.#generation = fit(this.#generation, capacity);
455
+ this.#heard = fit(this.#heard, capacity);
456
+ this.#direct = fit(this.#direct, ACOUSTIC_DIRECT_FLOATS * capacity);
457
+ this.#direct_bytes = new Uint8Array(this.#direct.buffer);
458
+ this.#epoch++;
459
+ }
460
+
461
+ /**
462
+ * Room for the coupling sums of `sources` traced sources: written whole by each frame's coupling pass before its
463
+ * source pass reads them, so nothing of the old is kept.
464
+ *
465
+ * @param {number} sources
466
+ */
467
+ #ensure_coupling(sources) {
468
+ if (sources <= this.#coupling_capacity) {
469
+ return;
470
+ }
471
+
472
+ this.#coupling_partials?.destroy();
473
+
474
+ this.#coupling_capacity = Math.max(sources, 2 * this.#coupling_capacity);
475
+
476
+ this.#coupling_partials = this.#device.createBuffer(BufferDescriptor.fromJSON({
477
+ label: 'Acoustics / coupling sums',
478
+ size: this.#coupling_capacity * ACOUSTIC_LISTENER_GROUPS * ACOUSTIC_COUPLING_PARTIAL_VEC4S * 16,
479
+ usage: GPUBufferUsage.STORAGE,
480
+ }));
481
+ }
482
+
483
+ /**
484
+ * The room about the listener as it last landed: none before the first, while the listener stands inside a solid,
485
+ * or where no ray of its resolved.
486
+ *
487
+ * @param {Float32Array} out {@link ACOUSTIC_REVERB_FLOATS}: energy per band (as a ratio to the free-field direct
488
+ * energy at 1 m), centre time per band (seconds), lean
489
+ * @returns {boolean} whether there is one
490
+ */
491
+ room(out) {
492
+ const room = this.#room;
493
+
494
+ if (!this.#room_answered || room[ROOM_INSIDE] > 0 || !(room[ROOM_ANSWERED] > 0)) {
495
+ out.fill(0);
496
+
497
+ return false;
498
+ }
499
+
500
+ for (let b = 0; b < 3; b++) {
501
+ out[b] = room[ROOM_ENERGY + b];
502
+ out[3 + b] = room[ROOM_CENTRE + b];
503
+ out[6 + b] = room[ROOM_LEAN + b];
504
+ }
505
+
506
+ return true;
507
+ }
508
+
509
+ /**
510
+ * Record the frame's pass into `graph`: the rows' upload, the listener's rays and the room they make, the heard
511
+ * sources' coupling and direct paths, traced through the bricks `clipmap` holds, then the readback's copy of what
512
+ * they wrote.
513
+ *
514
+ * @param {object} options
515
+ * @param {FrameGraph} options.graph
516
+ * @param {GPUBrickClipmap} options.clipmap
517
+ * @param {GPUBrickAcoustics} options.payload
518
+ * @param {ArrayLike<number>} options.listener world metres
519
+ * @param {ArrayLike<number>} options.air the ambient medium's absorption of energy per metre, per band
520
+ */
521
+ record({ graph, clipmap, payload, listener, air }) {
522
+ assert.notOk(this.#destroyed, 'destroyed');
523
+ assert.defined(graph, 'graph');
524
+ assert.defined(clipmap, 'clipmap');
525
+ assert.defined(payload, 'payload');
526
+
527
+ const frame = this.#frame_record;
528
+
529
+ frame.listener[0] = listener[0];
530
+ frame.listener[1] = listener[1];
531
+ frame.listener[2] = listener[2];
532
+ frame.cascade_count = clipmap.cascade_count;
533
+ frame.atlas_shift = clipmap.atlas_shift;
534
+ frame.air[0] = air[0];
535
+ frame.air[1] = air[1];
536
+ frame.air[2] = air[2];
537
+ frame.fallback.set(payload.fallback);
538
+
539
+ FRAME_WRITER.write_record(this.#frame_floats, this.#frame_words, 0, frame);
540
+
541
+ const pass = this.#pass;
542
+
543
+ pass.sources = fit(pass.sources, this.#live_count);
544
+
545
+ let sources = 0;
546
+
547
+ for (let i = 0; i < this.#live_count; i++) {
548
+ const row = this.#live[i];
549
+
550
+ if (this.#heard[row] === 1) {
551
+ pass.sources[sources++] = row;
552
+ }
553
+ }
554
+
555
+ // ascending rows: the readback copies a run of neighbouring rows as one, where rows out of order each take a
556
+ // copy, and a view, of their own. The live list is out of order only where a removal moved its last, so an
557
+ // insertion sort is about one pass
558
+ const list = pass.sources;
559
+
560
+ for (let i = 1; i < sources; i++) {
561
+ const row = list[i];
562
+ let j = i - 1;
563
+
564
+ while (j >= 0 && list[j] > row) {
565
+ list[j + 1] = list[j];
566
+ j--;
567
+ }
568
+
569
+ list[j + 1] = row;
570
+ }
571
+
572
+ pass.source_count = sources;
573
+ pass.clipmap = clipmap;
574
+ pass.payload = payload;
575
+
576
+ this.#ensure_coupling(sources);
577
+
578
+ // what the frame traces, read back
579
+ this.#flight = fit(this.#flight, FLIGHT_WORDS * (this.#flight_count + sources + 1));
580
+
581
+ this.#push_flight(this.#readback.request(this.#room_handle, this.#room_row, 0, ROOM_BYTES, this.#room_bytes, 0), this.#room_row, 0, FLIGHT_ROOM);
582
+
583
+ for (let i = 0; i < sources; i++) {
584
+ const row = pass.sources[i];
585
+ const handle = this.#readback.request(this.#direct_handle, row, 0, DIRECT_BYTES, this.#direct_bytes, row * DIRECT_BYTES);
586
+
587
+ this.#push_flight(handle, row, this.#generation[row], FLIGHT_SOURCE);
588
+ }
589
+
590
+ graph.add('Acoustics', pass, GPUAcousticProbes.#execute).make_side_effect();
591
+ }
592
+
593
+ #push_flight(handle, row, generation, kind) {
594
+ const f = FLIGHT_WORDS * this.#flight_count++;
595
+
596
+ this.#flight[f] = handle;
597
+ this.#flight[f + 1] = row;
598
+ this.#flight[f + 2] = this.#epoch;
599
+ this.#flight[f + 3] = generation;
600
+ this.#flight[f + 4] = kind;
601
+ }
602
+
603
+ /**
604
+ * @param {object} pass
605
+ * @param {*} resources
606
+ * @param {{encoder: import("../../device/ShadeGPUCommandContext.js").ShadeGPUCommandContext}} context
607
+ */
608
+ static #execute(pass, resources, context) {
609
+ const acoustics = pass.acoustics;
610
+
611
+ if (!acoustics.#destroyed) {
612
+ acoustics.#encode(context.encoder, pass);
613
+ }
614
+
615
+ pass.clipmap = null;
616
+ pass.payload = null;
617
+ }
618
+
619
+ /**
620
+ * @param {import("../../device/ShadeGPUCommandContext.js").ShadeGPUCommandContext} encoder
621
+ * @param {object} pass
622
+ */
623
+ #encode(encoder, pass) {
624
+ const database = this.#database;
625
+
626
+ if (database.has_pending_upload) {
627
+ database.update(encoder);
628
+ }
629
+
630
+ this.#device.queue.writeBuffer(this.#frame_buffer, 0, this.#frame_words);
631
+
632
+ const b = this.#bindings;
633
+
634
+ pass.clipmap.write_bindings(b);
635
+ pass.payload.write_bindings(b);
636
+
637
+ b.acoustic_frame = this.#frame_buffer;
638
+ b.database = database.buffer;
639
+ b.acoustic_listener_order = this.#order;
640
+ b.acoustic_listener_hits = this.#hits;
641
+ b.acoustic_listener_partials = this.#listener_partials;
642
+ b.acoustic_coupling_partials = this.#coupling_partials;
643
+
644
+ this.#run(shader_acoustic_listener, this.#listener_dispatch, encoder);
645
+ this.#run(shader_acoustic_room, this.#room_dispatch, encoder);
646
+
647
+ if (pass.source_count > 0) {
648
+ b.source_list = encoder.allocateTransientBufferAndLoad(pass.sources.buffer, GPUBufferUsage.STORAGE, 0, 4 * pass.source_count);
649
+ b.source_count = pass.source_count;
650
+
651
+ // the sources over y, folded over z past what a dimension is sure to hold
652
+ const coupling = this.#coupling_dispatch;
653
+
654
+ coupling.group_count_y = Math.min(pass.source_count, WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION);
655
+ coupling.group_count_z = Math.ceil(pass.source_count / WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION);
656
+
657
+ this.#run(shader_acoustic_coupling, coupling, encoder);
658
+
659
+ const source = this.#source_dispatch;
660
+
661
+ source.group_count_x = Math.min(pass.source_count, WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION);
662
+ source.group_count_y = Math.ceil(pass.source_count / source.group_count_x);
663
+
664
+ this.#run(shader_acoustic_source, source, encoder);
665
+ }
666
+
667
+ // right after the passes: the copy reads what they wrote
668
+ this.#readback.encode(encoder);
669
+ }
670
+
671
+ #run(shader, dispatch, encoder) {
672
+ dispatch.encoder = encoder;
673
+ shader.dispatch(dispatch);
674
+ dispatch.encoder = null;
675
+ }
676
+
677
+ /**
678
+ * A mapping landed between frames: apply it, and tell the owner if anything was delivered. Bound once.
679
+ * @type {function(): void}
680
+ */
681
+ #landed = () => {
682
+ if (this.apply() > 0 && this.#on_landed !== null) {
683
+ this.#on_landed();
684
+ }
685
+ };
686
+
687
+ /**
688
+ * The apply point: once a frame at the owner's, and again whenever a mapping lands between frames.
689
+ * @returns {number} readings delivered
690
+ */
691
+ apply() {
692
+ if (this.#destroyed) {
693
+ return 0;
694
+ }
695
+
696
+ this.#settle();
697
+
698
+ const delivered = this.#readback.apply();
699
+
700
+ this.#settle();
701
+
702
+ return delivered;
703
+ }
704
+
705
+ /**
706
+ * Let go of every reading in flight that has ended: one delivered answers its row, if it is still the source it
707
+ * was asked of, or the room; one dropped answers nothing.
708
+ */
709
+ #settle() {
710
+ const status = this.#readback.status;
711
+ const flight = this.#flight;
712
+ const count = this.#flight_count;
713
+
714
+ let kept = 0;
715
+
716
+ for (let i = 0; i < count; i++) {
717
+ const f = FLIGHT_WORDS * i;
718
+ const outcome = status[flight[f]];
719
+
720
+ if (outcome === GPUReadbackStatus.Delivered) {
721
+ const row = flight[f + 1];
722
+
723
+ if (flight[f + 4] === FLIGHT_ROOM) {
724
+ this.#room_answered = true;
725
+ } else if (flight[f + 2] === this.#epoch && flight[f + 3] === this.#generation[row]) {
726
+ // a row is written neutral, and a frame none of its rays resolved keeps what it had: either is its answer
727
+ this.#answered[row] = 1;
728
+ }
729
+
730
+ continue;
731
+ }
732
+
733
+ if (outcome === GPUReadbackStatus.Dropped) {
734
+ continue;
735
+ }
736
+
737
+ flight.copyWithin(FLIGHT_WORDS * kept, f, f + FLIGHT_WORDS);
738
+ kept++;
739
+ }
740
+
741
+ this.#flight_count = kept;
742
+ }
743
+
744
+ destroy() {
745
+ if (this.#destroyed) {
746
+ return;
747
+ }
748
+
749
+ this.#destroyed = true;
750
+ this.#flight_count = 0;
751
+
752
+ this.#readback.destroy();
753
+ this.#database.destroy();
754
+ this.#frame_buffer.destroy();
755
+ this.#order.destroy();
756
+ this.#hits.destroy();
757
+ this.#listener_partials.destroy();
758
+ this.#coupling_partials.destroy();
759
+ }
760
+ }