@pmndrs/vdb 0.0.0-stage → 0.1.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 (390) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/LICENSE +21 -0
  3. package/README.md +448 -2
  4. package/THIRD_PARTY_NOTICES.md +147 -0
  5. package/dist/core/compute/atlas.d.ts +94 -0
  6. package/dist/core/compute/atlas.js +98 -0
  7. package/dist/core/compute/atlas.js.map +1 -0
  8. package/dist/core/compute/index.d.ts +13 -0
  9. package/dist/core/compute/index.js +9 -0
  10. package/dist/core/compute/index.js.map +1 -0
  11. package/dist/core/compute/pyramid.d.ts +105 -0
  12. package/dist/core/compute/pyramid.js +455 -0
  13. package/dist/core/compute/pyramid.js.map +1 -0
  14. package/dist/core/compute/shared.d.ts +115 -0
  15. package/dist/core/compute/shared.js +211 -0
  16. package/dist/core/compute/shared.js.map +1 -0
  17. package/dist/core/compute/stats.d.ts +71 -0
  18. package/dist/core/compute/stats.js +188 -0
  19. package/dist/core/compute/stats.js.map +1 -0
  20. package/dist/core/compute/value-transform.d.ts +23 -0
  21. package/dist/core/compute/value-transform.js +58 -0
  22. package/dist/core/compute/value-transform.js.map +1 -0
  23. package/dist/core/errors.d.ts +11 -0
  24. package/dist/core/errors.js +9 -0
  25. package/dist/core/errors.js.map +1 -0
  26. package/dist/core/index.d.ts +30 -0
  27. package/dist/core/index.js +27 -0
  28. package/dist/core/index.js.map +1 -0
  29. package/dist/core/internal.d.ts +15 -0
  30. package/dist/core/internal.js +15 -0
  31. package/dist/core/internal.js.map +1 -0
  32. package/dist/core/pool/affine.d.ts +34 -0
  33. package/dist/core/pool/affine.js +100 -0
  34. package/dist/core/pool/affine.js.map +1 -0
  35. package/dist/core/pool/allocator.d.ts +32 -0
  36. package/dist/core/pool/allocator.js +81 -0
  37. package/dist/core/pool/allocator.js.map +1 -0
  38. package/dist/core/pool/image-header.d.ts +82 -0
  39. package/dist/core/pool/image-header.js +175 -0
  40. package/dist/core/pool/image-header.js.map +1 -0
  41. package/dist/core/pool/layout.d.ts +164 -0
  42. package/dist/core/pool/layout.js +267 -0
  43. package/dist/core/pool/layout.js.map +1 -0
  44. package/dist/core/pool/limits.d.ts +40 -0
  45. package/dist/core/pool/limits.js +79 -0
  46. package/dist/core/pool/limits.js.map +1 -0
  47. package/dist/core/pool/pool.d.ts +279 -0
  48. package/dist/core/pool/pool.js +953 -0
  49. package/dist/core/pool/pool.js.map +1 -0
  50. package/dist/core/source/dense.d.ts +19 -0
  51. package/dist/core/source/dense.js +287 -0
  52. package/dist/core/source/dense.js.map +1 -0
  53. package/dist/core/source/types.d.ts +63 -0
  54. package/dist/core/source/types.js +9 -0
  55. package/dist/core/source/types.js.map +1 -0
  56. package/dist/core/types.d.ts +28 -0
  57. package/dist/core/types.js +28 -0
  58. package/dist/core/types.js.map +1 -0
  59. package/dist/core/wgsl/api.d.ts +41 -0
  60. package/dist/core/wgsl/api.js +463 -0
  61. package/dist/core/wgsl/api.js.map +1 -0
  62. package/dist/core/wgsl/generate.d.ts +82 -0
  63. package/dist/core/wgsl/generate.js +505 -0
  64. package/dist/core/wgsl/generate.js.map +1 -0
  65. package/dist/core/wgsl/level-set.d.ts +54 -0
  66. package/dist/core/wgsl/level-set.js +194 -0
  67. package/dist/core/wgsl/level-set.js.map +1 -0
  68. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
  69. package/dist/core/wgsl/pnanovdb.chunks.generated.js +330 -0
  70. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
  71. package/dist/core/wgsl/reserved.d.ts +9 -0
  72. package/dist/core/wgsl/reserved.js +26 -0
  73. package/dist/core/wgsl/reserved.js.map +1 -0
  74. package/dist/core/wgsl/types.d.ts +104 -0
  75. package/dist/core/wgsl/types.js +2 -0
  76. package/dist/core/wgsl/types.js.map +1 -0
  77. package/dist/three/coarse-first.d.ts +162 -0
  78. package/dist/three/coarse-first.js +187 -0
  79. package/dist/three/coarse-first.js.map +1 -0
  80. package/dist/three/compute.d.ts +63 -0
  81. package/dist/three/compute.js +56 -0
  82. package/dist/three/compute.js.map +1 -0
  83. package/dist/three/device.d.ts +59 -0
  84. package/dist/three/device.js +59 -0
  85. package/dist/three/device.js.map +1 -0
  86. package/dist/three/frame/blackbody.d.ts +42 -0
  87. package/dist/three/frame/blackbody.js +74 -0
  88. package/dist/three/frame/blackbody.js.map +1 -0
  89. package/dist/three/frame/chunks.d.ts +157 -0
  90. package/dist/three/frame/chunks.js +559 -0
  91. package/dist/three/frame/chunks.js.map +1 -0
  92. package/dist/three/frame/density-material.d.ts +53 -0
  93. package/dist/three/frame/density-material.js +353 -0
  94. package/dist/three/frame/density-material.js.map +1 -0
  95. package/dist/three/frame/emission-light.d.ts +167 -0
  96. package/dist/three/frame/emission-light.js +655 -0
  97. package/dist/three/frame/emission-light.js.map +1 -0
  98. package/dist/three/frame/environment-grid-material.d.ts +21 -0
  99. package/dist/three/frame/environment-grid-material.js +184 -0
  100. package/dist/three/frame/environment-grid-material.js.map +1 -0
  101. package/dist/three/frame/environment-material.d.ts +22 -0
  102. package/dist/three/frame/environment-material.js +87 -0
  103. package/dist/three/frame/environment-material.js.map +1 -0
  104. package/dist/three/frame/grid-mip-material.d.ts +12 -0
  105. package/dist/three/frame/grid-mip-material.js +61 -0
  106. package/dist/three/frame/grid-mip-material.js.map +1 -0
  107. package/dist/three/frame/index.d.ts +39 -0
  108. package/dist/three/frame/index.js +35 -0
  109. package/dist/three/frame/index.js.map +1 -0
  110. package/dist/three/frame/inject-material.d.ts +56 -0
  111. package/dist/three/frame/inject-material.js +424 -0
  112. package/dist/three/frame/inject-material.js.map +1 -0
  113. package/dist/three/frame/integrate-material.d.ts +26 -0
  114. package/dist/three/frame/integrate-material.js +198 -0
  115. package/dist/three/frame/integrate-material.js.map +1 -0
  116. package/dist/three/frame/layout.d.ts +34 -0
  117. package/dist/three/frame/layout.js +48 -0
  118. package/dist/three/frame/layout.js.map +1 -0
  119. package/dist/three/frame/lighting-material.d.ts +41 -0
  120. package/dist/three/frame/lighting-material.js +257 -0
  121. package/dist/three/frame/lighting-material.js.map +1 -0
  122. package/dist/three/frame/lights.d.ts +11 -0
  123. package/dist/three/frame/lights.js +16 -0
  124. package/dist/three/frame/lights.js.map +1 -0
  125. package/dist/three/frame/medium.d.ts +21 -0
  126. package/dist/three/frame/medium.js +29 -0
  127. package/dist/three/frame/medium.js.map +1 -0
  128. package/dist/three/frame/neural.d.ts +14 -0
  129. package/dist/three/frame/neural.js +105 -0
  130. package/dist/three/frame/neural.js.map +1 -0
  131. package/dist/three/frame/phase.d.ts +44 -0
  132. package/dist/three/frame/phase.js +80 -0
  133. package/dist/three/frame/phase.js.map +1 -0
  134. package/dist/three/frame/renderer.d.ts +493 -0
  135. package/dist/three/frame/renderer.js +1498 -0
  136. package/dist/three/frame/renderer.js.map +1 -0
  137. package/dist/three/frame/shadow-density-material.d.ts +30 -0
  138. package/dist/three/frame/shadow-density-material.js +123 -0
  139. package/dist/three/frame/shadow-density-material.js.map +1 -0
  140. package/dist/three/frame/spectrum.d.ts +18 -0
  141. package/dist/three/frame/spectrum.js +36 -0
  142. package/dist/three/frame/spectrum.js.map +1 -0
  143. package/dist/three/frame/temporal-material.d.ts +29 -0
  144. package/dist/three/frame/temporal-material.js +152 -0
  145. package/dist/three/frame/temporal-material.js.map +1 -0
  146. package/dist/three/frame/three-internals.d.ts +65 -0
  147. package/dist/three/frame/three-internals.js +150 -0
  148. package/dist/three/frame/three-internals.js.map +1 -0
  149. package/dist/three/frame/transmittance-material.d.ts +31 -0
  150. package/dist/three/frame/transmittance-material.js +315 -0
  151. package/dist/three/frame/transmittance-material.js.map +1 -0
  152. package/dist/three/frame/view.d.ts +103 -0
  153. package/dist/three/frame/view.js +296 -0
  154. package/dist/three/frame/view.js.map +1 -0
  155. package/dist/three/frame/volume-shadow-material.d.ts +36 -0
  156. package/dist/three/frame/volume-shadow-material.js +128 -0
  157. package/dist/three/frame/volume-shadow-material.js.map +1 -0
  158. package/dist/three/frame/volume-shadows.d.ts +153 -0
  159. package/dist/three/frame/volume-shadows.js +756 -0
  160. package/dist/three/frame/volume-shadows.js.map +1 -0
  161. package/dist/three/frame/volume.d.ts +172 -0
  162. package/dist/three/frame/volume.js +256 -0
  163. package/dist/three/frame/volume.js.map +1 -0
  164. package/dist/three/grid-node.d.ts +196 -0
  165. package/dist/three/grid-node.js +510 -0
  166. package/dist/three/grid-node.js.map +1 -0
  167. package/dist/three/index.d.ts +43 -0
  168. package/dist/three/index.js +49 -0
  169. package/dist/three/index.js.map +1 -0
  170. package/dist/three/internal.d.ts +14 -0
  171. package/dist/three/internal.js +14 -0
  172. package/dist/three/internal.js.map +1 -0
  173. package/dist/three/level-set-material.d.ts +112 -0
  174. package/dist/three/level-set-material.js +204 -0
  175. package/dist/three/level-set-material.js.map +1 -0
  176. package/dist/three/material.d.ts +194 -0
  177. package/dist/three/material.js +359 -0
  178. package/dist/three/material.js.map +1 -0
  179. package/dist/three/points.d.ts +84 -0
  180. package/dist/three/points.js +130 -0
  181. package/dist/three/points.js.map +1 -0
  182. package/dist/three/sequence.d.ts +317 -0
  183. package/dist/three/sequence.js +526 -0
  184. package/dist/three/sequence.js.map +1 -0
  185. package/dist/three/sparse-source.d.ts +233 -0
  186. package/dist/three/sparse-source.js +876 -0
  187. package/dist/three/sparse-source.js.map +1 -0
  188. package/dist/three/volume-source.d.ts +167 -0
  189. package/dist/three/volume-source.js +353 -0
  190. package/dist/three/volume-source.js.map +1 -0
  191. package/dist/tools/cpu/compute.d.ts +97 -0
  192. package/dist/tools/cpu/compute.js +218 -0
  193. package/dist/tools/cpu/compute.js.map +1 -0
  194. package/dist/tools/cpu/level-set.d.ts +72 -0
  195. package/dist/tools/cpu/level-set.js +261 -0
  196. package/dist/tools/cpu/level-set.js.map +1 -0
  197. package/dist/tools/cpu/march.d.ts +206 -0
  198. package/dist/tools/cpu/march.js +575 -0
  199. package/dist/tools/cpu/march.js.map +1 -0
  200. package/dist/tools/cpu/probe-coords.d.ts +70 -0
  201. package/dist/tools/cpu/probe-coords.js +116 -0
  202. package/dist/tools/cpu/probe-coords.js.map +1 -0
  203. package/dist/tools/cpu/read-value.d.ts +31 -0
  204. package/dist/tools/cpu/read-value.js +336 -0
  205. package/dist/tools/cpu/read-value.js.map +1 -0
  206. package/dist/tools/cpu/sample-trilinear.d.ts +30 -0
  207. package/dist/tools/cpu/sample-trilinear.js +156 -0
  208. package/dist/tools/cpu/sample-trilinear.js.map +1 -0
  209. package/dist/tools/cpu/stride-tables.d.ts +56 -0
  210. package/dist/tools/cpu/stride-tables.generated.d.ts +1058 -0
  211. package/dist/tools/cpu/stride-tables.generated.js +1266 -0
  212. package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
  213. package/dist/tools/cpu/stride-tables.js +78 -0
  214. package/dist/tools/cpu/stride-tables.js.map +1 -0
  215. package/dist/tools/errors.d.ts +57 -0
  216. package/dist/tools/errors.js +58 -0
  217. package/dist/tools/errors.js.map +1 -0
  218. package/dist/tools/frame/blackbody.d.ts +42 -0
  219. package/dist/tools/frame/blackbody.js +116 -0
  220. package/dist/tools/frame/blackbody.js.map +1 -0
  221. package/dist/tools/frame/emission.d.ts +128 -0
  222. package/dist/tools/frame/emission.js +282 -0
  223. package/dist/tools/frame/emission.js.map +1 -0
  224. package/dist/tools/frame/environment.d.ts +105 -0
  225. package/dist/tools/frame/environment.js +268 -0
  226. package/dist/tools/frame/environment.js.map +1 -0
  227. package/dist/tools/frame/grid.d.ts +302 -0
  228. package/dist/tools/frame/grid.js +703 -0
  229. package/dist/tools/frame/grid.js.map +1 -0
  230. package/dist/tools/frame/index.d.ts +136 -0
  231. package/dist/tools/frame/index.js +348 -0
  232. package/dist/tools/frame/index.js.map +1 -0
  233. package/dist/tools/frame/medium.d.ts +61 -0
  234. package/dist/tools/frame/medium.js +99 -0
  235. package/dist/tools/frame/medium.js.map +1 -0
  236. package/dist/tools/frame/mie-table.d.ts +6 -0
  237. package/dist/tools/frame/mie-table.js +16 -0
  238. package/dist/tools/frame/mie-table.js.map +1 -0
  239. package/dist/tools/frame/mie.d.ts +54 -0
  240. package/dist/tools/frame/mie.js +176 -0
  241. package/dist/tools/frame/mie.js.map +1 -0
  242. package/dist/tools/frame/neural-weights.d.ts +9 -0
  243. package/dist/tools/frame/neural-weights.js +245 -0
  244. package/dist/tools/frame/neural-weights.js.map +1 -0
  245. package/dist/tools/frame/neural.d.ts +80 -0
  246. package/dist/tools/frame/neural.js +150 -0
  247. package/dist/tools/frame/neural.js.map +1 -0
  248. package/dist/tools/frame/pyramid-layout.d.ts +38 -0
  249. package/dist/tools/frame/pyramid-layout.js +53 -0
  250. package/dist/tools/frame/pyramid-layout.js.map +1 -0
  251. package/dist/tools/frame/shadows.d.ts +80 -0
  252. package/dist/tools/frame/shadows.js +182 -0
  253. package/dist/tools/frame/shadows.js.map +1 -0
  254. package/dist/tools/frame/sparse.d.ts +65 -0
  255. package/dist/tools/frame/sparse.js +191 -0
  256. package/dist/tools/frame/sparse.js.map +1 -0
  257. package/dist/tools/frame/spectral.d.ts +203 -0
  258. package/dist/tools/frame/spectral.js +550 -0
  259. package/dist/tools/frame/spectral.js.map +1 -0
  260. package/dist/tools/index.d.ts +106 -0
  261. package/dist/tools/index.js +88 -0
  262. package/dist/tools/index.js.map +1 -0
  263. package/dist/tools/internal.d.ts +46 -0
  264. package/dist/tools/internal.js +31 -0
  265. package/dist/tools/internal.js.map +1 -0
  266. package/dist/tools/nanovdb/build-from-vdb.d.ts +50 -0
  267. package/dist/tools/nanovdb/build-from-vdb.js +92 -0
  268. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
  269. package/dist/tools/nanovdb/bytes.d.ts +220 -0
  270. package/dist/tools/nanovdb/bytes.js +345 -0
  271. package/dist/tools/nanovdb/bytes.js.map +1 -0
  272. package/dist/tools/nanovdb/coarse-first.d.ts +62 -0
  273. package/dist/tools/nanovdb/coarse-first.js +86 -0
  274. package/dist/tools/nanovdb/coarse-first.js.map +1 -0
  275. package/dist/tools/nanovdb/index.d.ts +32 -0
  276. package/dist/tools/nanovdb/index.js +24 -0
  277. package/dist/tools/nanovdb/index.js.map +1 -0
  278. package/dist/tools/nanovdb/inspect.d.ts +24 -0
  279. package/dist/tools/nanovdb/inspect.js +63 -0
  280. package/dist/tools/nanovdb/inspect.js.map +1 -0
  281. package/dist/tools/nanovdb/leaf-codec.d.ts +85 -0
  282. package/dist/tools/nanovdb/leaf-codec.js +320 -0
  283. package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
  284. package/dist/tools/nanovdb/quantize.d.ts +43 -0
  285. package/dist/tools/nanovdb/quantize.js +277 -0
  286. package/dist/tools/nanovdb/quantize.js.map +1 -0
  287. package/dist/tools/nanovdb/resample.d.ts +160 -0
  288. package/dist/tools/nanovdb/resample.js +679 -0
  289. package/dist/tools/nanovdb/resample.js.map +1 -0
  290. package/dist/tools/nanovdb/serialize.d.ts +145 -0
  291. package/dist/tools/nanovdb/serialize.js +395 -0
  292. package/dist/tools/nanovdb/serialize.js.map +1 -0
  293. package/dist/tools/nanovdb/stats.d.ts +58 -0
  294. package/dist/tools/nanovdb/stats.js +149 -0
  295. package/dist/tools/nanovdb/stats.js.map +1 -0
  296. package/dist/tools/nanovdb/transform.d.ts +26 -0
  297. package/dist/tools/nanovdb/transform.js +91 -0
  298. package/dist/tools/nanovdb/transform.js.map +1 -0
  299. package/dist/tools/nanovdb/tree.d.ts +175 -0
  300. package/dist/tools/nanovdb/tree.js +518 -0
  301. package/dist/tools/nanovdb/tree.js.map +1 -0
  302. package/dist/tools/nanovdb/write-nvdb.d.ts +39 -0
  303. package/dist/tools/nanovdb/write-nvdb.js +210 -0
  304. package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
  305. package/dist/tools/nvdb-file.d.ts +195 -0
  306. package/dist/tools/nvdb-file.js +606 -0
  307. package/dist/tools/nvdb-file.js.map +1 -0
  308. package/dist/tools/nvdb-stream.d.ts +138 -0
  309. package/dist/tools/nvdb-stream.js +365 -0
  310. package/dist/tools/nvdb-stream.js.map +1 -0
  311. package/dist/tools/vdb/bit-utils.d.ts +20 -0
  312. package/dist/tools/vdb/bit-utils.js +42 -0
  313. package/dist/tools/vdb/bit-utils.js.map +1 -0
  314. package/dist/tools/vdb/blosc.d.ts +56 -0
  315. package/dist/tools/vdb/blosc.js +231 -0
  316. package/dist/tools/vdb/blosc.js.map +1 -0
  317. package/dist/tools/vdb/byte-reader.d.ts +40 -0
  318. package/dist/tools/vdb/byte-reader.js +139 -0
  319. package/dist/tools/vdb/byte-reader.js.map +1 -0
  320. package/dist/tools/vdb/compression.d.ts +73 -0
  321. package/dist/tools/vdb/compression.js +249 -0
  322. package/dist/tools/vdb/compression.js.map +1 -0
  323. package/dist/tools/vdb/errors.d.ts +10 -0
  324. package/dist/tools/vdb/errors.js +11 -0
  325. package/dist/tools/vdb/errors.js.map +1 -0
  326. package/dist/tools/vdb/grid.d.ts +37 -0
  327. package/dist/tools/vdb/grid.js +147 -0
  328. package/dist/tools/vdb/grid.js.map +1 -0
  329. package/dist/tools/vdb/half-float.d.ts +9 -0
  330. package/dist/tools/vdb/half-float.js +24 -0
  331. package/dist/tools/vdb/half-float.js.map +1 -0
  332. package/dist/tools/vdb/index.d.ts +3 -0
  333. package/dist/tools/vdb/index.js +3 -0
  334. package/dist/tools/vdb/index.js.map +1 -0
  335. package/dist/tools/vdb/inflate.d.ts +24 -0
  336. package/dist/tools/vdb/inflate.js +334 -0
  337. package/dist/tools/vdb/inflate.js.map +1 -0
  338. package/dist/tools/vdb/metadata.d.ts +17 -0
  339. package/dist/tools/vdb/metadata.js +72 -0
  340. package/dist/tools/vdb/metadata.js.map +1 -0
  341. package/dist/tools/vdb/parse.d.ts +25 -0
  342. package/dist/tools/vdb/parse.js +171 -0
  343. package/dist/tools/vdb/parse.js.map +1 -0
  344. package/dist/tools/vdb/point-render-data.d.ts +31 -0
  345. package/dist/tools/vdb/point-render-data.js +57 -0
  346. package/dist/tools/vdb/point-render-data.js.map +1 -0
  347. package/dist/tools/vdb/points.d.ts +160 -0
  348. package/dist/tools/vdb/points.js +794 -0
  349. package/dist/tools/vdb/points.js.map +1 -0
  350. package/dist/tools/vdb/transform.d.ts +23 -0
  351. package/dist/tools/vdb/transform.js +54 -0
  352. package/dist/tools/vdb/transform.js.map +1 -0
  353. package/dist/tools/vdb/tree.d.ts +111 -0
  354. package/dist/tools/vdb/tree.js +228 -0
  355. package/dist/tools/vdb/tree.js.map +1 -0
  356. package/dist/tools/vdb/types.d.ts +138 -0
  357. package/dist/tools/vdb/types.js +3 -0
  358. package/dist/tools/vdb/types.js.map +1 -0
  359. package/dist/tools/wvdb/bake.d.ts +116 -0
  360. package/dist/tools/wvdb/bake.js +311 -0
  361. package/dist/tools/wvdb/bake.js.map +1 -0
  362. package/dist/tools/wvdb/dense.d.ts +112 -0
  363. package/dist/tools/wvdb/dense.js +309 -0
  364. package/dist/tools/wvdb/dense.js.map +1 -0
  365. package/dist/tools/wvdb/format.d.ts +161 -0
  366. package/dist/tools/wvdb/format.js +303 -0
  367. package/dist/tools/wvdb/format.js.map +1 -0
  368. package/dist/tools/wvdb/index.d.ts +13 -0
  369. package/dist/tools/wvdb/index.js +14 -0
  370. package/dist/tools/wvdb/index.js.map +1 -0
  371. package/dist/tools/wvdb/level-set.d.ts +48 -0
  372. package/dist/tools/wvdb/level-set.js +153 -0
  373. package/dist/tools/wvdb/level-set.js.map +1 -0
  374. package/dist/tools/wvdb/nanovdb.d.ts +54 -0
  375. package/dist/tools/wvdb/nanovdb.js +60 -0
  376. package/dist/tools/wvdb/nanovdb.js.map +1 -0
  377. package/dist/tools/wvdb/read.d.ts +260 -0
  378. package/dist/tools/wvdb/read.js +743 -0
  379. package/dist/tools/wvdb/read.js.map +1 -0
  380. package/dist/tools/wvdb/sha256.d.ts +7 -0
  381. package/dist/tools/wvdb/sha256.js +76 -0
  382. package/dist/tools/wvdb/sha256.js.map +1 -0
  383. package/dist/tools/wvdb/write.d.ts +127 -0
  384. package/dist/tools/wvdb/write.js +396 -0
  385. package/dist/tools/wvdb/write.js.map +1 -0
  386. package/package.json +82 -4
  387. package/vendor/LICENSE +201 -0
  388. package/vendor/NOTICE +19 -0
  389. package/vendor/VENDOR.md +85 -0
  390. package/vendor/pnanovdb.wgsl +1539 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool.js","sourceRoot":"","sources":["../../../src/core/pool/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAoB,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,cAAc,EAAuB,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAuB,MAAM,mBAAmB,CAAC;AACxF,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,OAAO,EACP,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,gBAAgB,GAGjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,OAAO,EACP,cAAc,EACd,iBAAiB,EACjB,WAAW,GACZ,MAAM,aAAa,CAAC;AAsKrB,qHAAqH;AACrH,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAE/B,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,CAAC;AACtC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,SAAS,SAAS,CAAC,OAAe;IAChC,MAAM,IAAI,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,UAAU,CAAC,IAAY,EAAE,KAAc,EAAE,GAAW;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,GAAG,EAAE,C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C,IAAI,CAAC;QAChD,OAAO;YACL,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,KAAM,CAAC,MAAM;YAClC,UAAU,EAAE,CAAC,CAAC,UAAU;YACxB,QAAQ,EAAE,CAAC,CAAC,UAAU;YACtB,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,gBAAgB,EAAE,CAAC,KAAK,IAAI;YAC5B,iBAAiB,EAAE,CAAC,CAAC,SAAS,KAAK,IAAI;YACvC,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,SAAS,EAAE,CAAC,EAAE,SAAS,IAAI,CAAC;YAC5B,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;YAChD,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;YAChD,YAAY,EAAE,CAAC,CAAC,YAAY;YAC5B,YAAY,EAAE,CAAC,CAAC,YAAY;YAC5B,UAAU,EAAE,CAAC,CAAC,UAAU;YACxB,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;YAC3B,cAAc,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;YACrC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;SACrC,CAAC;IACJ,CAAC;CACF","sourcesContent":["/**\n * `VDBGridPool`: many NanoVDB grids in one `GPUBuffer` behind a grid table\n * (docs/dev/design/K1-core.md §1, §4; D8, D10).\n *\n * Model: CPU calls (`add`, `replace`, `remove`, `setTransform`, `setMajorant`)\n * stage changes and return at once; `update(encoder)` applies them. Growth and\n * compaction happen only in `update`, by a new buffer plus copies of the ranges\n * that were resident before that update; `version` bumps then (and when a\n * failed growth rolls back to the previous buffer).\n *\n * Lifecycle (docs/archive/handoffs/K1.md, \"K1.3 pool lifecycle\"):\n * - A request that could never fit under the byte limit throws `VDB_POOL_LIMIT`\n * at staging, with the pool unchanged.\n * - Growth allocates inside `out-of-memory` and `validation` error scopes. The\n * pool switches to the new buffer at once (update is synchronous) but keeps\n * the old one alive until the scopes resolve; on an error it rolls back to the\n * old buffer and reports through `settled()` / `lastError`.\n * - A retired buffer is destroyed once its growth is confirmed, two `update`s\n * have passed, and `queue.onSubmittedWorkDone()` asked at that point resolves.\n */\n\nimport { VDBError } from \"../errors.js\";\nimport { applyAffine, composeGridAffines, type GridAffines } from \"./affine.js\";\nimport { RangeAllocator, type AllocatedRange } from \"./allocator.js\";\nimport type { VDBGridTypeName, VDBSlot } from \"../types.js\";\nimport { gridClassName, readImageHeader, type VDBImageHeader } from \"./image-header.js\";\nimport {\n VDB_GPU_LAYOUT_VERSION,\n VDB_POOL_HEADER_WORDS,\n VDB_POOL_RECORD_WORDS,\n align32,\n dataStartOffset,\n encodeHeader,\n encodeRecord,\n recordByteOffset,\n type VDBGridRecord,\n type VDBVec3,\n} from \"./layout.js\";\nimport {\n BUFFER_USAGE,\n POOL_BUFFER_USAGE,\n deviceByteLimit,\n floor32,\n requiredLimits,\n unsupportedReason,\n watchDevice,\n} from \"./limits.js\";\n\n/**\n * A dense grid of upper bounds over a grid's index space, one f32 per brick of\n * `2^brickLog2` voxels per side, x fastest (§5.1). Built by `tools`; the pool\n * only stores it.\n */\nexport interface VDBBrickMajorant {\n /** log2 of the brick edge in index voxels (3 for 8³ bricks). */\n brickLog2: number;\n /** Cells along x, y, z. */\n dims: readonly [number, number, number];\n /** `dims[0] * dims[1] * dims[2]` bounds, x fastest. */\n data: Float32Array;\n}\n\n/** A 4x4 column-major object-to-world matrix (three's `Matrix4.elements`), or `null` for the file's map. */\nexport type VDBTransformInput = Float32Array | Float64Array | readonly number[] | null;\n\n/** Options for {@link VDBGridPool.create}. */\nexport interface VDBGridPoolOptions {\n /** Initial buffer bytes (default 1 MiB); the first `update` grows it to fit. */\n initialBytes?: number;\n /** Initial table capacity in grids (default 16); the table doubles through the growth path. */\n maxGrids?: number;\n /** Upper bound on the buffer size (default: the device limit). */\n maxBytes?: number;\n /** Debug label for the buffers the pool creates. */\n label?: string;\n /** Extra `GPUBufferUsage` flags ORed into `STORAGE | COPY_DST | COPY_SRC`. */\n usage?: number;\n /**\n * A host-owned buffer to use instead. It must have `STORAGE | COPY_DST`\n * usage. The pool never destroys it and never grows it: when it is full,\n * `add`/`replace`/`setMajorant` throw `VDB_POOL_FULL`.\n */\n buffer?: GPUBuffer;\n}\n\n/** Options for {@link VDBGridPool.add}. */\nexport interface VDBAddOptions {\n /** Bytes to reserve for the image (at least its size), so later `replace` calls fit in place. */\n capacity?: number;\n /** Instance transform (see {@link VDBGridPool.setTransform}). */\n transform?: VDBTransformInput;\n /** Brick-majorant bounds for this grid (see {@link VDBGridPool.setMajorant}). */\n majorant?: VDBBrickMajorant;\n /** Global density bound (record word 35); default `max(root max, background)` when the image has stats. */\n valueMax?: number;\n /** Free-form label, reported by `info`. */\n label?: string;\n}\n\n/** What {@link VDBGridPool.info} reports about one grid. */\nexport interface VDBGridInfo {\n id: number;\n type: VDBGridTypeName;\n /** NanoVDB `GridType` id. */\n gridTypeId: number;\n /** NanoVDB `GridClass` name, e.g. `\"FogVolume\"`. */\n gridClass: string;\n gridClassId: number;\n /** Grid name from the image header. */\n name: string;\n label: string | undefined;\n imageBytes: number;\n /** Bytes reserved for the image (≥ `imageBytes`, 32 B multiple). */\n capacity: number;\n /** Byte offset of the image in the pool, or `null` until an `update` places it. */\n imageOffset: number | null;\n /** True once the image bytes are on the GPU (after the `update` that wrote them). */\n resident: boolean;\n /**\n * The pool {@link VDBGridPool.revision} at this grid's last `add` or `replace`: changes exactly\n * when the image's contents may have (not on `setTransform` / `setMajorant`). Data derived from the\n * image (a coarse pyramid, K3.2a) rebuilds when it moves; ids reused after `remove` get a new one.\n */\n imageRevision: number;\n hasStats: boolean;\n hasBrickMajorant: boolean;\n majorantOffset: number | null;\n majorantDims: VDBVec3 | null;\n instanceTransform: boolean;\n background: number;\n valueMax: number;\n /**\n * The root node's min/max statistics as stored in the image (f32). Meaningful\n * only when `hasStats`; without stats they are whatever the file holds\n * (usually 0). `gridStats` and `decodeToAtlas` use them as their range.\n */\n rootMin: number;\n rootMax: number;\n voxelSize: VDBVec3;\n indexBBox: { min: VDBVec3; max: VDBVec3 };\n /** World-space AABB of the index bbox's voxels (max corner + 1 voxel), through the record's f64 transform. */\n worldBBox: { min: VDBVec3; max: VDBVec3 };\n /** f64 affines before f32 rounding, 3x4 row-major. */\n worldToIndex: Float64Array;\n indexToWorld: Float64Array;\n}\n\n/** A sub-allocated range plus its GPU state. */\ninterface RangeState {\n range: AllocatedRange | null;\n /** The GPU holds this range's current bytes at `range.offset`. */\n resident: boolean;\n}\n\ninterface MajorantState extends RangeState {\n brickLog2: number;\n dims: VDBVec3;\n bytes: number;\n pending: Float32Array | null;\n /** The data last written, kept while a growth is unconfirmed so a rollback can stage it again. */\n retained: Float32Array | null;\n}\n\ninterface GridState {\n header: VDBImageHeader;\n label: string | undefined;\n capacity: number;\n image: RangeState;\n pendingImage: Uint32Array | null;\n /** The image last written, kept while a growth is unconfirmed so a rollback can stage it again. */\n retainedImage: Uint32Array | null;\n /** +1 per `replace`: tells a rollback whether the old buffer still holds this grid's current image. */\n imageSerial: number;\n /** The pool `revision` of this grid's last `add` / `replace` (K3.2a: derived data rebuilds on a change). */\n imageRevision: number;\n transform: Float64Array | null;\n affines: GridAffines;\n valueMaxOverride: number | undefined;\n majorant: MajorantState | null;\n}\n\n/** What the buffer a growth copied from holds for one grid (clean, resident ranges only). */\ninterface GridSnapshot {\n imageSerial: number;\n image: AllocatedRange | null;\n majorant: MajorantState | null;\n majorantRange: AllocatedRange | null;\n}\n\n/** A growth whose allocation the device hasn't confirmed yet. */\ninterface Growth {\n /** The buffer copied from; kept alive until this growth is confirmed or rolled back. */\n from: GPUBuffer;\n to: GPUBuffer;\n /** Table capacity of `from`. */\n capacity: number;\n /** `update` count when it happened. */\n update: number;\n snapshot: Map<GridState, GridSnapshot>;\n /** Settles in growth order; resolves to the rollback error, or `null` when confirmed or voided. */\n done: Promise<VDBError | null>;\n}\n\n/** A replaced buffer awaiting destruction. */\ninterface Retired {\n buffer: GPUBuffer;\n /** `update` count of the growth that replaced it. */\n since: number;\n /** `onSubmittedWorkDone` has been requested for it. */\n waiting: boolean;\n}\n\n/** Updates a retired buffer must outlive before the pool asks the queue about it (one update of slack to submit). */\nconst RETIRE_AFTER_UPDATES = 2;\n\nconst DEFAULT_INITIAL_BYTES = 1 << 20;\nconst DEFAULT_MAX_GRIDS = 16;\n\nfunction badOption(message: string): never {\n throw new VDBError(\"VDB_BAD_OPTION\", message);\n}\n\nfunction checkCount(name: string, value: unknown, min: number): number {\n if (typeof value !== \"number\" || !Number.isInteger(value) || value < min) {\n badOption(`${name} must be an integer ≥ ${min}, got ${String(value)}.`);\n }\n return value;\n}\n\nfunction copyTransform(m: VDBTransformInput | undefined): Float64Array | null {\n if (m === null || m === undefined) return null;\n return Float64Array.from(m);\n}\n\nfunction validateMajorant(m: VDBBrickMajorant): MajorantState {\n if (typeof m !== \"object\" || m === null) badOption(\"majorant must be { brickLog2, dims, data } or null.\");\n checkCount(\"majorant.brickLog2\", m.brickLog2, 0);\n if (m.brickLog2 > 10) badOption(`majorant.brickLog2 is ${m.brickLog2}; bricks larger than 1024 voxels aren't supported.`);\n if (!Array.isArray(m.dims) && !ArrayBuffer.isView(m.dims)) badOption(\"majorant.dims must be [x, y, z].\");\n if (m.dims.length !== 3) badOption(`majorant.dims must have 3 entries, got ${m.dims.length}.`);\n const dims: VDBVec3 = [m.dims[0], m.dims[1], m.dims[2]];\n dims.forEach((d, k) => checkCount(`majorant.dims[${k}]`, d, 1));\n if (!(m.data instanceof Float32Array)) badOption(\"majorant.data must be a Float32Array.\");\n const cells = dims[0] * dims[1] * dims[2];\n if (m.data.length !== cells) {\n badOption(`majorant.data has ${m.data.length} values; dims ${dims.join(\"x\")} need ${cells}. Rebuild the majorant.`);\n }\n const bytes = cells * 4;\n if (bytes > 2 ** 32 - 32) badOption(`majorant needs ${bytes} bytes; the pool addresses ranges with 32 bits.`);\n return { brickLog2: m.brickLog2, dims, bytes, pending: m.data, retained: null, range: null, resident: false };\n}\n\n/**\n * `queue.writeBuffer` for any typed array. The WebGPU typings want an\n * `ArrayBuffer`-backed view; callers' arrays are typed `ArrayBufferLike`, and\n * writeBuffer copies the bytes either way.\n */\nfunction write(queue: GPUQueue, buffer: GPUBuffer, offset: number, data: Uint32Array | Float32Array): void {\n queue.writeBuffer(buffer, offset, data as Uint32Array<ArrayBuffer>);\n}\n\nfunction checkValueMax(v: number | undefined): number | undefined {\n if (v === undefined) return undefined;\n if (typeof v !== \"number\" || Number.isNaN(v)) badOption(`valueMax must be a number, got ${String(v)}.`);\n return v;\n}\n\n/**\n * Many NanoVDB grids in one storage buffer, bound at one slot (D10). The pool\n * takes the host's `GPUDevice`, records into the host's encoder, and frees only\n * what it allocated (D8).\n *\n * Images passed to `add`/`replace` are held by reference (not copied) until the\n * next `update` writes them, and after that while a growth is unconfirmed\n * (until `settled()` resolves); don't mutate them before then.\n */\nexport class VDBGridPool {\n /** The device the pool allocates on. */\n readonly device: GPUDevice;\n\n #buffer: GPUBuffer;\n #ownsBuffer: boolean;\n #retired: Retired[] = [];\n #growths: Growth[] = [];\n #updates = 0;\n #lastError: VDBError | null = null;\n #version = 0;\n #revision = 0;\n #capacity: number;\n #limit: number;\n #label: string;\n #usage: number;\n #grids: (GridState | undefined)[] = [];\n #alloc: RangeAllocator;\n #dirtyRecords = new Set<number>();\n #headerDirty = true;\n #disposed = false;\n\n private constructor(device: GPUDevice, buffer: GPUBuffer, owns: boolean, capacity: number, limit: number, label: string, usage: number) {\n this.device = device;\n this.#buffer = buffer;\n this.#ownsBuffer = owns;\n this.#capacity = capacity;\n this.#limit = limit;\n this.#label = label;\n this.#usage = usage;\n this.#alloc = new RangeAllocator(dataStartOffset(capacity), buffer.size);\n }\n\n /**\n * Creates a pool on `device`. Throws `VDB_UNSUPPORTED_DEVICE` (see\n * {@link unsupportedReason}) or `VDB_BAD_OPTION`. The returned pool is\n * bindable at once (an empty table).\n */\n static async create(device: GPUDevice, options: VDBGridPoolOptions = {}): Promise<VDBGridPool> {\n const reason = unsupportedReason(device);\n if (reason !== null) throw new VDBError(\"VDB_UNSUPPORTED_DEVICE\", reason);\n watchDevice(device);\n\n const capacity = checkCount(\"maxGrids\", options.maxGrids ?? DEFAULT_MAX_GRIDS, 1);\n const usage = checkCount(\"usage\", options.usage ?? 0, 0);\n const label = options.label ?? \"vdb pool\";\n const deviceLimit = deviceByteLimit(device);\n let limit = deviceLimit;\n if (options.maxBytes !== undefined) limit = Math.min(limit, floor32(checkCount(\"maxBytes\", options.maxBytes, 1)));\n const tableEnd = dataStartOffset(capacity);\n\n let pool: VDBGridPool;\n if (options.buffer !== undefined) {\n if (options.initialBytes !== undefined) badOption(\"initialBytes and buffer are exclusive; the host buffer's size is the pool size.\");\n const host = options.buffer;\n const need = BUFFER_USAGE.STORAGE | BUFFER_USAGE.COPY_DST;\n if ((host.usage & need) !== need) {\n badOption(\"The host buffer needs GPUBufferUsage.STORAGE | COPY_DST. Create it with those flags.\");\n }\n if (host.size % 4 !== 0) badOption(`The host buffer is ${host.size} bytes; storage buffers must be a multiple of 4.`);\n if (host.size > deviceLimit) {\n badOption(\n `The host buffer is ${host.size} bytes; this device binds at most ${deviceLimit}. ` +\n `Use a smaller buffer or request the device with VDBGridPool.requiredLimits(adapter).`,\n );\n }\n if (host.size < tableEnd) {\n badOption(`The host buffer is ${host.size} bytes; a ${capacity}-grid table needs ${tableEnd}. Lower maxGrids or enlarge it.`);\n }\n pool = new VDBGridPool(device, host, false, capacity, floor32(host.size), label, usage);\n // A host buffer may hold old data: clear the header and table.\n pool.#writeTable();\n } else {\n if (tableEnd > limit) {\n badOption(`A ${capacity}-grid table needs ${tableEnd} bytes; the pool limit is ${limit}. Lower maxGrids.`);\n }\n const initial = checkCount(\"initialBytes\", options.initialBytes ?? DEFAULT_INITIAL_BYTES, 1);\n const size = Math.min(limit, Math.max(align32(initial), tableEnd));\n device.pushErrorScope(\"out-of-memory\");\n const buffer = device.createBuffer({ label: `${label} (v0)`, size, usage: POOL_BUFFER_USAGE | usage });\n const oom = await device.popErrorScope();\n if (oom) {\n buffer.destroy();\n throw new VDBError(\"VDB_POOL_LIMIT\", `The device could not allocate ${size} bytes (${oom.message}). Lower initialBytes.`);\n }\n pool = new VDBGridPool(device, buffer, true, capacity, limit, label, usage);\n pool.#writeHeader();\n }\n return pool;\n }\n\n /** True when `device` can hold a pool. */\n static isSupported(device: GPUDevice): boolean {\n return unsupportedReason(device) === null;\n }\n\n /** Why `device` can't hold a pool, or `null`. */\n static unsupportedReason(device: GPUDevice): string | null {\n return unsupportedReason(device);\n }\n\n /** Limits for `adapter.requestDevice({ requiredLimits })` so the pool can grow to the adapter's maxima. */\n static requiredLimits(adapter: GPUAdapter): Record<string, number> {\n return requiredLimits(adapter);\n }\n\n /**\n * The pool's buffer. Replaced by a growth in `update`, or by the rollback of\n * a growth whose allocation failed (asynchronously; see `settled`); `version`\n * changes each time.\n */\n get buffer(): GPUBuffer {\n return this.#buffer;\n }\n\n /**\n * +1 whenever `buffer` changes object: rebuild bind groups. Monotonic: a\n * failed growth's rollback to the previous buffer is a new version too.\n *\n * Read it after `update(encoder)`: call `update(encoder)` before building\n * or reusing bind groups this frame. A bind group built before `update()`\n * keeps the previous (still-alive) buffer and silently misses new grids.\n */\n get version(): number {\n return this.#version;\n }\n\n /** +1 on every content change (add, replace, remove, setTransform, setMajorant). */\n get revision(): number {\n return this.#revision;\n }\n\n /** {@link VDB_GPU_LAYOUT_VERSION}. */\n get layoutVersion(): number {\n return VDB_GPU_LAYOUT_VERSION;\n }\n\n /** Size of `buffer` in bytes. */\n get byteLength(): number {\n return this.#buffer.size;\n }\n\n /** Allocation high-water mark in bytes (header word 6). */\n get usedBytes(): number {\n return this.#alloc.highWater;\n }\n\n /** Bytes in replaced buffers still alive: awaiting growth confirmation or the queue (see `update`). */\n get retiredBytes(): number {\n let n = 0;\n for (const r of this.#retired) n += r.buffer.size;\n for (const g of this.#growths) n += g.from.size;\n return n;\n }\n\n /**\n * The error from the last growth whose allocation failed (`VDB_POOL_LIMIT`;\n * the pool rolled back to its previous buffer), or `null`. Cleared when a\n * later growth is confirmed.\n */\n get lastError(): VDBError | null {\n return this.#lastError;\n }\n\n /**\n * Resolves once every growth started so far is confirmed by the device;\n * rejects with the `VDB_POOL_LIMIT` error if one failed and the pool rolled\n * back (see {@link lastError}). Resolves at once when no growth is pending.\n */\n settled(): Promise<void> {\n this.#checkAlive();\n return Promise.all(this.#growths.map((g) => g.done)).then((errors) => {\n const error = errors.find((e) => e !== null);\n if (error) throw error;\n });\n }\n\n /** Records in the grid table. */\n get gridCapacity(): number {\n return this.#capacity;\n }\n\n /** Highest live id + 1 (header word 3). */\n get gridCount(): number {\n for (let id = this.#grids.length - 1; id >= 0; id--) if (this.#grids[id]) return id + 1;\n return 0;\n }\n\n /**\n * Grid types of the live grids now, for `vdbCheckModule` and\n * `vdbModuleWgsl({ types })`. It does not know about grids the host adds\n * later: generate the module for every type the host may add (see `add`).\n */\n get types(): ReadonlySet<VDBGridTypeName> {\n const out = new Set<VDBGridTypeName>();\n for (const g of this.#grids) if (g) out.add(g.header.gridType);\n return out;\n }\n\n /**\n * Stages a grid image and returns its id at once. The image is validated\n * here (`VDB_BAD_IMAGE`, `VDB_UNSUPPORTED_GRID_TYPE`) and written by the next\n * `update`. Dead ids are reused, lowest first.\n *\n * The shader reading this pool decodes only the types its module was\n * generated for; a grid of any other type reads as 0. A module must\n * therefore be generated for every type the host may add (its known set,\n * or `VDB_ALL_SCALAR_TYPES`), or regenerated and its pipeline rebuilt when\n * a new type arrives. Call `vdbCheckModule(pool, options)` after `add` to\n * catch a mismatch (`VDB_TYPE_NOT_COMPILED`).\n */\n add(image: Uint32Array, options: VDBAddOptions = {}): number {\n this.#checkAlive();\n const header = readImageHeader(image);\n const capacity = align32(Math.max(header.byteLength, checkCount(\"capacity\", options.capacity ?? 0, 0)));\n const transform = copyTransform(options.transform);\n const affines = composeGridAffines(header, transform);\n const valueMaxOverride = checkValueMax(options.valueMax);\n const majorant = options.majorant ? validateMajorant(options.majorant) : null;\n\n let id = this.#grids.findIndex((g) => g === undefined);\n if (id < 0) id = this.#grids.length;\n if (!this.#ownsBuffer && id >= this.#capacity) {\n throw new VDBError(\n \"VDB_POOL_FULL\",\n `The host buffer's table holds ${this.#capacity} grids and all are live. Remove a grid, or create the pool with a larger maxGrids.`,\n );\n }\n this.#checkCanFit(Math.max(this.#grids.length, id + 1), majorant ? [capacity, majorant.bytes] : [capacity], \"image\");\n const grid: GridState = {\n header,\n label: options.label,\n capacity,\n image: { range: null, resident: false },\n pendingImage: image,\n retainedImage: null,\n imageSerial: 0,\n imageRevision: 0,\n transform,\n affines,\n valueMaxOverride,\n majorant,\n };\n // Place now when it fits; a host buffer must fit now (it never grows).\n const tableFits = id < this.#capacity && this.#grids.length <= this.#capacity;\n this.#place(grid.image, capacity, \"image\", tableFits);\n if (majorant) {\n try {\n this.#place(majorant, majorant.bytes, \"majorant\", tableFits);\n } catch (e) {\n if (grid.image.range) this.#alloc.free(grid.image.range.offset);\n throw e;\n }\n }\n this.#grids[id] = grid;\n this.#touch(id);\n grid.imageRevision = this.#revision;\n return id;\n }\n\n /**\n * Stages a new image for grid `id`. It is written in place when it fits the\n * grid's reserved range (no `version` change: the sequence-player path), else\n * moved. A brick majorant set on the grid is dropped (it described the old\n * image); call `setMajorant` again. Transform, label and `valueMax` are kept.\n */\n replace(id: number, image: Uint32Array): void {\n this.#checkAlive();\n const grid = this.#grid(id);\n const header = readImageHeader(image);\n if (align32(header.byteLength) > grid.capacity) {\n const capacity = align32(header.byteLength);\n this.#checkCanFit(this.#grids.length, [capacity], \"image\"); // replace drops the majorant\n const next: RangeState = { range: null, resident: false };\n this.#replaceRange(grid.image.range, () => this.#place(next, capacity, \"image\"));\n grid.image = next;\n grid.capacity = capacity;\n }\n grid.header = header;\n grid.pendingImage = image;\n grid.imageSerial++;\n grid.affines = composeGridAffines(header, grid.transform);\n this.#dropMajorant(grid);\n this.#touch(id);\n grid.imageRevision = this.#revision;\n }\n\n /** Frees grid `id`'s ranges and clears its record; the id may be reused by the next `add`. */\n remove(id: number): void {\n this.#checkAlive();\n const grid = this.#grid(id);\n if (grid.image.range) this.#alloc.free(grid.image.range.offset);\n this.#dropMajorant(grid);\n this.#grids[id] = undefined;\n while (this.#grids.length > 0 && this.#grids[this.#grids.length - 1] === undefined) this.#grids.pop();\n this.#touch(id);\n }\n\n /**\n * Sets grid `id`'s instance transform: a 4x4 column-major object-to-world\n * matrix (WebGPU / three convention), or `null` for the file's own map. The\n * pool composes `worldToIndex = map⁻¹ ∘ objectToWorld⁻¹` and `indexToWorld`\n * in f64 and rounds to f32. Only the record changes; the image is untouched.\n */\n setTransform(id: number, objectToWorld: VDBTransformInput): void {\n this.#checkAlive();\n const grid = this.#grid(id);\n const transform = copyTransform(objectToWorld);\n grid.affines = composeGridAffines(grid.header, transform);\n grid.transform = transform;\n this.#touch(id);\n }\n\n /**\n * Stores brick-majorant bounds for grid `id` in the pool (record words\n * 36–39, flag b2, brick log2 in b16–23), or clears them with `null`.\n */\n setMajorant(id: number, majorant: VDBBrickMajorant | null): void {\n this.#checkAlive();\n const grid = this.#grid(id);\n if (majorant === null) {\n this.#dropMajorant(grid);\n this.#touch(id);\n return;\n }\n const next = validateMajorant(majorant);\n const current = grid.majorant;\n if (current?.range && align32(next.bytes) <= current.range.size) {\n next.range = current.range;\n next.resident = current.resident;\n } else {\n this.#checkCanFit(this.#grids.length, [grid.capacity, next.bytes], \"majorant\");\n this.#replaceRange(current?.range ?? null, () => this.#place(next, next.bytes, \"majorant\"));\n }\n grid.majorant = next;\n this.#touch(id);\n }\n\n /** Describes grid `id`. Throws `VDB_UNKNOWN_GRID` for a dead or out-of-range id. */\n info(id: number): VDBGridInfo {\n this.#checkAlive();\n const g = this.#grid(id);\n const h = g.header;\n const lo = h.indexBBoxMin;\n const hi = h.indexBBoxMax.map((v) => v + 1) as VDBVec3;\n const min: VDBVec3 = [Infinity, Infinity, Infinity];\n const max: VDBVec3 = [-Infinity, -Infinity, -Infinity];\n for (let c = 0; c < 8; c++) {\n const p = applyAffine(g.affines.indexToWorld, [c & 1 ? hi[0] : lo[0], c & 2 ? hi[1] : lo[1], c & 4 ? hi[2] : lo[2]]);\n for (let a = 0; a < 3; a++) {\n min[a] = Math.min(min[a]!, p[a]!);\n max[a] = Math.max(max[a]!, p[a]!);\n }\n }\n const m = g.majorant;\n return {\n id,\n type: h.gridType,\n gridTypeId: h.gridTypeId,\n gridClass: gridClassName(h.gridClass),\n gridClassId: h.gridClass,\n name: h.name,\n label: g.label,\n imageBytes: h.byteLength,\n capacity: g.capacity,\n imageOffset: g.image.range?.offset ?? null,\n resident: g.image.resident && g.pendingImage === null,\n imageRevision: g.imageRevision,\n hasStats: h.hasStats,\n hasBrickMajorant: m !== null,\n majorantOffset: m?.range?.offset ?? null,\n majorantDims: m ? [...m.dims] : null,\n instanceTransform: g.transform !== null,\n background: h.background,\n valueMax: this.#valueMax(g),\n rootMin: h.rootMin,\n rootMax: h.rootMax,\n voxelSize: [...h.voxelSize],\n indexBBox: { min: [...lo], max: [...h.indexBBoxMax] },\n worldBBox: { min, max },\n worldToIndex: g.affines.worldToIndex.slice(),\n indexToWorld: g.affines.indexToWorld.slice(),\n };\n }\n\n /**\n * Applies staged changes, recording any copies into `encoder`:\n * 1. asks the queue about buffers retired at least two updates ago (once\n * their growth is confirmed); each is destroyed when\n * `onSubmittedWorkDone` resolves;\n * 2. if the staged state doesn't fit, grows (or, when only fragmentation\n * blocks a placement, compacts) into a new buffer, copying ranges that\n * were resident before this call, and bumps `version`. The allocation is\n * checked in error scopes; if it fails, the pool rolls back later (see\n * {@link settled}). Planned before anything changes: when the staged\n * grids together pass the byte limit, nothing is re-laid out;\n * 3. writes new images, majorants, dirty records and the header with\n * `queue.writeBuffer`, for ranges placed in the current buffer (a grid\n * still waiting for space reads as dead on the GPU).\n * Then, if step 2 hit the limit, throws `VDB_POOL_LIMIT` (buffer and\n * `version` unchanged; remove grids and update again).\n *\n * Submit `encoder` before the second `update` after this one (one update of\n * slack): a buffer this update retires stays alive until then.\n *\n * Call `update(encoder)` before building or reusing bind groups this frame,\n * then compare `version` with the version the bind group was built at. A\n * bind group built before `update()` keeps the previous (still-alive)\n * buffer and silently misses new grids: no validation error, just stale\n * data.\n */\n update(encoder: GPUCommandEncoder): void {\n this.#checkAlive();\n this.#updates++;\n this.#reapRetired();\n\n let limitError: VDBError | null = null;\n const needIds = this.#grids.length;\n const unplaced = this.#unplaced();\n if (needIds > this.#capacity || unplaced.length > 0) {\n if (needIds <= this.#capacity && this.#tryPlace(unplaced)) {\n // Placed in gaps freed since staging.\n } else {\n try {\n this.#relayout(encoder, needIds);\n } catch (e) {\n if (!(e instanceof VDBError) || e.code !== \"VDB_POOL_LIMIT\") throw e;\n limitError = e; // independent writes below still reach the current buffer\n }\n }\n }\n this.#writePending();\n if (limitError) throw limitError;\n }\n\n /** Convenience: creates an encoder, calls `update`, and submits it. */\n flush(): void {\n this.#checkAlive();\n const encoder = this.device.createCommandEncoder({ label: `${this.#label} flush` });\n this.update(encoder);\n this.device.queue.submit([encoder.finish()]);\n }\n\n /**\n * The bind group entry for `slot`: `{ binding: slot.firstBinding, resource: { buffer } }`.\n * Takes the same `VDBSlot` as `vdbModuleWgsl({ slot })` and\n * `vdbModuleEntries(slot)`.\n *\n * It names the current `buffer`, so call `update(encoder)` before building\n * or reusing bind groups this frame, and rebuild when `version` changed. A\n * bind group built before `update()` keeps the previous (still-alive)\n * buffer and silently misses new grids.\n */\n bindGroupEntry(slot: VDBSlot): GPUBindGroupEntry {\n this.#checkAlive();\n checkCount(\"slot.firstBinding\", slot?.firstBinding, 0);\n return { binding: slot.firstBinding, resource: { buffer: this.#buffer } };\n }\n\n /**\n * Destroys every buffer this pool created (current, retired, and those of an\n * unconfirmed growth) at once, never a host buffer or the device. Submit no\n * work recorded by `update` after this. Idempotent.\n */\n dispose(): void {\n if (this.#disposed) return;\n this.#disposed = true;\n const owned = new Set<GPUBuffer>();\n for (const r of this.#retired) owned.add(r.buffer);\n for (const g of this.#growths) owned.add(g.from).add(g.to);\n if (this.#ownsBuffer) owned.add(this.#buffer);\n for (const b of owned) b.destroy();\n this.#retired = [];\n this.#growths = [];\n this.#grids = [];\n this.#dirtyRecords.clear();\n }\n\n // -------------------------------------------------------------------------\n\n #checkAlive(): void {\n if (this.#disposed) throw new VDBError(\"VDB_DISPOSED\", \"This VDBGridPool was disposed. Create a new pool.\");\n }\n\n #grid(id: number): GridState {\n const g = Number.isInteger(id) ? this.#grids[id] : undefined;\n if (!g) {\n throw new VDBError(\n \"VDB_UNKNOWN_GRID\",\n `Grid id ${id} is not live in this pool (removed, or never returned by add). Use an id from add().`,\n );\n }\n return g;\n }\n\n #touch(id: number): void {\n this.#dirtyRecords.add(id);\n this.#headerDirty = true;\n this.#revision++;\n }\n\n #valueMax(g: GridState): number {\n if (g.valueMaxOverride !== undefined) return g.valueMaxOverride;\n // Without stats there is no bound in the image; Infinity tells the integrator to pass valueMax.\n return g.header.hasStats ? Math.max(g.header.rootMax, g.header.background) : Infinity;\n }\n\n /** Limit detail for `VDB_POOL_LIMIT` messages. */\n #limitDetail(): string {\n const { maxStorageBufferBindingSize, maxBufferSize } = this.device.limits;\n return (\n `device maxStorageBufferBindingSize ${maxStorageBufferBindingSize}, maxBufferSize ${maxBufferSize}` +\n `${this.#limit < deviceByteLimit(this.device) ? `, maxBytes ${this.#limit}` : \"\"}`\n );\n }\n\n /**\n * Throws `VDB_POOL_LIMIT` when ranges of `bytes` could not fit under the\n * limit even alone, beside a table of `ids` records (§1.5). Staged, such a\n * request would make every later `update` fail; reject it while the pool is\n * unchanged. Host buffers are checked by `#place` instead (`VDB_POOL_FULL`).\n */\n #checkCanFit(ids: number, bytes: number[], what: string): void {\n if (!this.#ownsBuffer) return;\n let capacity = this.#capacity;\n while (capacity < ids) capacity *= 2;\n const start = dataStartOffset(capacity);\n let needed = start;\n for (const b of bytes) needed += align32(b);\n if (needed <= this.#limit) return;\n throw new VDBError(\n \"VDB_POOL_LIMIT\",\n `This ${what} needs ${needed - start} bytes beside a ${capacity}-grid table (${start} bytes), ${needed} in all: ` +\n `more than the pool limit of ${this.#limit} bytes (${this.#limitDetail()}) even with no other grids. ` +\n `Use a smaller grid, or request the device with VDBGridPool.requiredLimits(adapter). The pool is unchanged.`,\n );\n }\n\n /** Frees `old`, runs `place` (which may reuse its space), and restores `old` if `place` throws. */\n #replaceRange(old: AllocatedRange | null, place: () => void): void {\n if (old) this.#alloc.free(old.offset);\n try {\n place();\n } catch (e) {\n if (old) this.#alloc.restore(old);\n throw e;\n }\n }\n\n /**\n * First-fit placement at staging time; a host buffer must fit now. In an\n * owned pool a range that doesn't fit (or any range while the table is\n * over capacity) stays unplaced and the next `update` re-lays out.\n */\n #place(state: RangeState, bytes: number, what: string, tableFits = this.#grids.length <= this.#capacity): void {\n const offset = tableFits ? this.#alloc.alloc(bytes) : null;\n if (offset !== null) {\n state.range = { offset, size: align32(bytes) };\n return;\n }\n if (!this.#ownsBuffer) {\n throw new VDBError(\n \"VDB_POOL_FULL\",\n `The host buffer (${this.#buffer.size} bytes, ${this.#alloc.allocatedBytes} allocated) has no free range of ` +\n `${align32(bytes)} bytes for this ${what}. Remove grids, or create the pool on a larger buffer (or without one, so it can grow).`,\n );\n }\n state.range = null; // placed by the next update\n }\n\n #dropMajorant(grid: GridState): void {\n const m = grid.majorant;\n if (m?.range) this.#alloc.free(m.range.offset);\n grid.majorant = null;\n }\n\n #unplaced(): { state: RangeState; bytes: number }[] {\n const out: { state: RangeState; bytes: number }[] = [];\n for (const g of this.#grids) {\n if (!g) continue;\n if (!g.image.range) out.push({ state: g.image, bytes: g.capacity });\n if (g.majorant && !g.majorant.range) out.push({ state: g.majorant, bytes: g.majorant.bytes });\n }\n return out;\n }\n\n /** Places every unplaced range first-fit, or changes nothing and returns false. */\n #tryPlace(unplaced: { state: RangeState; bytes: number }[]): boolean {\n const placed: number[] = [];\n for (const u of unplaced) {\n const offset = this.#alloc.alloc(u.bytes);\n if (offset === null) {\n for (const o of placed) this.#alloc.free(o);\n return false;\n }\n placed.push(offset);\n }\n unplaced.forEach((u, k) => (u.state.range = { offset: placed[k]!, size: align32(u.bytes) }));\n return true;\n }\n\n /** Grows or compacts into a new buffer (§1.4 step 2). Plans and checks before changing anything. */\n #relayout(encoder: GPUCommandEncoder, needIds: number): void {\n if (!this.#ownsBuffer) {\n // #place already guarantees host-buffer placements; reaching here is a pool bug.\n throw new VDBError(\"VDB_POOL_FULL\", \"The host buffer cannot be re-laid out. Remove grids or use a larger buffer.\");\n }\n let capacity = this.#capacity;\n while (capacity < needIds) capacity *= 2;\n\n // Pack every live range in id order: image, then majorant.\n const ranges: { state: RangeState; bytes: number; copyBytes: number }[] = [];\n for (const g of this.#grids) {\n if (!g) continue;\n ranges.push({ state: g.image, bytes: g.capacity, copyBytes: g.pendingImage ? 0 : g.header.byteLength });\n if (g.majorant) ranges.push({ state: g.majorant, bytes: g.majorant.bytes, copyBytes: g.majorant.pending ? 0 : g.majorant.bytes });\n }\n const start = dataStartOffset(capacity);\n let needed = start;\n for (const r of ranges) needed += align32(r.bytes);\n\n const current = this.#buffer.size;\n const grows = capacity > this.#capacity || needed > current;\n const size = grows ? Math.min(this.#limit, Math.max(needed, 2 * current)) : current;\n if (needed > size) {\n throw new VDBError(\n \"VDB_POOL_LIMIT\",\n `The staged grids need a ${needed}-byte pool; the limit is ${this.#limit} bytes (${this.#limitDetail()}). ` +\n `Remove grids, or request the device with VDBGridPool.requiredLimits(adapter). The buffer is unchanged; ` +\n `staged changes that fit it were applied.`,\n );\n }\n\n // What `from` holds (clean, resident ranges), for a rollback if the allocation fails.\n const snapshot = new Map<GridState, GridSnapshot>();\n for (const g of this.#grids) {\n if (!g) continue;\n const m = g.majorant;\n snapshot.set(g, {\n imageSerial: g.imageSerial,\n image: g.image.range && g.image.resident && !g.pendingImage ? { ...g.image.range } : null,\n majorant: m,\n majorantRange: m?.range && m.resident && !m.pending ? { ...m.range } : null,\n });\n }\n\n // update() is synchronous: switch now, keep `from` alive, and settle when the scopes resolve.\n const device = this.device;\n device.pushErrorScope(\"out-of-memory\");\n device.pushErrorScope(\"validation\");\n const next = device.createBuffer({\n label: `${this.#label} (v${this.#version + 1})`,\n size,\n usage: POOL_BUFFER_USAGE | this.#usage,\n });\n const validation = device.popErrorScope();\n const oom = device.popErrorScope();\n const growth: Growth = {\n from: this.#buffer,\n to: next,\n capacity: this.#capacity,\n update: this.#updates,\n snapshot,\n done: Promise.resolve(null),\n };\n // A rejected pop (e.g. the host popped our scope) tells us nothing: treat it as success.\n const scopeError = Promise.all([oom, validation]).then(\n ([o, v]) => o ?? v,\n () => null,\n );\n const previous = this.#growths[this.#growths.length - 1]?.done ?? Promise.resolve(null);\n growth.done = Promise.all([scopeError, previous]).then(([e]) => this.#settleGrowth(growth, e));\n this.#growths.push(growth);\n\n const alloc = new RangeAllocator(start, size);\n for (const r of ranges) {\n const offset = alloc.alloc(r.bytes)!;\n const old = r.state.range;\n if (old && r.state.resident && r.copyBytes > 0) {\n encoder.copyBufferToBuffer(this.#buffer, old.offset, next, offset, r.copyBytes);\n }\n r.state.range = { offset, size: align32(r.bytes) };\n if (r.copyBytes === 0) r.state.resident = false;\n }\n\n this.#buffer = next;\n this.#alloc = alloc;\n this.#capacity = capacity;\n this.#version++;\n this.#writeTable();\n }\n\n /**\n * Runs when a growth's error scopes resolve, in growth order. Confirmed: its\n * old buffer is retired. Failed: roll back to that old buffer, voiding every\n * later growth (they copied from the failed buffer).\n */\n #settleGrowth(growth: Growth, scopeError: { message: string } | null): VDBError | null {\n // Disposed (dispose destroyed everything), or voided by an earlier failure.\n if (this.#disposed || this.#growths[0] !== growth) return null;\n if (!scopeError) {\n this.#growths.shift();\n this.#retired.push({ buffer: growth.from, since: growth.update, waiting: false });\n this.#lastError = null;\n if (this.#growths.length === 0) this.#releaseRetained();\n return null;\n }\n const error = new VDBError(\n \"VDB_POOL_LIMIT\",\n `The device could not allocate a ${growth.to.size}-byte pool buffer while growing (${scopeError.message}). ` +\n `The pool rolled back to its previous ${growth.from.size}-byte buffer as version ${this.#version + 1}; rebuild ` +\n `bind groups. Grids resident before the growth are intact; ones staged or written since are staged again. ` +\n `Remove grids or free GPU memory, then update again.`,\n );\n this.#rollBack(growth);\n this.#lastError = error;\n return error;\n }\n\n /** Returns to `growth.from` and what it holds; every other range is staged again. */\n #rollBack(growth: Growth): void {\n for (const g of this.#growths) g.to.destroy(); // the failed buffer and any chained after it\n this.#growths = [];\n const alloc = new RangeAllocator(dataStartOffset(growth.capacity), growth.from.size);\n for (const g of this.#grids) {\n if (!g) continue;\n const snap = growth.snapshot.get(g);\n // Same serial: no replace since the snapshot, so `from` holds the current image and nothing is pending.\n if (snap?.image && snap.imageSerial === g.imageSerial) {\n alloc.restore(snap.image);\n g.image.range = { ...snap.image };\n g.image.resident = true;\n } else {\n g.image.range = null;\n g.image.resident = false;\n g.pendingImage ??= g.retainedImage;\n }\n const m = g.majorant;\n if (!m) continue;\n if (snap?.majorantRange && snap.majorant === m) {\n alloc.restore(snap.majorantRange);\n m.range = { ...snap.majorantRange };\n m.resident = true;\n } else {\n m.range = null;\n m.resident = false;\n m.pending ??= m.retained;\n }\n }\n this.#releaseRetained();\n this.#buffer = growth.from;\n this.#alloc = alloc;\n this.#capacity = growth.capacity;\n this.#version++;\n this.#writeTable(); // `from`'s table is stale: restored grids are live, the rest read as dead until placed\n }\n\n #releaseRetained(): void {\n for (const g of this.#grids) {\n if (!g) continue;\n g.retainedImage = null;\n if (g.majorant) g.majorant.retained = null;\n }\n }\n\n /**\n * §1.4 step 1: for retired buffers that are confirmed and at least\n * {@link RETIRE_AFTER_UPDATES} updates old (so the encoder that copied out of\n * them has been submitted), asks the queue once and destroys them when that\n * work is done.\n */\n #reapRetired(): void {\n const ready = this.#retired.filter((r) => !r.waiting && this.#updates - r.since >= RETIRE_AFTER_UPDATES);\n if (ready.length === 0) return;\n for (const r of ready) r.waiting = true;\n const destroy = (): void => {\n if (this.#disposed) return; // dispose destroyed them\n this.#retired = this.#retired.filter((r) => !ready.includes(r));\n for (const r of ready) r.buffer.destroy();\n };\n this.device.queue.onSubmittedWorkDone().then(destroy, destroy);\n }\n\n /** Every range of `g` is placed. Until then its record stays dirty. */\n #complete(g: GridState): boolean {\n return g.image.range !== null && (g.majorant === null || g.majorant.range !== null);\n }\n\n /** The header's grid count: highest live id + 1, clamped to the table (ids past it can't be read). */\n #headerGridCount(): number {\n return Math.min(this.gridCount, this.#capacity);\n }\n\n /** Writes the header and every record (after create on a host buffer, a relayout, or a rollback). */\n #writeTable(): void {\n const words = new Uint32Array(VDB_POOL_HEADER_WORDS + this.#capacity * VDB_POOL_RECORD_WORDS);\n const dirty = new Set<number>();\n this.#grids.forEach((g, id) => {\n if (!g) return;\n if (id < this.#capacity && g.image.range) {\n encodeRecord(this.#record(g), words, VDB_POOL_HEADER_WORDS + id * VDB_POOL_RECORD_WORDS);\n }\n if (!this.#complete(g)) dirty.add(id);\n });\n encodeHeader({ gridCapacity: this.#capacity, gridCount: this.#headerGridCount(), usedBytes: this.usedBytes }, words, 0);\n write(this.device.queue, this.#buffer, 0, words);\n this.#dirtyRecords = dirty;\n this.#headerDirty = false;\n }\n\n #writeHeader(): void {\n const words = encodeHeader({ gridCapacity: this.#capacity, gridCount: this.#headerGridCount(), usedBytes: this.usedBytes });\n write(this.device.queue, this.#buffer, 0, words);\n this.#headerDirty = false;\n }\n\n /**\n * §1.4 step 3: images, majorants, dirty records, header. Only ranges placed\n * in the current buffer are written; a grid whose image is unplaced gets a\n * dead record, and its id stays dirty until every range of it is placed.\n */\n #writePending(): void {\n const queue = this.device.queue;\n const keep = this.#growths.length > 0; // a rollback may have to stage these again\n for (const g of this.#grids) {\n if (!g) continue;\n if (g.pendingImage && g.image.range) {\n write(queue, this.#buffer, g.image.range.offset, g.pendingImage);\n if (keep) g.retainedImage = g.pendingImage;\n g.pendingImage = null;\n g.image.resident = true;\n }\n const m = g.majorant;\n if (m?.pending && m.range) {\n write(queue, this.#buffer, m.range.offset, m.pending);\n if (keep) m.retained = m.pending;\n m.pending = null;\n m.resident = true;\n }\n }\n const dirty = new Set<number>();\n for (const id of [...this.#dirtyRecords].sort((a, b) => a - b)) {\n const g = this.#grids[id];\n if (g && !this.#complete(g)) dirty.add(id);\n if (id >= this.#capacity) continue; // past the table end: the relayout that grows the table writes it\n const words = new Uint32Array(VDB_POOL_RECORD_WORDS);\n if (g?.image.range) encodeRecord(this.#record(g), words, 0);\n write(queue, this.#buffer, recordByteOffset(id), words);\n }\n this.#dirtyRecords = dirty;\n if (this.#headerDirty) this.#writeHeader();\n }\n\n /** The record for `g`, whose image is placed. A majorant is recorded only once it is placed. */\n #record(g: GridState): VDBGridRecord {\n const h = g.header;\n const m = g.majorant?.range ? g.majorant : null;\n return {\n imageOffset: g.image.range!.offset,\n imageBytes: h.byteLength,\n gridType: h.gridTypeId,\n live: true,\n hasStats: h.hasStats,\n hasBrickMajorant: m !== null,\n instanceTransform: g.transform !== null,\n gridClass: h.gridClass,\n brickLog2: m?.brickLog2 ?? 0,\n worldToIndex: Array.from(g.affines.worldToIndex),\n indexToWorld: Array.from(g.affines.indexToWorld),\n indexBBoxMin: h.indexBBoxMin,\n indexBBoxMax: h.indexBBoxMax,\n background: h.background,\n valueMax: this.#valueMax(g),\n majorantOffset: m?.range?.offset ?? 0,\n majorantDims: m ? m.dims : [0, 0, 0],\n };\n }\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import type { WvdbDenseVolume } from "../../tools/wvdb/dense.js";
2
+ import type { VDBVolumeSource } from "./types.js";
3
+ /** Options of {@link vdbDenseSource}. */
4
+ export interface VDBDenseSourceOptions {
5
+ /** Label prefix of the GPU objects. */
6
+ label?: string;
7
+ }
8
+ /** A dense source with `replace` (LOD swap). */
9
+ export type VDBDenseSource = VDBVolumeSource & {
10
+ readonly kind: "dense";
11
+ readonly volume: WvdbDenseVolume;
12
+ replace(volume: WvdbDenseVolume): void;
13
+ };
14
+ /**
15
+ * Upload a dense `.wvdb` volume (`wvdbDenseVolume` from `@pmndrs/vdb/tools`) on
16
+ * the host's device. The source owns its textures and sampler; `dispose()` frees
17
+ * the textures (samplers have no destroy).
18
+ */
19
+ export declare function vdbDenseSource(device: GPUDevice, volume: WvdbDenseVolume, o?: VDBDenseSourceOptions): VDBDenseSource;
@@ -0,0 +1,287 @@
1
+ // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
+ // src/three-openvdb/frame/webgpu/frameShaderChunks.js L834–1028 (createVolumeNodes: sampleMipAtlas,
3
+ // sampleMipmapped, sample3D, sampleOptional), src/three-openvdb/frame/core/FrameVolume.js L14–22 and
4
+ // src/three-openvdb/frame/webgpu/FrameRenderer.js L483–487 (texture setup: linear filter, clamp to edge,
5
+ // no GPU mipmaps), src/three-openvdb/frame/webgpu/frameMipmaps.js L183–189 (mip atlas texture).
6
+ // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
7
+ // Changes: TSL → WGSL, raw WebGPU upload; mip level count from textureDimensions instead of a uniform.
8
+ // Divergences: DIVERGES.md V23–V25.
9
+ /**
10
+ * `vdbDenseSource(device, volume)`: the dense `.wvdb` volume source on raw
11
+ * WebGPU (K3.0, R1 §4.2). It uploads the bytes `wvdbDenseVolume` (tools) built,
12
+ * as his renderer does: one 3D texture per channel (`r8unorm` density, mask and
13
+ * emission; `rgba8unorm` albedo) plus a CPU box mip atlas per channel, sampled
14
+ * with hardware trilinear (linear min/mag, clamp to edge, no GPU mipmaps).
15
+ *
16
+ * D10 says kernels need no textures; that holds for the sparse source. A
17
+ * kernel compiled against a dense source binds textures, by the host's choice.
18
+ */
19
+ import { VDBError } from "../errors.js";
20
+ /** `GPUTextureUsage.TEXTURE_BINDING | COPY_DST` (0x04 | 0x02); the globals do not exist in Node. */
21
+ const TEXTURE_USAGE = 0x04 | 0x02;
22
+ /** `GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE`. */
23
+ const STAGE_FRAGMENT_COMPUTE = 0x2 | 0x4;
24
+ const CHANNELS = ["density", "mask", "albedo", "emission"];
25
+ const CAP = { density: "Density", mask: "Mask", albedo: "Albedo", emission: "Emission" };
26
+ const bad = (message) => new VDBError("VDB_BAD_OPTION", message);
27
+ function upload(device, data, dims, format, texelBytes, label) {
28
+ const [w, h, d] = dims;
29
+ if (data.byteLength !== w * h * d * texelBytes) {
30
+ throw bad(`vdbDenseSource: ${label} has ${data.byteLength} bytes, expected ${w}x${h}x${d}x${texelBytes}`);
31
+ }
32
+ const texture = device.createTexture({ label, size: [w, h, d], dimension: "3d", format, usage: TEXTURE_USAGE });
33
+ // writeTexture has no 256-byte row alignment rule (only buffer copies do); FrameVolume uses unpackAlignment 1.
34
+ device.queue.writeTexture({ texture }, data, { bytesPerRow: w * texelBytes, rowsPerImage: h }, [w, h, d]);
35
+ return texture;
36
+ }
37
+ function uploadChannel(device, tex, label) {
38
+ const map = upload(device, tex.data, tex.dimensions, tex.format, tex.texelBytes, `${label}`);
39
+ const mip = tex.mip ? upload(device, tex.mip.data, tex.mip.dimensions, tex.format, tex.texelBytes, `${label} mip atlas`) : null;
40
+ return { map, mip };
41
+ }
42
+ function present(volume) {
43
+ return { density: volume.density, mask: volume.mask, albedo: volume.albedo, emission: volume.emission };
44
+ }
45
+ function checkSlot(slot, where) {
46
+ if (!slot || !Number.isInteger(slot.group) || slot.group < 0 || !Number.isInteger(slot.firstBinding) || slot.firstBinding < 0) {
47
+ throw bad(`${where}: slot must be { group, firstBinding } with non-negative integers, got ${JSON.stringify(slot)}.`);
48
+ }
49
+ return slot;
50
+ }
51
+ /** WGSL for one channel's sample function (his sampleMipmapped / sampleMipAtlas, L838–877). */
52
+ function channelWgsl(name, hasMip) {
53
+ const C = CAP[name];
54
+ const map = `vdbSrc${C}Map`;
55
+ if (!hasMip) {
56
+ return `fn vdbSrcSample${C}(uvw: vec3f, lod: f32) -> vec4f {\n return textureSampleLevel(${map}, vdbSrcSampler, uvw, 0.0);\n}\n`;
57
+ }
58
+ const mip = `vdbSrc${C}Mip`;
59
+ return `fn vdbSrcMipAtlas${C}(level: f32, uvw: vec3f) -> vec4f {
60
+ let texels = vec3f(textureDimensions(${map}));
61
+ let atlas = vec3f(textureDimensions(${mip}));
62
+ let size = max(vec3f(1.0), ceil(texels / exp2(level)));
63
+ let offset = atlas.x - atlas.x / exp2(level - 1.0);
64
+ let texel = clamp(uvw * size, vec3f(0.5), size - 0.5);
65
+ return textureSampleLevel(${mip}, vdbSrcSampler, vec3f(texel.x + offset, texel.y, texel.z) / atlas, 0.0);
66
+ }
67
+ fn vdbSrcSample${C}(uvw: vec3f, lod: f32) -> vec4f {
68
+ let level = min(lod, vdbSrcLevelCount(textureDimensions(${map})));
69
+ if (level <= 0.0) {
70
+ return textureSampleLevel(${map}, vdbSrcSampler, uvw, 0.0);
71
+ }
72
+ let level0 = floor(level);
73
+ var low: vec4f;
74
+ if (level0 < 0.5) {
75
+ low = textureSampleLevel(${map}, vdbSrcSampler, uvw, 0.0);
76
+ } else {
77
+ low = vdbSrcMipAtlas${C}(level0, uvw);
78
+ }
79
+ let high = vdbSrcMipAtlas${C}(min(level0 + 1.0, vdbSrcLevelCount(textureDimensions(${map}))), uvw);
80
+ return mix(low, high, level - level0);
81
+ }
82
+ `;
83
+ }
84
+ class DenseSource {
85
+ kind = "dense";
86
+ texels;
87
+ lodLevels;
88
+ channels;
89
+ stats;
90
+ /** Local unit box → uvw: translate by 0.5 (column-major). */
91
+ boxToSource = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1]);
92
+ version = 0;
93
+ #device;
94
+ #label;
95
+ #volume;
96
+ #textures = {};
97
+ #sampler;
98
+ #disposed = false;
99
+ constructor(device, volume, o) {
100
+ this.#device = device;
101
+ this.#label = o.label ?? "vdb dense source";
102
+ this.#volume = volume;
103
+ this.channels = { mask: !!volume.mask, albedo: !!volume.albedo, emission: !!volume.emission };
104
+ // FrameRenderer.js L483–487 + Data3DTexture defaults: linear, clamp to edge, no mipmaps.
105
+ this.#sampler = device.createSampler({
106
+ label: `${this.#label} sampler`,
107
+ magFilter: "linear",
108
+ minFilter: "linear",
109
+ mipmapFilter: "nearest",
110
+ addressModeU: "clamp-to-edge",
111
+ addressModeV: "clamp-to-edge",
112
+ addressModeW: "clamp-to-edge",
113
+ });
114
+ this.texels = [...volume.dimensions];
115
+ this.lodLevels = volume.density.mip?.levels ?? 0;
116
+ this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };
117
+ this.#upload(volume);
118
+ }
119
+ #upload(volume) {
120
+ const textures = present(volume);
121
+ for (const name of CHANNELS) {
122
+ const tex = textures[name];
123
+ if (tex)
124
+ this.#textures[name] = uploadChannel(this.#device, tex, `${this.#label} ${name}`);
125
+ }
126
+ }
127
+ #destroyTextures() {
128
+ for (const t of Object.values(this.#textures)) {
129
+ t.map.destroy();
130
+ t.mip?.destroy();
131
+ }
132
+ this.#textures = {};
133
+ }
134
+ #check() {
135
+ if (this.#disposed)
136
+ throw new VDBError("VDB_DISPOSED", "vdbDenseSource: the source was disposed; create a new one.");
137
+ }
138
+ /** The textures as uploaded (for tests and adapters). */
139
+ get volume() {
140
+ return this.#volume;
141
+ }
142
+ /**
143
+ * Swap in another LOD (or frame) of the same grids. The channel set and mip
144
+ * presence must match; a size change makes new textures and bumps `version`
145
+ * (rebuild bind groups; the WGSL does not change).
146
+ */
147
+ replace(volume) {
148
+ this.#check();
149
+ const now = present(this.#volume);
150
+ const next = present(volume);
151
+ for (const name of CHANNELS) {
152
+ if (!!now[name] !== !!next[name] || !!now[name]?.mip !== !!next[name]?.mip) {
153
+ throw bad(`vdbDenseSource.replace: the ${name} channel or its mip atlas appears or disappears; create a new source (the WGSL differs).`);
154
+ }
155
+ }
156
+ const sameSize = (a, b) => !a || !b || (a.dimensions.every((v, i) => v === b.dimensions[i]) && (!a.mip || a.mip.dimensions.every((v, i) => v === b.mip.dimensions[i])));
157
+ if (CHANNELS.every((n) => sameSize(now[n], next[n]))) {
158
+ for (const name of CHANNELS) {
159
+ const tex = next[name];
160
+ const up = this.#textures[name];
161
+ if (!tex || !up)
162
+ continue;
163
+ const [w, h, d] = tex.dimensions;
164
+ this.#device.queue.writeTexture({ texture: up.map }, tex.data, { bytesPerRow: w * tex.texelBytes, rowsPerImage: h }, [w, h, d]);
165
+ if (tex.mip && up.mip) {
166
+ const [aw, ah, ad] = tex.mip.dimensions;
167
+ this.#device.queue.writeTexture({ texture: up.mip }, tex.mip.data, { bytesPerRow: aw * tex.texelBytes, rowsPerImage: ah }, [aw, ah, ad]);
168
+ }
169
+ }
170
+ }
171
+ else {
172
+ this.#destroyTextures();
173
+ this.#upload(volume);
174
+ this.version++;
175
+ }
176
+ this.#volume = volume;
177
+ this.texels = [...volume.dimensions];
178
+ this.lodLevels = volume.density.mip?.levels ?? 0;
179
+ this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };
180
+ }
181
+ /** Bindings in order: sampler, then per present channel its texture and its mip atlas. */
182
+ #bindings(slot) {
183
+ let b = slot.firstBinding;
184
+ const out = [
185
+ { name: "vdbSrcSampler", binding: b++, kind: "sampler" },
186
+ ];
187
+ for (const name of CHANNELS) {
188
+ const t = this.#textures[name];
189
+ if (!t)
190
+ continue;
191
+ out.push({ name: `vdbSrc${CAP[name]}Map`, binding: b++, kind: "texture", texture: t.map });
192
+ if (t.mip)
193
+ out.push({ name: `vdbSrc${CAP[name]}Mip`, binding: b++, kind: "texture", texture: t.mip });
194
+ }
195
+ return out;
196
+ }
197
+ wgsl(o) {
198
+ this.#check();
199
+ const slot = checkSlot(o.slot, "vdbDenseSource.wgsl");
200
+ if (o.profile !== "sample" && o.profile !== "march")
201
+ throw bad(`vdbDenseSource.wgsl: profile must be 'sample' or 'march', got ${JSON.stringify(o.profile)}.`);
202
+ const on = (name) => this.channels[name] && o.channels?.[name] !== false;
203
+ const lines = [`// vdbDenseSource: dense .wvdb volume source (K3.0). ${this.#label}`];
204
+ for (const b of this.#bindings(slot)) {
205
+ lines.push(`@group(${slot.group}) @binding(${b.binding}) var ${b.name}: ${b.kind === "sampler" ? "sampler" : "texture_3d<f32>"};`);
206
+ }
207
+ lines.push(`
208
+ // frameMipmaps.js getMipLevelCount: ceil(log2(max side)), exactly, in integers.
209
+ fn vdbSrcLevelCount(dims: vec3u) -> f32 {
210
+ let m = max(max(dims.x, dims.y), max(dims.z, 1u));
211
+ if (m <= 1u) {
212
+ return 0.0;
213
+ }
214
+ return f32(32u - countLeadingZeros(m - 1u));
215
+ }
216
+ `);
217
+ const sampled = ["density", ...["mask", "albedo", "emission"].filter(on)];
218
+ for (const name of sampled)
219
+ lines.push(channelWgsl(name, !!this.#textures[name]?.mip));
220
+ lines.push(`fn vdbSrcDensity(v: u32, uvw: vec3f, lod: f32) -> f32 {
221
+ return vdbSrcSampleDensity(uvw, lod).r;
222
+ }
223
+ fn vdbSrcMask(v: u32, uvw: vec3f, lod: f32) -> f32 {
224
+ return ${on("mask") ? "vdbSrcSampleMask(uvw, lod).r" : "1.0"};
225
+ }
226
+ fn vdbSrcAlbedo(v: u32, uvw: vec3f, lod: f32) -> vec3f {
227
+ return ${on("albedo") ? "vdbSrcSampleAlbedo(uvw, lod).rgb" : "vec3f(1.0)"};
228
+ }
229
+ fn vdbSrcEmission(v: u32, uvw: vec3f, lod: f32) -> f32 {
230
+ return ${on("emission") ? "vdbSrcSampleEmission(uvw, lod).r" : "0.0"};
231
+ }
232
+ fn vdbSrcTexels(v: u32) -> vec3f {
233
+ return vec3f(textureDimensions(vdbSrcDensityMap));
234
+ }
235
+ fn vdbSrcLodLevels(v: u32) -> f32 {
236
+ return ${this.#textures.density?.mip ? "vdbSrcLevelCount(textureDimensions(vdbSrcDensityMap))" : "0.0"};
237
+ }
238
+ `);
239
+ if (o.profile === "march") {
240
+ // Dense: no empty-space structure; the march steps everywhere (R1 §4.2).
241
+ lines.push(`fn vdbSrcSkipEmpty(v: u32, o: vec3f, d: vec3f, t0: f32, t1: f32) -> f32 {
242
+ return t0;
243
+ }
244
+ fn vdbSrcMaxIn(v: u32, uvwMin: vec3f, uvwMax: vec3f) -> f32 {
245
+ return ${this.stats.max.toFixed(9)};
246
+ }
247
+ `);
248
+ }
249
+ return lines.join("\n");
250
+ }
251
+ layoutEntries(slot, visibility = STAGE_FRAGMENT_COMPUTE) {
252
+ this.#check();
253
+ checkSlot(slot, "vdbDenseSource.layoutEntries");
254
+ return this.#bindings(slot).map((b) => b.kind === "sampler"
255
+ ? { binding: b.binding, visibility, sampler: { type: "filtering" } }
256
+ : { binding: b.binding, visibility, texture: { sampleType: "float", viewDimension: "3d" } });
257
+ }
258
+ bindEntries(slot) {
259
+ this.#check();
260
+ checkSlot(slot, "vdbDenseSource.bindEntries");
261
+ return this.#bindings(slot).map((b) => ({
262
+ binding: b.binding,
263
+ resource: b.kind === "sampler" ? this.#sampler : b.texture.createView({ dimension: "3d" }),
264
+ }));
265
+ }
266
+ dispose() {
267
+ if (this.#disposed)
268
+ return;
269
+ this.#destroyTextures();
270
+ this.#disposed = true;
271
+ }
272
+ }
273
+ /**
274
+ * Upload a dense `.wvdb` volume (`wvdbDenseVolume` from `@pmndrs/vdb/tools`) on
275
+ * the host's device. The source owns its textures and sampler; `dispose()` frees
276
+ * the textures (samplers have no destroy).
277
+ */
278
+ export function vdbDenseSource(device, volume, o = {}) {
279
+ if (!device || typeof device.createTexture !== "function") {
280
+ throw new VDBError("VDB_UNSUPPORTED_DEVICE", "vdbDenseSource: pass the host's GPUDevice.");
281
+ }
282
+ if (!volume || volume.kind !== "dense" || !volume.density) {
283
+ throw bad("vdbDenseSource: pass a dense volume from wvdbDenseVolume() (@pmndrs/vdb/tools).");
284
+ }
285
+ return new DenseSource(device, volume, o);
286
+ }
287
+ //# sourceMappingURL=dense.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dense.js","sourceRoot":"","sources":["../../../src/core/source/dense.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,sGAAsG;AACtG,uGAAuG;AACvG,2GAA2G;AAC3G,kGAAkG;AAClG,4GAA4G;AAC5G,uGAAuG;AACvG,oCAAoC;AAEpC;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAKxC,oGAAoG;AACpG,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,CAAC;AAClC,0DAA0D;AAC1D,MAAM,sBAAsB,GAAG,GAAG,GAAG,GAAG,CAAC;AAGzC,MAAM,QAAQ,GAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AACnF,MAAM,GAAG,GAAgC,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AAatH,MAAM,GAAG,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAEzE,SAAS,MAAM,CAAC,MAAiB,EAAE,IAA6B,EAAE,IAAuB,EAAE,MAAwB,EAAE,UAAkB,EAAE,KAAa;IACpJ,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAgC,CAAC;IACnD,IAAI,IAAI,CAAC,UAAU,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,EAAE,CAAC;QAC/C,MAAM,GAAG,CAAC,mBAAmB,KAAK,QAAQ,IAAI,CAAC,UAAU,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC;IAC5G,CAAC;IACD,M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SAAS;YAAE,OAAO;QAC3B,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF;AASD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAiB,EAAE,MAAuB,EAAE,IAA2B,EAAE;IACtG,IAAI,CAAC,MAAM,IAAI,OAAQ,MAAsC,CAAC,aAAa,KAAK,UAAU,EAAE,CAAC;QAC3F,MAAM,IAAI,QAAQ,CAAC,wBAAwB,EAAE,4CAA4C,CAAC,CAAC;IAC7F,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC1D,MAAM,GAAG,CAAC,iFAAiF,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/frameShaderChunks.js L834–1028 (createVolumeNodes: sampleMipAtlas,\n// sampleMipmapped, sample3D, sampleOptional), src/three-openvdb/frame/core/FrameVolume.js L14–22 and\n// src/three-openvdb/frame/webgpu/FrameRenderer.js L483–487 (texture setup: linear filter, clamp to edge,\n// no GPU mipmaps), src/three-openvdb/frame/webgpu/frameMipmaps.js L183–189 (mip atlas texture).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TSL → WGSL, raw WebGPU upload; mip level count from textureDimensions instead of a uniform.\n// Divergences: DIVERGES.md V23–V25.\n\n/**\n * `vdbDenseSource(device, volume)`: the dense `.wvdb` volume source on raw\n * WebGPU (K3.0, R1 §4.2). It uploads the bytes `wvdbDenseVolume` (tools) built,\n * as his renderer does: one 3D texture per channel (`r8unorm` density, mask and\n * emission; `rgba8unorm` albedo) plus a CPU box mip atlas per channel, sampled\n * with hardware trilinear (linear min/mag, clamp to edge, no GPU mipmaps).\n *\n * D10 says kernels need no textures; that holds for the sparse source. A\n * kernel compiled against a dense source binds textures, by the host's choice.\n */\n\nimport { VDBError } from \"../errors.js\";\nimport type { VDBSlot } from \"../types.js\";\nimport type { WvdbDenseTexture, WvdbDenseVolume } from \"../../tools/wvdb/dense.js\";\nimport type { VDBVolumeChannels, VDBVolumeSource, VDBVolumeSourceWgslOptions } from \"./types.js\";\n\n/** `GPUTextureUsage.TEXTURE_BINDING | COPY_DST` (0x04 | 0x02); the globals do not exist in Node. */\nconst TEXTURE_USAGE = 0x04 | 0x02;\n/** `GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE`. */\nconst STAGE_FRAGMENT_COMPUTE = 0x2 | 0x4;\n\ntype ChannelName = \"density\" | \"mask\" | \"albedo\" | \"emission\";\nconst CHANNELS: readonly ChannelName[] = [\"density\", \"mask\", \"albedo\", \"emission\"];\nconst CAP: Record<ChannelName, string> = { density: \"Density\", mask: \"Mask\", albedo: \"Albedo\", emission: \"Emission\" };\n\n/** Options of {@link vdbDenseSource}. */\nexport interface VDBDenseSourceOptions {\n /** Label prefix of the GPU objects. */\n label?: string;\n}\n\ninterface Uploaded {\n map: GPUTexture;\n mip: GPUTexture | null;\n}\n\nconst bad = (message: string) => new VDBError(\"VDB_BAD_OPTION\", message);\n\nfunction upload(device: GPUDevice, data: Uint8Array<ArrayBuffer>, dims: readonly number[], format: GPUTextureFormat, texelBytes: number, label: string): GPUTexture {\n const [w, h, d] = dims as [number, number, number];\n if (data.byteLength !== w * h * d * texelBytes) {\n throw bad(`vdbDenseSource: ${label} has ${data.byteLength} bytes, expected ${w}x${h}x${d}x${texelBytes}`);\n }\n const texture = device.createTexture({ label, size: [w, h, d], dimension: \"3d\", format, usage: TEXTURE_USAGE });\n // writeTexture has no 256-byte row alignment rule (only buffer copies do); FrameVolume uses unpackAlignment 1.\n device.queue.writeTexture({ texture }, data, { bytesPerRow: w * texelBytes, rowsPerImage: h }, [w, h, d]);\n return texture;\n}\n\nfunction uploadChannel(device: GPUDevice, tex: WvdbDenseTexture, label: string): Uploaded {\n const map = upload(device, tex.data, tex.dimensions, tex.format, tex.texelBytes, `${label}`);\n const mip = tex.mip ? upload(device, tex.mip.data, tex.mip.dimensions, tex.format, tex.texelBytes, `${label} mip atlas`) : null;\n return { map, mip };\n}\n\nfunction present(volume: WvdbDenseVolume): Record<ChannelName, WvdbDenseTexture | null> {\n return { density: volume.density, mask: volume.mask, albedo: volume.albedo, emission: volume.emission };\n}\n\nfunction checkSlot(slot: VDBSlot, where: string): VDBSlot {\n if (!slot || !Number.isInteger(slot.group) || slot.group < 0 || !Number.isInteger(slot.firstBinding) || slot.firstBinding < 0) {\n throw bad(`${where}: slot must be { group, firstBinding } with non-negative integers, got ${JSON.stringify(slot)}.`);\n }\n return slot;\n}\n\n/** WGSL for one channel's sample function (his sampleMipmapped / sampleMipAtlas, L838–877). */\nfunction channelWgsl(name: ChannelName, hasMip: boolean): string {\n const C = CAP[name];\n const map = `vdbSrc${C}Map`;\n if (!hasMip) {\n return `fn vdbSrcSample${C}(uvw: vec3f, lod: f32) -> vec4f {\\n return textureSampleLevel(${map}, vdbSrcSampler, uvw, 0.0);\\n}\\n`;\n }\n const mip = `vdbSrc${C}Mip`;\n return `fn vdbSrcMipAtlas${C}(level: f32, uvw: vec3f) -> vec4f {\n let texels = vec3f(textureDimensions(${map}));\n let atlas = vec3f(textureDimensions(${mip}));\n let size = max(vec3f(1.0), ceil(texels / exp2(level)));\n let offset = atlas.x - atlas.x / exp2(level - 1.0);\n let texel = clamp(uvw * size, vec3f(0.5), size - 0.5);\n return textureSampleLevel(${mip}, vdbSrcSampler, vec3f(texel.x + offset, texel.y, texel.z) / atlas, 0.0);\n}\nfn vdbSrcSample${C}(uvw: vec3f, lod: f32) -> vec4f {\n let level = min(lod, vdbSrcLevelCount(textureDimensions(${map})));\n if (level <= 0.0) {\n return textureSampleLevel(${map}, vdbSrcSampler, uvw, 0.0);\n }\n let level0 = floor(level);\n var low: vec4f;\n if (level0 < 0.5) {\n low = textureSampleLevel(${map}, vdbSrcSampler, uvw, 0.0);\n } else {\n low = vdbSrcMipAtlas${C}(level0, uvw);\n }\n let high = vdbSrcMipAtlas${C}(min(level0 + 1.0, vdbSrcLevelCount(textureDimensions(${map}))), uvw);\n return mix(low, high, level - level0);\n}\n`;\n}\n\nclass DenseSource implements VDBVolumeSource {\n readonly kind = \"dense\" as const;\n texels: [number, number, number];\n lodLevels: number;\n readonly channels: VDBVolumeChannels;\n stats: { meanNonZero: number; max: number; activeVoxels: number };\n /** Local unit box → uvw: translate by 0.5 (column-major). */\n readonly boxToSource = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1]);\n version = 0;\n readonly #device: GPUDevice;\n readonly #label: string;\n #volume: WvdbDenseVolume;\n #textures: Partial<Record<ChannelName, Uploaded>> = {};\n #sampler: GPUSampler;\n #disposed = false;\n\n constructor(device: GPUDevice, volume: WvdbDenseVolume, o: VDBDenseSourceOptions) {\n this.#device = device;\n this.#label = o.label ?? \"vdb dense source\";\n this.#volume = volume;\n this.channels = { mask: !!volume.mask, albedo: !!volume.albedo, emission: !!volume.emission };\n // FrameRenderer.js L483–487 + Data3DTexture defaults: linear, clamp to edge, no mipmaps.\n this.#sampler = device.createSampler({\n label: `${this.#label} sampler`,\n magFilter: \"linear\",\n minFilter: \"linear\",\n mipmapFilter: \"nearest\",\n addressModeU: \"clamp-to-edge\",\n addressModeV: \"clamp-to-edge\",\n addressModeW: \"clamp-to-edge\",\n });\n this.texels = [...volume.dimensions] as [number, number, number];\n this.lodLevels = volume.density.mip?.levels ?? 0;\n this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };\n this.#upload(volume);\n }\n\n #upload(volume: WvdbDenseVolume): void {\n const textures = present(volume);\n for (const name of CHANNELS) {\n const tex = textures[name];\n if (tex) this.#textures[name] = uploadChannel(this.#device, tex, `${this.#label} ${name}`);\n }\n }\n\n #destroyTextures(): void {\n for (const t of Object.values(this.#textures)) {\n t.map.destroy();\n t.mip?.destroy();\n }\n this.#textures = {};\n }\n\n #check(): void {\n if (this.#disposed) throw new VDBError(\"VDB_DISPOSED\", \"vdbDenseSource: the source was disposed; create a new one.\");\n }\n\n /** The textures as uploaded (for tests and adapters). */\n get volume(): WvdbDenseVolume {\n return this.#volume;\n }\n\n /**\n * Swap in another LOD (or frame) of the same grids. The channel set and mip\n * presence must match; a size change makes new textures and bumps `version`\n * (rebuild bind groups; the WGSL does not change).\n */\n replace(volume: WvdbDenseVolume): void {\n this.#check();\n const now = present(this.#volume);\n const next = present(volume);\n for (const name of CHANNELS) {\n if (!!now[name] !== !!next[name] || !!now[name]?.mip !== !!next[name]?.mip) {\n throw bad(`vdbDenseSource.replace: the ${name} channel or its mip atlas appears or disappears; create a new source (the WGSL differs).`);\n }\n }\n const sameSize = (a: WvdbDenseTexture | null, b: WvdbDenseTexture | null) =>\n !a || !b || (a.dimensions.every((v, i) => v === b.dimensions[i]) && (!a.mip || a.mip.dimensions.every((v, i) => v === b.mip!.dimensions[i])));\n if (CHANNELS.every((n) => sameSize(now[n], next[n]))) {\n for (const name of CHANNELS) {\n const tex = next[name];\n const up = this.#textures[name];\n if (!tex || !up) continue;\n const [w, h, d] = tex.dimensions;\n this.#device.queue.writeTexture({ texture: up.map }, tex.data, { bytesPerRow: w * tex.texelBytes, rowsPerImage: h }, [w, h, d]);\n if (tex.mip && up.mip) {\n const [aw, ah, ad] = tex.mip.dimensions;\n this.#device.queue.writeTexture({ texture: up.mip }, tex.mip.data, { bytesPerRow: aw * tex.texelBytes, rowsPerImage: ah }, [aw, ah, ad]);\n }\n }\n } else {\n this.#destroyTextures();\n this.#upload(volume);\n this.version++;\n }\n this.#volume = volume;\n this.texels = [...volume.dimensions] as [number, number, number];\n this.lodLevels = volume.density.mip?.levels ?? 0;\n this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };\n }\n\n /** Bindings in order: sampler, then per present channel its texture and its mip atlas. */\n #bindings(slot: VDBSlot): { name: string; binding: number; kind: \"sampler\" | \"texture\"; texture?: GPUTexture }[] {\n let b = slot.firstBinding;\n const out: { name: string; binding: number; kind: \"sampler\" | \"texture\"; texture?: GPUTexture }[] = [\n { name: \"vdbSrcSampler\", binding: b++, kind: \"sampler\" },\n ];\n for (const name of CHANNELS) {\n const t = this.#textures[name];\n if (!t) continue;\n out.push({ name: `vdbSrc${CAP[name]}Map`, binding: b++, kind: \"texture\", texture: t.map });\n if (t.mip) out.push({ name: `vdbSrc${CAP[name]}Mip`, binding: b++, kind: \"texture\", texture: t.mip });\n }\n return out;\n }\n\n wgsl(o: VDBVolumeSourceWgslOptions): string {\n this.#check();\n const slot = checkSlot(o.slot, \"vdbDenseSource.wgsl\");\n if (o.profile !== \"sample\" && o.profile !== \"march\") throw bad(`vdbDenseSource.wgsl: profile must be 'sample' or 'march', got ${JSON.stringify(o.profile)}.`);\n const on = (name: Exclude<ChannelName, \"density\">) => this.channels[name] && o.channels?.[name] !== false;\n const lines: string[] = [`// vdbDenseSource: dense .wvdb volume source (K3.0). ${this.#label}`];\n for (const b of this.#bindings(slot)) {\n lines.push(`@group(${slot.group}) @binding(${b.binding}) var ${b.name}: ${b.kind === \"sampler\" ? \"sampler\" : \"texture_3d<f32>\"};`);\n }\n lines.push(`\n// frameMipmaps.js getMipLevelCount: ceil(log2(max side)), exactly, in integers.\nfn vdbSrcLevelCount(dims: vec3u) -> f32 {\n let m = max(max(dims.x, dims.y), max(dims.z, 1u));\n if (m <= 1u) {\n return 0.0;\n }\n return f32(32u - countLeadingZeros(m - 1u));\n}\n`);\n const sampled: ChannelName[] = [\"density\", ...([\"mask\", \"albedo\", \"emission\"] as const).filter(on)];\n for (const name of sampled) lines.push(channelWgsl(name, !!this.#textures[name]?.mip));\n lines.push(`fn vdbSrcDensity(v: u32, uvw: vec3f, lod: f32) -> f32 {\n return vdbSrcSampleDensity(uvw, lod).r;\n}\nfn vdbSrcMask(v: u32, uvw: vec3f, lod: f32) -> f32 {\n return ${on(\"mask\") ? \"vdbSrcSampleMask(uvw, lod).r\" : \"1.0\"};\n}\nfn vdbSrcAlbedo(v: u32, uvw: vec3f, lod: f32) -> vec3f {\n return ${on(\"albedo\") ? \"vdbSrcSampleAlbedo(uvw, lod).rgb\" : \"vec3f(1.0)\"};\n}\nfn vdbSrcEmission(v: u32, uvw: vec3f, lod: f32) -> f32 {\n return ${on(\"emission\") ? \"vdbSrcSampleEmission(uvw, lod).r\" : \"0.0\"};\n}\nfn vdbSrcTexels(v: u32) -> vec3f {\n return vec3f(textureDimensions(vdbSrcDensityMap));\n}\nfn vdbSrcLodLevels(v: u32) -> f32 {\n return ${this.#textures.density?.mip ? \"vdbSrcLevelCount(textureDimensions(vdbSrcDensityMap))\" : \"0.0\"};\n}\n`);\n if (o.profile === \"march\") {\n // Dense: no empty-space structure; the march steps everywhere (R1 §4.2).\n lines.push(`fn vdbSrcSkipEmpty(v: u32, o: vec3f, d: vec3f, t0: f32, t1: f32) -> f32 {\n return t0;\n}\nfn vdbSrcMaxIn(v: u32, uvwMin: vec3f, uvwMax: vec3f) -> f32 {\n return ${this.stats.max.toFixed(9)};\n}\n`);\n }\n return lines.join(\"\\n\");\n }\n\n layoutEntries(slot: VDBSlot, visibility: GPUShaderStageFlags = STAGE_FRAGMENT_COMPUTE): GPUBindGroupLayoutEntry[] {\n this.#check();\n checkSlot(slot, \"vdbDenseSource.layoutEntries\");\n return this.#bindings(slot).map((b) =>\n b.kind === \"sampler\"\n ? { binding: b.binding, visibility, sampler: { type: \"filtering\" } }\n : { binding: b.binding, visibility, texture: { sampleType: \"float\", viewDimension: \"3d\" } },\n );\n }\n\n bindEntries(slot: VDBSlot): GPUBindGroupEntry[] {\n this.#check();\n checkSlot(slot, \"vdbDenseSource.bindEntries\");\n return this.#bindings(slot).map((b) => ({\n binding: b.binding,\n resource: b.kind === \"sampler\" ? this.#sampler : b.texture!.createView({ dimension: \"3d\" }),\n }));\n }\n\n dispose(): void {\n if (this.#disposed) return;\n this.#destroyTextures();\n this.#disposed = true;\n }\n}\n\n/** A dense source with `replace` (LOD swap). */\nexport type VDBDenseSource = VDBVolumeSource & {\n readonly kind: \"dense\";\n readonly volume: WvdbDenseVolume;\n replace(volume: WvdbDenseVolume): void;\n};\n\n/**\n * Upload a dense `.wvdb` volume (`wvdbDenseVolume` from `@pmndrs/vdb/tools`) on\n * the host's device. The source owns its textures and sampler; `dispose()` frees\n * the textures (samplers have no destroy).\n */\nexport function vdbDenseSource(device: GPUDevice, volume: WvdbDenseVolume, o: VDBDenseSourceOptions = {}): VDBDenseSource {\n if (!device || typeof (device as { createTexture?: unknown }).createTexture !== \"function\") {\n throw new VDBError(\"VDB_UNSUPPORTED_DEVICE\", \"vdbDenseSource: pass the host's GPUDevice.\");\n }\n if (!volume || volume.kind !== \"dense\" || !volume.density) {\n throw bad(\"vdbDenseSource: pass a dense volume from wvdbDenseVolume() (@pmndrs/vdb/tools).\");\n }\n return new DenseSource(device, volume, o);\n}\n"]}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The volume-source seam of the K3 renderer (R1 §4.2): the renderer's shading
3
+ * reads density, mask, albedo and emission through one interface, with two
4
+ * sources behind it, the sparse `VDBGridPool` (K3.2) and dense `.wvdb` levels
5
+ * (`vdbDenseSource`, K3.0). It mirrors mjurczyk's `createVolumeNodes()`
6
+ * (frameShaderChunks.js L834–1028), so his materials port with call-site edits.
7
+ */
8
+ import type { VDBSlot } from "../types.js";
9
+ /** Optional channels of a source; absent channels compile to constants (mask 1, albedo 1, emission 0). */
10
+ export interface VDBVolumeChannels {
11
+ readonly mask: boolean;
12
+ readonly albedo: boolean;
13
+ readonly emission: boolean;
14
+ }
15
+ /** The descriptive half of a source: what every adapter needs, whatever it binds. */
16
+ export interface VDBVolumeSourceInfo {
17
+ readonly kind: "sparse" | "dense";
18
+ /** Voxels across the box at lod 0 (dense: the texture size; sparse: the index bbox extent). */
19
+ readonly texels: readonly [number, number, number];
20
+ /** Prefiltered levels available above level 0 (0 = level 0 only). */
21
+ readonly lodLevels: number;
22
+ readonly channels: VDBVolumeChannels;
23
+ /** `meanNonZero` feeds `normalizeDensity`; `max` bounds the density; `activeVoxels` counts non-zero voxels. */
24
+ readonly stats: {
25
+ readonly meanNonZero: number;
26
+ readonly max: number;
27
+ readonly activeVoxels: number;
28
+ };
29
+ /** Column-major 4x4: local unit box [-0.5, 0.5]³ → source space (dense: uvw in [0, 1]³; sparse: index space). */
30
+ readonly boxToSource: Float32Array;
31
+ /** Bumps when bindings must be rebuilt (new textures after a LOD swap, pool growth). */
32
+ readonly version: number;
33
+ }
34
+ /** Options of {@link VDBVolumeSource.wgsl}. */
35
+ export interface VDBVolumeSourceWgslOptions {
36
+ readonly slot: VDBSlot;
37
+ /** `march` adds `vdbSrcSkipEmpty` and `vdbSrcMaxIn`. */
38
+ readonly profile: "sample" | "march";
39
+ /** Turn channels the source has off (compiled to constants). Channels it lacks are always constants. */
40
+ readonly channels?: Partial<VDBVolumeChannels>;
41
+ }
42
+ /**
43
+ * A volume source for raw WebGPU kernels. Generated WGSL (all names `vdbSrc*`):
44
+ *
45
+ * fn vdbSrcDensity (v: u32, uvw: vec3f, lod: f32) -> f32; // dense: [0, 1]
46
+ * fn vdbSrcMask (v: u32, uvw: vec3f, lod: f32) -> f32; // 1.0 when absent
47
+ * fn vdbSrcAlbedo (v: u32, uvw: vec3f, lod: f32) -> vec3f; // vec3(1) when absent
48
+ * fn vdbSrcEmission(v: u32, uvw: vec3f, lod: f32) -> f32; // 0.0 when absent
49
+ * fn vdbSrcTexels (v: u32) -> vec3f;
50
+ * fn vdbSrcLodLevels(v: u32) -> f32;
51
+ * // profile 'march':
52
+ * fn vdbSrcSkipEmpty(v: u32, o: vec3f, d: vec3f, t0: f32, t1: f32) -> f32;
53
+ * fn vdbSrcMaxIn (v: u32, uvwMin: vec3f, uvwMax: vec3f) -> f32;
54
+ *
55
+ * `uvw` is in [0, 1]³ of the source box, already offset and wrapped by the
56
+ * caller; `lod` is in levels (log2 of the footprint in lod-0 voxels).
57
+ */
58
+ export interface VDBVolumeSource extends VDBVolumeSourceInfo {
59
+ wgsl(o: VDBVolumeSourceWgslOptions): string;
60
+ layoutEntries(slot: VDBSlot, visibility?: GPUShaderStageFlags): GPUBindGroupLayoutEntry[];
61
+ bindEntries(slot: VDBSlot): GPUBindGroupEntry[];
62
+ dispose(): void;
63
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The volume-source seam of the K3 renderer (R1 §4.2): the renderer's shading
3
+ * reads density, mask, albedo and emission through one interface, with two
4
+ * sources behind it, the sparse `VDBGridPool` (K3.2) and dense `.wvdb` levels
5
+ * (`vdbDenseSource`, K3.0). It mirrors mjurczyk's `createVolumeNodes()`
6
+ * (frameShaderChunks.js L834–1028), so his materials port with call-site edits.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=types.js.map