@pmndrs/vdb 0.1.0 → 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 (576) hide show
  1. package/CHANGELOG.md +592 -2
  2. package/README.md +85 -37
  3. package/THIRD_PARTY_NOTICES.md +197 -29
  4. package/dist/core/compute/atlas.d.ts +10 -2
  5. package/dist/core/compute/atlas.js +6 -1
  6. package/dist/core/compute/atlas.js.map +1 -1
  7. package/dist/core/compute/index.d.ts +3 -3
  8. package/dist/core/compute/index.js +2 -2
  9. package/dist/core/compute/index.js.map +1 -1
  10. package/dist/core/compute/majorant-build.d.ts +45 -0
  11. package/dist/core/compute/majorant-build.js +193 -0
  12. package/dist/core/compute/majorant-build.js.map +1 -0
  13. package/dist/core/compute/multi-scale.d.ts +155 -0
  14. package/dist/core/compute/multi-scale.js +684 -0
  15. package/dist/core/compute/multi-scale.js.map +1 -0
  16. package/dist/core/compute/pyramid.d.ts +22 -7
  17. package/dist/core/compute/pyramid.js +22 -9
  18. package/dist/core/compute/pyramid.js.map +1 -1
  19. package/dist/core/compute/shared.d.ts +1 -0
  20. package/dist/core/compute/shared.js.map +1 -1
  21. package/dist/core/compute/stats.d.ts +10 -3
  22. package/dist/core/compute/stats.js +6 -1
  23. package/dist/core/compute/stats.js.map +1 -1
  24. package/dist/core/compute/value-transform.d.ts +8 -1
  25. package/dist/core/compute/value-transform.js +9 -3
  26. package/dist/core/compute/value-transform.js.map +1 -1
  27. package/dist/core/errors.d.ts +10 -0
  28. package/dist/core/errors.js +8 -0
  29. package/dist/core/errors.js.map +1 -1
  30. package/dist/core/frame/emission.d.ts +85 -0
  31. package/dist/core/frame/emission.js +422 -0
  32. package/dist/core/frame/emission.js.map +1 -0
  33. package/dist/core/frame/environment.d.ts +47 -0
  34. package/dist/core/frame/environment.js +178 -0
  35. package/dist/core/frame/environment.js.map +1 -0
  36. package/dist/core/frame/index.d.ts +39 -0
  37. package/dist/core/frame/index.js +27 -0
  38. package/dist/core/frame/index.js.map +1 -0
  39. package/dist/core/frame/kernels.d.ts +115 -0
  40. package/dist/core/frame/kernels.js +496 -0
  41. package/dist/core/frame/kernels.js.map +1 -0
  42. package/dist/core/frame/limits.d.ts +67 -0
  43. package/dist/core/frame/limits.js +109 -0
  44. package/dist/core/frame/limits.js.map +1 -0
  45. package/dist/core/frame/phase.d.ts +17 -0
  46. package/dist/core/frame/phase.js +53 -0
  47. package/dist/core/frame/phase.js.map +1 -0
  48. package/dist/core/frame/pipelines.d.ts +49 -0
  49. package/dist/core/frame/pipelines.js +147 -0
  50. package/dist/core/frame/pipelines.js.map +1 -0
  51. package/dist/core/frame/renderer.d.ts +122 -0
  52. package/dist/core/frame/renderer.js +1712 -0
  53. package/dist/core/frame/renderer.js.map +1 -0
  54. package/dist/core/frame/resources.d.ts +71 -0
  55. package/dist/core/frame/resources.js +100 -0
  56. package/dist/core/frame/resources.js.map +1 -0
  57. package/dist/core/frame/scattering.d.ts +97 -0
  58. package/dist/core/frame/scattering.js +332 -0
  59. package/dist/core/frame/scattering.js.map +1 -0
  60. package/dist/core/frame/settings.d.ts +243 -0
  61. package/dist/core/frame/settings.js +67 -0
  62. package/dist/core/frame/settings.js.map +1 -0
  63. package/dist/core/frame/shadows.d.ts +55 -0
  64. package/dist/core/frame/shadows.js +460 -0
  65. package/dist/core/frame/shadows.js.map +1 -0
  66. package/dist/core/frame/types.d.ts +415 -0
  67. package/dist/core/frame/types.js +49 -0
  68. package/dist/core/frame/types.js.map +1 -0
  69. package/dist/core/frame/uniforms.d.ts +105 -0
  70. package/dist/core/frame/uniforms.js +276 -0
  71. package/dist/core/frame/uniforms.js.map +1 -0
  72. package/dist/core/frame/wgsl/chunks.d.ts +4 -0
  73. package/dist/core/frame/wgsl/chunks.js +728 -0
  74. package/dist/core/frame/wgsl/chunks.js.map +1 -0
  75. package/dist/core/frame/wgsl/emission.d.ts +82 -0
  76. package/dist/core/frame/wgsl/emission.js +353 -0
  77. package/dist/core/frame/wgsl/emission.js.map +1 -0
  78. package/dist/core/frame/wgsl/environment.d.ts +42 -0
  79. package/dist/core/frame/wgsl/environment.js +711 -0
  80. package/dist/core/frame/wgsl/environment.js.map +1 -0
  81. package/dist/core/frame/wgsl/gather.d.ts +55 -0
  82. package/dist/core/frame/wgsl/gather.js +850 -0
  83. package/dist/core/frame/wgsl/gather.js.map +1 -0
  84. package/dist/core/frame/wgsl/integrate.d.ts +78 -0
  85. package/dist/core/frame/wgsl/integrate.js +213 -0
  86. package/dist/core/frame/wgsl/integrate.js.map +1 -0
  87. package/dist/core/frame/wgsl/lighting.d.ts +103 -0
  88. package/dist/core/frame/wgsl/lighting.js +1636 -0
  89. package/dist/core/frame/wgsl/lighting.js.map +1 -0
  90. package/dist/core/frame/wgsl/occluders.d.ts +20 -0
  91. package/dist/core/frame/wgsl/occluders.js +95 -0
  92. package/dist/core/frame/wgsl/occluders.js.map +1 -0
  93. package/dist/core/frame/wgsl/resolve.d.ts +19 -0
  94. package/dist/core/frame/wgsl/resolve.js +205 -0
  95. package/dist/core/frame/wgsl/resolve.js.map +1 -0
  96. package/dist/core/frame/wgsl/shadows.d.ts +35 -0
  97. package/dist/core/frame/wgsl/shadows.js +328 -0
  98. package/dist/core/frame/wgsl/shadows.js.map +1 -0
  99. package/dist/core/half.d.ts +11 -0
  100. package/dist/core/half.js +22 -0
  101. package/dist/core/half.js.map +1 -0
  102. package/dist/core/index.d.ts +25 -3
  103. package/dist/core/index.js +23 -4
  104. package/dist/core/index.js.map +1 -1
  105. package/dist/core/internal.d.ts +17 -1
  106. package/dist/core/internal.js +18 -1
  107. package/dist/core/internal.js.map +1 -1
  108. package/dist/core/pool/image-header.d.ts +13 -2
  109. package/dist/core/pool/image-header.js +24 -5
  110. package/dist/core/pool/image-header.js.map +1 -1
  111. package/dist/core/pool/layout.d.ts +35 -1
  112. package/dist/core/pool/layout.js +51 -2
  113. package/dist/core/pool/layout.js.map +1 -1
  114. package/dist/core/pool/limits.d.ts +1 -0
  115. package/dist/core/pool/limits.js +1 -0
  116. package/dist/core/pool/limits.js.map +1 -1
  117. package/dist/core/pool/pool.d.ts +120 -15
  118. package/dist/core/pool/pool.js +255 -24
  119. package/dist/core/pool/pool.js.map +1 -1
  120. package/dist/core/reference/index.d.ts +6 -0
  121. package/dist/core/reference/index.js +7 -0
  122. package/dist/core/reference/index.js.map +1 -0
  123. package/dist/core/reference/renderer.d.ts +105 -0
  124. package/dist/core/reference/renderer.js +474 -0
  125. package/dist/core/reference/renderer.js.map +1 -0
  126. package/dist/core/reference/wgsl.d.ts +65 -0
  127. package/dist/core/reference/wgsl.js +803 -0
  128. package/dist/core/reference/wgsl.js.map +1 -0
  129. package/dist/{three → core}/sequence.d.ts +32 -2
  130. package/dist/{three → core}/sequence.js +24 -2
  131. package/dist/core/sequence.js.map +1 -0
  132. package/dist/core/source/brick-cache.d.ts +165 -0
  133. package/dist/core/source/brick-cache.js +627 -0
  134. package/dist/core/source/brick-cache.js.map +1 -0
  135. package/dist/core/source/dense-fill.d.ts +53 -0
  136. package/dist/core/source/dense-fill.js +377 -0
  137. package/dist/core/source/dense-fill.js.map +1 -0
  138. package/dist/core/source/dense.d.ts +33 -2
  139. package/dist/core/source/dense.js +121 -24
  140. package/dist/core/source/dense.js.map +1 -1
  141. package/dist/core/source/sparse-wgsl.d.ts +92 -0
  142. package/dist/core/source/sparse-wgsl.js +481 -0
  143. package/dist/core/source/sparse-wgsl.js.map +1 -0
  144. package/dist/core/source/sparse.d.ts +192 -0
  145. package/dist/core/source/sparse.js +762 -0
  146. package/dist/core/source/sparse.js.map +1 -0
  147. package/dist/core/source/types.d.ts +59 -2
  148. package/dist/core/source/types.js.map +1 -1
  149. package/dist/core/surface/index.d.ts +10 -0
  150. package/dist/core/surface/index.js +9 -0
  151. package/dist/core/surface/index.js.map +1 -0
  152. package/dist/core/surface/level-set-pass.d.ts +140 -0
  153. package/dist/core/surface/level-set-pass.js +291 -0
  154. package/dist/core/surface/level-set-pass.js.map +1 -0
  155. package/dist/core/surface/level-set-wgsl.d.ts +46 -0
  156. package/dist/core/surface/level-set-wgsl.js +99 -0
  157. package/dist/core/surface/level-set-wgsl.js.map +1 -0
  158. package/dist/core/surface/points.d.ts +109 -0
  159. package/dist/core/surface/points.js +226 -0
  160. package/dist/core/surface/points.js.map +1 -0
  161. package/dist/core/types.d.ts +12 -3
  162. package/dist/core/types.js +6 -2
  163. package/dist/core/types.js.map +1 -1
  164. package/dist/core/wgsl/api.d.ts +29 -5
  165. package/dist/core/wgsl/api.js +110 -27
  166. package/dist/core/wgsl/api.js.map +1 -1
  167. package/dist/core/wgsl/generate.d.ts +8 -0
  168. package/dist/core/wgsl/generate.js +195 -22
  169. package/dist/core/wgsl/generate.js.map +1 -1
  170. package/dist/core/wgsl/lean.d.ts +50 -0
  171. package/dist/core/wgsl/lean.js +327 -0
  172. package/dist/core/wgsl/lean.js.map +1 -0
  173. package/dist/core/wgsl/level-set.d.ts +5 -1
  174. package/dist/core/wgsl/level-set.js +11 -5
  175. package/dist/core/wgsl/level-set.js.map +1 -1
  176. package/dist/core/wgsl/majorant.d.ts +62 -0
  177. package/dist/core/wgsl/majorant.js +381 -0
  178. package/dist/core/wgsl/majorant.js.map +1 -0
  179. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +2 -2
  180. package/dist/core/wgsl/pnanovdb.chunks.generated.js +15 -12
  181. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -1
  182. package/dist/core/wgsl/types.d.ts +97 -3
  183. package/dist/core/wgsl/types.js.map +1 -1
  184. package/dist/three/coarse-first.d.ts +53 -8
  185. package/dist/three/coarse-first.js +24 -6
  186. package/dist/three/coarse-first.js.map +1 -1
  187. package/dist/three/compute.d.ts +12 -2
  188. package/dist/three/compute.js +16 -6
  189. package/dist/three/compute.js.map +1 -1
  190. package/dist/three/device.d.ts +7 -0
  191. package/dist/three/device.js +3 -0
  192. package/dist/three/device.js.map +1 -1
  193. package/dist/three/frame/core-environment.d.ts +38 -0
  194. package/dist/three/frame/core-environment.js +154 -0
  195. package/dist/three/frame/core-environment.js.map +1 -0
  196. package/dist/three/frame/core-integrate-material.d.ts +34 -0
  197. package/dist/three/frame/core-integrate-material.js +162 -0
  198. package/dist/three/frame/core-integrate-material.js.map +1 -0
  199. package/dist/three/frame/core-occluders.d.ts +53 -0
  200. package/dist/three/frame/core-occluders.js +193 -0
  201. package/dist/three/frame/core-occluders.js.map +1 -0
  202. package/dist/three/frame/core-structs.d.ts +34 -0
  203. package/dist/three/frame/core-structs.js +61 -0
  204. package/dist/three/frame/core-structs.js.map +1 -0
  205. package/dist/three/frame/core-textures.d.ts +41 -0
  206. package/dist/three/frame/core-textures.js +114 -0
  207. package/dist/three/frame/core-textures.js.map +1 -0
  208. package/dist/three/frame/emission-light.d.ts +64 -114
  209. package/dist/three/frame/emission-light.js +188 -567
  210. package/dist/three/frame/emission-light.js.map +1 -1
  211. package/dist/three/frame/index.d.ts +11 -31
  212. package/dist/three/frame/index.js +9 -29
  213. package/dist/three/frame/index.js.map +1 -1
  214. package/dist/three/frame/medium.d.ts +12 -0
  215. package/dist/three/frame/medium.js.map +1 -1
  216. package/dist/three/frame/renderer.d.ts +58 -454
  217. package/dist/three/frame/renderer.js +409 -1427
  218. package/dist/three/frame/renderer.js.map +1 -1
  219. package/dist/three/frame/spectrum.d.ts +0 -14
  220. package/dist/three/frame/spectrum.js +2 -23
  221. package/dist/three/frame/spectrum.js.map +1 -1
  222. package/dist/three/frame/three-internals.d.ts +3 -8
  223. package/dist/three/frame/three-internals.js +13 -11
  224. package/dist/three/frame/three-internals.js.map +1 -1
  225. package/dist/three/frame/volume-shadows.d.ts +93 -107
  226. package/dist/three/frame/volume-shadows.js +278 -631
  227. package/dist/three/frame/volume-shadows.js.map +1 -1
  228. package/dist/three/frame/volume.d.ts +91 -33
  229. package/dist/three/frame/volume.js +63 -51
  230. package/dist/three/frame/volume.js.map +1 -1
  231. package/dist/three/grid-node.d.ts +34 -1
  232. package/dist/three/grid-node.js +36 -1
  233. package/dist/three/grid-node.js.map +1 -1
  234. package/dist/three/index.d.ts +20 -11
  235. package/dist/three/index.js +21 -12
  236. package/dist/three/index.js.map +1 -1
  237. package/dist/three/internal.d.ts +14 -8
  238. package/dist/three/internal.js +11 -7
  239. package/dist/three/internal.js.map +1 -1
  240. package/dist/three/level-set-material.d.ts +81 -8
  241. package/dist/three/level-set-material.js +162 -125
  242. package/dist/three/level-set-material.js.map +1 -1
  243. package/dist/three/level-set-physical-material.d.ts +154 -0
  244. package/dist/three/level-set-physical-material.js +253 -0
  245. package/dist/three/level-set-physical-material.js.map +1 -0
  246. package/dist/three/level-set-velocity.d.ts +94 -0
  247. package/dist/three/level-set-velocity.js +208 -0
  248. package/dist/three/level-set-velocity.js.map +1 -0
  249. package/dist/three/material.d.ts +141 -11
  250. package/dist/three/material.js +161 -18
  251. package/dist/three/material.js.map +1 -1
  252. package/dist/three/points.d.ts +60 -4
  253. package/dist/three/points.js +140 -9
  254. package/dist/three/points.js.map +1 -1
  255. package/dist/three/sparse-source.d.ts +49 -117
  256. package/dist/three/sparse-source.js +109 -580
  257. package/dist/three/sparse-source.js.map +1 -1
  258. package/dist/three/volume-source.d.ts +11 -156
  259. package/dist/three/volume-source.js +29 -272
  260. package/dist/three/volume-source.js.map +1 -1
  261. package/dist/tools/cpu/brick-atlas.d.ts +36 -0
  262. package/dist/tools/cpu/brick-atlas.js +129 -0
  263. package/dist/tools/cpu/brick-atlas.js.map +1 -0
  264. package/dist/tools/cpu/compute.d.ts +23 -4
  265. package/dist/tools/cpu/compute.js +35 -14
  266. package/dist/tools/cpu/compute.js.map +1 -1
  267. package/dist/tools/cpu/lean-reads.d.ts +81 -0
  268. package/dist/tools/cpu/lean-reads.js +262 -0
  269. package/dist/tools/cpu/lean-reads.js.map +1 -0
  270. package/dist/tools/cpu/level-set.d.ts +42 -3
  271. package/dist/tools/cpu/level-set.js +59 -7
  272. package/dist/tools/cpu/level-set.js.map +1 -1
  273. package/dist/tools/cpu/majorant.d.ts +265 -0
  274. package/dist/tools/cpu/majorant.js +541 -0
  275. package/dist/tools/cpu/majorant.js.map +1 -0
  276. package/dist/tools/cpu/march.d.ts +93 -2
  277. package/dist/tools/cpu/march.js +165 -14
  278. package/dist/tools/cpu/march.js.map +1 -1
  279. package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
  280. package/dist/tools/cpu/mesh-decimate.js +1225 -0
  281. package/dist/tools/cpu/mesh-decimate.js.map +1 -0
  282. package/dist/tools/cpu/points.d.ts +29 -0
  283. package/dist/tools/cpu/points.js +38 -0
  284. package/dist/tools/cpu/points.js.map +1 -0
  285. package/dist/tools/cpu/read-value.d.ts +19 -6
  286. package/dist/tools/cpu/read-value.js +32 -17
  287. package/dist/tools/cpu/read-value.js.map +1 -1
  288. package/dist/tools/cpu/sample-trilinear.d.ts +17 -4
  289. package/dist/tools/cpu/sample-trilinear.js +19 -7
  290. package/dist/tools/cpu/sample-trilinear.js.map +1 -1
  291. package/dist/tools/cpu/stride-tables.d.ts +2 -2
  292. package/dist/tools/cpu/stride-tables.generated.d.ts +6 -5
  293. package/dist/tools/cpu/stride-tables.generated.js +7 -6
  294. package/dist/tools/cpu/stride-tables.generated.js.map +1 -1
  295. package/dist/tools/cpu/stride-tables.js +1 -1
  296. package/dist/tools/cpu/stride-tables.js.map +1 -1
  297. package/dist/tools/cpu/surface-nets.d.ts +90 -0
  298. package/dist/tools/cpu/surface-nets.js +597 -0
  299. package/dist/tools/cpu/surface-nets.js.map +1 -0
  300. package/dist/tools/errors.d.ts +9 -0
  301. package/dist/tools/errors.js +9 -0
  302. package/dist/tools/errors.js.map +1 -1
  303. package/dist/tools/frame/ambient.d.ts +98 -0
  304. package/dist/tools/frame/ambient.js +274 -0
  305. package/dist/tools/frame/ambient.js.map +1 -0
  306. package/dist/tools/frame/blackbody.d.ts +15 -0
  307. package/dist/tools/frame/blackbody.js +35 -0
  308. package/dist/tools/frame/blackbody.js.map +1 -1
  309. package/dist/tools/frame/brick-cache.d.ts +165 -0
  310. package/dist/tools/frame/brick-cache.js +326 -0
  311. package/dist/tools/frame/brick-cache.js.map +1 -0
  312. package/dist/tools/frame/emission.d.ts +9 -0
  313. package/dist/tools/frame/emission.js +9 -1
  314. package/dist/tools/frame/emission.js.map +1 -1
  315. package/dist/tools/frame/environment-gpu.d.ts +111 -0
  316. package/dist/tools/frame/environment-gpu.js +280 -0
  317. package/dist/tools/frame/environment-gpu.js.map +1 -0
  318. package/dist/tools/frame/environment.d.ts +3 -2
  319. package/dist/tools/frame/environment.js +8 -4
  320. package/dist/tools/frame/environment.js.map +1 -1
  321. package/dist/tools/frame/froxel.d.ts +58 -0
  322. package/dist/tools/frame/froxel.js +115 -0
  323. package/dist/tools/frame/froxel.js.map +1 -0
  324. package/dist/tools/frame/grid.d.ts +90 -0
  325. package/dist/tools/frame/grid.js +112 -13
  326. package/dist/tools/frame/grid.js.map +1 -1
  327. package/dist/tools/frame/index.d.ts +14 -0
  328. package/dist/tools/frame/index.js +45 -4
  329. package/dist/tools/frame/index.js.map +1 -1
  330. package/dist/tools/frame/medium.d.ts +16 -0
  331. package/dist/tools/frame/medium.js +3 -1
  332. package/dist/tools/frame/medium.js.map +1 -1
  333. package/dist/tools/frame/mie.d.ts +9 -0
  334. package/dist/tools/frame/mie.js +18 -0
  335. package/dist/tools/frame/mie.js.map +1 -1
  336. package/dist/tools/frame/mlp-nn.d.ts +36 -0
  337. package/dist/tools/frame/mlp-nn.js +159 -0
  338. package/dist/tools/frame/mlp-nn.js.map +1 -0
  339. package/dist/tools/frame/mlp-tza.d.ts +29 -0
  340. package/dist/tools/frame/mlp-tza.js +186 -0
  341. package/dist/tools/frame/mlp-tza.js.map +1 -0
  342. package/dist/tools/frame/mlp.d.ts +183 -0
  343. package/dist/tools/frame/mlp.js +434 -0
  344. package/dist/tools/frame/mlp.js.map +1 -0
  345. package/dist/tools/frame/ms-exit.d.ts +42 -0
  346. package/dist/tools/frame/ms-exit.js +90 -0
  347. package/dist/tools/frame/ms-exit.js.map +1 -0
  348. package/dist/tools/frame/multi-scale.d.ts +152 -0
  349. package/dist/tools/frame/multi-scale.js +302 -0
  350. package/dist/tools/frame/multi-scale.js.map +1 -0
  351. package/dist/tools/frame/neural-weights.d.ts +6 -5
  352. package/dist/tools/frame/neural-weights.js +234 -235
  353. package/dist/tools/frame/neural-weights.js.map +1 -1
  354. package/dist/tools/frame/neural.js +1 -1
  355. package/dist/tools/frame/neural.js.map +1 -1
  356. package/dist/tools/frame/occluders.d.ts +51 -0
  357. package/dist/tools/frame/occluders.js +72 -0
  358. package/dist/tools/frame/occluders.js.map +1 -0
  359. package/dist/tools/frame/pyramid-layout.d.ts +17 -0
  360. package/dist/tools/frame/pyramid-layout.js +47 -0
  361. package/dist/tools/frame/pyramid-layout.js.map +1 -1
  362. package/dist/tools/frame/shadows.d.ts +110 -0
  363. package/dist/tools/frame/shadows.js +286 -0
  364. package/dist/tools/frame/shadows.js.map +1 -1
  365. package/dist/tools/frame/sparse.d.ts +82 -0
  366. package/dist/tools/frame/sparse.js +242 -1
  367. package/dist/tools/frame/sparse.js.map +1 -1
  368. package/dist/tools/frame/spectral-stack.d.ts +159 -0
  369. package/dist/tools/frame/spectral-stack.js +391 -0
  370. package/dist/tools/frame/spectral-stack.js.map +1 -0
  371. package/dist/tools/frame/spectral.d.ts +21 -2
  372. package/dist/tools/frame/spectral.js +30 -8
  373. package/dist/tools/frame/spectral.js.map +1 -1
  374. package/dist/tools/frame/stack.d.ts +115 -0
  375. package/dist/tools/frame/stack.js +290 -0
  376. package/dist/tools/frame/stack.js.map +1 -0
  377. package/dist/tools/frame/view.d.ts +131 -0
  378. package/dist/tools/frame/view.js +337 -0
  379. package/dist/tools/frame/view.js.map +1 -0
  380. package/dist/tools/index.d.ts +66 -15
  381. package/dist/tools/index.js +55 -11
  382. package/dist/tools/index.js.map +1 -1
  383. package/dist/tools/internal.d.ts +58 -17
  384. package/dist/tools/internal.js +65 -11
  385. package/dist/tools/internal.js.map +1 -1
  386. package/dist/tools/nanovdb/build-from-vdb.d.ts +11 -2
  387. package/dist/tools/nanovdb/build-from-vdb.js +10 -2
  388. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -1
  389. package/dist/tools/nanovdb/bytes.d.ts +17 -4
  390. package/dist/tools/nanovdb/bytes.js +46 -3
  391. package/dist/tools/nanovdb/bytes.js.map +1 -1
  392. package/dist/tools/nanovdb/coarse-first.d.ts +19 -3
  393. package/dist/tools/nanovdb/coarse-first.js +7 -1
  394. package/dist/tools/nanovdb/coarse-first.js.map +1 -1
  395. package/dist/tools/nanovdb/half.d.ts +22 -0
  396. package/dist/tools/nanovdb/half.js +73 -0
  397. package/dist/tools/nanovdb/half.js.map +1 -0
  398. package/dist/tools/nanovdb/index.d.ts +3 -1
  399. package/dist/tools/nanovdb/index.js +2 -1
  400. package/dist/tools/nanovdb/index.js.map +1 -1
  401. package/dist/tools/nanovdb/inspect.d.ts +10 -1
  402. package/dist/tools/nanovdb/inspect.js +8 -1
  403. package/dist/tools/nanovdb/inspect.js.map +1 -1
  404. package/dist/tools/nanovdb/leaf-codec.d.ts +35 -1
  405. package/dist/tools/nanovdb/leaf-codec.js +40 -4
  406. package/dist/tools/nanovdb/leaf-codec.js.map +1 -1
  407. package/dist/tools/nanovdb/quantize.d.ts +39 -10
  408. package/dist/tools/nanovdb/quantize.js +96 -44
  409. package/dist/tools/nanovdb/quantize.js.map +1 -1
  410. package/dist/tools/nanovdb/resample.d.ts +20 -3
  411. package/dist/tools/nanovdb/resample.js +20 -7
  412. package/dist/tools/nanovdb/resample.js.map +1 -1
  413. package/dist/tools/nanovdb/serialize.d.ts +34 -3
  414. package/dist/tools/nanovdb/serialize.js +51 -7
  415. package/dist/tools/nanovdb/serialize.js.map +1 -1
  416. package/dist/tools/nanovdb/stats.d.ts +34 -5
  417. package/dist/tools/nanovdb/stats.js +87 -11
  418. package/dist/tools/nanovdb/stats.js.map +1 -1
  419. package/dist/tools/nanovdb/transform.d.ts +4 -0
  420. package/dist/tools/nanovdb/transform.js +3 -0
  421. package/dist/tools/nanovdb/transform.js.map +1 -1
  422. package/dist/tools/nanovdb/tree.d.ts +14 -3
  423. package/dist/tools/nanovdb/tree.js +25 -13
  424. package/dist/tools/nanovdb/tree.js.map +1 -1
  425. package/dist/tools/nanovdb/write-nvdb.d.ts +47 -12
  426. package/dist/tools/nanovdb/write-nvdb.js +108 -28
  427. package/dist/tools/nanovdb/write-nvdb.js.map +1 -1
  428. package/dist/tools/nvdb-file.d.ts +77 -7
  429. package/dist/tools/nvdb-file.js +177 -20
  430. package/dist/tools/nvdb-file.js.map +1 -1
  431. package/dist/tools/nvdb-stream.d.ts +23 -7
  432. package/dist/tools/nvdb-stream.js +78 -34
  433. package/dist/tools/nvdb-stream.js.map +1 -1
  434. package/dist/tools/reference/analytic.d.ts +41 -0
  435. package/dist/tools/reference/analytic.js +95 -0
  436. package/dist/tools/reference/analytic.js.map +1 -0
  437. package/dist/tools/reference/environment.d.ts +62 -0
  438. package/dist/tools/reference/environment.js +154 -0
  439. package/dist/tools/reference/environment.js.map +1 -0
  440. package/dist/tools/reference/index.d.ts +12 -0
  441. package/dist/tools/reference/index.js +13 -0
  442. package/dist/tools/reference/index.js.map +1 -0
  443. package/dist/tools/reference/media.d.ts +14 -0
  444. package/dist/tools/reference/media.js +30 -0
  445. package/dist/tools/reference/media.js.map +1 -0
  446. package/dist/tools/reference/rng.d.ts +20 -0
  447. package/dist/tools/reference/rng.js +30 -0
  448. package/dist/tools/reference/rng.js.map +1 -0
  449. package/dist/tools/reference/scene.d.ts +312 -0
  450. package/dist/tools/reference/scene.js +169 -0
  451. package/dist/tools/reference/scene.js.map +1 -0
  452. package/dist/tools/reference/tables.d.ts +98 -0
  453. package/dist/tools/reference/tables.js +264 -0
  454. package/dist/tools/reference/tables.js.map +1 -0
  455. package/dist/tools/reference/trace.d.ts +160 -0
  456. package/dist/tools/reference/trace.js +497 -0
  457. package/dist/tools/reference/trace.js.map +1 -0
  458. package/dist/tools/vdb/blosc-write.d.ts +43 -0
  459. package/dist/tools/vdb/blosc-write.js +197 -0
  460. package/dist/tools/vdb/blosc-write.js.map +1 -0
  461. package/dist/tools/vdb/blosc.d.ts +35 -5
  462. package/dist/tools/vdb/blosc.js +82 -26
  463. package/dist/tools/vdb/blosc.js.map +1 -1
  464. package/dist/tools/vdb/blosclz.d.ts +33 -0
  465. package/dist/tools/vdb/blosclz.js +112 -0
  466. package/dist/tools/vdb/blosclz.js.map +1 -0
  467. package/dist/tools/vdb/byte-reader.d.ts +13 -3
  468. package/dist/tools/vdb/byte-reader.js +26 -4
  469. package/dist/tools/vdb/byte-reader.js.map +1 -1
  470. package/dist/tools/vdb/compression.d.ts +13 -5
  471. package/dist/tools/vdb/compression.js +13 -2
  472. package/dist/tools/vdb/compression.js.map +1 -1
  473. package/dist/tools/vdb/grid.js +8 -2
  474. package/dist/tools/vdb/grid.js.map +1 -1
  475. package/dist/tools/vdb/index.d.ts +2 -1
  476. package/dist/tools/vdb/index.js.map +1 -1
  477. package/dist/tools/vdb/lz4.d.ts +30 -0
  478. package/dist/tools/vdb/lz4.js +228 -0
  479. package/dist/tools/vdb/lz4.js.map +1 -0
  480. package/dist/tools/vdb/metadata.js +1 -1
  481. package/dist/tools/vdb/metadata.js.map +1 -1
  482. package/dist/tools/vdb/parse.d.ts +24 -2
  483. package/dist/tools/vdb/parse.js +102 -32
  484. package/dist/tools/vdb/parse.js.map +1 -1
  485. package/dist/tools/vdb/point-render-data.d.ts +49 -1
  486. package/dist/tools/vdb/point-render-data.js +91 -11
  487. package/dist/tools/vdb/point-render-data.js.map +1 -1
  488. package/dist/tools/vdb/points.d.ts +26 -0
  489. package/dist/tools/vdb/points.js +46 -5
  490. package/dist/tools/vdb/points.js.map +1 -1
  491. package/dist/tools/vdb/types.d.ts +59 -2
  492. package/dist/tools/vdb/types.js.map +1 -1
  493. package/dist/tools/wvdb/bake.d.ts +38 -9
  494. package/dist/tools/wvdb/bake.js +63 -13
  495. package/dist/tools/wvdb/bake.js.map +1 -1
  496. package/dist/tools/wvdb/dense.d.ts +80 -1
  497. package/dist/tools/wvdb/dense.js +67 -8
  498. package/dist/tools/wvdb/dense.js.map +1 -1
  499. package/dist/tools/wvdb/format.d.ts +59 -0
  500. package/dist/tools/wvdb/format.js +3 -0
  501. package/dist/tools/wvdb/format.js.map +1 -1
  502. package/dist/tools/wvdb/index.d.ts +1 -0
  503. package/dist/tools/wvdb/index.js +1 -0
  504. package/dist/tools/wvdb/index.js.map +1 -1
  505. package/dist/tools/wvdb/level-set.d.ts +10 -2
  506. package/dist/tools/wvdb/level-set.js.map +1 -1
  507. package/dist/tools/wvdb/nanovdb.d.ts +6 -1
  508. package/dist/tools/wvdb/nanovdb.js +5 -1
  509. package/dist/tools/wvdb/nanovdb.js.map +1 -1
  510. package/dist/tools/wvdb/partial.d.ts +74 -0
  511. package/dist/tools/wvdb/partial.js +233 -0
  512. package/dist/tools/wvdb/partial.js.map +1 -0
  513. package/dist/tools/wvdb/read.d.ts +77 -1
  514. package/dist/tools/wvdb/read.js +30 -7
  515. package/dist/tools/wvdb/read.js.map +1 -1
  516. package/dist/tools/wvdb/write.d.ts +23 -1
  517. package/dist/tools/wvdb/write.js +8 -1
  518. package/dist/tools/wvdb/write.js.map +1 -1
  519. package/package.json +2 -1
  520. package/vendor/VENDOR.md +21 -6
  521. package/vendor/pnanovdb.wgsl +52 -14
  522. package/dist/three/frame/blackbody.d.ts +0 -42
  523. package/dist/three/frame/blackbody.js +0 -74
  524. package/dist/three/frame/blackbody.js.map +0 -1
  525. package/dist/three/frame/chunks.d.ts +0 -157
  526. package/dist/three/frame/chunks.js +0 -559
  527. package/dist/three/frame/chunks.js.map +0 -1
  528. package/dist/three/frame/density-material.d.ts +0 -53
  529. package/dist/three/frame/density-material.js +0 -353
  530. package/dist/three/frame/density-material.js.map +0 -1
  531. package/dist/three/frame/environment-grid-material.d.ts +0 -21
  532. package/dist/three/frame/environment-grid-material.js +0 -184
  533. package/dist/three/frame/environment-grid-material.js.map +0 -1
  534. package/dist/three/frame/environment-material.d.ts +0 -22
  535. package/dist/three/frame/environment-material.js +0 -87
  536. package/dist/three/frame/environment-material.js.map +0 -1
  537. package/dist/three/frame/grid-mip-material.d.ts +0 -12
  538. package/dist/three/frame/grid-mip-material.js +0 -61
  539. package/dist/three/frame/grid-mip-material.js.map +0 -1
  540. package/dist/three/frame/inject-material.d.ts +0 -56
  541. package/dist/three/frame/inject-material.js +0 -424
  542. package/dist/three/frame/inject-material.js.map +0 -1
  543. package/dist/three/frame/integrate-material.d.ts +0 -26
  544. package/dist/three/frame/integrate-material.js +0 -198
  545. package/dist/three/frame/integrate-material.js.map +0 -1
  546. package/dist/three/frame/layout.d.ts +0 -34
  547. package/dist/three/frame/layout.js +0 -48
  548. package/dist/three/frame/layout.js.map +0 -1
  549. package/dist/three/frame/lighting-material.d.ts +0 -41
  550. package/dist/three/frame/lighting-material.js +0 -257
  551. package/dist/three/frame/lighting-material.js.map +0 -1
  552. package/dist/three/frame/lights.d.ts +0 -11
  553. package/dist/three/frame/lights.js +0 -16
  554. package/dist/three/frame/lights.js.map +0 -1
  555. package/dist/three/frame/neural.d.ts +0 -14
  556. package/dist/three/frame/neural.js +0 -105
  557. package/dist/three/frame/neural.js.map +0 -1
  558. package/dist/three/frame/phase.d.ts +0 -44
  559. package/dist/three/frame/phase.js +0 -80
  560. package/dist/three/frame/phase.js.map +0 -1
  561. package/dist/three/frame/shadow-density-material.d.ts +0 -30
  562. package/dist/three/frame/shadow-density-material.js +0 -123
  563. package/dist/three/frame/shadow-density-material.js.map +0 -1
  564. package/dist/three/frame/temporal-material.d.ts +0 -29
  565. package/dist/three/frame/temporal-material.js +0 -152
  566. package/dist/three/frame/temporal-material.js.map +0 -1
  567. package/dist/three/frame/transmittance-material.d.ts +0 -31
  568. package/dist/three/frame/transmittance-material.js +0 -315
  569. package/dist/three/frame/transmittance-material.js.map +0 -1
  570. package/dist/three/frame/view.d.ts +0 -103
  571. package/dist/three/frame/view.js +0 -296
  572. package/dist/three/frame/view.js.map +0 -1
  573. package/dist/three/frame/volume-shadow-material.d.ts +0 -36
  574. package/dist/three/frame/volume-shadow-material.js +0 -128
  575. package/dist/three/frame/volume-shadow-material.js.map +0 -1
  576. package/dist/three/sequence.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"atlas.js","sourceRoot":"","sources":["../../../src/core/compute/atlas.ts"],"names":[],"mappings":"AAkCA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,UAAU,EACV,KAAK,EACL,UAAU,EACV,cAAc,GAGf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAA4C,MAAM,4BAA4B,CAAC;AAIzH,MAAM,CAAC,GAAG,cAAc,CAAC;AAEzB,MAAM,KAAK,GAAiB;IAC1B,UAAU,EAAE,SAAS;IACrB,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,UAAU,CAAC;;;2BAGM,CAAC,KAAK,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;CAmBvC;CACA,CAAC;AAyCF,MAAM,KAAK,GAAG,eAAe,CAAC;AAE9B,SAAS,iBAAiB,CAAC,CAA0B;IACnD,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;IACnD,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QACjF,MAAM,IAAI,QAAQ,CAAC,gBAAgB,EAAE,GAAG,KAAK,kDAAkD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC9H,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,IAAI,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AO,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACxE,IAAI,CAAC,MAAM,EAAE,CAAC;IAEd,MAAM,MAAM,GAAG,CAAC,GAAgB,EAAY,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACrJ,OAAO,IAAI,QAAQ,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;AAC1G,CAAC;AAED,MAAM,QAAS,SAAQ,UAAoB;IAM9B;IACA;IACA;IAPX,YACE,KAAkB,EAClB,OAAyB,EACzB,KAA+B,EAC/B,MAAwC,EAC/B,IAA8B,EAC9B,KAAmC,EACnC,MAAiB,EAC1B,aAAsB;QAEtB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;QALlD,SAAI,GAAJ,IAAI,CAA0B;QAC9B,UAAK,GAAL,KAAK,CAA8B;QACnC,WAAM,GAAN,MAAM,CAAW;IAI5B,CAAC;CACF","sourcesContent":["/**\n * `decodeToAtlas`: dense decode of one pool grid's index bbox into a flat f32\n * array (x fastest), recorded into the host's encoder (K2.3, ported from v1\n * `three/compute.ts`). CPU twin: `vdbDecodeToAtlasCpu` + `atlasFromRaw` in\n * `@pmndrs/vdb/tools`.\n *\n * One thread per output voxel samples the index bbox at the voxel-centre\n * position of its cell (below) with `vdbReadValue(floor(p + 0.5))`\n * (`'nearest'`) or `vdbSample` (`'trilinear'`, the vendored trilinear,\n * `outside: 'background'`).\n *\n * **Sampling convention (K2.6; voxel centres).** NanoVDB voxel centres sit at\n * integer index coordinates, and the bbox `[min, max]` (inclusive) holds\n * `size = max - min + 1` voxels, i.e. the cells `[min - 0.5, max + 0.5]`.\n * Cell `i` of an axis with `n` cells over `[min, max]` samples the index-space\n * position\n *\n * p = min + (i + 0.5) * (max - min + 1) / n - 0.5\n *\n * (the centre of the i-th of `n` equal slices of `[min - 0.5, max + 0.5]`).\n * At full resolution (`n == size`) that is `p = min + i`: `'nearest'` reads\n * exactly voxel `min + i` (the last cell is voxel `max`) and `'trilinear'`\n * reads that voxel's value unblended. Downsampled, each cell samples the\n * centre of its slice. The atlas is a texture over the voxel-centred box\n * `[min - 0.5, max + 0.5]`: texel `i`'s centre `(i + 0.5) / n` maps to `p`\n * above. (Before K2.6 this was v1's `min + (i + 0.5) / n * size`, half a voxel\n * past the centres.) The GPU writes raw f32; normalizing and quantizing to\n * `uint8` happen on the CPU after readback, as in v1.\n *\n * The raw buffer is also the GPU-side output: with `readback: false` the\n * host keeps `buffer` (`STORAGE | COPY_SRC`, `dims` product f32s) for its own\n * passes and calls `dispose()` when done.\n */\nimport type { VDBGridPool } from \"../pool/pool.js\";\nimport { VDBError } from \"../errors.js\";\nimport {\n checkPositiveInt,\n checkTarget,\n ComputeJob,\n createInitialized,\n hostEncoder,\n kernelPipeline,\n packParams,\n USAGE,\n workgroups,\n WORKGROUP_AXIS,\n type KernelSource,\n type VDBReadback,\n} from \"./shared.js\";\nimport { atlasDims, atlasFromRaw, bboxSize, type VDBAtlasFilter, type VDBAtlasFormat } from \"../../tools/cpu/compute.js\";\n\nexport type { VDBAtlasFilter, VDBAtlasFormat };\n\nconst W = WORKGROUP_AXIS;\n\nconst ATLAS: KernelSource = {\n entryPoint: \"csAtlas\",\n outputs: 1,\n footer: /* wgsl */ `\n@group(1) @binding(0) var<storage, read_write> csAtlasOut: array<f32>;\n\n@compute @workgroup_size(${W}, ${W}, ${W})\nfn csAtlas(@builtin(global_invocation_id) gid: vec3u) {\n let dims = csParams.dims;\n if any(gid >= dims) {\n return;\n }\n // Voxel-centre position: min + (i + 0.5) * size / dims - 0.5. Multiply\n // before dividing and subtract the half voxel before adding min, so at\n // full resolution the offset is exactly i (the CPU twin does the same).\n let pos = vec3f(csParams.regionMin) + ((vec3f(gid) + vec3f(0.5)) * vec3f(csParams.regionSize) / vec3f(dims) - vec3f(0.5));\n var acc = vdbAccessorInit(csParams.grid);\n var value: f32;\n if csParams.filterMode == 1u {\n value = vdbSample(&acc, pos);\n } else {\n value = vdbReadValue(&acc, vec3i(floor(pos + vec3f(0.5))));\n }\n csAtlasOut[gid.x + gid.y * dims.x + gid.z * dims.x * dims.y] = value;\n}\n`,\n};\n\n/** Options of {@link vdbDecodeToAtlasGpu} (v1's, plus `encoder` and `readback`). */\nexport interface VDBDecodeToAtlasOptions {\n /** Per-axis output resolution cap (a literal clamp, not a proportional downscale). Default 256. */\n maxDim?: number;\n /** Default `'trilinear'`. */\n filter?: VDBAtlasFilter;\n /** Element type of `read()`'s `data`. Default `'uint8'`. */\n format?: VDBAtlasFormat;\n /** Map `range` to `[0, 1]` (`float32`) or `[0, 255]` (`uint8`) in `read()`. Default `true`. */\n normalize?: boolean;\n /** Normalization range. Default: the grid's root min/max statistics (`pool.info(id).rootMin/rootMax`). */\n range?: { min: number; max: number };\n /**\n * Record into this encoder. The host submits it, then calls\n * `job.submitted().read()` (`read()` before `submitted()` rejects with\n * `VDB_BAD_OPTION`). Omitted: the tool submits its own.\n */\n encoder?: GPUCommandEncoder;\n /** `false`: no readback; keep `buffer` for GPU use and `dispose()` it. Default `true`. */\n readback?: boolean;\n}\n\n/** What `read()` resolves with (v1's `DecodeToAtlasResult`). */\nexport interface VDBAtlas {\n /** `dims` product values, x fastest. */\n data: Uint8Array | Float32Array;\n dims: [number, number, number];\n /** The range used for normalization (echoed so the caller can undo it). */\n range: { min: number; max: number };\n}\n\n/** The pending atlas: a {@link VDBReadback} plus the GPU output. */\nexport interface VDBAtlasReadback extends VDBReadback<VDBAtlas> {\n readonly dims: [number, number, number];\n readonly range: { min: number; max: number };\n /** Raw f32 values on the GPU (`STORAGE | COPY_SRC`); freed by `read()` / `dispose()`. */\n readonly buffer: GPUBuffer;\n}\n\nconst WHERE = \"decodeToAtlas\";\n\nfunction checkAtlasOptions(o: VDBDecodeToAtlasOptions): void {\n checkPositiveInt(WHERE, \"maxDim\", o.maxDim ?? 256);\n if (o.filter !== undefined && o.filter !== \"nearest\" && o.filter !== \"trilinear\") {\n throw new VDBError(\"VDB_BAD_OPTION\", `${WHERE}: filter must be \"nearest\" or \"trilinear\", got ${JSON.stringify(o.filter)}.`);\n }\n if (o.format !== undefined && o.format !== \"uint8\" && o.format !== \"float32\") {\n throw new VDBError(\"VDB_BAD_OPTION\", `${WHERE}: format must be \"uint8\" or \"float32\", got ${JSON.stringify(o.format)}.`);\n }\n if (o.range !== undefined && !(Number.isFinite(o.range?.min) && Number.isFinite(o.range?.max))) {\n throw new VDBError(\"VDB_BAD_OPTION\", `${WHERE}: range must be { min, max } with finite numbers, got ${JSON.stringify(o.range)}.`);\n }\n}\n\n/**\n * Records the decode of grid `gridId` of `pool` and returns a\n * {@link VDBAtlasReadback}: `const { data, dims } = await decodeToAtlas(device, pool, id).read()`\n * (with a host encoder: submit it, then `await job.submitted().read()`).\n * Cell `i` samples index position `min + (i + 0.5) * size / n - 0.5`, voxel\n * centres at full resolution (see the file comment).\n *\n * The grid must be resident and the pool must live on `device` (as for\n * `gridStats`). The tool frees only its own parameter, output and readback\n * buffers.\n */\nexport function vdbDecodeToAtlasGpu(device: GPUDevice, pool: VDBGridPool, gridId: number, options: VDBDecodeToAtlasOptions = {}): VDBAtlasReadback {\n checkAtlasOptions(options);\n const info = checkTarget(WHERE, device, pool, gridId);\n const maxDim = options.maxDim ?? 256;\n const filter = options.filter ?? \"trilinear\";\n const format = options.format ?? \"uint8\";\n const normalize = options.normalize ?? true;\n const range = options.range ? { min: options.range.min, max: options.range.max } : normalize ? { min: info.rootMin, max: info.rootMax } : { min: 0, max: 1 };\n const regionSize = bboxSize(info.indexBBox);\n const dims = atlasDims(info.indexBBox, maxDim);\n const cached = kernelPipeline(device, ATLAS, info.type);\n\n const params = createInitialized(\n device,\n \"vdb decodeToAtlas params\",\n USAGE.UNIFORM,\n new Uint8Array(packParams({ grid: gridId, filter: filter === \"trilinear\" ? 1 : 0, regionMin: info.indexBBox.min, regionSize, dims })),\n );\n const bytes = dims[0] * dims[1] * dims[2] * 4;\n const out = device.createBuffer({ label: \"vdb decodeToAtlas\", size: bytes, usage: USAGE.STORAGE | USAGE.COPY_SRC });\n const readback = options.readback ?? true;\n const staging = readback ? device.createBuffer({ label: \"vdb decodeToAtlas readback\", size: bytes, usage: USAGE.MAP_READ | USAGE.COPY_DST }) : null;\n\n const group0 = device.createBindGroup({ layout: cached.group0, entries: [pool.bindGroupEntry({ group: 0, firstBinding: 0 }), { binding: 1, resource: { buffer: params } }] });\n const group1 = device.createBindGroup({ layout: cached.group1, entries: [{ binding: 0, resource: { buffer: out } }] });\n\n const host = hostEncoder(device, options.encoder, \"vdb decodeToAtlas\");\n const pass = host.encoder.beginComputePass({ label: \"vdb decodeToAtlas\" });\n pass.setPipeline(cached.pipeline);\n pass.setBindGroup(0, group0);\n pass.setBindGroup(1, group1);\n pass.dispatchWorkgroups(...workgroups(dims));\n pass.end();\n if (staging) host.encoder.copyBufferToBuffer(out, 0, staging, 0, bytes);\n host.submit();\n\n const finish = (raw: ArrayBuffer): VDBAtlas => ({ data: atlasFromRaw(new Float32Array(raw), { format, normalize, range }), dims: [...dims], range });\n return new AtlasJob([params, out], staging, cached.error, finish, dims, range, out, host.selfSubmitted);\n}\n\nclass AtlasJob extends ComputeJob<VDBAtlas> implements VDBAtlasReadback {\n constructor(\n owned: GPUBuffer[],\n staging: GPUBuffer | null,\n error: Promise<GPUError | null>,\n finish: (bytes: ArrayBuffer) => VDBAtlas,\n readonly dims: [number, number, number],\n readonly range: { min: number; max: number },\n readonly buffer: GPUBuffer,\n selfSubmitted: boolean,\n ) {\n super(WHERE, owned, staging, error, finish, selfSubmitted);\n }\n}\n"]}
1
+ {"version":3,"file":"atlas.js","sourceRoot":"","sources":["../../../src/core/compute/atlas.ts"],"names":[],"mappings":"AAkCA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,UAAU,EACV,KAAK,EACL,UAAU,EACV,cAAc,GAGf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAA4C,MAAM,4BAA4B,CAAC;AAIzH,MAAM,CAAC,GAAG,cAAc,CAAC;AAEzB,MAAM,KAAK,GAAiB;IAC1B,UAAU,EAAE,SAAS;IACrB,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,UAAU,CAAC;;;2BAGM,CAAC,KAAK,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;CAmBvC;CACA,CAAC;AA4CF,MAAM,KAAK,GAAG,eAAe,CAAC;AAE9B,SAAS,iBAAiB,CAAC,CAA0B;IACnD,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;IACnD,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QACjF,MAAM,IAAI,QAAQ,CAAC,gBAAgB,EAAE,GAAG,KAAK,kDAAkD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC9H,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC7E,MAAM,IAAI,QAAQ,CAAC,gBAAgB,EAAE,GAAG,K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AAC,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACrJ,OAAO,IAAI,QAAQ,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;AAC1G,CAAC;AAED,MAAM,QAAS,SAAQ,UAAoB;IAM9B;IACA;IACA;IAPX,YACE,KAAkB,EAClB,OAAyB,EACzB,KAA+B,EAC/B,MAAwC,EAC/B,IAA8B,EAC9B,KAAmC,EACnC,MAAiB,EAC1B,aAAsB;QAEtB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;QALlD,SAAI,GAAJ,IAAI,CAA0B;QAC9B,UAAK,GAAL,KAAK,CAA8B;QACnC,WAAM,GAAN,MAAM,CAAW;IAI5B,CAAC;CACF","sourcesContent":["/**\n * `decodeToAtlas`: dense decode of one pool grid's index bbox into a flat f32\n * array (x fastest), recorded into the host's encoder (K2.3, ported from v1\n * `three/compute.ts`). CPU twin: `vdbDecodeToAtlasCpu` + `atlasFromRaw` in\n * `@pmndrs/vdb/tools`.\n *\n * One thread per output voxel samples the index bbox at the voxel-centre\n * position of its cell (below) with `vdbReadValue(floor(p + 0.5))`\n * (`'nearest'`) or `vdbSample` (`'trilinear'`, the vendored trilinear,\n * `outside: 'background'`).\n *\n * **Sampling convention (K2.6; voxel centres).** NanoVDB voxel centres sit at\n * integer index coordinates, and the bbox `[min, max]` (inclusive) holds\n * `size = max - min + 1` voxels, i.e. the cells `[min - 0.5, max + 0.5]`.\n * Cell `i` of an axis with `n` cells over `[min, max]` samples the index-space\n * position\n *\n * p = min + (i + 0.5) * (max - min + 1) / n - 0.5\n *\n * (the centre of the i-th of `n` equal slices of `[min - 0.5, max + 0.5]`).\n * At full resolution (`n == size`) that is `p = min + i`: `'nearest'` reads\n * exactly voxel `min + i` (the last cell is voxel `max`) and `'trilinear'`\n * reads that voxel's value unblended. Downsampled, each cell samples the\n * centre of its slice. The atlas is a texture over the voxel-centred box\n * `[min - 0.5, max + 0.5]`: texel `i`'s centre `(i + 0.5) / n` maps to `p`\n * above. (Before K2.6 this was v1's `min + (i + 0.5) / n * size`, half a voxel\n * past the centres.) The GPU writes raw f32; normalizing and quantizing to\n * `uint8` happen on the CPU after readback, as in v1.\n *\n * The raw buffer is also the GPU-side output: with `readback: false` the\n * host keeps `buffer` (`STORAGE | COPY_SRC`, `dims` product f32s) for its own\n * passes and calls `dispose()` when done.\n */\nimport type { VDBGridPool } from \"../pool/pool.js\";\nimport { VDBError } from \"../errors.js\";\nimport {\n checkPositiveInt,\n checkTarget,\n ComputeJob,\n createInitialized,\n hostEncoder,\n kernelPipeline,\n packParams,\n USAGE,\n workgroups,\n WORKGROUP_AXIS,\n type KernelSource,\n type VDBReadback,\n} from \"./shared.js\";\nimport { atlasDims, atlasFromRaw, bboxSize, type VDBAtlasFilter, type VDBAtlasFormat } from \"../../tools/cpu/compute.js\";\n\nexport type { VDBAtlasFilter, VDBAtlasFormat };\n\nconst W = WORKGROUP_AXIS;\n\nconst ATLAS: KernelSource = {\n entryPoint: \"csAtlas\",\n outputs: 1,\n footer: /* wgsl */ `\n@group(1) @binding(0) var<storage, read_write> csAtlasOut: array<f32>;\n\n@compute @workgroup_size(${W}, ${W}, ${W})\nfn csAtlas(@builtin(global_invocation_id) gid: vec3u) {\n let dims = csParams.dims;\n if any(gid >= dims) {\n return;\n }\n // Voxel-centre position: min + (i + 0.5) * size / dims - 0.5. Multiply\n // before dividing and subtract the half voxel before adding min, so at\n // full resolution the offset is exactly i (the CPU twin does the same).\n let pos = vec3f(csParams.regionMin) + ((vec3f(gid) + vec3f(0.5)) * vec3f(csParams.regionSize) / vec3f(dims) - vec3f(0.5));\n var acc = vdbAccessorInit(csParams.grid);\n var value: f32;\n if csParams.filterMode == 1u {\n value = vdbSample(&acc, pos);\n } else {\n value = vdbReadValue(&acc, vec3i(floor(pos + vec3f(0.5))));\n }\n csAtlasOut[gid.x + gid.y * dims.x + gid.z * dims.x * dims.y] = value;\n}\n`,\n};\n\n/** Options of {@link vdbDecodeToAtlas} (v1's, plus `encoder` and `readback`). */\nexport interface VDBDecodeToAtlasOptions {\n /** Per-axis output resolution cap (a literal clamp, not a proportional downscale). Default 256. */\n maxDim?: number;\n /** Default `'trilinear'`. */\n filter?: VDBAtlasFilter;\n /** Element type of `read()`'s `data`. Default `'uint8'`. */\n format?: VDBAtlasFormat;\n /** Map `range` to `[0, 1]` (`float32`) or `[0, 255]` (`uint8`) in `read()`. Default `true`. */\n normalize?: boolean;\n /** Normalization range. Default: the grid's root min/max statistics (`pool.info(id).rootMin/rootMax`). */\n range?: { min: number; max: number };\n /**\n * Record into this encoder. The host submits it, then calls\n * `job.submitted().read()` (`read()` before `submitted()` rejects with\n * `VDB_BAD_OPTION`). Omitted: the tool submits its own.\n */\n encoder?: GPUCommandEncoder;\n /** `false`: no readback; keep `buffer` for GPU use and `dispose()` it. Default `true`. */\n readback?: boolean;\n}\n\n/** What `read()` resolves with (v1's `DecodeToAtlasResult`). */\nexport interface VDBAtlas {\n /** `dims` product values, x fastest. */\n data: Uint8Array | Float32Array;\n /** Output size per axis in cells (the grid's index box, capped by `maxDim`). */\n dims: [number, number, number];\n /** The range used for normalization (echoed so the caller can undo it). */\n range: { min: number; max: number };\n}\n\n/** The pending atlas: a {@link VDBReadback} plus the GPU output. */\nexport interface VDBAtlasReadback extends VDBReadback<VDBAtlas> {\n /** Output size per axis in cells. */\n readonly dims: [number, number, number];\n /** The normalization range (the option, or the grid's root min/max). */\n readonly range: { min: number; max: number };\n /** Raw f32 values on the GPU (`STORAGE | COPY_SRC`); freed by `read()` / `dispose()`. */\n readonly buffer: GPUBuffer;\n}\n\nconst WHERE = \"decodeToAtlas\";\n\nfunction checkAtlasOptions(o: VDBDecodeToAtlasOptions): void {\n checkPositiveInt(WHERE, \"maxDim\", o.maxDim ?? 256);\n if (o.filter !== undefined && o.filter !== \"nearest\" && o.filter !== \"trilinear\") {\n throw new VDBError(\"VDB_BAD_OPTION\", `${WHERE}: filter must be \"nearest\" or \"trilinear\", got ${JSON.stringify(o.filter)}.`);\n }\n if (o.format !== undefined && o.format !== \"uint8\" && o.format !== \"float32\") {\n throw new VDBError(\"VDB_BAD_OPTION\", `${WHERE}: format must be \"uint8\" or \"float32\", got ${JSON.stringify(o.format)}.`);\n }\n if (o.range !== undefined && !(Number.isFinite(o.range?.min) && Number.isFinite(o.range?.max))) {\n throw new VDBError(\"VDB_BAD_OPTION\", `${WHERE}: range must be { min, max } with finite numbers, got ${JSON.stringify(o.range)}.`);\n }\n}\n\n/**\n * Records the decode of grid `gridId` of `pool` and returns a\n * {@link VDBAtlasReadback}: `const { data, dims } = await decodeToAtlas(device, pool, id).read()`\n * (with a host encoder: submit it, then `await job.submitted().read()`).\n * Cell `i` samples index position `min + (i + 0.5) * size / n - 0.5`, voxel\n * centres at full resolution (see the file comment).\n *\n * The grid must be resident and the pool must live on `device` (as for\n * `gridStats`). The tool frees only its own parameter, output and readback\n * buffers.\n *\n * @param device The host's `GPUDevice`; the pool must live on it.\n * @param pool The pool that holds the grid.\n * @param gridId The grid's pool id; it must be resident.\n * @param options Resolution, filter, format, normalization and encoder ({@link VDBDecodeToAtlasOptions}).\n */\nexport function vdbDecodeToAtlas(device: GPUDevice, pool: VDBGridPool, gridId: number, options: VDBDecodeToAtlasOptions = {}): VDBAtlasReadback {\n checkAtlasOptions(options);\n const info = checkTarget(WHERE, device, pool, gridId);\n const maxDim = options.maxDim ?? 256;\n const filter = options.filter ?? \"trilinear\";\n const format = options.format ?? \"uint8\";\n const normalize = options.normalize ?? true;\n const range = options.range ? { min: options.range.min, max: options.range.max } : normalize ? { min: info.rootMin, max: info.rootMax } : { min: 0, max: 1 };\n const regionSize = bboxSize(info.indexBBox);\n const dims = atlasDims(info.indexBBox, maxDim);\n const cached = kernelPipeline(device, ATLAS, info.type);\n\n const params = createInitialized(\n device,\n \"vdb decodeToAtlas params\",\n USAGE.UNIFORM,\n new Uint8Array(packParams({ grid: gridId, filter: filter === \"trilinear\" ? 1 : 0, regionMin: info.indexBBox.min, regionSize, dims })),\n );\n const bytes = dims[0] * dims[1] * dims[2] * 4;\n const out = device.createBuffer({ label: \"vdb decodeToAtlas\", size: bytes, usage: USAGE.STORAGE | USAGE.COPY_SRC });\n const readback = options.readback ?? true;\n const staging = readback ? device.createBuffer({ label: \"vdb decodeToAtlas readback\", size: bytes, usage: USAGE.MAP_READ | USAGE.COPY_DST }) : null;\n\n const group0 = device.createBindGroup({ layout: cached.group0, entries: [pool.bindGroupEntry({ group: 0, firstBinding: 0 }), { binding: 1, resource: { buffer: params } }] });\n const group1 = device.createBindGroup({ layout: cached.group1, entries: [{ binding: 0, resource: { buffer: out } }] });\n\n const host = hostEncoder(device, options.encoder, \"vdb decodeToAtlas\");\n const pass = host.encoder.beginComputePass({ label: \"vdb decodeToAtlas\" });\n pass.setPipeline(cached.pipeline);\n pass.setBindGroup(0, group0);\n pass.setBindGroup(1, group1);\n pass.dispatchWorkgroups(...workgroups(dims));\n pass.end();\n if (staging) host.encoder.copyBufferToBuffer(out, 0, staging, 0, bytes);\n host.submit();\n\n const finish = (raw: ArrayBuffer): VDBAtlas => ({ data: atlasFromRaw(new Float32Array(raw), { format, normalize, range }), dims: [...dims], range });\n return new AtlasJob([params, out], staging, cached.error, finish, dims, range, out, host.selfSubmitted);\n}\n\nclass AtlasJob extends ComputeJob<VDBAtlas> implements VDBAtlasReadback {\n constructor(\n owned: GPUBuffer[],\n staging: GPUBuffer | null,\n error: Promise<GPUError | null>,\n finish: (bytes: ArrayBuffer) => VDBAtlas,\n readonly dims: [number, number, number],\n readonly range: { min: number; max: number },\n readonly buffer: GPUBuffer,\n selfSubmitted: boolean,\n ) {\n super(WHERE, owned, staging, error, finish, selfSubmitted);\n }\n}\n"]}
@@ -2,12 +2,12 @@
2
2
  * Core compute tools (K2.3): engine-free compute passes over pool grids,
3
3
  * recorded into the host's encoder, plus the CPU value transform.
4
4
  */
5
- export { vdbGridStatsGpu } from "./stats.js";
5
+ export { vdbGridStats } from "./stats.js";
6
6
  export type { VDBGridStats, VDBGridStatsOptions } from "./stats.js";
7
- export { vdbDecodeToAtlasGpu } from "./atlas.js";
7
+ export { vdbDecodeToAtlas } from "./atlas.js";
8
8
  export type { VDBAtlasFilter, VDBAtlasFormat, VDBAtlas, VDBAtlasReadback, VDBDecodeToAtlasOptions } from "./atlas.js";
9
9
  export { vdbApplyValueTransform, VDB_VALUE_TRANSFORM_PRESETS } from "./value-transform.js";
10
10
  export type { VDBValueTransform, VDBValueTransformPreset } from "./value-transform.js";
11
11
  export type { VDBReadback } from "./shared.js";
12
12
  export { boxPyramidWgsl, vdbCreateBoxPyramid } from "./pyramid.js";
13
- export type { VDBBoxPyramidGpu, VDBBoxPyramidGpuOptions, VDBBoxPyramidRecordOptions } from "./pyramid.js";
13
+ export type { VDBBoxPyramid, VDBBoxPyramidOptions, VDBBoxPyramidRecordOptions } from "./pyramid.js";
@@ -2,8 +2,8 @@
2
2
  * Core compute tools (K2.3): engine-free compute passes over pool grids,
3
3
  * recorded into the host's encoder, plus the CPU value transform.
4
4
  */
5
- export { vdbGridStatsGpu } from "./stats.js";
6
- export { vdbDecodeToAtlasGpu } from "./atlas.js";
5
+ export { vdbGridStats } from "./stats.js";
6
+ export { vdbDecodeToAtlas } from "./atlas.js";
7
7
  export { vdbApplyValueTransform, VDB_VALUE_TRANSFORM_PRESETS } from "./value-transform.js";
8
8
  export { boxPyramidWgsl, vdbCreateBoxPyramid } from "./pyramid.js";
9
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/compute/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAG3F,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["/**\n * Core compute tools (K2.3): engine-free compute passes over pool grids,\n * recorded into the host's encoder, plus the CPU value transform.\n */\nexport { vdbGridStatsGpu } from \"./stats.js\";\nexport type { VDBGridStats, VDBGridStatsOptions } from \"./stats.js\";\nexport { vdbDecodeToAtlasGpu } from \"./atlas.js\";\nexport type { VDBAtlasFilter, VDBAtlasFormat, VDBAtlas, VDBAtlasReadback, VDBDecodeToAtlasOptions } from \"./atlas.js\";\nexport { vdbApplyValueTransform, VDB_VALUE_TRANSFORM_PRESETS } from \"./value-transform.js\";\nexport type { VDBValueTransform, VDBValueTransformPreset } from \"./value-transform.js\";\nexport type { VDBReadback } from \"./shared.js\";\nexport { boxPyramidWgsl, vdbCreateBoxPyramid } from \"./pyramid.js\";\nexport type { VDBBoxPyramidGpu, VDBBoxPyramidGpuOptions, VDBBoxPyramidRecordOptions } from \"./pyramid.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/compute/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAG3F,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["/**\n * Core compute tools (K2.3): engine-free compute passes over pool grids,\n * recorded into the host's encoder, plus the CPU value transform.\n */\nexport { vdbGridStats } from \"./stats.js\";\nexport type { VDBGridStats, VDBGridStatsOptions } from \"./stats.js\";\nexport { vdbDecodeToAtlas } from \"./atlas.js\";\nexport type { VDBAtlasFilter, VDBAtlasFormat, VDBAtlas, VDBAtlasReadback, VDBDecodeToAtlasOptions } from \"./atlas.js\";\nexport { vdbApplyValueTransform, VDB_VALUE_TRANSFORM_PRESETS } from \"./value-transform.js\";\nexport type { VDBValueTransform, VDBValueTransformPreset } from \"./value-transform.js\";\nexport type { VDBReadback } from \"./shared.js\";\nexport { boxPyramidWgsl, vdbCreateBoxPyramid } from \"./pyramid.js\";\nexport type { VDBBoxPyramid, VDBBoxPyramidOptions, VDBBoxPyramidRecordOptions } from \"./pyramid.js\";\n"]}
@@ -0,0 +1,45 @@
1
+ import type { VDBGridTypeName } from "../types.js";
2
+ /** Threads per workgroup (one workgroup per cell). */
3
+ export declare const MAJORANT_BUILD_THREADS = 64;
4
+ /** Bytes of `VdbMbParams`. */
5
+ export declare const MAJORANT_BUILD_PARAMS_BYTES = 96;
6
+ /** Largest brick the GPU builds: `(B + 1)³` taps per cell over 64 threads (B = 64: ~4.4k taps per thread). */
7
+ export declare const MAJORANT_BUILD_MAX_LOG2 = 6;
8
+ /** Flags of `VdbMbParams.flags`. */
9
+ export declare const MAJORANT_BUILD_FLAG: {
10
+ readonly zero: 1;
11
+ readonly pathtracer: 2;
12
+ readonly minima: 4;
13
+ };
14
+ /** What one build needs (the pool fills it from the grid's layout and placed range). */
15
+ export interface MajorantBuildParams {
16
+ grid: number;
17
+ /** Byte offset of the range in the pool buffer (32-aligned). */
18
+ rangeOffset: number;
19
+ brickLog2: number;
20
+ origin: readonly [number, number, number];
21
+ dims: readonly [number, number, number];
22
+ bboxMin: readonly [number, number, number];
23
+ bboxMax: readonly [number, number, number];
24
+ /** `align: 'pathtracer'`'s resolution (else unused). */
25
+ resolution: readonly [number, number, number];
26
+ zero: boolean;
27
+ pathtracer: boolean;
28
+ minima: boolean;
29
+ }
30
+ /** The kernel's WGSL for grids of `type` (exported for tests and the WGSL patch harness). */
31
+ export declare function majorantBuildWgsl(type: VDBGridTypeName): string;
32
+ /** Packs `VdbMbParams` (see {@link majorantBuildWgsl}) and the dispatch size. */
33
+ export declare function packMajorantBuild(p: MajorantBuildParams, maxGroups?: number): {
34
+ params: ArrayBuffer;
35
+ groups: [number, number];
36
+ };
37
+ interface MajorantBuildPipeline {
38
+ pipeline: GPUComputePipeline;
39
+ layout: GPUBindGroupLayout;
40
+ /** Validation of the module and pipeline (null = valid). */
41
+ error: Promise<GPUError | null>;
42
+ }
43
+ /** The build pipeline for grids of `type` on `device`, made once per device and type. */
44
+ export declare function majorantBuildPipeline(device: GPUDevice, type: VDBGridTypeName): MajorantBuildPipeline;
45
+ export {};
@@ -0,0 +1,193 @@
1
+ /**
2
+ * The GPU brick-majorant builder (P1.15; docs/dev/design/K1-core.md §5.1 "K3.2 adds a GPU builder").
3
+ * `VDBGridPool.buildMajorant` stages a build and `update(encoder)` records it here, into the host's encoder,
4
+ * after the queue writes of that update (D34: the core records, the host submits).
5
+ *
6
+ * CPU twin: `tools` `vdbBrickMajorant` (same options, same layout through `brickMajorantLayout`). The kernel
7
+ * writes the whole majorant range in the pool buffer: the 32-byte header (origin, flags, `"VDBM"`,
8
+ * `encodeMajorantRange`), the upper bounds and, with minima, the lower bounds. Bounds are maxima / minima of
9
+ * the values the reader returns, so they equal the twin's bit for bit wherever the GPU decodes a voxel as
10
+ * `vdbReadValueF32Cpu` does (always for Float / Half; Fp8 / FpN on a GPU that does not fuse the decode's
11
+ * multiply-add, DIVERGES V214).
12
+ *
13
+ * One workgroup (64 threads) per cell: the cell's `B + 1` tap rows per axis are shared out a row
14
+ * (`B + 1` taps along x, one accessor, mostly one leaf) at a time, then reduced in workgroup memory. A
15
+ * cell is the max (min) of every tap a trilinear sample in it reads (`vdbReadValue`: leaf voxels active
16
+ * or not, tiles, the background), a tap outside the index bbox reading 0 with `outside: 'zero'`, plus the
17
+ * pathtracer's two border rules with `align: 'pathtracer'`.
18
+ *
19
+ * One storage buffer (the pool, read-write; the generated reader in `buffer` mode reads it through the
20
+ * same binding) and one uniform per build (`VdbMbParams`, 96 bytes). The kernel only writes the range,
21
+ * which the pool placed apart from every image.
22
+ */
23
+ import { VDB_MAJORANT_FLAG, VDB_MAJORANT_HEADER_BYTES, VDB_MAJORANT_MAGIC, VDB_MAJORANT_WORD } from "../pool/layout.js";
24
+ import { vdbModuleWgsl } from "../wgsl/generate.js";
25
+ /** Threads per workgroup (one workgroup per cell). */
26
+ export const MAJORANT_BUILD_THREADS = 64;
27
+ /** Bytes of `VdbMbParams`. */
28
+ export const MAJORANT_BUILD_PARAMS_BYTES = 96;
29
+ /** Largest brick the GPU builds: `(B + 1)³` taps per cell over 64 threads (B = 64: ~4.4k taps per thread). */
30
+ export const MAJORANT_BUILD_MAX_LOG2 = 6;
31
+ /** WebGPU's default `maxComputeWorkgroupsPerDimension`. */
32
+ const DEFAULT_MAX_GROUPS = 65535;
33
+ const STAGE_COMPUTE = 0x4;
34
+ /** Flags of `VdbMbParams.flags`. */
35
+ export const MAJORANT_BUILD_FLAG = { zero: 1, pathtracer: 2, minima: 4 };
36
+ /** The kernel's WGSL for grids of `type` (exported for tests and the WGSL patch harness). */
37
+ export function majorantBuildWgsl(type) {
38
+ const H = VDB_MAJORANT_HEADER_BYTES / 4;
39
+ const F = MAJORANT_BUILD_FLAG;
40
+ return `${vdbModuleWgsl({ buffer: "vdbMbPool", types: [type], profile: "read", isActive: false })}
41
+ @group(0) @binding(0) var<storage, read_write> vdbMbPool: array<u32>;
42
+
43
+ struct VdbMbParams {
44
+ origin: vec3i,
45
+ grid: u32,
46
+ dims: vec3u,
47
+ flags: u32,
48
+ lo: vec3i,
49
+ side: u32,
50
+ hi: vec3i,
51
+ out: u32,
52
+ res: vec3i,
53
+ groupsX: u32,
54
+ brick: u32,
55
+ cells: u32,
56
+ pad0: u32,
57
+ pad1: u32,
58
+ };
59
+ @group(0) @binding(1) var<uniform> vdbMbParams: VdbMbParams;
60
+
61
+ var<workgroup> vdbMbHi: array<f32, ${MAJORANT_BUILD_THREADS}>;
62
+ var<workgroup> vdbMbLo: array<f32, ${MAJORANT_BUILD_THREADS}>;
63
+
64
+ fn vdbMbZero(bits: u32) -> u32 {
65
+ return select(bits, 0u, (bits & 0x7fffffffu) == 0u);
66
+ }
67
+
68
+ @compute @workgroup_size(${MAJORANT_BUILD_THREADS})
69
+ fn vdbMajorantBuild(@builtin(workgroup_id) wid: vec3u, @builtin(local_invocation_index) li: u32) {
70
+ let prm = vdbMbParams;
71
+ let cell = wid.x + wid.y * prm.groupsX;
72
+ let live = cell < prm.cells;
73
+ let zero = (prm.flags & ${F.zero}u) != 0u;
74
+ let c = vec3u(cell % prm.dims.x, (cell / prm.dims.x) % prm.dims.y, cell / (prm.dims.x * prm.dims.y));
75
+ let t0 = prm.origin + vec3i(c) * i32(prm.brick);
76
+ var hi = bitcast<f32>(0xff7fffffu); // -f32 max
77
+ var lo = bitcast<f32>(0x7f7fffffu); // f32 max
78
+ if live {
79
+ var acc = vdbAccessorInit(prm.grid);
80
+ let side = prm.side;
81
+ for (var r = li; r < side * side; r += ${MAJORANT_BUILD_THREADS}u) {
82
+ let row = t0 + vec3i(0, i32(r % side), i32(r / side));
83
+ for (var x = 0u; x < side; x++) {
84
+ let p = row + vec3i(i32(x), 0, 0);
85
+ var v = 0.0;
86
+ if !zero || all((p >= prm.lo) & (p <= prm.hi)) {
87
+ v = vdbReadValue(&acc, p);
88
+ }
89
+ hi = max(hi, v);
90
+ lo = min(lo, v);
91
+ }
92
+ }
93
+ }
94
+ vdbMbHi[li] = hi;
95
+ vdbMbLo[li] = lo;
96
+ workgroupBarrier();
97
+ for (var s = ${MAJORANT_BUILD_THREADS / 2}u; s > 0u; s = s >> 1u) {
98
+ if li < s {
99
+ vdbMbHi[li] = max(vdbMbHi[li], vdbMbHi[li + s]);
100
+ vdbMbLo[li] = min(vdbMbLo[li], vdbMbLo[li + s]);
101
+ }
102
+ workgroupBarrier();
103
+ }
104
+ if li == 0u && live {
105
+ var h = vdbMbHi[0];
106
+ var l = vdbMbLo[0];
107
+ if (prm.flags & ${F.pathtracer}u) != 0u {
108
+ // Its brickMajorants: the bound starts at 0; the minimum is 0 when the taps start below 0 or end at n - 1 or later.
109
+ h = max(h, 0.0);
110
+ if any(t0 < vec3i(0)) || any(t0 + vec3i(i32(prm.brick)) >= prm.res - vec3i(1)) {
111
+ l = min(l, 0.0);
112
+ }
113
+ }
114
+ // A signed-zero bound is stored as +0, on the bits (min / max of +0 and -0 may return either, and WGSL may
115
+ // ignore the sign of a zero in float compares; the twin does the same).
116
+ let hb = vdbMbZero(bitcast<u32>(h));
117
+ let base = prm.out + ${H}u;
118
+ vdbMbPool[base + cell] = hb;
119
+ if (prm.flags & ${F.minima}u) != 0u {
120
+ vdbMbPool[base + prm.cells + cell] = vdbMbZero(bitcast<u32>(min(l, h)));
121
+ }
122
+ }
123
+ // The range header (encodeMajorantRange): origin, flags, magic, zeros.
124
+ if cell == 0u && li < ${H}u {
125
+ var w = 0u;
126
+ if li < 3u {
127
+ w = bitcast<u32>(prm.origin[li]);
128
+ } else if li == ${VDB_MAJORANT_WORD.flags}u {
129
+ w = select(0u, ${VDB_MAJORANT_FLAG.minima}u, (prm.flags & ${F.minima}u) != 0u);
130
+ } else if li == ${VDB_MAJORANT_WORD.magic}u {
131
+ w = ${VDB_MAJORANT_MAGIC}u;
132
+ }
133
+ vdbMbPool[prm.out + li] = w;
134
+ }
135
+ }
136
+ `;
137
+ }
138
+ /** Packs `VdbMbParams` (see {@link majorantBuildWgsl}) and the dispatch size. */
139
+ export function packMajorantBuild(p, maxGroups = DEFAULT_MAX_GROUPS) {
140
+ const cells = p.dims[0] * p.dims[1] * p.dims[2];
141
+ const groupsX = Math.min(cells, maxGroups);
142
+ const groupsY = Math.ceil(cells / groupsX);
143
+ if (groupsY > maxGroups)
144
+ throw new RangeError(`buildMajorant: ${cells} cells need more than ${maxGroups}² workgroups.`);
145
+ const bytes = new ArrayBuffer(MAJORANT_BUILD_PARAMS_BYTES);
146
+ const i = new Int32Array(bytes);
147
+ const u = new Uint32Array(bytes);
148
+ const B = 1 << p.brickLog2;
149
+ for (let a = 0; a < 3; a++) {
150
+ i[a] = p.origin[a];
151
+ u[4 + a] = p.dims[a];
152
+ i[8 + a] = p.bboxMin[a];
153
+ i[12 + a] = p.bboxMax[a];
154
+ i[16 + a] = p.resolution[a];
155
+ }
156
+ const F = MAJORANT_BUILD_FLAG;
157
+ u[3] = p.grid;
158
+ u[7] = (p.zero ? F.zero : 0) | (p.pathtracer ? F.pathtracer : 0) | (p.minima ? F.minima : 0);
159
+ u[11] = B + 1;
160
+ u[15] = p.rangeOffset / 4;
161
+ u[19] = groupsX;
162
+ u[20] = B;
163
+ u[21] = cells;
164
+ return { params: bytes, groups: [groupsX, groupsY] };
165
+ }
166
+ const pipelines = new WeakMap();
167
+ /** The build pipeline for grids of `type` on `device`, made once per device and type. */
168
+ export function majorantBuildPipeline(device, type) {
169
+ let byType = pipelines.get(device);
170
+ if (!byType)
171
+ pipelines.set(device, (byType = new Map()));
172
+ let cached = byType.get(type);
173
+ if (cached)
174
+ return cached;
175
+ device.pushErrorScope("validation");
176
+ const layout = device.createBindGroupLayout({
177
+ label: `vdb buildMajorant ${type}`,
178
+ entries: [
179
+ { binding: 0, visibility: STAGE_COMPUTE, buffer: { type: "storage" } },
180
+ { binding: 1, visibility: STAGE_COMPUTE, buffer: { type: "uniform" } },
181
+ ],
182
+ });
183
+ const module = device.createShaderModule({ label: `vdb buildMajorant ${type}`, code: majorantBuildWgsl(type) });
184
+ const pipeline = device.createComputePipeline({
185
+ label: `vdb buildMajorant ${type}`,
186
+ layout: device.createPipelineLayout({ bindGroupLayouts: [layout] }),
187
+ compute: { module, entryPoint: "vdbMajorantBuild" },
188
+ });
189
+ cached = { pipeline, layout, error: device.popErrorScope() };
190
+ byType.set(type, cached);
191
+ return cached;
192
+ }
193
+ //# sourceMappingURL=majorant-build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"majorant-build.js","sourceRoot":"","sources":["../../../src/core/compute/majorant-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAExH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AACzC,8BAA8B;AAC9B,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAC9C,8GAA8G;AAC9G,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AACzC,2DAA2D;AAC3D,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,oCAAoC;AACpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAW,CAAC;AAmBlF,6FAA6F;AAC7F,MAAM,UAAU,iBAAiB,CAAC,IAAqB;IACrD,MAAM,CAAC,GAAG,yBAAyB,GAAG,CAAC,CAAC;IACxC,MAAM,CAAC,GAAG,mBAAmB,CAAC;IAC9B,OAAO,GAAG,aAAa,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;qCAqB9D,sBAAsB;qCACtB,sBAAsB;;;;;;2BAMhC,sBAAsB;;;;;8BAKnB,CAAC,CAAC,IAAI;;;;;;;;iDAQa,sBAAsB;;;;;;;;;;;;;;;;mBAgBpD,sBAAsB,GAAG,C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,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzB,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * The GPU brick-majorant builder (P1.15; docs/dev/design/K1-core.md §5.1 \"K3.2 adds a GPU builder\").\n * `VDBGridPool.buildMajorant` stages a build and `update(encoder)` records it here, into the host's encoder,\n * after the queue writes of that update (D34: the core records, the host submits).\n *\n * CPU twin: `tools` `vdbBrickMajorant` (same options, same layout through `brickMajorantLayout`). The kernel\n * writes the whole majorant range in the pool buffer: the 32-byte header (origin, flags, `\"VDBM\"`,\n * `encodeMajorantRange`), the upper bounds and, with minima, the lower bounds. Bounds are maxima / minima of\n * the values the reader returns, so they equal the twin's bit for bit wherever the GPU decodes a voxel as\n * `vdbReadValueF32Cpu` does (always for Float / Half; Fp8 / FpN on a GPU that does not fuse the decode's\n * multiply-add, DIVERGES V214).\n *\n * One workgroup (64 threads) per cell: the cell's `B + 1` tap rows per axis are shared out a row\n * (`B + 1` taps along x, one accessor, mostly one leaf) at a time, then reduced in workgroup memory. A\n * cell is the max (min) of every tap a trilinear sample in it reads (`vdbReadValue`: leaf voxels active\n * or not, tiles, the background), a tap outside the index bbox reading 0 with `outside: 'zero'`, plus the\n * pathtracer's two border rules with `align: 'pathtracer'`.\n *\n * One storage buffer (the pool, read-write; the generated reader in `buffer` mode reads it through the\n * same binding) and one uniform per build (`VdbMbParams`, 96 bytes). The kernel only writes the range,\n * which the pool placed apart from every image.\n */\nimport { VDB_MAJORANT_FLAG, VDB_MAJORANT_HEADER_BYTES, VDB_MAJORANT_MAGIC, VDB_MAJORANT_WORD } from \"../pool/layout.js\";\nimport type { VDBGridTypeName } from \"../types.js\";\nimport { vdbModuleWgsl } from \"../wgsl/generate.js\";\n\n/** Threads per workgroup (one workgroup per cell). */\nexport const MAJORANT_BUILD_THREADS = 64;\n/** Bytes of `VdbMbParams`. */\nexport const MAJORANT_BUILD_PARAMS_BYTES = 96;\n/** Largest brick the GPU builds: `(B + 1)³` taps per cell over 64 threads (B = 64: ~4.4k taps per thread). */\nexport const MAJORANT_BUILD_MAX_LOG2 = 6;\n/** WebGPU's default `maxComputeWorkgroupsPerDimension`. */\nconst DEFAULT_MAX_GROUPS = 65535;\n\nconst STAGE_COMPUTE = 0x4;\n\n/** Flags of `VdbMbParams.flags`. */\nexport const MAJORANT_BUILD_FLAG = { zero: 1, pathtracer: 2, minima: 4 } as const;\n\n/** What one build needs (the pool fills it from the grid's layout and placed range). */\nexport interface MajorantBuildParams {\n grid: number;\n /** Byte offset of the range in the pool buffer (32-aligned). */\n rangeOffset: number;\n brickLog2: number;\n origin: readonly [number, number, number];\n dims: readonly [number, number, number];\n bboxMin: readonly [number, number, number];\n bboxMax: readonly [number, number, number];\n /** `align: 'pathtracer'`'s resolution (else unused). */\n resolution: readonly [number, number, number];\n zero: boolean;\n pathtracer: boolean;\n minima: boolean;\n}\n\n/** The kernel's WGSL for grids of `type` (exported for tests and the WGSL patch harness). */\nexport function majorantBuildWgsl(type: VDBGridTypeName): string {\n const H = VDB_MAJORANT_HEADER_BYTES / 4;\n const F = MAJORANT_BUILD_FLAG;\n return `${vdbModuleWgsl({ buffer: \"vdbMbPool\", types: [type], profile: \"read\", isActive: false })}\n@group(0) @binding(0) var<storage, read_write> vdbMbPool: array<u32>;\n\nstruct VdbMbParams {\n origin: vec3i,\n grid: u32,\n dims: vec3u,\n flags: u32,\n lo: vec3i,\n side: u32,\n hi: vec3i,\n out: u32,\n res: vec3i,\n groupsX: u32,\n brick: u32,\n cells: u32,\n pad0: u32,\n pad1: u32,\n};\n@group(0) @binding(1) var<uniform> vdbMbParams: VdbMbParams;\n\nvar<workgroup> vdbMbHi: array<f32, ${MAJORANT_BUILD_THREADS}>;\nvar<workgroup> vdbMbLo: array<f32, ${MAJORANT_BUILD_THREADS}>;\n\nfn vdbMbZero(bits: u32) -> u32 {\n return select(bits, 0u, (bits & 0x7fffffffu) == 0u);\n}\n\n@compute @workgroup_size(${MAJORANT_BUILD_THREADS})\nfn vdbMajorantBuild(@builtin(workgroup_id) wid: vec3u, @builtin(local_invocation_index) li: u32) {\n let prm = vdbMbParams;\n let cell = wid.x + wid.y * prm.groupsX;\n let live = cell < prm.cells;\n let zero = (prm.flags & ${F.zero}u) != 0u;\n let c = vec3u(cell % prm.dims.x, (cell / prm.dims.x) % prm.dims.y, cell / (prm.dims.x * prm.dims.y));\n let t0 = prm.origin + vec3i(c) * i32(prm.brick);\n var hi = bitcast<f32>(0xff7fffffu); // -f32 max\n var lo = bitcast<f32>(0x7f7fffffu); // f32 max\n if live {\n var acc = vdbAccessorInit(prm.grid);\n let side = prm.side;\n for (var r = li; r < side * side; r += ${MAJORANT_BUILD_THREADS}u) {\n let row = t0 + vec3i(0, i32(r % side), i32(r / side));\n for (var x = 0u; x < side; x++) {\n let p = row + vec3i(i32(x), 0, 0);\n var v = 0.0;\n if !zero || all((p >= prm.lo) & (p <= prm.hi)) {\n v = vdbReadValue(&acc, p);\n }\n hi = max(hi, v);\n lo = min(lo, v);\n }\n }\n }\n vdbMbHi[li] = hi;\n vdbMbLo[li] = lo;\n workgroupBarrier();\n for (var s = ${MAJORANT_BUILD_THREADS / 2}u; s > 0u; s = s >> 1u) {\n if li < s {\n vdbMbHi[li] = max(vdbMbHi[li], vdbMbHi[li + s]);\n vdbMbLo[li] = min(vdbMbLo[li], vdbMbLo[li + s]);\n }\n workgroupBarrier();\n }\n if li == 0u && live {\n var h = vdbMbHi[0];\n var l = vdbMbLo[0];\n if (prm.flags & ${F.pathtracer}u) != 0u {\n // Its brickMajorants: the bound starts at 0; the minimum is 0 when the taps start below 0 or end at n - 1 or later.\n h = max(h, 0.0);\n if any(t0 < vec3i(0)) || any(t0 + vec3i(i32(prm.brick)) >= prm.res - vec3i(1)) {\n l = min(l, 0.0);\n }\n }\n // A signed-zero bound is stored as +0, on the bits (min / max of +0 and -0 may return either, and WGSL may\n // ignore the sign of a zero in float compares; the twin does the same).\n let hb = vdbMbZero(bitcast<u32>(h));\n let base = prm.out + ${H}u;\n vdbMbPool[base + cell] = hb;\n if (prm.flags & ${F.minima}u) != 0u {\n vdbMbPool[base + prm.cells + cell] = vdbMbZero(bitcast<u32>(min(l, h)));\n }\n }\n // The range header (encodeMajorantRange): origin, flags, magic, zeros.\n if cell == 0u && li < ${H}u {\n var w = 0u;\n if li < 3u {\n w = bitcast<u32>(prm.origin[li]);\n } else if li == ${VDB_MAJORANT_WORD.flags}u {\n w = select(0u, ${VDB_MAJORANT_FLAG.minima}u, (prm.flags & ${F.minima}u) != 0u);\n } else if li == ${VDB_MAJORANT_WORD.magic}u {\n w = ${VDB_MAJORANT_MAGIC}u;\n }\n vdbMbPool[prm.out + li] = w;\n }\n}\n`;\n}\n\n/** Packs `VdbMbParams` (see {@link majorantBuildWgsl}) and the dispatch size. */\nexport function packMajorantBuild(p: MajorantBuildParams, maxGroups = DEFAULT_MAX_GROUPS): { params: ArrayBuffer; groups: [number, number] } {\n const cells = p.dims[0] * p.dims[1] * p.dims[2];\n const groupsX = Math.min(cells, maxGroups);\n const groupsY = Math.ceil(cells / groupsX);\n if (groupsY > maxGroups) throw new RangeError(`buildMajorant: ${cells} cells need more than ${maxGroups}² workgroups.`);\n const bytes = new ArrayBuffer(MAJORANT_BUILD_PARAMS_BYTES);\n const i = new Int32Array(bytes);\n const u = new Uint32Array(bytes);\n const B = 1 << p.brickLog2;\n for (let a = 0; a < 3; a++) {\n i[a] = p.origin[a]!;\n u[4 + a] = p.dims[a]!;\n i[8 + a] = p.bboxMin[a]!;\n i[12 + a] = p.bboxMax[a]!;\n i[16 + a] = p.resolution[a]!;\n }\n const F = MAJORANT_BUILD_FLAG;\n u[3] = p.grid;\n u[7] = (p.zero ? F.zero : 0) | (p.pathtracer ? F.pathtracer : 0) | (p.minima ? F.minima : 0);\n u[11] = B + 1;\n u[15] = p.rangeOffset / 4;\n u[19] = groupsX;\n u[20] = B;\n u[21] = cells;\n return { params: bytes, groups: [groupsX, groupsY] };\n}\n\ninterface MajorantBuildPipeline {\n pipeline: GPUComputePipeline;\n layout: GPUBindGroupLayout;\n /** Validation of the module and pipeline (null = valid). */\n error: Promise<GPUError | null>;\n}\n\nconst pipelines = new WeakMap<GPUDevice, Map<VDBGridTypeName, MajorantBuildPipeline>>();\n\n/** The build pipeline for grids of `type` on `device`, made once per device and type. */\nexport function majorantBuildPipeline(device: GPUDevice, type: VDBGridTypeName): MajorantBuildPipeline {\n let byType = pipelines.get(device);\n if (!byType) pipelines.set(device, (byType = new Map()));\n let cached = byType.get(type);\n if (cached) return cached;\n device.pushErrorScope(\"validation\");\n const layout = device.createBindGroupLayout({\n label: `vdb buildMajorant ${type}`,\n entries: [\n { binding: 0, visibility: STAGE_COMPUTE, buffer: { type: \"storage\" } },\n { binding: 1, visibility: STAGE_COMPUTE, buffer: { type: \"uniform\" } },\n ],\n });\n const module = device.createShaderModule({ label: `vdb buildMajorant ${type}`, code: majorantBuildWgsl(type) });\n const pipeline = device.createComputePipeline({\n label: `vdb buildMajorant ${type}`,\n layout: device.createPipelineLayout({ bindGroupLayouts: [layout] }),\n compute: { module, entryPoint: \"vdbMajorantBuild\" },\n });\n cached = { pipeline, layout, error: device.popErrorScope() };\n byType.set(type, cached);\n return cached;\n}\n"]}
@@ -0,0 +1,155 @@
1
+ import { type VDBFrameMultiScaleEdge, type VDBFrameMultiScaleLayout } from "../../tools/frame/multi-scale.js";
2
+ /** Output formats of the chain: components per texel. */
3
+ export type VDBMultiScaleFormat = "r16float" | "rg16float" | "rgba16float";
4
+ /** The WGSL of the mip build kernels (exported for tests). */
5
+ export declare function multiScaleMipsWgsl(): string;
6
+ /** Options of {@link vdbCreateMultiScaleMips}. */
7
+ export interface VDBMultiScaleMipsOptions {
8
+ /** Base texels per axis: the grid region the levels filter (one cascade of the shadow grid). */
9
+ size: readonly [number, number, number];
10
+ /** Levels including the base (2 to 8, default 6: his `multiScaleLevels` maximum). */
11
+ levels?: number;
12
+ /** Source components that become the level channels, in order (default [0, 1]: extinction, absorption). */
13
+ channels?: readonly number[];
14
+ /** Output format (default by channel count: 1 r16float, 2 rg16float, 3–4 rgba16float). */
15
+ format?: VDBMultiScaleFormat;
16
+ /** Edge rule (default `'zero'`; `'clamp'` is his clamp-to-edge). */
17
+ edge?: VDBFrameMultiScaleEdge;
18
+ /**
19
+ * Write into this 3D texture instead of allocating: `format`, the layout's level-1 size, levels − 1 mips,
20
+ * `COPY_DST`. Never destroyed here.
21
+ */
22
+ target?: GPUTexture;
23
+ /** Debug label of the GPU objects. */
24
+ label?: string;
25
+ }
26
+ /** Options of {@link VDBMultiScaleMips.record}. */
27
+ export interface VDBMultiScaleRecordOptions {
28
+ /** First texel of the base region in the source texture (default 0, 0, 0): a cascade of a stacked grid. */
29
+ origin?: readonly [number, number, number];
30
+ /** Timestamps around the build's one compute pass (the `timestamp-query` feature). */
31
+ timestampWrites?: GPUComputePassTimestampWrites;
32
+ }
33
+ /** Options of {@link VDBMultiScaleMips.resize}. */
34
+ export interface VDBMultiScaleResizeOptions {
35
+ /** Levels (default: unchanged). */
36
+ levels?: number;
37
+ /** The host texture for the new size (required when the chain was made with `target`). */
38
+ target?: GPUTexture;
39
+ }
40
+ /** The mip chain of a grid texture on the GPU (see the file comment). */
41
+ export interface VDBMultiScaleMips {
42
+ /** The level sizes (levels 1 … levels − 1 = mips 0 … levels − 2 of {@link texture}). */
43
+ readonly layout: VDBFrameMultiScaleLayout;
44
+ /** Components per level texel (the `channels` option's length). */
45
+ readonly channels: number;
46
+ /** The texture's format. */
47
+ readonly format: VDBMultiScaleFormat;
48
+ /** The levels as one 3D texture with levels − 1 mips. */
49
+ readonly texture: GPUTexture;
50
+ /** A 3D view of every mip of {@link texture}: bind it as the lookup's `mips`. */
51
+ readonly view: GPUTextureView;
52
+ /** Bumps when `resize` replaces {@link texture}: rebuild bind groups that hold {@link view}. */
53
+ readonly version: number;
54
+ /** Bytes: `textures` (counted whoever owns them) and `scratch` (this chain's buffers). */
55
+ readonly gpuBytes: {
56
+ readonly textures: number;
57
+ readonly scratch: number;
58
+ };
59
+ /** Pipeline validation (null = valid). */
60
+ readonly error: Promise<GPUError | null>;
61
+ /**
62
+ * Records a build of every level from `source` into `encoder`; the host submits it. Record it after the
63
+ * pass that writes `source` (in the same encoder or an earlier submit).
64
+ *
65
+ * @param encoder The host's encoder.
66
+ * @param source The base grid: a 3D texture with `TEXTURE_BINDING` and a float sample type, or a 3D view of
67
+ * one (then the size and format are the host's to check). Holds the region at `origin`.
68
+ * @param options Region origin and timestamps. The origin lives in a uniform written with `queue.writeBuffer`,
69
+ * so builds from two origins need two submits.
70
+ */
71
+ record(encoder: GPUCommandEncoder, source: GPUTexture | GPUTextureView, options?: VDBMultiScaleRecordOptions): void;
72
+ /** New base size (and levels): new texture and scratch, `version` bumps, the old ones retired (file comment). */
73
+ resize(size: readonly [number, number, number], options?: VDBMultiScaleResizeOptions): void;
74
+ /** Frees what this chain allocated, retired resources included (never `target`). Idempotent. */
75
+ destroy(): void;
76
+ }
77
+ /**
78
+ * Creates the binomial mip chain of a grid texture for `'multi-scale'` multiple scattering (see the file comment)
79
+ * and returns it unbuilt: record a build with `mips.record(encoder, source)` after the pass that writes the grid,
80
+ * then bind `mips.view` as the lookup's `mips` (`vdbFrameMultiScaleWgsl`).
81
+ *
82
+ * const mips = vdbCreateMultiScaleMips(device, { size: [64, 64, 64] });
83
+ * mips.record(encoder, shadowGrid, { origin: [0, 0, 64 * lastCascade] });
84
+ * device.queue.submit([encoder.finish()]);
85
+ *
86
+ * @param device The host's `GPUDevice`.
87
+ * @param options Size, levels, channels, format, edge rule, target and label ({@link VDBMultiScaleMipsOptions}).
88
+ */
89
+ export declare function vdbCreateMultiScaleMips(device: GPUDevice, options: VDBMultiScaleMipsOptions): VDBMultiScaleMips;
90
+ /** Bytes of the WGSL `VdbFrameMultiScale` struct ({@link vdbFrameMultiScaleParams}). */
91
+ export declare const VDB_FRAME_MULTI_SCALE_PARAMS_BYTES = 64;
92
+ /** The lookup's sampler: linear, clamp-to-edge (the lookup picks each mip with an explicit level). */
93
+ export declare const VDB_FRAME_MULTI_SCALE_SAMPLER: GPUSamplerDescriptor;
94
+ /** The lookup's grid (WGSL `VdbFrameMultiScale`; the CPU twin's `VDBFrameMultiScaleGrid` plus the base region). */
95
+ export interface VDBFrameMultiScaleParams {
96
+ /** World box of the base region (his last cascade: gridMin, gridSize). */
97
+ boxMin: readonly [number, number, number];
98
+ boxSize: readonly [number, number, number];
99
+ /** h: the grid's largest voxel side, world units. */
100
+ unit: number;
101
+ /** Levels read, base included (clamped in WGSL to the mips present + 1). */
102
+ levels: number;
103
+ /** 1 − g; 0 gives no scattered light. */
104
+ multipleScattering: number;
105
+ /** First texel of the base region in the base texture (default 0, 0, 0). */
106
+ baseOrigin?: readonly [number, number, number];
107
+ /** Base region texels per axis (the chain's `layout.size`). */
108
+ baseSize: readonly [number, number, number];
109
+ /**
110
+ * K6.3a: level k of the lookup reads mip level min(k + levelOffset, the chain's mips) (default 0, his; 1 is the
111
+ * paper's σ = 2^k, `multiScaleSigma: 'paper'`, with one more level in the chain).
112
+ */
113
+ levelOffset?: number;
114
+ }
115
+ /**
116
+ * The 64 bytes of a WGSL `VdbFrameMultiScale` (into `target` at `byteOffset`, or a new buffer): boxMin, levels,
117
+ * boxSize, unit, baseOrigin, multipleScattering, baseSize, levelOffset (K6.3a; was padding, 0 = unchanged).
118
+ */
119
+ export declare function vdbFrameMultiScaleParams(p: VDBFrameMultiScaleParams, target?: ArrayBuffer, byteOffset?: number): ArrayBuffer;
120
+ /** Options of {@link vdbFrameMultiScaleWgsl}. */
121
+ export interface VDBFrameMultiScaleWgslOptions {
122
+ /** Base texture components of extinction and absorption (default [0, 1]; one entry: no absorption). */
123
+ baseChannels?: readonly number[];
124
+ /** Components of the mip texture (default: as many as `baseChannels`; 1 reads no absorption). */
125
+ mipChannels?: number;
126
+ /**
127
+ * K7.4a-3: the per-channel lookup of spectral media instead of the grey one: `vdbFrameMultiScaleSample3` /
128
+ * `vdbFrameMultiScaleLight3` over two bases (extinction rgb, absorption rgb in xyz) and their two chains (made with
129
+ * `channels: [0, 1, 2]`). Each channel runs the grey arithmetic in the grey order, so a grey medium gives the grey
130
+ * lookup's value in every channel. `baseChannels` / `mipChannels` are ignored.
131
+ */
132
+ spectral?: boolean;
133
+ }
134
+ /**
135
+ * The WGSL lookup of `'multi-scale'` multiple scattering, as text to paste into a host shader once (not part of
136
+ * the VDB module, so module bytes and the size snapshot never move). Declares:
137
+ *
138
+ * struct VdbFrameMultiScale { boxMin: vec3f, levels: u32, boxSize: vec3f, unit: f32,
139
+ * baseOrigin: vec3f, multipleScattering: f32, baseSize: vec3f, levelOffset: u32 }
140
+ * fn vdbFrameMultiScaleSample(base: texture_3d<f32>, mips: texture_3d<f32>, smp: sampler,
141
+ * ms: VdbFrameMultiScale, level: u32, world: vec3f) -> vec2f
142
+ * fn vdbFrameMultiScaleLight(base: texture_3d<f32>, mips: texture_3d<f32>, smp: sampler,
143
+ * ms: VdbFrameMultiScale, world: vec3f, direction: vec3f, maxDistance: f32) -> f32
144
+ *
145
+ * `base` is the host's grid texture (filterable float), `mips` the chain's `view`, `smp` a sampler made from
146
+ * {@link VDB_FRAME_MULTI_SCALE_SAMPLER}; the host binds all three at its own slots and fills the struct with
147
+ * {@link vdbFrameMultiScaleParams}. `vdbFrameMultiScaleLight` returns the scattered light (total − direct) for a
148
+ * unit direction to the light; the caller adds its march's direct transmittance and clamps to 1. No derivatives
149
+ * (`textureSampleLevel`), so it runs in compute and in non-uniform control flow. CPU twins:
150
+ * `tools/frame/multi-scale.ts`. K7.4a-3 `spectral: true` declares the per-channel lookup instead,
151
+ * `vdbFrameMultiScaleSample3` / `vdbFrameMultiScaleLight3(baseE, baseA, mipsE, mipsA, smp, ms, world, direction,
152
+ * maxDistance) -> vec3f` over the extinction rgb and absorption rgb bases and their chains (twins
153
+ * `vdbFrameMultiScaleSampleRgb` / `vdbFrameSpectralMultiScaleLight`).
154
+ */
155
+ export declare function vdbFrameMultiScaleWgsl(options?: VDBFrameMultiScaleWgslOptions): string;