@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,67 @@
1
+ /**
2
+ * Device-limit clamps of the core frame renderer's large textures (K6.8, K6.10a): the transmittance stack's grid
3
+ * resolution and the volume shadow map size. Pure functions of the device's limits, so the unit tests run them on a
4
+ * fake device's limits without allocating anything.
5
+ *
6
+ * Dawn zero-fills a new texture through one staging buffer of its size, with rows padded to 256 bytes. A texture
7
+ * whose staging buffer would exceed the device's `maxBufferSize` fails the host's submit and the frame is lost, so
8
+ * both clamps bound that staging size, not only the texture's dimensions.
9
+ */
10
+ /** The limits the clamps read (a `GPUSupportedLimits` subset); a missing one takes the WebGPU default. */
11
+ export interface VDBFrameLimits {
12
+ readonly maxBufferSize?: number;
13
+ readonly maxTextureDimension2D?: number;
14
+ readonly maxTextureDimension3D?: number;
15
+ }
16
+ /** WebGPU's default limits (the floor every adapter meets). */
17
+ export declare const VDB_FRAME_DEFAULT_LIMITS: {
18
+ readonly maxBufferSize: 268435456;
19
+ readonly maxTextureDimension2D: 8192;
20
+ readonly maxTextureDimension3D: 2048;
21
+ };
22
+ /** Bytes of Dawn's zero-fill staging buffer for a texture: rows padded to 256 bytes, times rows and depth (or layers). */
23
+ export declare function vdbFrameStagingBytes(width: number, height: number, depthOrLayers: number, texelBytes: number): number;
24
+ /** Why a clamp lowered a size: the stack does not tile, the texture is too large, or its staging buffer is. */
25
+ export type VDBFrameClampReason = "tile" | "dimension" | "bytes";
26
+ /** A clamped size and the reason it was lowered (`null`: unchanged). */
27
+ export interface VDBFrameClamp {
28
+ readonly size: number;
29
+ readonly reason: VDBFrameClampReason | null;
30
+ }
31
+ /**
32
+ * Targets in the transmittance stack: 4 per cascade, 3 per slot group and cascade when spectral (every group counted).
33
+ * K6.Q1d `dipole` (the stack holds the pairs' dipole, {@link vdbFrameDipoleTargetsWanted}): 1 more per cascade
34
+ * (spectral: 3).
35
+ */
36
+ export declare function vdbFrameStackTargets(cascades: number, spectral: boolean, dipole?: boolean): number;
37
+ /** What {@link vdbFrameDipoleTargetsWanted} reads of the renderer's settings. */
38
+ export interface VDBFrameDipoleSettings {
39
+ readonly lighting: string | false;
40
+ readonly ambientOcclusion: boolean;
41
+ readonly multipleScattering: string | boolean;
42
+ readonly ambientPhase?: string;
43
+ }
44
+ /**
45
+ * K6.Q1d-a (D41): whether 'frame' lighting's transmittance stack holds the pairs' dipole targets this update, i.e.
46
+ * whether a gather reads them: 'frame' lighting, `ambientOcclusion` on, the internal `ambientPhase` 'dipole' (the
47
+ * default), multiple scattering off or `'octaves'` (diffusion totals stay unweighted: 'neural', the default mode,
48
+ * never reads the targets) and distant light in the frame (`distant`: ambient, hemisphere or probe light, or an
49
+ * 'outward' environment; without it no AO pair runs). The renderer keeps allocated targets through
50
+ * `VDB_FRAME_RELEASE_UPDATES` updates in a row without distant light (a light that blinks does not reallocate the
51
+ * stack); a setting that turns them off frees them at the next update (K7.16).
52
+ */
53
+ export declare function vdbFrameDipoleTargetsWanted(settings: VDBFrameDipoleSettings, distant: boolean): boolean;
54
+ /** The settings half of {@link vdbFrameDipoleTargetsWanted} (everything but the lights). */
55
+ export declare function vdbFrameDipoleSettingsOn(settings: VDBFrameDipoleSettings): boolean;
56
+ /**
57
+ * K6.8 / K6.10a: the largest shadow grid resolution ≤ `resolution` (≥ 2) whose textures the device can hold. Before
58
+ * K6.10a a resolution whose stack did not tile (above 1024 with one cascade, 1024 with 3–4 cascades) threw a
59
+ * `RangeError` from `vdbFrameStackLayout` instead of clamping.
60
+ */
61
+ export declare function vdbFrameFitGridResolution(resolution: number, cascades: number, spectral: boolean, limits?: VDBFrameLimits, dipole?: boolean): VDBFrameClamp;
62
+ /**
63
+ * K6.10a: the largest volume shadow map size ≤ `size` (≥ 1) the device can hold: at most `maxTextureDimension2D`, and
64
+ * one map texture (`layers` rgba16float layers: 6 for a point light's cube, the cascades for a directional light) with
65
+ * a staging buffer within `maxBufferSize`. A spectral map's rgb twin is a second texture of the same size.
66
+ */
67
+ export declare function vdbFrameFitShadowMapSize(size: number, layers: number, limits?: VDBFrameLimits): VDBFrameClamp;
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Device-limit clamps of the core frame renderer's large textures (K6.8, K6.10a): the transmittance stack's grid
3
+ * resolution and the volume shadow map size. Pure functions of the device's limits, so the unit tests run them on a
4
+ * fake device's limits without allocating anything.
5
+ *
6
+ * Dawn zero-fills a new texture through one staging buffer of its size, with rows padded to 256 bytes. A texture
7
+ * whose staging buffer would exceed the device's `maxBufferSize` fails the host's submit and the frame is lost, so
8
+ * both clamps bound that staging size, not only the texture's dimensions.
9
+ */
10
+ import { vdbFrameStackLayout } from "../../tools/frame/stack.js";
11
+ import { VDB_FRAME_SPECTRAL_GROUPS } from "./uniforms.js";
12
+ import { VDB_FRAME_SPECTRAL_GRID_WORDS } from "./wgsl/lighting.js";
13
+ /** WebGPU's default limits (the floor every adapter meets). */
14
+ export const VDB_FRAME_DEFAULT_LIMITS = { maxBufferSize: 268435456, maxTextureDimension2D: 8192, maxTextureDimension3D: 2048 };
15
+ /** Bytes of Dawn's zero-fill staging buffer for a texture: rows padded to 256 bytes, times rows and depth (or layers). */
16
+ export function vdbFrameStagingBytes(width, height, depthOrLayers, texelBytes) {
17
+ return Math.ceil((width * texelBytes) / 256) * 256 * height * depthOrLayers;
18
+ }
19
+ /**
20
+ * Targets in the transmittance stack: 4 per cascade, 3 per slot group and cascade when spectral (every group counted).
21
+ * K6.Q1d `dipole` (the stack holds the pairs' dipole, {@link vdbFrameDipoleTargetsWanted}): 1 more per cascade
22
+ * (spectral: 3).
23
+ */
24
+ export function vdbFrameStackTargets(cascades, spectral, dipole = false) {
25
+ return (spectral ? 3 * VDB_FRAME_SPECTRAL_GROUPS * cascades : 4 * cascades) + (dipole ? (spectral ? 3 : 1) * cascades : 0);
26
+ }
27
+ /**
28
+ * K6.Q1d-a (D41): whether 'frame' lighting's transmittance stack holds the pairs' dipole targets this update, i.e.
29
+ * whether a gather reads them: 'frame' lighting, `ambientOcclusion` on, the internal `ambientPhase` 'dipole' (the
30
+ * default), multiple scattering off or `'octaves'` (diffusion totals stay unweighted: 'neural', the default mode,
31
+ * never reads the targets) and distant light in the frame (`distant`: ambient, hemisphere or probe light, or an
32
+ * 'outward' environment; without it no AO pair runs). The renderer keeps allocated targets through
33
+ * `VDB_FRAME_RELEASE_UPDATES` updates in a row without distant light (a light that blinks does not reallocate the
34
+ * stack); a setting that turns them off frees them at the next update (K7.16).
35
+ */
36
+ export function vdbFrameDipoleTargetsWanted(settings, distant) {
37
+ return vdbFrameDipoleSettingsOn(settings) && distant;
38
+ }
39
+ /** The settings half of {@link vdbFrameDipoleTargetsWanted} (everything but the lights). */
40
+ export function vdbFrameDipoleSettingsOn(settings) {
41
+ const ms = settings.multipleScattering;
42
+ return settings.lighting === "frame" && !!settings.ambientOcclusion && (settings.ambientPhase ?? "dipole") === "dipole" && (!ms || ms === "octaves");
43
+ }
44
+ /**
45
+ * Why `side` does not fit the grid textures, or `null` when it does: the transmittance stack (the largest, rgba16float)
46
+ * must tile in `maxTextureDimension3D` and its staging buffer fit `maxBufferSize`; a spectral grid's partials are the
47
+ * shadow stack 3 words deep, which must fit `maxTextureDimension3D` too.
48
+ */
49
+ function gridMisfit(side, cascades, spectral, maxDim, maxBytes, dipole) {
50
+ const targets = vdbFrameStackTargets(cascades, spectral, dipole);
51
+ const perAxis = Math.floor(maxDim / side);
52
+ if (perAxis < 1 || targets > perAxis ** 3)
53
+ return "tile";
54
+ const stack = vdbFrameStackLayout(side, targets, maxDim).size;
55
+ if (spectral && vdbFrameStackLayout(side, cascades, maxDim).size[2] * VDB_FRAME_SPECTRAL_GRID_WORDS > maxDim)
56
+ return "tile";
57
+ if (vdbFrameStagingBytes(stack[0], stack[1], stack[2], 8) > maxBytes)
58
+ return "bytes";
59
+ return null;
60
+ }
61
+ /**
62
+ * K6.8 / K6.10a: the largest shadow grid resolution ≤ `resolution` (≥ 2) whose textures the device can hold. Before
63
+ * K6.10a a resolution whose stack did not tile (above 1024 with one cascade, 1024 with 3–4 cascades) threw a
64
+ * `RangeError` from `vdbFrameStackLayout` instead of clamping.
65
+ */
66
+ export function vdbFrameFitGridResolution(resolution, cascades, spectral, limits = {}, dipole = false) {
67
+ const maxDim = limits.maxTextureDimension3D ?? VDB_FRAME_DEFAULT_LIMITS.maxTextureDimension3D;
68
+ const maxBytes = limits.maxBufferSize ?? VDB_FRAME_DEFAULT_LIMITS.maxBufferSize;
69
+ const start = Math.max(2, Math.floor(resolution));
70
+ let reason = null;
71
+ // Start at the side the byte budget allows at all (a cube's 8 bytes per texel per target), then step down
72
+ const targets = vdbFrameStackTargets(cascades, spectral, dipole);
73
+ let r = Math.min(start, maxDim, Math.max(2, Math.floor(Math.cbrt(maxBytes / (8 * targets))) + 1));
74
+ if (r < start)
75
+ reason = gridMisfit(start, cascades, spectral, maxDim, maxBytes, dipole) ?? "bytes";
76
+ for (;;) {
77
+ const misfit = gridMisfit(r, cascades, spectral, maxDim, maxBytes, dipole);
78
+ if (!misfit || r <= 2)
79
+ break;
80
+ reason ??= misfit;
81
+ r--;
82
+ }
83
+ return { size: r, reason: r === start ? null : reason };
84
+ }
85
+ /**
86
+ * K6.10a: the largest volume shadow map size ≤ `size` (≥ 1) the device can hold: at most `maxTextureDimension2D`, and
87
+ * one map texture (`layers` rgba16float layers: 6 for a point light's cube, the cascades for a directional light) with
88
+ * a staging buffer within `maxBufferSize`. A spectral map's rgb twin is a second texture of the same size.
89
+ */
90
+ export function vdbFrameFitShadowMapSize(size, layers, limits = {}) {
91
+ const maxDim = limits.maxTextureDimension2D ?? VDB_FRAME_DEFAULT_LIMITS.maxTextureDimension2D;
92
+ const maxBytes = limits.maxBufferSize ?? VDB_FRAME_DEFAULT_LIMITS.maxBufferSize;
93
+ const start = Math.max(1, Math.round(size));
94
+ let s = start;
95
+ let reason = null;
96
+ if (s > maxDim) {
97
+ s = maxDim;
98
+ reason = "dimension";
99
+ }
100
+ const bytes = (side) => vdbFrameStagingBytes(side, side, layers, 8);
101
+ if (bytes(s) > maxBytes) {
102
+ reason ??= "bytes";
103
+ s = Math.min(s, Math.max(1, Math.floor(Math.sqrt(maxBytes / (8 * layers)))));
104
+ while (s > 1 && bytes(s) > maxBytes)
105
+ s--;
106
+ }
107
+ return { size: s, reason: s === start ? null : reason };
108
+ }
109
+ //# sourceMappingURL=limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.js","sourceRoot":"","sources":["../../../src/core/frame/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AASnE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,qBAAqB,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAW,CAAC;AAExI,0HAA0H;AAC1H,MAAM,UAAU,oBAAoB,CAAC,KAAa,EAAE,MAAc,EAAE,aAAqB,EAAE,UAAkB;IAC3G,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,MAAM,GAAG,aAAa,CAAC;AAC9E,CAAC;AAWD;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB,EAAE,QAAiB,EAAE,MAAM,GAAG,KAAK;IACtF,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,yBAAyB,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7H,CAAC;AAUD;;;;;;;;GAQG;AACH,MAAM,UAAU,2BAA2B,CAAC,QAAgC,EAAE,OAAgB;IAC5F,OAAO,wBAAwB,CAAC,QAA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AM,EAAE,CAAC;AAC1D,CAAC","sourcesContent":["/**\n * Device-limit clamps of the core frame renderer's large textures (K6.8, K6.10a): the transmittance stack's grid\n * resolution and the volume shadow map size. Pure functions of the device's limits, so the unit tests run them on a\n * fake device's limits without allocating anything.\n *\n * Dawn zero-fills a new texture through one staging buffer of its size, with rows padded to 256 bytes. A texture\n * whose staging buffer would exceed the device's `maxBufferSize` fails the host's submit and the frame is lost, so\n * both clamps bound that staging size, not only the texture's dimensions.\n */\n\nimport { vdbFrameStackLayout } from \"../../tools/frame/stack.js\";\nimport { VDB_FRAME_SPECTRAL_GROUPS } from \"./uniforms.js\";\nimport { VDB_FRAME_SPECTRAL_GRID_WORDS } from \"./wgsl/lighting.js\";\n\n/** The limits the clamps read (a `GPUSupportedLimits` subset); a missing one takes the WebGPU default. */\nexport interface VDBFrameLimits {\n readonly maxBufferSize?: number;\n readonly maxTextureDimension2D?: number;\n readonly maxTextureDimension3D?: number;\n}\n\n/** WebGPU's default limits (the floor every adapter meets). */\nexport const VDB_FRAME_DEFAULT_LIMITS = { maxBufferSize: 268435456, maxTextureDimension2D: 8192, maxTextureDimension3D: 2048 } as const;\n\n/** Bytes of Dawn's zero-fill staging buffer for a texture: rows padded to 256 bytes, times rows and depth (or layers). */\nexport function vdbFrameStagingBytes(width: number, height: number, depthOrLayers: number, texelBytes: number): number {\n return Math.ceil((width * texelBytes) / 256) * 256 * height * depthOrLayers;\n}\n\n/** Why a clamp lowered a size: the stack does not tile, the texture is too large, or its staging buffer is. */\nexport type VDBFrameClampReason = \"tile\" | \"dimension\" | \"bytes\";\n\n/** A clamped size and the reason it was lowered (`null`: unchanged). */\nexport interface VDBFrameClamp {\n readonly size: number;\n readonly reason: VDBFrameClampReason | null;\n}\n\n/**\n * Targets in the transmittance stack: 4 per cascade, 3 per slot group and cascade when spectral (every group counted).\n * K6.Q1d `dipole` (the stack holds the pairs' dipole, {@link vdbFrameDipoleTargetsWanted}): 1 more per cascade\n * (spectral: 3).\n */\nexport function vdbFrameStackTargets(cascades: number, spectral: boolean, dipole = false): number {\n return (spectral ? 3 * VDB_FRAME_SPECTRAL_GROUPS * cascades : 4 * cascades) + (dipole ? (spectral ? 3 : 1) * cascades : 0);\n}\n\n/** What {@link vdbFrameDipoleTargetsWanted} reads of the renderer's settings. */\nexport interface VDBFrameDipoleSettings {\n readonly lighting: string | false;\n readonly ambientOcclusion: boolean;\n readonly multipleScattering: string | boolean;\n readonly ambientPhase?: string;\n}\n\n/**\n * K6.Q1d-a (D41): whether 'frame' lighting's transmittance stack holds the pairs' dipole targets this update, i.e.\n * whether a gather reads them: 'frame' lighting, `ambientOcclusion` on, the internal `ambientPhase` 'dipole' (the\n * default), multiple scattering off or `'octaves'` (diffusion totals stay unweighted: 'neural', the default mode,\n * never reads the targets) and distant light in the frame (`distant`: ambient, hemisphere or probe light, or an\n * 'outward' environment; without it no AO pair runs). The renderer keeps allocated targets through\n * `VDB_FRAME_RELEASE_UPDATES` updates in a row without distant light (a light that blinks does not reallocate the\n * stack); a setting that turns them off frees them at the next update (K7.16).\n */\nexport function vdbFrameDipoleTargetsWanted(settings: VDBFrameDipoleSettings, distant: boolean): boolean {\n return vdbFrameDipoleSettingsOn(settings) && distant;\n}\n\n/** The settings half of {@link vdbFrameDipoleTargetsWanted} (everything but the lights). */\nexport function vdbFrameDipoleSettingsOn(settings: VDBFrameDipoleSettings): boolean {\n const ms = settings.multipleScattering;\n return settings.lighting === \"frame\" && !!settings.ambientOcclusion && (settings.ambientPhase ?? \"dipole\") === \"dipole\" && (!ms || ms === \"octaves\");\n}\n\n/**\n * Why `side` does not fit the grid textures, or `null` when it does: the transmittance stack (the largest, rgba16float)\n * must tile in `maxTextureDimension3D` and its staging buffer fit `maxBufferSize`; a spectral grid's partials are the\n * shadow stack 3 words deep, which must fit `maxTextureDimension3D` too.\n */\nfunction gridMisfit(side: number, cascades: number, spectral: boolean, maxDim: number, maxBytes: number, dipole: boolean): VDBFrameClampReason | null {\n const targets = vdbFrameStackTargets(cascades, spectral, dipole);\n const perAxis = Math.floor(maxDim / side);\n if (perAxis < 1 || targets > perAxis ** 3) return \"tile\";\n const stack = vdbFrameStackLayout(side, targets, maxDim).size;\n if (spectral && vdbFrameStackLayout(side, cascades, maxDim).size[2] * VDB_FRAME_SPECTRAL_GRID_WORDS > maxDim) return \"tile\";\n if (vdbFrameStagingBytes(stack[0], stack[1], stack[2], 8) > maxBytes) return \"bytes\";\n return null;\n}\n\n/**\n * K6.8 / K6.10a: the largest shadow grid resolution ≤ `resolution` (≥ 2) whose textures the device can hold. Before\n * K6.10a a resolution whose stack did not tile (above 1024 with one cascade, 1024 with 3–4 cascades) threw a\n * `RangeError` from `vdbFrameStackLayout` instead of clamping.\n */\nexport function vdbFrameFitGridResolution(resolution: number, cascades: number, spectral: boolean, limits: VDBFrameLimits = {}, dipole = false): VDBFrameClamp {\n const maxDim = limits.maxTextureDimension3D ?? VDB_FRAME_DEFAULT_LIMITS.maxTextureDimension3D;\n const maxBytes = limits.maxBufferSize ?? VDB_FRAME_DEFAULT_LIMITS.maxBufferSize;\n const start = Math.max(2, Math.floor(resolution));\n let reason: VDBFrameClampReason | null = null;\n // Start at the side the byte budget allows at all (a cube's 8 bytes per texel per target), then step down\n const targets = vdbFrameStackTargets(cascades, spectral, dipole);\n let r = Math.min(start, maxDim, Math.max(2, Math.floor(Math.cbrt(maxBytes / (8 * targets))) + 1));\n if (r < start) reason = gridMisfit(start, cascades, spectral, maxDim, maxBytes, dipole) ?? \"bytes\";\n for (;;) {\n const misfit = gridMisfit(r, cascades, spectral, maxDim, maxBytes, dipole);\n if (!misfit || r <= 2) break;\n reason ??= misfit;\n r--;\n }\n return { size: r, reason: r === start ? null : reason };\n}\n\n/**\n * K6.10a: the largest volume shadow map size ≤ `size` (≥ 1) the device can hold: at most `maxTextureDimension2D`, and\n * one map texture (`layers` rgba16float layers: 6 for a point light's cube, the cascades for a directional light) with\n * a staging buffer within `maxBufferSize`. A spectral map's rgb twin is a second texture of the same size.\n */\nexport function vdbFrameFitShadowMapSize(size: number, layers: number, limits: VDBFrameLimits = {}): VDBFrameClamp {\n const maxDim = limits.maxTextureDimension2D ?? VDB_FRAME_DEFAULT_LIMITS.maxTextureDimension2D;\n const maxBytes = limits.maxBufferSize ?? VDB_FRAME_DEFAULT_LIMITS.maxBufferSize;\n const start = Math.max(1, Math.round(size));\n let s = start;\n let reason: VDBFrameClampReason | null = null;\n if (s > maxDim) {\n s = maxDim;\n reason = \"dimension\";\n }\n const bytes = (side: number) => vdbFrameStagingBytes(side, side, layers, 8);\n if (bytes(s) > maxBytes) {\n reason ??= \"bytes\";\n s = Math.min(s, Math.max(1, Math.floor(Math.sqrt(maxBytes / (8 * layers)))));\n while (s > 1 && bytes(s) > maxBytes) s--;\n }\n return { size: s, reason: s === start ? null : reason };\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { VDBFrameMultipleScatteringMode, VDBFramePhaseName } from "./settings.js";
2
+ /** The phase fields of a volume after its overrides (his `VDBFramePhaseSource`). */
3
+ export interface VDBFramePhaseFields {
4
+ phase: VDBFramePhaseName;
5
+ phaseG: number;
6
+ phaseBackG: number;
7
+ phaseBackWeight: number;
8
+ phaseGExponent: number;
9
+ }
10
+ /** `getFramePhase`: (forward g, back g, back weight, Lorenz-Mie mode). */
11
+ export declare function vdbFramePhaseVector(p: VDBFramePhaseFields): [number, number, number, number];
12
+ /** `getFramePhaseSpectrum`: (red g scale, blue g scale, flag). */
13
+ export declare function vdbFramePhaseSpectrum(p: VDBFramePhaseFields): [number, number, number];
14
+ /** `getFramePhaseAsymmetry`. */
15
+ export declare function vdbFramePhaseAsymmetry(p: VDBFramePhaseFields): number;
16
+ /** `getFrameMultipleScattering`: 1 − g for the diffusion modes (true, 'two-sided', 'neural'), else 0. */
17
+ export declare function vdbFrameMultipleScatteringValue(mode: VDBFrameMultipleScatteringMode, p: VDBFramePhaseFields): number;
@@ -0,0 +1,53 @@
1
+ // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
+ // src/three-openvdb/frame/core/framePhase.js L5–58 (getFramePhase, getFramePhaseSpectrum), L79–108
3
+ // (getFramePhaseAsymmetry, isFrameDiffusion, getFrameMultipleScattering).
4
+ // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
5
+ // Changes: engine-free (plain tuples) for the core renderer (K6.1). Divergences: DIVERGES.md (K3.4 rows).
6
+ const clampG = (g) => Math.min(0.99, Math.max(-0.99, Number(g) || 0.0));
7
+ const clampWeight = (w) => Math.min(1.0, Math.max(0.0, Number(w) || 0.0));
8
+ /** His `frameSpectrumWavelengths` (nm): red, green, blue. */
9
+ const WAVELENGTHS = [650.0, 550.0, 450.0];
10
+ /** Lorenz-Mie mode of 'lorenz-mie-rgb'. */
11
+ const MIE_RGB_MODE = 2.0;
12
+ /** Asymmetry g of the Lorenz-Mie table (`vdbFrameMieAsymmetry`). */
13
+ const MIE_ASYMMETRY = 0.8526;
14
+ /** `getFramePhase`: (forward g, back g, back weight, Lorenz-Mie mode). */
15
+ export function vdbFramePhaseVector(p) {
16
+ if (p.phase === "henyey-greenstein")
17
+ return [clampG(p.phaseG), 0, 0, 0];
18
+ if (p.phase === "dual-lobe")
19
+ return [clampG(p.phaseG), clampG(p.phaseBackG), clampWeight(p.phaseBackWeight), 0];
20
+ if (p.phase === "lorenz-mie")
21
+ return [0, 0, 0, 1];
22
+ if (p.phase === "lorenz-mie-rgb")
23
+ return [0, 0, 0, MIE_RGB_MODE];
24
+ return [0, 0, 0, 0];
25
+ }
26
+ /** `getFramePhaseSpectrum`: (red g scale, blue g scale, flag). */
27
+ export function vdbFramePhaseSpectrum(p) {
28
+ const exponent = Number.isFinite(Number(p.phaseGExponent)) ? Number(p.phaseGExponent) : 0.0;
29
+ if (p.phase === "lorenz-mie-rgb")
30
+ return [1, 1, 1];
31
+ if ((p.phase === "henyey-greenstein" || p.phase === "dual-lobe") && exponent !== 0.0) {
32
+ const [red, green, blue] = WAVELENGTHS;
33
+ return [Math.pow(red / green, -exponent), Math.pow(blue / green, -exponent), 1];
34
+ }
35
+ return [1, 1, 0];
36
+ }
37
+ /** `getFramePhaseAsymmetry`. */
38
+ export function vdbFramePhaseAsymmetry(p) {
39
+ if (p.phase === "henyey-greenstein")
40
+ return clampG(p.phaseG);
41
+ if (p.phase === "dual-lobe") {
42
+ const w = clampWeight(p.phaseBackWeight);
43
+ return clampG(p.phaseG) * (1 - w) + clampG(p.phaseBackG) * w;
44
+ }
45
+ if (p.phase === "lorenz-mie" || p.phase === "lorenz-mie-rgb")
46
+ return MIE_ASYMMETRY;
47
+ return 0;
48
+ }
49
+ /** `getFrameMultipleScattering`: 1 − g for the diffusion modes (true, 'two-sided', 'neural'), else 0. */
50
+ export function vdbFrameMultipleScatteringValue(mode, p) {
51
+ return !!mode && mode !== "octaves" ? 1 - vdbFramePhaseAsymmetry(p) : 0;
52
+ }
53
+ //# sourceMappingURL=phase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phase.js","sourceRoot":"","sources":["../../../src/core/frame/phase.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,qGAAqG;AACrG,4EAA4E;AAC5E,4GAA4G;AAC5G,0GAA0G;AAa1G,MAAM,MAAM,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;AACjF,MAAM,WAAW,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;AACnF,6DAA6D;AAC7D,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAU,CAAC;AACnD,2CAA2C;AAC3C,M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-openvdb/frame/core/framePhase.js L5–58 (getFramePhase, getFramePhaseSpectrum), L79–108\n// (getFramePhaseAsymmetry, isFrameDiffusion, getFrameMultipleScattering).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: engine-free (plain tuples) for the core renderer (K6.1). Divergences: DIVERGES.md (K3.4 rows).\n\nimport type { VDBFrameMultipleScatteringMode, VDBFramePhaseName } from \"./settings.js\";\n\n/** The phase fields of a volume after its overrides (his `VDBFramePhaseSource`). */\nexport interface VDBFramePhaseFields {\n phase: VDBFramePhaseName;\n phaseG: number;\n phaseBackG: number;\n phaseBackWeight: number;\n phaseGExponent: number;\n}\n\nconst clampG = (g: unknown) => Math.min(0.99, Math.max(-0.99, Number(g) || 0.0));\nconst clampWeight = (w: unknown) => Math.min(1.0, Math.max(0.0, Number(w) || 0.0));\n/** His `frameSpectrumWavelengths` (nm): red, green, blue. */\nconst WAVELENGTHS = [650.0, 550.0, 450.0] as const;\n/** Lorenz-Mie mode of 'lorenz-mie-rgb'. */\nconst MIE_RGB_MODE = 2.0;\n/** Asymmetry g of the Lorenz-Mie table (`vdbFrameMieAsymmetry`). */\nconst MIE_ASYMMETRY = 0.8526;\n\n/** `getFramePhase`: (forward g, back g, back weight, Lorenz-Mie mode). */\nexport function vdbFramePhaseVector(p: VDBFramePhaseFields): [number, number, number, number] {\n if (p.phase === \"henyey-greenstein\") return [clampG(p.phaseG), 0, 0, 0];\n if (p.phase === \"dual-lobe\") return [clampG(p.phaseG), clampG(p.phaseBackG), clampWeight(p.phaseBackWeight), 0];\n if (p.phase === \"lorenz-mie\") return [0, 0, 0, 1];\n if (p.phase === \"lorenz-mie-rgb\") return [0, 0, 0, MIE_RGB_MODE];\n return [0, 0, 0, 0];\n}\n\n/** `getFramePhaseSpectrum`: (red g scale, blue g scale, flag). */\nexport function vdbFramePhaseSpectrum(p: VDBFramePhaseFields): [number, number, number] {\n const exponent = Number.isFinite(Number(p.phaseGExponent)) ? Number(p.phaseGExponent) : 0.0;\n if (p.phase === \"lorenz-mie-rgb\") return [1, 1, 1];\n if ((p.phase === \"henyey-greenstein\" || p.phase === \"dual-lobe\") && exponent !== 0.0) {\n const [red, green, blue] = WAVELENGTHS;\n return [Math.pow(red / green, -exponent), Math.pow(blue / green, -exponent), 1];\n }\n return [1, 1, 0];\n}\n\n/** `getFramePhaseAsymmetry`. */\nexport function vdbFramePhaseAsymmetry(p: VDBFramePhaseFields): number {\n if (p.phase === \"henyey-greenstein\") return clampG(p.phaseG);\n if (p.phase === \"dual-lobe\") {\n const w = clampWeight(p.phaseBackWeight);\n return clampG(p.phaseG) * (1 - w) + clampG(p.phaseBackG) * w;\n }\n if (p.phase === \"lorenz-mie\" || p.phase === \"lorenz-mie-rgb\") return MIE_ASYMMETRY;\n return 0;\n}\n\n/** `getFrameMultipleScattering`: 1 − g for the diffusion modes (true, 'two-sided', 'neural'), else 0. */\nexport function vdbFrameMultipleScatteringValue(mode: VDBFrameMultipleScatteringMode, p: VDBFramePhaseFields): number {\n return !!mode && mode !== \"octaves\" ? 1 - vdbFramePhaseAsymmetry(p) : 0;\n}\n"]}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The per-device pipeline cache of the core frame renderer (K6.1, design §4.1, §5.2): pipelines, layouts
3
+ * and modules live as long as their device (a WeakMap keyed by the device), found by a key of the WGSL
4
+ * text's hash, the bind-group layouts and the target formats. Every creation runs inside
5
+ * `pushErrorScope('validation')`; `prepare()` uses the async creators. Bind-group layouts are positional
6
+ * and must have no gaps (Traps): callers pass one descriptor per group, 0..n−1.
7
+ */
8
+ /** FNV-1a (two 32-bit lanes) of a string: the WGSL text's key. */
9
+ export declare function vdbHashText(text: string): string;
10
+ /** A compute kernel to build. */
11
+ export interface VDBComputeSpec {
12
+ readonly label: string;
13
+ readonly code: string;
14
+ readonly entryPoint: string;
15
+ /** One layout per group, 0..n−1 (no gaps). */
16
+ readonly groups: readonly GPUBindGroupLayoutDescriptor[];
17
+ }
18
+ /** A render pipeline to build (the composite). */
19
+ export interface VDBRenderSpec {
20
+ readonly label: string;
21
+ readonly code: string;
22
+ readonly vertexEntryPoint: string;
23
+ readonly fragmentEntryPoint: string;
24
+ readonly groups: readonly GPUBindGroupLayoutDescriptor[];
25
+ readonly targets: readonly GPUColorTargetState[];
26
+ /** K6.6 (level sets, points): optional depth state, primitive state and vertex buffers (default: none, triangle-list). */
27
+ readonly depthStencil?: GPUDepthStencilState;
28
+ readonly primitive?: GPUPrimitiveState;
29
+ readonly buffers?: readonly GPUVertexBufferLayout[];
30
+ }
31
+ /** A built pipeline with its group layouts and the validation result of its creation. */
32
+ export interface VDBCachedPipeline<P> {
33
+ readonly pipeline: P;
34
+ readonly layouts: readonly GPUBindGroupLayout[];
35
+ /** Resolves null when valid, else the first validation error (also logged once). */
36
+ readonly error: Promise<GPUError | null>;
37
+ }
38
+ /** The cache key of a compute spec. */
39
+ export declare const computeKey: (s: VDBComputeSpec) => string;
40
+ /** The cache key of a render spec. */
41
+ export declare const renderKey: (s: VDBRenderSpec) => string;
42
+ /** The compute pipeline of `spec` on `device`, built once (synchronously) per device and key. */
43
+ export declare function computePipeline(device: GPUDevice, spec: VDBComputeSpec): VDBCachedPipeline<GPUComputePipeline>;
44
+ /** The render pipeline of `spec` on `device`, built once (synchronously) per device and key. */
45
+ export declare function renderPipeline(device: GPUDevice, spec: VDBRenderSpec): VDBCachedPipeline<GPURenderPipeline>;
46
+ /** Builds `spec` with `createComputePipelineAsync` into the cache (no-op when cached). */
47
+ export declare function prepareCompute(device: GPUDevice, spec: VDBComputeSpec): Promise<void>;
48
+ /** Builds `spec` with `createRenderPipelineAsync` into the cache (no-op when cached). */
49
+ export declare function prepareRender(device: GPUDevice, spec: VDBRenderSpec): Promise<void>;
@@ -0,0 +1,147 @@
1
+ /**
2
+ * The per-device pipeline cache of the core frame renderer (K6.1, design §4.1, §5.2): pipelines, layouts
3
+ * and modules live as long as their device (a WeakMap keyed by the device), found by a key of the WGSL
4
+ * text's hash, the bind-group layouts and the target formats. Every creation runs inside
5
+ * `pushErrorScope('validation')`; `prepare()` uses the async creators. Bind-group layouts are positional
6
+ * and must have no gaps (Traps): callers pass one descriptor per group, 0..n−1.
7
+ */
8
+ import { VDBError } from "../errors.js";
9
+ /** FNV-1a (two 32-bit lanes) of a string: the WGSL text's key. */
10
+ export function vdbHashText(text) {
11
+ let a = 0x811c9dc5;
12
+ let b = 0x01000193 ^ text.length;
13
+ for (let i = 0; i < text.length; i++) {
14
+ const c = text.charCodeAt(i);
15
+ a = Math.imul(a ^ c, 0x01000193);
16
+ b = Math.imul(b ^ c, 0x5bd1e995) ^ (b >>> 13);
17
+ }
18
+ return `${(a >>> 0).toString(16).padStart(8, "0")}${(b >>> 0).toString(16).padStart(8, "0")}`;
19
+ }
20
+ /** The pipeline-state part of a render spec's key and descriptor (K6.6); empty for the composite. */
21
+ const renderState = (s) => (s.depthStencil || s.primitive || s.buffers ? `:${vdbHashText(JSON.stringify([s.depthStencil ?? null, s.primitive ?? null, s.buffers ?? null]))}` : "");
22
+ function renderDescriptor(spec, module, layout) {
23
+ return {
24
+ label: spec.label,
25
+ layout,
26
+ vertex: { module, entryPoint: spec.vertexEntryPoint, ...(spec.buffers ? { buffers: [...spec.buffers] } : {}) },
27
+ fragment: { module, entryPoint: spec.fragmentEntryPoint, targets: [...spec.targets] },
28
+ primitive: spec.primitive ?? { topology: "triangle-list" },
29
+ ...(spec.depthStencil ? { depthStencil: spec.depthStencil } : {}),
30
+ };
31
+ }
32
+ const caches = new WeakMap();
33
+ const layoutKey = (groups) => JSON.stringify(groups.map((g) => [...g.entries].sort((x, y) => x.binding - y.binding)));
34
+ /** The cache key of a compute spec. */
35
+ export const computeKey = (s) => `c:${s.entryPoint}:${vdbHashText(s.code)}:${vdbHashText(layoutKey(s.groups))}`;
36
+ /** The cache key of a render spec. */
37
+ export const renderKey = (s) => `r:${s.vertexEntryPoint}:${s.fragmentEntryPoint}:${vdbHashText(s.code)}:${vdbHashText(layoutKey(s.groups))}:${vdbHashText(JSON.stringify(s.targets))}${renderState(s)}`;
38
+ function cacheOf(device) {
39
+ let c = caches.get(device);
40
+ if (!c)
41
+ caches.set(device, (c = new Map()));
42
+ return c;
43
+ }
44
+ function checkGroups(label, groups) {
45
+ if (groups.length > 4)
46
+ throw new VDBError("VDB_BAD_OPTION", `${label}: ${groups.length} bind groups exceed maxBindGroups (4).`);
47
+ }
48
+ function logged(label, error) {
49
+ return error.then((e) => {
50
+ if (e)
51
+ console.error(`@pmndrs/vdb frame renderer: ${label}: ${e.message}`);
52
+ return e;
53
+ });
54
+ }
55
+ function layoutsOf(device, label, groups) {
56
+ return groups.map((g, i) => device.createBindGroupLayout({ ...g, label: `${label} group ${i}` }));
57
+ }
58
+ /** The compute pipeline of `spec` on `device`, built once (synchronously) per device and key. */
59
+ export function computePipeline(device, spec) {
60
+ const cache = cacheOf(device);
61
+ const key = computeKey(spec);
62
+ const hit = cache.get(key);
63
+ if (hit && !(hit instanceof Promise))
64
+ return hit;
65
+ checkGroups(spec.label, spec.groups);
66
+ device.pushErrorScope("validation");
67
+ const layouts = layoutsOf(device, spec.label, spec.groups);
68
+ const module = device.createShaderModule({ label: spec.label, code: spec.code });
69
+ const pipeline = device.createComputePipeline({
70
+ label: spec.label,
71
+ layout: device.createPipelineLayout({ label: spec.label, bindGroupLayouts: layouts }),
72
+ compute: { module, entryPoint: spec.entryPoint },
73
+ });
74
+ const built = { pipeline, layouts, error: logged(spec.label, device.popErrorScope()) };
75
+ cache.set(key, built);
76
+ return built;
77
+ }
78
+ /** The render pipeline of `spec` on `device`, built once (synchronously) per device and key. */
79
+ export function renderPipeline(device, spec) {
80
+ const cache = cacheOf(device);
81
+ const key = renderKey(spec);
82
+ const hit = cache.get(key);
83
+ if (hit && !(hit instanceof Promise))
84
+ return hit;
85
+ checkGroups(spec.label, spec.groups);
86
+ device.pushErrorScope("validation");
87
+ const layouts = layoutsOf(device, spec.label, spec.groups);
88
+ const module = device.createShaderModule({ label: spec.label, code: spec.code });
89
+ const pipeline = device.createRenderPipeline(renderDescriptor(spec, module, device.createPipelineLayout({ label: spec.label, bindGroupLayouts: layouts })));
90
+ const built = { pipeline, layouts, error: logged(spec.label, device.popErrorScope()) };
91
+ cache.set(key, built);
92
+ return built;
93
+ }
94
+ /** Builds `spec` with `createComputePipelineAsync` into the cache (no-op when cached). */
95
+ export async function prepareCompute(device, spec) {
96
+ const cache = cacheOf(device);
97
+ const key = computeKey(spec);
98
+ const hit = cache.get(key);
99
+ if (hit) {
100
+ await hit;
101
+ return;
102
+ }
103
+ checkGroups(spec.label, spec.groups);
104
+ const job = (async () => {
105
+ device.pushErrorScope("validation");
106
+ const layouts = layoutsOf(device, spec.label, spec.groups);
107
+ const module = device.createShaderModule({ label: spec.label, code: spec.code });
108
+ const layout = device.createPipelineLayout({ label: spec.label, bindGroupLayouts: layouts });
109
+ const scope = device.popErrorScope();
110
+ const pipeline = await device.createComputePipelineAsync({ label: spec.label, layout, compute: { module, entryPoint: spec.entryPoint } });
111
+ return { pipeline, layouts, error: logged(spec.label, scope) };
112
+ })();
113
+ await settle(cache, key, job);
114
+ }
115
+ /** Caches `job` under `key`, then its result; a failed build leaves no entry and rethrows. */
116
+ async function settle(cache, key, job) {
117
+ cache.set(key, job);
118
+ try {
119
+ cache.set(key, await job);
120
+ }
121
+ catch (e) {
122
+ cache.delete(key);
123
+ throw e;
124
+ }
125
+ }
126
+ /** Builds `spec` with `createRenderPipelineAsync` into the cache (no-op when cached). */
127
+ export async function prepareRender(device, spec) {
128
+ const cache = cacheOf(device);
129
+ const key = renderKey(spec);
130
+ const hit = cache.get(key);
131
+ if (hit) {
132
+ await hit;
133
+ return;
134
+ }
135
+ checkGroups(spec.label, spec.groups);
136
+ const job = (async () => {
137
+ device.pushErrorScope("validation");
138
+ const layouts = layoutsOf(device, spec.label, spec.groups);
139
+ const module = device.createShaderModule({ label: spec.label, code: spec.code });
140
+ const layout = device.createPipelineLayout({ label: spec.label, bindGroupLayouts: layouts });
141
+ const scope = device.popErrorScope();
142
+ const pipeline = await device.createRenderPipelineAsync(renderDescriptor(spec, module, layout));
143
+ return { pipeline, layouts, error: logged(spec.label, scope) };
144
+ })();
145
+ await settle(cache, key, job);
146
+ }
147
+ //# sourceMappingURL=pipelines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipelines.js","sourceRoot":"","sources":["../../../src/core/frame/pipelines.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,kEAAkE;AAClE,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,IAAI,CAAC,GAAG,UAAU,CAAC;IACnB,IAAI,CAAC,GAAG,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;QACjC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AAChG,CAAC;AAyBD,qGAAqG;AACrG,MAAM,WAAW,GAAG,CAAC,CAAgB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,IAAI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B,EAAE;QAC5C,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QACpC,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3D,MAAM,MAAM,GAAG,MAAM,CAAC,kBAAkB,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACjF,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,CAAC;QAC7F,MAAM,KAAK,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;QACrC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAChG,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;IACjE,CAAC,CAAC,EAAE,CAAC;IACL,MAAM,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC","sourcesContent":["/**\n * The per-device pipeline cache of the core frame renderer (K6.1, design §4.1, §5.2): pipelines, layouts\n * and modules live as long as their device (a WeakMap keyed by the device), found by a key of the WGSL\n * text's hash, the bind-group layouts and the target formats. Every creation runs inside\n * `pushErrorScope('validation')`; `prepare()` uses the async creators. Bind-group layouts are positional\n * and must have no gaps (Traps): callers pass one descriptor per group, 0..n−1.\n */\n\nimport { VDBError } from \"../errors.js\";\n\n/** FNV-1a (two 32-bit lanes) of a string: the WGSL text's key. */\nexport function vdbHashText(text: string): string {\n let a = 0x811c9dc5;\n let b = 0x01000193 ^ text.length;\n for (let i = 0; i < text.length; i++) {\n const c = text.charCodeAt(i);\n a = Math.imul(a ^ c, 0x01000193);\n b = Math.imul(b ^ c, 0x5bd1e995) ^ (b >>> 13);\n }\n return `${(a >>> 0).toString(16).padStart(8, \"0\")}${(b >>> 0).toString(16).padStart(8, \"0\")}`;\n}\n\n/** A compute kernel to build. */\nexport interface VDBComputeSpec {\n readonly label: string;\n readonly code: string;\n readonly entryPoint: string;\n /** One layout per group, 0..n−1 (no gaps). */\n readonly groups: readonly GPUBindGroupLayoutDescriptor[];\n}\n\n/** A render pipeline to build (the composite). */\nexport interface VDBRenderSpec {\n readonly label: string;\n readonly code: string;\n readonly vertexEntryPoint: string;\n readonly fragmentEntryPoint: string;\n readonly groups: readonly GPUBindGroupLayoutDescriptor[];\n readonly targets: readonly GPUColorTargetState[];\n /** K6.6 (level sets, points): optional depth state, primitive state and vertex buffers (default: none, triangle-list). */\n readonly depthStencil?: GPUDepthStencilState;\n readonly primitive?: GPUPrimitiveState;\n readonly buffers?: readonly GPUVertexBufferLayout[];\n}\n\n/** The pipeline-state part of a render spec's key and descriptor (K6.6); empty for the composite. */\nconst renderState = (s: VDBRenderSpec) => (s.depthStencil || s.primitive || s.buffers ? `:${vdbHashText(JSON.stringify([s.depthStencil ?? null, s.primitive ?? null, s.buffers ?? null]))}` : \"\");\n\nfunction renderDescriptor(spec: VDBRenderSpec, module: GPUShaderModule, layout: GPUPipelineLayout): GPURenderPipelineDescriptor {\n return {\n label: spec.label,\n layout,\n vertex: { module, entryPoint: spec.vertexEntryPoint, ...(spec.buffers ? { buffers: [...spec.buffers] } : {}) },\n fragment: { module, entryPoint: spec.fragmentEntryPoint, targets: [...spec.targets] },\n primitive: spec.primitive ?? { topology: \"triangle-list\" },\n ...(spec.depthStencil ? { depthStencil: spec.depthStencil } : {}),\n };\n}\n\n/** A built pipeline with its group layouts and the validation result of its creation. */\nexport interface VDBCachedPipeline<P> {\n readonly pipeline: P;\n readonly layouts: readonly GPUBindGroupLayout[];\n /** Resolves null when valid, else the first validation error (also logged once). */\n readonly error: Promise<GPUError | null>;\n}\n\ntype AnyPipeline = VDBCachedPipeline<GPUComputePipeline> | VDBCachedPipeline<GPURenderPipeline>;\nconst caches = new WeakMap<GPUDevice, Map<string, AnyPipeline | Promise<AnyPipeline>>>();\n\nconst layoutKey = (groups: readonly GPUBindGroupLayoutDescriptor[]) =>\n JSON.stringify(groups.map((g) => [...g.entries].sort((x, y) => x.binding - y.binding)));\n\n/** The cache key of a compute spec. */\nexport const computeKey = (s: VDBComputeSpec) => `c:${s.entryPoint}:${vdbHashText(s.code)}:${vdbHashText(layoutKey(s.groups))}`;\n/** The cache key of a render spec. */\nexport const renderKey = (s: VDBRenderSpec) =>\n `r:${s.vertexEntryPoint}:${s.fragmentEntryPoint}:${vdbHashText(s.code)}:${vdbHashText(layoutKey(s.groups))}:${vdbHashText(JSON.stringify(s.targets))}${renderState(s)}`;\n\nfunction cacheOf(device: GPUDevice): Map<string, AnyPipeline | Promise<AnyPipeline>> {\n let c = caches.get(device);\n if (!c) caches.set(device, (c = new Map()));\n return c;\n}\n\nfunction checkGroups(label: string, groups: readonly GPUBindGroupLayoutDescriptor[]): void {\n if (groups.length > 4) throw new VDBError(\"VDB_BAD_OPTION\", `${label}: ${groups.length} bind groups exceed maxBindGroups (4).`);\n}\n\nfunction logged(label: string, error: Promise<GPUError | null>): Promise<GPUError | null> {\n return error.then((e) => {\n if (e) console.error(`@pmndrs/vdb frame renderer: ${label}: ${e.message}`);\n return e;\n });\n}\n\nfunction layoutsOf(device: GPUDevice, label: string, groups: readonly GPUBindGroupLayoutDescriptor[]): GPUBindGroupLayout[] {\n return groups.map((g, i) => device.createBindGroupLayout({ ...g, label: `${label} group ${i}` }));\n}\n\n/** The compute pipeline of `spec` on `device`, built once (synchronously) per device and key. */\nexport function computePipeline(device: GPUDevice, spec: VDBComputeSpec): VDBCachedPipeline<GPUComputePipeline> {\n const cache = cacheOf(device);\n const key = computeKey(spec);\n const hit = cache.get(key);\n if (hit && !(hit instanceof Promise)) return hit as VDBCachedPipeline<GPUComputePipeline>;\n checkGroups(spec.label, spec.groups);\n device.pushErrorScope(\"validation\");\n const layouts = layoutsOf(device, spec.label, spec.groups);\n const module = device.createShaderModule({ label: spec.label, code: spec.code });\n const pipeline = device.createComputePipeline({\n label: spec.label,\n layout: device.createPipelineLayout({ label: spec.label, bindGroupLayouts: layouts }),\n compute: { module, entryPoint: spec.entryPoint },\n });\n const built = { pipeline, layouts, error: logged(spec.label, device.popErrorScope()) };\n cache.set(key, built);\n return built;\n}\n\n/** The render pipeline of `spec` on `device`, built once (synchronously) per device and key. */\nexport function renderPipeline(device: GPUDevice, spec: VDBRenderSpec): VDBCachedPipeline<GPURenderPipeline> {\n const cache = cacheOf(device);\n const key = renderKey(spec);\n const hit = cache.get(key);\n if (hit && !(hit instanceof Promise)) return hit as VDBCachedPipeline<GPURenderPipeline>;\n checkGroups(spec.label, spec.groups);\n device.pushErrorScope(\"validation\");\n const layouts = layoutsOf(device, spec.label, spec.groups);\n const module = device.createShaderModule({ label: spec.label, code: spec.code });\n const pipeline = device.createRenderPipeline(renderDescriptor(spec, module, device.createPipelineLayout({ label: spec.label, bindGroupLayouts: layouts })));\n const built = { pipeline, layouts, error: logged(spec.label, device.popErrorScope()) };\n cache.set(key, built);\n return built;\n}\n\n/** Builds `spec` with `createComputePipelineAsync` into the cache (no-op when cached). */\nexport async function prepareCompute(device: GPUDevice, spec: VDBComputeSpec): Promise<void> {\n const cache = cacheOf(device);\n const key = computeKey(spec);\n const hit = cache.get(key);\n if (hit) {\n await hit;\n return;\n }\n checkGroups(spec.label, spec.groups);\n const job = (async (): Promise<AnyPipeline> => {\n device.pushErrorScope(\"validation\");\n const layouts = layoutsOf(device, spec.label, spec.groups);\n const module = device.createShaderModule({ label: spec.label, code: spec.code });\n const layout = device.createPipelineLayout({ label: spec.label, bindGroupLayouts: layouts });\n const scope = device.popErrorScope();\n const pipeline = await device.createComputePipelineAsync({ label: spec.label, layout, compute: { module, entryPoint: spec.entryPoint } });\n return { pipeline, layouts, error: logged(spec.label, scope) };\n })();\n await settle(cache, key, job);\n}\n\n/** Caches `job` under `key`, then its result; a failed build leaves no entry and rethrows. */\nasync function settle(cache: Map<string, AnyPipeline | Promise<AnyPipeline>>, key: string, job: Promise<AnyPipeline>): Promise<void> {\n cache.set(key, job);\n try {\n cache.set(key, await job);\n } catch (e) {\n cache.delete(key);\n throw e;\n }\n}\n\n/** Builds `spec` with `createRenderPipelineAsync` into the cache (no-op when cached). */\nexport async function prepareRender(device: GPUDevice, spec: VDBRenderSpec): Promise<void> {\n const cache = cacheOf(device);\n const key = renderKey(spec);\n const hit = cache.get(key);\n if (hit) {\n await hit;\n return;\n }\n checkGroups(spec.label, spec.groups);\n const job = (async (): Promise<AnyPipeline> => {\n device.pushErrorScope(\"validation\");\n const layouts = layoutsOf(device, spec.label, spec.groups);\n const module = device.createShaderModule({ label: spec.label, code: spec.code });\n const layout = device.createPipelineLayout({ label: spec.label, bindGroupLayouts: layouts });\n const scope = device.popErrorScope();\n const pipeline = await device.createRenderPipelineAsync(renderDescriptor(spec, module, layout));\n return { pipeline, layouts, error: logged(spec.label, scope) };\n })();\n await settle(cache, key, job);\n}\n"]}