@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,316 @@
1
+ /**
2
+ * Pool buffer layout 1 (docs/dev/design/K1-core.md §1): a 32-byte header, a table of
3
+ * fixed-stride 160-byte grid records, then 32-byte-aligned ranges (NanoVDB
4
+ * images, brick-majorant grids).
5
+ *
6
+ * This file is the single source of truth for every header word, record word
7
+ * and flag bit. The TypeScript encoders below and the WGSL constants returned by
8
+ * {@link vdbPoolLayoutWgsl} are both derived from the tables in this file, so the
9
+ * CPU writer and the GPU reader cannot drift apart. Any change to a word or its
10
+ * meaning bumps {@link VDB_GPU_LAYOUT_VERSION} and is a breaking change (§1.8).
11
+ */
12
+ import { VDBError } from "../errors.js";
13
+ /** Layout version written to header word 1 and baked into generated WGSL. */
14
+ export const VDB_GPU_LAYOUT_VERSION = 1;
15
+ /** Header word 0: `"VDBP"` read as a little-endian u32. */
16
+ export const VDB_POOL_MAGIC = 0x50424456;
17
+ /** Every range in the pool (table, images, majorants) starts on this byte alignment (NanoVDB's data alignment). */
18
+ export const VDB_POOL_ALIGN = 32;
19
+ /** Header size in bytes. */
20
+ export const VDB_POOL_HEADER_BYTES = 32;
21
+ /** Header size in u32 words. */
22
+ export const VDB_POOL_HEADER_WORDS = VDB_POOL_HEADER_BYTES / 4;
23
+ /** Byte offset of record 0 (fixed in layout 1). */
24
+ export const VDB_POOL_TABLE_OFFSET = 32;
25
+ /** Grid record size in bytes. A multiple of 16 so `vec4` loads stay possible. */
26
+ export const VDB_POOL_RECORD_BYTES = 160;
27
+ /** Grid record size in u32 words. */
28
+ export const VDB_POOL_RECORD_WORDS = VDB_POOL_RECORD_BYTES / 4;
29
+ /** Header word indices (§1.1). */
30
+ export const VDB_HEADER_WORD = {
31
+ /** {@link VDB_POOL_MAGIC}. */
32
+ magic: 0,
33
+ /** {@link VDB_GPU_LAYOUT_VERSION}. */
34
+ layoutVersion: 1,
35
+ /** Records in the table. */
36
+ gridCapacity: 2,
37
+ /** Highest live grid id + 1 (`vdbGridCount()` in WGSL). */
38
+ gridCount: 3,
39
+ /** {@link VDB_POOL_TABLE_OFFSET}, written for readers that don't know the version. */
40
+ tableOffset: 4,
41
+ /** {@link VDB_POOL_RECORD_BYTES}. */
42
+ recordBytes: 5,
43
+ /** Allocation high-water mark in bytes (diagnostics). */
44
+ usedBytes: 6,
45
+ /** Always 0 in layout 1. */
46
+ reserved: 7,
47
+ };
48
+ /** Grid record word indices (§1.2). Multi-word fields name their first word. */
49
+ export const VDB_RECORD_WORD = {
50
+ /** u32: image byte offset from the start of the pool; a multiple of 32. */
51
+ imageOffset: 0,
52
+ /** u32: NanoVDB `GridData.mGridSize` (its high word must be 0). */
53
+ imageBytes: 1,
54
+ /** u32: NanoVDB `GridType` id (1 Float, 9 Half, 13 Fp4, 14 Fp8, 15 Fp16, 16 FpN). */
55
+ gridType: 2,
56
+ /** u32: see {@link VDB_RECORD_FLAG} and the class / brick-log2 bit fields. */
57
+ flags: 3,
58
+ /** f32 x12: world -> index, 3x4 row-major (`idx = M * [p, 1]`). */
59
+ worldToIndex: 4,
60
+ /** f32 x12: index -> world, 3x4 row-major. */
61
+ indexToWorld: 16,
62
+ /** i32 x3: root active bbox min. */
63
+ indexBBoxMin: 28,
64
+ /** f32: root background value. */
65
+ background: 31,
66
+ /** i32 x3: root active bbox max (inclusive). */
67
+ indexBBoxMax: 32,
68
+ /** f32: `max(root max stat, background)` or the caller's bound; the `global` majorant. */
69
+ valueMax: 35,
70
+ /** u32: brick-majorant range byte offset; 0 = none. */
71
+ majorantOffset: 36,
72
+ /** u32 x3: brick-majorant grid dimensions in cells. */
73
+ majorantDims: 37,
74
+ };
75
+ /** Single-bit record flags (record word 3). */
76
+ export const VDB_RECORD_FLAG = {
77
+ /** b0: the record describes a live grid; a dead id reads 0 everywhere. */
78
+ live: 1 << 0,
79
+ /** b1: the image carries min/max stats (`GridData` flag `HasMinMax`). */
80
+ hasStats: 1 << 1,
81
+ /** b2: `majorantOffset`/`majorantDims` describe a brick-majorant range. */
82
+ hasBrickMajorant: 1 << 2,
83
+ /** b3: the affines include a host instance transform (`setTransform`). */
84
+ instanceTransform: 1 << 3,
85
+ };
86
+ /** Bit position of the 8-bit NanoVDB `GridClass` field in record word 3. */
87
+ export const VDB_RECORD_GRID_CLASS_SHIFT = 8;
88
+ /** Bit position of the 8-bit brick log2 field in record word 3. */
89
+ export const VDB_RECORD_BRICK_LOG2_SHIFT = 16;
90
+ /** Mask (after shifting) of the 8-bit class and brick-log2 fields. */
91
+ export const VDB_RECORD_BYTE_FIELD_MASK = 0xff;
92
+ /**
93
+ * A brick-majorant range (P1.3; record words 36-39 point at it): a 32-byte header, then
94
+ * `dims.x * dims.y * dims.z` f32 upper bounds (x fastest), then as many lower bounds when the header's
95
+ * minima flag is set. The header carries what the record has no room for: the index position of cell 0's
96
+ * min corner and the flags. Layout 1 never defined the range's bytes (no 0.1 module read them, D22); the
97
+ * magic lets a module tell a P1 range from a 0.1 pool's bare bounds and walk the latter as `global`.
98
+ */
99
+ export const VDB_MAJORANT_HEADER_BYTES = 32;
100
+ /** Majorant header word 4: `"VDBM"` read as a little-endian u32. */
101
+ export const VDB_MAJORANT_MAGIC = 0x4d424456;
102
+ /** Majorant range header word indices. */
103
+ export const VDB_MAJORANT_WORD = {
104
+ /** i32 x3: index position of cell 0's min corner. */
105
+ origin: 0,
106
+ /** u32: see {@link VDB_MAJORANT_FLAG}. */
107
+ flags: 3,
108
+ /** {@link VDB_MAJORANT_MAGIC}. */
109
+ magic: 4,
110
+ };
111
+ /** Majorant range header flag bits (word 3). */
112
+ export const VDB_MAJORANT_FLAG = {
113
+ /** b0: lower bounds follow the upper bounds. */
114
+ minima: 1 << 0,
115
+ };
116
+ /** Packs a brick majorant's range: header, upper bounds, optional lower bounds. `bytes` is its size. */
117
+ export function encodeMajorantRange(m) {
118
+ const cells = m.dims[0] * m.dims[1] * m.dims[2];
119
+ const headerWords = VDB_MAJORANT_HEADER_BYTES / 4;
120
+ const out = new Float32Array(headerWords + cells * (m.minima ? 2 : 1));
121
+ const u32 = new Uint32Array(out.buffer);
122
+ const i32 = new Int32Array(out.buffer);
123
+ for (let k = 0; k < 3; k++)
124
+ i32[VDB_MAJORANT_WORD.origin + k] = m.origin[k];
125
+ u32[VDB_MAJORANT_WORD.flags] = m.minima ? VDB_MAJORANT_FLAG.minima : 0;
126
+ u32[VDB_MAJORANT_WORD.magic] = VDB_MAJORANT_MAGIC;
127
+ out.set(m.data, headerWords);
128
+ if (m.minima)
129
+ out.set(m.minima, headerWords + cells);
130
+ return out;
131
+ }
132
+ /** Rounds `n` up to the pool alignment ({@link VDB_POOL_ALIGN}). */
133
+ export function align32(n) {
134
+ return Math.ceil(n / VDB_POOL_ALIGN) * VDB_POOL_ALIGN;
135
+ }
136
+ /** Byte offset of record `id`. */
137
+ export function recordByteOffset(id) {
138
+ return VDB_POOL_TABLE_OFFSET + id * VDB_POOL_RECORD_BYTES;
139
+ }
140
+ /** First byte after a table of `capacity` records, aligned: where ranges may start. */
141
+ export function dataStartOffset(capacity) {
142
+ return align32(VDB_POOL_TABLE_OFFSET + capacity * VDB_POOL_RECORD_BYTES);
143
+ }
144
+ /** Writes the header's 8 words into `out` at `wordOffset` and returns `out`. */
145
+ export function encodeHeader(header, out = new Uint32Array(VDB_POOL_HEADER_WORDS), wordOffset = 0) {
146
+ const w = VDB_HEADER_WORD;
147
+ out[wordOffset + w.magic] = VDB_POOL_MAGIC;
148
+ out[wordOffset + w.layoutVersion] = VDB_GPU_LAYOUT_VERSION;
149
+ out[wordOffset + w.gridCapacity] = header.gridCapacity;
150
+ out[wordOffset + w.gridCount] = header.gridCount;
151
+ out[wordOffset + w.tableOffset] = VDB_POOL_TABLE_OFFSET;
152
+ out[wordOffset + w.recordBytes] = VDB_POOL_RECORD_BYTES;
153
+ out[wordOffset + w.usedBytes] = header.usedBytes;
154
+ out[wordOffset + w.reserved] = 0;
155
+ return out;
156
+ }
157
+ /** Reads a header from `words` at `wordOffset` (no validation; see {@link VDBPoolHeader}). */
158
+ export function decodeHeader(words, wordOffset = 0) {
159
+ const w = VDB_HEADER_WORD;
160
+ const at = (i) => words[wordOffset + i] ?? 0;
161
+ return {
162
+ magic: at(w.magic),
163
+ layoutVersion: at(w.layoutVersion),
164
+ gridCapacity: at(w.gridCapacity),
165
+ gridCount: at(w.gridCount),
166
+ tableOffset: at(w.tableOffset),
167
+ recordBytes: at(w.recordBytes),
168
+ usedBytes: at(w.usedBytes),
169
+ };
170
+ }
171
+ function views(words) {
172
+ return {
173
+ f32: new Float32Array(words.buffer, words.byteOffset, words.length),
174
+ i32: new Int32Array(words.buffer, words.byteOffset, words.length),
175
+ };
176
+ }
177
+ function byteField(name, value) {
178
+ if (!Number.isInteger(value) || value < 0 || value > VDB_RECORD_BYTE_FIELD_MASK) {
179
+ throw new VDBError("VDB_BAD_OPTION", `encodeRecord: ${name} must be an integer in 0..255, got ${value}.`);
180
+ }
181
+ return value;
182
+ }
183
+ /**
184
+ * Writes `record` as 40 words into `out` at `wordOffset` and returns `out`.
185
+ * Affines are rounded to f32 here; pass the f64 values you composed.
186
+ */
187
+ export function encodeRecord(record, out = new Uint32Array(VDB_POOL_RECORD_WORDS), wordOffset = 0) {
188
+ if (record.worldToIndex.length !== 12 || record.indexToWorld.length !== 12) {
189
+ throw new VDBError("VDB_BAD_OPTION", "encodeRecord: worldToIndex and indexToWorld must each have 12 entries (3x4 row-major).");
190
+ }
191
+ if (out.length < wordOffset + VDB_POOL_RECORD_WORDS) {
192
+ throw new VDBError("VDB_BAD_OPTION", `encodeRecord: output has ${out.length} words; a record at word ${wordOffset} needs ${wordOffset + VDB_POOL_RECORD_WORDS}.`);
193
+ }
194
+ const { f32, i32 } = views(out);
195
+ const r = VDB_RECORD_WORD;
196
+ const o = wordOffset;
197
+ const F = VDB_RECORD_FLAG;
198
+ let flags = 0;
199
+ if (record.live)
200
+ flags |= F.live;
201
+ if (record.hasStats)
202
+ flags |= F.hasStats;
203
+ if (record.hasBrickMajorant)
204
+ flags |= F.hasBrickMajorant;
205
+ if (record.instanceTransform)
206
+ flags |= F.instanceTransform;
207
+ flags |= byteField("gridClass", record.gridClass) << VDB_RECORD_GRID_CLASS_SHIFT;
208
+ flags |= byteField("brickLog2", record.brickLog2) << VDB_RECORD_BRICK_LOG2_SHIFT;
209
+ out[o + r.imageOffset] = record.imageOffset;
210
+ out[o + r.imageBytes] = record.imageBytes;
211
+ out[o + r.gridType] = record.gridType;
212
+ out[o + r.flags] = flags >>> 0;
213
+ for (let k = 0; k < 12; k++) {
214
+ f32[o + r.worldToIndex + k] = record.worldToIndex[k];
215
+ f32[o + r.indexToWorld + k] = record.indexToWorld[k];
216
+ }
217
+ for (let k = 0; k < 3; k++) {
218
+ i32[o + r.indexBBoxMin + k] = record.indexBBoxMin[k];
219
+ i32[o + r.indexBBoxMax + k] = record.indexBBoxMax[k];
220
+ out[o + r.majorantDims + k] = record.majorantDims[k];
221
+ }
222
+ f32[o + r.background] = record.background;
223
+ f32[o + r.valueMax] = record.valueMax;
224
+ out[o + r.majorantOffset] = record.majorantOffset;
225
+ return out;
226
+ }
227
+ /** Reads the 40-word record at `wordOffset` of `words`. */
228
+ export function decodeRecord(words, wordOffset = 0) {
229
+ if (words.length < wordOffset + VDB_POOL_RECORD_WORDS) {
230
+ throw new VDBError("VDB_BAD_OPTION", `decodeRecord: input has ${words.length} words; a record at word ${wordOffset} needs ${wordOffset + VDB_POOL_RECORD_WORDS}.`);
231
+ }
232
+ const { f32, i32 } = views(words);
233
+ const r = VDB_RECORD_WORD;
234
+ const o = wordOffset;
235
+ const flags = words[o + r.flags];
236
+ const F = VDB_RECORD_FLAG;
237
+ const vec = (src, at) => [src[o + at], src[o + at + 1], src[o + at + 2]];
238
+ return {
239
+ imageOffset: words[o + r.imageOffset],
240
+ imageBytes: words[o + r.imageBytes],
241
+ gridType: words[o + r.gridType],
242
+ live: (flags & F.live) !== 0,
243
+ hasStats: (flags & F.hasStats) !== 0,
244
+ hasBrickMajorant: (flags & F.hasBrickMajorant) !== 0,
245
+ instanceTransform: (flags & F.instanceTransform) !== 0,
246
+ gridClass: (flags >>> VDB_RECORD_GRID_CLASS_SHIFT) & VDB_RECORD_BYTE_FIELD_MASK,
247
+ brickLog2: (flags >>> VDB_RECORD_BRICK_LOG2_SHIFT) & VDB_RECORD_BYTE_FIELD_MASK,
248
+ worldToIndex: Array.from(f32.subarray(o + r.worldToIndex, o + r.worldToIndex + 12)),
249
+ indexToWorld: Array.from(f32.subarray(o + r.indexToWorld, o + r.indexToWorld + 12)),
250
+ indexBBoxMin: vec(i32, r.indexBBoxMin),
251
+ indexBBoxMax: vec(i32, r.indexBBoxMax),
252
+ background: f32[o + r.background],
253
+ valueMax: f32[o + r.valueMax],
254
+ majorantOffset: words[o + r.majorantOffset],
255
+ majorantDims: vec(words, r.majorantDims),
256
+ };
257
+ }
258
+ /** `fooBarBaz` -> `FOO_BAR_BAZ`. */
259
+ function upperSnake(name) {
260
+ return name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
261
+ }
262
+ function u32Hex(n) {
263
+ return `0x${(n >>> 0).toString(16)}u`;
264
+ }
265
+ /**
266
+ * WGSL `const` declarations for layout {@link VDB_GPU_LAYOUT_VERSION}, generated
267
+ * from the tables in this file. Pure and deterministic: same package version,
268
+ * same text. Every name carries the `VDB_` prefix (D10, K1-core §3.4) and no
269
+ * comment contains a back-tick (CLAUDE.md Traps).
270
+ *
271
+ * Emitted names (all `u32`):
272
+ * - `VDB_GPU_LAYOUT_VERSION`, `VDB_POOL_MAGIC`
273
+ * - `VDB_POOL_TABLE_OFFSET` (bytes), `VDB_POOL_TABLE_WORD` (= offset / 4),
274
+ * `VDB_POOL_RECORD_BYTES`, `VDB_POOL_RECORD_WORDS`, `VDB_POOL_ALIGN`
275
+ * - `VDB_HEADER_<FIELD>` for every {@link VDB_HEADER_WORD} entry (word index),
276
+ * e.g. `VDB_HEADER_GRID_COUNT = 3u`
277
+ * - `VDB_REC_<FIELD>` for every {@link VDB_RECORD_WORD} entry (word index within
278
+ * a record), e.g. `VDB_REC_IMAGE_OFFSET = 0u`, `VDB_REC_WORLD_TO_INDEX = 4u`
279
+ * - `VDB_REC_FLAG_<NAME>` for every {@link VDB_RECORD_FLAG} bit, plus
280
+ * `VDB_REC_GRID_CLASS_SHIFT`, `VDB_REC_BRICK_LOG2_SHIFT`, `VDB_REC_BYTE_FIELD_MASK`
281
+ * - P1.3, the brick-majorant range header: `VDB_MAJORANT_MAGIC`, `VDB_MAJORANT_HEADER_WORDS`,
282
+ * `VDB_MAJ_<FIELD>` for every {@link VDB_MAJORANT_WORD} entry and `VDB_MAJ_FLAG_<NAME>` per
283
+ * {@link VDB_MAJORANT_FLAG} bit
284
+ *
285
+ * Word `w` of record `g` is `vdb_load(VDB_POOL_TABLE_WORD + g * VDB_POOL_RECORD_WORDS + w)`.
286
+ */
287
+ export function vdbPoolLayoutWgsl() {
288
+ const lines = [
289
+ `// @pmndrs/vdb pool layout ${VDB_GPU_LAYOUT_VERSION} (generated from core/pool/layout.ts; do not edit).`,
290
+ `const VDB_GPU_LAYOUT_VERSION: u32 = ${VDB_GPU_LAYOUT_VERSION}u;`,
291
+ `const VDB_POOL_MAGIC: u32 = ${u32Hex(VDB_POOL_MAGIC)};`,
292
+ `const VDB_POOL_ALIGN: u32 = ${VDB_POOL_ALIGN}u;`,
293
+ `const VDB_POOL_TABLE_OFFSET: u32 = ${VDB_POOL_TABLE_OFFSET}u;`,
294
+ `const VDB_POOL_TABLE_WORD: u32 = ${VDB_POOL_TABLE_OFFSET / 4}u;`,
295
+ `const VDB_POOL_RECORD_BYTES: u32 = ${VDB_POOL_RECORD_BYTES}u;`,
296
+ `const VDB_POOL_RECORD_WORDS: u32 = ${VDB_POOL_RECORD_WORDS}u;`,
297
+ ];
298
+ for (const [name, word] of Object.entries(VDB_HEADER_WORD)) {
299
+ lines.push(`const VDB_HEADER_${upperSnake(name)}: u32 = ${word}u;`);
300
+ }
301
+ for (const [name, word] of Object.entries(VDB_RECORD_WORD)) {
302
+ lines.push(`const VDB_REC_${upperSnake(name)}: u32 = ${word}u;`);
303
+ }
304
+ for (const [name, bit] of Object.entries(VDB_RECORD_FLAG)) {
305
+ lines.push(`const VDB_REC_FLAG_${upperSnake(name)}: u32 = ${u32Hex(bit)};`);
306
+ }
307
+ lines.push(`const VDB_REC_GRID_CLASS_SHIFT: u32 = ${VDB_RECORD_GRID_CLASS_SHIFT}u;`, `const VDB_REC_BRICK_LOG2_SHIFT: u32 = ${VDB_RECORD_BRICK_LOG2_SHIFT}u;`, `const VDB_REC_BYTE_FIELD_MASK: u32 = ${u32Hex(VDB_RECORD_BYTE_FIELD_MASK)};`, `const VDB_MAJORANT_MAGIC: u32 = ${u32Hex(VDB_MAJORANT_MAGIC)};`, `const VDB_MAJORANT_HEADER_WORDS: u32 = ${VDB_MAJORANT_HEADER_BYTES / 4}u;`);
308
+ for (const [name, word] of Object.entries(VDB_MAJORANT_WORD)) {
309
+ lines.push(`const VDB_MAJ_${upperSnake(name)}: u32 = ${word}u;`);
310
+ }
311
+ for (const [name, bit] of Object.entries(VDB_MAJORANT_FLAG)) {
312
+ lines.push(`const VDB_MAJ_FLAG_${upperSnake(name)}: u32 = ${u32Hex(bit)};`);
313
+ }
314
+ return lines.join("\n") + "\n";
315
+ }
316
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../src/core/pool/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC,2DAA2D;AAC3D,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AAEzC,mHAAmH;AACnH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC,4BAA4B;AAC5B,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACxC,gCAAgC;AAChC,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,GAAG,CAAC,CAAC;AAE/D,mDAAmD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GAAG,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACjC,CAAC","sourcesContent":["/**\n * Pool buffer layout 1 (docs/dev/design/K1-core.md §1): a 32-byte header, a table of\n * fixed-stride 160-byte grid records, then 32-byte-aligned ranges (NanoVDB\n * images, brick-majorant grids).\n *\n * This file is the single source of truth for every header word, record word\n * and flag bit. The TypeScript encoders below and the WGSL constants returned by\n * {@link vdbPoolLayoutWgsl} are both derived from the tables in this file, so the\n * CPU writer and the GPU reader cannot drift apart. Any change to a word or its\n * meaning bumps {@link VDB_GPU_LAYOUT_VERSION} and is a breaking change (§1.8).\n */\n\nimport type { VDBVec3 } from \"../../tools/vdb/types.js\";\nimport { VDBError } from \"../errors.js\";\n\n/** Layout version written to header word 1 and baked into generated WGSL. */\nexport const VDB_GPU_LAYOUT_VERSION = 1;\n\n/** Header word 0: `\"VDBP\"` read as a little-endian u32. */\nexport const VDB_POOL_MAGIC = 0x50424456;\n\n/** Every range in the pool (table, images, majorants) starts on this byte alignment (NanoVDB's data alignment). */\nexport const VDB_POOL_ALIGN = 32;\n\n/** Header size in bytes. */\nexport const VDB_POOL_HEADER_BYTES = 32;\n/** Header size in u32 words. */\nexport const VDB_POOL_HEADER_WORDS = VDB_POOL_HEADER_BYTES / 4;\n\n/** Byte offset of record 0 (fixed in layout 1). */\nexport const VDB_POOL_TABLE_OFFSET = 32;\n\n/** Grid record size in bytes. A multiple of 16 so `vec4` loads stay possible. */\nexport const VDB_POOL_RECORD_BYTES = 160;\n/** Grid record size in u32 words. */\nexport const VDB_POOL_RECORD_WORDS = VDB_POOL_RECORD_BYTES / 4;\n\n/** Header word indices (§1.1). */\nexport const VDB_HEADER_WORD = {\n /** {@link VDB_POOL_MAGIC}. */\n magic: 0,\n /** {@link VDB_GPU_LAYOUT_VERSION}. */\n layoutVersion: 1,\n /** Records in the table. */\n gridCapacity: 2,\n /** Highest live grid id + 1 (`vdbGridCount()` in WGSL). */\n gridCount: 3,\n /** {@link VDB_POOL_TABLE_OFFSET}, written for readers that don't know the version. */\n tableOffset: 4,\n /** {@link VDB_POOL_RECORD_BYTES}. */\n recordBytes: 5,\n /** Allocation high-water mark in bytes (diagnostics). */\n usedBytes: 6,\n /** Always 0 in layout 1. */\n reserved: 7,\n} as const;\n\n/** Grid record word indices (§1.2). Multi-word fields name their first word. */\nexport const VDB_RECORD_WORD = {\n /** u32: image byte offset from the start of the pool; a multiple of 32. */\n imageOffset: 0,\n /** u32: NanoVDB `GridData.mGridSize` (its high word must be 0). */\n imageBytes: 1,\n /** u32: NanoVDB `GridType` id (1 Float, 9 Half, 13 Fp4, 14 Fp8, 15 Fp16, 16 FpN). */\n gridType: 2,\n /** u32: see {@link VDB_RECORD_FLAG} and the class / brick-log2 bit fields. */\n flags: 3,\n /** f32 x12: world -> index, 3x4 row-major (`idx = M * [p, 1]`). */\n worldToIndex: 4,\n /** f32 x12: index -> world, 3x4 row-major. */\n indexToWorld: 16,\n /** i32 x3: root active bbox min. */\n indexBBoxMin: 28,\n /** f32: root background value. */\n background: 31,\n /** i32 x3: root active bbox max (inclusive). */\n indexBBoxMax: 32,\n /** f32: `max(root max stat, background)` or the caller's bound; the `global` majorant. */\n valueMax: 35,\n /** u32: brick-majorant range byte offset; 0 = none. */\n majorantOffset: 36,\n /** u32 x3: brick-majorant grid dimensions in cells. */\n majorantDims: 37,\n} as const;\n\n/** Single-bit record flags (record word 3). */\nexport const VDB_RECORD_FLAG = {\n /** b0: the record describes a live grid; a dead id reads 0 everywhere. */\n live: 1 << 0,\n /** b1: the image carries min/max stats (`GridData` flag `HasMinMax`). */\n hasStats: 1 << 1,\n /** b2: `majorantOffset`/`majorantDims` describe a brick-majorant range. */\n hasBrickMajorant: 1 << 2,\n /** b3: the affines include a host instance transform (`setTransform`). */\n instanceTransform: 1 << 3,\n} as const;\n\n/** Bit position of the 8-bit NanoVDB `GridClass` field in record word 3. */\nexport const VDB_RECORD_GRID_CLASS_SHIFT = 8;\n/** Bit position of the 8-bit brick log2 field in record word 3. */\nexport const VDB_RECORD_BRICK_LOG2_SHIFT = 16;\n/** Mask (after shifting) of the 8-bit class and brick-log2 fields. */\nexport const VDB_RECORD_BYTE_FIELD_MASK = 0xff;\n\n/**\n * A brick-majorant range (P1.3; record words 36-39 point at it): a 32-byte header, then\n * `dims.x * dims.y * dims.z` f32 upper bounds (x fastest), then as many lower bounds when the header's\n * minima flag is set. The header carries what the record has no room for: the index position of cell 0's\n * min corner and the flags. Layout 1 never defined the range's bytes (no 0.1 module read them, D22); the\n * magic lets a module tell a P1 range from a 0.1 pool's bare bounds and walk the latter as `global`.\n */\nexport const VDB_MAJORANT_HEADER_BYTES = 32;\n/** Majorant header word 4: `\"VDBM\"` read as a little-endian u32. */\nexport const VDB_MAJORANT_MAGIC = 0x4d424456;\n/** Majorant range header word indices. */\nexport const VDB_MAJORANT_WORD = {\n /** i32 x3: index position of cell 0's min corner. */\n origin: 0,\n /** u32: see {@link VDB_MAJORANT_FLAG}. */\n flags: 3,\n /** {@link VDB_MAJORANT_MAGIC}. */\n magic: 4,\n} as const;\n/** Majorant range header flag bits (word 3). */\nexport const VDB_MAJORANT_FLAG = {\n /** b0: lower bounds follow the upper bounds. */\n minima: 1 << 0,\n} as const;\n\n/** Packs a brick majorant's range: header, upper bounds, optional lower bounds. `bytes` is its size. */\nexport function encodeMajorantRange(m: {\n readonly origin: VDBVec3;\n readonly dims: VDBVec3;\n readonly data: Float32Array;\n readonly minima?: Float32Array | undefined;\n}): Float32Array {\n const cells = m.dims[0] * m.dims[1] * m.dims[2];\n const headerWords = VDB_MAJORANT_HEADER_BYTES / 4;\n const out = new Float32Array(headerWords + cells * (m.minima ? 2 : 1));\n const u32 = new Uint32Array(out.buffer);\n const i32 = new Int32Array(out.buffer);\n for (let k = 0; k < 3; k++) i32[VDB_MAJORANT_WORD.origin + k] = m.origin[k]!;\n u32[VDB_MAJORANT_WORD.flags] = m.minima ? VDB_MAJORANT_FLAG.minima : 0;\n u32[VDB_MAJORANT_WORD.magic] = VDB_MAJORANT_MAGIC;\n out.set(m.data, headerWords);\n if (m.minima) out.set(m.minima, headerWords + cells);\n return out;\n}\n\n/** Decoded pool header (§1.1). */\nexport interface VDBPoolHeader {\n magic: number;\n layoutVersion: number;\n gridCapacity: number;\n gridCount: number;\n tableOffset: number;\n recordBytes: number;\n usedBytes: number;\n}\n\n// One definition, shared with `@pmndrs/vdb/tools` (D32).\nexport type { VDBVec3 };\n\n/**\n * Decoded grid record (§1.2). Affines hold the f32-rounded values the GPU sees;\n * 12 entries each, 3x4 row-major.\n */\nexport interface VDBGridRecord {\n imageOffset: number;\n imageBytes: number;\n gridType: number;\n live: boolean;\n hasStats: boolean;\n hasBrickMajorant: boolean;\n instanceTransform: boolean;\n /** NanoVDB `GridClass` id (0-255). */\n gridClass: number;\n /** log2 of the brick edge in voxels (0-255; 0 when there is no brick majorant). */\n brickLog2: number;\n worldToIndex: number[];\n indexToWorld: number[];\n indexBBoxMin: VDBVec3;\n indexBBoxMax: VDBVec3;\n background: number;\n valueMax: number;\n majorantOffset: number;\n majorantDims: VDBVec3;\n}\n\n/** Rounds `n` up to the pool alignment ({@link VDB_POOL_ALIGN}). */\nexport function align32(n: number): number {\n return Math.ceil(n / VDB_POOL_ALIGN) * VDB_POOL_ALIGN;\n}\n\n/** Byte offset of record `id`. */\nexport function recordByteOffset(id: number): number {\n return VDB_POOL_TABLE_OFFSET + id * VDB_POOL_RECORD_BYTES;\n}\n\n/** First byte after a table of `capacity` records, aligned: where ranges may start. */\nexport function dataStartOffset(capacity: number): number {\n return align32(VDB_POOL_TABLE_OFFSET + capacity * VDB_POOL_RECORD_BYTES);\n}\n\n/** Writes the header's 8 words into `out` at `wordOffset` and returns `out`. */\nexport function encodeHeader(\n header: Omit<VDBPoolHeader, \"magic\" | \"layoutVersion\" | \"tableOffset\" | \"recordBytes\">,\n out: Uint32Array = new Uint32Array(VDB_POOL_HEADER_WORDS),\n wordOffset = 0,\n): Uint32Array {\n const w = VDB_HEADER_WORD;\n out[wordOffset + w.magic] = VDB_POOL_MAGIC;\n out[wordOffset + w.layoutVersion] = VDB_GPU_LAYOUT_VERSION;\n out[wordOffset + w.gridCapacity] = header.gridCapacity;\n out[wordOffset + w.gridCount] = header.gridCount;\n out[wordOffset + w.tableOffset] = VDB_POOL_TABLE_OFFSET;\n out[wordOffset + w.recordBytes] = VDB_POOL_RECORD_BYTES;\n out[wordOffset + w.usedBytes] = header.usedBytes;\n out[wordOffset + w.reserved] = 0;\n return out;\n}\n\n/** Reads a header from `words` at `wordOffset` (no validation; see {@link VDBPoolHeader}). */\nexport function decodeHeader(words: Uint32Array, wordOffset = 0): VDBPoolHeader {\n const w = VDB_HEADER_WORD;\n const at = (i: number) => words[wordOffset + i] ?? 0;\n return {\n magic: at(w.magic),\n layoutVersion: at(w.layoutVersion),\n gridCapacity: at(w.gridCapacity),\n gridCount: at(w.gridCount),\n tableOffset: at(w.tableOffset),\n recordBytes: at(w.recordBytes),\n usedBytes: at(w.usedBytes),\n };\n}\n\nfunction views(words: Uint32Array): { f32: Float32Array; i32: Int32Array } {\n return {\n f32: new Float32Array(words.buffer, words.byteOffset, words.length),\n i32: new Int32Array(words.buffer, words.byteOffset, words.length),\n };\n}\n\nfunction byteField(name: string, value: number): number {\n if (!Number.isInteger(value) || value < 0 || value > VDB_RECORD_BYTE_FIELD_MASK) {\n throw new VDBError(\"VDB_BAD_OPTION\", `encodeRecord: ${name} must be an integer in 0..255, got ${value}.`);\n }\n return value;\n}\n\n/**\n * Writes `record` as 40 words into `out` at `wordOffset` and returns `out`.\n * Affines are rounded to f32 here; pass the f64 values you composed.\n */\nexport function encodeRecord(\n record: VDBGridRecord,\n out: Uint32Array = new Uint32Array(VDB_POOL_RECORD_WORDS),\n wordOffset = 0,\n): Uint32Array {\n if (record.worldToIndex.length !== 12 || record.indexToWorld.length !== 12) {\n throw new VDBError(\"VDB_BAD_OPTION\", \"encodeRecord: worldToIndex and indexToWorld must each have 12 entries (3x4 row-major).\");\n }\n if (out.length < wordOffset + VDB_POOL_RECORD_WORDS) {\n throw new VDBError(\n \"VDB_BAD_OPTION\",\n `encodeRecord: output has ${out.length} words; a record at word ${wordOffset} needs ${wordOffset + VDB_POOL_RECORD_WORDS}.`,\n );\n }\n const { f32, i32 } = views(out);\n const r = VDB_RECORD_WORD;\n const o = wordOffset;\n const F = VDB_RECORD_FLAG;\n let flags = 0;\n if (record.live) flags |= F.live;\n if (record.hasStats) flags |= F.hasStats;\n if (record.hasBrickMajorant) flags |= F.hasBrickMajorant;\n if (record.instanceTransform) flags |= F.instanceTransform;\n flags |= byteField(\"gridClass\", record.gridClass) << VDB_RECORD_GRID_CLASS_SHIFT;\n flags |= byteField(\"brickLog2\", record.brickLog2) << VDB_RECORD_BRICK_LOG2_SHIFT;\n\n out[o + r.imageOffset] = record.imageOffset;\n out[o + r.imageBytes] = record.imageBytes;\n out[o + r.gridType] = record.gridType;\n out[o + r.flags] = flags >>> 0;\n for (let k = 0; k < 12; k++) {\n f32[o + r.worldToIndex + k] = record.worldToIndex[k]!;\n f32[o + r.indexToWorld + k] = record.indexToWorld[k]!;\n }\n for (let k = 0; k < 3; k++) {\n i32[o + r.indexBBoxMin + k] = record.indexBBoxMin[k]!;\n i32[o + r.indexBBoxMax + k] = record.indexBBoxMax[k]!;\n out[o + r.majorantDims + k] = record.majorantDims[k]!;\n }\n f32[o + r.background] = record.background;\n f32[o + r.valueMax] = record.valueMax;\n out[o + r.majorantOffset] = record.majorantOffset;\n return out;\n}\n\n/** Reads the 40-word record at `wordOffset` of `words`. */\nexport function decodeRecord(words: Uint32Array, wordOffset = 0): VDBGridRecord {\n if (words.length < wordOffset + VDB_POOL_RECORD_WORDS) {\n throw new VDBError(\n \"VDB_BAD_OPTION\",\n `decodeRecord: input has ${words.length} words; a record at word ${wordOffset} needs ${wordOffset + VDB_POOL_RECORD_WORDS}.`,\n );\n }\n const { f32, i32 } = views(words);\n const r = VDB_RECORD_WORD;\n const o = wordOffset;\n const flags = words[o + r.flags]!;\n const F = VDB_RECORD_FLAG;\n const vec = (src: Int32Array | Uint32Array, at: number): VDBVec3 => [src[o + at]!, src[o + at + 1]!, src[o + at + 2]!];\n return {\n imageOffset: words[o + r.imageOffset]!,\n imageBytes: words[o + r.imageBytes]!,\n gridType: words[o + r.gridType]!,\n live: (flags & F.live) !== 0,\n hasStats: (flags & F.hasStats) !== 0,\n hasBrickMajorant: (flags & F.hasBrickMajorant) !== 0,\n instanceTransform: (flags & F.instanceTransform) !== 0,\n gridClass: (flags >>> VDB_RECORD_GRID_CLASS_SHIFT) & VDB_RECORD_BYTE_FIELD_MASK,\n brickLog2: (flags >>> VDB_RECORD_BRICK_LOG2_SHIFT) & VDB_RECORD_BYTE_FIELD_MASK,\n worldToIndex: Array.from(f32.subarray(o + r.worldToIndex, o + r.worldToIndex + 12)),\n indexToWorld: Array.from(f32.subarray(o + r.indexToWorld, o + r.indexToWorld + 12)),\n indexBBoxMin: vec(i32, r.indexBBoxMin),\n indexBBoxMax: vec(i32, r.indexBBoxMax),\n background: f32[o + r.background]!,\n valueMax: f32[o + r.valueMax]!,\n majorantOffset: words[o + r.majorantOffset]!,\n majorantDims: vec(words, r.majorantDims),\n };\n}\n\n/** `fooBarBaz` -> `FOO_BAR_BAZ`. */\nfunction upperSnake(name: string): string {\n return name.replace(/([a-z0-9])([A-Z])/g, \"$1_$2\").toUpperCase();\n}\n\nfunction u32Hex(n: number): string {\n return `0x${(n >>> 0).toString(16)}u`;\n}\n\n/**\n * WGSL `const` declarations for layout {@link VDB_GPU_LAYOUT_VERSION}, generated\n * from the tables in this file. Pure and deterministic: same package version,\n * same text. Every name carries the `VDB_` prefix (D10, K1-core §3.4) and no\n * comment contains a back-tick (CLAUDE.md Traps).\n *\n * Emitted names (all `u32`):\n * - `VDB_GPU_LAYOUT_VERSION`, `VDB_POOL_MAGIC`\n * - `VDB_POOL_TABLE_OFFSET` (bytes), `VDB_POOL_TABLE_WORD` (= offset / 4),\n * `VDB_POOL_RECORD_BYTES`, `VDB_POOL_RECORD_WORDS`, `VDB_POOL_ALIGN`\n * - `VDB_HEADER_<FIELD>` for every {@link VDB_HEADER_WORD} entry (word index),\n * e.g. `VDB_HEADER_GRID_COUNT = 3u`\n * - `VDB_REC_<FIELD>` for every {@link VDB_RECORD_WORD} entry (word index within\n * a record), e.g. `VDB_REC_IMAGE_OFFSET = 0u`, `VDB_REC_WORLD_TO_INDEX = 4u`\n * - `VDB_REC_FLAG_<NAME>` for every {@link VDB_RECORD_FLAG} bit, plus\n * `VDB_REC_GRID_CLASS_SHIFT`, `VDB_REC_BRICK_LOG2_SHIFT`, `VDB_REC_BYTE_FIELD_MASK`\n * - P1.3, the brick-majorant range header: `VDB_MAJORANT_MAGIC`, `VDB_MAJORANT_HEADER_WORDS`,\n * `VDB_MAJ_<FIELD>` for every {@link VDB_MAJORANT_WORD} entry and `VDB_MAJ_FLAG_<NAME>` per\n * {@link VDB_MAJORANT_FLAG} bit\n *\n * Word `w` of record `g` is `vdb_load(VDB_POOL_TABLE_WORD + g * VDB_POOL_RECORD_WORDS + w)`.\n */\nexport function vdbPoolLayoutWgsl(): string {\n const lines: string[] = [\n `// @pmndrs/vdb pool layout ${VDB_GPU_LAYOUT_VERSION} (generated from core/pool/layout.ts; do not edit).`,\n `const VDB_GPU_LAYOUT_VERSION: u32 = ${VDB_GPU_LAYOUT_VERSION}u;`,\n `const VDB_POOL_MAGIC: u32 = ${u32Hex(VDB_POOL_MAGIC)};`,\n `const VDB_POOL_ALIGN: u32 = ${VDB_POOL_ALIGN}u;`,\n `const VDB_POOL_TABLE_OFFSET: u32 = ${VDB_POOL_TABLE_OFFSET}u;`,\n `const VDB_POOL_TABLE_WORD: u32 = ${VDB_POOL_TABLE_OFFSET / 4}u;`,\n `const VDB_POOL_RECORD_BYTES: u32 = ${VDB_POOL_RECORD_BYTES}u;`,\n `const VDB_POOL_RECORD_WORDS: u32 = ${VDB_POOL_RECORD_WORDS}u;`,\n ];\n for (const [name, word] of Object.entries(VDB_HEADER_WORD)) {\n lines.push(`const VDB_HEADER_${upperSnake(name)}: u32 = ${word}u;`);\n }\n for (const [name, word] of Object.entries(VDB_RECORD_WORD)) {\n lines.push(`const VDB_REC_${upperSnake(name)}: u32 = ${word}u;`);\n }\n for (const [name, bit] of Object.entries(VDB_RECORD_FLAG)) {\n lines.push(`const VDB_REC_FLAG_${upperSnake(name)}: u32 = ${u32Hex(bit)};`);\n }\n lines.push(\n `const VDB_REC_GRID_CLASS_SHIFT: u32 = ${VDB_RECORD_GRID_CLASS_SHIFT}u;`,\n `const VDB_REC_BRICK_LOG2_SHIFT: u32 = ${VDB_RECORD_BRICK_LOG2_SHIFT}u;`,\n `const VDB_REC_BYTE_FIELD_MASK: u32 = ${u32Hex(VDB_RECORD_BYTE_FIELD_MASK)};`,\n `const VDB_MAJORANT_MAGIC: u32 = ${u32Hex(VDB_MAJORANT_MAGIC)};`,\n `const VDB_MAJORANT_HEADER_WORDS: u32 = ${VDB_MAJORANT_HEADER_BYTES / 4}u;`,\n );\n for (const [name, word] of Object.entries(VDB_MAJORANT_WORD)) {\n lines.push(`const VDB_MAJ_${upperSnake(name)}: u32 = ${word}u;`);\n }\n for (const [name, bit] of Object.entries(VDB_MAJORANT_FLAG)) {\n lines.push(`const VDB_MAJ_FLAG_${upperSnake(name)}: u32 = ${u32Hex(bit)};`);\n }\n return lines.join(\"\\n\") + \"\\n\";\n}\n"]}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Device checks and size limits for the pool (docs/dev/design/K1-core.md §1.5).
3
+ */
4
+ /**
5
+ * `GPUBufferUsage` bits, restated as numbers so the core runs where the WebGPU
6
+ * globals don't exist (Node tests, workers before a device). Values from the
7
+ * WebGPU spec.
8
+ */
9
+ export declare const BUFFER_USAGE: {
10
+ readonly MAP_READ: 1;
11
+ readonly COPY_SRC: 4;
12
+ readonly COPY_DST: 8;
13
+ readonly UNIFORM: 64;
14
+ readonly STORAGE: 128;
15
+ };
16
+ /** Usage flags every pool-owned buffer has. */
17
+ export declare const POOL_BUFFER_USAGE: number;
18
+ /** Largest pool the 32-bit image addressing allows (§2), rounded down to the 32 B alignment. */
19
+ export declare const ADDRESS_LIMIT_BYTES: number;
20
+ /** The smallest buffer a pool can be: header + a one-record table, rounded to 32 B. */
21
+ export declare const MIN_POOL_BYTES = 256;
22
+ /** Starts tracking `device.lost` so later checks can report a lost device synchronously. */
23
+ export declare function watchDevice(device: GPUDevice): void;
24
+ /** True once a watched device has reported loss. */
25
+ export declare function isDeviceLost(device: GPUDevice): boolean;
26
+ /** Largest pool buffer `device` can bind, clamped to the 32-bit addressing limit. */
27
+ export declare function deviceByteLimit(device: GPUDevice): number;
28
+ /** Rounds down to a multiple of 32. */
29
+ export declare function floor32(n: number): number;
30
+ /**
31
+ * Why `device` can't hold a pool, or `null` when it can. Messages name the fix.
32
+ * Checks: a device object with limits, not lost (tracked once the core has seen
33
+ * the device), at least one storage buffer per stage, and room for a minimal pool.
34
+ */
35
+ export declare function unsupportedReason(device: GPUDevice | null | undefined): string | null;
36
+ /**
37
+ * The limits to pass to `adapter.requestDevice({ requiredLimits })` so the pool
38
+ * can grow as far as the adapter allows: the adapter's maxima for
39
+ * `maxStorageBufferBindingSize` and `maxBufferSize`.
40
+ */
41
+ export declare function requiredLimits(adapter: GPUAdapter): Record<string, number>;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Device checks and size limits for the pool (docs/dev/design/K1-core.md §1.5).
3
+ */
4
+ /**
5
+ * `GPUBufferUsage` bits, restated as numbers so the core runs where the WebGPU
6
+ * globals don't exist (Node tests, workers before a device). Values from the
7
+ * WebGPU spec.
8
+ */
9
+ export const BUFFER_USAGE = {
10
+ MAP_READ: 0x0001,
11
+ COPY_SRC: 0x0004,
12
+ COPY_DST: 0x0008,
13
+ UNIFORM: 0x0040,
14
+ STORAGE: 0x0080,
15
+ };
16
+ /** Usage flags every pool-owned buffer has. */
17
+ export const POOL_BUFFER_USAGE = BUFFER_USAGE.STORAGE | BUFFER_USAGE.COPY_DST | BUFFER_USAGE.COPY_SRC;
18
+ /** Largest pool the 32-bit image addressing allows (§2), rounded down to the 32 B alignment. */
19
+ export const ADDRESS_LIMIT_BYTES = 2 ** 32 - 32;
20
+ /** The smallest buffer a pool can be: header + a one-record table, rounded to 32 B. */
21
+ export const MIN_POOL_BYTES = 256;
22
+ const lostDevices = new WeakSet();
23
+ const watchedDevices = new WeakSet();
24
+ /** Starts tracking `device.lost` so later checks can report a lost device synchronously. */
25
+ export function watchDevice(device) {
26
+ if (watchedDevices.has(device))
27
+ return;
28
+ watchedDevices.add(device);
29
+ const lost = device.lost;
30
+ void lost?.then(() => lostDevices.add(device));
31
+ }
32
+ /** True once a watched device has reported loss. */
33
+ export function isDeviceLost(device) {
34
+ return lostDevices.has(device);
35
+ }
36
+ /** Largest pool buffer `device` can bind, clamped to the 32-bit addressing limit. */
37
+ export function deviceByteLimit(device) {
38
+ const { maxStorageBufferBindingSize, maxBufferSize } = device.limits;
39
+ return floor32(Math.min(maxStorageBufferBindingSize, maxBufferSize, ADDRESS_LIMIT_BYTES));
40
+ }
41
+ /** Rounds down to a multiple of 32. */
42
+ export function floor32(n) {
43
+ return Math.floor(n / 32) * 32;
44
+ }
45
+ /**
46
+ * Why `device` can't hold a pool, or `null` when it can. Messages name the fix.
47
+ * Checks: a device object with limits, not lost (tracked once the core has seen
48
+ * the device), at least one storage buffer per stage, and room for a minimal pool.
49
+ */
50
+ export function unsupportedReason(device) {
51
+ if (!device)
52
+ return "No GPUDevice was passed. Request one with adapter.requestDevice() and pass it in.";
53
+ const limits = device.limits;
54
+ if (!limits)
55
+ return "The object passed as a GPUDevice has no limits. Pass a real GPUDevice.";
56
+ if (isDeviceLost(device))
57
+ return "The GPUDevice was lost. Request a new device and create a new pool on it.";
58
+ if (!(limits.maxStorageBuffersPerShaderStage >= 1)) {
59
+ return (`The device allows ${limits.maxStorageBuffersPerShaderStage} storage buffers per shader stage; the pool needs 1. ` +
60
+ `Request a core (non-compatibility) device.`);
61
+ }
62
+ const limit = deviceByteLimit(device);
63
+ if (limit < MIN_POOL_BYTES) {
64
+ return (`The device can bind storage buffers of ${limit} bytes; the pool needs at least ${MIN_POOL_BYTES}. ` +
65
+ `Request the device with VDBGridPool.requiredLimits(adapter).`);
66
+ }
67
+ return null;
68
+ }
69
+ /**
70
+ * The limits to pass to `adapter.requestDevice({ requiredLimits })` so the pool
71
+ * can grow as far as the adapter allows: the adapter's maxima for
72
+ * `maxStorageBufferBindingSize` and `maxBufferSize`.
73
+ */
74
+ export function requiredLimits(adapter) {
75
+ return {
76
+ maxStorageBufferBindingSize: adapter.limits.maxStorageBufferBindingSize,
77
+ maxBufferSize: adapter.limits.maxBufferSize,
78
+ };
79
+ }
80
+ //# sourceMappingURL=limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.js","sourceRoot":"","sources":["../../../src/core/pool/limits.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,MAAM;IAChB,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,MAAM;CACP,CAAC;AAEX,+CAA+C;AAC/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,YAAY,CAAC,OAAO,GAAG,YAAY,CAAC,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAC;AAEtG,gGAAgG;AAChG,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC;AAEhD,uFAAuF;AACvF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAElC,MAAM,WAAW,GAAG,IAAI,OAAO,EAAa,CAAC;AAC7C,MAAM,cAAc,GAAG,IAAI,OAAO,EAAa,CAAC;AAEhD,4FAA4F;AAC5F,MAAM,UAAU,WAAW,CAAC,MAAiB;IAC3C,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,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,KAAK,GAAG,cAAc,EAAE,CAAC;QAC3B,OAAO,CACL,0CAA0C,KAAK,mCAAmC,cAAc,IAAI;YACpG,8DAA8D,CAC/D,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,OAAmB;IAChD,OAAO;QACL,2BAA2B,EAAE,OAAO,CAAC,MAAM,CAAC,2BAA2B;QACvE,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa;KAC5C,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Device checks and size limits for the pool (docs/dev/design/K1-core.md §1.5).\n */\n\n/**\n * `GPUBufferUsage` bits, restated as numbers so the core runs where the WebGPU\n * globals don't exist (Node tests, workers before a device). Values from the\n * WebGPU spec.\n */\nexport const BUFFER_USAGE = {\n MAP_READ: 0x0001,\n COPY_SRC: 0x0004,\n COPY_DST: 0x0008,\n UNIFORM: 0x0040,\n STORAGE: 0x0080,\n} as const;\n\n/** Usage flags every pool-owned buffer has. */\nexport const POOL_BUFFER_USAGE = BUFFER_USAGE.STORAGE | BUFFER_USAGE.COPY_DST | BUFFER_USAGE.COPY_SRC;\n\n/** Largest pool the 32-bit image addressing allows (§2), rounded down to the 32 B alignment. */\nexport const ADDRESS_LIMIT_BYTES = 2 ** 32 - 32;\n\n/** The smallest buffer a pool can be: header + a one-record table, rounded to 32 B. */\nexport const MIN_POOL_BYTES = 256;\n\nconst lostDevices = new WeakSet<GPUDevice>();\nconst watchedDevices = new WeakSet<GPUDevice>();\n\n/** Starts tracking `device.lost` so later checks can report a lost device synchronously. */\nexport function watchDevice(device: GPUDevice): void {\n if (watchedDevices.has(device)) return;\n watchedDevices.add(device);\n const lost: Promise<GPUDeviceLostInfo> | undefined = device.lost;\n void lost?.then(() => lostDevices.add(device));\n}\n\n/** True once a watched device has reported loss. */\nexport function isDeviceLost(device: GPUDevice): boolean {\n return lostDevices.has(device);\n}\n\n/** Largest pool buffer `device` can bind, clamped to the 32-bit addressing limit. */\nexport function deviceByteLimit(device: GPUDevice): number {\n const { maxStorageBufferBindingSize, maxBufferSize } = device.limits;\n return floor32(Math.min(maxStorageBufferBindingSize, maxBufferSize, ADDRESS_LIMIT_BYTES));\n}\n\n/** Rounds down to a multiple of 32. */\nexport function floor32(n: number): number {\n return Math.floor(n / 32) * 32;\n}\n\n/**\n * Why `device` can't hold a pool, or `null` when it can. Messages name the fix.\n * Checks: a device object with limits, not lost (tracked once the core has seen\n * the device), at least one storage buffer per stage, and room for a minimal pool.\n */\nexport function unsupportedReason(device: GPUDevice | null | undefined): string | null {\n if (!device) return \"No GPUDevice was passed. Request one with adapter.requestDevice() and pass it in.\";\n const limits = device.limits as GPUSupportedLimits | undefined;\n if (!limits) return \"The object passed as a GPUDevice has no limits. Pass a real GPUDevice.\";\n if (isDeviceLost(device)) return \"The GPUDevice was lost. Request a new device and create a new pool on it.\";\n if (!(limits.maxStorageBuffersPerShaderStage >= 1)) {\n return (\n `The device allows ${limits.maxStorageBuffersPerShaderStage} storage buffers per shader stage; the pool needs 1. ` +\n `Request a core (non-compatibility) device.`\n );\n }\n const limit = deviceByteLimit(device);\n if (limit < MIN_POOL_BYTES) {\n return (\n `The device can bind storage buffers of ${limit} bytes; the pool needs at least ${MIN_POOL_BYTES}. ` +\n `Request the device with VDBGridPool.requiredLimits(adapter).`\n );\n }\n return null;\n}\n\n/**\n * The limits to pass to `adapter.requestDevice({ requiredLimits })` so the pool\n * can grow as far as the adapter allows: the adapter's maxima for\n * `maxStorageBufferBindingSize` and `maxBufferSize`.\n */\nexport function requiredLimits(adapter: GPUAdapter): Record<string, number> {\n return {\n maxStorageBufferBindingSize: adapter.limits.maxStorageBufferBindingSize,\n maxBufferSize: adapter.limits.maxBufferSize,\n };\n}\n"]}