@woosh/meep-engine 3.29.0 → 3.31.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 (1766) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -1
  2. package/build/bundle-worker-terrain.js +1 -1
  3. package/package.json +3 -1
  4. package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
  5. package/src/core/binary/BinaryBuffer.js +56 -16
  6. package/src/core/binary/BitImage2.d.ts.map +1 -1
  7. package/src/core/binary/BitImage2.js +2 -6
  8. package/src/core/binary/BitSet.js +5 -5
  9. package/src/core/binary/compression/chunks_to_stream.d.ts +24 -0
  10. package/src/core/binary/compression/chunks_to_stream.d.ts.map +1 -0
  11. package/src/core/binary/compression/chunks_to_stream.js +35 -0
  12. package/src/core/binary/compression/compress_bytes.d.ts +3 -4
  13. package/src/core/binary/compression/compress_bytes.d.ts.map +1 -1
  14. package/src/core/binary/compression/compress_bytes.js +6 -17
  15. package/src/core/binary/compression/decompress_bytes.d.ts +1 -2
  16. package/src/core/binary/compression/decompress_bytes.d.ts.map +1 -1
  17. package/src/core/binary/compression/decompress_bytes.js +4 -15
  18. package/src/core/binary/compression/decompress_bytes_into.d.ts.map +1 -1
  19. package/src/core/binary/compression/decompress_bytes_into.js +2 -13
  20. package/src/core/binary/ctz32.d.ts +12 -4
  21. package/src/core/binary/ctz32.d.ts.map +1 -1
  22. package/src/core/binary/ctz32.js +23 -41
  23. package/src/core/binary/lsb_32.d.ts +10 -2
  24. package/src/core/binary/lsb_32.d.ts.map +1 -1
  25. package/src/core/binary/lsb_32.js +17 -12
  26. package/src/core/binary/lz4/lz4_compress_block_hc.js +2 -2
  27. package/src/core/binary/type/DataTypeIndices.d.ts +39 -0
  28. package/src/core/binary/type/DataTypeIndices.d.ts.map +1 -1
  29. package/src/core/binary/type/DataTypeIndices.js +38 -1
  30. package/src/core/binary/type/Type.d.ts.map +1 -1
  31. package/src/core/binary/type/Type.js +6 -1
  32. package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
  33. package/src/core/bvh2/bvh3/BVH.js +14 -1
  34. package/src/core/bvh2/bvh3/ebvh_optimize_treelet.js +3 -3
  35. package/src/core/bvh8/bvh8_geometry_validate.d.ts.map +1 -1
  36. package/src/core/bvh8/bvh8_geometry_validate.js +2 -88
  37. package/src/core/bvh8/bvh8_geometry_validate_bounds.d.ts +25 -0
  38. package/src/core/bvh8/bvh8_geometry_validate_bounds.d.ts.map +1 -0
  39. package/src/core/bvh8/bvh8_geometry_validate_bounds.js +105 -0
  40. package/src/core/bvh8/bvh8_geometry_validate_indirect.d.ts.map +1 -1
  41. package/src/core/bvh8/bvh8_geometry_validate_indirect.js +2 -91
  42. package/src/core/cache/FrequencySketch.d.ts +3 -1
  43. package/src/core/cache/FrequencySketch.d.ts.map +1 -1
  44. package/src/core/cache/FrequencySketch.js +10 -4
  45. package/src/core/cache/wtinylfu/CacheWTinylfu.d.ts.map +1 -1
  46. package/src/core/cache/wtinylfu/CacheWTinylfu.js +24 -2
  47. package/src/core/clipboard/obtainClipBoard.d.ts +4 -0
  48. package/src/core/clipboard/obtainClipBoard.d.ts.map +1 -1
  49. package/src/core/clipboard/obtainClipBoard.js +29 -8
  50. package/src/core/clipboard/safeClipboardReadText.d.ts.map +1 -1
  51. package/src/core/clipboard/safeClipboardReadText.js +73 -38
  52. package/src/core/clipboard/safeClipboardWriteText.d.ts.map +1 -1
  53. package/src/core/clipboard/safeClipboardWriteText.js +11 -9
  54. package/src/core/collection/array/iterator/ArrayIteratorRandom.d.ts.map +1 -1
  55. package/src/core/collection/array/iterator/ArrayIteratorRandom.js +6 -0
  56. package/src/core/collection/heap/IndexedFloatMinHeap.d.ts +6 -0
  57. package/src/core/collection/heap/IndexedFloatMinHeap.d.ts.map +1 -1
  58. package/src/core/collection/heap/IndexedFloatMinHeap.js +14 -0
  59. package/src/core/collection/list/FilteredListProjection.d.ts.map +1 -1
  60. package/src/core/collection/list/FilteredListProjection.js +7 -54
  61. package/src/core/collection/list/List.d.ts +4 -0
  62. package/src/core/collection/list/List.d.ts.map +1 -1
  63. package/src/core/collection/list/List.js +10 -52
  64. package/src/core/collection/list/SortedListProjection.d.ts +7 -0
  65. package/src/core/collection/list/SortedListProjection.d.ts.map +1 -1
  66. package/src/core/collection/list/SortedListProjection.js +12 -0
  67. package/src/core/collection/list/list_apply_ordered_diff.d.ts +37 -0
  68. package/src/core/collection/list/list_apply_ordered_diff.d.ts.map +1 -0
  69. package/src/core/collection/list/list_apply_ordered_diff.js +87 -0
  70. package/src/core/collection/map/BiMap.d.ts.map +1 -1
  71. package/src/core/collection/map/BiMap.js +19 -6
  72. package/src/core/collection/map/HashMap.d.ts.map +1 -1
  73. package/src/core/collection/map/HashMap.js +38 -11
  74. package/src/core/collection/queue/Deque.d.ts +2 -2
  75. package/src/core/collection/queue/Deque.d.ts.map +1 -1
  76. package/src/core/collection/queue/Deque.js +12 -1
  77. package/src/core/collection/table/RowFirstTable.d.ts.map +1 -1
  78. package/src/core/collection/table/RowFirstTable.js +15 -2
  79. package/src/core/collection/table/serializeRowFirstTable.d.ts.map +1 -1
  80. package/src/core/collection/table/serializeRowFirstTable.js +2 -3
  81. package/src/core/color/operations/color_lerp.d.ts.map +1 -1
  82. package/src/core/color/operations/color_lerp.js +77 -55
  83. package/src/core/color/sRGB/linear_to_sRGB.d.ts.map +1 -1
  84. package/src/core/color/sRGB/linear_to_sRGB.js +3 -1
  85. package/src/core/debug/matchers/AllOf.d.ts +2 -1
  86. package/src/core/debug/matchers/AllOf.d.ts.map +1 -1
  87. package/src/core/debug/matchers/AllOf.js +1 -1
  88. package/src/core/debug/matchers/AnyOf.d.ts +2 -1
  89. package/src/core/debug/matchers/AnyOf.d.ts.map +1 -1
  90. package/src/core/debug/matchers/AnyOf.js +1 -1
  91. package/src/core/debug/matchers/CombinableMatcher.d.ts +2 -1
  92. package/src/core/debug/matchers/CombinableMatcher.d.ts.map +1 -1
  93. package/src/core/debug/matchers/CombinableMatcher.js +1 -1
  94. package/src/core/debug/matchers/DescribeAs.d.ts +2 -1
  95. package/src/core/debug/matchers/DescribeAs.d.ts.map +1 -1
  96. package/src/core/debug/matchers/DescribeAs.js +2 -1
  97. package/src/core/debug/matchers/IsAnything.d.ts +2 -1
  98. package/src/core/debug/matchers/IsAnything.d.ts.map +1 -1
  99. package/src/core/debug/matchers/IsAnything.js +2 -1
  100. package/src/core/debug/matchers/IsEqual.d.ts +2 -1
  101. package/src/core/debug/matchers/IsEqual.d.ts.map +1 -1
  102. package/src/core/debug/matchers/IsEqual.js +2 -1
  103. package/src/core/debug/matchers/IsFinite.d.ts +2 -1
  104. package/src/core/debug/matchers/IsFinite.d.ts.map +1 -1
  105. package/src/core/debug/matchers/IsFinite.js +2 -1
  106. package/src/core/debug/matchers/IsIn.d.ts +2 -1
  107. package/src/core/debug/matchers/IsIn.d.ts.map +1 -1
  108. package/src/core/debug/matchers/IsIn.js +2 -1
  109. package/src/core/debug/matchers/IsInteger.d.ts +2 -1
  110. package/src/core/debug/matchers/IsInteger.d.ts.map +1 -1
  111. package/src/core/debug/matchers/IsInteger.js +2 -1
  112. package/src/core/debug/matchers/IsIterableContaining.d.ts +2 -1
  113. package/src/core/debug/matchers/IsIterableContaining.d.ts.map +1 -1
  114. package/src/core/debug/matchers/IsIterableContaining.js +1 -1
  115. package/src/core/debug/matchers/IsNot.d.ts +2 -1
  116. package/src/core/debug/matchers/IsNot.d.ts.map +1 -1
  117. package/src/core/debug/matchers/IsNot.js +2 -1
  118. package/src/core/debug/matchers/IsNull.d.ts +2 -1
  119. package/src/core/debug/matchers/IsNull.d.ts.map +1 -1
  120. package/src/core/debug/matchers/IsNull.js +2 -1
  121. package/src/core/debug/matchers/IsUndefined.d.ts +2 -1
  122. package/src/core/debug/matchers/IsUndefined.d.ts.map +1 -1
  123. package/src/core/debug/matchers/IsUndefined.js +2 -1
  124. package/src/core/events/signal/Signal.d.ts +15 -0
  125. package/src/core/events/signal/Signal.d.ts.map +1 -1
  126. package/src/core/events/signal/Signal.js +857 -820
  127. package/src/core/fsm/simple/SimpleStateMachineDescription.d.ts.map +1 -1
  128. package/src/core/fsm/simple/SimpleStateMachineDescription.js +4 -3
  129. package/src/core/geom/2d/convex-hull/convex_hull_fixed_count_2d_bruteforce.d.ts.map +1 -1
  130. package/src/core/geom/2d/convex-hull/convex_hull_fixed_count_2d_bruteforce.js +6 -1
  131. package/src/core/geom/2d/convex-hull/convex_hull_fixed_count_2d_relaxation.d.ts +1 -1
  132. package/src/core/geom/2d/convex-hull/convex_hull_fixed_count_2d_relaxation.d.ts.map +1 -1
  133. package/src/core/geom/2d/convex-hull/convex_hull_fixed_count_2d_relaxation.js +6 -7
  134. package/src/core/geom/2d/hash-grid/SpatialHashGrid.d.ts.map +1 -1
  135. package/src/core/geom/2d/hash-grid/SpatialHashGrid.js +23 -6
  136. package/src/core/geom/2d/line/ray2_ray2_compute_intersection_array_2d.d.ts.map +1 -1
  137. package/src/core/geom/2d/line/ray2_ray2_compute_intersection_array_2d.js +13 -1
  138. package/src/core/geom/3d/aabb/aabb3_raycast_hit_point.d.ts.map +1 -1
  139. package/src/core/geom/3d/aabb/aabb3_raycast_hit_point.js +53 -32
  140. package/src/core/geom/3d/atlas/segment/atlas_chart_growth_cost.d.ts +40 -0
  141. package/src/core/geom/3d/atlas/segment/atlas_chart_growth_cost.d.ts.map +1 -0
  142. package/src/core/geom/3d/atlas/segment/atlas_chart_growth_cost.js +54 -0
  143. package/src/core/geom/3d/atlas/segment/atlas_segment_charts.d.ts +21 -3
  144. package/src/core/geom/3d/atlas/segment/atlas_segment_charts.d.ts.map +1 -1
  145. package/src/core/geom/3d/atlas/segment/atlas_segment_charts.js +24 -15
  146. package/src/core/geom/3d/atlas/segment/atlas_segment_charts_atomic.d.ts +6 -3
  147. package/src/core/geom/3d/atlas/segment/atlas_segment_charts_atomic.d.ts.map +1 -1
  148. package/src/core/geom/3d/atlas/segment/atlas_segment_charts_atomic.js +9 -15
  149. package/src/core/geom/3d/cone/cone_compute_plane_side.d.ts.map +1 -1
  150. package/src/core/geom/3d/cone/cone_compute_plane_side.js +31 -19
  151. package/src/core/geom/3d/equirectangular/equirectangular_direction_to_uv.d.ts +11 -1
  152. package/src/core/geom/3d/equirectangular/equirectangular_direction_to_uv.d.ts.map +1 -1
  153. package/src/core/geom/3d/equirectangular/equirectangular_direction_to_uv.js +11 -1
  154. package/src/core/geom/3d/equirectangular/equirectangular_uv_to_direction.d.ts +11 -1
  155. package/src/core/geom/3d/equirectangular/equirectangular_uv_to_direction.d.ts.map +1 -1
  156. package/src/core/geom/3d/equirectangular/equirectangular_uv_to_direction.js +11 -1
  157. package/src/core/geom/3d/frustum/frustum3_compute_closest_point.d.ts.map +1 -1
  158. package/src/core/geom/3d/frustum/frustum3_compute_closest_point.js +55 -0
  159. package/src/core/geom/3d/frustum/frustum_from_projection_matrix_array.d.ts +14 -0
  160. package/src/core/geom/3d/frustum/frustum_from_projection_matrix_array.d.ts.map +1 -1
  161. package/src/core/geom/3d/frustum/frustum_from_projection_matrix_array.js +17 -1
  162. package/src/core/geom/3d/gjk/gjk.d.ts +15 -0
  163. package/src/core/geom/3d/gjk/gjk.d.ts.map +1 -1
  164. package/src/core/geom/3d/gjk/gjk.js +15 -0
  165. package/src/core/geom/3d/gjk/gjk_epa_penetration.d.ts.map +1 -1
  166. package/src/core/geom/3d/gjk/gjk_epa_penetration.js +18 -0
  167. package/src/core/geom/3d/hash-grid/PointHashGrid3.d.ts +32 -3
  168. package/src/core/geom/3d/hash-grid/PointHashGrid3.d.ts.map +1 -1
  169. package/src/core/geom/3d/hash-grid/PointHashGrid3.js +36 -3
  170. package/src/core/geom/3d/morton/v3_morton_encode_lut.d.ts.map +1 -1
  171. package/src/core/geom/3d/morton/v3_morton_encode_lut.js +11 -4
  172. package/src/core/geom/3d/morton/v3_morton_encode_normalized.d.ts +16 -4
  173. package/src/core/geom/3d/morton/v3_morton_encode_normalized.d.ts.map +1 -1
  174. package/src/core/geom/3d/morton/v3_morton_encode_normalized.js +21 -8
  175. package/src/core/geom/3d/normal/spherical/encode_unit_to_spheremap.d.ts.map +1 -1
  176. package/src/core/geom/3d/normal/spherical/encode_unit_to_spheremap.js +17 -3
  177. package/src/core/geom/3d/octahedra/octahedral_direction_to_uv.d.ts +10 -0
  178. package/src/core/geom/3d/octahedra/octahedral_direction_to_uv.d.ts.map +1 -1
  179. package/src/core/geom/3d/octahedra/octahedral_direction_to_uv.js +46 -49
  180. package/src/core/geom/3d/octahedra/octahedral_uv_to_direction.d.ts +13 -1
  181. package/src/core/geom/3d/octahedra/octahedral_uv_to_direction.d.ts.map +1 -1
  182. package/src/core/geom/3d/octahedra/octahedral_uv_to_direction.js +36 -39
  183. package/src/core/geom/3d/quadric/quadric3_to_tensor_m3_inverse.d.ts +4 -1
  184. package/src/core/geom/3d/quadric/quadric3_to_tensor_m3_inverse.d.ts.map +1 -1
  185. package/src/core/geom/3d/quadric/quadric3_to_tensor_m3_inverse.js +22 -4
  186. package/src/core/geom/3d/quaternion/quat3_canonicalize_sign_run.d.ts +38 -0
  187. package/src/core/geom/3d/quaternion/quat3_canonicalize_sign_run.d.ts.map +1 -0
  188. package/src/core/geom/3d/quaternion/quat3_canonicalize_sign_run.js +76 -0
  189. package/src/core/geom/3d/quaternion/quat3_encode_to_uint32.d.ts +11 -0
  190. package/src/core/geom/3d/quaternion/quat3_encode_to_uint32.d.ts.map +1 -1
  191. package/src/core/geom/3d/quaternion/quat3_encode_to_uint32.js +14 -34
  192. package/src/core/geom/3d/shape/PosedShape3D.d.ts +9 -0
  193. package/src/core/geom/3d/shape/PosedShape3D.d.ts.map +1 -1
  194. package/src/core/geom/3d/shape/PosedShape3D.js +43 -0
  195. package/src/core/geom/3d/shape/UnionShape3D.d.ts.map +1 -1
  196. package/src/core/geom/3d/shape/UnionShape3D.js +20 -3
  197. package/src/core/geom/3d/shape/json/type_adapters.d.ts +11 -2
  198. package/src/core/geom/3d/shape/json/type_adapters.d.ts.map +1 -1
  199. package/src/core/geom/3d/shape/json/type_adapters.js +36 -12
  200. package/src/core/geom/3d/sphere/harmonics/sh3_sample_irradiance_by_direction.d.ts +13 -0
  201. package/src/core/geom/3d/sphere/harmonics/sh3_sample_irradiance_by_direction.d.ts.map +1 -1
  202. package/src/core/geom/3d/sphere/harmonics/sh3_sample_irradiance_by_direction.js +17 -4
  203. package/src/core/geom/3d/tetrahedra/tetrahedral_flip_layouts.d.ts +88 -0
  204. package/src/core/geom/3d/tetrahedra/tetrahedral_flip_layouts.d.ts.map +1 -0
  205. package/src/core/geom/3d/tetrahedra/tetrahedral_flip_layouts.js +108 -0
  206. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.d.ts.map +1 -1
  207. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.js +13 -31
  208. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.d.ts.map +1 -1
  209. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.js +14 -22
  210. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.d.ts.map +1 -1
  211. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.js +96 -26
  212. package/src/core/geom/3d/tetrahedra/tetrahedron_contains_point.d.ts.map +1 -1
  213. package/src/core/geom/3d/tetrahedra/tetrahedron_contains_point.js +17 -6
  214. package/src/core/geom/3d/topology/struct/binary/io/bt_boundary_loop.d.ts +27 -0
  215. package/src/core/geom/3d/topology/struct/binary/io/bt_boundary_loop.d.ts.map +1 -1
  216. package/src/core/geom/3d/topology/struct/binary/io/bt_boundary_loop.js +101 -0
  217. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts +3 -0
  218. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts.map +1 -1
  219. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.js +5 -57
  220. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadrics.d.ts +20 -0
  221. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadrics.d.ts.map +1 -1
  222. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadrics.js +68 -35
  223. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_fill_small_holes.d.ts.map +1 -1
  224. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_fill_small_holes.js +2 -43
  225. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts +72 -21
  226. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts.map +1 -1
  227. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.js +452 -99
  228. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts.map +1 -1
  229. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.js +4 -15
  230. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_mesh_split_pinched_vertices.d.ts.map +1 -1
  231. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_mesh_split_pinched_vertices.js +13 -1
  232. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_fuse_duplicate_edges.d.ts.map +1 -1
  233. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_fuse_duplicate_edges.js +3 -1
  234. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.d.ts.map +1 -1
  235. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.js +22 -3
  236. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_collapse_fold_limit.d.ts +25 -0
  237. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_collapse_fold_limit.d.ts.map +1 -0
  238. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_collapse_fold_limit.js +228 -0
  239. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_collapse_would_fold.d.ts +13 -0
  240. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_collapse_would_fold.d.ts.map +1 -1
  241. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_collapse_would_fold.js +10 -128
  242. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_count_faces.d.ts +17 -2
  243. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_count_faces.d.ts.map +1 -1
  244. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_count_faces.js +28 -4
  245. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.d.ts.map +1 -1
  246. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.js +8 -1
  247. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_edge_adjacent_faces_weighted.d.ts.map +1 -1
  248. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_edge_adjacent_faces_weighted.js +10 -2
  249. package/src/core/geom/3d/topology/struct/binary/query/bt_face_island_flood_fill.d.ts.map +1 -1
  250. package/src/core/geom/3d/topology/struct/binary/query/bt_face_island_flood_fill.js +2 -0
  251. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_build_boundary_distance_field.d.ts.map +1 -1
  252. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_build_boundary_distance_field.js +25 -5
  253. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_build_face_bvh.d.ts.map +1 -1
  254. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_build_face_bvh.js +11 -1
  255. package/src/core/geom/3d/triangle/tri3_compute_normal.d.ts +5 -1
  256. package/src/core/geom/3d/triangle/tri3_compute_normal.d.ts.map +1 -1
  257. package/src/core/geom/3d/triangle/tri3_compute_normal.js +8 -1
  258. package/src/core/geom/3d/triangle/tri3_ray_intersection.d.ts.map +1 -1
  259. package/src/core/geom/3d/triangle/tri3_ray_intersection.js +15 -3
  260. package/src/core/geom/3d/triangle/tri3_ray_intersection_barycentric.d.ts +2 -1
  261. package/src/core/geom/3d/triangle/tri3_ray_intersection_barycentric.d.ts.map +1 -1
  262. package/src/core/geom/3d/triangle/tri3_ray_intersection_barycentric.js +2 -1
  263. package/src/core/geom/3d/triangle/tri3_ray_intersection_barycentric_edge.d.ts +1 -1
  264. package/src/core/geom/3d/triangle/tri3_ray_intersection_barycentric_edge.d.ts.map +1 -1
  265. package/src/core/geom/3d/triangle/tri3_ray_intersection_barycentric_edge.js +8 -1
  266. package/src/core/geom/vec/vector_normalize.d.ts.map +1 -1
  267. package/src/core/geom/vec/vector_normalize.js +5 -1
  268. package/src/core/geom/vec3/v3_slerp.d.ts.map +1 -1
  269. package/src/core/geom/vec3/v3_slerp.js +69 -4
  270. package/src/core/geom/vec4/v4_max_axis.d.ts +28 -0
  271. package/src/core/geom/vec4/v4_max_axis.d.ts.map +1 -0
  272. package/src/core/geom/vec4/v4_max_axis.js +41 -0
  273. package/src/core/graph/coloring/colorizeGraph.js +10 -7
  274. package/src/core/graph/layout/graph_peel_topological_layer.d.ts.map +1 -1
  275. package/src/core/graph/layout/graph_peel_topological_layer.js +16 -2
  276. package/src/core/graph/mn_graph_collapse_weighted_edge.js +6 -6
  277. package/src/core/json/JsonUtils.d.ts.map +1 -1
  278. package/src/core/json/JsonUtils.js +6 -2
  279. package/src/core/json/abstractJSONSerializer.d.ts.map +1 -1
  280. package/src/core/json/abstractJSONSerializer.js +5 -1
  281. package/src/core/lang/reactive/ReactiveOperatorType.d.ts +20 -0
  282. package/src/core/lang/reactive/ReactiveOperatorType.d.ts.map +1 -1
  283. package/src/core/lang/reactive/ReactiveOperatorType.js +34 -12
  284. package/src/core/localization/LanguageMetadata.d.ts +2 -1
  285. package/src/core/localization/LanguageMetadata.d.ts.map +1 -1
  286. package/src/core/localization/LanguageMetadata.js +6 -0
  287. package/src/core/localization/Localization.d.ts.map +1 -1
  288. package/src/core/localization/Localization.js +23 -10
  289. package/src/core/localization/LocalizationEngine.d.ts.map +1 -1
  290. package/src/core/localization/LocalizationEngine.js +4 -0
  291. package/src/core/math/fract.d.ts.map +1 -1
  292. package/src/core/math/fract.js +4 -3
  293. package/src/core/math/hash/squirrel3.d.ts +10 -2
  294. package/src/core/math/hash/squirrel3.d.ts.map +1 -1
  295. package/src/core/math/hash/squirrel3.js +16 -8
  296. package/src/core/math/linalg/m2/m2_polar_decomp_noS.d.ts +7 -0
  297. package/src/core/math/linalg/m2/m2_polar_decomp_noS.d.ts.map +1 -1
  298. package/src/core/math/linalg/m2/m2_polar_decomp_noS.js +20 -1
  299. package/src/core/math/lookup/ParameterLookupTable.d.ts.map +1 -1
  300. package/src/core/math/lookup/ParameterLookupTable.js +10 -5
  301. package/src/core/math/noise/sdnoise.d.ts.map +1 -1
  302. package/src/core/math/noise/sdnoise.js +16 -10
  303. package/src/core/math/physics/pdf/pdf_normal.d.ts +11 -3
  304. package/src/core/math/physics/pdf/pdf_normal.d.ts.map +1 -1
  305. package/src/core/math/physics/pdf/pdf_normal.js +25 -11
  306. package/src/core/math/solveQuadratic.d.ts.map +1 -1
  307. package/src/core/math/solveQuadratic.js +22 -3
  308. package/src/core/math/statistics/computeStatisticalPartialMedian.d.ts +9 -2
  309. package/src/core/math/statistics/computeStatisticalPartialMedian.d.ts.map +1 -1
  310. package/src/core/math/statistics/computeStatisticalPartialMedian.js +12 -6
  311. package/src/core/math/statistics/computeStatisticalPercentile.d.ts.map +1 -1
  312. package/src/core/math/statistics/computeStatisticalPercentile.js +9 -2
  313. package/src/core/math/statistics/gaussian_amplitude.d.ts +10 -1
  314. package/src/core/math/statistics/gaussian_amplitude.d.ts.map +1 -1
  315. package/src/core/math/statistics/gaussian_amplitude.js +20 -15
  316. package/src/core/model/BooleanVector3.d.ts.map +1 -1
  317. package/src/core/model/BooleanVector3.js +18 -2
  318. package/src/core/model/BoundedValue.d.ts +9 -0
  319. package/src/core/model/BoundedValue.d.ts.map +1 -1
  320. package/src/core/model/BoundedValue.js +30 -3
  321. package/src/core/model/ObservedBoolean.d.ts.map +1 -1
  322. package/src/core/model/ObservedBoolean.js +22 -2
  323. package/src/core/model/ObservedEnum.d.ts.map +1 -1
  324. package/src/core/model/ObservedEnum.js +6 -2
  325. package/src/core/model/node-graph/NodeGraph.d.ts +6 -1
  326. package/src/core/model/node-graph/NodeGraph.d.ts.map +1 -1
  327. package/src/core/model/node-graph/NodeGraph.js +22 -4
  328. package/src/core/model/node-graph/json/deserializeNodeGraphFromJSON.d.ts.map +1 -1
  329. package/src/core/model/node-graph/json/deserializeNodeGraphFromJSON.js +3 -1
  330. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts.map +1 -1
  331. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.js +5 -0
  332. package/src/core/model/node-graph/type/DataType.d.ts.map +1 -1
  333. package/src/core/model/node-graph/type/DataType.js +8 -0
  334. package/src/core/model/node-graph/type/ParametricDataType.d.ts.map +1 -1
  335. package/src/core/model/node-graph/type/ParametricDataType.js +19 -0
  336. package/src/core/model/node-graph/visual/NodeGraphVisualData.d.ts.map +1 -1
  337. package/src/core/model/node-graph/visual/NodeGraphVisualData.js +5 -0
  338. package/src/core/model/object/ImmutableObjectPool.d.ts.map +1 -1
  339. package/src/core/model/object/ImmutableObjectPool.js +17 -7
  340. package/src/core/model/reactive/js/compileReactiveToJS.d.ts +22 -0
  341. package/src/core/model/reactive/js/compileReactiveToJS.d.ts.map +1 -1
  342. package/src/core/model/reactive/js/compileReactiveToJS.js +113 -219
  343. package/src/core/model/reactive/model/ReactiveBinaryExpression.d.ts.map +1 -1
  344. package/src/core/model/reactive/model/ReactiveBinaryExpression.js +8 -2
  345. package/src/core/model/reactive/model/comparative/ReactiveEquals.d.ts.map +1 -1
  346. package/src/core/model/reactive/model/comparative/ReactiveEquals.js +3 -1
  347. package/src/core/model/reactive/model/comparative/ReactiveNotEquals.d.ts.map +1 -1
  348. package/src/core/model/reactive/model/comparative/ReactiveNotEquals.js +2 -1
  349. package/src/core/model/reactive/model/terminal/ReactiveLiteralString.d.ts.map +1 -1
  350. package/src/core/model/reactive/model/terminal/ReactiveLiteralString.js +4 -2
  351. package/src/core/model/stat/Stat.d.ts.map +1 -1
  352. package/src/core/model/stat/Stat.js +4 -0
  353. package/src/core/parser/seedVariablesIntoTemplateString.d.ts.map +1 -1
  354. package/src/core/parser/seedVariablesIntoTemplateString.js +5 -0
  355. package/src/core/parser/simple/readArrayLiteral.d.ts.map +1 -1
  356. package/src/core/parser/simple/readArrayLiteral.js +7 -0
  357. package/src/core/parser/simple/readHexToken.d.ts +3 -0
  358. package/src/core/parser/simple/readHexToken.d.ts.map +1 -1
  359. package/src/core/parser/simple/readHexToken.js +39 -106
  360. package/src/core/parser/simple/readNumberToken.d.ts.map +1 -1
  361. package/src/core/parser/simple/readNumberToken.js +13 -4
  362. package/src/core/parser/simple/readUnsignedIntegerToken.d.ts +2 -0
  363. package/src/core/parser/simple/readUnsignedIntegerToken.d.ts.map +1 -1
  364. package/src/core/parser/simple/readUnsignedIntegerToken.js +31 -71
  365. package/src/core/parser/simple/read_digits.d.ts +31 -0
  366. package/src/core/parser/simple/read_digits.d.ts.map +1 -0
  367. package/src/core/parser/simple/read_digits.js +74 -0
  368. package/src/core/primitives/numbers/number_format_by_thousands.d.ts.map +1 -1
  369. package/src/core/primitives/numbers/number_format_by_thousands.js +16 -1
  370. package/src/core/primitives/numbers/number_pretty_print.d.ts.map +1 -1
  371. package/src/core/primitives/numbers/number_pretty_print.js +6 -1
  372. package/src/core/process/executor/ConcurrentExecutor.d.ts +1 -5
  373. package/src/core/process/executor/ConcurrentExecutor.d.ts.map +1 -1
  374. package/src/core/process/executor/ConcurrentExecutor.js +131 -1
  375. package/src/core/process/task/Task.d.ts +8 -0
  376. package/src/core/process/task/Task.d.ts.map +1 -1
  377. package/src/core/process/task/Task.js +12 -1
  378. package/src/core/process/task/TaskGroup.d.ts +6 -0
  379. package/src/core/process/task/TaskGroup.d.ts.map +1 -1
  380. package/src/core/process/task/TaskGroup.js +7 -1
  381. package/src/core/process/task/task_find_dependency_cycle.d.ts +17 -0
  382. package/src/core/process/task/task_find_dependency_cycle.d.ts.map +1 -0
  383. package/src/core/process/task/task_find_dependency_cycle.js +81 -0
  384. package/src/core/process/undo/ActionProcessor.d.ts +12 -0
  385. package/src/core/process/undo/ActionProcessor.d.ts.map +1 -1
  386. package/src/core/process/undo/ActionProcessor.js +41 -15
  387. package/src/core/process/worker/OnDemandWorkerManager.d.ts.map +1 -1
  388. package/src/core/process/worker/OnDemandWorkerManager.js +6 -1
  389. package/src/core/process/worker/WorkerBuilder.d.ts.map +1 -1
  390. package/src/core/process/worker/WorkerBuilder.js +27 -5
  391. package/src/core/wfc/WFCCellChoice.d.ts +17 -0
  392. package/src/core/wfc/WFCCellChoice.d.ts.map +1 -0
  393. package/src/core/wfc/WFCCellChoice.js +36 -0
  394. package/src/core/wfc/WFCLattice.d.ts +105 -0
  395. package/src/core/wfc/WFCLattice.d.ts.map +1 -0
  396. package/src/core/wfc/WFCLattice.js +235 -0
  397. package/src/core/wfc/WFCRuleTable.d.ts +172 -0
  398. package/src/core/wfc/WFCRuleTable.d.ts.map +1 -0
  399. package/src/core/wfc/WFCRuleTable.js +334 -0
  400. package/src/core/wfc/WFCState.d.ts +273 -0
  401. package/src/core/wfc/WFCState.d.ts.map +1 -0
  402. package/src/core/wfc/WFCState.js +552 -0
  403. package/src/core/wfc/WFCStatus.d.ts +11 -0
  404. package/src/core/wfc/WFCStatus.d.ts.map +1 -0
  405. package/src/core/wfc/WFCStatus.js +28 -0
  406. package/src/core/wfc/WFCTileWeights.d.ts +48 -0
  407. package/src/core/wfc/WFCTileWeights.d.ts.map +1 -0
  408. package/src/core/wfc/WFCTileWeights.js +86 -0
  409. package/src/core/wfc/WFC_UNRESOLVED.d.ts +12 -0
  410. package/src/core/wfc/WFC_UNRESOLVED.d.ts.map +1 -0
  411. package/src/core/wfc/WFC_UNRESOLVED.js +11 -0
  412. package/src/core/wfc/wfc_estimate_bytes.d.ts +24 -0
  413. package/src/core/wfc/wfc_estimate_bytes.d.ts.map +1 -0
  414. package/src/core/wfc/wfc_estimate_bytes.js +47 -0
  415. package/src/core/wfc/wfc_rule_table_tile_components.d.ts +27 -0
  416. package/src/core/wfc/wfc_rule_table_tile_components.d.ts.map +1 -0
  417. package/src/core/wfc/wfc_rule_table_tile_components.js +80 -0
  418. package/src/core/wfc/wfc_solve.d.ts +21 -0
  419. package/src/core/wfc/wfc_solve.d.ts.map +1 -0
  420. package/src/core/wfc/wfc_solve.js +154 -0
  421. package/src/core/wfc/wfc_state_apply_boundary.d.ts +18 -0
  422. package/src/core/wfc/wfc_state_apply_boundary.d.ts.map +1 -0
  423. package/src/core/wfc/wfc_state_apply_boundary.js +61 -0
  424. package/src/core/wfc/wfc_state_assign.d.ts +11 -0
  425. package/src/core/wfc/wfc_state_assign.d.ts.map +1 -0
  426. package/src/core/wfc/wfc_state_assign.js +36 -0
  427. package/src/core/wfc/wfc_state_ban_bits.d.ts +17 -0
  428. package/src/core/wfc/wfc_state_ban_bits.d.ts.map +1 -0
  429. package/src/core/wfc/wfc_state_ban_bits.js +81 -0
  430. package/src/core/wfc/wfc_state_collapse.d.ts +12 -0
  431. package/src/core/wfc/wfc_state_collapse.d.ts.map +1 -0
  432. package/src/core/wfc/wfc_state_collapse.js +73 -0
  433. package/src/core/wfc/wfc_state_flush_dirty.d.ts +12 -0
  434. package/src/core/wfc/wfc_state_flush_dirty.d.ts.map +1 -0
  435. package/src/core/wfc/wfc_state_flush_dirty.js +39 -0
  436. package/src/core/wfc/wfc_state_propagate.d.ts +14 -0
  437. package/src/core/wfc/wfc_state_propagate.d.ts.map +1 -0
  438. package/src/core/wfc/wfc_state_propagate.js +155 -0
  439. package/src/core/wfc/wfc_state_read.d.ts +11 -0
  440. package/src/core/wfc/wfc_state_read.d.ts.map +1 -0
  441. package/src/core/wfc/wfc_state_read.js +38 -0
  442. package/src/core/wfc/wfc_state_restrict.d.ts +18 -0
  443. package/src/core/wfc/wfc_state_restrict.d.ts.map +1 -0
  444. package/src/core/wfc/wfc_state_restrict.js +39 -0
  445. package/src/core/wfc/wfc_state_set_eligible.d.ts +24 -0
  446. package/src/core/wfc/wfc_state_set_eligible.d.ts.map +1 -0
  447. package/src/core/wfc/wfc_state_set_eligible.js +49 -0
  448. package/src/core/wfc/wfc_state_undo_to.d.ts +13 -0
  449. package/src/core/wfc/wfc_state_undo_to.d.ts.map +1 -0
  450. package/src/core/wfc/wfc_state_undo_to.js +84 -0
  451. package/src/core/wfc/wfc_words_per_cell.d.ts +11 -0
  452. package/src/core/wfc/wfc_words_per_cell.d.ts.map +1 -0
  453. package/src/core/wfc/wfc_words_per_cell.js +16 -0
  454. package/src/engine/Clock.d.ts.map +1 -1
  455. package/src/engine/Clock.js +11 -0
  456. package/src/engine/Engine.d.ts.map +1 -1
  457. package/src/engine/Engine.js +107 -6
  458. package/src/engine/achievements/AchievementManager.d.ts.map +1 -1
  459. package/src/engine/achievements/AchievementManager.js +16 -1
  460. package/src/engine/animation/clip/ecd_bind_animation_curve.d.ts.map +1 -1
  461. package/src/engine/animation/clip/ecd_bind_animation_curve.js +17 -6
  462. package/src/engine/animation/clip/hemisphere_align_quaternion_values.d.ts +19 -10
  463. package/src/engine/animation/clip/hemisphere_align_quaternion_values.d.ts.map +1 -1
  464. package/src/engine/animation/clip/hemisphere_align_quaternion_values.js +19 -23
  465. package/src/engine/animation/keyed2/AnimationTrackPlayback.d.ts +1 -1
  466. package/src/engine/animation/keyed2/AnimationTrackPlayback.d.ts.map +1 -1
  467. package/src/engine/animation/keyed2/AnimationTrackPlayback.js +21 -4
  468. package/src/engine/asset/AssetManager.d.ts.map +1 -1
  469. package/src/engine/asset/AssetManager.js +11 -3
  470. package/src/engine/control/first-person/FirstPersonPlayerController.d.ts +1 -0
  471. package/src/engine/control/first-person/FirstPersonPlayerController.d.ts.map +1 -1
  472. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts +28 -0
  473. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts.map +1 -1
  474. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.js +14 -0
  475. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +23 -2
  476. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
  477. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +2122 -2078
  478. package/src/engine/ecs/Entity.d.ts.map +1 -1
  479. package/src/engine/ecs/Entity.js +43 -7
  480. package/src/engine/ecs/EntityBlueprint.d.ts.map +1 -1
  481. package/src/engine/ecs/EntityBlueprint.js +13 -4
  482. package/src/engine/ecs/EntityComponentDataset.d.ts +8 -0
  483. package/src/engine/ecs/EntityComponentDataset.d.ts.map +1 -1
  484. package/src/engine/ecs/EntityComponentDataset.js +132 -23
  485. package/src/engine/ecs/EntityManager.d.ts +16 -0
  486. package/src/engine/ecs/EntityManager.d.ts.map +1 -1
  487. package/src/engine/ecs/EntityManager.js +112 -37
  488. package/src/engine/ecs/EntityObserver.d.ts +7 -0
  489. package/src/engine/ecs/EntityObserver.d.ts.map +1 -1
  490. package/src/engine/ecs/EntityObserver.js +8 -1
  491. package/src/engine/ecs/System.d.ts +23 -0
  492. package/src/engine/ecs/System.d.ts.map +1 -1
  493. package/src/engine/ecs/System.js +25 -0
  494. package/src/engine/ecs/components/Tag.d.ts.map +1 -1
  495. package/src/engine/ecs/components/Tag.js +4 -1
  496. package/src/engine/ecs/computeComponentClassName.d.ts +13 -1
  497. package/src/engine/ecs/computeComponentClassName.d.ts.map +1 -1
  498. package/src/engine/ecs/computeComponentClassName.js +11 -1
  499. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.d.ts.map +1 -1
  500. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +11 -0
  501. package/src/engine/ecs/fow/FogOfWar.d.ts.map +1 -1
  502. package/src/engine/ecs/fow/FogOfWar.js +37 -11
  503. package/src/engine/ecs/fow/FogOfWarRevealerSystem.d.ts +8 -1
  504. package/src/engine/ecs/fow/FogOfWarRevealerSystem.d.ts.map +1 -1
  505. package/src/engine/ecs/fow/FogOfWarRevealerSystem.js +37 -2
  506. package/src/engine/ecs/guid/UUID.d.ts.map +1 -1
  507. package/src/engine/ecs/guid/UUID.js +45 -17
  508. package/src/engine/ecs/ik/OneBoneSurfaceAlignmentSolver.d.ts.map +1 -1
  509. package/src/engine/ecs/ik/OneBoneSurfaceAlignmentSolver.js +3 -1
  510. package/src/engine/ecs/parent/EntityNode.d.ts.map +1 -1
  511. package/src/engine/ecs/parent/EntityNode.js +8 -0
  512. package/src/engine/ecs/speaker/VoiceSystem.d.ts.map +1 -1
  513. package/src/engine/ecs/speaker/VoiceSystem.js +9 -0
  514. package/src/engine/ecs/storage/binary/BinaryClassSerializationAdapter.d.ts +15 -0
  515. package/src/engine/ecs/storage/binary/BinaryClassSerializationAdapter.d.ts.map +1 -1
  516. package/src/engine/ecs/storage/binary/BinaryClassSerializationAdapter.js +18 -0
  517. package/src/engine/ecs/system/AbstractContextSystem.d.ts.map +1 -1
  518. package/src/engine/ecs/system/AbstractContextSystem.js +14 -4
  519. package/src/engine/ecs/system/SystemEntityContext.d.ts +12 -0
  520. package/src/engine/ecs/system/SystemEntityContext.d.ts.map +1 -1
  521. package/src/engine/ecs/system/SystemEntityContext.js +23 -0
  522. package/src/engine/ecs/system_validate_class.d.ts.map +1 -1
  523. package/src/engine/ecs/system_validate_class.js +6 -2
  524. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.d.ts.map +1 -1
  525. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.js +395 -360
  526. package/src/engine/ecs/terrain/tiles/TerrainTile.d.ts.map +1 -1
  527. package/src/engine/ecs/terrain/tiles/TerrainTile.js +45 -3
  528. package/src/engine/ecs/terrain/tiles/TerrainTileManager.d.ts.map +1 -1
  529. package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +5 -8
  530. package/src/engine/graphics/ecs/camera/pp/PerfectPanner.d.ts.map +1 -1
  531. package/src/engine/graphics/ecs/camera/pp/PerfectPanner.js +62 -7
  532. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.d.ts +9 -0
  533. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.d.ts.map +1 -1
  534. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.js +13 -0
  535. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshAnimationControllerSystem.d.ts +11 -0
  536. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshAnimationControllerSystem.d.ts.map +1 -1
  537. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshAnimationControllerSystem.js +78 -13
  538. package/src/engine/graphics/ecs/path/tube/build/make_ring_vertices.d.ts.map +1 -1
  539. package/src/engine/graphics/ecs/path/tube/build/make_ring_vertices.js +22 -8
  540. package/src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals_indexed.d.ts.map +1 -1
  541. package/src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals_indexed.js +18 -2
  542. package/src/engine/graphics/geometry/geometry_construct_triangle_normal.d.ts +3 -1
  543. package/src/engine/graphics/geometry/geometry_construct_triangle_normal.d.ts.map +1 -1
  544. package/src/engine/graphics/geometry/geometry_construct_triangle_normal.js +3 -1
  545. package/src/engine/graphics/geometry/geometry_construct_triangle_normal_area_weighted.d.ts +32 -0
  546. package/src/engine/graphics/geometry/geometry_construct_triangle_normal_area_weighted.d.ts.map +1 -0
  547. package/src/engine/graphics/geometry/geometry_construct_triangle_normal_area_weighted.js +53 -0
  548. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts +22 -2
  549. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts.map +1 -1
  550. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +1201 -1160
  551. package/src/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseVelocity.d.ts +0 -1
  552. package/src/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseVelocity.d.ts.map +1 -1
  553. package/src/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseVelocity.js +10 -5
  554. package/src/engine/graphics/particles/particular/engine/simulator/update_parameters.d.ts.map +1 -1
  555. package/src/engine/graphics/particles/particular/engine/simulator/update_parameters.js +23 -0
  556. package/src/engine/graphics/particles/particular/group/itemSizeFromAttributeType.d.ts +1 -1
  557. package/src/engine/graphics/sh3/path_tracer/texture/apply_texture_clamping_to_coordinate.d.ts.map +1 -1
  558. package/src/engine/graphics/sh3/path_tracer/texture/apply_texture_clamping_to_coordinate.js +6 -1
  559. package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.d.ts.map +1 -1
  560. package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +20 -0
  561. package/src/engine/graphics/texture/atlas/TextureAtlas.d.ts +1 -0
  562. package/src/engine/graphics/texture/atlas/TextureAtlas.d.ts.map +1 -1
  563. package/src/engine/graphics/texture/atlas/TextureAtlas.js +24 -5
  564. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
  565. package/src/engine/graphics/texture/sampler/Sampler2D.js +14 -1
  566. package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_linear.d.ts.map +1 -1
  567. package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_linear.js +24 -10
  568. package/src/engine/graphics/texture/sampler/sampler2d_sub_copy_same_item_size.d.ts.map +1 -1
  569. package/src/engine/graphics/texture/sampler/sampler2d_sub_copy_same_item_size.js +16 -5
  570. package/src/engine/graphics/texture/sampler/sampler2d_to_uint8_RGBA.d.ts.map +1 -1
  571. package/src/engine/graphics/texture/sampler/sampler2d_to_uint8_RGBA.js +29 -8
  572. package/src/engine/graphics/texture/sampler/serialization/TextureBinaryBufferSerializer.d.ts.map +1 -1
  573. package/src/engine/graphics/texture/sampler/serialization/TextureBinaryBufferSerializer.js +8 -3
  574. package/src/engine/graphics3/DecalSystem.d.ts +5 -4
  575. package/src/engine/graphics3/DecalSystem.d.ts.map +1 -1
  576. package/src/engine/graphics3/DecalSystem.js +5 -4
  577. package/src/engine/graphics3/GraphicsEngine.d.ts +40 -7
  578. package/src/engine/graphics3/GraphicsEngine.d.ts.map +1 -1
  579. package/src/engine/graphics3/GraphicsEngine.js +92 -7
  580. package/src/engine/graphics3/MeshSystem.d.ts +7 -0
  581. package/src/engine/graphics3/MeshSystem.d.ts.map +1 -1
  582. package/src/engine/graphics3/MeshSystem.js +681 -661
  583. package/src/engine/graphics3/ParticleEmitterSystem.d.ts +1 -0
  584. package/src/engine/graphics3/ParticleEmitterSystem.d.ts.map +1 -1
  585. package/src/engine/graphics3/ParticleEmitterSystem.js +1 -0
  586. package/src/engine/graphics3/TerrainSystem.d.ts +10 -40
  587. package/src/engine/graphics3/TerrainSystem.d.ts.map +1 -1
  588. package/src/engine/graphics3/TerrainSystem.js +186 -185
  589. package/src/engine/graphics3/Trail3DSystem.d.ts +28 -19
  590. package/src/engine/graphics3/Trail3DSystem.d.ts.map +1 -1
  591. package/src/engine/graphics3/Trail3DSystem.js +57 -64
  592. package/src/engine/graphics3/debug/gizmo_write_geometry.d.ts.map +1 -1
  593. package/src/engine/graphics3/debug/gizmo_write_geometry.js +7 -59
  594. package/src/engine/graphics3/decal/GPUDecalRenderer.d.ts.map +1 -1
  595. package/src/engine/graphics3/decal/GPUDecalRenderer.js +23 -7
  596. package/src/engine/graphics3/decal/shader_cluster_assign_decals.d.ts.map +1 -1
  597. package/src/engine/graphics3/decal/shader_cluster_assign_decals.js +29 -6
  598. package/src/engine/graphics3/path/tube_stream_write_geometry.d.ts.map +1 -1
  599. package/src/engine/graphics3/path/tube_stream_write_geometry.js +7 -56
  600. package/src/engine/graphics3/register_instance_animation.d.ts +3 -3
  601. package/src/engine/graphics3/register_instance_animation.js +3 -3
  602. package/src/engine/graphics3/terrain/GPUTerrainSplatRenderer.d.ts.map +1 -1
  603. package/src/engine/graphics3/terrain/TERRAIN_MATERIAL_TEMPLATE.d.ts +77 -0
  604. package/src/engine/graphics3/terrain/TERRAIN_MATERIAL_TEMPLATE.d.ts.map +1 -0
  605. package/src/engine/graphics3/terrain/TERRAIN_MATERIAL_TEMPLATE.js +485 -0
  606. package/src/engine/graphics3/terrain/TerrainShadeMaterial.d.ts +103 -0
  607. package/src/engine/graphics3/terrain/TerrainShadeMaterial.d.ts.map +1 -0
  608. package/src/engine/graphics3/terrain/TerrainShadeMaterial.js +130 -0
  609. package/src/engine/graphics3/terrain/chunk_terrain_material_surface.d.ts +23 -0
  610. package/src/engine/graphics3/terrain/chunk_terrain_material_surface.d.ts.map +1 -0
  611. package/src/engine/graphics3/terrain/chunk_terrain_material_surface.js +68 -0
  612. package/src/engine/graphics3/trail/trail_tube_write_geometry.d.ts.map +1 -1
  613. package/src/engine/graphics3/trail/trail_tube_write_geometry.js +8 -59
  614. package/src/engine/grid/grid2transform/GridPosition2TransformSystem.d.ts.map +1 -1
  615. package/src/engine/grid/grid2transform/GridPosition2TransformSystem.js +24 -5
  616. package/src/engine/grid/transform2grid/Transform2GridPositionSystem.d.ts.map +1 -1
  617. package/src/engine/grid/transform2grid/Transform2GridPositionSystem.js +10 -0
  618. package/src/engine/input/devices/PointerDevice.d.ts.map +1 -1
  619. package/src/engine/input/devices/PointerDevice.js +58 -5
  620. package/src/engine/input/ecs/ism/InputMapProgram.d.ts.map +1 -1
  621. package/src/engine/input/ecs/ism/InputMapProgram.js +13 -0
  622. package/src/engine/input/ecs/systems/InputControllerSystem.d.ts +1 -0
  623. package/src/engine/input/ecs/systems/InputControllerSystem.d.ts.map +1 -1
  624. package/src/engine/input/ecs/systems/InputControllerSystem.js +52 -2
  625. package/src/engine/intelligence/behavior/composite/ParallelBehavior.d.ts.map +1 -1
  626. package/src/engine/intelligence/behavior/composite/ParallelBehavior.js +8 -0
  627. package/src/engine/intelligence/behavior/decorator/RepeatBehavior.d.ts.map +1 -1
  628. package/src/engine/intelligence/behavior/decorator/RepeatBehavior.js +7 -0
  629. package/src/engine/intelligence/behavior/decorator/RepeatUntilSuccessBehavior.d.ts.map +1 -1
  630. package/src/engine/intelligence/behavior/decorator/RepeatUntilSuccessBehavior.js +14 -0
  631. package/src/engine/intelligence/behavior/ecs/BehaviorSystem.d.ts.map +1 -1
  632. package/src/engine/intelligence/behavior/ecs/BehaviorSystem.js +13 -0
  633. package/src/engine/interpolation/Interpoland.d.ts +7 -1
  634. package/src/engine/interpolation/Interpoland.d.ts.map +1 -1
  635. package/src/engine/interpolation/Interpoland.js +8 -1
  636. package/src/engine/interpolation/InterpolationLog.d.ts +51 -4
  637. package/src/engine/interpolation/InterpolationLog.d.ts.map +1 -1
  638. package/src/engine/interpolation/InterpolationLog.js +132 -2
  639. package/src/engine/interpolation/InterpolationSystem.d.ts +113 -35
  640. package/src/engine/interpolation/InterpolationSystem.d.ts.map +1 -1
  641. package/src/engine/interpolation/InterpolationSystem.js +677 -50
  642. package/src/engine/interpolation/TransformPoseSerializationAdapter.d.ts +5 -3
  643. package/src/engine/interpolation/TransformPoseSerializationAdapter.d.ts.map +1 -1
  644. package/src/engine/interpolation/TransformPoseSerializationAdapter.js +14 -3
  645. package/src/engine/interpolation/pose_interpoland.d.ts.map +1 -1
  646. package/src/engine/interpolation/pose_interpoland.js +2 -0
  647. package/src/engine/network/NetworkSession.d.ts +176 -47
  648. package/src/engine/network/NetworkSession.d.ts.map +1 -1
  649. package/src/engine/network/NetworkSession.js +1462 -272
  650. package/src/engine/network/README.md +106 -3
  651. package/src/engine/network/SMOOTHNESS_DESIGN.md +392 -0
  652. package/src/engine/network/adapters/PoseCorrection.d.ts +50 -0
  653. package/src/engine/network/adapters/PoseCorrection.d.ts.map +1 -0
  654. package/src/engine/network/adapters/PoseCorrection.js +211 -0
  655. package/src/engine/network/adapters/TransformReplicationAdapter.d.ts +1 -0
  656. package/src/engine/network/adapters/TransformReplicationAdapter.d.ts.map +1 -1
  657. package/src/engine/network/adapters/TransformReplicationAdapter.js +17 -0
  658. package/src/engine/network/adapters/VelocityCorrection.d.ts +31 -0
  659. package/src/engine/network/adapters/VelocityCorrection.d.ts.map +1 -0
  660. package/src/engine/network/adapters/VelocityCorrection.js +71 -0
  661. package/src/engine/network/adapters/replicate_transform64.d.ts +13 -0
  662. package/src/engine/network/adapters/replicate_transform64.d.ts.map +1 -0
  663. package/src/engine/network/adapters/replicate_transform64.js +18 -0
  664. package/src/engine/network/adapters/rigid_body_of.d.ts +22 -0
  665. package/src/engine/network/adapters/rigid_body_of.d.ts.map +1 -0
  666. package/src/engine/network/adapters/rigid_body_of.js +33 -0
  667. package/src/engine/network/correction/Correction.d.ts +120 -0
  668. package/src/engine/network/correction/Correction.d.ts.map +1 -0
  669. package/src/engine/network/correction/Correction.js +143 -0
  670. package/src/engine/network/ecs/NetworkSystem.d.ts +36 -7
  671. package/src/engine/network/ecs/NetworkSystem.d.ts.map +1 -1
  672. package/src/engine/network/ecs/NetworkSystem.js +49 -7
  673. package/src/engine/network/orchestrator/NetworkPeer.d.ts +50 -1
  674. package/src/engine/network/orchestrator/NetworkPeer.d.ts.map +1 -1
  675. package/src/engine/network/orchestrator/NetworkPeer.js +158 -20
  676. package/src/engine/network/orchestrator/ServerAuthoritativeClient.d.ts +38 -2
  677. package/src/engine/network/orchestrator/ServerAuthoritativeClient.d.ts.map +1 -1
  678. package/src/engine/network/orchestrator/ServerAuthoritativeClient.js +58 -10
  679. package/src/engine/network/orchestrator/ServerAuthoritativeServer.d.ts +68 -2
  680. package/src/engine/network/orchestrator/ServerAuthoritativeServer.d.ts.map +1 -1
  681. package/src/engine/network/orchestrator/ServerAuthoritativeServer.js +299 -18
  682. package/src/engine/network/replication/Replicator.d.ts +8 -1
  683. package/src/engine/network/replication/Replicator.d.ts.map +1 -1
  684. package/src/engine/network/replication/Replicator.js +50 -6
  685. package/src/engine/network/sim/ActionLog.d.ts +5 -2
  686. package/src/engine/network/sim/ActionLog.d.ts.map +1 -1
  687. package/src/engine/network/sim/ActionLog.js +5 -2
  688. package/src/engine/network/sim/RewindEngine.d.ts.map +1 -1
  689. package/src/engine/network/sim/RewindEngine.js +6 -0
  690. package/src/engine/network/sim/SimActionExecutor.d.ts +48 -3
  691. package/src/engine/network/sim/SimActionExecutor.d.ts.map +1 -1
  692. package/src/engine/network/sim/SimActionExecutor.js +152 -6
  693. package/src/engine/network/sim/SmoothingState.d.ts +54 -2
  694. package/src/engine/network/sim/SmoothingState.d.ts.map +1 -1
  695. package/src/engine/network/sim/SmoothingState.js +107 -3
  696. package/src/engine/network/state/MutationLedger.d.ts.map +1 -1
  697. package/src/engine/network/state/MutationLedger.js +18 -2
  698. package/src/engine/network/state/PredictionHistory.d.ts +67 -0
  699. package/src/engine/network/state/PredictionHistory.d.ts.map +1 -0
  700. package/src/engine/network/state/PredictionHistory.js +145 -0
  701. package/src/engine/network/time/RenderPlayout.d.ts +2 -1
  702. package/src/engine/network/time/RenderPlayout.d.ts.map +1 -1
  703. package/src/engine/network/time/RenderPlayout.js +174 -163
  704. package/src/engine/network/transport/DeferredTransport.d.ts +57 -0
  705. package/src/engine/network/transport/DeferredTransport.d.ts.map +1 -0
  706. package/src/engine/network/transport/DeferredTransport.js +143 -0
  707. package/src/engine/network/transport/LoopbackTransport.d.ts +8 -0
  708. package/src/engine/network/transport/LoopbackTransport.d.ts.map +1 -1
  709. package/src/engine/network/transport/LoopbackTransport.js +12 -1
  710. package/src/engine/network/transport/ReliableCommandPipeline.d.ts.map +1 -1
  711. package/src/engine/network/transport/ReliableCommandPipeline.js +20 -0
  712. package/src/engine/network/transport/adapters/NodeUDPTransport.d.ts.map +1 -1
  713. package/src/engine/network/transport/adapters/NodeUDPTransport.js +11 -2
  714. package/src/engine/network/transport/adapters/WebTransportTransport.d.ts.map +1 -1
  715. package/src/engine/network/transport/adapters/WebTransportTransport.js +8 -1
  716. package/src/engine/network/transport/fragments/FragmentAssembler.d.ts +2 -1
  717. package/src/engine/network/transport/fragments/FragmentAssembler.d.ts.map +1 -1
  718. package/src/engine/network/transport/fragments/FragmentAssembler.js +67 -3
  719. package/src/engine/network/transport/fragments/fragment_send.d.ts +8 -0
  720. package/src/engine/network/transport/fragments/fragment_send.d.ts.map +1 -1
  721. package/src/engine/network/transport/fragments/fragment_send.js +17 -7
  722. package/src/engine/network/transport/fragments/packet_size.d.ts +6 -0
  723. package/src/engine/network/transport/fragments/packet_size.d.ts.map +1 -1
  724. package/src/engine/network/transport/fragments/packet_size.js +6 -0
  725. package/src/engine/physics/ccd/linear_sweep.d.ts.map +1 -1
  726. package/src/engine/physics/ccd/linear_sweep.js +19 -1
  727. package/src/engine/physics/cloth/ecs/ClothWorld.d.ts +7 -3
  728. package/src/engine/physics/cloth/ecs/ClothWorld.d.ts.map +1 -1
  729. package/src/engine/physics/cloth/ecs/ClothWorld.js +51 -4
  730. package/src/engine/physics/cloth/solver/cloth_self_find.js +17 -0
  731. package/src/engine/physics/contact/ManifoldStore.d.ts +20 -1
  732. package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -1
  733. package/src/engine/physics/contact/ManifoldStore.js +24 -2
  734. package/src/engine/physics/ecs/PhysicsSystem.d.ts +51 -88
  735. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  736. package/src/engine/physics/ecs/PhysicsSystem.js +82 -217
  737. package/src/engine/physics/ecs/is_sensor.d.ts +24 -0
  738. package/src/engine/physics/ecs/is_sensor.d.ts.map +1 -1
  739. package/src/engine/physics/ecs/is_sensor.js +39 -0
  740. package/src/engine/physics/fluid/ecs/FluidComponent.d.ts +18 -4
  741. package/src/engine/physics/fluid/ecs/FluidComponent.d.ts.map +1 -1
  742. package/src/engine/physics/fluid/ecs/FluidComponent.js +29 -8
  743. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  744. package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts +8 -0
  745. package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts.map +1 -1
  746. package/src/engine/physics/fluid/effector/AbstractFluidEffector.js +8 -0
  747. package/src/engine/physics/fluid/solver/NOTES.md +46 -0
  748. package/src/engine/physics/fluid/solver/v3_grid_advect_maccormack_scalar.js +1 -1
  749. package/src/engine/physics/fluid/solver/v3_grid_advect_maccormack_velocity.js +1 -1
  750. package/src/engine/physics/fluid/solver/v3_grid_advect_sl_velocity.js +1 -1
  751. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.js +1 -1
  752. package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.js +1 -1
  753. package/src/engine/physics/fluid/solver/v3_grid_apply_vorticity_confinement.d.ts.map +1 -1
  754. package/src/engine/physics/fluid/solver/v3_grid_apply_vorticity_confinement.js +8 -0
  755. package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.d.ts.map +1 -1
  756. package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.js +8 -0
  757. package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts.map +1 -1
  758. package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.js +8 -0
  759. package/src/engine/physics/fluid/solver/v3_mac_advect_scalar.d.ts +5 -0
  760. package/src/engine/physics/fluid/solver/v3_mac_advect_scalar.d.ts.map +1 -1
  761. package/src/engine/physics/fluid/solver/v3_mac_advect_scalar.js +5 -0
  762. package/src/engine/physics/integration/integrate_velocity.d.ts +15 -0
  763. package/src/engine/physics/integration/integrate_velocity.d.ts.map +1 -1
  764. package/src/engine/physics/integration/integrate_velocity.js +15 -0
  765. package/src/engine/physics/island/IslandBuilder.d.ts.map +1 -1
  766. package/src/engine/physics/island/IslandBuilder.js +6 -7
  767. package/src/engine/physics/mls-mpm/MLS_MPM.d.ts.map +1 -1
  768. package/src/engine/physics/mls-mpm/MLS_MPM.js +36 -6
  769. package/src/engine/physics/mls-mpm/mls_mpm_demo_scene.d.ts +29 -0
  770. package/src/engine/physics/mls-mpm/mls_mpm_demo_scene.d.ts.map +1 -0
  771. package/src/engine/physics/mls-mpm/mls_mpm_demo_scene.js +44 -0
  772. package/src/engine/physics/mls-mpm/testMLS_MPM.js +3 -3
  773. package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -1
  774. package/src/engine/physics/narrowphase/narrowphase_step.js +74 -11
  775. package/src/engine/physics/queries/overlap_shape.d.ts.map +1 -1
  776. package/src/engine/physics/queries/overlap_shape.js +92 -45
  777. package/src/engine/physics/queries/raycast.d.ts.map +1 -1
  778. package/src/engine/physics/queries/raycast.js +55 -43
  779. package/src/engine/physics/queries/shape_cast.d.ts.map +1 -1
  780. package/src/engine/physics/queries/shape_cast.js +185 -174
  781. package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -1
  782. package/src/engine/physics/solver/solve_contacts.js +42 -19
  783. package/src/engine/plugin/EnginePluginManager.d.ts +10 -0
  784. package/src/engine/plugin/EnginePluginManager.d.ts.map +1 -1
  785. package/src/engine/plugin/EnginePluginManager.js +54 -1
  786. package/src/engine/plugin/PluginReferenceContext.d.ts.map +1 -1
  787. package/src/engine/plugin/PluginReferenceContext.js +7 -3
  788. package/src/engine/reference/v2/Reference.d.ts +9 -0
  789. package/src/engine/reference/v2/Reference.d.ts.map +1 -1
  790. package/src/engine/reference/v2/Reference.js +39 -2
  791. package/src/engine/simulation/Ticker.d.ts.map +1 -1
  792. package/src/engine/simulation/Ticker.js +20 -1
  793. package/src/engine/sound/ecs/SoundListenerSystem.d.ts +27 -0
  794. package/src/engine/sound/ecs/SoundListenerSystem.d.ts.map +1 -1
  795. package/src/engine/sound/ecs/SoundListenerSystem.js +82 -21
  796. package/src/engine/sound/ecs/audio/LiveEmitterSet.d.ts.map +1 -1
  797. package/src/engine/sound/ecs/audio/LiveEmitterSet.js +394 -356
  798. package/src/engine/sound/material/concrete/SoundMaterialComposition.d.ts.map +1 -1
  799. package/src/engine/sound/material/concrete/SoundMaterialComposition.js +54 -17
  800. package/src/engine/sound/material/detector/terrain/TerrainSoundMaterialSurfaceDetector.d.ts.map +1 -1
  801. package/src/engine/sound/material/detector/terrain/TerrainSoundMaterialSurfaceDetector.js +34 -3
  802. package/src/engine/sound/simulation/core/AcousticSolution.d.ts +5 -0
  803. package/src/engine/sound/simulation/core/AcousticSolution.d.ts.map +1 -1
  804. package/src/engine/sound/simulation/core/AcousticSolution.js +5 -0
  805. package/src/engine/sound/simulation/definition/AcousticMaterial.d.ts +8 -0
  806. package/src/engine/sound/simulation/definition/AcousticMaterial.d.ts.map +1 -1
  807. package/src/engine/sound/simulation/definition/AcousticMaterial.js +8 -0
  808. package/src/engine/sound/simulation/probe/probe_visibility_augment.d.ts +6 -4
  809. package/src/engine/sound/simulation/probe/probe_visibility_augment.d.ts.map +1 -1
  810. package/src/engine/sound/simulation/probe/probe_visibility_augment.js +19 -7
  811. package/src/engine/sound/simulation/render/FoaProbeReverbRenderer.d.ts +39 -0
  812. package/src/engine/sound/simulation/render/FoaProbeReverbRenderer.d.ts.map +1 -1
  813. package/src/engine/sound/simulation/render/FoaProbeReverbRenderer.js +130 -1
  814. package/src/engine/sound/simulation/render/ProbeReverbRenderer.d.ts +3 -2
  815. package/src/engine/sound/simulation/render/ProbeReverbRenderer.d.ts.map +1 -1
  816. package/src/engine/sound/simulation/render/ProbeReverbRenderer.js +15 -1
  817. package/src/engine/sound/sopra/SopraEngine.d.ts +10 -0
  818. package/src/engine/sound/sopra/SopraEngine.d.ts.map +1 -1
  819. package/src/engine/sound/sopra/SopraEngine.js +486 -440
  820. package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.d.ts +2 -1
  821. package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.d.ts.map +1 -1
  822. package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.js +1 -1
  823. package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.d.ts +1 -0
  824. package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.d.ts.map +1 -1
  825. package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClip.d.ts +1 -0
  826. package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClip.d.ts.map +1 -1
  827. package/src/engine/sound/sopra/definition/clip/SampleAudioClip.d.ts +2 -1
  828. package/src/engine/sound/sopra/definition/clip/SampleAudioClip.d.ts.map +1 -1
  829. package/src/engine/sound/sopra/definition/clip/SampleAudioClip.js +12 -3
  830. package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClip.d.ts +1 -0
  831. package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClip.d.ts.map +1 -1
  832. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts +1 -0
  833. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts.map +1 -1
  834. package/src/engine/sound/sopra/runtime/BusGraph.d.ts +29 -0
  835. package/src/engine/sound/sopra/runtime/BusGraph.d.ts.map +1 -1
  836. package/src/engine/sound/sopra/runtime/BusGraph.js +69 -2
  837. package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -1
  838. package/src/engine/sound/sopra/runtime/EventInstance.js +134 -10
  839. package/src/engine/ui/GUIEngine.d.ts +14 -0
  840. package/src/engine/ui/GUIEngine.d.ts.map +1 -1
  841. package/src/engine/ui/GUIEngine.js +52 -4
  842. package/src/format/image/avif/api/apply_transformations.d.ts +2 -1
  843. package/src/format/image/avif/api/apply_transformations.d.ts.map +1 -1
  844. package/src/format/image/avif/api/apply_transformations.js +129 -120
  845. package/src/format/image/avif/api/convert_to_rgba.d.ts.map +1 -1
  846. package/src/format/image/avif/api/convert_to_rgba.js +35 -2
  847. package/src/format/image/avif/api/decode_image_item.d.ts +2 -1
  848. package/src/format/image/avif/api/decode_image_item.d.ts.map +1 -1
  849. package/src/format/image/avif/api/decode_image_item.js +322 -234
  850. package/src/format/image/avif/av1/decode/decode_av1_still.js +329 -309
  851. package/src/format/image/avif/av1/decode/decode_coefficients.d.ts.map +1 -1
  852. package/src/format/image/avif/av1/decode/decode_coefficients.js +248 -259
  853. package/src/format/image/avif/av1/decode/read_golomb.d.ts +21 -0
  854. package/src/format/image/avif/av1/decode/read_golomb.d.ts.map +1 -0
  855. package/src/format/image/avif/av1/decode/read_golomb.js +49 -0
  856. package/src/format/image/avif/av1/encode/encode_tile.js +2349 -2331
  857. package/src/format/image/avif/av1/entropy/symbol_cost.d.ts.map +1 -1
  858. package/src/format/image/avif/av1/entropy/symbol_cost.js +86 -76
  859. package/src/format/image/avif/av1/filter/loop_restoration.js +461 -451
  860. package/src/format/image/avif/av1/util/round2.d.ts +19 -2
  861. package/src/format/image/avif/av1/util/round2.d.ts.map +1 -1
  862. package/src/format/image/avif/av1/util/round2.js +51 -27
  863. package/src/format/image/avif/heif/AvifFile.d.ts +11 -0
  864. package/src/format/image/avif/heif/AvifFile.d.ts.map +1 -1
  865. package/src/format/image/avif/heif/AvifFile.js +154 -142
  866. package/src/format/image/avif/heif/find_item_properties.d.ts +23 -0
  867. package/src/format/image/avif/heif/find_item_properties.d.ts.map +1 -0
  868. package/src/format/image/avif/heif/find_item_properties.js +36 -0
  869. package/src/format/image/avif/heif/parse_avif_file.js +30 -3
  870. package/src/format/image/avif/heif/read_item_data.d.ts.map +1 -1
  871. package/src/format/image/avif/heif/read_item_data.js +131 -97
  872. package/src/format/image/jpeg/decodeScan.d.ts.map +1 -1
  873. package/src/format/image/jpeg/decodeScan.js +17 -0
  874. package/src/format/scene/gltf/gltf_parse_container.d.ts.map +1 -1
  875. package/src/format/scene/gltf/gltf_parse_container.js +61 -41
  876. package/src/format/scene/gltf/gltf_read_accessor.d.ts +21 -0
  877. package/src/format/scene/gltf/gltf_read_accessor.d.ts.map +1 -1
  878. package/src/format/scene/gltf/gltf_read_accessor.js +37 -0
  879. package/src/format/scene/usd/usd_compose_transform.d.ts.map +1 -1
  880. package/src/format/scene/usd/usd_compose_transform.js +56 -6
  881. package/src/format/texture/basis/transcode/fit_endpoints.d.ts +6 -0
  882. package/src/format/texture/basis/transcode/fit_endpoints.d.ts.map +1 -1
  883. package/src/format/texture/basis/transcode/fit_endpoints.js +33 -39
  884. package/src/generation/filtering/numeric/CellFilterCache.d.ts +17 -0
  885. package/src/generation/filtering/numeric/CellFilterCache.d.ts.map +1 -1
  886. package/src/generation/filtering/numeric/CellFilterCache.js +36 -3
  887. package/src/generation/grid/actions/ContinuousGridCellActionSetTerrainObstacle.d.ts +9 -0
  888. package/src/generation/grid/actions/ContinuousGridCellActionSetTerrainObstacle.d.ts.map +1 -1
  889. package/src/generation/grid/actions/ContinuousGridCellActionSetTerrainObstacle.js +37 -6
  890. package/src/generation/grid/actions/ContinuousGridCellActionWriteObstacle.d.ts.map +1 -1
  891. package/src/generation/grid/actions/ContinuousGridCellActionWriteObstacle.js +8 -21
  892. package/src/generation/grid/actions/grid_obstacle_write_grid_point.d.ts +28 -0
  893. package/src/generation/grid/actions/grid_obstacle_write_grid_point.d.ts.map +1 -0
  894. package/src/generation/grid/actions/grid_obstacle_write_grid_point.js +41 -0
  895. package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.d.ts +15 -1
  896. package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.d.ts.map +1 -1
  897. package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.js +17 -3
  898. package/src/generation/markers/actions/MarkerNodeProcessingRuleSet.d.ts.map +1 -1
  899. package/src/generation/markers/actions/MarkerNodeProcessingRuleSet.js +16 -1
  900. package/src/generation/placement/action/GridCellActionWriteFilterToLayer.d.ts.map +1 -1
  901. package/src/generation/placement/action/GridCellActionWriteFilterToLayer.js +8 -1
  902. package/src/generation/theme/TerrainTheme.d.ts.map +1 -1
  903. package/src/generation/theme/TerrainTheme.js +20 -1
  904. package/src/shade/RENDERER_CONTRACT.md +48 -6
  905. package/src/shade/descriptor/texture/format/gpu_texture_formats_copy_compatible.d.ts +23 -0
  906. package/src/shade/descriptor/texture/format/gpu_texture_formats_copy_compatible.d.ts.map +1 -0
  907. package/src/shade/descriptor/texture/format/gpu_texture_formats_copy_compatible.js +28 -0
  908. package/src/shade/descriptor/texture/format/gpu_texture_formats_view_compatible.d.ts +25 -0
  909. package/src/shade/descriptor/texture/format/gpu_texture_formats_view_compatible.d.ts.map +1 -0
  910. package/src/shade/descriptor/texture/format/gpu_texture_formats_view_compatible.js +42 -0
  911. package/src/shade/device/ShadeGPUCommandContext.d.ts.map +1 -1
  912. package/src/shade/device/ShadeGPUCommandContext.js +874 -857
  913. package/src/shade/device/mock/SoftwareGPUBindGroup.d.ts +38 -1
  914. package/src/shade/device/mock/SoftwareGPUBindGroup.d.ts.map +1 -1
  915. package/src/shade/device/mock/SoftwareGPUBindGroup.js +73 -1
  916. package/src/shade/device/mock/SoftwareGPUBuffer.d.ts.map +1 -1
  917. package/src/shade/device/mock/SoftwareGPUBuffer.js +5 -0
  918. package/src/shade/device/mock/SoftwareGPUCommandBuffer.d.ts +34 -0
  919. package/src/shade/device/mock/SoftwareGPUCommandBuffer.d.ts.map +1 -1
  920. package/src/shade/device/mock/SoftwareGPUCommandBuffer.js +71 -1
  921. package/src/shade/device/mock/SoftwareGPUCommandEncoder.d.ts +15 -0
  922. package/src/shade/device/mock/SoftwareGPUCommandEncoder.d.ts.map +1 -1
  923. package/src/shade/device/mock/SoftwareGPUCommandEncoder.js +109 -1
  924. package/src/shade/device/mock/SoftwareGPUComputePassEncoder.d.ts.map +1 -1
  925. package/src/shade/device/mock/SoftwareGPUComputePassEncoder.js +51 -0
  926. package/src/shade/device/mock/SoftwareGPUDevice.d.ts +5 -1
  927. package/src/shade/device/mock/SoftwareGPUDevice.d.ts.map +1 -1
  928. package/src/shade/device/mock/SoftwareGPUDevice.js +58 -1
  929. package/src/shade/device/mock/SoftwareGPUPipeline.d.ts +1 -0
  930. package/src/shade/device/mock/SoftwareGPUPipeline.d.ts.map +1 -1
  931. package/src/shade/device/mock/SoftwareGPUPipeline.js +17 -11
  932. package/src/shade/device/mock/SoftwareGPUQueue.d.ts.map +1 -1
  933. package/src/shade/device/mock/SoftwareGPUQueue.js +41 -0
  934. package/src/shade/device/mock/SoftwareGPURenderPassEncoder.d.ts.map +1 -1
  935. package/src/shade/device/mock/SoftwareGPURenderPassEncoder.js +24 -0
  936. package/src/shade/device/mock/SoftwareGPUTexture.d.ts +11 -1
  937. package/src/shade/device/mock/SoftwareGPUTexture.d.ts.map +1 -1
  938. package/src/shade/device/mock/SoftwareGPUTexture.js +45 -8
  939. package/src/shade/device/mock/SoftwareGPUTextureView.d.ts +20 -1
  940. package/src/shade/device/mock/SoftwareGPUTextureView.d.ts.map +1 -1
  941. package/src/shade/device/mock/SoftwareGPUTextureView.js +28 -1
  942. package/src/shade/device/mock/recorded_binding_kind_mismatches.d.ts +20 -0
  943. package/src/shade/device/mock/recorded_binding_kind_mismatches.d.ts.map +1 -0
  944. package/src/shade/device/mock/recorded_binding_kind_mismatches.js +84 -0
  945. package/src/shade/device/mock/texture_copy.d.ts.map +1 -1
  946. package/src/shade/device/mock/texture_copy.js +41 -3
  947. package/src/shade/device/mock/texture_view_resource.d.ts +26 -0
  948. package/src/shade/device/mock/texture_view_resource.d.ts.map +1 -0
  949. package/src/shade/device/mock/texture_view_resource.js +47 -0
  950. package/src/shade/device/timing/GPUTimer.d.ts.map +1 -1
  951. package/src/shade/device/timing/GPUTimer.js +35 -21
  952. package/src/shade/playground/caldera/caldera_format.d.ts +28 -1
  953. package/src/shade/playground/caldera/caldera_format.d.ts.map +1 -1
  954. package/src/shade/playground/caldera/caldera_format.js +37 -0
  955. package/src/shade/playground/caldera/main.js +12 -2
  956. package/src/shade/playground/frame_rate_meter.d.ts +92 -0
  957. package/src/shade/playground/frame_rate_meter.d.ts.map +1 -0
  958. package/src/shade/playground/frame_rate_meter.js +147 -0
  959. package/src/shade/playground/particle_ecs/main.js +53 -7
  960. package/src/shade/playground/particle_ecs/moonlit_environment.js +2 -2
  961. package/src/shade/playground/particle_stats_readback.d.ts +58 -0
  962. package/src/shade/playground/particle_stats_readback.d.ts.map +1 -0
  963. package/src/shade/playground/particle_stats_readback.js +83 -0
  964. package/src/shade/playground/particle_system/main.js +378 -325
  965. package/src/shade/playground/skinned_blas_refit/main.d.ts.map +1 -1
  966. package/src/shade/playground/skinned_blas_refit/main.js +7 -2
  967. package/src/shade/playground/sponza_path_trace/main.d.ts.map +1 -1
  968. package/src/shade/playground/sponza_path_trace/main.js +398 -393
  969. package/src/shade/playground/volumetrics_froxel/main.d.ts.map +1 -1
  970. package/src/shade/playground/volumetrics_froxel/main.js +941 -936
  971. package/src/shade/renderer/GraphicsContext.d.ts.map +1 -1
  972. package/src/shade/renderer/GraphicsContext.js +7 -2
  973. package/src/shade/renderer/Renderer.d.ts +47 -1
  974. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  975. package/src/shade/renderer/Renderer.js +224 -27
  976. package/src/shade/renderer/animation/ANIMATION_CLIP_STATE_STRUCT.d.ts +4 -7
  977. package/src/shade/renderer/animation/ANIMATION_CLIP_STATE_STRUCT.d.ts.map +1 -1
  978. package/src/shade/renderer/animation/ANIMATION_CLIP_STATE_STRUCT.js +19 -16
  979. package/src/shade/renderer/animation/ANIMATION_CURVE_HEADER_STRUCT.js +11 -11
  980. package/src/shade/renderer/animation/ANIMATION_DATABASE_SPEC.d.ts +14 -18
  981. package/src/shade/renderer/animation/ANIMATION_DATABASE_SPEC.d.ts.map +1 -1
  982. package/src/shade/renderer/animation/ANIMATION_DATABASE_SPEC.js +95 -24
  983. package/src/shade/renderer/animation/ANIMATION_SKIN_JOINT_STRUCT.d.ts +5 -4
  984. package/src/shade/renderer/animation/ANIMATION_SKIN_JOINT_STRUCT.d.ts.map +1 -1
  985. package/src/shade/renderer/animation/ANIMATION_SKIN_JOINT_STRUCT.js +7 -4
  986. package/src/shade/renderer/animation/ANIMATION_SKIN_STRUCT.d.ts +6 -12
  987. package/src/shade/renderer/animation/ANIMATION_SKIN_STRUCT.d.ts.map +1 -1
  988. package/src/shade/renderer/animation/ANIMATION_SKIN_STRUCT.js +9 -16
  989. package/src/shade/renderer/animation/ANIMATION_TRACK_BINDING_STRUCT.d.ts +6 -5
  990. package/src/shade/renderer/animation/ANIMATION_TRACK_BINDING_STRUCT.d.ts.map +1 -1
  991. package/src/shade/renderer/animation/ANIMATION_TRACK_BINDING_STRUCT.js +12 -5
  992. package/src/shade/renderer/animation/GPUAnimationManager.d.ts +80 -95
  993. package/src/shade/renderer/animation/GPUAnimationManager.d.ts.map +1 -1
  994. package/src/shade/renderer/animation/GPUAnimationManager.js +371 -606
  995. package/src/shade/renderer/animation/chunk_animation_curve_evaluate.d.ts +10 -14
  996. package/src/shade/renderer/animation/chunk_animation_curve_evaluate.d.ts.map +1 -1
  997. package/src/shade/renderer/animation/chunk_animation_curve_evaluate.js +40 -67
  998. package/src/shade/renderer/animation/chunk_pose_accumulator.d.ts.map +1 -1
  999. package/src/shade/renderer/animation/chunk_pose_accumulator.js +13 -4
  1000. package/src/shade/renderer/animation/shader_animation_apply.d.ts +14 -8
  1001. package/src/shade/renderer/animation/shader_animation_apply.d.ts.map +1 -1
  1002. package/src/shade/renderer/animation/shader_animation_apply.js +129 -128
  1003. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.js +2 -2
  1004. package/src/shade/renderer/animation/skinning/SKINNING_BINDING_STRUCT.d.ts +3 -2
  1005. package/src/shade/renderer/animation/skinning/SKINNING_BINDING_STRUCT.d.ts.map +1 -1
  1006. package/src/shade/renderer/animation/skinning/SKINNING_BINDING_STRUCT.js +3 -2
  1007. package/src/shade/renderer/animation/skinning/shader_skin_matrix_prep.d.ts +12 -7
  1008. package/src/shade/renderer/animation/skinning/shader_skin_matrix_prep.d.ts.map +1 -1
  1009. package/src/shade/renderer/animation/skinning/shader_skin_matrix_prep.js +107 -104
  1010. package/src/shade/renderer/binding/BindingResource.d.ts +36 -1
  1011. package/src/shade/renderer/binding/BindingResource.d.ts.map +1 -1
  1012. package/src/shade/renderer/binding/BindingResource.js +36 -3
  1013. package/src/shade/renderer/binding/BufferBinding.d.ts +8 -0
  1014. package/src/shade/renderer/binding/BufferBinding.d.ts.map +1 -1
  1015. package/src/shade/renderer/binding/BufferBinding.js +21 -0
  1016. package/src/shade/renderer/buffer/table/GPUDatabase.d.ts +19 -0
  1017. package/src/shade/renderer/buffer/table/GPUDatabase.d.ts.map +1 -1
  1018. package/src/shade/renderer/buffer/table/GPUDatabase.js +114 -1
  1019. package/src/shade/renderer/buffer/table/GPUDatabaseDefinition.d.ts +132 -1
  1020. package/src/shade/renderer/buffer/table/GPUDatabaseDefinition.d.ts.map +1 -1
  1021. package/src/shade/renderer/buffer/table/GPUDatabaseDefinition.js +384 -1
  1022. package/src/shade/renderer/buffer/table/GPUDatabaseReadback.d.ts.map +1 -1
  1023. package/src/shade/renderer/buffer/table/GPUDatabaseReadback.js +1332 -1323
  1024. package/src/shade/renderer/buffer/table/GPUTableLink.d.ts +67 -0
  1025. package/src/shade/renderer/buffer/table/GPUTableLink.d.ts.map +1 -0
  1026. package/src/shade/renderer/buffer/table/GPUTableLink.js +76 -0
  1027. package/src/shade/renderer/buffer/table/GPUTableRange.d.ts +72 -0
  1028. package/src/shade/renderer/buffer/table/GPUTableRange.d.ts.map +1 -0
  1029. package/src/shade/renderer/buffer/table/GPUTableRange.js +82 -0
  1030. package/src/shade/renderer/buffer/table/GPUTypedTable.d.ts +106 -5
  1031. package/src/shade/renderer/buffer/table/GPUTypedTable.d.ts.map +1 -1
  1032. package/src/shade/renderer/buffer/table/GPUTypedTable.js +458 -28
  1033. package/src/shade/renderer/buffer/table/GPUTypedTableDescriptor.d.ts.map +1 -1
  1034. package/src/shade/renderer/buffer/table/GPUTypedTableDescriptor.js +28 -5
  1035. package/src/shade/renderer/buffer/table/GPU_DATABASE_NULL.d.ts +14 -0
  1036. package/src/shade/renderer/buffer/table/GPU_DATABASE_NULL.d.ts.map +1 -0
  1037. package/src/shade/renderer/buffer/table/GPU_DATABASE_NULL.js +13 -0
  1038. package/src/shade/renderer/buffer/table/gpu_database_check_links.d.ts +80 -0
  1039. package/src/shade/renderer/buffer/table/gpu_database_check_links.d.ts.map +1 -0
  1040. package/src/shade/renderer/buffer/table/gpu_database_check_links.js +456 -0
  1041. package/src/shade/renderer/buffer/table/gpu_table_field_word.d.ts +17 -0
  1042. package/src/shade/renderer/buffer/table/gpu_table_field_word.d.ts.map +1 -0
  1043. package/src/shade/renderer/buffer/table/gpu_table_field_word.js +111 -0
  1044. package/src/shade/renderer/buffer/table/gpu_table_range_well_formed.d.ts +20 -0
  1045. package/src/shade/renderer/buffer/table/gpu_table_range_well_formed.d.ts.map +1 -0
  1046. package/src/shade/renderer/buffer/table/gpu_table_range_well_formed.js +27 -0
  1047. package/src/shade/renderer/camera/CameraManager.d.ts +11 -0
  1048. package/src/shade/renderer/camera/CameraManager.d.ts.map +1 -1
  1049. package/src/shade/renderer/camera/CameraManager.js +18 -0
  1050. package/src/shade/renderer/create_frame_loop.d.ts +16 -0
  1051. package/src/shade/renderer/create_frame_loop.d.ts.map +1 -1
  1052. package/src/shade/renderer/create_frame_loop.js +16 -0
  1053. package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.d.ts +23 -0
  1054. package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.d.ts.map +1 -1
  1055. package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.js +27 -32
  1056. package/src/shade/renderer/deferred/chunk_shade_standard_material_direct_heavy.d.ts +9 -7
  1057. package/src/shade/renderer/deferred/chunk_shade_standard_material_direct_heavy.d.ts.map +1 -1
  1058. package/src/shade/renderer/deferred/chunk_shade_standard_material_direct_heavy.js +16 -108
  1059. package/src/shade/renderer/dynamic/DynamicMeshAVBOITChannel.d.ts +135 -0
  1060. package/src/shade/renderer/dynamic/DynamicMeshAVBOITChannel.d.ts.map +1 -0
  1061. package/src/shade/renderer/dynamic/DynamicMeshAVBOITChannel.js +296 -0
  1062. package/src/shade/renderer/dynamic/GPUDynamicMeshRenderer.d.ts +2 -2
  1063. package/src/shade/renderer/dynamic/GPUDynamicMeshRenderer.d.ts.map +1 -1
  1064. package/src/shade/renderer/dynamic/GPUDynamicMeshRenderer.js +10 -131
  1065. package/src/shade/renderer/dynamic/GPUDynamicMeshResidency.d.ts.map +1 -1
  1066. package/src/shade/renderer/dynamic/GPUDynamicMeshResidency.js +185 -167
  1067. package/src/shade/renderer/dynamic/GPUDynamicMeshResidencyTable.d.ts +49 -0
  1068. package/src/shade/renderer/dynamic/GPUDynamicMeshResidencyTable.d.ts.map +1 -0
  1069. package/src/shade/renderer/dynamic/GPUDynamicMeshResidencyTable.js +185 -0
  1070. package/src/shade/renderer/dynamic/chunk_dynamic_mesh_avboit_vertex.d.ts +24 -0
  1071. package/src/shade/renderer/dynamic/chunk_dynamic_mesh_avboit_vertex.d.ts.map +1 -0
  1072. package/src/shade/renderer/dynamic/chunk_dynamic_mesh_avboit_vertex.js +49 -0
  1073. package/src/shade/renderer/dynamic/chunk_dynamic_mesh_vertex.d.ts +18 -0
  1074. package/src/shade/renderer/dynamic/chunk_dynamic_mesh_vertex.d.ts.map +1 -0
  1075. package/src/shade/renderer/dynamic/chunk_dynamic_mesh_vertex.js +54 -0
  1076. package/src/shade/renderer/dynamic/dynamic_mesh_live_bounds.d.ts +26 -0
  1077. package/src/shade/renderer/dynamic/dynamic_mesh_live_bounds.d.ts.map +1 -0
  1078. package/src/shade/renderer/dynamic/dynamic_mesh_live_bounds.js +96 -0
  1079. package/src/shade/renderer/dynamic/graph_dynamic_mesh_avboit.d.ts +102 -0
  1080. package/src/shade/renderer/dynamic/graph_dynamic_mesh_avboit.d.ts.map +1 -0
  1081. package/src/shade/renderer/dynamic/graph_dynamic_mesh_avboit.js +364 -0
  1082. package/src/shade/renderer/dynamic/shader_dynamic_mesh.d.ts.map +1 -1
  1083. package/src/shade/renderer/dynamic/shader_dynamic_mesh.js +153 -177
  1084. package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_draw.d.ts +20 -0
  1085. package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_draw.d.ts.map +1 -0
  1086. package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_draw.js +136 -0
  1087. package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_occupancy.d.ts +20 -0
  1088. package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_occupancy.d.ts.map +1 -0
  1089. package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_occupancy.js +106 -0
  1090. package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_splat.d.ts +32 -0
  1091. package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_splat.d.ts.map +1 -0
  1092. package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_splat.js +163 -0
  1093. package/src/shade/renderer/extension/RENDER_EXTENSION_DESIGN.md +13 -2
  1094. package/src/shade/renderer/fow/GPUFogOfWarRenderer.d.ts.map +1 -1
  1095. package/src/shade/renderer/fow/GPUFogOfWarRenderer.js +5 -14
  1096. package/src/shade/renderer/fow/fow_obtain_mask.d.ts +17 -0
  1097. package/src/shade/renderer/fow/fow_obtain_mask.d.ts.map +1 -0
  1098. package/src/shade/renderer/fow/fow_obtain_mask.js +41 -0
  1099. package/src/shade/renderer/frame_jitter_applies.d.ts +21 -0
  1100. package/src/shade/renderer/frame_jitter_applies.d.ts.map +1 -0
  1101. package/src/shade/renderer/frame_jitter_applies.js +23 -0
  1102. package/src/shade/renderer/geometry/bvh/GPUGeometryBVHManager.d.ts.map +1 -1
  1103. package/src/shade/renderer/geometry/bvh/GPUGeometryBVHManager.js +128 -3
  1104. package/src/shade/renderer/geometry/geometry_obtain_attribute.d.ts +42 -0
  1105. package/src/shade/renderer/geometry/geometry_obtain_attribute.d.ts.map +1 -0
  1106. package/src/shade/renderer/geometry/geometry_obtain_attribute.js +83 -0
  1107. package/src/shade/renderer/geometry/meshlet/GPUMeshletManager.d.ts +12 -0
  1108. package/src/shade/renderer/geometry/meshlet/GPUMeshletManager.d.ts.map +1 -1
  1109. package/src/shade/renderer/geometry/meshlet/GPUMeshletManager.js +65 -0
  1110. package/src/shade/renderer/geometry/meshlet/build/geometry_to_meshlets_greedy.d.ts.map +1 -1
  1111. package/src/shade/renderer/geometry/meshlet/build/geometry_to_meshlets_greedy.js +4 -1
  1112. package/src/shade/renderer/geometry/meshlet/build/meshoptimizer/geometry_to_meshlets_meshoptimizer.d.ts.map +1 -1
  1113. package/src/shade/renderer/geometry/meshlet/build/meshoptimizer/geometry_to_meshlets_meshoptimizer.js +4 -1
  1114. package/src/shade/renderer/geometry/normals/encode_normals_to_octahedral_u32.d.ts.map +1 -1
  1115. package/src/shade/renderer/geometry/normals/encode_normals_to_octahedral_u32.js +4 -1
  1116. package/src/shade/renderer/geometry/normals/geometry_build_tangents.d.ts.map +1 -1
  1117. package/src/shade/renderer/geometry/normals/geometry_build_tangents.js +39 -1
  1118. package/src/shade/renderer/geometry/util/geometry_merge.d.ts.map +1 -1
  1119. package/src/shade/renderer/geometry/util/geometry_merge.js +18 -2
  1120. package/src/shade/renderer/geometry/virtual/VIRTUAL_GEOMETRY_DESIGN.md +93 -12
  1121. package/src/shade/renderer/geometry/virtual/WEDGE_PLAN_2026_09_18.md +91 -1
  1122. package/src/shade/renderer/geometry/virtual/build/VGeoBuildOptions.d.ts +0 -13
  1123. package/src/shade/renderer/geometry/virtual/build/VGeoBuildOptions.d.ts.map +1 -1
  1124. package/src/shade/renderer/geometry/virtual/build/VGeoBuildOptions.js +0 -15
  1125. package/src/shade/renderer/geometry/virtual/build/gltf/gltf_collect_geometries.d.ts.map +1 -1
  1126. package/src/shade/renderer/geometry/virtual/build/gltf/gltf_collect_geometries.js +31 -2
  1127. package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.d.ts +18 -0
  1128. package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.d.ts.map +1 -1
  1129. package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.js +19 -0
  1130. package/src/shade/renderer/geometry/virtual/build/level/VGeoGroupStep.d.ts +8 -0
  1131. package/src/shade/renderer/geometry/virtual/build/level/VGeoGroupStep.d.ts.map +1 -1
  1132. package/src/shade/renderer/geometry/virtual/build/level/VGeoGroupStep.js +9 -0
  1133. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts.map +1 -1
  1134. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.js +15 -6
  1135. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_leaf_frontier.d.ts.map +1 -1
  1136. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_leaf_frontier.js +4 -0
  1137. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_levels.d.ts.map +1 -1
  1138. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_levels.js +12 -0
  1139. package/src/shade/renderer/geometry/virtual/build/mesh/VGEO_DEFAULT_ATTRIBUTE_WEIGHT_RATIOS.d.ts +11 -1
  1140. package/src/shade/renderer/geometry/virtual/build/mesh/VGEO_DEFAULT_ATTRIBUTE_WEIGHT_RATIOS.d.ts.map +1 -1
  1141. package/src/shade/renderer/geometry/virtual/build/mesh/VGEO_DEFAULT_ATTRIBUTE_WEIGHT_RATIOS.js +11 -1
  1142. package/src/shade/renderer/geometry/virtual/build/mesh/vgeo_compute_vertex_normals.d.ts +18 -9
  1143. package/src/shade/renderer/geometry/virtual/build/mesh/vgeo_compute_vertex_normals.d.ts.map +1 -1
  1144. package/src/shade/renderer/geometry/virtual/build/mesh/vgeo_compute_vertex_normals.js +20 -26
  1145. package/src/shade/renderer/geometry/virtual/build/mesh/vgeo_normalize_source.d.ts +1 -3
  1146. package/src/shade/renderer/geometry/virtual/build/mesh/vgeo_normalize_source.d.ts.map +1 -1
  1147. package/src/shade/renderer/geometry/virtual/build/mesh/vgeo_normalize_source.js +2 -5
  1148. package/src/shade/renderer/geometry/virtual/build/vgeo_build.js +1 -1
  1149. package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.d.ts.map +1 -1
  1150. package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.js +10 -1
  1151. package/src/shade/renderer/geometry/virtual/format/read/vgeo_read_page.js +21 -0
  1152. package/src/shade/renderer/geometry/virtual/format/vgeo_write_container.d.ts.map +1 -1
  1153. package/src/shade/renderer/geometry/virtual/format/vgeo_write_container.js +33 -1
  1154. package/src/shade/renderer/geometry/virtual/runtime/VGeoPageFetcher.d.ts.map +1 -1
  1155. package/src/shade/renderer/geometry/virtual/runtime/VGeoPageFetcher.js +63 -2
  1156. package/src/shade/renderer/geometry/virtual/runtime/VGeoResidency.d.ts.map +1 -1
  1157. package/src/shade/renderer/geometry/virtual/runtime/VGeoResidency.js +14 -1
  1158. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.d.ts +17 -0
  1159. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.d.ts.map +1 -1
  1160. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.js +39 -0
  1161. package/src/shade/renderer/geometry/virtual/runtime/graph_vgeo_expand_instances_to_meshlets.d.ts.map +1 -1
  1162. package/src/shade/renderer/geometry/virtual/runtime/graph_vgeo_expand_instances_to_meshlets.js +7 -0
  1163. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_decode.d.ts.map +1 -1
  1164. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_decode.js +23 -2
  1165. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_decode_from_storage.d.ts.map +1 -1
  1166. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_decode_from_storage.js +22 -1
  1167. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_encode.d.ts.map +1 -1
  1168. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_encode.js +23 -2
  1169. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_encode_to_storage.d.ts.map +1 -1
  1170. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_encode_to_storage.js +22 -1
  1171. package/src/shade/renderer/global_illumination/lpv/lpv_visualise_probes.d.ts +2 -1
  1172. package/src/shade/renderer/global_illumination/lpv/lpv_visualise_probes.d.ts.map +1 -1
  1173. package/src/shade/renderer/global_illumination/lpv/lpv_visualise_probes.js +12 -53
  1174. package/src/shade/renderer/global_illumination/probe/octahedral/GPUProbeAtlas.d.ts.map +1 -1
  1175. package/src/shade/renderer/global_illumination/probe/octahedral/GPUProbeAtlas.js +12 -3
  1176. package/src/shade/renderer/global_illumination/probe/octahedral/convolve/graph_lvp_atlas_to_sh.d.ts.map +1 -1
  1177. package/src/shade/renderer/global_illumination/probe/octahedral/convolve/graph_lvp_atlas_to_sh.js +2 -1
  1178. package/src/shade/renderer/global_illumination/probe/octahedral/sample/chunk_lpv_atlas_patch_texel_coord.d.ts +17 -0
  1179. package/src/shade/renderer/global_illumination/probe/octahedral/sample/chunk_lpv_atlas_patch_texel_coord.d.ts.map +1 -0
  1180. package/src/shade/renderer/global_illumination/probe/octahedral/sample/chunk_lpv_atlas_patch_texel_coord.js +38 -0
  1181. package/src/shade/renderer/global_illumination/probe/octahedral/sample/chunk_lpv_atlas_read_patch_texel.d.ts.map +1 -1
  1182. package/src/shade/renderer/global_illumination/probe/octahedral/sample/chunk_lpv_atlas_read_patch_texel.js +16 -10
  1183. package/src/shade/renderer/gpu_primitive/indirect/IndirectComputeCommandBuildPass.d.ts +1 -1
  1184. package/src/shade/renderer/gpu_primitive/indirect/IndirectComputeCommandBuildPass.d.ts.map +1 -1
  1185. package/src/shade/renderer/gpu_primitive/indirect/IndirectComputeCommandBuildPass.js +25 -14
  1186. package/src/shade/renderer/gpu_primitive/indirect/NOTES.md +94 -0
  1187. package/src/shade/renderer/gpu_primitive/indirect/WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION.d.ts +10 -7
  1188. package/src/shade/renderer/gpu_primitive/indirect/WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION.d.ts.map +1 -1
  1189. package/src/shade/renderer/gpu_primitive/indirect/WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION.js +10 -7
  1190. package/src/shade/renderer/light/GPULightCollection.d.ts.map +1 -1
  1191. package/src/shade/renderer/light/GPULightCollection.js +22 -1
  1192. package/src/shade/renderer/light/LIGHT_DATABASE_SPEC.d.ts.map +1 -1
  1193. package/src/shade/renderer/light/LIGHT_DATABASE_SPEC.js +26 -0
  1194. package/src/shade/renderer/light/cluster/chunk_cluster_keep_smallest.d.ts +21 -0
  1195. package/src/shade/renderer/light/cluster/chunk_cluster_keep_smallest.d.ts.map +1 -0
  1196. package/src/shade/renderer/light/cluster/chunk_cluster_keep_smallest.js +47 -0
  1197. package/src/shade/renderer/light/cluster/shader_cluster_assign_lights.d.ts.map +1 -1
  1198. package/src/shade/renderer/light/cluster/shader_cluster_assign_lights.js +12 -8
  1199. package/src/shade/renderer/light/environment/equirectangular_zenith_first_direction_to_uv.d.ts +36 -0
  1200. package/src/shade/renderer/light/environment/equirectangular_zenith_first_direction_to_uv.d.ts.map +1 -0
  1201. package/src/shade/renderer/light/environment/equirectangular_zenith_first_direction_to_uv.js +41 -0
  1202. package/src/shade/renderer/light/environment/execute_filter_environment_map.d.ts.map +1 -1
  1203. package/src/shade/renderer/light/environment/execute_filter_environment_map.js +17 -1
  1204. package/src/shade/renderer/light/environment/octahedral_uv_to_direction.d.ts +5 -13
  1205. package/src/shade/renderer/light/environment/octahedral_uv_to_direction.d.ts.map +1 -1
  1206. package/src/shade/renderer/light/environment/octahedral_uv_to_direction.js +10 -30
  1207. package/src/shade/renderer/light/environment/octahedral_z_pole_uv_to_direction.d.ts +31 -0
  1208. package/src/shade/renderer/light/environment/octahedral_z_pole_uv_to_direction.d.ts.map +1 -0
  1209. package/src/shade/renderer/light/environment/octahedral_z_pole_uv_to_direction.js +45 -0
  1210. package/src/shade/renderer/light/environment/resample_cube_to_octahedral.js +2 -2
  1211. package/src/shade/renderer/light/environment/resample_equirectangular_to_octahedral.d.ts.map +1 -1
  1212. package/src/shade/renderer/light/environment/resample_equirectangular_to_octahedral.js +11 -8
  1213. package/src/shade/renderer/light/environment/rgbe/RGBE_ReadPixels_RLE.d.ts.map +1 -1
  1214. package/src/shade/renderer/light/environment/rgbe/RGBE_ReadPixels_RLE.js +7 -1
  1215. package/src/shade/renderer/light/model/SpotLight.d.ts +10 -1
  1216. package/src/shade/renderer/light/model/SpotLight.d.ts.map +1 -1
  1217. package/src/shade/renderer/light/model/SpotLight.js +11 -3
  1218. package/src/shade/renderer/light/model/io/light_record_directional.d.ts.map +1 -1
  1219. package/src/shade/renderer/light/model/io/light_record_directional.js +3 -1
  1220. package/src/shade/renderer/light/model/io/light_record_point.d.ts.map +1 -1
  1221. package/src/shade/renderer/light/model/io/light_record_point.js +3 -1
  1222. package/src/shade/renderer/light/model/io/light_record_spot.d.ts.map +1 -1
  1223. package/src/shade/renderer/light/model/io/light_record_spot.js +3 -1
  1224. package/src/shade/renderer/lightmap/GPULightMap.d.ts.map +1 -1
  1225. package/src/shade/renderer/lightmap/GPULightMap.js +349 -336
  1226. package/src/shade/renderer/loader/gltf/gltf_base_url.d.ts +20 -0
  1227. package/src/shade/renderer/loader/gltf/gltf_base_url.d.ts.map +1 -0
  1228. package/src/shade/renderer/loader/gltf/gltf_base_url.js +27 -0
  1229. package/src/shade/renderer/loader/gltf/gltf_create_material.d.ts.map +1 -1
  1230. package/src/shade/renderer/loader/gltf/gltf_create_material.js +50 -10
  1231. package/src/shade/renderer/loader/gltf/load_gltf.d.ts +4 -0
  1232. package/src/shade/renderer/loader/gltf/load_gltf.d.ts.map +1 -1
  1233. package/src/shade/renderer/loader/gltf/load_gltf.js +1109 -1128
  1234. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  1235. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts.map +1 -1
  1236. package/src/shade/renderer/loader/gltf/tiny-gltf.js +843 -843
  1237. package/src/shade/renderer/material/GPUMaterialContext.d.ts +63 -26
  1238. package/src/shade/renderer/material/GPUMaterialContext.d.ts.map +1 -1
  1239. package/src/shade/renderer/material/GPUMaterialContext.js +255 -390
  1240. package/src/shade/renderer/material/GPUMaterialManager.d.ts +51 -1
  1241. package/src/shade/renderer/material/GPUMaterialManager.d.ts.map +1 -1
  1242. package/src/shade/renderer/material/GPUMaterialManager.js +345 -91
  1243. package/src/shade/renderer/material/ShadeMaterial.d.ts +21 -0
  1244. package/src/shade/renderer/material/ShadeMaterial.d.ts.map +1 -1
  1245. package/src/shade/renderer/material/ShadeMaterial.js +31 -0
  1246. package/src/shade/renderer/material/resident/GPUResidentMaterialContext.d.ts.map +1 -1
  1247. package/src/shade/renderer/material/resident/GPUResidentMaterialContext.js +25 -6
  1248. package/src/shade/renderer/material/standard/SHADING_MATERIAL_RESOURCE_GROUP.d.ts +10 -0
  1249. package/src/shade/renderer/material/standard/SHADING_MATERIAL_RESOURCE_GROUP.d.ts.map +1 -1
  1250. package/src/shade/renderer/material/standard/SHADING_MATERIAL_RESOURCE_GROUP.js +14 -2
  1251. package/src/shade/renderer/material/standard/STANDARD_MATERIAL_TEMPLATE.d.ts +12 -0
  1252. package/src/shade/renderer/material/standard/STANDARD_MATERIAL_TEMPLATE.d.ts.map +1 -0
  1253. package/src/shade/renderer/material/standard/STANDARD_MATERIAL_TEMPLATE.js +166 -0
  1254. package/src/shade/renderer/material/standard/VT_MATERIAL_TEMPLATE.d.ts +10 -0
  1255. package/src/shade/renderer/material/standard/VT_MATERIAL_TEMPLATE.d.ts.map +1 -0
  1256. package/src/shade/renderer/material/standard/VT_MATERIAL_TEMPLATE.js +141 -0
  1257. package/src/shade/renderer/material/standard/chunk_standard_material_surface.d.ts +29 -0
  1258. package/src/shade/renderer/material/standard/chunk_standard_material_surface.d.ts.map +1 -0
  1259. package/src/shade/renderer/material/standard/chunk_standard_material_surface.js +92 -0
  1260. package/src/shade/renderer/material/standard/fragment_gbuffer.d.ts +74 -28
  1261. package/src/shade/renderer/material/standard/fragment_gbuffer.d.ts.map +1 -1
  1262. package/src/shade/renderer/material/standard/fragment_gbuffer.js +165 -67
  1263. package/src/shade/renderer/material/standard/fragment_gbuffer_vt.d.ts +27 -18
  1264. package/src/shade/renderer/material/standard/fragment_gbuffer_vt.d.ts.map +1 -1
  1265. package/src/shade/renderer/material/standard/fragment_gbuffer_vt.js +70 -91
  1266. package/src/shade/renderer/material/standard/material_gbuffer_vertex.d.ts +9 -6
  1267. package/src/shade/renderer/material/standard/material_gbuffer_vertex.d.ts.map +1 -1
  1268. package/src/shade/renderer/material/standard/material_gbuffer_vertex.js +13 -14
  1269. package/src/shade/renderer/material/template/GPUMaterialServices.d.ts +73 -0
  1270. package/src/shade/renderer/material/template/GPUMaterialServices.d.ts.map +1 -0
  1271. package/src/shade/renderer/material/template/GPUMaterialServices.js +79 -0
  1272. package/src/shade/renderer/material/template/ShadeMaterialTemplate.d.ts +170 -0
  1273. package/src/shade/renderer/material/template/ShadeMaterialTemplate.d.ts.map +1 -0
  1274. package/src/shade/renderer/material/template/ShadeMaterialTemplate.js +234 -0
  1275. package/src/shade/renderer/material/template/chunk_material_surface.d.ts +47 -0
  1276. package/src/shade/renderer/material/template/chunk_material_surface.d.ts.map +1 -0
  1277. package/src/shade/renderer/material/template/chunk_material_surface.js +116 -0
  1278. package/src/shade/renderer/material/template/flat_material_template_spec_support.d.ts +22 -0
  1279. package/src/shade/renderer/material/template/flat_material_template_spec_support.d.ts.map +1 -0
  1280. package/src/shade/renderer/material/template/flat_material_template_spec_support.js +78 -0
  1281. package/src/shade/renderer/material/template/material_metadata_neutral.d.ts +15 -0
  1282. package/src/shade/renderer/material/template/material_metadata_neutral.d.ts.map +1 -0
  1283. package/src/shade/renderer/material/template/material_metadata_neutral.js +46 -0
  1284. package/src/shade/renderer/material/template/material_template_of.d.ts +10 -0
  1285. package/src/shade/renderer/material/template/material_template_of.d.ts.map +1 -0
  1286. package/src/shade/renderer/material/template/material_template_of.js +20 -0
  1287. package/src/shade/renderer/object_property/chunk_write_object_property.d.ts +5 -0
  1288. package/src/shade/renderer/object_property/chunk_write_object_property.d.ts.map +1 -1
  1289. package/src/shade/renderer/object_property/chunk_write_object_property.js +7 -1
  1290. package/src/shade/renderer/object_property/chunk_write_object_property_node3d.d.ts +7 -1
  1291. package/src/shade/renderer/object_property/chunk_write_object_property_node3d.d.ts.map +1 -1
  1292. package/src/shade/renderer/object_property/chunk_write_object_property_node3d.js +9 -2
  1293. package/src/shade/renderer/particles/DESIGN.md +21 -5
  1294. package/src/shade/renderer/particles/GPUParticleSystem.d.ts +25 -10
  1295. package/src/shade/renderer/particles/GPUParticleSystem.d.ts.map +1 -1
  1296. package/src/shade/renderer/particles/GPUParticleSystem.js +182 -38
  1297. package/src/shade/renderer/particles/data/PARTICLE_DATABASE_SPEC.d.ts.map +1 -1
  1298. package/src/shade/renderer/particles/data/PARTICLE_DATABASE_SPEC.js +81 -68
  1299. package/src/shade/renderer/particles/graph/groups/simplex_reference.d.ts.map +1 -1
  1300. package/src/shade/renderer/particles/graph/groups/simplex_reference.js +16 -10
  1301. package/src/shade/renderer/particles/graph_particles.d.ts +4 -2
  1302. package/src/shade/renderer/particles/graph_particles.d.ts.map +1 -1
  1303. package/src/shade/renderer/particles/graph_particles.js +8 -2
  1304. package/src/shade/renderer/particles/isa/ParticleVMISA.d.ts +22 -3
  1305. package/src/shade/renderer/particles/isa/ParticleVMISA.d.ts.map +1 -1
  1306. package/src/shade/renderer/particles/isa/ParticleVMISA.js +30 -3
  1307. package/src/shade/renderer/particles/isa/particle_assembly.js +41 -1
  1308. package/src/shade/renderer/particles/optimizer/particle_program_analysis.d.ts +7 -1
  1309. package/src/shade/renderer/particles/optimizer/particle_program_analysis.d.ts.map +1 -1
  1310. package/src/shade/renderer/particles/optimizer/particle_program_analysis.js +23 -17
  1311. package/src/shade/renderer/particles/optimizer/particle_vm_semantics.d.ts.map +1 -1
  1312. package/src/shade/renderer/particles/optimizer/particle_vm_semantics.js +8 -2
  1313. package/src/shade/renderer/particles/optimizer/pass_allocate_registers.js +1 -1
  1314. package/src/shade/renderer/particles/optimizer/pass_fold_constants.d.ts.map +1 -1
  1315. package/src/shade/renderer/particles/optimizer/pass_fold_constants.js +20 -13
  1316. package/src/shade/renderer/particles/optimizer/pass_inline_constants.d.ts.map +1 -1
  1317. package/src/shade/renderer/particles/optimizer/pass_inline_constants.js +4 -3
  1318. package/src/shade/renderer/particles/optimizer/pass_narrow_widths.d.ts.map +1 -1
  1319. package/src/shade/renderer/particles/optimizer/pass_narrow_widths.js +1 -1
  1320. package/src/shade/renderer/particles/optimizer/pass_pack_registers.d.ts.map +1 -1
  1321. package/src/shade/renderer/particles/optimizer/pass_pack_registers.js +12 -4
  1322. package/src/shade/renderer/particles/optimizer/pass_peephole.d.ts.map +1 -1
  1323. package/src/shade/renderer/particles/optimizer/pass_peephole.js +11 -10
  1324. package/src/shade/renderer/particles/optimizer/pass_propagate_copies.d.ts.map +1 -1
  1325. package/src/shade/renderer/particles/optimizer/pass_propagate_copies.js +12 -10
  1326. package/src/shade/renderer/particles/optimizer/pass_share_subexpressions.d.ts.map +1 -1
  1327. package/src/shade/renderer/particles/optimizer/pass_share_subexpressions.js +12 -4
  1328. package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts.map +1 -1
  1329. package/src/shade/renderer/particles/runtime/ParticleEmitter.js +7 -0
  1330. package/src/shade/renderer/particles/shaders/chunk_particle_avboit_contribution.d.ts +4 -0
  1331. package/src/shade/renderer/particles/shaders/chunk_particle_avboit_contribution.d.ts.map +1 -1
  1332. package/src/shade/renderer/particles/shaders/chunk_particle_avboit_contribution.js +47 -88
  1333. package/src/shade/renderer/particles/shaders/shader_particle_avboit_occupancy.d.ts.map +1 -1
  1334. package/src/shade/renderer/particles/shaders/shader_particle_avboit_occupancy.js +22 -68
  1335. package/src/shade/renderer/particles/shaders/shader_particle_avboit_splat.d.ts.map +1 -1
  1336. package/src/shade/renderer/particles/shaders/shader_particle_avboit_splat.js +5 -3
  1337. package/src/shade/renderer/particles/shaders/shader_particle_init_free_list.d.ts +31 -0
  1338. package/src/shade/renderer/particles/shaders/shader_particle_init_free_list.d.ts.map +1 -0
  1339. package/src/shade/renderer/particles/shaders/shader_particle_init_free_list.js +62 -0
  1340. package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts +13 -0
  1341. package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts.map +1 -1
  1342. package/src/shade/renderer/particles/vm/ParticleVMReference.js +112 -18
  1343. package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.d.ts.map +1 -1
  1344. package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.js +12 -2
  1345. package/src/shade/renderer/postprocess/TemporalJitterSequence.d.ts +44 -0
  1346. package/src/shade/renderer/postprocess/TemporalJitterSequence.d.ts.map +1 -0
  1347. package/src/shade/renderer/postprocess/TemporalJitterSequence.js +104 -0
  1348. package/src/shade/renderer/postprocess/chunk_find_nearest_depth.d.ts +25 -0
  1349. package/src/shade/renderer/postprocess/chunk_find_nearest_depth.d.ts.map +1 -0
  1350. package/src/shade/renderer/postprocess/chunk_find_nearest_depth.js +74 -0
  1351. package/src/shade/renderer/postprocess/denoise/shader_temporal_reprojection_luma.d.ts.map +1 -1
  1352. package/src/shade/renderer/postprocess/denoise/shader_temporal_reprojection_luma.js +19 -4
  1353. package/src/shade/renderer/postprocess/dof/gather/shader_dof2_recombine.d.ts.map +1 -1
  1354. package/src/shade/renderer/postprocess/dof/gather/shader_dof2_recombine.js +12 -1
  1355. package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.d.ts.map +1 -1
  1356. package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.js +8 -0
  1357. package/src/shade/renderer/postprocess/eye/shader_autoexposure_adapt.d.ts.map +1 -1
  1358. package/src/shade/renderer/postprocess/eye/shader_autoexposure_adapt.js +18 -3
  1359. package/src/shade/renderer/postprocess/eye/shader_autoexposure_read_histogram.d.ts.map +1 -1
  1360. package/src/shade/renderer/postprocess/eye/shader_autoexposure_read_histogram.js +17 -4
  1361. package/src/shade/renderer/postprocess/gtao/GTAO_CONSTANTS.d.ts +29 -0
  1362. package/src/shade/renderer/postprocess/gtao/GTAO_CONSTANTS.d.ts.map +1 -0
  1363. package/src/shade/renderer/postprocess/gtao/GTAO_CONSTANTS.js +69 -0
  1364. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao.d.ts +4 -16
  1365. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao.d.ts.map +1 -1
  1366. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao.js +10 -52
  1367. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao_with_irradiance.d.ts +0 -16
  1368. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao_with_irradiance.d.ts.map +1 -1
  1369. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao_with_irradiance.js +23 -55
  1370. package/src/shade/renderer/postprocess/motion_blur/MotionBlur.d.ts +4 -1
  1371. package/src/shade/renderer/postprocess/motion_blur/MotionBlur.d.ts.map +1 -1
  1372. package/src/shade/renderer/postprocess/motion_blur/MotionBlur.js +4 -1
  1373. package/src/shade/renderer/postprocess/motion_blur/chunk_motion_blur_resolution.d.ts +18 -0
  1374. package/src/shade/renderer/postprocess/motion_blur/chunk_motion_blur_resolution.d.ts.map +1 -0
  1375. package/src/shade/renderer/postprocess/motion_blur/chunk_motion_blur_resolution.js +43 -0
  1376. package/src/shade/renderer/postprocess/motion_blur/graph_postprocess_motion_blur.d.ts +5 -1
  1377. package/src/shade/renderer/postprocess/motion_blur/graph_postprocess_motion_blur.d.ts.map +1 -1
  1378. package/src/shade/renderer/postprocess/motion_blur/graph_postprocess_motion_blur.js +12 -2
  1379. package/src/shade/renderer/postprocess/motion_blur/shader_motion_blur_reconstruct.d.ts.map +1 -1
  1380. package/src/shade/renderer/postprocess/motion_blur/shader_motion_blur_reconstruct.js +33 -6
  1381. package/src/shade/renderer/postprocess/nss/NSS.d.ts +16 -8
  1382. package/src/shade/renderer/postprocess/nss/NSS.d.ts.map +1 -1
  1383. package/src/shade/renderer/postprocess/nss/NSS.js +37 -35
  1384. package/src/shade/renderer/postprocess/nss/chunk_nss_find_nearest_depth.d.ts +2 -2
  1385. package/src/shade/renderer/postprocess/nss/chunk_nss_find_nearest_depth.d.ts.map +1 -1
  1386. package/src/shade/renderer/postprocess/nss/chunk_nss_find_nearest_depth.js +28 -61
  1387. package/src/shade/renderer/postprocess/nss/shader_nss_postprocess.d.ts.map +1 -1
  1388. package/src/shade/renderer/postprocess/nss/shader_nss_postprocess.js +296 -291
  1389. package/src/shade/renderer/postprocess/nss/shader_nss_preprocess.d.ts.map +1 -1
  1390. package/src/shade/renderer/postprocess/nss/shader_nss_preprocess.js +13 -0
  1391. package/src/shade/renderer/postprocess/ssr/SSR.d.ts.map +1 -1
  1392. package/src/shade/renderer/postprocess/ssr/SSR.js +9 -7
  1393. package/src/shade/renderer/postprocess/ssr/depth_max_shader.d.ts +14 -0
  1394. package/src/shade/renderer/postprocess/ssr/depth_max_shader.d.ts.map +1 -1
  1395. package/src/shade/renderer/postprocess/ssr/depth_max_shader.js +53 -25
  1396. package/src/shade/renderer/postprocess/ssr/graph_build_depth_max_pyramid.d.ts +11 -1
  1397. package/src/shade/renderer/postprocess/ssr/graph_build_depth_max_pyramid.d.ts.map +1 -1
  1398. package/src/shade/renderer/postprocess/ssr/graph_build_depth_max_pyramid.js +11 -1
  1399. package/src/shade/renderer/postprocess/ssr/prefilter/NOTES.md +46 -0
  1400. package/src/shade/renderer/postprocess/ssr/prefilter/shader_ssr_prefilter.d.ts.map +1 -1
  1401. package/src/shade/renderer/postprocess/ssr/prefilter/shader_ssr_prefilter.js +7 -0
  1402. package/src/shade/renderer/postprocess/ssr/shader/chunk_ssr_depth_thickness.d.ts +32 -0
  1403. package/src/shade/renderer/postprocess/ssr/shader/chunk_ssr_depth_thickness.d.ts.map +1 -0
  1404. package/src/shade/renderer/postprocess/ssr/shader/chunk_ssr_depth_thickness.js +41 -0
  1405. package/src/shade/renderer/postprocess/ssr/ssr_trace_shader.d.ts.map +1 -1
  1406. package/src/shade/renderer/postprocess/ssr/ssr_trace_shader.js +11 -6
  1407. package/src/shade/renderer/postprocess/taa/TAA.d.ts +13 -4
  1408. package/src/shade/renderer/postprocess/taa/TAA.d.ts.map +1 -1
  1409. package/src/shade/renderer/postprocess/taa/TAA.js +29 -48
  1410. package/src/shade/renderer/postprocess/taa/chunk_taa_tonemap.d.ts +11 -0
  1411. package/src/shade/renderer/postprocess/taa/chunk_taa_tonemap.d.ts.map +1 -1
  1412. package/src/shade/renderer/postprocess/taa/chunk_taa_tonemap.js +25 -4
  1413. package/src/shade/renderer/postprocess/taa/shader_depth_occlusion_clip.d.ts +8 -0
  1414. package/src/shade/renderer/postprocess/taa/shader_depth_occlusion_clip.d.ts.map +1 -1
  1415. package/src/shade/renderer/postprocess/taa/shader_depth_occlusion_clip.js +14 -42
  1416. package/src/shade/renderer/rasterize/RasterizationJob.d.ts +4 -2
  1417. package/src/shade/renderer/rasterize/RasterizationJob.d.ts.map +1 -1
  1418. package/src/shade/renderer/rasterize/RasterizationJob.js +3 -1
  1419. package/src/shade/renderer/rasterize/TemplatePassDescriptor.d.ts +57 -0
  1420. package/src/shade/renderer/rasterize/TemplatePassDescriptor.d.ts.map +1 -0
  1421. package/src/shade/renderer/rasterize/TemplatePassDescriptor.js +133 -0
  1422. package/src/shade/renderer/rasterize/bucket/construct_primitive_state.d.ts.map +1 -1
  1423. package/src/shade/renderer/rasterize/bucket/construct_primitive_state.js +17 -0
  1424. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.d.ts.map +1 -1
  1425. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.js +30 -4
  1426. package/src/shade/renderer/rasterize/bucket/rasterization_has_opaque_bucket.d.ts +21 -0
  1427. package/src/shade/renderer/rasterize/bucket/rasterization_has_opaque_bucket.d.ts.map +1 -0
  1428. package/src/shade/renderer/rasterize/bucket/rasterization_has_opaque_bucket.js +28 -0
  1429. package/src/shade/renderer/rasterize/bucket/shader_count_meshlets_by_material.d.ts.map +1 -1
  1430. package/src/shade/renderer/rasterize/bucket/shader_count_meshlets_by_material.js +74 -68
  1431. package/src/shade/renderer/rasterize/bucket/shader_read_out_bucket.d.ts.map +1 -1
  1432. package/src/shade/renderer/rasterize/bucket/shader_read_out_bucket.js +11 -1
  1433. package/src/shade/renderer/rasterize/bucket/shader_sort_meshlets_by_material.d.ts.map +1 -1
  1434. package/src/shade/renderer/rasterize/bucket/shader_sort_meshlets_by_material.js +70 -64
  1435. package/src/shade/renderer/rasterize/cull/hzb/shader_hzb_meshlet_filter_1way.d.ts.map +1 -1
  1436. package/src/shade/renderer/rasterize/cull/hzb/shader_hzb_meshlet_filter_1way.js +3 -4
  1437. package/src/shade/renderer/rasterize/cull/hzb/shader_hzb_meshlet_filter_1way_full.d.ts.map +1 -1
  1438. package/src/shade/renderer/rasterize/cull/hzb/shader_hzb_meshlet_filter_1way_full.js +8 -2
  1439. package/src/shade/renderer/rasterize/expand/bucket/meshlet/shader_meshlets_count_by_rasterization_bucket.d.ts.map +1 -1
  1440. package/src/shade/renderer/rasterize/expand/bucket/meshlet/shader_meshlets_count_by_rasterization_bucket.js +3 -4
  1441. package/src/shade/renderer/rasterize/expand/bucket/meshlet/shader_meshlets_extract_bucket.d.ts.map +1 -1
  1442. package/src/shade/renderer/rasterize/expand/bucket/meshlet/shader_meshlets_extract_bucket.js +7 -5
  1443. package/src/shade/renderer/rasterize/expand/bucket/meshlet/shader_meshlets_rasterization_bucket_sort.d.ts.map +1 -1
  1444. package/src/shade/renderer/rasterize/expand/bucket/meshlet/shader_meshlets_rasterization_bucket_sort.js +3 -4
  1445. package/src/shade/renderer/rasterize/expand/mesh/shader_mesh_expand_to_meshlets_prefix.d.ts.map +1 -1
  1446. package/src/shade/renderer/rasterize/expand/mesh/shader_mesh_expand_to_meshlets_prefix.js +3 -4
  1447. package/src/shade/renderer/rasterize/expand/mesh/shader_prefix_sum_to_command.d.ts.map +1 -1
  1448. package/src/shade/renderer/rasterize/expand/mesh/shader_prefix_sum_to_command.js +5 -2
  1449. package/src/shade/renderer/rasterize/expand/pass1/filter_meshlets.2-way.compute.d.ts.map +1 -1
  1450. package/src/shade/renderer/rasterize/expand/pass1/filter_meshlets.2-way.compute.js +3 -4
  1451. package/src/shade/renderer/rasterize/fast/graph_rasterize_scene_fast.d.ts.map +1 -1
  1452. package/src/shade/renderer/rasterize/fast/graph_rasterize_scene_fast.js +19 -2
  1453. package/src/shade/renderer/rasterize/forward/SHADING_SCENE_RESOURCE_GROUP.d.ts +20 -0
  1454. package/src/shade/renderer/rasterize/forward/SHADING_SCENE_RESOURCE_GROUP.d.ts.map +1 -1
  1455. package/src/shade/renderer/rasterize/forward/SHADING_SCENE_RESOURCE_GROUP.js +25 -0
  1456. package/src/shade/renderer/rasterize/forward/chunk_forward_shade_standard_fragment_brick4.d.ts.map +1 -1
  1457. package/src/shade/renderer/rasterize/forward/chunk_forward_shade_standard_fragment_brick4.js +2 -1
  1458. package/src/shade/renderer/rasterize/forward/chunk_forward_shade_standard_fragment_ibl.d.ts.map +1 -1
  1459. package/src/shade/renderer/rasterize/forward/chunk_forward_shade_standard_fragment_ibl.js +2 -1
  1460. package/src/shade/renderer/rasterize/forward/forward_template_pipeline.d.ts +40 -0
  1461. package/src/shade/renderer/rasterize/forward/forward_template_pipeline.d.ts.map +1 -0
  1462. package/src/shade/renderer/rasterize/forward/forward_template_pipeline.js +86 -0
  1463. package/src/shade/renderer/rasterize/forward/vertex_shader_chunk.d.ts +11 -0
  1464. package/src/shade/renderer/rasterize/forward/vertex_shader_chunk.d.ts.map +1 -1
  1465. package/src/shade/renderer/rasterize/forward/vertex_shader_chunk.js +13 -2
  1466. package/src/shade/renderer/rasterize/native/alpha_tested_pass_resources.d.ts +59 -1
  1467. package/src/shade/renderer/rasterize/native/alpha_tested_pass_resources.d.ts.map +1 -1
  1468. package/src/shade/renderer/rasterize/native/alpha_tested_pass_resources.js +109 -7
  1469. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.d.ts +16 -1
  1470. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.d.ts.map +1 -1
  1471. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.js +13 -1
  1472. package/src/shade/renderer/rasterize/native/avboit/AVBOIT_LEDGER.md +247 -0
  1473. package/src/shade/renderer/rasterize/native/avboit/AVBOIT_PLAN_2026_09_03.md +20 -2
  1474. package/src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.js +1 -1
  1475. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_coverage.d.ts +17 -0
  1476. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_coverage.d.ts.map +1 -0
  1477. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_coverage.js +25 -0
  1478. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_fold_pairs.d.ts +4 -5
  1479. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_fold_pairs.d.ts.map +1 -1
  1480. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_fold_pairs.js +7 -6
  1481. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_occupancy_mark.d.ts +17 -0
  1482. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_occupancy_mark.d.ts.map +1 -0
  1483. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_occupancy_mark.js +51 -0
  1484. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_premultiplied_contribution.d.ts +23 -0
  1485. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_premultiplied_contribution.d.ts.map +1 -0
  1486. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_premultiplied_contribution.js +77 -0
  1487. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.d.ts.map +1 -1
  1488. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.js +16 -20
  1489. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_draw_brick4.d.ts +8 -2
  1490. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_draw_brick4.d.ts.map +1 -1
  1491. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_draw_brick4.js +57 -43
  1492. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_draw_ibl.d.ts +8 -2
  1493. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_draw_ibl.d.ts.map +1 -1
  1494. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_draw_ibl.js +57 -43
  1495. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_occupancy.d.ts.map +1 -1
  1496. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_occupancy.js +8 -2
  1497. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.d.ts +7 -2
  1498. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.d.ts.map +1 -1
  1499. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.js +67 -58
  1500. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.d.ts +8 -2
  1501. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.d.ts.map +1 -1
  1502. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.js +186 -156
  1503. package/src/shade/renderer/rasterize/native/graph_rasterize_meshes_alpha_tested.d.ts +2 -2
  1504. package/src/shade/renderer/rasterize/native/graph_rasterize_meshes_alpha_tested.d.ts.map +1 -1
  1505. package/src/shade/renderer/rasterize/native/graph_rasterize_meshes_alpha_tested.js +36 -28
  1506. package/src/shade/renderer/rasterize/native/material_draw_indirect.d.ts +14 -12
  1507. package/src/shade/renderer/rasterize/native/material_draw_indirect.d.ts.map +1 -1
  1508. package/src/shade/renderer/rasterize/native/material_draw_indirect.js +29 -23
  1509. package/src/shade/renderer/rasterize/native/oit/graph_rasterize_meshes_transparent_oit.d.ts.map +1 -1
  1510. package/src/shade/renderer/rasterize/native/oit/graph_rasterize_meshes_transparent_oit.js +16 -22
  1511. package/src/shade/renderer/rasterize/native/oit/oit_resolve_fragment_body.d.ts +33 -0
  1512. package/src/shade/renderer/rasterize/native/oit/oit_resolve_fragment_body.d.ts.map +1 -0
  1513. package/src/shade/renderer/rasterize/native/oit/oit_resolve_fragment_body.js +123 -0
  1514. package/src/shade/renderer/rasterize/native/oit/shader_oit_generate_moments.d.ts +7 -2
  1515. package/src/shade/renderer/rasterize/native/oit/shader_oit_generate_moments.d.ts.map +1 -1
  1516. package/src/shade/renderer/rasterize/native/oit/shader_oit_generate_moments.js +227 -218
  1517. package/src/shade/renderer/rasterize/native/oit/shader_oit_resolve_moments.d.ts +8 -2
  1518. package/src/shade/renderer/rasterize/native/oit/shader_oit_resolve_moments.d.ts.map +1 -1
  1519. package/src/shade/renderer/rasterize/native/oit/shader_oit_resolve_moments.js +112 -180
  1520. package/src/shade/renderer/rasterize/native/oit/shader_oit_resolve_moments_ibl.d.ts +8 -2
  1521. package/src/shade/renderer/rasterize/native/oit/shader_oit_resolve_moments_ibl.d.ts.map +1 -1
  1522. package/src/shade/renderer/rasterize/native/oit/shader_oit_resolve_moments_ibl.js +110 -178
  1523. package/src/shade/renderer/rasterize/native/viz/viz_rasterization_alpha_tested_pass_descriptor.d.ts +7 -2
  1524. package/src/shade/renderer/rasterize/native/viz/viz_rasterization_alpha_tested_pass_descriptor.d.ts.map +1 -1
  1525. package/src/shade/renderer/rasterize/native/viz/viz_rasterization_alpha_tested_pass_descriptor.js +242 -204
  1526. package/src/shade/renderer/rasterize/standard/graph_rasterize_scene.d.ts.map +1 -1
  1527. package/src/shade/renderer/rasterize/standard/graph_rasterize_scene.js +19 -2
  1528. package/src/shade/renderer/restir/reservoir/shader.d.ts.map +1 -1
  1529. package/src/shade/renderer/restir/reservoir/shader.js +27 -1
  1530. package/src/shade/renderer/scene/GPUSceneContext.d.ts +2 -1
  1531. package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
  1532. package/src/shade/renderer/scene/GPUSceneContext.js +11 -9
  1533. package/src/shade/renderer/scene/SCENE_DATABASE_SPEC.js +22 -0
  1534. package/src/shade/renderer/scene/SceneManager.d.ts +10 -0
  1535. package/src/shade/renderer/scene/SceneManager.d.ts.map +1 -1
  1536. package/src/shade/renderer/scene/SceneManager.js +17 -0
  1537. package/src/shade/renderer/scene/rows/GPUEntityBoundsReadback.d.ts.map +1 -1
  1538. package/src/shade/renderer/scene/rows/GPUEntityBoundsReadback.js +164 -144
  1539. package/src/shade/renderer/scene/rows/GPUSceneRows.d.ts +10 -0
  1540. package/src/shade/renderer/scene/rows/GPUSceneRows.d.ts.map +1 -1
  1541. package/src/shade/renderer/scene/rows/GPUSceneRows.js +14 -0
  1542. package/src/shade/renderer/scene/serialization/serialize_scene.d.ts.map +1 -1
  1543. package/src/shade/renderer/scene/serialization/serialize_scene.js +2 -6
  1544. package/src/shade/renderer/shader/ComputeShader.d.ts +5 -0
  1545. package/src/shade/renderer/shader/ComputeShader.d.ts.map +1 -1
  1546. package/src/shade/renderer/shader/ComputeShader.js +358 -353
  1547. package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_scattering.d.ts.map +1 -1
  1548. package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_scattering.js +15 -1
  1549. package/src/shade/renderer/shader/chunk/binary/chunk_encode_f16.d.ts +11 -2
  1550. package/src/shade/renderer/shader/chunk/binary/chunk_encode_f16.d.ts.map +1 -1
  1551. package/src/shade/renderer/shader/chunk/binary/chunk_encode_f16.js +33 -13
  1552. package/src/shade/renderer/shader/chunk/brdf/chunk_D_GGX.d.ts.map +1 -1
  1553. package/src/shade/renderer/shader/chunk/brdf/chunk_D_GGX.js +31 -3
  1554. package/src/shade/renderer/shader/chunk/bvh/morton/chunk_decode32_morton2.d.ts +10 -1
  1555. package/src/shade/renderer/shader/chunk/bvh/morton/chunk_decode32_morton2.d.ts.map +1 -1
  1556. package/src/shade/renderer/shader/chunk/bvh/morton/chunk_decode32_morton2.js +23 -8
  1557. package/src/shade/renderer/shader/chunk/camera/chunk_pixel_radius_to_world.d.ts +8 -1
  1558. package/src/shade/renderer/shader/chunk/camera/chunk_pixel_radius_to_world.d.ts.map +1 -1
  1559. package/src/shade/renderer/shader/chunk/camera/chunk_pixel_radius_to_world.js +12 -5
  1560. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_distance_to_ray.d.ts +15 -1
  1561. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_distance_to_ray.d.ts.map +1 -1
  1562. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_distance_to_ray.js +24 -28
  1563. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_distance_to_ray_v2.d.ts +5 -0
  1564. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_distance_to_ray_v2.d.ts.map +1 -1
  1565. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_distance_to_ray_v2.js +18 -13
  1566. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_intersects_ray.d.ts.map +1 -1
  1567. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_intersects_ray.js +1 -47
  1568. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_raycast.d.ts +10 -0
  1569. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_raycast.d.ts.map +1 -1
  1570. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_raycast.js +23 -8
  1571. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_raycast_positive.d.ts +7 -0
  1572. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_raycast_positive.d.ts.map +1 -1
  1573. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_raycast_positive.js +12 -25
  1574. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_slab_span.d.ts +32 -0
  1575. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_slab_span.d.ts.map +1 -0
  1576. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_slab_span.js +52 -0
  1577. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_view_depth_range.d.ts +20 -0
  1578. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_view_depth_range.d.ts.map +1 -0
  1579. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_view_depth_range.js +42 -0
  1580. package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_octahedral_uv_wrap.d.ts +10 -1
  1581. package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_octahedral_uv_wrap.d.ts.map +1 -1
  1582. package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_octahedral_uv_wrap.js +18 -3
  1583. package/src/shade/renderer/shader/chunk/geometry/quaternion/chunk_quat_encode_u32.d.ts.map +1 -1
  1584. package/src/shade/renderer/shader/chunk/geometry/quaternion/chunk_quat_encode_u32.js +8 -4
  1585. package/src/shade/renderer/shader/chunk/grid/chunk_folded_workgroup_index.d.ts +24 -0
  1586. package/src/shade/renderer/shader/chunk/grid/chunk_folded_workgroup_index.d.ts.map +1 -0
  1587. package/src/shade/renderer/shader/chunk/grid/chunk_folded_workgroup_index.js +36 -0
  1588. package/src/shade/renderer/shader/chunk/grid/chunk_grid3d_to_index.d.ts +6 -0
  1589. package/src/shade/renderer/shader/chunk/grid/chunk_grid3d_to_index.d.ts.map +1 -1
  1590. package/src/shade/renderer/shader/chunk/grid/chunk_grid3d_to_index.js +6 -0
  1591. package/src/shade/renderer/shader/chunk/light/INCIDENT_LIGHT_STRUCT.d.ts.map +1 -1
  1592. package/src/shade/renderer/shader/chunk/light/INCIDENT_LIGHT_STRUCT.js +6 -1
  1593. package/src/shade/renderer/shader/chunk/light/io/chunk_get_spot_light_info.d.ts.map +1 -1
  1594. package/src/shade/renderer/shader/chunk/light/io/chunk_get_spot_light_info.js +6 -1
  1595. package/src/shade/renderer/shader/chunk/material/chunk_albedo_unpremultiply.d.ts +24 -0
  1596. package/src/shade/renderer/shader/chunk/material/chunk_albedo_unpremultiply.d.ts.map +1 -0
  1597. package/src/shade/renderer/shader/chunk/material/chunk_albedo_unpremultiply.js +31 -0
  1598. package/src/shade/renderer/shader/chunk/random/pcg/chunk_pcg2d.js +2 -2
  1599. package/src/shade/renderer/shader/chunk/random/pcg/chunk_pcg3d16.js +1 -1
  1600. package/src/shade/renderer/shader/chunk/random/pcg/chunk_pcg4d.js +1 -1
  1601. package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_validate_hit.d.ts.map +1 -1
  1602. package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_validate_hit.js +8 -4
  1603. package/src/shade/renderer/shader/chunk/sdf/chunk_mesh_sdf_soft_shadow.d.ts.map +1 -1
  1604. package/src/shade/renderer/shader/chunk/sdf/chunk_mesh_sdf_soft_shadow.js +17 -3
  1605. package/src/shade/renderer/shader/graph/compute/graph_compute_indirect_pass.d.ts +4 -0
  1606. package/src/shade/renderer/shader/graph/compute/graph_compute_indirect_pass.d.ts.map +1 -1
  1607. package/src/shade/renderer/shader/graph/compute/graph_compute_indirect_pass.js +4 -0
  1608. package/src/shade/renderer/shader/pass/RenderPassDescriptor.d.ts +8 -0
  1609. package/src/shade/renderer/shader/pass/RenderPassDescriptor.d.ts.map +1 -1
  1610. package/src/shade/renderer/shader/pass/RenderPassDescriptor.js +203 -192
  1611. package/src/shade/renderer/shader/resource/ShaderResourceGroupDescriptor.d.ts.map +1 -1
  1612. package/src/shade/renderer/shader/resource/ShaderResourceGroupDescriptor.js +12 -0
  1613. package/src/shade/renderer/shader/type/WebGPUArray.d.ts.map +1 -1
  1614. package/src/shade/renderer/shader/type/WebGPUArray.js +25 -1
  1615. package/src/shade/renderer/shader/type/WebGPUStruct.d.ts.map +1 -1
  1616. package/src/shade/renderer/shader/type/WebGPUStruct.js +12 -0
  1617. package/src/shade/renderer/shader/type/queue_typed_buffer_update.d.ts.map +1 -1
  1618. package/src/shade/renderer/shader/type/queue_typed_buffer_update.js +15 -0
  1619. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.d.ts.map +1 -1
  1620. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.js +10 -9
  1621. package/src/shade/renderer/shadow/map/ShadowmapDrawSelector.d.ts +12 -2
  1622. package/src/shade/renderer/shadow/map/ShadowmapDrawSelector.d.ts.map +1 -1
  1623. package/src/shade/renderer/shadow/map/ShadowmapDrawSelector.js +210 -196
  1624. package/src/shade/renderer/shadow/map/csm/shader/shader_csm_caster_range.d.ts +10 -3
  1625. package/src/shade/renderer/shadow/map/csm/shader/shader_csm_caster_range.d.ts.map +1 -1
  1626. package/src/shade/renderer/shadow/map/csm/shader/shader_csm_caster_range.js +219 -194
  1627. package/src/shade/renderer/shadow/map/shadowmap_budget_carry_over.d.ts +32 -0
  1628. package/src/shade/renderer/shadow/map/shadowmap_budget_carry_over.d.ts.map +1 -0
  1629. package/src/shade/renderer/shadow/map/shadowmap_budget_carry_over.js +47 -0
  1630. package/src/shade/renderer/shadow/vsm/VirtualShadowMap.d.ts.map +1 -1
  1631. package/src/shade/renderer/shadow/vsm/VirtualShadowMap.js +11 -1
  1632. package/src/shade/renderer/texture/ShadeTexture.d.ts +16 -0
  1633. package/src/shade/renderer/texture/ShadeTexture.d.ts.map +1 -1
  1634. package/src/shade/renderer/texture/ShadeTexture.js +17 -0
  1635. package/src/shade/renderer/texture/TextureManager.d.ts +22 -5
  1636. package/src/shade/renderer/texture/TextureManager.d.ts.map +1 -1
  1637. package/src/shade/renderer/texture/TextureManager.js +109 -6
  1638. package/src/shade/renderer/texture/bindless/GPUBindlessTextureManager.d.ts.map +1 -1
  1639. package/src/shade/renderer/texture/bindless/GPUBindlessTextureManager.js +8 -2
  1640. package/src/shade/renderer/texture/download_texture_data.d.ts.map +1 -1
  1641. package/src/shade/renderer/texture/download_texture_data.js +12 -4
  1642. package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.d.ts.map +1 -1
  1643. package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.js +66 -63
  1644. package/src/shade/renderer/texture/encode/shader_texture_encode_bc1.d.ts.map +1 -1
  1645. package/src/shade/renderer/texture/encode/shader_texture_encode_bc1.js +63 -60
  1646. package/src/shade/renderer/texture/encode/shader_texture_encode_bc4.d.ts.map +1 -1
  1647. package/src/shade/renderer/texture/encode/shader_texture_encode_bc4.js +79 -76
  1648. package/src/shade/renderer/texture/encode/shader_texture_encode_bc4_snorm.d.ts.map +1 -1
  1649. package/src/shade/renderer/texture/encode/shader_texture_encode_bc4_snorm.js +67 -64
  1650. package/src/shade/renderer/texture/encode/shader_texture_encode_bc5.d.ts.map +1 -1
  1651. package/src/shade/renderer/texture/encode/shader_texture_encode_bc5.js +70 -67
  1652. package/src/shade/renderer/texture/encode/shader_texture_encode_bc5_snorm.d.ts.map +1 -1
  1653. package/src/shade/renderer/texture/encode/shader_texture_encode_bc5_snorm.js +66 -63
  1654. package/src/shade/renderer/texture/encode/shader_texture_encode_bc6h.d.ts.map +1 -1
  1655. package/src/shade/renderer/texture/encode/shader_texture_encode_bc6h.js +65 -62
  1656. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7.d.ts.map +1 -1
  1657. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7.js +61 -58
  1658. package/src/shade/renderer/texture/format/texture_format_from_shade_image.d.ts +7 -1
  1659. package/src/shade/renderer/texture/format/texture_format_from_shade_image.d.ts.map +1 -1
  1660. package/src/shade/renderer/texture/format/texture_format_from_shade_image.js +100 -95
  1661. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.d.ts +8 -2
  1662. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.d.ts.map +1 -1
  1663. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.js +99 -73
  1664. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_wronski2021.d.ts +30 -1
  1665. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_wronski2021.d.ts.map +1 -1
  1666. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_wronski2021.js +37 -20
  1667. package/src/shade/renderer/texture/texture_descriptor_from_texture_shade.js +73 -73
  1668. package/src/shade/renderer/view/ViewManager.d.ts +8 -0
  1669. package/src/shade/renderer/view/ViewManager.d.ts.map +1 -1
  1670. package/src/shade/renderer/view/ViewManager.js +15 -0
  1671. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts.map +1 -1
  1672. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.js +516 -507
  1673. package/src/shade/renderer/volumetrics/shader_volumetrics_build_scattering_lut.d.ts.map +1 -1
  1674. package/src/shade/renderer/volumetrics/shader_volumetrics_build_scattering_lut.js +272 -260
  1675. package/src/shade/renderer/volumetrics/taa/shader_volumetrics_taa.d.ts.map +1 -1
  1676. package/src/shade/renderer/volumetrics/taa/shader_volumetrics_taa.js +160 -134
  1677. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.d.ts +3 -0
  1678. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.d.ts.map +1 -1
  1679. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +2564 -2356
  1680. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  1681. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +110 -7
  1682. package/src/shade/wgsl/validate_wgsl_source.d.ts.map +1 -1
  1683. package/src/shade/wgsl/validate_wgsl_source.js +57 -0
  1684. package/src/view/asset/AssetLoaderStatusView.d.ts.map +1 -1
  1685. package/src/view/asset/AssetLoaderStatusView.js +8 -0
  1686. package/src/view/common/LabelView.d.ts.map +1 -1
  1687. package/src/view/common/LabelView.js +4 -0
  1688. package/src/view/common/ListView.d.ts +6 -2
  1689. package/src/view/common/ListView.d.ts.map +1 -1
  1690. package/src/view/common/ListView.js +27 -7
  1691. package/src/view/common/TabbedView.d.ts.map +1 -1
  1692. package/src/view/common/TabbedView.js +8 -0
  1693. package/src/view/common/VirtualListView.d.ts.map +1 -1
  1694. package/src/view/common/VirtualListView.js +17 -1
  1695. package/src/view/common/dnd/DropTarget.d.ts.map +1 -1
  1696. package/src/view/common/dnd/DropTarget.js +18 -0
  1697. package/src/view/elements/DropDownSelectionView.d.ts.map +1 -1
  1698. package/src/view/elements/DropDownSelectionView.js +8 -0
  1699. package/src/view/elements/image/SvgImageView.d.ts.map +1 -1
  1700. package/src/view/elements/image/SvgImageView.js +8 -0
  1701. package/src/view/elements/navigation/ViewStack.d.ts.map +1 -1
  1702. package/src/view/elements/navigation/ViewStack.js +4 -0
  1703. package/src/view/elements/notify/NotificationView.d.ts.map +1 -1
  1704. package/src/view/elements/notify/NotificationView.js +4 -0
  1705. package/src/view/elements/progress/segmented/SegmentedResourceBarView.d.ts.map +1 -1
  1706. package/src/view/elements/progress/segmented/SegmentedResourceBarView.js +8 -0
  1707. package/src/view/elements/radial/RadialMenu.d.ts.map +1 -1
  1708. package/src/view/elements/radial/RadialMenu.js +4 -0
  1709. package/src/view/minimap/Minimap.d.ts.map +1 -1
  1710. package/src/view/minimap/Minimap.js +8 -0
  1711. package/src/view/minimap/MinimapCanvasView.d.ts.map +1 -1
  1712. package/src/view/minimap/MinimapCanvasView.js +21 -1
  1713. package/src/view/minimap/dom/MinimapCameraView.d.ts.map +1 -1
  1714. package/src/view/minimap/dom/MinimapCameraView.js +232 -220
  1715. package/src/view/minimap/dom/MinimapMarkerView.d.ts.map +1 -1
  1716. package/src/view/minimap/dom/MinimapMarkerView.js +8 -0
  1717. package/src/view/minimap/minimap_focus_area.d.ts +5 -0
  1718. package/src/view/minimap/minimap_focus_area.d.ts.map +1 -1
  1719. package/src/view/minimap/minimap_focus_area.js +22 -0
  1720. package/src/view/tooltip/DomTooltipManager.d.ts +7 -0
  1721. package/src/view/tooltip/DomTooltipManager.d.ts.map +1 -1
  1722. package/src/view/tooltip/DomTooltipManager.js +22 -0
  1723. package/src/view/tooltip/DomTooltipObserver.d.ts.map +1 -1
  1724. package/src/view/tooltip/DomTooltipObserver.js +13 -3
  1725. package/src/view/tooltip/TooltipManager.d.ts.map +1 -1
  1726. package/src/view/tooltip/TooltipManager.js +16 -4
  1727. package/src/core/geom/3d/atlas/atlas_bench_lib.js +0 -315
  1728. package/src/engine/graphics/ecs/mesh/MeshEvents.d.ts +0 -6
  1729. package/src/engine/graphics/ecs/mesh/MeshEvents.d.ts.map +0 -1
  1730. package/src/engine/graphics/ecs/mesh/MeshEvents.js +0 -16
  1731. package/src/engine/graphics/ecs/mesh/commonObject3DFastMatrixUpdate.d.ts +0 -2
  1732. package/src/engine/graphics/ecs/mesh/commonObject3DFastMatrixUpdate.d.ts.map +0 -1
  1733. package/src/engine/graphics/ecs/mesh/commonObject3DFastMatrixUpdate.js +0 -37
  1734. package/src/engine/graphics/ecs/mesh/copyToVector3.d.ts +0 -8
  1735. package/src/engine/graphics/ecs/mesh/copyToVector3.d.ts.map +0 -1
  1736. package/src/engine/graphics/ecs/mesh/copyToVector3.js +0 -18
  1737. package/src/engine/graphics/ecs/mesh/object3DFastMatrixUpdate.d.ts +0 -6
  1738. package/src/engine/graphics/ecs/mesh/object3DFastMatrixUpdate.d.ts.map +0 -1
  1739. package/src/engine/graphics/ecs/mesh/object3DFastMatrixUpdate.js +0 -18
  1740. package/src/engine/graphics/ecs/mesh/rootObject3DFastMatrixUpdate.d.ts +0 -6
  1741. package/src/engine/graphics/ecs/mesh/rootObject3DFastMatrixUpdate.d.ts.map +0 -1
  1742. package/src/engine/graphics/ecs/mesh/rootObject3DFastMatrixUpdate.js +0 -14
  1743. package/src/engine/graphics/ecs/mesh/setMesh.d.ts +0 -16
  1744. package/src/engine/graphics/ecs/mesh/setMesh.d.ts.map +0 -1
  1745. package/src/engine/graphics/ecs/mesh/setMesh.js +0 -55
  1746. package/src/engine/graphics/ecs/mesh/skeleton/BoneMapping.d.ts +0 -13
  1747. package/src/engine/graphics/ecs/mesh/skeleton/BoneMapping.d.ts.map +0 -1
  1748. package/src/engine/graphics/ecs/mesh/skeleton/BoneMapping.js +0 -99
  1749. package/src/engine/graphics/ecs/mesh/skeleton/HumanoidBoneType.d.ts +0 -25
  1750. package/src/engine/graphics/ecs/mesh/skeleton/HumanoidBoneType.d.ts.map +0 -1
  1751. package/src/engine/graphics/ecs/mesh/skeleton/HumanoidBoneType.js +0 -29
  1752. package/src/engine/graphics/ecs/mesh/updateMeshTransform.d.ts +0 -6
  1753. package/src/engine/graphics/ecs/mesh/updateMeshTransform.d.ts.map +0 -1
  1754. package/src/engine/graphics/ecs/mesh/updateMeshTransform.js +0 -15
  1755. package/src/engine/graphics/ecs/mesh/updateNodeByTransformAndBBB.d.ts +0 -8
  1756. package/src/engine/graphics/ecs/mesh/updateNodeByTransformAndBBB.d.ts.map +0 -1
  1757. package/src/engine/graphics/ecs/mesh/updateNodeByTransformAndBBB.js +0 -14
  1758. package/src/engine/graphics3/terrain/GPUTerrainSplatRenderer.js +0 -481
  1759. package/src/engine/graphics3/terrain/pack_terrain_row_table.js +0 -48
  1760. package/src/engine/graphics3/terrain/shader_terrain_splat.js +0 -215
  1761. package/src/shade/renderer/animation/ANIMATION_BOUND_TRACK_GROUP_STRUCT.js +0 -57
  1762. package/src/shade/renderer/animation/ANIMATION_KEYFRAME_BLOCK_STRUCT.js +0 -50
  1763. package/src/shade/renderer/animation/ANIMATION_SKIN_JOINT_BLOCK_STRUCT.js +0 -62
  1764. package/src/shade/renderer/geometry/virtual/build/mesh/VGEO_CREASE_ANGLE.d.ts +0 -46
  1765. package/src/shade/renderer/geometry/virtual/build/mesh/VGEO_CREASE_ANGLE.d.ts.map +0 -1
  1766. package/src/shade/renderer/geometry/virtual/build/mesh/VGEO_CREASE_ANGLE.js +0 -45
@@ -1,1323 +1,1332 @@
1
- import { assert } from "../../../../core/assert.js";
2
- import { round_up } from "../../../../core/math/round_up.js";
3
- import { GPU_DATABASE_BUFFER_ELEMENT_TYPE } from "./GPU_DATABASE_BUFFER_ELEMENT_TYPE.js";
4
- import { GPU_TABLE_GATHER_DESCRIPTOR_WORDS } from "./GPU_TABLE_GATHER_DESCRIPTOR_WORDS.js";
5
- import { gpu_table_gather_shader } from "./gpu_table_gather_shader.js";
6
- import { GPUReadbackStatus } from "./GPUReadbackStatus.js";
7
-
8
- /**
9
- * Bytes per {@link GPU_DATABASE_BUFFER_ELEMENT_TYPE}.
10
- * @type {number}
11
- */
12
- const WORD_SIZE = GPU_DATABASE_BUFFER_ELEMENT_TYPE.size;
13
-
14
- /**
15
- * Largest transient descriptor buffer one dispatch will be given, matching the upload path's.
16
- * @type {number}
17
- */
18
- const DESCRIPTOR_CHUNK_BYTES = 256 * 1024;
19
-
20
- /**
21
- * Granularity the gather scratch buffer grows by.
22
- * @type {number}
23
- */
24
- const GATHER_SIZE_GRANULARITY = 1024;
25
-
26
- /**
27
- * Requests at or above which a batch is gathered by a dispatch rather than copied range by range.
28
- *
29
- * **Measured, not chosen**, on a real device: Chrome 141 / Dawn, NVIDIA Lovelace, reading a 64-byte
30
- * range out of each of N 176-byte rows spread across 4 KiB pages. Best of five blocks of a hundred
31
- * batches, by `src/shade/playground/readback_crossover/`.
32
- *
33
- * | rows | encode copies | encode gather | round trip copies | round trip gather |
34
- * |-----:|--------------:|--------------:|------------------:|------------------:|
35
- * | 1 | 5.0 µs | 17.0 µs | 63 µs | 79 µs |
36
- * | 8 | 6.0 µs | 25.0 µs | 75 µs | 125 µs |
37
- * | 32 | 10.0 µs | 27.0 µs | 111 µs | 130 µs |
38
- * | 64 | 14.0 µs | 33.0 µs | 135 µs | 129 µs |
39
- * | 256 | 45.0 µs | 53.0 µs | 230 µs | 116 µs |
40
- * | 512 | 87.0 µs | 77.0 µs | 307 µs | 115 µs |
41
- *
42
- * Fitted: encoding costs `4.5 µs + 0.161 per row` for copies against `21.9 µs + 0.112` for the
43
- * gather, which crosses at **352 rows** — on CPU encode cost alone the gather is almost never worth
44
- * it, because appending a descriptor is not much cheaper than appending a copy command.
45
- *
46
- * The round trip is where the difference actually lives: `81 µs + 0.480 per row` for copies against
47
- * `104 µs + 0.037` for the gather. Submitting and executing N scattered copy commands costs about
48
- * half a microsecond each, and the gather is flat — 512 rows cost it no more than 8 do. Those cross
49
- * at **51 rows**, and the measured curves cross between 32 and 64. This is 48: inside the measured
50
- * interval, and on the side of the path whose cost does not grow.
51
- *
52
- * The fixed term of the round trip is mostly the wait for `onSubmittedWorkDone` and is not a cost a
53
- * frame pays synchronously; the slopes are the part that decides, and they differ by 13×.
54
- *
55
- * Those numbers were taken against the first, callback-and-objects version of this service. The
56
- * same page, re-run on the same adapter after the request became a few integer stores (two idle
57
- * runs, headless Chrome): encode `5.7–5.9 + 0.14 per row` for copies against `23.5–23.8 + 0.10` for
58
- * the gather; round trip `67–73 + 0.31` against `83–86 + 0.003–0.010`, crossing at 34 and 62 rows
59
- * with the curves crossing between 16 and 64. The per-row cost fell on both paths and the slopes
60
- * that decide are further apart than before; 48 is still inside the interval.
61
- *
62
- * @see https://claude.ai/code/artifact/88ee4932-ed98-407e-a25b-d379f3cf852a F5, which asked for this
63
- * number rather than for "batched is better"
64
- * @type {number}
65
- */
66
- const DEFAULT_GATHER_THRESHOLD = 48;
67
-
68
- /**
69
- * Batches allowed in flight before a frame's requests are refused. A mapping normally lands one or
70
- * two frames after its copy, so this is only reached when the device has stopped answering, and
71
- * the right thing to do with a frame's requests then is to say so and drop them: a consumer asks
72
- * every frame anyway, and a value delivered a dozen frames late is not the value it wanted.
73
- *
74
- * @type {number}
75
- */
76
- const DEFAULT_MAX_IN_FLIGHT = 4;
77
-
78
- /**
79
- * Request records and batch handle lists start at this many entries and double.
80
- * @type {number}
81
- */
82
- const INITIAL_CAPACITY = 64;
83
-
84
- /*
85
- * One request is RECORD_WORDS words of the flat record array, at handle * RECORD_WORDS. The first
86
- * six are written by `request`, the last two by `encode`.
87
- */
88
- const R_TABLE = 0;
89
- const R_ROW = 1;
90
- const R_WORD_OFFSET = 2;
91
- const R_WORD_COUNT = 3;
92
- const R_GENERATION = 4;
93
- const R_TARGET_OFFSET = 5;
94
- const R_SOURCE_WORD = 6;
95
- const R_DESTINATION_WORD = 7;
96
- const RECORD_WORDS = 8;
97
-
98
- /**
99
- * @enum {number}
100
- */
101
- const BatchState = {
102
- /** taking requests; the one batch in this state is the frame's */
103
- Assembling: 0,
104
- /** copy recorded, the frame that recorded it not yet known to be submitted */
105
- Encoded: 1,
106
- /** `mapAsync` outstanding */
107
- Mapping: 2,
108
- /** mapped, waiting for an apply point */
109
- Ready: 3,
110
- /** the map was refused; the batch is discarded without delivering */
111
- Failed: 4,
112
- };
113
-
114
- /**
115
- * One frame's worth of requests, travelling together. Pooled: a batch that has been delivered keeps
116
- * its arrays and takes the next frame's requests, so a steady stream of batches allocates nothing.
117
- */
118
- class GPUReadbackBatch {
119
- /**
120
- * Handles in request order.
121
- * @type {Uint32Array}
122
- */
123
- handles = new Uint32Array(INITIAL_CAPACITY);
124
-
125
- /**
126
- * @type {number}
127
- */
128
- count = 0;
129
-
130
- /**
131
- * Requests whose row was resident when the batch was encoded.
132
- * @type {number}
133
- */
134
- live = 0;
135
-
136
- /**
137
- * Bytes of the packed image.
138
- * @type {number}
139
- */
140
- byte_size = 0;
141
-
142
- /**
143
- * The readback buffer the image was copied into. From {@link GPUBufferReadbackAllocator}, and
144
- * given back when the batch is delivered or discarded.
145
- *
146
- * @type {GPUBuffer|null}
147
- */
148
- buffer = null;
149
-
150
- /**
151
- * The mapped image, valid from the mapping settling until the buffer is given back. Read
152
- * directly at the apply point — the buffer stays mapped until then, which is what makes the
153
- * copy into the caller's memory the only copy.
154
- *
155
- * @type {Uint8Array|null}
156
- */
157
- bytes = null;
158
-
159
- /**
160
- * The command context the copy was recorded on. The mapping may not start until it has been
161
- * finished, because a map of a buffer whose copy has not been submitted reads the frame before.
162
- *
163
- * @type {import("../../../device/ShadeGPUCommandContext.js").ShadeGPUCommandContext|null}
164
- */
165
- context = null;
166
-
167
- /**
168
- * @type {BatchState}
169
- */
170
- state = BatchState.Assembling;
171
-
172
- /**
173
- * Live handles grouped by table, for the gather path's one dispatch per table.
174
- * @type {Uint32Array}
175
- */
176
- order = new Uint32Array(0);
177
-
178
- /**
179
- * Reactions to this batch's mapping, bound once per pooled batch rather than once per frame.
180
- * @type {function(): void}
181
- */
182
- on_mapped = null;
183
-
184
- /**
185
- * @type {function(): void}
186
- */
187
- on_failed = null;
188
- }
189
-
190
- /**
191
- * Reading rows back from a {@link GPUDatabase} in batches: one gather, one copy, one map, and one
192
- * point in the frame where the answers land — in memory the caller already owns.
193
- *
194
- * **Why this is not `debug_table_read_element`.** That resolves one row's byte offset and calls
195
- * {@link inspect_gpu_buffer_typed}, which creates a `MAP_READ` buffer, copies, submits, maps and
196
- * destroys it — per call. It is a debug affordance and stays one. Here the buffers persist, the
197
- * requests of a frame travel together, and the result arrives at a stated moment rather than
198
- * whenever a promise happens to settle.
199
- *
200
- * **The caller names memory, and nothing is called.** A request is a table handle, a row, a byte
201
- * range of the record, and a `Uint8Array` plus offset to put it in. At the apply point the service
202
- * copies the bytes there and marks the request's handle in {@link status}; the consumer reads the
203
- * status when its own system next runs, which is when it wanted the value anyway. There is no
204
- * callback and no promise, for the same reason: a function called per row is a closure allocated
205
- * per row and a permanently megamorphic call site, and code running inside the apply point could
206
- * re-enter this service, or destroy the database, from the middle of `GPUDatabase.update`. The
207
- * shader packs a batch contiguously in request order, so a consumer's run of rows lands in its
208
- * destination as one `set` — which a per-row function could never have done.
209
- *
210
- * **Gather, then one copy.** Rows sit at scattered offsets across pages, so a compute shader packs
211
- * the requested ranges contiguously before a single copy into a readback buffer. Packing a *range*
212
- * rather than a record is what makes it worth doing: an entity's world matrix is 64 bytes of a
213
- * 176-byte row.
214
- *
215
- * **But the request list is itself an upload.** A gather needs its descriptors on the GPU, so every
216
- * frame with any request writes a buffer, allocates, binds and dispatches. For one row that costs
217
- * far more than the value retrieved. Below {@link DEFAULT_GATHER_THRESHOLD} — a measured number, see
218
- * its docblock — the batch degrades to direct `copyBufferToBuffer` calls into the same readback
219
- * buffer, with no shader at all. A frame with no requests skips the whole path: no buffer, no
220
- * command.
221
- *
222
- * **One apply point, in encode order.** Results are delivered from {@link apply}, at the head of a
223
- * frame, and never on the timing of the map's own promise. A component that changed value in the
224
- * middle of an update because a readback happened to settle would be a different world for the
225
- * systems that ran before it and the ones that ran after. And a batch is delivered only after every
226
- * older batch has been: `mapAsync` promises are not promised to settle in the order the maps were
227
- * started, and a consumer asking for the same row every frame must never see a fresh value
228
- * overwritten by a stale one.
229
- *
230
- * **Nothing here may reach simulation state.** A readback is a frame or more late and settles on the
231
- * GPU's own schedule, so an outcome that depended on one would depend on frame pacing, and the
232
- * determinism gate with it. This answers tools, sounds and cosmetics. Where the simulation wants a
233
- * GPU-owned pose it evaluates the chain exactly, on the CPU.
234
- *
235
- * @see GPUStateAuthority which says whose value is worth reading back in the first place
236
- * @see GPUReadbackStatus
237
- */
238
- export class GPUDatabaseReadback {
239
- /**
240
- * @type {import("./GPUDatabase.js").GPUDatabase}
241
- */
242
- #database;
243
-
244
- /**
245
- * @type {GPUDevice}
246
- */
247
- #device;
248
-
249
- /**
250
- * Where readback buffers come from: the graphics context's, shared with every other database
251
- * on it, and taken from the first command context this service encodes on — the database is
252
- * built against a device, not a context.
253
- *
254
- * @type {import("../GPUBufferReadbackAllocator.js").GPUBufferReadbackAllocator|null}
255
- */
256
- #allocator = null;
257
-
258
- /**
259
- * Shader-writable scratch the gather packs into, copied to a readback buffer in one go.
260
- * Persistent and grown, never per batch, and unlike the readback buffers it needs no pool,
261
- * because it is written and read inside one submission.
262
- *
263
- * @type {GPUBuffer|null}
264
- */
265
- #gather_buffer = null;
266
-
267
- /**
268
- * Request records, {@link RECORD_WORDS} words per handle. A request is a few integer stores
269
- * into this array; the target it names is the only thing that is not an integer, and it sits
270
- * in {@link #targets} beside it.
271
- *
272
- * @type {Uint32Array}
273
- */
274
- #records = new Uint32Array(INITIAL_CAPACITY * RECORD_WORDS);
275
-
276
- /**
277
- * Per handle, the memory the bytes are to land in.
278
- * @type {(Uint8Array|null)[]}
279
- */
280
- #targets = new Array(INITIAL_CAPACITY).fill(null);
281
-
282
- /**
283
- * Per handle, a {@link GPUReadbackStatus}. Exposed as {@link status}.
284
- * @type {Uint8Array}
285
- */
286
- #status = new Uint8Array(INITIAL_CAPACITY);
287
-
288
- /**
289
- * Recycled handles. Never longer than the record capacity, so it never overflows.
290
- * @type {Uint32Array}
291
- */
292
- #free = new Uint32Array(INITIAL_CAPACITY);
293
-
294
- /**
295
- * @type {number}
296
- */
297
- #free_count = 0;
298
-
299
- /**
300
- * Handles below this have been handed out at least once.
301
- * @type {number}
302
- */
303
- #fresh = 0;
304
-
305
- /**
306
- * The batch taking this frame's requests.
307
- * @type {GPUReadbackBatch}
308
- */
309
- #assembling;
310
-
311
- /**
312
- * Encoded batches, oldest first.
313
- * @type {GPUReadbackBatch[]}
314
- */
315
- #in_flight = [];
316
-
317
- /**
318
- * Batches delivered or dropped since the last apply point. Their handles stay readable until
319
- * the next one, and are recycled there.
320
- *
321
- * @type {GPUReadbackBatch[]}
322
- */
323
- #retiring = [];
324
-
325
- /**
326
- * Batches with nothing in them, waiting to be the next frame's.
327
- * @type {GPUReadbackBatch[]}
328
- */
329
- #spare = [];
330
-
331
- /**
332
- * Scratch for bucketing a batch's live requests by table: counts, then starts.
333
- * @type {Uint32Array}
334
- */
335
- #table_starts;
336
-
337
- /**
338
- * @type {number}
339
- */
340
- #gather_threshold;
341
-
342
- /**
343
- * @type {number}
344
- */
345
- #max_in_flight;
346
-
347
- /**
348
- * Descriptor words for one dispatch, reused. Grown to the largest chunk this service has ever
349
- * needed and kept.
350
- *
351
- * @type {Uint32Array}
352
- */
353
- #descriptor_scratch = new Uint32Array(0);
354
-
355
- /**
356
- * Immediate data for the gather dispatch, reused. `dispatchThreads` serialises it at the call,
357
- * so one object can carry every dispatch of a frame.
358
- *
359
- * @type {Object}
360
- */
361
- #gather_settings = {
362
- count: 0,
363
- record_size: 0,
364
- elements_per_page: 0,
365
- page_lookup_address: 0,
366
- page_header_words: 0,
367
- page_limit: 0,
368
- };
369
-
370
- /**
371
- * @type {boolean}
372
- */
373
- #destroyed = false;
374
-
375
- #copies_encoded = 0;
376
- #dispatches_encoded = 0;
377
- #delivered_count = 0;
378
- #dropped_count = 0;
379
- #stalled_count = 0;
380
-
381
- /**
382
- * @param {Object} options
383
- * @param {import("./GPUDatabase.js").GPUDatabase} options.database
384
- * @param {GPUDevice} options.device
385
- * @param {number} [options.gather_threshold] requests at or above which a dispatch is used
386
- * @param {number} [options.max_in_flight] batches in flight before a frame's requests are dropped
387
- * @param {string} [options.label]
388
- */
389
- constructor({
390
- database,
391
- device,
392
- gather_threshold = DEFAULT_GATHER_THRESHOLD,
393
- max_in_flight = DEFAULT_MAX_IN_FLIGHT,
394
- label = 'GPUDatabaseReadback',
395
- }) {
396
- assert.defined(database, 'database');
397
- assert.defined(device, 'device');
398
- assert.isNonNegativeInteger(gather_threshold, 'gather_threshold');
399
- assert.isPositiveInteger(max_in_flight, 'max_in_flight');
400
- assert.isString(label, 'label');
401
-
402
- this.#database = database;
403
- this.#device = device;
404
- this.#gather_threshold = gather_threshold;
405
- this.#max_in_flight = max_in_flight;
406
-
407
- this.#table_starts = new Uint32Array(database.tables.length + 1);
408
-
409
- this.#assembling = this.#make_batch();
410
- }
411
-
412
- /**
413
- * Requests at or above which a batch is gathered rather than copied range by range.
414
- * @returns {number}
415
- */
416
- get gather_threshold() {
417
- return this.#gather_threshold;
418
- }
419
-
420
- /**
421
- * Batches in flight before a frame's requests are refused.
422
- * @returns {number}
423
- */
424
- get max_in_flight() {
425
- return this.#max_in_flight;
426
- }
427
-
428
- /**
429
- * Per handle, what became of the request — a {@link GPUReadbackStatus}.
430
- *
431
- * Read it fresh each time rather than keeping a reference: the array is replaced when the
432
- * handle space grows. A status is readable for one frame, from the apply point that set it to
433
- * the next.
434
- *
435
- * @returns {Uint8Array}
436
- */
437
- get status() {
438
- return this.#status;
439
- }
440
-
441
- /**
442
- * How many handles exist. Grows to the working set of a steady stream of requests and stops:
443
- * handles are recycled a frame after their result lands.
444
- *
445
- * @returns {number}
446
- */
447
- get handle_capacity() {
448
- return this.#status.length;
449
- }
450
-
451
- /**
452
- * Requests made and not yet encoded.
453
- * @returns {number}
454
- */
455
- get pending_count() {
456
- return this.#assembling.count;
457
- }
458
-
459
- /**
460
- * Batches encoded and not yet delivered or discarded.
461
- * @returns {number}
462
- */
463
- get in_flight_count() {
464
- return this.#in_flight.length;
465
- }
466
-
467
- /**
468
- * How many `copyBufferToBuffer` calls this service has encoded, over its life. Read by profiles,
469
- * and by the specs that assert an empty frame encodes nothing.
470
- *
471
- * @returns {number}
472
- */
473
- get copies_encoded() {
474
- return this.#copies_encoded;
475
- }
476
-
477
- /**
478
- * How many gather dispatches this service has encoded, over its life.
479
- * @returns {number}
480
- */
481
- get dispatches_encoded() {
482
- return this.#dispatches_encoded;
483
- }
484
-
485
- /**
486
- * Requests whose bytes reached their target.
487
- * @returns {number}
488
- */
489
- get delivered_count() {
490
- return this.#delivered_count;
491
- }
492
-
493
- /**
494
- * Requests thrown away because of the row — its page was not resident when the batch was
495
- * encoded, it was not occupied, or it was freed before the answer landed.
496
- *
497
- * Reported rather than swallowed: a consumer whose readbacks are all being dropped is asking
498
- * about rows that keep dying, and silence reads downstream as "the value did not change".
499
- *
500
- * @returns {number}
501
- */
502
- get dropped_count() {
503
- return this.#dropped_count;
504
- }
505
-
506
- /**
507
- * Requests thrown away because of the pipeline — {@link max_in_flight} batches were still
508
- * waiting on the device when the frame's batch was due, or a mapping was refused. Separate
509
- * from {@link dropped_count} because the cure is different: those rows died, these the device
510
- * stopped answering about.
511
- *
512
- * @returns {number}
513
- */
514
- get stalled_count() {
515
- return this.#stalled_count;
516
- }
517
-
518
- /**
519
- * Resolve a table name to the handle {@link request} takes. Once, at setup: a string lookup
520
- * per row per frame is what this exists to avoid.
521
- *
522
- * From here on the table counts how many times each of its rows is freed, which is what lets
523
- * an answer about a row that died and was reused be told from an answer about the row asked
524
- * for.
525
- *
526
- * @param {string} name
527
- * @returns {number}
528
- */
529
- table(name) {
530
- assert.isString(name, 'name');
531
-
532
- const table = this.#database.get(name);
533
-
534
- if (table === undefined) {
535
- throw new Error(`Table '${name}' does not exist`);
536
- }
537
-
538
- table.track_generations();
539
-
540
- return table.descriptor.index;
541
- }
542
-
543
- /**
544
- * Ask for a byte range of a row to be copied into `target`, at a later apply point.
545
- *
546
- * Positional, and a few integer stores: this is called once per row per frame by anything that
547
- * tracks rows, so it takes no options object and allocates nothing.
548
- *
549
- * @param {number} table from {@link table}
550
- * @param {number} row
551
- * @param {number} byte_offset within the record, word-aligned
552
- * @param {number} byte_size a positive multiple of the word size
553
- * @param {Uint8Array} target memory the caller owns and keeps; the bytes are written here at
554
- * the apply point. A byte view on purpose — a consumer that reads floats holds a
555
- * `Float32Array` over the same buffer, made once
556
- * @param {number} [target_byte_offset]
557
- * @returns {number} a handle into {@link status}, valid until the frame after its result lands
558
- */
559
- request(table, row, byte_offset, byte_size, target, target_byte_offset = 0) {
560
- assert.isNonNegativeInteger(table, 'table');
561
- assert.isNonNegativeInteger(row, 'row');
562
- assert.isNonNegativeInteger(byte_offset, 'byte_offset');
563
- assert.isPositiveInteger(byte_size, 'byte_size');
564
- assert.isNonNegativeInteger(target_byte_offset, 'target_byte_offset');
565
-
566
- const tables = this.#database.tables;
567
-
568
- assert.lessThan(table, tables.length, 'table is not a handle from table()');
569
- assert.equal(byte_offset % WORD_SIZE, 0, 'byte_offset must be word-aligned');
570
- assert.equal(byte_size % WORD_SIZE, 0, 'byte_size must be a whole number of words');
571
- assert.ok(target instanceof Uint8Array, 'target must be a Uint8Array');
572
-
573
- // constant messages: these run per row per frame, and a template literal built to describe a
574
- // failure that does not happen is the cost on the path being measured
575
- assert.lessThanOrEqual(byte_offset + byte_size, tables[table].descriptor.packed_element_size_bytes, 'range reaches past the record');
576
- assert.lessThanOrEqual(target_byte_offset + byte_size, target.length, 'range reaches past the target');
577
-
578
- const handle = this.#allocate_handle();
579
- const base = handle * RECORD_WORDS;
580
- const records = this.#records;
581
-
582
- records[base + R_TABLE] = table;
583
- records[base + R_ROW] = row;
584
- records[base + R_WORD_OFFSET] = byte_offset / WORD_SIZE;
585
- records[base + R_WORD_COUNT] = byte_size / WORD_SIZE;
586
- records[base + R_GENERATION] = tables[table].generation_of(row);
587
- records[base + R_TARGET_OFFSET] = target_byte_offset;
588
-
589
- this.#targets[handle] = target;
590
- this.#status[handle] = GPUReadbackStatus.Pending;
591
-
592
- const batch = this.#assembling;
593
-
594
- if (batch.count === batch.handles.length) {
595
- const grown = new Uint32Array(batch.handles.length * 2);
596
-
597
- grown.set(batch.handles);
598
-
599
- batch.handles = grown;
600
- }
601
-
602
- batch.handles[batch.count++] = handle;
603
-
604
- return handle;
605
- }
606
-
607
- /**
608
- * Deliver every batch whose bytes have arrived, oldest first and stopping at the first that has
609
- * not, then start the map for every batch whose frame has been submitted.
610
- *
611
- * **This is the apply point.** Call it at the head of a frame, before any system runs. A batch
612
- * therefore reaches its targets at the first frame head at which its mapping — and every older
613
- * batch's — has resolved, which is the frame after the one that encoded it at the earliest:
614
- * never inside an update, and never at two different moments for two requests of the same
615
- * batch. No caller-supplied code runs here.
616
- *
617
- * @returns {number} requests delivered
618
- */
619
- apply() {
620
- if (this.#destroyed) {
621
- return 0;
622
- }
623
-
624
- // The handles delivered or dropped at the previous apply point have had their frame of
625
- // being readable; they go back to the free list before anything is delivered, so nothing
626
- // delivered now can be recycled before it has been read.
627
- const retiring = this.#retiring;
628
-
629
- for (let i = 0; i < retiring.length; i++) {
630
- this.#recycle(retiring[i]);
631
- }
632
-
633
- retiring.length = 0;
634
-
635
- const in_flight = this.#in_flight;
636
-
637
- let delivered = 0;
638
-
639
- while (in_flight.length > 0) {
640
- const batch = in_flight[0];
641
-
642
- if (batch.state === BatchState.Ready) {
643
- delivered += this.#deliver(batch);
644
- } else if (batch.state === BatchState.Failed) {
645
- this.#drop_pending(batch, true);
646
- } else {
647
- // still on the device, and nothing younger may overtake it
648
- break;
649
- }
650
-
651
- this.#allocator.release(batch.buffer);
652
-
653
- batch.buffer = null;
654
- batch.bytes = null;
655
- batch.context = null;
656
-
657
- in_flight.shift();
658
- retiring.push(batch);
659
- }
660
-
661
- // Start the maps only now, and only for batches whose frame has been submitted. `encode`
662
- // records a copy into a command context the caller has not finished yet, and mapping a
663
- // buffer whose copy has not been submitted reads the frame before.
664
- for (let i = 0; i < in_flight.length; i++) {
665
- const batch = in_flight[i];
666
-
667
- if (batch.state === BatchState.Encoded && batch.context.finished) {
668
- this.#start_map(batch);
669
- }
670
- }
671
-
672
- return delivered;
673
- }
674
-
675
- /**
676
- * Record this frame's batch: a gather and one copy, or a handful of copies, or nothing at all.
677
- *
678
- * @param {import("../../../device/ShadeGPUCommandContext.js").ShadeGPUCommandContext} encoder
679
- * @returns {boolean} whether anything was encoded
680
- */
681
- encode(encoder) {
682
- if (this.#destroyed) {
683
- return false;
684
- }
685
-
686
- const batch = this.#assembling;
687
-
688
- if (batch.count === 0) {
689
- // The point of the whole arrangement: a frame nobody asked anything of costs one
690
- // comparison. No buffer is taken, no command is recorded.
691
- return false;
692
- }
693
-
694
- if (this.#allocator === null) {
695
- const allocator = encoder.graphics.buffer_allocator_readback;
696
-
697
- assert.defined(allocator, 'encoder.graphics.buffer_allocator_readback');
698
-
699
- this.#allocator = allocator;
700
- }
701
-
702
- if (this.#in_flight.length >= this.#max_in_flight) {
703
- // The device has stopped answering. Refusing the frame's requests, with a status the
704
- // consumer can see, bounds everything: nothing queues, nothing is re-resolved next
705
- // frame, and no buffer is taken for bytes that would be a dozen frames stale.
706
- this.#drop_pending(batch, true);
707
- this.#retire(batch);
708
-
709
- return false;
710
- }
711
-
712
- const live = this.#resolve(batch);
713
-
714
- if (live === 0) {
715
- // every row asked about has gone; nothing to copy and nothing to deliver
716
- this.#retire(batch);
717
-
718
- return false;
719
- }
720
-
721
- batch.buffer = this.#allocator.get(batch.byte_size);
722
-
723
- if (live < this.#gather_threshold) {
724
- this.#encode_copies(encoder, batch);
725
- } else {
726
- this.#encode_gather(encoder, batch);
727
- }
728
-
729
- batch.context = encoder;
730
- batch.state = BatchState.Encoded;
731
-
732
- this.#in_flight.push(batch);
733
- this.#assembling = this.#take_batch();
734
-
735
- return true;
736
- }
737
-
738
- /**
739
- * Where each request's range starts in the database buffer and where it lands in the image,
740
- * for every request whose row is there to be read. A request whose page is not resident, or
741
- * whose row is not occupied, is dropped here: "the page was gone" is a fact about the moment
742
- * the batch was encoded and cannot be recovered from the bytes afterwards.
743
- *
744
- * The same arithmetic {@link GPUDatabase#debug_table_read_element} does, and the same the gather
745
- * shader does — the CPU needs it for the copy path, and the residency answer for both.
746
- *
747
- * One pass, in request order, so the image is packed in request order and a consumer's run of
748
- * consecutive rows is one contiguous span of it. Requests cluster by table and by page, so the
749
- * table and the page are looked up when they change rather than per request. Live requests are
750
- * counted per table on the way through, which is all the gather path's bucketing needs.
751
- *
752
- * @param {GPUReadbackBatch} batch
753
- * @returns {number} live requests
754
- */
755
- #resolve(batch) {
756
- const database = this.#database;
757
- const tables = database.tables;
758
- const data_start = database.data_start_offset;
759
-
760
- const records = this.#records;
761
- const status = this.#status;
762
- const handles = batch.handles;
763
- const count = batch.count;
764
-
765
- const starts = this.#table_starts;
766
-
767
- starts.fill(0);
768
-
769
- let destination = 0;
770
- let live = 0;
771
- let dropped = 0;
772
-
773
- let table_index = -1;
774
- let table = null;
775
- let descriptor = null;
776
- let elements_per_page = 0;
777
- let record_words = 0;
778
-
779
- let page_index = -1;
780
- let page_base = -1;
781
-
782
- for (let i = 0; i < count; i++) {
783
- const handle = handles[i];
784
- const base = handle * RECORD_WORDS;
785
-
786
- const t = records[base + R_TABLE];
787
- const row = records[base + R_ROW];
788
-
789
- if (t !== table_index) {
790
- table_index = t;
791
- table = tables[t];
792
- descriptor = table.descriptor;
793
- elements_per_page = descriptor.elements_per_page;
794
- record_words = descriptor.packed_element_size_bytes / WORD_SIZE;
795
- page_index = -1;
796
- }
797
-
798
- const p = Math.floor(row / elements_per_page);
799
-
800
- if (p !== page_index) {
801
- page_index = p;
802
-
803
- const page = table.pages.get(p);
804
-
805
- page_base = (page === undefined || page.slot_offset === -1)
806
- ? -1
807
- : page.slot_offset + data_start + descriptor.page_header_words;
808
- }
809
-
810
- if (page_base === -1 || !table.occupancy.get(row)) {
811
- // the page is not on the GPU, or the row was removed and its bytes are whatever the
812
- // last occupant left
813
- status[handle] = GPUReadbackStatus.Dropped;
814
- dropped++;
815
-
816
- continue;
817
- }
818
-
819
- records[base + R_SOURCE_WORD] = page_base
820
- + (row - page_index * elements_per_page) * record_words
821
- + records[base + R_WORD_OFFSET];
822
- records[base + R_DESTINATION_WORD] = destination;
823
-
824
- destination += records[base + R_WORD_COUNT];
825
-
826
- live++;
827
- starts[t + 1]++;
828
- }
829
-
830
- this.#dropped_count += dropped;
831
-
832
- batch.live = live;
833
- batch.byte_size = destination * WORD_SIZE;
834
-
835
- return live;
836
- }
837
-
838
- /**
839
- * Copy each range straight out of the database into its place in the image. No shader, no
840
- * descriptor upload, no bind group — which below the threshold is cheaper than all three.
841
- *
842
- * @param {import("../../../device/ShadeGPUCommandContext.js").ShadeGPUCommandContext} encoder
843
- * @param {GPUReadbackBatch} batch
844
- */
845
- #encode_copies(encoder, batch) {
846
- const source = this.#database.buffer;
847
- const destination = batch.buffer;
848
-
849
- const records = this.#records;
850
- const status = this.#status;
851
- const handles = batch.handles;
852
- const count = batch.count;
853
-
854
- let copies = 0;
855
-
856
- for (let i = 0; i < count; i++) {
857
- const handle = handles[i];
858
-
859
- if (status[handle] !== GPUReadbackStatus.Pending) {
860
- continue;
861
- }
862
-
863
- const base = handle * RECORD_WORDS;
864
-
865
- encoder.copyBufferToBuffer(
866
- source,
867
- records[base + R_SOURCE_WORD] * WORD_SIZE,
868
- destination,
869
- records[base + R_DESTINATION_WORD] * WORD_SIZE,
870
- records[base + R_WORD_COUNT] * WORD_SIZE,
871
- );
872
-
873
- copies++;
874
- }
875
-
876
- this.#copies_encoded += copies;
877
- }
878
-
879
- /**
880
- * Pack every range into the scratch buffer with one dispatch per table, then copy the whole
881
- * image across in one go.
882
- *
883
- * One dispatch per table rather than one for the batch, because the page geometry a thread needs
884
- * — record size, elements per page, where the table's page addresses live — is per table, and
885
- * carrying it per descriptor would cost more words than the descriptor has.
886
- *
887
- * The live handles are bucketed by table with a counting sort off the per-table counts
888
- * {@link #resolve} left behind: one pass to scatter, then each table's run is emitted in turn.
889
- * Linear in the requests plus the tables, where scanning every request once per table was
890
- * their product.
891
- *
892
- * @param {import("../../../device/ShadeGPUCommandContext.js").ShadeGPUCommandContext} encoder
893
- * @param {GPUReadbackBatch} batch
894
- */
895
- #encode_gather(encoder, batch) {
896
- const live = batch.live;
897
- const byte_size = batch.byte_size;
898
-
899
- const gather_buffer = this.#fit_gather_buffer(byte_size);
900
-
901
- const tables = this.#database.tables;
902
- const table_count = tables.length;
903
-
904
- const records = this.#records;
905
- const status = this.#status;
906
- const handles = batch.handles;
907
- const count = batch.count;
908
-
909
- // counts to starts
910
- const starts = this.#table_starts;
911
-
912
- for (let t = 1; t <= table_count; t++) {
913
- starts[t] += starts[t - 1];
914
- }
915
-
916
- if (batch.order.length < live) {
917
- batch.order = new Uint32Array(Math.max(live, batch.order.length * 2));
918
- }
919
-
920
- const order = batch.order;
921
-
922
- // scatter, in request order within each table; afterwards starts[t] is the end of table t
923
- for (let i = 0; i < count; i++) {
924
- const handle = handles[i];
925
-
926
- if (status[handle] !== GPUReadbackStatus.Pending) {
927
- continue;
928
- }
929
-
930
- order[starts[records[handle * RECORD_WORDS + R_TABLE]]++] = handle;
931
- }
932
-
933
- const descriptor_stride = GPU_TABLE_GATHER_DESCRIPTOR_WORDS;
934
- const max_per_chunk = Math.max(1, Math.floor(DESCRIPTOR_CHUNK_BYTES / (descriptor_stride * WORD_SIZE)));
935
-
936
- const scratch_words = Math.min(live, max_per_chunk) * descriptor_stride;
937
-
938
- if (this.#descriptor_scratch.length < scratch_words) {
939
- this.#descriptor_scratch = new Uint32Array(scratch_words);
940
- }
941
-
942
- const scratch = this.#descriptor_scratch;
943
- const settings = this.#gather_settings;
944
-
945
- let run_start = 0;
946
-
947
- for (let t = 0; t < table_count; t++) {
948
- const run_end = starts[t];
949
-
950
- if (run_end === run_start) {
951
- continue;
952
- }
953
-
954
- const table_descriptor = tables[t].descriptor;
955
-
956
- settings.record_size = table_descriptor.packed_element_size_bytes / WORD_SIZE;
957
- settings.elements_per_page = table_descriptor.elements_per_page;
958
- settings.page_lookup_address = table_descriptor.page_lookup_address;
959
- settings.page_header_words = table_descriptor.page_header_words;
960
- settings.page_limit = table_descriptor.page_limit;
961
-
962
- let filled = 0;
963
-
964
- for (let i = run_start; i < run_end; i++) {
965
- const base = order[i] * RECORD_WORDS;
966
- const d = filled * descriptor_stride;
967
-
968
- scratch[d] = records[base + R_ROW];
969
- scratch[d + 1] = records[base + R_WORD_OFFSET];
970
- scratch[d + 2] = records[base + R_WORD_COUNT];
971
- scratch[d + 3] = records[base + R_DESTINATION_WORD];
972
-
973
- filled++;
974
-
975
- if (filled === max_per_chunk) {
976
- this.#dispatch_gather(encoder, scratch, filled, settings, gather_buffer);
977
- filled = 0;
978
- }
979
- }
980
-
981
- if (filled > 0) {
982
- this.#dispatch_gather(encoder, scratch, filled, settings, gather_buffer);
983
- }
984
-
985
- run_start = run_end;
986
- }
987
-
988
- encoder.copyBufferToBuffer(gather_buffer, 0, batch.buffer, 0, byte_size);
989
-
990
- this.#copies_encoded++;
991
- }
992
-
993
- /**
994
- * @param {import("../../../device/ShadeGPUCommandContext.js").ShadeGPUCommandContext} encoder
995
- * @param {Uint32Array} scratch
996
- * @param {number} count
997
- * @param {Object} settings
998
- * @param {GPUBuffer} gather_buffer
999
- */
1000
- #dispatch_gather(encoder, scratch, count, settings, gather_buffer) {
1001
- settings.count = count;
1002
-
1003
- const descriptors = encoder.allocateTransientBufferAndLoad(
1004
- scratch.buffer,
1005
- GPUBufferUsage.STORAGE,
1006
- 0,
1007
- count * GPU_TABLE_GATHER_DESCRIPTOR_WORDS * WORD_SIZE,
1008
- );
1009
-
1010
- gpu_table_gather_shader.dispatchThreads({
1011
- encoder,
1012
- bindings: {
1013
- settings,
1014
- descriptors,
1015
- database: this.#database.buffer,
1016
- gathered: gather_buffer,
1017
- },
1018
- thread_count_x: count,
1019
- });
1020
-
1021
- this.#dispatches_encoded++;
1022
- }
1023
-
1024
- /**
1025
- * @param {number} byte_size
1026
- * @returns {GPUBuffer}
1027
- */
1028
- #fit_gather_buffer(byte_size) {
1029
- const existing = this.#gather_buffer;
1030
-
1031
- if (existing !== null && existing.size >= byte_size) {
1032
- return existing;
1033
- }
1034
-
1035
- if (existing !== null) {
1036
- existing.destroy();
1037
- }
1038
-
1039
- const buffer = this.#device.createBuffer({
1040
- label: 'GPUDatabaseReadback/gather',
1041
- size: round_up(byte_size, GATHER_SIZE_GRANULARITY),
1042
- usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
1043
- mappedAtCreation: false,
1044
- });
1045
-
1046
- this.#gather_buffer = buffer;
1047
-
1048
- return buffer;
1049
- }
1050
-
1051
- /**
1052
- * @param {GPUReadbackBatch} batch
1053
- */
1054
- #start_map(batch) {
1055
- batch.state = BatchState.Mapping;
1056
-
1057
- batch.buffer.mapAsync(GPUMapMode.READ, 0, batch.byte_size).then(batch.on_mapped, batch.on_failed);
1058
- }
1059
-
1060
- /**
1061
- * Copy a mapped batch into its targets.
1062
- *
1063
- * The image is packed in request order, so consecutive live requests are consecutive in it;
1064
- * when they also name consecutive bytes of one target, the run is one `set`. A consumer that
1065
- * asks for a hundred rows into one array gets one copy, not a hundred.
1066
- *
1067
- * @param {GPUReadbackBatch} batch
1068
- * @returns {number} requests delivered
1069
- */
1070
- #deliver(batch) {
1071
- const records = this.#records;
1072
- const status = this.#status;
1073
- const targets = this.#targets;
1074
- const tables = this.#database.tables;
1075
-
1076
- const bytes = batch.bytes;
1077
- const handles = batch.handles;
1078
- const count = batch.count;
1079
-
1080
- let delivered = 0;
1081
- let dropped = 0;
1082
-
1083
- let run_target = null;
1084
- let run_source = 0;
1085
- let run_target_offset = 0;
1086
- let run_length = 0;
1087
-
1088
- for (let i = 0; i < count; i++) {
1089
- const handle = handles[i];
1090
-
1091
- if (status[handle] !== GPUReadbackStatus.Pending) {
1092
- // dropped at encode; it has no bytes in the image
1093
- continue;
1094
- }
1095
-
1096
- const base = handle * RECORD_WORDS;
1097
- const row = records[base + R_ROW];
1098
-
1099
- if (tables[records[base + R_TABLE]].generation_of(row) !== records[base + R_GENERATION]) {
1100
- // the row was freed while this was in flight, and an id freed is an id already
1101
- // handed out again — answering would be answering about a stranger
1102
- status[handle] = GPUReadbackStatus.Dropped;
1103
- dropped++;
1104
-
1105
- continue;
1106
- }
1107
-
1108
- const source = records[base + R_DESTINATION_WORD] * WORD_SIZE;
1109
- const length = records[base + R_WORD_COUNT] * WORD_SIZE;
1110
- const target = targets[handle];
1111
- const target_offset = records[base + R_TARGET_OFFSET];
1112
-
1113
- if (
1114
- target === run_target
1115
- && target_offset === run_target_offset + run_length
1116
- && source === run_source + run_length
1117
- ) {
1118
- run_length += length;
1119
- } else {
1120
- if (run_length > 0) {
1121
- run_target.set(bytes.subarray(run_source, run_source + run_length), run_target_offset);
1122
- }
1123
-
1124
- run_target = target;
1125
- run_source = source;
1126
- run_target_offset = target_offset;
1127
- run_length = length;
1128
- }
1129
-
1130
- status[handle] = GPUReadbackStatus.Delivered;
1131
- delivered++;
1132
- }
1133
-
1134
- if (run_length > 0) {
1135
- run_target.set(bytes.subarray(run_source, run_source + run_length), run_target_offset);
1136
- }
1137
-
1138
- this.#delivered_count += delivered;
1139
- this.#dropped_count += dropped;
1140
-
1141
- return delivered;
1142
- }
1143
-
1144
- /**
1145
- * Mark every request of a batch still waiting as dropped.
1146
- *
1147
- * @param {GPUReadbackBatch} batch
1148
- * @param {boolean} stalled whether the pipeline, rather than the rows, is the reason
1149
- */
1150
- #drop_pending(batch, stalled) {
1151
- const status = this.#status;
1152
- const handles = batch.handles;
1153
- const count = batch.count;
1154
-
1155
- let dropped = 0;
1156
-
1157
- for (let i = 0; i < count; i++) {
1158
- const handle = handles[i];
1159
-
1160
- if (status[handle] === GPUReadbackStatus.Pending) {
1161
- status[handle] = GPUReadbackStatus.Dropped;
1162
- dropped++;
1163
- }
1164
- }
1165
-
1166
- if (stalled) {
1167
- this.#stalled_count += dropped;
1168
- } else {
1169
- this.#dropped_count += dropped;
1170
- }
1171
- }
1172
-
1173
- /**
1174
- * Send the assembling batch straight to retiring — nothing of it is in flight — and take a
1175
- * fresh one for the requests that follow.
1176
- *
1177
- * @param {GPUReadbackBatch} batch
1178
- */
1179
- #retire(batch) {
1180
- this.#retiring.push(batch);
1181
- this.#assembling = this.#take_batch();
1182
- }
1183
-
1184
- /**
1185
- * Free a retired batch's handles and put the batch back in the pool.
1186
- *
1187
- * @param {GPUReadbackBatch} batch
1188
- */
1189
- #recycle(batch) {
1190
- const status = this.#status;
1191
- const targets = this.#targets;
1192
- const free = this.#free;
1193
- const handles = batch.handles;
1194
- const count = batch.count;
1195
-
1196
- let free_count = this.#free_count;
1197
-
1198
- for (let i = 0; i < count; i++) {
1199
- const handle = handles[i];
1200
-
1201
- status[handle] = GPUReadbackStatus.None;
1202
- targets[handle] = null;
1203
-
1204
- free[free_count++] = handle;
1205
- }
1206
-
1207
- this.#free_count = free_count;
1208
-
1209
- batch.count = 0;
1210
- batch.live = 0;
1211
- batch.byte_size = 0;
1212
- batch.state = BatchState.Assembling;
1213
-
1214
- this.#spare.push(batch);
1215
- }
1216
-
1217
- /**
1218
- * @returns {GPUReadbackBatch}
1219
- */
1220
- #take_batch() {
1221
- const spare = this.#spare;
1222
-
1223
- if (spare.length > 0) {
1224
- return spare.pop();
1225
- }
1226
-
1227
- return this.#make_batch();
1228
- }
1229
-
1230
- /**
1231
- * @returns {GPUReadbackBatch}
1232
- */
1233
- #make_batch() {
1234
- const batch = new GPUReadbackBatch();
1235
-
1236
- batch.on_mapped = () => {
1237
- if (this.#destroyed || batch.state !== BatchState.Mapping) {
1238
- // torn down while the map was out; the buffer went with it
1239
- return;
1240
- }
1241
-
1242
- batch.bytes = new Uint8Array(batch.buffer.getMappedRange(0, batch.byte_size));
1243
- batch.state = BatchState.Ready;
1244
- };
1245
-
1246
- batch.on_failed = () => {
1247
- if (batch.state === BatchState.Mapping) {
1248
- // device lost, buffer destroyed — discarded at the next apply point
1249
- batch.state = BatchState.Failed;
1250
- }
1251
- };
1252
-
1253
- return batch;
1254
- }
1255
-
1256
- /**
1257
- * @returns {number}
1258
- */
1259
- #allocate_handle() {
1260
- if (this.#free_count > 0) {
1261
- return this.#free[--this.#free_count];
1262
- }
1263
-
1264
- if (this.#fresh === this.#status.length) {
1265
- this.#grow_handles();
1266
- }
1267
-
1268
- return this.#fresh++;
1269
- }
1270
-
1271
- /**
1272
- * Double the handle space. Handles are indices, so nothing moves; a caller keeps the ones it
1273
- * has.
1274
- */
1275
- #grow_handles() {
1276
- const capacity = this.#status.length * 2;
1277
-
1278
- const records = new Uint32Array(capacity * RECORD_WORDS);
1279
- records.set(this.#records);
1280
- this.#records = records;
1281
-
1282
- const status = new Uint8Array(capacity);
1283
- status.set(this.#status);
1284
- this.#status = status;
1285
-
1286
- const free = new Uint32Array(capacity);
1287
- free.set(this.#free);
1288
- this.#free = free;
1289
-
1290
- const targets = this.#targets;
1291
-
1292
- for (let i = targets.length; i < capacity; i++) {
1293
- targets.push(null);
1294
- }
1295
- }
1296
-
1297
- destroy() {
1298
- this.#destroyed = true;
1299
-
1300
- const in_flight = this.#in_flight;
1301
-
1302
- for (let i = 0; i < in_flight.length; i++) {
1303
- const batch = in_flight[i];
1304
-
1305
- if (batch.buffer !== null) {
1306
- // may be mid-map, which WebGPU lets destroy() abort but not unmap()
1307
- this.#allocator.discard(batch.buffer);
1308
-
1309
- batch.buffer = null;
1310
- }
1311
- }
1312
-
1313
- in_flight.length = 0;
1314
- this.#retiring.length = 0;
1315
- this.#spare.length = 0;
1316
- this.#assembling.count = 0;
1317
-
1318
- if (this.#gather_buffer !== null) {
1319
- this.#gather_buffer.destroy();
1320
- this.#gather_buffer = null;
1321
- }
1322
- }
1323
- }
1
+ import { assert } from "../../../../core/assert.js";
2
+ import { round_up } from "../../../../core/math/round_up.js";
3
+ import { GPU_DATABASE_BUFFER_ELEMENT_TYPE } from "./GPU_DATABASE_BUFFER_ELEMENT_TYPE.js";
4
+ import { GPU_TABLE_GATHER_DESCRIPTOR_WORDS } from "./GPU_TABLE_GATHER_DESCRIPTOR_WORDS.js";
5
+ import { gpu_table_gather_shader } from "./gpu_table_gather_shader.js";
6
+ import { GPUReadbackStatus } from "./GPUReadbackStatus.js";
7
+
8
+ /**
9
+ * Bytes per {@link GPU_DATABASE_BUFFER_ELEMENT_TYPE}.
10
+ * @type {number}
11
+ */
12
+ const WORD_SIZE = GPU_DATABASE_BUFFER_ELEMENT_TYPE.size;
13
+
14
+ /**
15
+ * Largest transient descriptor buffer one dispatch will be given, matching the upload path's.
16
+ * @type {number}
17
+ */
18
+ const DESCRIPTOR_CHUNK_BYTES = 256 * 1024;
19
+
20
+ /**
21
+ * Granularity the gather scratch buffer grows by.
22
+ * @type {number}
23
+ */
24
+ const GATHER_SIZE_GRANULARITY = 1024;
25
+
26
+ /**
27
+ * Requests at or above which a batch is gathered by a dispatch rather than copied range by range.
28
+ *
29
+ * **Measured, not chosen**, on a real device: Chrome 141 / Dawn, NVIDIA Lovelace, reading a 64-byte
30
+ * range out of each of N 176-byte rows spread across 4 KiB pages. Best of five blocks of a hundred
31
+ * batches, by `src/shade/playground/readback_crossover/`.
32
+ *
33
+ * | rows | encode copies | encode gather | round trip copies | round trip gather |
34
+ * |-----:|--------------:|--------------:|------------------:|------------------:|
35
+ * | 1 | 5.0 µs | 17.0 µs | 63 µs | 79 µs |
36
+ * | 8 | 6.0 µs | 25.0 µs | 75 µs | 125 µs |
37
+ * | 32 | 10.0 µs | 27.0 µs | 111 µs | 130 µs |
38
+ * | 64 | 14.0 µs | 33.0 µs | 135 µs | 129 µs |
39
+ * | 256 | 45.0 µs | 53.0 µs | 230 µs | 116 µs |
40
+ * | 512 | 87.0 µs | 77.0 µs | 307 µs | 115 µs |
41
+ *
42
+ * Fitted: encoding costs `4.5 µs + 0.161 per row` for copies against `21.9 µs + 0.112` for the
43
+ * gather, which crosses at **352 rows** — on CPU encode cost alone the gather is almost never worth
44
+ * it, because appending a descriptor is not much cheaper than appending a copy command.
45
+ *
46
+ * The round trip is where the difference actually lives: `81 µs + 0.480 per row` for copies against
47
+ * `104 µs + 0.037` for the gather. Submitting and executing N scattered copy commands costs about
48
+ * half a microsecond each, and the gather is flat — 512 rows cost it no more than 8 do. Those cross
49
+ * at **51 rows**, and the measured curves cross between 32 and 64. This is 48: inside the measured
50
+ * interval, and on the side of the path whose cost does not grow.
51
+ *
52
+ * The fixed term of the round trip is mostly the wait for `onSubmittedWorkDone` and is not a cost a
53
+ * frame pays synchronously; the slopes are the part that decides, and they differ by 13×.
54
+ *
55
+ * Those numbers were taken against the first, callback-and-objects version of this service. The
56
+ * same page, re-run on the same adapter after the request became a few integer stores (two idle
57
+ * runs, headless Chrome): encode `5.7–5.9 + 0.14 per row` for copies against `23.5–23.8 + 0.10` for
58
+ * the gather; round trip `67–73 + 0.31` against `83–86 + 0.003–0.010`, crossing at 34 and 62 rows
59
+ * with the curves crossing between 16 and 64. The per-row cost fell on both paths and the slopes
60
+ * that decide are further apart than before; 48 is still inside the interval.
61
+ *
62
+ * @see https://claude.ai/code/artifact/88ee4932-ed98-407e-a25b-d379f3cf852a F5, which asked for this
63
+ * number rather than for "batched is better"
64
+ * @type {number}
65
+ */
66
+ const DEFAULT_GATHER_THRESHOLD = 48;
67
+
68
+ /**
69
+ * Batches allowed in flight before a frame's requests are refused. A mapping normally lands one or
70
+ * two frames after its copy, so this is only reached when the device has stopped answering, and
71
+ * the right thing to do with a frame's requests then is to say so and drop them: a consumer asks
72
+ * every frame anyway, and a value delivered a dozen frames late is not the value it wanted.
73
+ *
74
+ * @type {number}
75
+ */
76
+ const DEFAULT_MAX_IN_FLIGHT = 4;
77
+
78
+ /**
79
+ * Request records and batch handle lists start at this many entries and double.
80
+ * @type {number}
81
+ */
82
+ const INITIAL_CAPACITY = 64;
83
+
84
+ /*
85
+ * One request is RECORD_WORDS words of the flat record array, at handle * RECORD_WORDS. The first
86
+ * six are written by `request`, the last two by `encode`.
87
+ */
88
+ const R_TABLE = 0;
89
+ const R_ROW = 1;
90
+ const R_WORD_OFFSET = 2;
91
+ const R_WORD_COUNT = 3;
92
+ const R_GENERATION = 4;
93
+ const R_TARGET_OFFSET = 5;
94
+ const R_SOURCE_WORD = 6;
95
+ const R_DESTINATION_WORD = 7;
96
+ const RECORD_WORDS = 8;
97
+
98
+ /**
99
+ * @enum {number}
100
+ */
101
+ const BatchState = {
102
+ /** taking requests; the one batch in this state is the frame's */
103
+ Assembling: 0,
104
+ /** copy recorded, the frame that recorded it not yet known to be submitted */
105
+ Encoded: 1,
106
+ /** `mapAsync` outstanding */
107
+ Mapping: 2,
108
+ /** mapped, waiting for an apply point */
109
+ Ready: 3,
110
+ /** the map was refused; the batch is discarded without delivering */
111
+ Failed: 4,
112
+ };
113
+
114
+ /**
115
+ * One frame's worth of requests, travelling together. Pooled: a batch that has been delivered keeps
116
+ * its arrays and takes the next frame's requests, so a steady stream of batches allocates nothing.
117
+ */
118
+ class GPUReadbackBatch {
119
+ /**
120
+ * Handles in request order.
121
+ * @type {Uint32Array}
122
+ */
123
+ handles = new Uint32Array(INITIAL_CAPACITY);
124
+
125
+ /**
126
+ * @type {number}
127
+ */
128
+ count = 0;
129
+
130
+ /**
131
+ * Requests whose row was resident when the batch was encoded.
132
+ * @type {number}
133
+ */
134
+ live = 0;
135
+
136
+ /**
137
+ * Bytes of the packed image.
138
+ * @type {number}
139
+ */
140
+ byte_size = 0;
141
+
142
+ /**
143
+ * The readback buffer the image was copied into. From {@link GPUBufferReadbackAllocator}, and
144
+ * given back when the batch is delivered or discarded.
145
+ *
146
+ * @type {GPUBuffer|null}
147
+ */
148
+ buffer = null;
149
+
150
+ /**
151
+ * The mapped image, valid from the mapping settling until the buffer is given back. Read
152
+ * directly at the apply point — the buffer stays mapped until then, which is what makes the
153
+ * copy into the caller's memory the only copy.
154
+ *
155
+ * @type {Uint8Array|null}
156
+ */
157
+ bytes = null;
158
+
159
+ /**
160
+ * The command context the copy was recorded on. The mapping may not start until it has been
161
+ * finished, because a map of a buffer whose copy has not been submitted reads the frame before.
162
+ *
163
+ * @type {import("../../../device/ShadeGPUCommandContext.js").ShadeGPUCommandContext|null}
164
+ */
165
+ context = null;
166
+
167
+ /**
168
+ * @type {BatchState}
169
+ */
170
+ state = BatchState.Assembling;
171
+
172
+ /**
173
+ * Live handles grouped by table, for the gather path's one dispatch per table.
174
+ * @type {Uint32Array}
175
+ */
176
+ order = new Uint32Array(0);
177
+
178
+ /**
179
+ * Reactions to this batch's mapping, bound once per pooled batch rather than once per frame.
180
+ * @type {function(): void}
181
+ */
182
+ on_mapped = null;
183
+
184
+ /**
185
+ * @type {function(): void}
186
+ */
187
+ on_failed = null;
188
+ }
189
+
190
+ /**
191
+ * Reading rows back from a {@link GPUDatabase} in batches: one gather, one copy, one map, and one
192
+ * point in the frame where the answers land — in memory the caller already owns.
193
+ *
194
+ * **Why this is not `debug_table_read_element`.** That resolves one row's byte offset and calls
195
+ * {@link inspect_gpu_buffer_typed}, which creates a `MAP_READ` buffer, copies, submits, maps and
196
+ * destroys it — per call. It is a debug affordance and stays one. Here the buffers persist, the
197
+ * requests of a frame travel together, and the result arrives at a stated moment rather than
198
+ * whenever a promise happens to settle.
199
+ *
200
+ * **The caller names memory, and nothing is called.** A request is a table handle, a row, a byte
201
+ * range of the record, and a `Uint8Array` plus offset to put it in. At the apply point the service
202
+ * copies the bytes there and marks the request's handle in {@link status}; the consumer reads the
203
+ * status when its own system next runs, which is when it wanted the value anyway. There is no
204
+ * callback and no promise, for the same reason: a function called per row is a closure allocated
205
+ * per row and a permanently megamorphic call site, and code running inside the apply point could
206
+ * re-enter this service, or destroy the database, from the middle of `GPUDatabase.update`. The
207
+ * shader packs a batch contiguously in request order, so a consumer's run of rows lands in its
208
+ * destination as one `set` — which a per-row function could never have done.
209
+ *
210
+ * **Gather, then one copy.** Rows sit at scattered offsets across pages, so a compute shader packs
211
+ * the requested ranges contiguously before a single copy into a readback buffer. Packing a *range*
212
+ * rather than a record is what makes it worth doing: an entity's world matrix is 64 bytes of a
213
+ * 176-byte row.
214
+ *
215
+ * **But the request list is itself an upload.** A gather needs its descriptors on the GPU, so every
216
+ * frame with any request writes a buffer, allocates, binds and dispatches. For one row that costs
217
+ * far more than the value retrieved. Below {@link DEFAULT_GATHER_THRESHOLD} — a measured number, see
218
+ * its docblock — the batch degrades to direct `copyBufferToBuffer` calls into the same readback
219
+ * buffer, with no shader at all. A frame with no requests skips the whole path: no buffer, no
220
+ * command.
221
+ *
222
+ * **One apply point, in encode order.** Results are delivered from {@link apply}, at the head of a
223
+ * frame, and never on the timing of the map's own promise. A component that changed value in the
224
+ * middle of an update because a readback happened to settle would be a different world for the
225
+ * systems that ran before it and the ones that ran after. And a batch is delivered only after every
226
+ * older batch has been: `mapAsync` promises are not promised to settle in the order the maps were
227
+ * started, and a consumer asking for the same row every frame must never see a fresh value
228
+ * overwritten by a stale one.
229
+ *
230
+ * **Nothing here may reach simulation state.** A readback is a frame or more late and settles on the
231
+ * GPU's own schedule, so an outcome that depended on one would depend on frame pacing, and the
232
+ * determinism gate with it. This answers tools, sounds and cosmetics. Where the simulation wants a
233
+ * GPU-owned pose it evaluates the chain exactly, on the CPU.
234
+ *
235
+ * @see GPUStateAuthority which says whose value is worth reading back in the first place
236
+ * @see GPUReadbackStatus
237
+ */
238
+ export class GPUDatabaseReadback {
239
+ /**
240
+ * @type {import("./GPUDatabase.js").GPUDatabase}
241
+ */
242
+ #database;
243
+
244
+ /**
245
+ * @type {GPUDevice}
246
+ */
247
+ #device;
248
+
249
+ /**
250
+ * Where readback buffers come from: the graphics context's, shared with every other database
251
+ * on it, and taken from the first command context this service encodes on — the database is
252
+ * built against a device, not a context.
253
+ *
254
+ * @type {import("../GPUBufferReadbackAllocator.js").GPUBufferReadbackAllocator|null}
255
+ */
256
+ #allocator = null;
257
+
258
+ /**
259
+ * Shader-writable scratch the gather packs into, copied to a readback buffer in one go.
260
+ * Persistent and grown, never per batch, and unlike the readback buffers it needs no pool,
261
+ * because it is written and read inside one submission.
262
+ *
263
+ * @type {GPUBuffer|null}
264
+ */
265
+ #gather_buffer = null;
266
+
267
+ /**
268
+ * Request records, {@link RECORD_WORDS} words per handle. A request is a few integer stores
269
+ * into this array; the target it names is the only thing that is not an integer, and it sits
270
+ * in {@link #targets} beside it.
271
+ *
272
+ * @type {Uint32Array}
273
+ */
274
+ #records = new Uint32Array(INITIAL_CAPACITY * RECORD_WORDS);
275
+
276
+ /**
277
+ * Per handle, the memory the bytes are to land in.
278
+ * @type {(Uint8Array|null)[]}
279
+ */
280
+ #targets = new Array(INITIAL_CAPACITY).fill(null);
281
+
282
+ /**
283
+ * Per handle, a {@link GPUReadbackStatus}. Exposed as {@link status}.
284
+ * @type {Uint8Array}
285
+ */
286
+ #status = new Uint8Array(INITIAL_CAPACITY);
287
+
288
+ /**
289
+ * Recycled handles. Never longer than the record capacity, so it never overflows.
290
+ * @type {Uint32Array}
291
+ */
292
+ #free = new Uint32Array(INITIAL_CAPACITY);
293
+
294
+ /**
295
+ * @type {number}
296
+ */
297
+ #free_count = 0;
298
+
299
+ /**
300
+ * Handles below this have been handed out at least once.
301
+ * @type {number}
302
+ */
303
+ #fresh = 0;
304
+
305
+ /**
306
+ * The batch taking this frame's requests.
307
+ * @type {GPUReadbackBatch}
308
+ */
309
+ #assembling;
310
+
311
+ /**
312
+ * Encoded batches, oldest first.
313
+ * @type {GPUReadbackBatch[]}
314
+ */
315
+ #in_flight = [];
316
+
317
+ /**
318
+ * Batches delivered or dropped since the last apply point. Their handles stay readable until
319
+ * the next one, and are recycled there.
320
+ *
321
+ * @type {GPUReadbackBatch[]}
322
+ */
323
+ #retiring = [];
324
+
325
+ /**
326
+ * Batches with nothing in them, waiting to be the next frame's.
327
+ * @type {GPUReadbackBatch[]}
328
+ */
329
+ #spare = [];
330
+
331
+ /**
332
+ * Scratch for bucketing a batch's live requests by table: counts, then starts.
333
+ * @type {Uint32Array}
334
+ */
335
+ #table_starts;
336
+
337
+ /**
338
+ * @type {number}
339
+ */
340
+ #gather_threshold;
341
+
342
+ /**
343
+ * @type {number}
344
+ */
345
+ #max_in_flight;
346
+
347
+ /**
348
+ * Descriptor words for one dispatch, reused. Grown to the largest chunk this service has ever
349
+ * needed and kept.
350
+ *
351
+ * @type {Uint32Array}
352
+ */
353
+ #descriptor_scratch = new Uint32Array(0);
354
+
355
+ /**
356
+ * Immediate data for the gather dispatch, reused. `dispatchThreads` serialises it at the call,
357
+ * so one object can carry every dispatch of a frame.
358
+ *
359
+ * @type {Object}
360
+ */
361
+ #gather_settings = {
362
+ count: 0,
363
+ record_size: 0,
364
+ elements_per_page: 0,
365
+ page_lookup_address: 0,
366
+ page_header_words: 0,
367
+ page_limit: 0,
368
+ };
369
+
370
+ /**
371
+ * @type {boolean}
372
+ */
373
+ #destroyed = false;
374
+
375
+ #copies_encoded = 0;
376
+ #dispatches_encoded = 0;
377
+ #delivered_count = 0;
378
+ #dropped_count = 0;
379
+ #stalled_count = 0;
380
+
381
+ /**
382
+ * @param {Object} options
383
+ * @param {import("./GPUDatabase.js").GPUDatabase} options.database
384
+ * @param {GPUDevice} options.device
385
+ * @param {number} [options.gather_threshold] requests at or above which a dispatch is used
386
+ * @param {number} [options.max_in_flight] batches in flight before a frame's requests are dropped
387
+ * @param {string} [options.label]
388
+ */
389
+ constructor({
390
+ database,
391
+ device,
392
+ gather_threshold = DEFAULT_GATHER_THRESHOLD,
393
+ max_in_flight = DEFAULT_MAX_IN_FLIGHT,
394
+ label = 'GPUDatabaseReadback',
395
+ }) {
396
+ assert.defined(database, 'database');
397
+ assert.defined(device, 'device');
398
+ assert.isNonNegativeInteger(gather_threshold, 'gather_threshold');
399
+ assert.isPositiveInteger(max_in_flight, 'max_in_flight');
400
+ assert.isString(label, 'label');
401
+
402
+ this.#database = database;
403
+ this.#device = device;
404
+ this.#gather_threshold = gather_threshold;
405
+ this.#max_in_flight = max_in_flight;
406
+
407
+ this.#table_starts = new Uint32Array(database.tables.length + 1);
408
+
409
+ this.#assembling = this.#make_batch();
410
+ }
411
+
412
+ /**
413
+ * Requests at or above which a batch is gathered rather than copied range by range.
414
+ * @returns {number}
415
+ */
416
+ get gather_threshold() {
417
+ return this.#gather_threshold;
418
+ }
419
+
420
+ /**
421
+ * Batches in flight before a frame's requests are refused.
422
+ * @returns {number}
423
+ */
424
+ get max_in_flight() {
425
+ return this.#max_in_flight;
426
+ }
427
+
428
+ /**
429
+ * Per handle, what became of the request — a {@link GPUReadbackStatus}.
430
+ *
431
+ * Read it fresh each time rather than keeping a reference: the array is replaced when the
432
+ * handle space grows. A status is readable for one frame, from the apply point that set it to
433
+ * the next.
434
+ *
435
+ * @returns {Uint8Array}
436
+ */
437
+ get status() {
438
+ return this.#status;
439
+ }
440
+
441
+ /**
442
+ * How many handles exist. Grows to the working set of a steady stream of requests and stops:
443
+ * handles are recycled a frame after their result lands.
444
+ *
445
+ * @returns {number}
446
+ */
447
+ get handle_capacity() {
448
+ return this.#status.length;
449
+ }
450
+
451
+ /**
452
+ * Requests made and not yet encoded.
453
+ * @returns {number}
454
+ */
455
+ get pending_count() {
456
+ return this.#assembling.count;
457
+ }
458
+
459
+ /**
460
+ * Batches encoded and not yet delivered or discarded.
461
+ * @returns {number}
462
+ */
463
+ get in_flight_count() {
464
+ return this.#in_flight.length;
465
+ }
466
+
467
+ /**
468
+ * How many `copyBufferToBuffer` calls this service has encoded, over its life. Read by profiles,
469
+ * and by the specs that assert an empty frame encodes nothing.
470
+ *
471
+ * @returns {number}
472
+ */
473
+ get copies_encoded() {
474
+ return this.#copies_encoded;
475
+ }
476
+
477
+ /**
478
+ * How many gather dispatches this service has encoded, over its life.
479
+ * @returns {number}
480
+ */
481
+ get dispatches_encoded() {
482
+ return this.#dispatches_encoded;
483
+ }
484
+
485
+ /**
486
+ * Requests whose bytes reached their target.
487
+ * @returns {number}
488
+ */
489
+ get delivered_count() {
490
+ return this.#delivered_count;
491
+ }
492
+
493
+ /**
494
+ * Requests thrown away because of the row — its page was not resident when the batch was
495
+ * encoded, it was not occupied, or it was freed before the answer landed.
496
+ *
497
+ * Reported rather than swallowed: a consumer whose readbacks are all being dropped is asking
498
+ * about rows that keep dying, and silence reads downstream as "the value did not change".
499
+ *
500
+ * @returns {number}
501
+ */
502
+ get dropped_count() {
503
+ return this.#dropped_count;
504
+ }
505
+
506
+ /**
507
+ * Requests thrown away because of the pipeline — {@link max_in_flight} batches were still
508
+ * waiting on the device when the frame's batch was due, or a mapping was refused. Separate
509
+ * from {@link dropped_count} because the cure is different: those rows died, these the device
510
+ * stopped answering about.
511
+ *
512
+ * @returns {number}
513
+ */
514
+ get stalled_count() {
515
+ return this.#stalled_count;
516
+ }
517
+
518
+ /**
519
+ * Resolve a table name to the handle {@link request} takes. Once, at setup: a string lookup
520
+ * per row per frame is what this exists to avoid.
521
+ *
522
+ * From here on the table counts how many times each of its rows is freed, which is what lets
523
+ * an answer about a row that died and was reused be told from an answer about the row asked
524
+ * for.
525
+ *
526
+ * @param {string} name
527
+ * @returns {number}
528
+ */
529
+ table(name) {
530
+ assert.isString(name, 'name');
531
+
532
+ const table = this.#database.get(name);
533
+
534
+ if (table === undefined) {
535
+ throw new Error(`Table '${name}' does not exist`);
536
+ }
537
+
538
+ table.track_generations();
539
+
540
+ return table.descriptor.index;
541
+ }
542
+
543
+ /**
544
+ * Ask for a byte range of a row to be copied into `target`, at a later apply point.
545
+ *
546
+ * Positional, and a few integer stores: this is called once per row per frame by anything that
547
+ * tracks rows, so it takes no options object and allocates nothing.
548
+ *
549
+ * @param {number} table from {@link table}
550
+ * @param {number} row
551
+ * @param {number} byte_offset within the record, word-aligned
552
+ * @param {number} byte_size a positive multiple of the word size
553
+ * @param {Uint8Array} target memory the caller owns and keeps; the bytes are written here at
554
+ * the apply point. A byte view on purpose — a consumer that reads floats holds a
555
+ * `Float32Array` over the same buffer, made once
556
+ * @param {number} [target_byte_offset]
557
+ * @returns {number} a handle into {@link status}, valid until the frame after its result lands
558
+ */
559
+ request(table, row, byte_offset, byte_size, target, target_byte_offset = 0) {
560
+ assert.isNonNegativeInteger(table, 'table');
561
+ assert.isNonNegativeInteger(row, 'row');
562
+ assert.isNonNegativeInteger(byte_offset, 'byte_offset');
563
+ assert.isPositiveInteger(byte_size, 'byte_size');
564
+ assert.isNonNegativeInteger(target_byte_offset, 'target_byte_offset');
565
+
566
+ const tables = this.#database.tables;
567
+
568
+ assert.lessThan(table, tables.length, 'table is not a handle from table()');
569
+ assert.equal(byte_offset % WORD_SIZE, 0, 'byte_offset must be word-aligned');
570
+ assert.equal(byte_size % WORD_SIZE, 0, 'byte_size must be a whole number of words');
571
+ assert.ok(target instanceof Uint8Array, 'target must be a Uint8Array');
572
+
573
+ // constant messages: these run per row per frame, and a template literal built to describe a
574
+ // failure that does not happen is the cost on the path being measured
575
+ assert.lessThanOrEqual(byte_offset + byte_size, tables[table].descriptor.packed_element_size_bytes, 'range reaches past the record');
576
+ assert.lessThanOrEqual(target_byte_offset + byte_size, target.length, 'range reaches past the target');
577
+
578
+ const handle = this.#allocate_handle();
579
+ const base = handle * RECORD_WORDS;
580
+ const records = this.#records;
581
+
582
+ records[base + R_TABLE] = table;
583
+ records[base + R_ROW] = row;
584
+ records[base + R_WORD_OFFSET] = byte_offset / WORD_SIZE;
585
+ records[base + R_WORD_COUNT] = byte_size / WORD_SIZE;
586
+ records[base + R_GENERATION] = tables[table].generation_of(row);
587
+ records[base + R_TARGET_OFFSET] = target_byte_offset;
588
+
589
+ this.#targets[handle] = target;
590
+ this.#status[handle] = GPUReadbackStatus.Pending;
591
+
592
+ const batch = this.#assembling;
593
+
594
+ if (batch.count === batch.handles.length) {
595
+ const grown = new Uint32Array(batch.handles.length * 2);
596
+
597
+ grown.set(batch.handles);
598
+
599
+ batch.handles = grown;
600
+ }
601
+
602
+ batch.handles[batch.count++] = handle;
603
+
604
+ return handle;
605
+ }
606
+
607
+ /**
608
+ * Deliver every batch whose bytes have arrived, oldest first and stopping at the first that has
609
+ * not, then start the map for every batch whose frame has been submitted.
610
+ *
611
+ * **This is the apply point.** Call it at the head of a frame, before any system runs. A batch
612
+ * therefore reaches its targets at the first frame head at which its mapping — and every older
613
+ * batch's — has resolved, which is the frame after the one that encoded it at the earliest:
614
+ * never inside an update, and never at two different moments for two requests of the same
615
+ * batch. No caller-supplied code runs here.
616
+ *
617
+ * @returns {number} requests delivered
618
+ */
619
+ apply() {
620
+ if (this.#destroyed) {
621
+ return 0;
622
+ }
623
+
624
+ // The handles delivered or dropped at the previous apply point have had their frame of
625
+ // being readable; they go back to the free list before anything is delivered, so nothing
626
+ // delivered now can be recycled before it has been read.
627
+ const retiring = this.#retiring;
628
+
629
+ for (let i = 0; i < retiring.length; i++) {
630
+ this.#recycle(retiring[i]);
631
+ }
632
+
633
+ retiring.length = 0;
634
+
635
+ const in_flight = this.#in_flight;
636
+
637
+ let delivered = 0;
638
+
639
+ while (in_flight.length > 0) {
640
+ const batch = in_flight[0];
641
+
642
+ if (batch.state === BatchState.Ready) {
643
+ delivered += this.#deliver(batch);
644
+
645
+ this.#allocator.release(batch.buffer);
646
+ } else if (batch.state === BatchState.Failed) {
647
+ this.#drop_pending(batch, true);
648
+
649
+ /*
650
+ A refused mapping is the one case the allocator has discard for, and this used to
651
+ release alongside the delivered ones. release only inspects mapState, and a
652
+ destroyed buffer reports "unmapped", so the corpse went back on the free list in
653
+ size order and the next batch of the same size was handed it — a validation error
654
+ on every copy into it, for as long as the pool kept handing it out.
655
+ */
656
+ this.#allocator.discard(batch.buffer);
657
+ } else {
658
+ // still on the device, and nothing younger may overtake it
659
+ break;
660
+ }
661
+
662
+ batch.buffer = null;
663
+ batch.bytes = null;
664
+ batch.context = null;
665
+
666
+ in_flight.shift();
667
+ retiring.push(batch);
668
+ }
669
+
670
+ // Start the maps only now, and only for batches whose frame has been submitted. `encode`
671
+ // records a copy into a command context the caller has not finished yet, and mapping a
672
+ // buffer whose copy has not been submitted reads the frame before.
673
+ for (let i = 0; i < in_flight.length; i++) {
674
+ const batch = in_flight[i];
675
+
676
+ if (batch.state === BatchState.Encoded && batch.context.finished) {
677
+ this.#start_map(batch);
678
+ }
679
+ }
680
+
681
+ return delivered;
682
+ }
683
+
684
+ /**
685
+ * Record this frame's batch: a gather and one copy, or a handful of copies, or nothing at all.
686
+ *
687
+ * @param {import("../../../device/ShadeGPUCommandContext.js").ShadeGPUCommandContext} encoder
688
+ * @returns {boolean} whether anything was encoded
689
+ */
690
+ encode(encoder) {
691
+ if (this.#destroyed) {
692
+ return false;
693
+ }
694
+
695
+ const batch = this.#assembling;
696
+
697
+ if (batch.count === 0) {
698
+ // The point of the whole arrangement: a frame nobody asked anything of costs one
699
+ // comparison. No buffer is taken, no command is recorded.
700
+ return false;
701
+ }
702
+
703
+ if (this.#allocator === null) {
704
+ const allocator = encoder.graphics.buffer_allocator_readback;
705
+
706
+ assert.defined(allocator, 'encoder.graphics.buffer_allocator_readback');
707
+
708
+ this.#allocator = allocator;
709
+ }
710
+
711
+ if (this.#in_flight.length >= this.#max_in_flight) {
712
+ // The device has stopped answering. Refusing the frame's requests, with a status the
713
+ // consumer can see, bounds everything: nothing queues, nothing is re-resolved next
714
+ // frame, and no buffer is taken for bytes that would be a dozen frames stale.
715
+ this.#drop_pending(batch, true);
716
+ this.#retire(batch);
717
+
718
+ return false;
719
+ }
720
+
721
+ const live = this.#resolve(batch);
722
+
723
+ if (live === 0) {
724
+ // every row asked about has gone; nothing to copy and nothing to deliver
725
+ this.#retire(batch);
726
+
727
+ return false;
728
+ }
729
+
730
+ batch.buffer = this.#allocator.get(batch.byte_size);
731
+
732
+ if (live < this.#gather_threshold) {
733
+ this.#encode_copies(encoder, batch);
734
+ } else {
735
+ this.#encode_gather(encoder, batch);
736
+ }
737
+
738
+ batch.context = encoder;
739
+ batch.state = BatchState.Encoded;
740
+
741
+ this.#in_flight.push(batch);
742
+ this.#assembling = this.#take_batch();
743
+
744
+ return true;
745
+ }
746
+
747
+ /**
748
+ * Where each request's range starts in the database buffer and where it lands in the image,
749
+ * for every request whose row is there to be read. A request whose page is not resident, or
750
+ * whose row is not occupied, is dropped here: "the page was gone" is a fact about the moment
751
+ * the batch was encoded and cannot be recovered from the bytes afterwards.
752
+ *
753
+ * The same arithmetic {@link GPUDatabase#debug_table_read_element} does, and the same the gather
754
+ * shader does — the CPU needs it for the copy path, and the residency answer for both.
755
+ *
756
+ * One pass, in request order, so the image is packed in request order and a consumer's run of
757
+ * consecutive rows is one contiguous span of it. Requests cluster by table and by page, so the
758
+ * table and the page are looked up when they change rather than per request. Live requests are
759
+ * counted per table on the way through, which is all the gather path's bucketing needs.
760
+ *
761
+ * @param {GPUReadbackBatch} batch
762
+ * @returns {number} live requests
763
+ */
764
+ #resolve(batch) {
765
+ const database = this.#database;
766
+ const tables = database.tables;
767
+ const data_start = database.data_start_offset;
768
+
769
+ const records = this.#records;
770
+ const status = this.#status;
771
+ const handles = batch.handles;
772
+ const count = batch.count;
773
+
774
+ const starts = this.#table_starts;
775
+
776
+ starts.fill(0);
777
+
778
+ let destination = 0;
779
+ let live = 0;
780
+ let dropped = 0;
781
+
782
+ let table_index = -1;
783
+ let table = null;
784
+ let descriptor = null;
785
+ let elements_per_page = 0;
786
+ let record_words = 0;
787
+
788
+ let page_index = -1;
789
+ let page_base = -1;
790
+
791
+ for (let i = 0; i < count; i++) {
792
+ const handle = handles[i];
793
+ const base = handle * RECORD_WORDS;
794
+
795
+ const t = records[base + R_TABLE];
796
+ const row = records[base + R_ROW];
797
+
798
+ if (t !== table_index) {
799
+ table_index = t;
800
+ table = tables[t];
801
+ descriptor = table.descriptor;
802
+ elements_per_page = descriptor.elements_per_page;
803
+ record_words = descriptor.packed_element_size_bytes / WORD_SIZE;
804
+ page_index = -1;
805
+ }
806
+
807
+ const p = Math.floor(row / elements_per_page);
808
+
809
+ if (p !== page_index) {
810
+ page_index = p;
811
+
812
+ const page = table.pages.get(p);
813
+
814
+ page_base = (page === undefined || page.slot_offset === -1)
815
+ ? -1
816
+ : page.slot_offset + data_start + descriptor.page_header_words;
817
+ }
818
+
819
+ if (page_base === -1 || !table.occupancy.get(row)) {
820
+ // the page is not on the GPU, or the row was removed and its bytes are whatever the
821
+ // last occupant left
822
+ status[handle] = GPUReadbackStatus.Dropped;
823
+ dropped++;
824
+
825
+ continue;
826
+ }
827
+
828
+ records[base + R_SOURCE_WORD] = page_base
829
+ + (row - page_index * elements_per_page) * record_words
830
+ + records[base + R_WORD_OFFSET];
831
+ records[base + R_DESTINATION_WORD] = destination;
832
+
833
+ destination += records[base + R_WORD_COUNT];
834
+
835
+ live++;
836
+ starts[t + 1]++;
837
+ }
838
+
839
+ this.#dropped_count += dropped;
840
+
841
+ batch.live = live;
842
+ batch.byte_size = destination * WORD_SIZE;
843
+
844
+ return live;
845
+ }
846
+
847
+ /**
848
+ * Copy each range straight out of the database into its place in the image. No shader, no
849
+ * descriptor upload, no bind group — which below the threshold is cheaper than all three.
850
+ *
851
+ * @param {import("../../../device/ShadeGPUCommandContext.js").ShadeGPUCommandContext} encoder
852
+ * @param {GPUReadbackBatch} batch
853
+ */
854
+ #encode_copies(encoder, batch) {
855
+ const source = this.#database.buffer;
856
+ const destination = batch.buffer;
857
+
858
+ const records = this.#records;
859
+ const status = this.#status;
860
+ const handles = batch.handles;
861
+ const count = batch.count;
862
+
863
+ let copies = 0;
864
+
865
+ for (let i = 0; i < count; i++) {
866
+ const handle = handles[i];
867
+
868
+ if (status[handle] !== GPUReadbackStatus.Pending) {
869
+ continue;
870
+ }
871
+
872
+ const base = handle * RECORD_WORDS;
873
+
874
+ encoder.copyBufferToBuffer(
875
+ source,
876
+ records[base + R_SOURCE_WORD] * WORD_SIZE,
877
+ destination,
878
+ records[base + R_DESTINATION_WORD] * WORD_SIZE,
879
+ records[base + R_WORD_COUNT] * WORD_SIZE,
880
+ );
881
+
882
+ copies++;
883
+ }
884
+
885
+ this.#copies_encoded += copies;
886
+ }
887
+
888
+ /**
889
+ * Pack every range into the scratch buffer with one dispatch per table, then copy the whole
890
+ * image across in one go.
891
+ *
892
+ * One dispatch per table rather than one for the batch, because the page geometry a thread needs
893
+ * — record size, elements per page, where the table's page addresses live — is per table, and
894
+ * carrying it per descriptor would cost more words than the descriptor has.
895
+ *
896
+ * The live handles are bucketed by table with a counting sort off the per-table counts
897
+ * {@link #resolve} left behind: one pass to scatter, then each table's run is emitted in turn.
898
+ * Linear in the requests plus the tables, where scanning every request once per table was
899
+ * their product.
900
+ *
901
+ * @param {import("../../../device/ShadeGPUCommandContext.js").ShadeGPUCommandContext} encoder
902
+ * @param {GPUReadbackBatch} batch
903
+ */
904
+ #encode_gather(encoder, batch) {
905
+ const live = batch.live;
906
+ const byte_size = batch.byte_size;
907
+
908
+ const gather_buffer = this.#fit_gather_buffer(byte_size);
909
+
910
+ const tables = this.#database.tables;
911
+ const table_count = tables.length;
912
+
913
+ const records = this.#records;
914
+ const status = this.#status;
915
+ const handles = batch.handles;
916
+ const count = batch.count;
917
+
918
+ // counts to starts
919
+ const starts = this.#table_starts;
920
+
921
+ for (let t = 1; t <= table_count; t++) {
922
+ starts[t] += starts[t - 1];
923
+ }
924
+
925
+ if (batch.order.length < live) {
926
+ batch.order = new Uint32Array(Math.max(live, batch.order.length * 2));
927
+ }
928
+
929
+ const order = batch.order;
930
+
931
+ // scatter, in request order within each table; afterwards starts[t] is the end of table t
932
+ for (let i = 0; i < count; i++) {
933
+ const handle = handles[i];
934
+
935
+ if (status[handle] !== GPUReadbackStatus.Pending) {
936
+ continue;
937
+ }
938
+
939
+ order[starts[records[handle * RECORD_WORDS + R_TABLE]]++] = handle;
940
+ }
941
+
942
+ const descriptor_stride = GPU_TABLE_GATHER_DESCRIPTOR_WORDS;
943
+ const max_per_chunk = Math.max(1, Math.floor(DESCRIPTOR_CHUNK_BYTES / (descriptor_stride * WORD_SIZE)));
944
+
945
+ const scratch_words = Math.min(live, max_per_chunk) * descriptor_stride;
946
+
947
+ if (this.#descriptor_scratch.length < scratch_words) {
948
+ this.#descriptor_scratch = new Uint32Array(scratch_words);
949
+ }
950
+
951
+ const scratch = this.#descriptor_scratch;
952
+ const settings = this.#gather_settings;
953
+
954
+ let run_start = 0;
955
+
956
+ for (let t = 0; t < table_count; t++) {
957
+ const run_end = starts[t];
958
+
959
+ if (run_end === run_start) {
960
+ continue;
961
+ }
962
+
963
+ const table_descriptor = tables[t].descriptor;
964
+
965
+ settings.record_size = table_descriptor.packed_element_size_bytes / WORD_SIZE;
966
+ settings.elements_per_page = table_descriptor.elements_per_page;
967
+ settings.page_lookup_address = table_descriptor.page_lookup_address;
968
+ settings.page_header_words = table_descriptor.page_header_words;
969
+ settings.page_limit = table_descriptor.page_limit;
970
+
971
+ let filled = 0;
972
+
973
+ for (let i = run_start; i < run_end; i++) {
974
+ const base = order[i] * RECORD_WORDS;
975
+ const d = filled * descriptor_stride;
976
+
977
+ scratch[d] = records[base + R_ROW];
978
+ scratch[d + 1] = records[base + R_WORD_OFFSET];
979
+ scratch[d + 2] = records[base + R_WORD_COUNT];
980
+ scratch[d + 3] = records[base + R_DESTINATION_WORD];
981
+
982
+ filled++;
983
+
984
+ if (filled === max_per_chunk) {
985
+ this.#dispatch_gather(encoder, scratch, filled, settings, gather_buffer);
986
+ filled = 0;
987
+ }
988
+ }
989
+
990
+ if (filled > 0) {
991
+ this.#dispatch_gather(encoder, scratch, filled, settings, gather_buffer);
992
+ }
993
+
994
+ run_start = run_end;
995
+ }
996
+
997
+ encoder.copyBufferToBuffer(gather_buffer, 0, batch.buffer, 0, byte_size);
998
+
999
+ this.#copies_encoded++;
1000
+ }
1001
+
1002
+ /**
1003
+ * @param {import("../../../device/ShadeGPUCommandContext.js").ShadeGPUCommandContext} encoder
1004
+ * @param {Uint32Array} scratch
1005
+ * @param {number} count
1006
+ * @param {Object} settings
1007
+ * @param {GPUBuffer} gather_buffer
1008
+ */
1009
+ #dispatch_gather(encoder, scratch, count, settings, gather_buffer) {
1010
+ settings.count = count;
1011
+
1012
+ const descriptors = encoder.allocateTransientBufferAndLoad(
1013
+ scratch.buffer,
1014
+ GPUBufferUsage.STORAGE,
1015
+ 0,
1016
+ count * GPU_TABLE_GATHER_DESCRIPTOR_WORDS * WORD_SIZE,
1017
+ );
1018
+
1019
+ gpu_table_gather_shader.dispatchThreads({
1020
+ encoder,
1021
+ bindings: {
1022
+ settings,
1023
+ descriptors,
1024
+ database: this.#database.buffer,
1025
+ gathered: gather_buffer,
1026
+ },
1027
+ thread_count_x: count,
1028
+ });
1029
+
1030
+ this.#dispatches_encoded++;
1031
+ }
1032
+
1033
+ /**
1034
+ * @param {number} byte_size
1035
+ * @returns {GPUBuffer}
1036
+ */
1037
+ #fit_gather_buffer(byte_size) {
1038
+ const existing = this.#gather_buffer;
1039
+
1040
+ if (existing !== null && existing.size >= byte_size) {
1041
+ return existing;
1042
+ }
1043
+
1044
+ if (existing !== null) {
1045
+ existing.destroy();
1046
+ }
1047
+
1048
+ const buffer = this.#device.createBuffer({
1049
+ label: 'GPUDatabaseReadback/gather',
1050
+ size: round_up(byte_size, GATHER_SIZE_GRANULARITY),
1051
+ usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
1052
+ mappedAtCreation: false,
1053
+ });
1054
+
1055
+ this.#gather_buffer = buffer;
1056
+
1057
+ return buffer;
1058
+ }
1059
+
1060
+ /**
1061
+ * @param {GPUReadbackBatch} batch
1062
+ */
1063
+ #start_map(batch) {
1064
+ batch.state = BatchState.Mapping;
1065
+
1066
+ batch.buffer.mapAsync(GPUMapMode.READ, 0, batch.byte_size).then(batch.on_mapped, batch.on_failed);
1067
+ }
1068
+
1069
+ /**
1070
+ * Copy a mapped batch into its targets.
1071
+ *
1072
+ * The image is packed in request order, so consecutive live requests are consecutive in it;
1073
+ * when they also name consecutive bytes of one target, the run is one `set`. A consumer that
1074
+ * asks for a hundred rows into one array gets one copy, not a hundred.
1075
+ *
1076
+ * @param {GPUReadbackBatch} batch
1077
+ * @returns {number} requests delivered
1078
+ */
1079
+ #deliver(batch) {
1080
+ const records = this.#records;
1081
+ const status = this.#status;
1082
+ const targets = this.#targets;
1083
+ const tables = this.#database.tables;
1084
+
1085
+ const bytes = batch.bytes;
1086
+ const handles = batch.handles;
1087
+ const count = batch.count;
1088
+
1089
+ let delivered = 0;
1090
+ let dropped = 0;
1091
+
1092
+ let run_target = null;
1093
+ let run_source = 0;
1094
+ let run_target_offset = 0;
1095
+ let run_length = 0;
1096
+
1097
+ for (let i = 0; i < count; i++) {
1098
+ const handle = handles[i];
1099
+
1100
+ if (status[handle] !== GPUReadbackStatus.Pending) {
1101
+ // dropped at encode; it has no bytes in the image
1102
+ continue;
1103
+ }
1104
+
1105
+ const base = handle * RECORD_WORDS;
1106
+ const row = records[base + R_ROW];
1107
+
1108
+ if (tables[records[base + R_TABLE]].generation_of(row) !== records[base + R_GENERATION]) {
1109
+ // the row was freed while this was in flight, and an id freed is an id already
1110
+ // handed out again — answering would be answering about a stranger
1111
+ status[handle] = GPUReadbackStatus.Dropped;
1112
+ dropped++;
1113
+
1114
+ continue;
1115
+ }
1116
+
1117
+ const source = records[base + R_DESTINATION_WORD] * WORD_SIZE;
1118
+ const length = records[base + R_WORD_COUNT] * WORD_SIZE;
1119
+ const target = targets[handle];
1120
+ const target_offset = records[base + R_TARGET_OFFSET];
1121
+
1122
+ if (
1123
+ target === run_target
1124
+ && target_offset === run_target_offset + run_length
1125
+ && source === run_source + run_length
1126
+ ) {
1127
+ run_length += length;
1128
+ } else {
1129
+ if (run_length > 0) {
1130
+ run_target.set(bytes.subarray(run_source, run_source + run_length), run_target_offset);
1131
+ }
1132
+
1133
+ run_target = target;
1134
+ run_source = source;
1135
+ run_target_offset = target_offset;
1136
+ run_length = length;
1137
+ }
1138
+
1139
+ status[handle] = GPUReadbackStatus.Delivered;
1140
+ delivered++;
1141
+ }
1142
+
1143
+ if (run_length > 0) {
1144
+ run_target.set(bytes.subarray(run_source, run_source + run_length), run_target_offset);
1145
+ }
1146
+
1147
+ this.#delivered_count += delivered;
1148
+ this.#dropped_count += dropped;
1149
+
1150
+ return delivered;
1151
+ }
1152
+
1153
+ /**
1154
+ * Mark every request of a batch still waiting as dropped.
1155
+ *
1156
+ * @param {GPUReadbackBatch} batch
1157
+ * @param {boolean} stalled whether the pipeline, rather than the rows, is the reason
1158
+ */
1159
+ #drop_pending(batch, stalled) {
1160
+ const status = this.#status;
1161
+ const handles = batch.handles;
1162
+ const count = batch.count;
1163
+
1164
+ let dropped = 0;
1165
+
1166
+ for (let i = 0; i < count; i++) {
1167
+ const handle = handles[i];
1168
+
1169
+ if (status[handle] === GPUReadbackStatus.Pending) {
1170
+ status[handle] = GPUReadbackStatus.Dropped;
1171
+ dropped++;
1172
+ }
1173
+ }
1174
+
1175
+ if (stalled) {
1176
+ this.#stalled_count += dropped;
1177
+ } else {
1178
+ this.#dropped_count += dropped;
1179
+ }
1180
+ }
1181
+
1182
+ /**
1183
+ * Send the assembling batch straight to retiring — nothing of it is in flight — and take a
1184
+ * fresh one for the requests that follow.
1185
+ *
1186
+ * @param {GPUReadbackBatch} batch
1187
+ */
1188
+ #retire(batch) {
1189
+ this.#retiring.push(batch);
1190
+ this.#assembling = this.#take_batch();
1191
+ }
1192
+
1193
+ /**
1194
+ * Free a retired batch's handles and put the batch back in the pool.
1195
+ *
1196
+ * @param {GPUReadbackBatch} batch
1197
+ */
1198
+ #recycle(batch) {
1199
+ const status = this.#status;
1200
+ const targets = this.#targets;
1201
+ const free = this.#free;
1202
+ const handles = batch.handles;
1203
+ const count = batch.count;
1204
+
1205
+ let free_count = this.#free_count;
1206
+
1207
+ for (let i = 0; i < count; i++) {
1208
+ const handle = handles[i];
1209
+
1210
+ status[handle] = GPUReadbackStatus.None;
1211
+ targets[handle] = null;
1212
+
1213
+ free[free_count++] = handle;
1214
+ }
1215
+
1216
+ this.#free_count = free_count;
1217
+
1218
+ batch.count = 0;
1219
+ batch.live = 0;
1220
+ batch.byte_size = 0;
1221
+ batch.state = BatchState.Assembling;
1222
+
1223
+ this.#spare.push(batch);
1224
+ }
1225
+
1226
+ /**
1227
+ * @returns {GPUReadbackBatch}
1228
+ */
1229
+ #take_batch() {
1230
+ const spare = this.#spare;
1231
+
1232
+ if (spare.length > 0) {
1233
+ return spare.pop();
1234
+ }
1235
+
1236
+ return this.#make_batch();
1237
+ }
1238
+
1239
+ /**
1240
+ * @returns {GPUReadbackBatch}
1241
+ */
1242
+ #make_batch() {
1243
+ const batch = new GPUReadbackBatch();
1244
+
1245
+ batch.on_mapped = () => {
1246
+ if (this.#destroyed || batch.state !== BatchState.Mapping) {
1247
+ // torn down while the map was out; the buffer went with it
1248
+ return;
1249
+ }
1250
+
1251
+ batch.bytes = new Uint8Array(batch.buffer.getMappedRange(0, batch.byte_size));
1252
+ batch.state = BatchState.Ready;
1253
+ };
1254
+
1255
+ batch.on_failed = () => {
1256
+ if (batch.state === BatchState.Mapping) {
1257
+ // device lost, buffer destroyed — discarded at the next apply point
1258
+ batch.state = BatchState.Failed;
1259
+ }
1260
+ };
1261
+
1262
+ return batch;
1263
+ }
1264
+
1265
+ /**
1266
+ * @returns {number}
1267
+ */
1268
+ #allocate_handle() {
1269
+ if (this.#free_count > 0) {
1270
+ return this.#free[--this.#free_count];
1271
+ }
1272
+
1273
+ if (this.#fresh === this.#status.length) {
1274
+ this.#grow_handles();
1275
+ }
1276
+
1277
+ return this.#fresh++;
1278
+ }
1279
+
1280
+ /**
1281
+ * Double the handle space. Handles are indices, so nothing moves; a caller keeps the ones it
1282
+ * has.
1283
+ */
1284
+ #grow_handles() {
1285
+ const capacity = this.#status.length * 2;
1286
+
1287
+ const records = new Uint32Array(capacity * RECORD_WORDS);
1288
+ records.set(this.#records);
1289
+ this.#records = records;
1290
+
1291
+ const status = new Uint8Array(capacity);
1292
+ status.set(this.#status);
1293
+ this.#status = status;
1294
+
1295
+ const free = new Uint32Array(capacity);
1296
+ free.set(this.#free);
1297
+ this.#free = free;
1298
+
1299
+ const targets = this.#targets;
1300
+
1301
+ for (let i = targets.length; i < capacity; i++) {
1302
+ targets.push(null);
1303
+ }
1304
+ }
1305
+
1306
+ destroy() {
1307
+ this.#destroyed = true;
1308
+
1309
+ const in_flight = this.#in_flight;
1310
+
1311
+ for (let i = 0; i < in_flight.length; i++) {
1312
+ const batch = in_flight[i];
1313
+
1314
+ if (batch.buffer !== null) {
1315
+ // may be mid-map, which WebGPU lets destroy() abort but not unmap()
1316
+ this.#allocator.discard(batch.buffer);
1317
+
1318
+ batch.buffer = null;
1319
+ }
1320
+ }
1321
+
1322
+ in_flight.length = 0;
1323
+ this.#retiring.length = 0;
1324
+ this.#spare.length = 0;
1325
+ this.#assembling.count = 0;
1326
+
1327
+ if (this.#gather_buffer !== null) {
1328
+ this.#gather_buffer.destroy();
1329
+ this.#gather_buffer = null;
1330
+ }
1331
+ }
1332
+ }