@pmndrs/vdb 0.0.0-stage → 0.2.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 (570) hide show
  1. package/CHANGELOG.md +727 -0
  2. package/LICENSE +21 -0
  3. package/README.md +496 -2
  4. package/THIRD_PARTY_NOTICES.md +315 -0
  5. package/dist/core/compute/atlas.d.ts +102 -0
  6. package/dist/core/compute/atlas.js +103 -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/majorant-build.d.ts +45 -0
  12. package/dist/core/compute/majorant-build.js +193 -0
  13. package/dist/core/compute/majorant-build.js.map +1 -0
  14. package/dist/core/compute/multi-scale.d.ts +155 -0
  15. package/dist/core/compute/multi-scale.js +684 -0
  16. package/dist/core/compute/multi-scale.js.map +1 -0
  17. package/dist/core/compute/pyramid.d.ts +120 -0
  18. package/dist/core/compute/pyramid.js +468 -0
  19. package/dist/core/compute/pyramid.js.map +1 -0
  20. package/dist/core/compute/shared.d.ts +116 -0
  21. package/dist/core/compute/shared.js +211 -0
  22. package/dist/core/compute/shared.js.map +1 -0
  23. package/dist/core/compute/stats.d.ts +78 -0
  24. package/dist/core/compute/stats.js +193 -0
  25. package/dist/core/compute/stats.js.map +1 -0
  26. package/dist/core/compute/value-transform.d.ts +30 -0
  27. package/dist/core/compute/value-transform.js +64 -0
  28. package/dist/core/compute/value-transform.js.map +1 -0
  29. package/dist/core/errors.d.ts +21 -0
  30. package/dist/core/errors.js +17 -0
  31. package/dist/core/errors.js.map +1 -0
  32. package/dist/core/frame/emission.d.ts +85 -0
  33. package/dist/core/frame/emission.js +422 -0
  34. package/dist/core/frame/emission.js.map +1 -0
  35. package/dist/core/frame/environment.d.ts +47 -0
  36. package/dist/core/frame/environment.js +178 -0
  37. package/dist/core/frame/environment.js.map +1 -0
  38. package/dist/core/frame/index.d.ts +39 -0
  39. package/dist/core/frame/index.js +27 -0
  40. package/dist/core/frame/index.js.map +1 -0
  41. package/dist/core/frame/kernels.d.ts +115 -0
  42. package/dist/core/frame/kernels.js +496 -0
  43. package/dist/core/frame/kernels.js.map +1 -0
  44. package/dist/core/frame/limits.d.ts +67 -0
  45. package/dist/core/frame/limits.js +109 -0
  46. package/dist/core/frame/limits.js.map +1 -0
  47. package/dist/core/frame/phase.d.ts +17 -0
  48. package/dist/core/frame/phase.js +53 -0
  49. package/dist/core/frame/phase.js.map +1 -0
  50. package/dist/core/frame/pipelines.d.ts +49 -0
  51. package/dist/core/frame/pipelines.js +147 -0
  52. package/dist/core/frame/pipelines.js.map +1 -0
  53. package/dist/core/frame/renderer.d.ts +122 -0
  54. package/dist/core/frame/renderer.js +1712 -0
  55. package/dist/core/frame/renderer.js.map +1 -0
  56. package/dist/core/frame/resources.d.ts +71 -0
  57. package/dist/core/frame/resources.js +100 -0
  58. package/dist/core/frame/resources.js.map +1 -0
  59. package/dist/core/frame/scattering.d.ts +97 -0
  60. package/dist/core/frame/scattering.js +332 -0
  61. package/dist/core/frame/scattering.js.map +1 -0
  62. package/dist/core/frame/settings.d.ts +243 -0
  63. package/dist/core/frame/settings.js +67 -0
  64. package/dist/core/frame/settings.js.map +1 -0
  65. package/dist/core/frame/shadows.d.ts +55 -0
  66. package/dist/core/frame/shadows.js +460 -0
  67. package/dist/core/frame/shadows.js.map +1 -0
  68. package/dist/core/frame/types.d.ts +415 -0
  69. package/dist/core/frame/types.js +49 -0
  70. package/dist/core/frame/types.js.map +1 -0
  71. package/dist/core/frame/uniforms.d.ts +105 -0
  72. package/dist/core/frame/uniforms.js +276 -0
  73. package/dist/core/frame/uniforms.js.map +1 -0
  74. package/dist/core/frame/wgsl/chunks.d.ts +4 -0
  75. package/dist/core/frame/wgsl/chunks.js +728 -0
  76. package/dist/core/frame/wgsl/chunks.js.map +1 -0
  77. package/dist/core/frame/wgsl/emission.d.ts +82 -0
  78. package/dist/core/frame/wgsl/emission.js +353 -0
  79. package/dist/core/frame/wgsl/emission.js.map +1 -0
  80. package/dist/core/frame/wgsl/environment.d.ts +42 -0
  81. package/dist/core/frame/wgsl/environment.js +711 -0
  82. package/dist/core/frame/wgsl/environment.js.map +1 -0
  83. package/dist/core/frame/wgsl/gather.d.ts +55 -0
  84. package/dist/core/frame/wgsl/gather.js +850 -0
  85. package/dist/core/frame/wgsl/gather.js.map +1 -0
  86. package/dist/core/frame/wgsl/integrate.d.ts +78 -0
  87. package/dist/core/frame/wgsl/integrate.js +213 -0
  88. package/dist/core/frame/wgsl/integrate.js.map +1 -0
  89. package/dist/core/frame/wgsl/lighting.d.ts +103 -0
  90. package/dist/core/frame/wgsl/lighting.js +1636 -0
  91. package/dist/core/frame/wgsl/lighting.js.map +1 -0
  92. package/dist/core/frame/wgsl/occluders.d.ts +20 -0
  93. package/dist/core/frame/wgsl/occluders.js +95 -0
  94. package/dist/core/frame/wgsl/occluders.js.map +1 -0
  95. package/dist/core/frame/wgsl/resolve.d.ts +19 -0
  96. package/dist/core/frame/wgsl/resolve.js +205 -0
  97. package/dist/core/frame/wgsl/resolve.js.map +1 -0
  98. package/dist/core/frame/wgsl/shadows.d.ts +35 -0
  99. package/dist/core/frame/wgsl/shadows.js +328 -0
  100. package/dist/core/frame/wgsl/shadows.js.map +1 -0
  101. package/dist/core/half.d.ts +11 -0
  102. package/dist/core/half.js +22 -0
  103. package/dist/core/half.js.map +1 -0
  104. package/dist/core/index.d.ts +52 -0
  105. package/dist/core/index.js +46 -0
  106. package/dist/core/index.js.map +1 -0
  107. package/dist/core/internal.d.ts +31 -0
  108. package/dist/core/internal.js +32 -0
  109. package/dist/core/internal.js.map +1 -0
  110. package/dist/core/pool/affine.d.ts +34 -0
  111. package/dist/core/pool/affine.js +100 -0
  112. package/dist/core/pool/affine.js.map +1 -0
  113. package/dist/core/pool/allocator.d.ts +32 -0
  114. package/dist/core/pool/allocator.js +81 -0
  115. package/dist/core/pool/allocator.js.map +1 -0
  116. package/dist/core/pool/image-header.d.ts +93 -0
  117. package/dist/core/pool/image-header.js +194 -0
  118. package/dist/core/pool/image-header.js.map +1 -0
  119. package/dist/core/pool/layout.d.ts +198 -0
  120. package/dist/core/pool/layout.js +316 -0
  121. package/dist/core/pool/layout.js.map +1 -0
  122. package/dist/core/pool/limits.d.ts +41 -0
  123. package/dist/core/pool/limits.js +80 -0
  124. package/dist/core/pool/limits.js.map +1 -0
  125. package/dist/core/pool/pool.d.ts +384 -0
  126. package/dist/core/pool/pool.js +1184 -0
  127. package/dist/core/pool/pool.js.map +1 -0
  128. package/dist/core/reference/index.d.ts +6 -0
  129. package/dist/core/reference/index.js +7 -0
  130. package/dist/core/reference/index.js.map +1 -0
  131. package/dist/core/reference/renderer.d.ts +105 -0
  132. package/dist/core/reference/renderer.js +474 -0
  133. package/dist/core/reference/renderer.js.map +1 -0
  134. package/dist/core/reference/wgsl.d.ts +65 -0
  135. package/dist/core/reference/wgsl.js +803 -0
  136. package/dist/core/reference/wgsl.js.map +1 -0
  137. package/dist/core/sequence.d.ts +347 -0
  138. package/dist/core/sequence.js +548 -0
  139. package/dist/core/sequence.js.map +1 -0
  140. package/dist/core/source/brick-cache.d.ts +165 -0
  141. package/dist/core/source/brick-cache.js +627 -0
  142. package/dist/core/source/brick-cache.js.map +1 -0
  143. package/dist/core/source/dense-fill.d.ts +53 -0
  144. package/dist/core/source/dense-fill.js +377 -0
  145. package/dist/core/source/dense-fill.js.map +1 -0
  146. package/dist/core/source/dense.d.ts +50 -0
  147. package/dist/core/source/dense.js +384 -0
  148. package/dist/core/source/dense.js.map +1 -0
  149. package/dist/core/source/sparse-wgsl.d.ts +92 -0
  150. package/dist/core/source/sparse-wgsl.js +481 -0
  151. package/dist/core/source/sparse-wgsl.js.map +1 -0
  152. package/dist/core/source/sparse.d.ts +192 -0
  153. package/dist/core/source/sparse.js +762 -0
  154. package/dist/core/source/sparse.js.map +1 -0
  155. package/dist/core/source/types.d.ts +120 -0
  156. package/dist/core/source/types.js +9 -0
  157. package/dist/core/source/types.js.map +1 -0
  158. package/dist/core/surface/index.d.ts +10 -0
  159. package/dist/core/surface/index.js +9 -0
  160. package/dist/core/surface/index.js.map +1 -0
  161. package/dist/core/surface/level-set-pass.d.ts +140 -0
  162. package/dist/core/surface/level-set-pass.js +291 -0
  163. package/dist/core/surface/level-set-pass.js.map +1 -0
  164. package/dist/core/surface/level-set-wgsl.d.ts +46 -0
  165. package/dist/core/surface/level-set-wgsl.js +99 -0
  166. package/dist/core/surface/level-set-wgsl.js.map +1 -0
  167. package/dist/core/surface/points.d.ts +109 -0
  168. package/dist/core/surface/points.js +226 -0
  169. package/dist/core/surface/points.js.map +1 -0
  170. package/dist/core/types.d.ts +37 -0
  171. package/dist/core/types.js +32 -0
  172. package/dist/core/types.js.map +1 -0
  173. package/dist/core/wgsl/api.d.ts +65 -0
  174. package/dist/core/wgsl/api.js +546 -0
  175. package/dist/core/wgsl/api.js.map +1 -0
  176. package/dist/core/wgsl/generate.d.ts +90 -0
  177. package/dist/core/wgsl/generate.js +678 -0
  178. package/dist/core/wgsl/generate.js.map +1 -0
  179. package/dist/core/wgsl/lean.d.ts +50 -0
  180. package/dist/core/wgsl/lean.js +327 -0
  181. package/dist/core/wgsl/lean.js.map +1 -0
  182. package/dist/core/wgsl/level-set.d.ts +58 -0
  183. package/dist/core/wgsl/level-set.js +200 -0
  184. package/dist/core/wgsl/level-set.js.map +1 -0
  185. package/dist/core/wgsl/majorant.d.ts +62 -0
  186. package/dist/core/wgsl/majorant.js +381 -0
  187. package/dist/core/wgsl/majorant.js.map +1 -0
  188. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
  189. package/dist/core/wgsl/pnanovdb.chunks.generated.js +333 -0
  190. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
  191. package/dist/core/wgsl/reserved.d.ts +9 -0
  192. package/dist/core/wgsl/reserved.js +26 -0
  193. package/dist/core/wgsl/reserved.js.map +1 -0
  194. package/dist/core/wgsl/types.d.ts +198 -0
  195. package/dist/core/wgsl/types.js +2 -0
  196. package/dist/core/wgsl/types.js.map +1 -0
  197. package/dist/three/coarse-first.d.ts +207 -0
  198. package/dist/three/coarse-first.js +205 -0
  199. package/dist/three/coarse-first.js.map +1 -0
  200. package/dist/three/compute.d.ts +73 -0
  201. package/dist/three/compute.js +66 -0
  202. package/dist/three/compute.js.map +1 -0
  203. package/dist/three/device.d.ts +66 -0
  204. package/dist/three/device.js +62 -0
  205. package/dist/three/device.js.map +1 -0
  206. package/dist/three/frame/core-environment.d.ts +38 -0
  207. package/dist/three/frame/core-environment.js +154 -0
  208. package/dist/three/frame/core-environment.js.map +1 -0
  209. package/dist/three/frame/core-integrate-material.d.ts +34 -0
  210. package/dist/three/frame/core-integrate-material.js +162 -0
  211. package/dist/three/frame/core-integrate-material.js.map +1 -0
  212. package/dist/three/frame/core-occluders.d.ts +53 -0
  213. package/dist/three/frame/core-occluders.js +193 -0
  214. package/dist/three/frame/core-occluders.js.map +1 -0
  215. package/dist/three/frame/core-structs.d.ts +34 -0
  216. package/dist/three/frame/core-structs.js +61 -0
  217. package/dist/three/frame/core-structs.js.map +1 -0
  218. package/dist/three/frame/core-textures.d.ts +41 -0
  219. package/dist/three/frame/core-textures.js +114 -0
  220. package/dist/three/frame/core-textures.js.map +1 -0
  221. package/dist/three/frame/emission-light.d.ts +117 -0
  222. package/dist/three/frame/emission-light.js +276 -0
  223. package/dist/three/frame/emission-light.js.map +1 -0
  224. package/dist/three/frame/index.d.ts +19 -0
  225. package/dist/three/frame/index.js +15 -0
  226. package/dist/three/frame/index.js.map +1 -0
  227. package/dist/three/frame/medium.d.ts +33 -0
  228. package/dist/three/frame/medium.js +29 -0
  229. package/dist/three/frame/medium.js.map +1 -0
  230. package/dist/three/frame/renderer.d.ts +97 -0
  231. package/dist/three/frame/renderer.js +480 -0
  232. package/dist/three/frame/renderer.js.map +1 -0
  233. package/dist/three/frame/spectrum.d.ts +4 -0
  234. package/dist/three/frame/spectrum.js +15 -0
  235. package/dist/three/frame/spectrum.js.map +1 -0
  236. package/dist/three/frame/three-internals.d.ts +60 -0
  237. package/dist/three/frame/three-internals.js +152 -0
  238. package/dist/three/frame/three-internals.js.map +1 -0
  239. package/dist/three/frame/volume-shadows.d.ts +139 -0
  240. package/dist/three/frame/volume-shadows.js +403 -0
  241. package/dist/three/frame/volume-shadows.js.map +1 -0
  242. package/dist/three/frame/volume.d.ts +230 -0
  243. package/dist/three/frame/volume.js +268 -0
  244. package/dist/three/frame/volume.js.map +1 -0
  245. package/dist/three/grid-node.d.ts +229 -0
  246. package/dist/three/grid-node.js +545 -0
  247. package/dist/three/grid-node.js.map +1 -0
  248. package/dist/three/index.d.ts +52 -0
  249. package/dist/three/index.js +58 -0
  250. package/dist/three/index.js.map +1 -0
  251. package/dist/three/internal.d.ts +20 -0
  252. package/dist/three/internal.js +18 -0
  253. package/dist/three/internal.js.map +1 -0
  254. package/dist/three/level-set-material.d.ts +185 -0
  255. package/dist/three/level-set-material.js +241 -0
  256. package/dist/three/level-set-material.js.map +1 -0
  257. package/dist/three/level-set-physical-material.d.ts +154 -0
  258. package/dist/three/level-set-physical-material.js +253 -0
  259. package/dist/three/level-set-physical-material.js.map +1 -0
  260. package/dist/three/level-set-velocity.d.ts +94 -0
  261. package/dist/three/level-set-velocity.js +208 -0
  262. package/dist/three/level-set-velocity.js.map +1 -0
  263. package/dist/three/material.d.ts +324 -0
  264. package/dist/three/material.js +502 -0
  265. package/dist/three/material.js.map +1 -0
  266. package/dist/three/points.d.ts +140 -0
  267. package/dist/three/points.js +261 -0
  268. package/dist/three/points.js.map +1 -0
  269. package/dist/three/sparse-source.d.ts +165 -0
  270. package/dist/three/sparse-source.js +405 -0
  271. package/dist/three/sparse-source.js.map +1 -0
  272. package/dist/three/volume-source.d.ts +22 -0
  273. package/dist/three/volume-source.js +110 -0
  274. package/dist/three/volume-source.js.map +1 -0
  275. package/dist/tools/cpu/brick-atlas.d.ts +36 -0
  276. package/dist/tools/cpu/brick-atlas.js +129 -0
  277. package/dist/tools/cpu/brick-atlas.js.map +1 -0
  278. package/dist/tools/cpu/compute.d.ts +116 -0
  279. package/dist/tools/cpu/compute.js +239 -0
  280. package/dist/tools/cpu/compute.js.map +1 -0
  281. package/dist/tools/cpu/lean-reads.d.ts +81 -0
  282. package/dist/tools/cpu/lean-reads.js +262 -0
  283. package/dist/tools/cpu/lean-reads.js.map +1 -0
  284. package/dist/tools/cpu/level-set.d.ts +111 -0
  285. package/dist/tools/cpu/level-set.js +313 -0
  286. package/dist/tools/cpu/level-set.js.map +1 -0
  287. package/dist/tools/cpu/majorant.d.ts +265 -0
  288. package/dist/tools/cpu/majorant.js +541 -0
  289. package/dist/tools/cpu/majorant.js.map +1 -0
  290. package/dist/tools/cpu/march.d.ts +297 -0
  291. package/dist/tools/cpu/march.js +726 -0
  292. package/dist/tools/cpu/march.js.map +1 -0
  293. package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
  294. package/dist/tools/cpu/mesh-decimate.js +1225 -0
  295. package/dist/tools/cpu/mesh-decimate.js.map +1 -0
  296. package/dist/tools/cpu/points.d.ts +29 -0
  297. package/dist/tools/cpu/points.js +38 -0
  298. package/dist/tools/cpu/points.js.map +1 -0
  299. package/dist/tools/cpu/probe-coords.d.ts +70 -0
  300. package/dist/tools/cpu/probe-coords.js +116 -0
  301. package/dist/tools/cpu/probe-coords.js.map +1 -0
  302. package/dist/tools/cpu/read-value.d.ts +44 -0
  303. package/dist/tools/cpu/read-value.js +351 -0
  304. package/dist/tools/cpu/read-value.js.map +1 -0
  305. package/dist/tools/cpu/sample-trilinear.d.ts +43 -0
  306. package/dist/tools/cpu/sample-trilinear.js +168 -0
  307. package/dist/tools/cpu/sample-trilinear.js.map +1 -0
  308. package/dist/tools/cpu/stride-tables.d.ts +56 -0
  309. package/dist/tools/cpu/stride-tables.generated.d.ts +1059 -0
  310. package/dist/tools/cpu/stride-tables.generated.js +1267 -0
  311. package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
  312. package/dist/tools/cpu/stride-tables.js +78 -0
  313. package/dist/tools/cpu/stride-tables.js.map +1 -0
  314. package/dist/tools/cpu/surface-nets.d.ts +90 -0
  315. package/dist/tools/cpu/surface-nets.js +597 -0
  316. package/dist/tools/cpu/surface-nets.js.map +1 -0
  317. package/dist/tools/errors.d.ts +66 -0
  318. package/dist/tools/errors.js +67 -0
  319. package/dist/tools/errors.js.map +1 -0
  320. package/dist/tools/frame/ambient.d.ts +98 -0
  321. package/dist/tools/frame/ambient.js +274 -0
  322. package/dist/tools/frame/ambient.js.map +1 -0
  323. package/dist/tools/frame/blackbody.d.ts +57 -0
  324. package/dist/tools/frame/blackbody.js +151 -0
  325. package/dist/tools/frame/blackbody.js.map +1 -0
  326. package/dist/tools/frame/brick-cache.d.ts +165 -0
  327. package/dist/tools/frame/brick-cache.js +326 -0
  328. package/dist/tools/frame/brick-cache.js.map +1 -0
  329. package/dist/tools/frame/emission.d.ts +137 -0
  330. package/dist/tools/frame/emission.js +290 -0
  331. package/dist/tools/frame/emission.js.map +1 -0
  332. package/dist/tools/frame/environment-gpu.d.ts +111 -0
  333. package/dist/tools/frame/environment-gpu.js +280 -0
  334. package/dist/tools/frame/environment-gpu.js.map +1 -0
  335. package/dist/tools/frame/environment.d.ts +106 -0
  336. package/dist/tools/frame/environment.js +272 -0
  337. package/dist/tools/frame/environment.js.map +1 -0
  338. package/dist/tools/frame/froxel.d.ts +58 -0
  339. package/dist/tools/frame/froxel.js +115 -0
  340. package/dist/tools/frame/froxel.js.map +1 -0
  341. package/dist/tools/frame/grid.d.ts +392 -0
  342. package/dist/tools/frame/grid.js +802 -0
  343. package/dist/tools/frame/grid.js.map +1 -0
  344. package/dist/tools/frame/index.d.ts +150 -0
  345. package/dist/tools/frame/index.js +389 -0
  346. package/dist/tools/frame/index.js.map +1 -0
  347. package/dist/tools/frame/medium.d.ts +77 -0
  348. package/dist/tools/frame/medium.js +101 -0
  349. package/dist/tools/frame/medium.js.map +1 -0
  350. package/dist/tools/frame/mie-table.d.ts +6 -0
  351. package/dist/tools/frame/mie-table.js +16 -0
  352. package/dist/tools/frame/mie-table.js.map +1 -0
  353. package/dist/tools/frame/mie.d.ts +63 -0
  354. package/dist/tools/frame/mie.js +194 -0
  355. package/dist/tools/frame/mie.js.map +1 -0
  356. package/dist/tools/frame/mlp-nn.d.ts +36 -0
  357. package/dist/tools/frame/mlp-nn.js +159 -0
  358. package/dist/tools/frame/mlp-nn.js.map +1 -0
  359. package/dist/tools/frame/mlp-tza.d.ts +29 -0
  360. package/dist/tools/frame/mlp-tza.js +186 -0
  361. package/dist/tools/frame/mlp-tza.js.map +1 -0
  362. package/dist/tools/frame/mlp.d.ts +183 -0
  363. package/dist/tools/frame/mlp.js +434 -0
  364. package/dist/tools/frame/mlp.js.map +1 -0
  365. package/dist/tools/frame/ms-exit.d.ts +42 -0
  366. package/dist/tools/frame/ms-exit.js +90 -0
  367. package/dist/tools/frame/ms-exit.js.map +1 -0
  368. package/dist/tools/frame/multi-scale.d.ts +152 -0
  369. package/dist/tools/frame/multi-scale.js +302 -0
  370. package/dist/tools/frame/multi-scale.js.map +1 -0
  371. package/dist/tools/frame/neural-weights.d.ts +10 -0
  372. package/dist/tools/frame/neural-weights.js +244 -0
  373. package/dist/tools/frame/neural-weights.js.map +1 -0
  374. package/dist/tools/frame/neural.d.ts +80 -0
  375. package/dist/tools/frame/neural.js +150 -0
  376. package/dist/tools/frame/neural.js.map +1 -0
  377. package/dist/tools/frame/occluders.d.ts +51 -0
  378. package/dist/tools/frame/occluders.js +72 -0
  379. package/dist/tools/frame/occluders.js.map +1 -0
  380. package/dist/tools/frame/pyramid-layout.d.ts +55 -0
  381. package/dist/tools/frame/pyramid-layout.js +100 -0
  382. package/dist/tools/frame/pyramid-layout.js.map +1 -0
  383. package/dist/tools/frame/shadows.d.ts +190 -0
  384. package/dist/tools/frame/shadows.js +468 -0
  385. package/dist/tools/frame/shadows.js.map +1 -0
  386. package/dist/tools/frame/sparse.d.ts +147 -0
  387. package/dist/tools/frame/sparse.js +432 -0
  388. package/dist/tools/frame/sparse.js.map +1 -0
  389. package/dist/tools/frame/spectral-stack.d.ts +159 -0
  390. package/dist/tools/frame/spectral-stack.js +391 -0
  391. package/dist/tools/frame/spectral-stack.js.map +1 -0
  392. package/dist/tools/frame/spectral.d.ts +222 -0
  393. package/dist/tools/frame/spectral.js +572 -0
  394. package/dist/tools/frame/spectral.js.map +1 -0
  395. package/dist/tools/frame/stack.d.ts +115 -0
  396. package/dist/tools/frame/stack.js +290 -0
  397. package/dist/tools/frame/stack.js.map +1 -0
  398. package/dist/tools/frame/view.d.ts +131 -0
  399. package/dist/tools/frame/view.js +337 -0
  400. package/dist/tools/frame/view.js.map +1 -0
  401. package/dist/tools/index.d.ts +157 -0
  402. package/dist/tools/index.js +132 -0
  403. package/dist/tools/index.js.map +1 -0
  404. package/dist/tools/internal.d.ts +87 -0
  405. package/dist/tools/internal.js +85 -0
  406. package/dist/tools/internal.js.map +1 -0
  407. package/dist/tools/nanovdb/build-from-vdb.d.ts +59 -0
  408. package/dist/tools/nanovdb/build-from-vdb.js +100 -0
  409. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
  410. package/dist/tools/nanovdb/bytes.d.ts +233 -0
  411. package/dist/tools/nanovdb/bytes.js +388 -0
  412. package/dist/tools/nanovdb/bytes.js.map +1 -0
  413. package/dist/tools/nanovdb/coarse-first.d.ts +78 -0
  414. package/dist/tools/nanovdb/coarse-first.js +92 -0
  415. package/dist/tools/nanovdb/coarse-first.js.map +1 -0
  416. package/dist/tools/nanovdb/half.d.ts +22 -0
  417. package/dist/tools/nanovdb/half.js +73 -0
  418. package/dist/tools/nanovdb/half.js.map +1 -0
  419. package/dist/tools/nanovdb/index.d.ts +34 -0
  420. package/dist/tools/nanovdb/index.js +25 -0
  421. package/dist/tools/nanovdb/index.js.map +1 -0
  422. package/dist/tools/nanovdb/inspect.d.ts +33 -0
  423. package/dist/tools/nanovdb/inspect.js +70 -0
  424. package/dist/tools/nanovdb/inspect.js.map +1 -0
  425. package/dist/tools/nanovdb/leaf-codec.d.ts +119 -0
  426. package/dist/tools/nanovdb/leaf-codec.js +356 -0
  427. package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
  428. package/dist/tools/nanovdb/quantize.d.ts +72 -0
  429. package/dist/tools/nanovdb/quantize.js +329 -0
  430. package/dist/tools/nanovdb/quantize.js.map +1 -0
  431. package/dist/tools/nanovdb/resample.d.ts +177 -0
  432. package/dist/tools/nanovdb/resample.js +692 -0
  433. package/dist/tools/nanovdb/resample.js.map +1 -0
  434. package/dist/tools/nanovdb/serialize.d.ts +176 -0
  435. package/dist/tools/nanovdb/serialize.js +439 -0
  436. package/dist/tools/nanovdb/serialize.js.map +1 -0
  437. package/dist/tools/nanovdb/stats.d.ts +87 -0
  438. package/dist/tools/nanovdb/stats.js +225 -0
  439. package/dist/tools/nanovdb/stats.js.map +1 -0
  440. package/dist/tools/nanovdb/transform.d.ts +30 -0
  441. package/dist/tools/nanovdb/transform.js +94 -0
  442. package/dist/tools/nanovdb/transform.js.map +1 -0
  443. package/dist/tools/nanovdb/tree.d.ts +186 -0
  444. package/dist/tools/nanovdb/tree.js +530 -0
  445. package/dist/tools/nanovdb/tree.js.map +1 -0
  446. package/dist/tools/nanovdb/write-nvdb.d.ts +74 -0
  447. package/dist/tools/nanovdb/write-nvdb.js +290 -0
  448. package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
  449. package/dist/tools/nvdb-file.d.ts +265 -0
  450. package/dist/tools/nvdb-file.js +763 -0
  451. package/dist/tools/nvdb-file.js.map +1 -0
  452. package/dist/tools/nvdb-stream.d.ts +154 -0
  453. package/dist/tools/nvdb-stream.js +409 -0
  454. package/dist/tools/nvdb-stream.js.map +1 -0
  455. package/dist/tools/reference/analytic.d.ts +41 -0
  456. package/dist/tools/reference/analytic.js +95 -0
  457. package/dist/tools/reference/analytic.js.map +1 -0
  458. package/dist/tools/reference/environment.d.ts +62 -0
  459. package/dist/tools/reference/environment.js +154 -0
  460. package/dist/tools/reference/environment.js.map +1 -0
  461. package/dist/tools/reference/index.d.ts +12 -0
  462. package/dist/tools/reference/index.js +13 -0
  463. package/dist/tools/reference/index.js.map +1 -0
  464. package/dist/tools/reference/media.d.ts +14 -0
  465. package/dist/tools/reference/media.js +30 -0
  466. package/dist/tools/reference/media.js.map +1 -0
  467. package/dist/tools/reference/rng.d.ts +20 -0
  468. package/dist/tools/reference/rng.js +30 -0
  469. package/dist/tools/reference/rng.js.map +1 -0
  470. package/dist/tools/reference/scene.d.ts +312 -0
  471. package/dist/tools/reference/scene.js +169 -0
  472. package/dist/tools/reference/scene.js.map +1 -0
  473. package/dist/tools/reference/tables.d.ts +98 -0
  474. package/dist/tools/reference/tables.js +264 -0
  475. package/dist/tools/reference/tables.js.map +1 -0
  476. package/dist/tools/reference/trace.d.ts +160 -0
  477. package/dist/tools/reference/trace.js +497 -0
  478. package/dist/tools/reference/trace.js.map +1 -0
  479. package/dist/tools/vdb/bit-utils.d.ts +20 -0
  480. package/dist/tools/vdb/bit-utils.js +42 -0
  481. package/dist/tools/vdb/bit-utils.js.map +1 -0
  482. package/dist/tools/vdb/blosc-write.d.ts +43 -0
  483. package/dist/tools/vdb/blosc-write.js +197 -0
  484. package/dist/tools/vdb/blosc-write.js.map +1 -0
  485. package/dist/tools/vdb/blosc.d.ts +86 -0
  486. package/dist/tools/vdb/blosc.js +287 -0
  487. package/dist/tools/vdb/blosc.js.map +1 -0
  488. package/dist/tools/vdb/blosclz.d.ts +33 -0
  489. package/dist/tools/vdb/blosclz.js +112 -0
  490. package/dist/tools/vdb/blosclz.js.map +1 -0
  491. package/dist/tools/vdb/byte-reader.d.ts +50 -0
  492. package/dist/tools/vdb/byte-reader.js +161 -0
  493. package/dist/tools/vdb/byte-reader.js.map +1 -0
  494. package/dist/tools/vdb/compression.d.ts +81 -0
  495. package/dist/tools/vdb/compression.js +260 -0
  496. package/dist/tools/vdb/compression.js.map +1 -0
  497. package/dist/tools/vdb/errors.d.ts +10 -0
  498. package/dist/tools/vdb/errors.js +11 -0
  499. package/dist/tools/vdb/errors.js.map +1 -0
  500. package/dist/tools/vdb/grid.d.ts +37 -0
  501. package/dist/tools/vdb/grid.js +153 -0
  502. package/dist/tools/vdb/grid.js.map +1 -0
  503. package/dist/tools/vdb/half-float.d.ts +9 -0
  504. package/dist/tools/vdb/half-float.js +24 -0
  505. package/dist/tools/vdb/half-float.js.map +1 -0
  506. package/dist/tools/vdb/index.d.ts +4 -0
  507. package/dist/tools/vdb/index.js +3 -0
  508. package/dist/tools/vdb/index.js.map +1 -0
  509. package/dist/tools/vdb/inflate.d.ts +24 -0
  510. package/dist/tools/vdb/inflate.js +334 -0
  511. package/dist/tools/vdb/inflate.js.map +1 -0
  512. package/dist/tools/vdb/lz4.d.ts +30 -0
  513. package/dist/tools/vdb/lz4.js +228 -0
  514. package/dist/tools/vdb/lz4.js.map +1 -0
  515. package/dist/tools/vdb/metadata.d.ts +17 -0
  516. package/dist/tools/vdb/metadata.js +72 -0
  517. package/dist/tools/vdb/metadata.js.map +1 -0
  518. package/dist/tools/vdb/parse.d.ts +47 -0
  519. package/dist/tools/vdb/parse.js +241 -0
  520. package/dist/tools/vdb/parse.js.map +1 -0
  521. package/dist/tools/vdb/point-render-data.d.ts +79 -0
  522. package/dist/tools/vdb/point-render-data.js +137 -0
  523. package/dist/tools/vdb/point-render-data.js.map +1 -0
  524. package/dist/tools/vdb/points.d.ts +186 -0
  525. package/dist/tools/vdb/points.js +835 -0
  526. package/dist/tools/vdb/points.js.map +1 -0
  527. package/dist/tools/vdb/transform.d.ts +23 -0
  528. package/dist/tools/vdb/transform.js +54 -0
  529. package/dist/tools/vdb/transform.js.map +1 -0
  530. package/dist/tools/vdb/tree.d.ts +111 -0
  531. package/dist/tools/vdb/tree.js +228 -0
  532. package/dist/tools/vdb/tree.js.map +1 -0
  533. package/dist/tools/vdb/types.d.ts +195 -0
  534. package/dist/tools/vdb/types.js +3 -0
  535. package/dist/tools/vdb/types.js.map +1 -0
  536. package/dist/tools/wvdb/bake.d.ts +145 -0
  537. package/dist/tools/wvdb/bake.js +361 -0
  538. package/dist/tools/wvdb/bake.js.map +1 -0
  539. package/dist/tools/wvdb/dense.d.ts +191 -0
  540. package/dist/tools/wvdb/dense.js +368 -0
  541. package/dist/tools/wvdb/dense.js.map +1 -0
  542. package/dist/tools/wvdb/format.d.ts +220 -0
  543. package/dist/tools/wvdb/format.js +306 -0
  544. package/dist/tools/wvdb/format.js.map +1 -0
  545. package/dist/tools/wvdb/index.d.ts +14 -0
  546. package/dist/tools/wvdb/index.js +15 -0
  547. package/dist/tools/wvdb/index.js.map +1 -0
  548. package/dist/tools/wvdb/level-set.d.ts +56 -0
  549. package/dist/tools/wvdb/level-set.js +153 -0
  550. package/dist/tools/wvdb/level-set.js.map +1 -0
  551. package/dist/tools/wvdb/nanovdb.d.ts +59 -0
  552. package/dist/tools/wvdb/nanovdb.js +64 -0
  553. package/dist/tools/wvdb/nanovdb.js.map +1 -0
  554. package/dist/tools/wvdb/partial.d.ts +74 -0
  555. package/dist/tools/wvdb/partial.js +233 -0
  556. package/dist/tools/wvdb/partial.js.map +1 -0
  557. package/dist/tools/wvdb/read.d.ts +336 -0
  558. package/dist/tools/wvdb/read.js +766 -0
  559. package/dist/tools/wvdb/read.js.map +1 -0
  560. package/dist/tools/wvdb/sha256.d.ts +7 -0
  561. package/dist/tools/wvdb/sha256.js +76 -0
  562. package/dist/tools/wvdb/sha256.js.map +1 -0
  563. package/dist/tools/wvdb/write.d.ts +149 -0
  564. package/dist/tools/wvdb/write.js +403 -0
  565. package/dist/tools/wvdb/write.js.map +1 -0
  566. package/package.json +83 -4
  567. package/vendor/LICENSE +201 -0
  568. package/vendor/NOTICE +19 -0
  569. package/vendor/VENDOR.md +100 -0
  570. package/vendor/pnanovdb.wgsl +1577 -0
@@ -0,0 +1,678 @@
1
+ /**
2
+ * WGSL module generator (docs/dev/design/K1-core.md §3, task K1.4a).
3
+ *
4
+ * Roots for the profile and options (the vendored names the API layer uses)
5
+ * -> closure over the declaration table extracted from the unmodified vendored
6
+ * `pnanovdb.wgsl` -> generation transforms -> `pnanovdb_`→`vdb_` rename ->
7
+ * append the API layer -> prepend one SPDX line.
8
+ *
9
+ * Generation transforms (each one is a row in vendor/VENDOR.md, "Generation
10
+ * transforms"; none edits the vendored file):
11
+ * 1. `pnanovdb_buf_read_uint32` reads through `vdb_load`, the module's single
12
+ * buffer access site (§2).
13
+ * 2. The 27-row `pnanovdb_grid_type_constants` array becomes
14
+ * `fn vdb_gtc(grid_type)` returning only the compiled types' rows; its
15
+ * `[grid_type]` call sites become `vdb_gtc(grid_type)`.
16
+ * 3. `pnanovdb_read_float_typed` keeps only the compiled types' branches, so
17
+ * the other decoders drop out of the closure.
18
+ * 4. Declarations unreachable from the profile's roots are not emitted (the
19
+ * `pnanovdb_sample_trilinear_{float,fp8,fpn}` wrappers among them).
20
+ * 5. Every `pnanovdb_` / `PNANOVDB_` becomes `vdb_` / `VDB_`.
21
+ * 6. Comments are dropped (done at extraction).
22
+ * 7. `pnanovdb_leaf_get_stat_float` keeps only the compiled types' branch
23
+ * (the Fp leaf-stats decode, K1.4b), so a Float-only module has no
24
+ * uint16 decoder.
25
+ * 8. Half min/max stats (K7.H): without `half`, calls to
26
+ * `pnanovdb_read_minmax_float` / `pnanovdb_leaf_get_minmax_float` are
27
+ * rewritten to the plain readers they wrap (so modules without `half` are
28
+ * byte-identical to those generated before Half existed); with `half`,
29
+ * the two keep only the compiled types' branch.
30
+ *
31
+ * Output is deterministic: the same options give the same bytes, and `types`
32
+ * is a set (order and duplicates do not matter).
33
+ */
34
+ import { VDBError } from "../errors.js";
35
+ import { VDB_GPU_LAYOUT_VERSION, vdbPoolLayoutWgsl } from "../pool/layout.js";
36
+ import { VDB_GRID_TYPE_IDS, VDB_GRID_TYPE_NAMES } from "../types.js";
37
+ import { apiPublicFunctions, apiWgsl, hasMarch, pruneApiWgsl } from "./api.js";
38
+ import { WGSL_KEYWORDS, WGSL_RESERVED_WORDS } from "./reserved.js";
39
+ import { PNANOVDB_CHUNKS } from "./pnanovdb.chunks.generated.js";
40
+ /** First line of every generated module (§3.3). */
41
+ export const VDB_MODULE_BANNER = "// SPDX-License-Identifier: Apache-2.0 AND MIT. Derived from PNanoVDB.h (OpenVDB) via emcfarlane/webgpu-nanovdb; see NOTICE.";
42
+ /** Name of the storage binding `slot` mode declares. */
43
+ export const VDB_POOL_BINDING_NAME = "vdbPool";
44
+ /** Profiles in inclusion order (`majorant`, P1.3, takes the march layer only with `majorant: 'nodeMax'`). */
45
+ const PROFILES = ["read", "sample", "march", "majorant"];
46
+ const MAJORANT_MODES = ["brick", "global", "nodeMax"];
47
+ /** `GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE` (0x2 | 0x4); the global does not exist in Node. */
48
+ const SHADER_STAGE_FRAGMENT_COMPUTE = 0x2 | 0x4;
49
+ /** Opt-in helpers in canonical order, with the lowest profile rank each needs. */
50
+ const HELPERS = {
51
+ cellBoundTrilinear: { rank: 2 },
52
+ hddaCellEnd: { rank: 2 },
53
+ levelSet: { rank: 2 },
54
+ nodeAverage: { rank: 2 },
55
+ rayClipSupport: { rank: 1 },
56
+ fastTrilinear: { rank: 1 },
57
+ // EX1f-b, the majorant profile's helpers (appended: the canonical order of the older ones is unchanged).
58
+ majorantWorld: { rank: 3 },
59
+ majorantGlobal: { rank: 3 },
60
+ deltaTrack: { rank: 3 },
61
+ ratioTrack: { rank: 3 },
62
+ // P1.16, the lean reader's unchecked init (appended).
63
+ accessorUnchecked: { rank: 0 },
64
+ };
65
+ /** Helpers that never touch the vendored accessor (the lean reader takes them). */
66
+ const LEAN_HELPERS = ["rayClipSupport", "majorantWorld", "majorantGlobal", "deltaTrack", "ratioTrack", "accessorUnchecked"];
67
+ const LEAN_CACHES = ["leaf", "lower", "lowerLeaf"];
68
+ const TRACK_HELPERS = ["deltaTrack", "ratioTrack"];
69
+ const WGSL_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
70
+ const HELPER_NAMES = Object.keys(HELPERS);
71
+ const IDENTIFIER = /[A-Za-z_][A-Za-z0-9_]*/g;
72
+ const BUFFER_EXPRESSION = /^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/;
73
+ function bad(message) {
74
+ return new VDBError("VDB_BAD_OPTION", message);
75
+ }
76
+ function checkSlot(slot, where) {
77
+ const s = slot;
78
+ if (s === null ||
79
+ typeof s !== "object" ||
80
+ !Number.isInteger(s.group) ||
81
+ !Number.isInteger(s.firstBinding) ||
82
+ s.group < 0 ||
83
+ s.firstBinding < 0) {
84
+ throw bad(`${where}: slot must be { group, firstBinding } with non-negative integers, got ${JSON.stringify(slot)}.`);
85
+ }
86
+ return { group: s.group, firstBinding: s.firstBinding };
87
+ }
88
+ /** The old bvh-style positional slot (`{ group, firstBinding }` at the top level of the module options) would be silently misread. */
89
+ function rejectPositionalSlot(where, options) {
90
+ if ("group" in options || "firstBinding" in options) {
91
+ throw bad(`${where}: got 'group' or 'firstBinding' at the top level. Pass { slot: { group, firstBinding } }.`);
92
+ }
93
+ }
94
+ function normalizeHelpers(helpers, profile, profileRank, majorant, reader, cache, where) {
95
+ if (helpers === undefined)
96
+ return [];
97
+ if (helpers === null || typeof helpers === "string" || typeof helpers[Symbol.iterator] !== "function") {
98
+ throw bad(`${where}: helpers must be an array or set of helper names (${HELPER_NAMES.join(", ")}), got ${JSON.stringify(helpers)}.`);
99
+ }
100
+ const seen = new Set();
101
+ for (const h of helpers) {
102
+ if (typeof h !== "string" || !HELPER_NAMES.includes(h)) {
103
+ throw bad(`${where}: unknown helper ${JSON.stringify(h)}; use ${HELPER_NAMES.join(", ")}.`);
104
+ }
105
+ const need = HELPERS[h].rank;
106
+ if (profileRank < need || (need === 2 && !hasMarch(profileRank, { majorant }))) {
107
+ const also = profileRank === 3 ? " (profile 'majorant' has the march layer only with majorant: 'nodeMax')" : "";
108
+ throw bad(`${where}: helper '${h}' needs profile '${PROFILES[need]}' or above, got '${profile}'${also}.`);
109
+ }
110
+ if (reader === "lean" && h === "fastTrilinear") {
111
+ // P1.16: with a lower-node cache the lean vdbSample is the fast sampler; vdbSampleFast is its other name.
112
+ if (cache === "leaf") {
113
+ throw bad(`${where}: helper 'fastTrilinear' with reader 'lean' needs cache: 'lower' or 'lowerLeaf' (the lean vdbSample then reads every tap as one lower-node lookup).`);
114
+ }
115
+ }
116
+ else if (reader === "lean" && !LEAN_HELPERS.includes(h)) {
117
+ throw bad(`${where}: helper '${h}' reads the vendored accessor; reader 'lean' takes only ${LEAN_HELPERS.map((n) => `'${n}'`).join(", ")} (and 'fastTrilinear' with cache 'lower' / 'lowerLeaf').`);
118
+ }
119
+ if (reader !== "lean" && h === "accessorUnchecked") {
120
+ throw bad(`${where}: helper 'accessorUnchecked' needs reader: 'lean'.`);
121
+ }
122
+ if (h === "majorantGlobal" && majorant === "nodeMax") {
123
+ throw bad(`${where}: helper 'majorantGlobal' needs majorant 'brick' or 'global' (the 'nodeMax' iterator has no one-segment mode).`);
124
+ }
125
+ seen.add(h);
126
+ }
127
+ return HELPER_NAMES.filter((h) => seen.has(h));
128
+ }
129
+ function normalizeTypes(types, where) {
130
+ if (types === undefined || types === null || typeof types === "string" || typeof types[Symbol.iterator] !== "function") {
131
+ throw bad(`${where}: types must be an array or set of grid type names (${VDB_GRID_TYPE_NAMES.join(", ")}), e.g. [...pool.types].`);
132
+ }
133
+ const seen = new Set();
134
+ for (const t of types) {
135
+ if (typeof t !== "string" || !VDB_GRID_TYPE_NAMES.includes(t)) {
136
+ throw bad(`${where}: unknown grid type ${JSON.stringify(t)}; use ${VDB_GRID_TYPE_NAMES.join(", ")}.`);
137
+ }
138
+ seen.add(t);
139
+ }
140
+ if (seen.size === 0) {
141
+ throw bad(`${where}: types is empty. Compile at least one grid type, e.g. ['float'], or pass [...pool.types] after adding a grid.`);
142
+ }
143
+ return VDB_GRID_TYPE_NAMES.filter((t) => seen.has(t));
144
+ }
145
+ function normalize(options, where) {
146
+ if (options === null || typeof options !== "object") {
147
+ throw bad(`${where}: expected an options object { slot | buffer, types, profile }.`);
148
+ }
149
+ rejectPositionalSlot(where, options);
150
+ const hasSlot = options.slot !== undefined;
151
+ const hasBuffer = options.buffer !== undefined;
152
+ if (hasSlot === hasBuffer) {
153
+ throw bad(`${where}: pass exactly one of slot: { group, firstBinding } (declares the binding) or buffer: '<wgsl expression>' (reads a host-declared array<u32>).`);
154
+ }
155
+ let binding;
156
+ if (hasSlot) {
157
+ binding = { kind: "slot", slot: checkSlot(options.slot, where) };
158
+ }
159
+ else {
160
+ const expression = options.buffer;
161
+ if (typeof expression !== "string" || !BUFFER_EXPRESSION.test(expression)) {
162
+ throw bad(`${where}: buffer must be a WGSL identifier or member chain such as 'vdbPool.value', got ${JSON.stringify(expression)}.`);
163
+ }
164
+ for (const part of expression.split(".")) {
165
+ if (part.startsWith("__")) {
166
+ throw bad(`${where}: buffer ${JSON.stringify(expression)} uses '${part}'; WGSL identifiers must not start with '__'. Rename the host binding.`);
167
+ }
168
+ if (part === "_" || WGSL_RESERVED_WORDS.has(part) || WGSL_KEYWORDS.has(part)) {
169
+ throw bad(`${where}: buffer ${JSON.stringify(expression)} uses '${part}', which WGSL reserves. Rename the host binding (e.g. 'vdbPool.value').`);
170
+ }
171
+ }
172
+ binding = { kind: "buffer", expression };
173
+ }
174
+ const profileRank = PROFILES.indexOf(options.profile);
175
+ if (profileRank < 0) {
176
+ throw bad(`${where}: profile must be one of ${PROFILES.map((p) => `'${p}'`).join(", ")}, got ${JSON.stringify(options.profile)}.`);
177
+ }
178
+ const isMajorant = profileRank === 3;
179
+ if (options.majorant !== undefined && !isMajorant) {
180
+ throw bad(`${where}: majorant applies to profile 'majorant' only, got profile '${options.profile}'.`);
181
+ }
182
+ if (options.minima !== undefined && !isMajorant) {
183
+ throw bad(`${where}: minima applies to profile 'majorant' only, got profile '${options.profile}'.`);
184
+ }
185
+ const majorant = options.majorant ?? "brick";
186
+ if (!MAJORANT_MODES.includes(majorant)) {
187
+ throw bad(`${where}: majorant must be ${MAJORANT_MODES.map((m) => `'${m}'`).join(", ")}, got ${JSON.stringify(majorant)}.`);
188
+ }
189
+ const minima = options.minima ?? false;
190
+ if (typeof minima !== "boolean")
191
+ throw bad(`${where}: minima must be a boolean, got ${JSON.stringify(minima)}.`);
192
+ const reader = options.reader ?? "vendored";
193
+ if (reader !== "vendored" && reader !== "lean") {
194
+ throw bad(`${where}: reader must be 'vendored' or 'lean', got ${JSON.stringify(reader)}.`);
195
+ }
196
+ if (reader === "lean" && hasMarch(profileRank, { majorant })) {
197
+ throw bad(`${where}: reader 'lean' has no march layer (HDDA, node stats); use the vendored reader for profile 'march' or majorant 'nodeMax'.`);
198
+ }
199
+ // P1.16: the lean accessor's cache.
200
+ const cache = options.cache ?? "leaf";
201
+ if (!LEAN_CACHES.includes(cache)) {
202
+ throw bad(`${where}: cache must be ${LEAN_CACHES.map((c) => `'${c}'`).join(", ")}, got ${JSON.stringify(cache)}.`);
203
+ }
204
+ if (options.cache !== undefined && reader !== "lean") {
205
+ throw bad(`${where}: cache applies to reader 'lean' only (the vendored accessor has its own leaf / lower / upper cache).`);
206
+ }
207
+ // EX1f-b: the trackers call the host's random function by name.
208
+ const helperNames = normalizeHelpers(options.helpers, options.profile, profileRank, majorant, reader, cache, where);
209
+ const tracking = helperNames.some((h) => TRACK_HELPERS.includes(h));
210
+ const random = options.random;
211
+ if (random !== undefined) {
212
+ if (!tracking)
213
+ throw bad(`${where}: random applies to the helpers 'deltaTrack' and 'ratioTrack' only.`);
214
+ if (typeof random !== "string" || !WGSL_IDENTIFIER.test(random)) {
215
+ throw bad(`${where}: random must be the name of a WGSL function \`fn name() -> f32\` (an identifier), got ${JSON.stringify(random)}.`);
216
+ }
217
+ if (random.startsWith("__") || random === "_" || WGSL_RESERVED_WORDS.has(random) || WGSL_KEYWORDS.has(random)) {
218
+ throw bad(`${where}: random '${random}' is not a name WGSL allows for a function. Rename the host's function.`);
219
+ }
220
+ if (/^vdb/i.test(random))
221
+ throw bad(`${where}: random '${random}' starts with 'vdb', the module's own prefix. Rename the host's function.`);
222
+ }
223
+ else if (tracking) {
224
+ throw bad(`${where}: helpers 'deltaTrack' / 'ratioTrack' need random: '<name>', a function \`fn <name>() -> f32\` in your shader that returns uniform numbers in [0, 1).`);
225
+ }
226
+ const sampler = options.sampler ?? "trilinear";
227
+ if (sampler !== "trilinear" && sampler !== "nearest") {
228
+ throw bad(`${where}: sampler must be 'trilinear' or 'nearest', got ${JSON.stringify(sampler)}.`);
229
+ }
230
+ const outside = options.outside ?? "background";
231
+ if (outside !== "background" && outside !== "zero") {
232
+ throw bad(`${where}: outside must be 'background' or 'zero', got ${JSON.stringify(outside)}.`);
233
+ }
234
+ const isActive = options.isActive ?? true;
235
+ if (typeof isActive !== "boolean") {
236
+ throw bad(`${where}: isActive must be a boolean, got ${JSON.stringify(isActive)}.`);
237
+ }
238
+ // Sample-only options do not change a `read` module; normalize them away so
239
+ // equal modules share one cache key.
240
+ const sampleOnly = profileRank >= 1;
241
+ return {
242
+ profile: options.profile,
243
+ profileRank,
244
+ binding,
245
+ types: normalizeTypes(options.types, where),
246
+ isActive,
247
+ sampler: sampleOnly ? sampler : "trilinear",
248
+ outside: sampleOnly ? outside : "background",
249
+ helpers: checkHelperSampler(helperNames, sampleOnly ? sampler : "trilinear", where),
250
+ reader,
251
+ majorant,
252
+ minima,
253
+ random: random ?? null,
254
+ cache: cache,
255
+ keep: normalizeKeep(options.keep, where),
256
+ };
257
+ }
258
+ /** P1.16 `keep`: a set of function names (checked against the module's functions at build), sorted. */
259
+ function normalizeKeep(keep, where) {
260
+ if (keep === undefined)
261
+ return null;
262
+ if (keep === null || typeof keep === "string" || typeof keep[Symbol.iterator] !== "function") {
263
+ throw bad(`${where}: keep must be an array or set of the module's function names, e.g. ['vdbAccessorInit', 'vdbSample'].`);
264
+ }
265
+ const seen = new Set();
266
+ for (const k of keep) {
267
+ if (typeof k !== "string" || !WGSL_IDENTIFIER.test(k))
268
+ throw bad(`${where}: keep entries are function names, got ${JSON.stringify(k)}.`);
269
+ seen.add(k);
270
+ }
271
+ if (seen.size === 0)
272
+ throw bad(`${where}: keep is empty; list the functions the kernel calls, or leave it out.`);
273
+ return [...seen].sort();
274
+ }
275
+ /** The API text of the options: every layer and helper, cut to `keep` when given. */
276
+ function apiText(o, where) {
277
+ const api = apiWgsl(o.profileRank, o);
278
+ if (o.keep === null)
279
+ return api;
280
+ const names = apiPublicFunctions(api);
281
+ const unknown = o.keep.filter((k) => !names.includes(k));
282
+ if (unknown.length > 0) {
283
+ throw bad(`${where}: keep names ${unknown.map((k) => `'${k}'`).join(", ")}, which this module does not have. Its functions: ${names.join(", ")}.`);
284
+ }
285
+ return pruneApiWgsl(api, o.keep);
286
+ }
287
+ /** `fastTrilinear` shares one leaf between the 8 trilinear taps; `nearest` has one tap. */
288
+ function checkHelperSampler(helpers, sampler, where) {
289
+ if (sampler === "nearest" && helpers.includes("fastTrilinear")) {
290
+ throw bad(`${where}: helper 'fastTrilinear' needs sampler 'trilinear' (nearest reads one voxel; call vdbSample).`);
291
+ }
292
+ return helpers;
293
+ }
294
+ // ---------------------------------------------------------------------------
295
+ // Declaration table and transforms
296
+ const CHUNKS = new Map(PNANOVDB_CHUNKS.map((c) => [c.name, c]));
297
+ const ORDER = new Map(PNANOVDB_CHUNKS.map((c, i) => [c.name, i]));
298
+ function chunk(name) {
299
+ const c = CHUNKS.get(name);
300
+ if (!c)
301
+ throw new Error(`@pmndrs/vdb: vendored declaration ${name} is missing; re-run scripts/extract-wgsl-chunks.mjs`);
302
+ return c;
303
+ }
304
+ const TYPE_TABLE = "pnanovdb_grid_type_constants";
305
+ const TYPE_TABLE_FN = "pnanovdb_gtc";
306
+ const TYPE_TABLE_CALL_SITE = /\bpnanovdb_grid_type_constants\[([^\]]+)\]/g;
307
+ /** Names the transforms introduce, resolved to the declaration they replace. */
308
+ const ALIASES = new Map([[TYPE_TABLE_FN, TYPE_TABLE]]);
309
+ const GRID_TYPE_CONSTANT_PRE = {
310
+ float: "PNANOVDB_GRID_TYPE_FLOAT",
311
+ fp4: "PNANOVDB_GRID_TYPE_FP4",
312
+ fp8: "PNANOVDB_GRID_TYPE_FP8",
313
+ fp16: "PNANOVDB_GRID_TYPE_FP16",
314
+ fpn: "PNANOVDB_GRID_TYPE_FPN",
315
+ half: "PNANOVDB_GRID_TYPE_HALF",
316
+ };
317
+ /** Types whose leaf values are Fp codes (decoded by `pnanovdb_root_<t>_read_float`). */
318
+ const FP_TYPES = new Set(["fp4", "fp8", "fp16", "fpn"]);
319
+ /** Field names of the vendored `pnanovdb_grid_type_constants_t`, in order. */
320
+ const TYPE_TABLE_FIELDS = [...chunk("pnanovdb_grid_type_constants_t").text.matchAll(/^\s+(\w+)\s*:/gm)].map((m) => m[1]);
321
+ /** The 27 rows of the vendored type table, as argument lists. */
322
+ const TYPE_TABLE_ROWS = (() => {
323
+ const rows = [...chunk(TYPE_TABLE).text.matchAll(/pnanovdb_grid_type_constants_t\(([^)]*)\)/g)].map((m) => m[1].split(",").map((v) => v.trim()));
324
+ if (rows.length !== 27 || rows.some((r) => r.length !== TYPE_TABLE_FIELDS.length)) {
325
+ throw new Error(`@pmndrs/vdb: unexpected vendored grid type table shape; re-check generate.ts against vendor/pnanovdb.wgsl`);
326
+ }
327
+ return rows;
328
+ })();
329
+ /** Transform 1: the single buffer access. */
330
+ function bufReadOverride() {
331
+ return `fn pnanovdb_buf_read_uint32(buf: pnanovdb_buf_t, byte_offset: u32) -> u32 {
332
+ return vdb_load((buf.byte_offset >> 2u) + (byte_offset >> 2u));
333
+ }`;
334
+ }
335
+ /**
336
+ * Transform 2: the type table cut to the compiled types. Fields no emitted code
337
+ * reads are written as 0u, and types whose remaining rows are equal share one
338
+ * branch (Fp4/Fp8/Fp16/FpN differ only in the unread `leaf_size`). One distinct
339
+ * row: a constant, no branch.
340
+ */
341
+ function typeTableOverride({ o, fields }) {
342
+ const groups = [];
343
+ for (const t of o.types) {
344
+ const values = TYPE_TABLE_ROWS[VDB_GRID_TYPE_IDS[t]];
345
+ const row = `pnanovdb_grid_type_constants_t(${values
346
+ .map((v, i) => (fields === null || fields.has(TYPE_TABLE_FIELDS[i]) ? v : "0u"))
347
+ .join(", ")})`;
348
+ const group = groups.find((g) => g.row === row);
349
+ if (group)
350
+ group.types.push(t);
351
+ else
352
+ groups.push({ row, types: [t] });
353
+ }
354
+ const lines = [`fn ${TYPE_TABLE_FN}(grid_type: u32) -> pnanovdb_grid_type_constants_t {`];
355
+ groups.forEach((g, i) => {
356
+ if (i === groups.length - 1) {
357
+ lines.push(` return ${g.row};`);
358
+ }
359
+ else {
360
+ lines.push(` if ${g.types.map((t) => `grid_type == ${GRID_TYPE_CONSTANT_PRE[t]}`).join(" || ")} {`);
361
+ lines.push(` return ${g.row};`);
362
+ lines.push(` }`);
363
+ }
364
+ });
365
+ lines.push("}");
366
+ return lines.join("\n");
367
+ }
368
+ /** Transform 3: typed decode limited to the compiled types. */
369
+ function readFloatTypedOverride({ o }) {
370
+ const text = chunk("pnanovdb_read_float_typed").text;
371
+ const signature = text.slice(0, text.indexOf("{") + 1);
372
+ const special = o.types.filter((t) => t !== "float");
373
+ const decode = (t) => t === "half" ? "pnanovdb_read_half(buf, address)" : `pnanovdb_root_${t}_read_float(buf, address, ijk, level)`;
374
+ const lines = [signature];
375
+ // Without Float, the last other type is the fallthrough: `ok` already rejects
376
+ // every type not compiled before a read reaches here.
377
+ const branches = o.types.includes("float") ? special : special.slice(0, -1);
378
+ for (const t of branches) {
379
+ lines.push(` if grid_type == ${GRID_TYPE_CONSTANT_PRE[t]} {`);
380
+ lines.push(` return ${decode(t)};`);
381
+ lines.push(` }`);
382
+ }
383
+ lines.push(o.types.includes("float") ? " return pnanovdb_read_float(buf, address);" : ` return ${decode(special[special.length - 1])};`);
384
+ lines.push("}");
385
+ return lines.join("\n");
386
+ }
387
+ /**
388
+ * Transform 7: the leaf-stat dispatch limited to the compiled types. No Fp type
389
+ * compiled: a plain f32 read (the code decoder drops out). Only Fp types: the
390
+ * decode, unconditionally. Both: one branch over the compiled Fp types. (Half
391
+ * leaf ave/stddev are f32, so Half counts as a plain type here; its min/max go
392
+ * through transform 8.)
393
+ */
394
+ function leafStatOverride({ o }) {
395
+ const text = chunk("pnanovdb_leaf_get_stat_float").text;
396
+ const signature = text.slice(0, text.indexOf("{") + 1);
397
+ const fpTypes = o.types.filter((t) => FP_TYPES.has(t));
398
+ const plainTypes = o.types.filter((t) => !FP_TYPES.has(t));
399
+ const decode = "return pnanovdb_leaf_fp_get_stat_float(grid_type, buf, node, address, with_minimum);";
400
+ const plain = "return pnanovdb_read_float(buf, address);";
401
+ const lines = [signature];
402
+ if (fpTypes.length === 0) {
403
+ lines.push(` ${plain}`);
404
+ }
405
+ else if (plainTypes.length === 0) {
406
+ lines.push(` ${decode}`);
407
+ }
408
+ else {
409
+ lines.push(` if ${fpTypes.map((t) => `grid_type == ${GRID_TYPE_CONSTANT_PRE[t]}`).join(" || ")} {`);
410
+ lines.push(` ${decode}`);
411
+ lines.push(" }");
412
+ lines.push(` ${plain}`);
413
+ }
414
+ lines.push("}");
415
+ return lines.join("\n");
416
+ }
417
+ /** Transform 8 (with `half`): a Half-aware min/max reader keeping only the compiled types' branch. */
418
+ function minmaxOverride(name, other) {
419
+ return ({ o }) => {
420
+ const text = chunk(name).text;
421
+ const signature = text.slice(0, text.indexOf("{") + 1);
422
+ const half = "return pnanovdb_read_half(buf, address);";
423
+ const lines = [signature];
424
+ if (o.types.length === 1) {
425
+ lines.push(` ${half}`);
426
+ }
427
+ else {
428
+ lines.push(` if grid_type == ${GRID_TYPE_CONSTANT_PRE.half} {`);
429
+ lines.push(` ${half}`);
430
+ lines.push(" }");
431
+ lines.push(` ${other}`);
432
+ }
433
+ lines.push("}");
434
+ return lines.join("\n");
435
+ };
436
+ }
437
+ /** Transform 8 (without `half`): call sites of the Half-aware min/max readers, back to the readers they wrap. */
438
+ const MINMAX_CALL_SITE = /\bpnanovdb_read_minmax_float\(grid_type, buf, /g;
439
+ const LEAF_MINMAX_CALL_SITE = /\bpnanovdb_leaf_get_minmax_float\(grid_type, buf, node, (pnanovdb_leaf_get_m(?:in|ax)_address\(grid_type, buf, node\))\)/g;
440
+ const OVERRIDES = new Map([
441
+ ["pnanovdb_buf_read_uint32", bufReadOverride],
442
+ [TYPE_TABLE, typeTableOverride],
443
+ ["pnanovdb_read_float_typed", readFloatTypedOverride],
444
+ ["pnanovdb_leaf_get_stat_float", leafStatOverride],
445
+ ["pnanovdb_read_minmax_float", minmaxOverride("pnanovdb_read_minmax_float", "return pnanovdb_read_float(buf, address);")],
446
+ [
447
+ "pnanovdb_leaf_get_minmax_float",
448
+ minmaxOverride("pnanovdb_leaf_get_minmax_float", "return pnanovdb_leaf_get_stat_float(grid_type, buf, node, address, true);"),
449
+ ],
450
+ ]);
451
+ function effectiveText(c, ctx) {
452
+ const override = OVERRIDES.get(c.name);
453
+ if (override)
454
+ return override(ctx);
455
+ let text = c.text.replace(TYPE_TABLE_CALL_SITE, `${TYPE_TABLE_FN}($1)`);
456
+ if (!ctx.o.types.includes("half")) {
457
+ text = text
458
+ .replace(MINMAX_CALL_SITE, "pnanovdb_read_float(buf, ")
459
+ .replace(LEAF_MINMAX_CALL_SITE, "pnanovdb_leaf_get_stat_float(grid_type, buf, node, $1, true)");
460
+ }
461
+ return text;
462
+ }
463
+ function referencedChunks(text, self) {
464
+ const out = new Set();
465
+ for (const m of text.matchAll(IDENTIFIER)) {
466
+ const name = ALIASES.get(m[0]) ?? m[0];
467
+ if (name !== self && CHUNKS.has(name))
468
+ out.add(name);
469
+ }
470
+ return [...out];
471
+ }
472
+ /** Map a final (`vdb_` / `VDB_`) name back to its vendored declaration, if it is one. */
473
+ function vendoredName(finalName) {
474
+ let name;
475
+ if (finalName.startsWith("vdb_"))
476
+ name = `pnanovdb_${finalName.slice(4)}`;
477
+ else if (finalName.startsWith("VDB_"))
478
+ name = `PNANOVDB_${finalName.slice(4)}`;
479
+ if (name === undefined)
480
+ return undefined;
481
+ name = ALIASES.get(name) ?? name;
482
+ return CHUNKS.has(name) ? name : undefined;
483
+ }
484
+ function rename(text) {
485
+ return text.replace(/\bpnanovdb_/g, "vdb_").replace(/\bPNANOVDB_/g, "VDB_");
486
+ }
487
+ /** Vendored declarations a module needs, in file order. */
488
+ function closurePass(api, ctx) {
489
+ const roots = new Set();
490
+ for (const m of api.matchAll(IDENTIFIER)) {
491
+ const name = vendoredName(m[0]);
492
+ if (name)
493
+ roots.add(name);
494
+ }
495
+ const included = new Set();
496
+ const stack = [...roots];
497
+ while (stack.length > 0) {
498
+ const name = stack.pop();
499
+ if (included.has(name))
500
+ continue;
501
+ included.add(name);
502
+ const c = chunk(name);
503
+ for (const d of referencedChunks(effectiveText(c, ctx), name))
504
+ if (!included.has(d))
505
+ stack.push(d);
506
+ }
507
+ return [...included].sort((a, b) => ORDER.get(a) - ORDER.get(b));
508
+ }
509
+ /**
510
+ * Vendored declarations a module needs, in file order, and the context to
511
+ * emit them with. Two passes: the first (whole type-table rows) finds which
512
+ * type-table fields the closure reads; the second emits only those, which can
513
+ * only shrink the closure.
514
+ */
515
+ function closure(api, o) {
516
+ const first = closurePass(api, { o, fields: null });
517
+ const fields = new Set();
518
+ for (const name of first) {
519
+ if (name === TYPE_TABLE || name === "pnanovdb_grid_type_constants_t")
520
+ continue;
521
+ for (const m of chunk(name).text.matchAll(/\.([A-Za-z_]\w*)/g)) {
522
+ if (TYPE_TABLE_FIELDS.includes(m[1]))
523
+ fields.add(m[1]);
524
+ }
525
+ }
526
+ const ctx = { o, fields };
527
+ return { names: closurePass(api, ctx), ctx };
528
+ }
529
+ const cache = new Map();
530
+ function build(o) {
531
+ const api = apiText(o, "vdbModuleWgsl");
532
+ const access = o.binding.kind === "slot" ? VDB_POOL_BINDING_NAME : o.binding.expression;
533
+ const load = `fn vdb_load(vdb_i: u32) -> u32 {
534
+ return ${access}[vdb_i];
535
+ }`;
536
+ const { names, ctx } = closure(api, o);
537
+ const vendored = names.map((name) => rename(effectiveText(chunk(name), ctx))).join("\n");
538
+ const body = [vendored, load, api].join("\n");
539
+ // Layout constants come from core/pool/layout.ts (one source of truth); keep
540
+ // only the `const` lines the body references.
541
+ const constants = vdbPoolLayoutWgsl()
542
+ .split("\n")
543
+ .filter((line) => {
544
+ const name = /^const\s+(\w+)/.exec(line)?.[1];
545
+ return name !== undefined && new RegExp(`\\b${name}\\b`).test(body);
546
+ });
547
+ const head = [VDB_MODULE_BANNER];
548
+ if (o.binding.kind === "slot") {
549
+ head.push(`@group(${o.binding.slot.group}) @binding(${o.binding.slot.firstBinding}) var<storage, read> ${VDB_POOL_BINDING_NAME}: array<u32>;`);
550
+ }
551
+ return [...head, ...constants, body].join("\n") + "\n";
552
+ }
553
+ /**
554
+ * Generate a WGSL module for the pool (docs/dev/design/K1-core.md §3.1).
555
+ * Deterministic: the same options give the same string.
556
+ *
557
+ * `types` must cover every grid type the host may add to the pool, not just
558
+ * the ones present now: a grid of a type the module wasn't generated for reads
559
+ * as 0. Either generate for every type up front (`VDB_ALL_SCALAR_TYPES`, or
560
+ * the host's known set) or regenerate the module and rebuild the pipeline when
561
+ * `vdbCheckModule(pool, options)` throws `VDB_TYPE_NOT_COMPILED` after an `add`.
562
+ *
563
+ * @throws VDBError `VDB_BAD_OPTION` for invalid options.
564
+ */
565
+ export function vdbModuleWgsl(options) {
566
+ const o = normalize(options, "vdbModuleWgsl");
567
+ const key = JSON.stringify(o);
568
+ let code = cache.get(key);
569
+ if (code === undefined) {
570
+ code = build(o);
571
+ cache.set(key, code);
572
+ }
573
+ return code;
574
+ }
575
+ /**
576
+ * The bind group layout entries a `slot` module declares: one read-only
577
+ * storage buffer at `slot.firstBinding` (layout 1).
578
+ *
579
+ * Takes the same `VDBSlot` as `vdbModuleWgsl({ slot })` and
580
+ * `pool.bindGroupEntry(slot)`, either bare or as `{ slot, visibility }`.
581
+ * `visibility` defaults to `GPUShaderStage.COMPUTE | GPUShaderStage.FRAGMENT`
582
+ * (read-only storage is legal in both stages), so render and compute hosts
583
+ * both work without it; pass it to narrow the layout.
584
+ *
585
+ * @throws VDBError `VDB_BAD_OPTION` for a malformed slot.
586
+ */
587
+ export function vdbModuleEntries(slotOrOptions) {
588
+ const where = "vdbModuleEntries";
589
+ if (slotOrOptions === null || typeof slotOrOptions !== "object")
590
+ throw bad(`${where}: expected a slot { group, firstBinding } or { slot, visibility? }.`);
591
+ let slot;
592
+ let visibility = SHADER_STAGE_FRAGMENT_COMPUTE;
593
+ if ("slot" in slotOrOptions) {
594
+ rejectPositionalSlot(where, slotOrOptions);
595
+ slot = checkSlot(slotOrOptions.slot, where);
596
+ const v = slotOrOptions.visibility;
597
+ if (v !== undefined) {
598
+ if (!Number.isInteger(v) || v <= 0)
599
+ throw bad(`${where}: visibility must be GPUShaderStage flags (a positive integer), got ${JSON.stringify(v)}.`);
600
+ visibility = v;
601
+ }
602
+ }
603
+ else {
604
+ if ("visibility" in slotOrOptions)
605
+ throw bad(`${where}: pass visibility as { slot: { group, firstBinding }, visibility }.`);
606
+ slot = checkSlot(slotOrOptions, where);
607
+ }
608
+ return [{ binding: slot.firstBinding, visibility, buffer: { type: "read-only-storage" } }];
609
+ }
610
+ /**
611
+ * Check that a module generated with `options` can read every grid in `pool`.
612
+ *
613
+ * `options` is either the full `vdbModuleWgsl` options (validated as such) or
614
+ * just `{ types, layoutVersion? }` for a type/layout-only check, e.g. from an
615
+ * engine adapter that builds its module elsewhere. `layoutVersion` is the
616
+ * layout the module targets (default: this generator's,
617
+ * `VDB_GPU_LAYOUT_VERSION`).
618
+ *
619
+ * After every `pool.add`: a module must be generated for every type the host
620
+ * may add, or regenerated and its pipeline rebuilt.
621
+ *
622
+ * @param pool The pool whose grids the module must read.
623
+ * @param options The module's options, or just `{ types, layoutVersion? }`.
624
+ *
625
+ * @throws VDBError `VDB_LAYOUT_MISMATCH` if the pool's layout is not the one
626
+ * the module targets; `VDB_TYPE_NOT_COMPILED` if the pool holds a grid
627
+ * type the module would not decode; `VDB_BAD_OPTION` for invalid options.
628
+ */
629
+ export function vdbCheckModule(pool, options) {
630
+ const where = "vdbCheckModule";
631
+ let o;
632
+ let walk = null;
633
+ let target = VDB_GPU_LAYOUT_VERSION;
634
+ if (options !== null && typeof options === "object" && !("slot" in options) && !("buffer" in options) && !("profile" in options)) {
635
+ // Type/layout-only form.
636
+ o = { types: normalizeTypes(options.types, where) };
637
+ const v = options.layoutVersion;
638
+ if (v !== undefined) {
639
+ if (!Number.isInteger(v) || v < 0)
640
+ throw bad(`${where}: layoutVersion must be a non-negative integer, got ${JSON.stringify(v)}.`);
641
+ target = v;
642
+ }
643
+ }
644
+ else {
645
+ const n = normalize(options, where);
646
+ o = n;
647
+ if (n.profileRank === 3)
648
+ walk = n.majorant;
649
+ }
650
+ if (pool.layoutVersion !== target) {
651
+ throw new VDBError("VDB_LAYOUT_MISMATCH", `the pool uses layout ${pool.layoutVersion} but the module targets layout ${target}. Use one @pmndrs/vdb version for both.`);
652
+ }
653
+ const missing = [...new Set(pool.types)].filter((t) => !o.types.includes(t));
654
+ if (missing.length > 0) {
655
+ throw new VDBError("VDB_TYPE_NOT_COMPILED", `the pool holds ${missing.join(", ")} grids but the module compiles only ${o.types.join(", ")}; those grids would read 0. ` +
656
+ `A module must be generated for every type the host may add: regenerate it with types that include ${missing.join(", ")} ` +
657
+ `(e.g. [...pool.types], or VDB_ALL_SCALAR_TYPES to never rebuild) and rebuild the pipeline that uses it.`);
658
+ }
659
+ // EX1f-a: a walk on the global bound needs a finite one (WGSL may assume no infinities). 'global' always walks
660
+ // on it, 'brick' for a grid without brick bounds, 'nodeMax' for a grid without statistics.
661
+ if (walk !== null && pool.unboundedGrids !== undefined) {
662
+ const mode = walk;
663
+ const open = [...pool.unboundedGrids].filter((g) => (mode === "global" ? true : mode === "brick" ? !g.hasBrickMajorant : !g.hasStats));
664
+ if (open.length > 0) {
665
+ const ids = open.map((g) => g.id).join(", ");
666
+ throw new VDBError("VDB_NO_STATS", `grid ${ids} has no min/max statistics and no valueMax, so its global bound is infinite and the '${mode}' majorant walk ` +
667
+ `would step with it. Give it a bound: pool.setValueMax(id, vdbValueRange(image, { outside }).max) with vdbValueRange from ` +
668
+ `@pmndrs/vdb/tools (or valueMax in pool.add)` +
669
+ (mode === "brick" ? `, or brick bounds (pool.buildMajorant(id) / pool.setMajorant).` : `.`));
670
+ }
671
+ }
672
+ }
673
+ /** @internal Vendored declarations (vendored names) a module with these options includes, in file order. For tests. */
674
+ export function vdbModuleDeclarations(options) {
675
+ const o = normalize(options, "vdbModuleDeclarations");
676
+ return closure(apiText(o, "vdbModuleDeclarations"), o).names;
677
+ }
678
+ //# sourceMappingURL=generate.js.map