@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.
- package/CHANGELOG.md +592 -2
- package/README.md +85 -37
- package/THIRD_PARTY_NOTICES.md +197 -29
- package/dist/core/compute/atlas.d.ts +10 -2
- package/dist/core/compute/atlas.js +6 -1
- package/dist/core/compute/atlas.js.map +1 -1
- package/dist/core/compute/index.d.ts +3 -3
- package/dist/core/compute/index.js +2 -2
- package/dist/core/compute/index.js.map +1 -1
- package/dist/core/compute/majorant-build.d.ts +45 -0
- package/dist/core/compute/majorant-build.js +193 -0
- package/dist/core/compute/majorant-build.js.map +1 -0
- package/dist/core/compute/multi-scale.d.ts +155 -0
- package/dist/core/compute/multi-scale.js +684 -0
- package/dist/core/compute/multi-scale.js.map +1 -0
- package/dist/core/compute/pyramid.d.ts +22 -7
- package/dist/core/compute/pyramid.js +22 -9
- package/dist/core/compute/pyramid.js.map +1 -1
- package/dist/core/compute/shared.d.ts +1 -0
- package/dist/core/compute/shared.js.map +1 -1
- package/dist/core/compute/stats.d.ts +10 -3
- package/dist/core/compute/stats.js +6 -1
- package/dist/core/compute/stats.js.map +1 -1
- package/dist/core/compute/value-transform.d.ts +8 -1
- package/dist/core/compute/value-transform.js +9 -3
- package/dist/core/compute/value-transform.js.map +1 -1
- package/dist/core/errors.d.ts +10 -0
- package/dist/core/errors.js +8 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/frame/emission.d.ts +85 -0
- package/dist/core/frame/emission.js +422 -0
- package/dist/core/frame/emission.js.map +1 -0
- package/dist/core/frame/environment.d.ts +47 -0
- package/dist/core/frame/environment.js +178 -0
- package/dist/core/frame/environment.js.map +1 -0
- package/dist/core/frame/index.d.ts +39 -0
- package/dist/core/frame/index.js +27 -0
- package/dist/core/frame/index.js.map +1 -0
- package/dist/core/frame/kernels.d.ts +115 -0
- package/dist/core/frame/kernels.js +496 -0
- package/dist/core/frame/kernels.js.map +1 -0
- package/dist/core/frame/limits.d.ts +67 -0
- package/dist/core/frame/limits.js +109 -0
- package/dist/core/frame/limits.js.map +1 -0
- package/dist/core/frame/phase.d.ts +17 -0
- package/dist/core/frame/phase.js +53 -0
- package/dist/core/frame/phase.js.map +1 -0
- package/dist/core/frame/pipelines.d.ts +49 -0
- package/dist/core/frame/pipelines.js +147 -0
- package/dist/core/frame/pipelines.js.map +1 -0
- package/dist/core/frame/renderer.d.ts +122 -0
- package/dist/core/frame/renderer.js +1712 -0
- package/dist/core/frame/renderer.js.map +1 -0
- package/dist/core/frame/resources.d.ts +71 -0
- package/dist/core/frame/resources.js +100 -0
- package/dist/core/frame/resources.js.map +1 -0
- package/dist/core/frame/scattering.d.ts +97 -0
- package/dist/core/frame/scattering.js +332 -0
- package/dist/core/frame/scattering.js.map +1 -0
- package/dist/core/frame/settings.d.ts +243 -0
- package/dist/core/frame/settings.js +67 -0
- package/dist/core/frame/settings.js.map +1 -0
- package/dist/core/frame/shadows.d.ts +55 -0
- package/dist/core/frame/shadows.js +460 -0
- package/dist/core/frame/shadows.js.map +1 -0
- package/dist/core/frame/types.d.ts +415 -0
- package/dist/core/frame/types.js +49 -0
- package/dist/core/frame/types.js.map +1 -0
- package/dist/core/frame/uniforms.d.ts +105 -0
- package/dist/core/frame/uniforms.js +276 -0
- package/dist/core/frame/uniforms.js.map +1 -0
- package/dist/core/frame/wgsl/chunks.d.ts +4 -0
- package/dist/core/frame/wgsl/chunks.js +728 -0
- package/dist/core/frame/wgsl/chunks.js.map +1 -0
- package/dist/core/frame/wgsl/emission.d.ts +82 -0
- package/dist/core/frame/wgsl/emission.js +353 -0
- package/dist/core/frame/wgsl/emission.js.map +1 -0
- package/dist/core/frame/wgsl/environment.d.ts +42 -0
- package/dist/core/frame/wgsl/environment.js +711 -0
- package/dist/core/frame/wgsl/environment.js.map +1 -0
- package/dist/core/frame/wgsl/gather.d.ts +55 -0
- package/dist/core/frame/wgsl/gather.js +850 -0
- package/dist/core/frame/wgsl/gather.js.map +1 -0
- package/dist/core/frame/wgsl/integrate.d.ts +78 -0
- package/dist/core/frame/wgsl/integrate.js +213 -0
- package/dist/core/frame/wgsl/integrate.js.map +1 -0
- package/dist/core/frame/wgsl/lighting.d.ts +103 -0
- package/dist/core/frame/wgsl/lighting.js +1636 -0
- package/dist/core/frame/wgsl/lighting.js.map +1 -0
- package/dist/core/frame/wgsl/occluders.d.ts +20 -0
- package/dist/core/frame/wgsl/occluders.js +95 -0
- package/dist/core/frame/wgsl/occluders.js.map +1 -0
- package/dist/core/frame/wgsl/resolve.d.ts +19 -0
- package/dist/core/frame/wgsl/resolve.js +205 -0
- package/dist/core/frame/wgsl/resolve.js.map +1 -0
- package/dist/core/frame/wgsl/shadows.d.ts +35 -0
- package/dist/core/frame/wgsl/shadows.js +328 -0
- package/dist/core/frame/wgsl/shadows.js.map +1 -0
- package/dist/core/half.d.ts +11 -0
- package/dist/core/half.js +22 -0
- package/dist/core/half.js.map +1 -0
- package/dist/core/index.d.ts +25 -3
- package/dist/core/index.js +23 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/internal.d.ts +17 -1
- package/dist/core/internal.js +18 -1
- package/dist/core/internal.js.map +1 -1
- package/dist/core/pool/image-header.d.ts +13 -2
- package/dist/core/pool/image-header.js +24 -5
- package/dist/core/pool/image-header.js.map +1 -1
- package/dist/core/pool/layout.d.ts +35 -1
- package/dist/core/pool/layout.js +51 -2
- package/dist/core/pool/layout.js.map +1 -1
- package/dist/core/pool/limits.d.ts +1 -0
- package/dist/core/pool/limits.js +1 -0
- package/dist/core/pool/limits.js.map +1 -1
- package/dist/core/pool/pool.d.ts +120 -15
- package/dist/core/pool/pool.js +255 -24
- package/dist/core/pool/pool.js.map +1 -1
- package/dist/core/reference/index.d.ts +6 -0
- package/dist/core/reference/index.js +7 -0
- package/dist/core/reference/index.js.map +1 -0
- package/dist/core/reference/renderer.d.ts +105 -0
- package/dist/core/reference/renderer.js +474 -0
- package/dist/core/reference/renderer.js.map +1 -0
- package/dist/core/reference/wgsl.d.ts +65 -0
- package/dist/core/reference/wgsl.js +803 -0
- package/dist/core/reference/wgsl.js.map +1 -0
- package/dist/{three → core}/sequence.d.ts +32 -2
- package/dist/{three → core}/sequence.js +24 -2
- package/dist/core/sequence.js.map +1 -0
- package/dist/core/source/brick-cache.d.ts +165 -0
- package/dist/core/source/brick-cache.js +627 -0
- package/dist/core/source/brick-cache.js.map +1 -0
- package/dist/core/source/dense-fill.d.ts +53 -0
- package/dist/core/source/dense-fill.js +377 -0
- package/dist/core/source/dense-fill.js.map +1 -0
- package/dist/core/source/dense.d.ts +33 -2
- package/dist/core/source/dense.js +121 -24
- package/dist/core/source/dense.js.map +1 -1
- package/dist/core/source/sparse-wgsl.d.ts +92 -0
- package/dist/core/source/sparse-wgsl.js +481 -0
- package/dist/core/source/sparse-wgsl.js.map +1 -0
- package/dist/core/source/sparse.d.ts +192 -0
- package/dist/core/source/sparse.js +762 -0
- package/dist/core/source/sparse.js.map +1 -0
- package/dist/core/source/types.d.ts +59 -2
- package/dist/core/source/types.js.map +1 -1
- package/dist/core/surface/index.d.ts +10 -0
- package/dist/core/surface/index.js +9 -0
- package/dist/core/surface/index.js.map +1 -0
- package/dist/core/surface/level-set-pass.d.ts +140 -0
- package/dist/core/surface/level-set-pass.js +291 -0
- package/dist/core/surface/level-set-pass.js.map +1 -0
- package/dist/core/surface/level-set-wgsl.d.ts +46 -0
- package/dist/core/surface/level-set-wgsl.js +99 -0
- package/dist/core/surface/level-set-wgsl.js.map +1 -0
- package/dist/core/surface/points.d.ts +109 -0
- package/dist/core/surface/points.js +226 -0
- package/dist/core/surface/points.js.map +1 -0
- package/dist/core/types.d.ts +12 -3
- package/dist/core/types.js +6 -2
- package/dist/core/types.js.map +1 -1
- package/dist/core/wgsl/api.d.ts +29 -5
- package/dist/core/wgsl/api.js +110 -27
- package/dist/core/wgsl/api.js.map +1 -1
- package/dist/core/wgsl/generate.d.ts +8 -0
- package/dist/core/wgsl/generate.js +195 -22
- package/dist/core/wgsl/generate.js.map +1 -1
- package/dist/core/wgsl/lean.d.ts +50 -0
- package/dist/core/wgsl/lean.js +327 -0
- package/dist/core/wgsl/lean.js.map +1 -0
- package/dist/core/wgsl/level-set.d.ts +5 -1
- package/dist/core/wgsl/level-set.js +11 -5
- package/dist/core/wgsl/level-set.js.map +1 -1
- package/dist/core/wgsl/majorant.d.ts +62 -0
- package/dist/core/wgsl/majorant.js +381 -0
- package/dist/core/wgsl/majorant.js.map +1 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +2 -2
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +15 -12
- package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -1
- package/dist/core/wgsl/types.d.ts +97 -3
- package/dist/core/wgsl/types.js.map +1 -1
- package/dist/three/coarse-first.d.ts +53 -8
- package/dist/three/coarse-first.js +24 -6
- package/dist/three/coarse-first.js.map +1 -1
- package/dist/three/compute.d.ts +12 -2
- package/dist/three/compute.js +16 -6
- package/dist/three/compute.js.map +1 -1
- package/dist/three/device.d.ts +7 -0
- package/dist/three/device.js +3 -0
- package/dist/three/device.js.map +1 -1
- package/dist/three/frame/core-environment.d.ts +38 -0
- package/dist/three/frame/core-environment.js +154 -0
- package/dist/three/frame/core-environment.js.map +1 -0
- package/dist/three/frame/core-integrate-material.d.ts +34 -0
- package/dist/three/frame/core-integrate-material.js +162 -0
- package/dist/three/frame/core-integrate-material.js.map +1 -0
- package/dist/three/frame/core-occluders.d.ts +53 -0
- package/dist/three/frame/core-occluders.js +193 -0
- package/dist/three/frame/core-occluders.js.map +1 -0
- package/dist/three/frame/core-structs.d.ts +34 -0
- package/dist/three/frame/core-structs.js +61 -0
- package/dist/three/frame/core-structs.js.map +1 -0
- package/dist/three/frame/core-textures.d.ts +41 -0
- package/dist/three/frame/core-textures.js +114 -0
- package/dist/three/frame/core-textures.js.map +1 -0
- package/dist/three/frame/emission-light.d.ts +64 -114
- package/dist/three/frame/emission-light.js +188 -567
- package/dist/three/frame/emission-light.js.map +1 -1
- package/dist/three/frame/index.d.ts +11 -31
- package/dist/three/frame/index.js +9 -29
- package/dist/three/frame/index.js.map +1 -1
- package/dist/three/frame/medium.d.ts +12 -0
- package/dist/three/frame/medium.js.map +1 -1
- package/dist/three/frame/renderer.d.ts +58 -454
- package/dist/three/frame/renderer.js +409 -1427
- package/dist/three/frame/renderer.js.map +1 -1
- package/dist/three/frame/spectrum.d.ts +0 -14
- package/dist/three/frame/spectrum.js +2 -23
- package/dist/three/frame/spectrum.js.map +1 -1
- package/dist/three/frame/three-internals.d.ts +3 -8
- package/dist/three/frame/three-internals.js +13 -11
- package/dist/three/frame/three-internals.js.map +1 -1
- package/dist/three/frame/volume-shadows.d.ts +93 -107
- package/dist/three/frame/volume-shadows.js +278 -631
- package/dist/three/frame/volume-shadows.js.map +1 -1
- package/dist/three/frame/volume.d.ts +91 -33
- package/dist/three/frame/volume.js +63 -51
- package/dist/three/frame/volume.js.map +1 -1
- package/dist/three/grid-node.d.ts +34 -1
- package/dist/three/grid-node.js +36 -1
- package/dist/three/grid-node.js.map +1 -1
- package/dist/three/index.d.ts +20 -11
- package/dist/three/index.js +21 -12
- package/dist/three/index.js.map +1 -1
- package/dist/three/internal.d.ts +14 -8
- package/dist/three/internal.js +11 -7
- package/dist/three/internal.js.map +1 -1
- package/dist/three/level-set-material.d.ts +81 -8
- package/dist/three/level-set-material.js +162 -125
- package/dist/three/level-set-material.js.map +1 -1
- package/dist/three/level-set-physical-material.d.ts +154 -0
- package/dist/three/level-set-physical-material.js +253 -0
- package/dist/three/level-set-physical-material.js.map +1 -0
- package/dist/three/level-set-velocity.d.ts +94 -0
- package/dist/three/level-set-velocity.js +208 -0
- package/dist/three/level-set-velocity.js.map +1 -0
- package/dist/three/material.d.ts +141 -11
- package/dist/three/material.js +161 -18
- package/dist/three/material.js.map +1 -1
- package/dist/three/points.d.ts +60 -4
- package/dist/three/points.js +140 -9
- package/dist/three/points.js.map +1 -1
- package/dist/three/sparse-source.d.ts +49 -117
- package/dist/three/sparse-source.js +109 -580
- package/dist/three/sparse-source.js.map +1 -1
- package/dist/three/volume-source.d.ts +11 -156
- package/dist/three/volume-source.js +29 -272
- package/dist/three/volume-source.js.map +1 -1
- package/dist/tools/cpu/brick-atlas.d.ts +36 -0
- package/dist/tools/cpu/brick-atlas.js +129 -0
- package/dist/tools/cpu/brick-atlas.js.map +1 -0
- package/dist/tools/cpu/compute.d.ts +23 -4
- package/dist/tools/cpu/compute.js +35 -14
- package/dist/tools/cpu/compute.js.map +1 -1
- package/dist/tools/cpu/lean-reads.d.ts +81 -0
- package/dist/tools/cpu/lean-reads.js +262 -0
- package/dist/tools/cpu/lean-reads.js.map +1 -0
- package/dist/tools/cpu/level-set.d.ts +42 -3
- package/dist/tools/cpu/level-set.js +59 -7
- package/dist/tools/cpu/level-set.js.map +1 -1
- package/dist/tools/cpu/majorant.d.ts +265 -0
- package/dist/tools/cpu/majorant.js +541 -0
- package/dist/tools/cpu/majorant.js.map +1 -0
- package/dist/tools/cpu/march.d.ts +93 -2
- package/dist/tools/cpu/march.js +165 -14
- package/dist/tools/cpu/march.js.map +1 -1
- package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
- package/dist/tools/cpu/mesh-decimate.js +1225 -0
- package/dist/tools/cpu/mesh-decimate.js.map +1 -0
- package/dist/tools/cpu/points.d.ts +29 -0
- package/dist/tools/cpu/points.js +38 -0
- package/dist/tools/cpu/points.js.map +1 -0
- package/dist/tools/cpu/read-value.d.ts +19 -6
- package/dist/tools/cpu/read-value.js +32 -17
- package/dist/tools/cpu/read-value.js.map +1 -1
- package/dist/tools/cpu/sample-trilinear.d.ts +17 -4
- package/dist/tools/cpu/sample-trilinear.js +19 -7
- package/dist/tools/cpu/sample-trilinear.js.map +1 -1
- package/dist/tools/cpu/stride-tables.d.ts +2 -2
- package/dist/tools/cpu/stride-tables.generated.d.ts +6 -5
- package/dist/tools/cpu/stride-tables.generated.js +7 -6
- package/dist/tools/cpu/stride-tables.generated.js.map +1 -1
- package/dist/tools/cpu/stride-tables.js +1 -1
- package/dist/tools/cpu/stride-tables.js.map +1 -1
- package/dist/tools/cpu/surface-nets.d.ts +90 -0
- package/dist/tools/cpu/surface-nets.js +597 -0
- package/dist/tools/cpu/surface-nets.js.map +1 -0
- package/dist/tools/errors.d.ts +9 -0
- package/dist/tools/errors.js +9 -0
- package/dist/tools/errors.js.map +1 -1
- package/dist/tools/frame/ambient.d.ts +98 -0
- package/dist/tools/frame/ambient.js +274 -0
- package/dist/tools/frame/ambient.js.map +1 -0
- package/dist/tools/frame/blackbody.d.ts +15 -0
- package/dist/tools/frame/blackbody.js +35 -0
- package/dist/tools/frame/blackbody.js.map +1 -1
- package/dist/tools/frame/brick-cache.d.ts +165 -0
- package/dist/tools/frame/brick-cache.js +326 -0
- package/dist/tools/frame/brick-cache.js.map +1 -0
- package/dist/tools/frame/emission.d.ts +9 -0
- package/dist/tools/frame/emission.js +9 -1
- package/dist/tools/frame/emission.js.map +1 -1
- package/dist/tools/frame/environment-gpu.d.ts +111 -0
- package/dist/tools/frame/environment-gpu.js +280 -0
- package/dist/tools/frame/environment-gpu.js.map +1 -0
- package/dist/tools/frame/environment.d.ts +3 -2
- package/dist/tools/frame/environment.js +8 -4
- package/dist/tools/frame/environment.js.map +1 -1
- package/dist/tools/frame/froxel.d.ts +58 -0
- package/dist/tools/frame/froxel.js +115 -0
- package/dist/tools/frame/froxel.js.map +1 -0
- package/dist/tools/frame/grid.d.ts +90 -0
- package/dist/tools/frame/grid.js +112 -13
- package/dist/tools/frame/grid.js.map +1 -1
- package/dist/tools/frame/index.d.ts +14 -0
- package/dist/tools/frame/index.js +45 -4
- package/dist/tools/frame/index.js.map +1 -1
- package/dist/tools/frame/medium.d.ts +16 -0
- package/dist/tools/frame/medium.js +3 -1
- package/dist/tools/frame/medium.js.map +1 -1
- package/dist/tools/frame/mie.d.ts +9 -0
- package/dist/tools/frame/mie.js +18 -0
- package/dist/tools/frame/mie.js.map +1 -1
- package/dist/tools/frame/mlp-nn.d.ts +36 -0
- package/dist/tools/frame/mlp-nn.js +159 -0
- package/dist/tools/frame/mlp-nn.js.map +1 -0
- package/dist/tools/frame/mlp-tza.d.ts +29 -0
- package/dist/tools/frame/mlp-tza.js +186 -0
- package/dist/tools/frame/mlp-tza.js.map +1 -0
- package/dist/tools/frame/mlp.d.ts +183 -0
- package/dist/tools/frame/mlp.js +434 -0
- package/dist/tools/frame/mlp.js.map +1 -0
- package/dist/tools/frame/ms-exit.d.ts +42 -0
- package/dist/tools/frame/ms-exit.js +90 -0
- package/dist/tools/frame/ms-exit.js.map +1 -0
- package/dist/tools/frame/multi-scale.d.ts +152 -0
- package/dist/tools/frame/multi-scale.js +302 -0
- package/dist/tools/frame/multi-scale.js.map +1 -0
- package/dist/tools/frame/neural-weights.d.ts +6 -5
- package/dist/tools/frame/neural-weights.js +234 -235
- package/dist/tools/frame/neural-weights.js.map +1 -1
- package/dist/tools/frame/neural.js +1 -1
- package/dist/tools/frame/neural.js.map +1 -1
- package/dist/tools/frame/occluders.d.ts +51 -0
- package/dist/tools/frame/occluders.js +72 -0
- package/dist/tools/frame/occluders.js.map +1 -0
- package/dist/tools/frame/pyramid-layout.d.ts +17 -0
- package/dist/tools/frame/pyramid-layout.js +47 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -1
- package/dist/tools/frame/shadows.d.ts +110 -0
- package/dist/tools/frame/shadows.js +286 -0
- package/dist/tools/frame/shadows.js.map +1 -1
- package/dist/tools/frame/sparse.d.ts +82 -0
- package/dist/tools/frame/sparse.js +242 -1
- package/dist/tools/frame/sparse.js.map +1 -1
- package/dist/tools/frame/spectral-stack.d.ts +159 -0
- package/dist/tools/frame/spectral-stack.js +391 -0
- package/dist/tools/frame/spectral-stack.js.map +1 -0
- package/dist/tools/frame/spectral.d.ts +21 -2
- package/dist/tools/frame/spectral.js +30 -8
- package/dist/tools/frame/spectral.js.map +1 -1
- package/dist/tools/frame/stack.d.ts +115 -0
- package/dist/tools/frame/stack.js +290 -0
- package/dist/tools/frame/stack.js.map +1 -0
- package/dist/tools/frame/view.d.ts +131 -0
- package/dist/tools/frame/view.js +337 -0
- package/dist/tools/frame/view.js.map +1 -0
- package/dist/tools/index.d.ts +66 -15
- package/dist/tools/index.js +55 -11
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/internal.d.ts +58 -17
- package/dist/tools/internal.js +65 -11
- package/dist/tools/internal.js.map +1 -1
- package/dist/tools/nanovdb/build-from-vdb.d.ts +11 -2
- package/dist/tools/nanovdb/build-from-vdb.js +10 -2
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -1
- package/dist/tools/nanovdb/bytes.d.ts +17 -4
- package/dist/tools/nanovdb/bytes.js +46 -3
- package/dist/tools/nanovdb/bytes.js.map +1 -1
- package/dist/tools/nanovdb/coarse-first.d.ts +19 -3
- package/dist/tools/nanovdb/coarse-first.js +7 -1
- package/dist/tools/nanovdb/coarse-first.js.map +1 -1
- package/dist/tools/nanovdb/half.d.ts +22 -0
- package/dist/tools/nanovdb/half.js +73 -0
- package/dist/tools/nanovdb/half.js.map +1 -0
- package/dist/tools/nanovdb/index.d.ts +3 -1
- package/dist/tools/nanovdb/index.js +2 -1
- package/dist/tools/nanovdb/index.js.map +1 -1
- package/dist/tools/nanovdb/inspect.d.ts +10 -1
- package/dist/tools/nanovdb/inspect.js +8 -1
- package/dist/tools/nanovdb/inspect.js.map +1 -1
- package/dist/tools/nanovdb/leaf-codec.d.ts +35 -1
- package/dist/tools/nanovdb/leaf-codec.js +40 -4
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -1
- package/dist/tools/nanovdb/quantize.d.ts +39 -10
- package/dist/tools/nanovdb/quantize.js +96 -44
- package/dist/tools/nanovdb/quantize.js.map +1 -1
- package/dist/tools/nanovdb/resample.d.ts +20 -3
- package/dist/tools/nanovdb/resample.js +20 -7
- package/dist/tools/nanovdb/resample.js.map +1 -1
- package/dist/tools/nanovdb/serialize.d.ts +34 -3
- package/dist/tools/nanovdb/serialize.js +51 -7
- package/dist/tools/nanovdb/serialize.js.map +1 -1
- package/dist/tools/nanovdb/stats.d.ts +34 -5
- package/dist/tools/nanovdb/stats.js +87 -11
- package/dist/tools/nanovdb/stats.js.map +1 -1
- package/dist/tools/nanovdb/transform.d.ts +4 -0
- package/dist/tools/nanovdb/transform.js +3 -0
- package/dist/tools/nanovdb/transform.js.map +1 -1
- package/dist/tools/nanovdb/tree.d.ts +14 -3
- package/dist/tools/nanovdb/tree.js +25 -13
- package/dist/tools/nanovdb/tree.js.map +1 -1
- package/dist/tools/nanovdb/write-nvdb.d.ts +47 -12
- package/dist/tools/nanovdb/write-nvdb.js +108 -28
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -1
- package/dist/tools/nvdb-file.d.ts +77 -7
- package/dist/tools/nvdb-file.js +177 -20
- package/dist/tools/nvdb-file.js.map +1 -1
- package/dist/tools/nvdb-stream.d.ts +23 -7
- package/dist/tools/nvdb-stream.js +78 -34
- package/dist/tools/nvdb-stream.js.map +1 -1
- package/dist/tools/reference/analytic.d.ts +41 -0
- package/dist/tools/reference/analytic.js +95 -0
- package/dist/tools/reference/analytic.js.map +1 -0
- package/dist/tools/reference/environment.d.ts +62 -0
- package/dist/tools/reference/environment.js +154 -0
- package/dist/tools/reference/environment.js.map +1 -0
- package/dist/tools/reference/index.d.ts +12 -0
- package/dist/tools/reference/index.js +13 -0
- package/dist/tools/reference/index.js.map +1 -0
- package/dist/tools/reference/media.d.ts +14 -0
- package/dist/tools/reference/media.js +30 -0
- package/dist/tools/reference/media.js.map +1 -0
- package/dist/tools/reference/rng.d.ts +20 -0
- package/dist/tools/reference/rng.js +30 -0
- package/dist/tools/reference/rng.js.map +1 -0
- package/dist/tools/reference/scene.d.ts +312 -0
- package/dist/tools/reference/scene.js +169 -0
- package/dist/tools/reference/scene.js.map +1 -0
- package/dist/tools/reference/tables.d.ts +98 -0
- package/dist/tools/reference/tables.js +264 -0
- package/dist/tools/reference/tables.js.map +1 -0
- package/dist/tools/reference/trace.d.ts +160 -0
- package/dist/tools/reference/trace.js +497 -0
- package/dist/tools/reference/trace.js.map +1 -0
- package/dist/tools/vdb/blosc-write.d.ts +43 -0
- package/dist/tools/vdb/blosc-write.js +197 -0
- package/dist/tools/vdb/blosc-write.js.map +1 -0
- package/dist/tools/vdb/blosc.d.ts +35 -5
- package/dist/tools/vdb/blosc.js +82 -26
- package/dist/tools/vdb/blosc.js.map +1 -1
- package/dist/tools/vdb/blosclz.d.ts +33 -0
- package/dist/tools/vdb/blosclz.js +112 -0
- package/dist/tools/vdb/blosclz.js.map +1 -0
- package/dist/tools/vdb/byte-reader.d.ts +13 -3
- package/dist/tools/vdb/byte-reader.js +26 -4
- package/dist/tools/vdb/byte-reader.js.map +1 -1
- package/dist/tools/vdb/compression.d.ts +13 -5
- package/dist/tools/vdb/compression.js +13 -2
- package/dist/tools/vdb/compression.js.map +1 -1
- package/dist/tools/vdb/grid.js +8 -2
- package/dist/tools/vdb/grid.js.map +1 -1
- package/dist/tools/vdb/index.d.ts +2 -1
- package/dist/tools/vdb/index.js.map +1 -1
- package/dist/tools/vdb/lz4.d.ts +30 -0
- package/dist/tools/vdb/lz4.js +228 -0
- package/dist/tools/vdb/lz4.js.map +1 -0
- package/dist/tools/vdb/metadata.js +1 -1
- package/dist/tools/vdb/metadata.js.map +1 -1
- package/dist/tools/vdb/parse.d.ts +24 -2
- package/dist/tools/vdb/parse.js +102 -32
- package/dist/tools/vdb/parse.js.map +1 -1
- package/dist/tools/vdb/point-render-data.d.ts +49 -1
- package/dist/tools/vdb/point-render-data.js +91 -11
- package/dist/tools/vdb/point-render-data.js.map +1 -1
- package/dist/tools/vdb/points.d.ts +26 -0
- package/dist/tools/vdb/points.js +46 -5
- package/dist/tools/vdb/points.js.map +1 -1
- package/dist/tools/vdb/types.d.ts +59 -2
- package/dist/tools/vdb/types.js.map +1 -1
- package/dist/tools/wvdb/bake.d.ts +38 -9
- package/dist/tools/wvdb/bake.js +63 -13
- package/dist/tools/wvdb/bake.js.map +1 -1
- package/dist/tools/wvdb/dense.d.ts +80 -1
- package/dist/tools/wvdb/dense.js +67 -8
- package/dist/tools/wvdb/dense.js.map +1 -1
- package/dist/tools/wvdb/format.d.ts +59 -0
- package/dist/tools/wvdb/format.js +3 -0
- package/dist/tools/wvdb/format.js.map +1 -1
- package/dist/tools/wvdb/index.d.ts +1 -0
- package/dist/tools/wvdb/index.js +1 -0
- package/dist/tools/wvdb/index.js.map +1 -1
- package/dist/tools/wvdb/level-set.d.ts +10 -2
- package/dist/tools/wvdb/level-set.js.map +1 -1
- package/dist/tools/wvdb/nanovdb.d.ts +6 -1
- package/dist/tools/wvdb/nanovdb.js +5 -1
- package/dist/tools/wvdb/nanovdb.js.map +1 -1
- package/dist/tools/wvdb/partial.d.ts +74 -0
- package/dist/tools/wvdb/partial.js +233 -0
- package/dist/tools/wvdb/partial.js.map +1 -0
- package/dist/tools/wvdb/read.d.ts +77 -1
- package/dist/tools/wvdb/read.js +30 -7
- package/dist/tools/wvdb/read.js.map +1 -1
- package/dist/tools/wvdb/write.d.ts +23 -1
- package/dist/tools/wvdb/write.js +8 -1
- package/dist/tools/wvdb/write.js.map +1 -1
- package/package.json +2 -1
- package/vendor/VENDOR.md +21 -6
- package/vendor/pnanovdb.wgsl +52 -14
- package/dist/three/frame/blackbody.d.ts +0 -42
- package/dist/three/frame/blackbody.js +0 -74
- package/dist/three/frame/blackbody.js.map +0 -1
- package/dist/three/frame/chunks.d.ts +0 -157
- package/dist/three/frame/chunks.js +0 -559
- package/dist/three/frame/chunks.js.map +0 -1
- package/dist/three/frame/density-material.d.ts +0 -53
- package/dist/three/frame/density-material.js +0 -353
- package/dist/three/frame/density-material.js.map +0 -1
- package/dist/three/frame/environment-grid-material.d.ts +0 -21
- package/dist/three/frame/environment-grid-material.js +0 -184
- package/dist/three/frame/environment-grid-material.js.map +0 -1
- package/dist/three/frame/environment-material.d.ts +0 -22
- package/dist/three/frame/environment-material.js +0 -87
- package/dist/three/frame/environment-material.js.map +0 -1
- package/dist/three/frame/grid-mip-material.d.ts +0 -12
- package/dist/three/frame/grid-mip-material.js +0 -61
- package/dist/three/frame/grid-mip-material.js.map +0 -1
- package/dist/three/frame/inject-material.d.ts +0 -56
- package/dist/three/frame/inject-material.js +0 -424
- package/dist/three/frame/inject-material.js.map +0 -1
- package/dist/three/frame/integrate-material.d.ts +0 -26
- package/dist/three/frame/integrate-material.js +0 -198
- package/dist/three/frame/integrate-material.js.map +0 -1
- package/dist/three/frame/layout.d.ts +0 -34
- package/dist/three/frame/layout.js +0 -48
- package/dist/three/frame/layout.js.map +0 -1
- package/dist/three/frame/lighting-material.d.ts +0 -41
- package/dist/three/frame/lighting-material.js +0 -257
- package/dist/three/frame/lighting-material.js.map +0 -1
- package/dist/three/frame/lights.d.ts +0 -11
- package/dist/three/frame/lights.js +0 -16
- package/dist/three/frame/lights.js.map +0 -1
- package/dist/three/frame/neural.d.ts +0 -14
- package/dist/three/frame/neural.js +0 -105
- package/dist/three/frame/neural.js.map +0 -1
- package/dist/three/frame/phase.d.ts +0 -44
- package/dist/three/frame/phase.js +0 -80
- package/dist/three/frame/phase.js.map +0 -1
- package/dist/three/frame/shadow-density-material.d.ts +0 -30
- package/dist/three/frame/shadow-density-material.js +0 -123
- package/dist/three/frame/shadow-density-material.js.map +0 -1
- package/dist/three/frame/temporal-material.d.ts +0 -29
- package/dist/three/frame/temporal-material.js +0 -152
- package/dist/three/frame/temporal-material.js.map +0 -1
- package/dist/three/frame/transmittance-material.d.ts +0 -31
- package/dist/three/frame/transmittance-material.js +0 -315
- package/dist/three/frame/transmittance-material.js.map +0 -1
- package/dist/three/frame/view.d.ts +0 -103
- package/dist/three/frame/view.js +0 -296
- package/dist/three/frame/view.js.map +0 -1
- package/dist/three/frame/volume-shadow-material.d.ts +0 -36
- package/dist/three/frame/volume-shadow-material.js +0 -128
- package/dist/three/frame/volume-shadow-material.js.map +0 -1
- package/dist/three/sequence.js.map +0 -1
|
@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,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAChI,IAAI,CAAC,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;YACnB,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;YACxC,OAAO,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,YAAY,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAC5I,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,gFAAgF;IAChF,OAAO;QACL,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,OAAO,GAAG,CAAC;IACb,CAAC;CACF","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/wvdb/wvdbKernel.js upsample L122–188 (a multi-page LOD shows the previous LOD upsampled in the\n// bricks not decoded yet), src/three-openvdb/frame/webgpu/frameMipmaps.js downsample L20–62 and packAtlas L65–88.\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: WGSL compute instead of his worker / CPU loops; integer weights (8 fractional bits) so the CPU twin\n// (`tools/wvdb/partial.ts` wvdbUpsampleTexels, `wvdbMipAtlas`) agrees byte for byte; only pending bricks upsample.\n// Divergences: DIVERGES.md (K4.22 row).\n\n/**\n * K4.22: the dense source's GPU fill of a partially streamed `.wvdb` LOD (`WvdbDenseTexture.fill`). One storage\n * buffer holds, at byte offsets: the pending-brick bits, the coarser LOD's texels, the partial LOD's texels (both\n * tight, as the host has them), then the texture's rows and the mip atlas's rows padded to 256 bytes (copy layout).\n * One compute pass:\n *\n * 1. `vdbDenseFillCs`, one thread per texel: a pending brick's texel is the coarse texels' trilinear upsample\n * (his `axis`: centres aligned, edges clamped; weights in 1/256, the sum rounded half up once), any other texel\n * is the host's; written into the cleared row region with `atomicOr` per byte.\n * 2. `vdbDenseMipCs`, one dispatch per mip level, one thread per texel: his box downsample (`(sum of 8 + 4) >> 3`,\n * edge taps clamped) of the level below, into the atlas at his x offset (`atlasWidth − atlasWidth / 2^(l−1)`).\n * With `mips: 'coarse'` (the default fill) level 1 of a pending brick is the coarser LOD's texel instead: the LOD\n * the bake box-filtered from this one, so a far view of a pending brick reads it, not a blur of its upsample.\n *\n * Then `copyBufferToTexture` into the source's texture and atlas. The work is submitted at once (the source's\n * `replace` acts on the queue, as `writeTexture` does), so a later `replace` lands after it. r8unorm is not a\n * storage-texture format in core WebGPU, hence the buffer and the copies (Traps: the f16 multi-scale chain does\n * the same). A texture whose buffer would pass `maxStorageBufferBindingSize` or `maxBufferSize` is filled on the\n * CPU by the twin instead (`vdbDenseFillFits`).\n */\n\nimport { VDBError } from \"../errors.js\";\nimport { USAGE, WORKGROUP_AXIS } from \"../compute/shared.js\";\nimport type { WvdbDenseTexture } from \"../../tools/wvdb/dense.js\";\nimport { wvdbFillCoarseMips } from \"../../tools/wvdb/partial.js\";\n\nconst W = WORKGROUP_AXIS;\nconst STAGE_COMPUTE = 0x4;\n/** Uniform slot stride (minUniformBufferOffsetAlignment's default). */\nconst SLOT = 256;\nconst PARAMS_BYTES = 96;\nconst BRICK = 8;\n\nconst FILL_WGSL = /* wgsl */ `\nstruct VdbDenseFillParams {\n dims: vec3u,\n texelBytes: u32,\n srcDims: vec3u,\n pendingWord: u32,\n bricks: vec3u,\n coarseByte: u32,\n fineByte: u32,\n dstByte: u32,\n dstRow: u32,\n dstRows: u32,\n dstX: u32,\n srcByte: u32,\n srcRow: u32,\n srcRows: u32,\n srcX: u32,\n coarseMip: u32,\n pad1: u32,\n pad2: u32,\n};\n@group(0) @binding(0) var<uniform> vdbFillP: VdbDenseFillParams;\n@group(0) @binding(1) var<storage, read_write> vdbFillBuf: array<atomic<u32>>;\n\n// Byte b of the buffer, and an OR of v into byte b (the row regions are cleared before the pass).\nfn vdbFillLoad(b: u32) -> u32 {\n return (atomicLoad(&vdbFillBuf[b >> 2u]) >> ((b & 3u) * 8u)) & 0xffu;\n}\nfn vdbFillStore(b: u32, v: u32) {\n atomicOr(&vdbFillBuf[b >> 2u], (v & 0xffu) << ((b & 3u) * 8u));\n}\n\n// His upsample axis in integers: target texel i of size reads clamp((i + 1/2) src / size - 1/2, 0, src - 1);\n// returns (lower tap, upper tap, upper weight in 1/256, the exact fraction rounded half up).\nfn vdbFillAxis(i: u32, size: u32, src: u32) -> vec3u {\n let den = 2u * size;\n let num = min(u32(max(i32((2u * i + 1u) * src) - i32(size), 0)), (src - 1u) * den);\n let lo = num / den;\n let r = num - lo * den;\n return vec3u(lo, min(lo + 1u, src - 1u), (r * 256u + size) / den);\n}\n\nfn vdbFillTap(i: u32, c: u32) -> u32 {\n return vdbFillLoad(vdbFillP.coarseByte + i * vdbFillP.texelBytes + c);\n}\n\n@compute @workgroup_size(${W}, ${W}, ${W})\nfn vdbDenseFillCs(@builtin(global_invocation_id) id: vec3u) {\n let p = vdbFillP;\n if any(id >= p.dims) {\n return;\n }\n let brick = (id.x >> 3u) + p.bricks.x * ((id.y >> 3u) + p.bricks.y * (id.z >> 3u));\n let pending = (atomicLoad(&vdbFillBuf[p.pendingWord + (brick >> 5u)]) >> (brick & 31u)) & 1u;\n let dst = p.dstByte + (id.z * p.dstRows + id.y) * p.dstRow + (p.dstX + id.x) * p.texelBytes;\n if pending == 0u {\n let src = p.fineByte + ((id.z * p.dims.y + id.y) * p.dims.x + id.x) * p.texelBytes;\n for (var c = 0u; c < p.texelBytes; c++) {\n vdbFillStore(dst + c, vdbFillLoad(src + c));\n }\n return;\n }\n let ax = vdbFillAxis(id.x, p.dims.x, p.srcDims.x);\n let ay = vdbFillAxis(id.y, p.dims.y, p.srcDims.y);\n let az = vdbFillAxis(id.z, p.dims.z, p.srcDims.z);\n let r00 = (ay.x + az.x * p.srcDims.y) * p.srcDims.x;\n let r10 = (ay.y + az.x * p.srcDims.y) * p.srcDims.x;\n let r01 = (ay.x + az.y * p.srcDims.y) * p.srcDims.x;\n let r11 = (ay.y + az.y * p.srcDims.y) * p.srcDims.x;\n for (var c = 0u; c < p.texelBytes; c++) {\n let c00 = vdbFillTap(ax.x + r00, c) * (256u - ax.z) + vdbFillTap(ax.y + r00, c) * ax.z;\n let c10 = vdbFillTap(ax.x + r10, c) * (256u - ax.z) + vdbFillTap(ax.y + r10, c) * ax.z;\n let c01 = vdbFillTap(ax.x + r01, c) * (256u - ax.z) + vdbFillTap(ax.y + r01, c) * ax.z;\n let c11 = vdbFillTap(ax.x + r11, c) * (256u - ax.z) + vdbFillTap(ax.y + r11, c) * ax.z;\n let c0 = c00 * (256u - ay.z) + c10 * ay.z;\n let c1 = c01 * (256u - ay.z) + c11 * ay.z;\n vdbFillStore(dst + c, (c0 * (256u - az.z) + c1 * az.z + 0x800000u) >> 24u);\n }\n}\n\nfn vdbMipTap(x: u32, y: u32, z: u32, c: u32) -> u32 {\n let p = vdbFillP;\n return vdbFillLoad(p.srcByte + (z * p.srcRows + y) * p.srcRow + (p.srcX + x) * p.texelBytes + c);\n}\n\n@compute @workgroup_size(${W}, ${W}, ${W})\nfn vdbDenseMipCs(@builtin(global_invocation_id) id: vec3u) {\n let p = vdbFillP;\n if any(id >= p.dims) {\n return;\n }\n let s = p.srcDims - vec3u(1u);\n let x0 = min(id.x * 2u, s.x);\n let x1 = min(id.x * 2u + 1u, s.x);\n let y0 = min(id.y * 2u, s.y);\n let y1 = min(id.y * 2u + 1u, s.y);\n let z0 = min(id.z * 2u, s.z);\n let z1 = min(id.z * 2u + 1u, s.z);\n let dst = p.dstByte + (id.z * p.dstRows + id.y) * p.dstRow + (p.dstX + id.x) * p.texelBytes;\n if p.coarseMip != 0u {\n // Level 1 of a pending brick: the coarser LOD's texel (its size is level 1's). Children 2x, 2x + 1 share a brick.\n let brick = ((id.x * 2u) >> 3u) + p.bricks.x * (((id.y * 2u) >> 3u) + p.bricks.y * ((id.z * 2u) >> 3u));\n if ((atomicLoad(&vdbFillBuf[p.pendingWord + (brick >> 5u)]) >> (brick & 31u)) & 1u) != 0u {\n let src = p.coarseByte + ((id.z * p.dims.y + id.y) * p.dims.x + id.x) * p.texelBytes;\n for (var c = 0u; c < p.texelBytes; c++) {\n vdbFillStore(dst + c, vdbFillLoad(src + c));\n }\n return;\n }\n }\n for (var c = 0u; c < p.texelBytes; c++) {\n let sum = vdbMipTap(x0, y0, z0, c) + vdbMipTap(x1, y0, z0, c) + vdbMipTap(x0, y1, z0, c) + vdbMipTap(x1, y1, z0, c)\n + vdbMipTap(x0, y0, z1, c) + vdbMipTap(x1, y0, z1, c) + vdbMipTap(x0, y1, z1, c) + vdbMipTap(x1, y1, z1, c);\n vdbFillStore(dst + c, (sum + 4u) >> 3u);\n }\n}\n`;\n\n/** The WGSL of the fill and mip kernels (exported for probes and tests). */\nexport function vdbDenseFillWgsl(): string {\n return FILL_WGSL;\n}\n\nconst align = (n: number, a: number) => Math.ceil(n / a) * a;\nconst levelSize = (size: number, level: number) => Math.max(1, Math.ceil(size / 2 ** level));\n\n/** One dispatch: its parameters (u32 words of `VdbDenseFillParams`) and size. */\ninterface Dispatch {\n entry: \"fill\" | \"mip\";\n dims: [number, number, number];\n params: Uint32Array;\n}\n\n/** Where everything sits in the fill buffer of one texture (bytes), and the dispatches. */\nexport interface VDBDenseFillLayout {\n readonly key: string;\n readonly texelBytes: number;\n readonly dims: readonly [number, number, number];\n readonly srcDims: readonly [number, number, number];\n readonly pendingByte: number;\n readonly pendingWords: number;\n readonly coarseByte: number;\n readonly fineByte: number;\n readonly mapByte: number;\n readonly mapRow: number;\n /** The atlas rows (null without a mip atlas). */\n readonly atlas: { readonly byte: number; readonly row: number; readonly dimensions: readonly [number, number, number]; readonly levels: number } | null;\n /** Level 1 of the pending bricks from the coarse texels (`fill.mips` 'coarse' and a halving size). */\n readonly coarseMips: boolean;\n /** Buffer bytes. */\n readonly size: number;\n}\n\n/** The fill buffer layout of `tex` (which must carry a `fill`). */\nexport function vdbDenseFillLayout(tex: WvdbDenseTexture): VDBDenseFillLayout {\n const fill = tex.fill;\n if (!fill) throw new VDBError(\"VDB_BAD_OPTION\", \"vdbDenseFillLayout: the texture has no fill.\");\n const tb = tex.texelBytes;\n const dims = [...tex.dimensions] as [number, number, number];\n const srcDims = [...fill.from.dimensions] as [number, number, number];\n const bricks = dims.map((d) => Math.ceil(d / BRICK));\n const pendingWords = Math.ceil((bricks[0]! * bricks[1]! * bricks[2]!) / 32);\n const coarseByte = align(pendingWords * 4, 16);\n const fineByte = coarseByte + align(srcDims[0] * srcDims[1] * srcDims[2] * tb, 16);\n const mapByte = align(fineByte + dims[0] * dims[1] * dims[2] * tb, 256);\n const mapRow = align(dims[0] * tb, 256);\n let end = mapByte + mapRow * dims[1] * dims[2];\n let atlas: VDBDenseFillLayout[\"atlas\"] = null;\n if (tex.mip) {\n const a = tex.mip.dimensions;\n atlas = { byte: align(end, 256), row: align(a[0] * tb, 256), dimensions: [a[0], a[1], a[2]], levels: tex.mip.levels };\n end = atlas.byte + atlas.row * a[1] * a[2];\n }\n const coarseMips = !!atlas && wvdbFillCoarseMips(tex);\n return {\n key: `${dims.join(\"x\")}|${srcDims.join(\"x\")}|${tb}|${atlas ? `${atlas.dimensions.join(\"x\")}:${atlas.levels}` : \"-\"}|${coarseMips ? \"coarse\" : \"box\"}`,\n texelBytes: tb,\n dims,\n srcDims,\n pendingByte: 0,\n pendingWords,\n coarseByte,\n fineByte,\n mapByte,\n mapRow,\n atlas,\n coarseMips,\n size: align(end, 4),\n };\n}\n\n/** The dispatches of a layout: the fill, then one per mip level (level 1 reads the texture rows, then the atlas). */\nfunction dispatchesOf(l: VDBDenseFillLayout): Dispatch[] {\n const [w, h, d] = l.dims;\n const bricks = l.dims.map((v) => Math.ceil(v / BRICK));\n const params = (o: Partial<Record<string, number | readonly number[]>>): Uint32Array => {\n const u = new Uint32Array(PARAMS_BYTES / 4);\n const vec = (at: number, v: readonly number[]) => u.set(v, at);\n vec(0, (o.dims as readonly number[]) ?? [0, 0, 0]);\n u[3] = l.texelBytes;\n vec(4, (o.srcDims as readonly number[]) ?? [0, 0, 0]);\n u[7] = l.pendingByte / 4;\n vec(8, bricks);\n u[11] = l.coarseByte;\n u[12] = l.fineByte;\n u[13] = o.dstByte as number;\n u[14] = o.dstRow as number;\n u[15] = o.dstRows as number;\n u[16] = (o.dstX as number) ?? 0;\n u[17] = (o.srcByte as number) ?? 0;\n u[18] = (o.srcRow as number) ?? 0;\n u[19] = (o.srcRows as number) ?? 0;\n u[20] = (o.srcX as number) ?? 0;\n u[21] = (o.coarseMip as number) ?? 0;\n return u;\n };\n const out: Dispatch[] = [{ entry: \"fill\", dims: [w, h, d], params: params({ dims: l.dims, srcDims: l.srcDims, dstByte: l.mapByte, dstRow: l.mapRow, dstRows: h, dstX: 0 }) }];\n const a = l.atlas;\n if (a) {\n const aw = a.dimensions[0];\n const xOf = (level: number) => aw - aw / 2 ** (level - 1);\n for (let level = 1; level <= a.levels; level++) {\n const dims = [levelSize(w, level), levelSize(h, level), levelSize(d, level)] as [number, number, number];\n const src = level === 1 ? { srcByte: l.mapByte, srcRow: l.mapRow, srcRows: h, srcX: 0 } : { srcByte: a.byte, srcRow: a.row, srcRows: a.dimensions[1], srcX: xOf(level - 1) };\n const srcDims = [levelSize(w, level - 1), levelSize(h, level - 1), levelSize(d, level - 1)];\n const coarseMip = level === 1 && l.coarseMips ? 1 : 0;\n out.push({ entry: \"mip\", dims, params: params({ dims, srcDims, dstByte: a.byte, dstRow: a.row, dstRows: a.dimensions[1], dstX: xOf(level), coarseMip, ...src }) });\n }\n }\n return out;\n}\n\n/** True when `layout`'s buffer fits the device's storage binding and buffer limits (else fill on the CPU). */\nexport function vdbDenseFillFits(device: GPUDevice, layout: VDBDenseFillLayout): boolean {\n const limits = (device as { limits?: Partial<GPUSupportedLimits> }).limits ?? {};\n const binding = limits.maxStorageBufferBindingSize ?? 128 * 1024 * 1024;\n const buffer = limits.maxBufferSize ?? 256 * 1024 * 1024;\n return layout.size <= binding && layout.size <= buffer;\n}\n\ninterface Pipelines {\n fill: GPUComputePipeline;\n mip: GPUComputePipeline;\n group0: GPUBindGroupLayout;\n error: Promise<GPUError | null>;\n}\n\nconst pipelines = new WeakMap<GPUDevice, Pipelines>();\n\nfunction fillPipelines(device: GPUDevice): Pipelines {\n const cached = pipelines.get(device);\n if (cached) return cached;\n device.pushErrorScope(\"validation\");\n const group0 = device.createBindGroupLayout({\n label: \"vdb dense fill group 0\",\n entries: [\n { binding: 0, visibility: STAGE_COMPUTE, buffer: { type: \"uniform\", hasDynamicOffset: true, minBindingSize: PARAMS_BYTES } },\n { binding: 1, visibility: STAGE_COMPUTE, buffer: { type: \"storage\" } },\n ],\n });\n const module = device.createShaderModule({ label: \"vdb dense fill\", code: FILL_WGSL });\n const layout = device.createPipelineLayout({ label: \"vdb dense fill\", bindGroupLayouts: [group0] });\n const make = (entryPoint: string) => device.createComputePipeline({ label: `vdb dense fill ${entryPoint}`, layout, compute: { module, entryPoint } });\n const error = device.popErrorScope().then((e) => {\n if (e) console.error(`@pmndrs/vdb vdbDenseSource: the fill kernels are invalid: ${e.message}`);\n return e;\n });\n const p: Pipelines = { fill: make(\"vdbDenseFillCs\"), mip: make(\"vdbDenseMipCs\"), group0, error };\n pipelines.set(device, p);\n return p;\n}\n\n/** Writes `data` at `offset` (bytes) with `writeBuffer`'s 4-byte size rule: the tail goes through a padded word. */\nfunction writeBytes(device: GPUDevice, buffer: GPUBuffer, offset: number, data: Uint8Array<ArrayBuffer>): void {\n const body = data.byteLength & ~3;\n if (body > 0) device.queue.writeBuffer(buffer, offset, data, 0, body);\n if (body < data.byteLength) {\n const tail = new Uint8Array(4);\n tail.set(data.subarray(body));\n device.queue.writeBuffer(buffer, offset + body, tail);\n }\n}\n\n/**\n * The GPU fill of one dense channel's textures (see the file comment). Keeps its buffer while the layout stays\n * (the pages of one LOD), and the coarse texels it last wrote (pages share one coarse array).\n */\nexport class VDBDenseFiller {\n readonly #device: GPUDevice;\n readonly #label: string;\n #layout: VDBDenseFillLayout | null = null;\n #buffer: GPUBuffer | null = null;\n #params: GPUBuffer | null = null;\n #group: GPUBindGroup | null = null;\n #dispatches: Dispatch[] = [];\n #coarse: Uint8Array | null = null;\n /** Fills run (for tests and probes). */\n runs = 0;\n\n constructor(device: GPUDevice, label: string) {\n this.#device = device;\n this.#label = label;\n }\n\n /** Pipeline validation of the kernels (null = valid). */\n get error(): Promise<GPUError | null> {\n return fillPipelines(this.#device).error;\n }\n\n /** Bytes of this filler's buffers. */\n get gpuBytes(): number {\n return (this.#buffer?.size ?? 0) + (this.#params?.size ?? 0);\n }\n\n /**\n * Fills `map` (and `mip`, the atlas texture, when `tex` has one) with `tex` and its pending bricks upsampled, and\n * submits the work. `tex.fill` must be set; `map`/`mip` must have `tex`'s sizes and `COPY_DST`.\n * @returns the buffers it replaced (the caller retires them).\n */\n fill(map: GPUTexture, mip: GPUTexture | null, tex: WvdbDenseTexture): GPUBuffer[] {\n const fill = tex.fill!;\n const device = this.#device;\n const layout = vdbDenseFillLayout(tex);\n const retired: GPUBuffer[] = [];\n if (!this.#layout || this.#layout.key !== layout.key) {\n if (this.#buffer) retired.push(this.#buffer, this.#params!);\n this.#layout = layout;\n this.#dispatches = dispatchesOf(layout);\n this.#buffer = device.createBuffer({ label: `${this.#label} fill`, size: layout.size, usage: USAGE.STORAGE | USAGE.COPY_DST | USAGE.COPY_SRC });\n this.#params = device.createBuffer({ label: `${this.#label} fill params`, size: this.#dispatches.length * SLOT, usage: USAGE.UNIFORM | USAGE.COPY_DST });\n const bytes = new Uint8Array(this.#dispatches.length * SLOT);\n this.#dispatches.forEach((d, i) => bytes.set(new Uint8Array(d.params.buffer), i * SLOT));\n device.queue.writeBuffer(this.#params, 0, bytes);\n const p = fillPipelines(device);\n this.#group = device.createBindGroup({\n label: `${this.#label} fill group`,\n layout: p.group0,\n entries: [\n { binding: 0, resource: { buffer: this.#params, size: PARAMS_BYTES } },\n { binding: 1, resource: { buffer: this.#buffer } },\n ],\n });\n this.#coarse = null;\n }\n const buffer = this.#buffer!;\n const l = this.#layout;\n device.queue.writeBuffer(buffer, l.pendingByte, new Uint32Array(fill.pending.subarray(0, l.pendingWords)));\n if (this.#coarse !== fill.from.data) {\n writeBytes(device, buffer, l.coarseByte, fill.from.data);\n this.#coarse = fill.from.data;\n }\n writeBytes(device, buffer, l.fineByte, tex.data);\n const p = fillPipelines(device);\n const encoder = device.createCommandEncoder({ label: `${this.#label} fill` });\n encoder.clearBuffer(buffer, l.mapByte, l.size - l.mapByte);\n const pass = encoder.beginComputePass({ label: `${this.#label} fill` });\n this.#dispatches.forEach((d, i) => {\n pass.setPipeline(d.entry === \"fill\" ? p.fill : p.mip);\n pass.setBindGroup(0, this.#group!, [i * SLOT]);\n pass.dispatchWorkgroups(Math.ceil(d.dims[0] / W), Math.ceil(d.dims[1] / W), Math.ceil(d.dims[2] / W));\n });\n pass.end();\n const [w, h, d] = l.dims;\n encoder.copyBufferToTexture({ buffer, offset: l.mapByte, bytesPerRow: l.mapRow, rowsPerImage: h }, { texture: map }, [w, h, d]);\n if (l.atlas && mip) {\n const [aw, ah, ad] = l.atlas.dimensions;\n encoder.copyBufferToTexture({ buffer, offset: l.atlas.byte, bytesPerRow: l.atlas.row, rowsPerImage: ah }, { texture: mip }, [aw, ah, ad]);\n }\n device.queue.submit([encoder.finish()]);\n this.runs++;\n return retired;\n }\n\n /** The buffers this filler holds (the caller retires them), and forget them. */\n release(): GPUBuffer[] {\n const out = this.#buffer ? [this.#buffer, this.#params!] : [];\n this.#buffer = this.#params = null;\n this.#group = null;\n this.#layout = null;\n this.#coarse = null;\n return out;\n }\n}\n"]}
|
|
@@ -1,19 +1,50 @@
|
|
|
1
1
|
import type { WvdbDenseVolume } from "../../tools/wvdb/dense.js";
|
|
2
|
-
import type { VDBVolumeSource } from "./types.js";
|
|
2
|
+
import type { VDBVolumeSlot, VDBVolumeSource } from "./types.js";
|
|
3
|
+
type ChannelName = "density" | "mask" | "albedo" | "emission";
|
|
3
4
|
/** Options of {@link vdbDenseSource}. */
|
|
4
5
|
export interface VDBDenseSourceOptions {
|
|
5
6
|
/** Label prefix of the GPU objects. */
|
|
6
7
|
label?: string;
|
|
8
|
+
/**
|
|
9
|
+
* K4.22: where a partial LOD's pending bricks (`WvdbDenseTexture.fill`) are filled: `'gpu'` (default, a compute
|
|
10
|
+
* kernel) or `'cpu'` (`wvdbDenseResolve`, then an upload). Both give the same bytes; a texture whose fill buffer
|
|
11
|
+
* would pass the device's storage binding or buffer size limit is filled on the CPU anyway.
|
|
12
|
+
*/
|
|
13
|
+
fill?: "gpu" | "cpu";
|
|
7
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* @internal The textures a dense source holds now, per channel (`map`, and `mip` the atlas): for probes that read
|
|
17
|
+
* them back (they have `COPY_SRC`). Null for an object that is not a dense source.
|
|
18
|
+
*/
|
|
19
|
+
export declare function vdbDenseSourceTextures(source: object): Partial<Record<ChannelName, {
|
|
20
|
+
map: GPUTexture;
|
|
21
|
+
mip: GPUTexture | null;
|
|
22
|
+
}>> | null;
|
|
8
23
|
/** A dense source with `replace` (LOD swap). */
|
|
9
|
-
export type VDBDenseSource = VDBVolumeSource & {
|
|
24
|
+
export type VDBDenseSource = VDBVolumeSource & VDBVolumeSlot & {
|
|
10
25
|
readonly kind: "dense";
|
|
11
26
|
readonly volume: WvdbDenseVolume;
|
|
27
|
+
/**
|
|
28
|
+
* Swap in another LOD or frame. K4.22: a partial LOD (`wvdbDensePartialVolume`) is filled before the upload
|
|
29
|
+
* (its pending bricks upsampled from the coarser LOD, on the GPU by default; see {@link VDBDenseSourceOptions}).
|
|
30
|
+
*/
|
|
12
31
|
replace(volume: WvdbDenseVolume): void;
|
|
32
|
+
/** K4.22: how many channel fills ran on the GPU and on the CPU (partial LODs). */
|
|
33
|
+
readonly fills: {
|
|
34
|
+
readonly gpu: number;
|
|
35
|
+
readonly cpu: number;
|
|
36
|
+
};
|
|
37
|
+
/** K4.22: bumps on every `replace` (the content changed; `version` only when the textures are new). */
|
|
38
|
+
readonly revision: number;
|
|
13
39
|
};
|
|
14
40
|
/**
|
|
15
41
|
* Upload a dense `.wvdb` volume (`wvdbDenseVolume` from `@pmndrs/vdb/tools`) on
|
|
16
42
|
* the host's device. The source owns its textures and sampler; `dispose()` frees
|
|
17
43
|
* the textures (samplers have no destroy).
|
|
44
|
+
*
|
|
45
|
+
* @param device The host's `GPUDevice`; the source creates its textures on it.
|
|
46
|
+
* @param volume The decoded `.wvdb` level (`wvdbDenseVolume`).
|
|
47
|
+
* @param o Options ({@link VDBDenseSourceOptions}).
|
|
18
48
|
*/
|
|
19
49
|
export declare function vdbDenseSource(device: GPUDevice, volume: WvdbDenseVolume, o?: VDBDenseSourceOptions): VDBDenseSource;
|
|
50
|
+
export {};
|
|
@@ -15,28 +15,48 @@
|
|
|
15
15
|
*
|
|
16
16
|
* D10 says kernels need no textures; that holds for the sparse source. A
|
|
17
17
|
* kernel compiled against a dense source binds textures, by the host's choice.
|
|
18
|
+
*
|
|
19
|
+
* K4.22: a volume from `wvdbDensePartialVolume` (a `.wvdb` LOD still streaming) carries a `fill` on its
|
|
20
|
+
* textures: the bricks stored but not decoded yet, and the coarser LOD to upsample there. The source fills them
|
|
21
|
+
* on the GPU (`dense-fill.ts`: one compute pass, its own submit) and builds the mip atlas from the result; the
|
|
22
|
+
* CPU twin (`wvdbDenseResolve`) gives the same bytes and is the fallback (`fill: 'cpu'`, or a texture too large
|
|
23
|
+
* for one storage binding).
|
|
18
24
|
*/
|
|
19
25
|
import { VDBError } from "../errors.js";
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
import { VDBRetireQueue } from "../frame/resources.js";
|
|
27
|
+
import { wvdbDenseResolveTexture } from "../../tools/wvdb/partial.js";
|
|
28
|
+
import { VDBDenseFiller, vdbDenseFillFits, vdbDenseFillLayout } from "./dense-fill.js";
|
|
29
|
+
/** `GPUTextureUsage.TEXTURE_BINDING | COPY_DST | COPY_SRC` (0x04 | 0x02 | 0x01); the globals do not exist in Node. */
|
|
30
|
+
const TEXTURE_USAGE = 0x04 | 0x02 | 0x01;
|
|
22
31
|
/** `GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE`. */
|
|
23
32
|
const STAGE_FRAGMENT_COMPUTE = 0x2 | 0x4;
|
|
24
33
|
const CHANNELS = ["density", "mask", "albedo", "emission"];
|
|
25
34
|
const CAP = { density: "Density", mask: "Mask", albedo: "Albedo", emission: "Emission" };
|
|
35
|
+
/** K4.22 probes: each source's live textures (core internal, `vdbDenseSourceTextures`). */
|
|
36
|
+
const liveTextures = new WeakMap();
|
|
37
|
+
/**
|
|
38
|
+
* @internal The textures a dense source holds now, per channel (`map`, and `mip` the atlas): for probes that read
|
|
39
|
+
* them back (they have `COPY_SRC`). Null for an object that is not a dense source.
|
|
40
|
+
*/
|
|
41
|
+
export function vdbDenseSourceTextures(source) {
|
|
42
|
+
return liveTextures.get(source)?.() ?? null;
|
|
43
|
+
}
|
|
26
44
|
const bad = (message) => new VDBError("VDB_BAD_OPTION", message);
|
|
27
|
-
function
|
|
45
|
+
function create(device, dims, format, label) {
|
|
46
|
+
const [w, h, d] = dims;
|
|
47
|
+
return device.createTexture({ label, size: [w, h, d], dimension: "3d", format, usage: TEXTURE_USAGE });
|
|
48
|
+
}
|
|
49
|
+
function write(device, texture, data, dims, texelBytes, label) {
|
|
28
50
|
const [w, h, d] = dims;
|
|
29
51
|
if (data.byteLength !== w * h * d * texelBytes) {
|
|
30
52
|
throw bad(`vdbDenseSource: ${label} has ${data.byteLength} bytes, expected ${w}x${h}x${d}x${texelBytes}`);
|
|
31
53
|
}
|
|
32
|
-
const texture = device.createTexture({ label, size: [w, h, d], dimension: "3d", format, usage: TEXTURE_USAGE });
|
|
33
54
|
// writeTexture has no 256-byte row alignment rule (only buffer copies do); FrameVolume uses unpackAlignment 1.
|
|
34
55
|
device.queue.writeTexture({ texture }, data, { bytesPerRow: w * texelBytes, rowsPerImage: h }, [w, h, d]);
|
|
35
|
-
return texture;
|
|
36
56
|
}
|
|
37
|
-
function
|
|
38
|
-
const map =
|
|
39
|
-
const mip = tex.mip ?
|
|
57
|
+
function createChannel(device, tex, label) {
|
|
58
|
+
const map = create(device, tex.dimensions, tex.format, `${label}`);
|
|
59
|
+
const mip = tex.mip ? create(device, tex.mip.dimensions, tex.format, `${label} mip atlas`) : null;
|
|
40
60
|
return { map, mip };
|
|
41
61
|
}
|
|
42
62
|
function present(volume) {
|
|
@@ -83,6 +103,11 @@ fn vdbSrcSample${C}(uvw: vec3f, lod: f32) -> vec4f {
|
|
|
83
103
|
}
|
|
84
104
|
class DenseSource {
|
|
85
105
|
kind = "dense";
|
|
106
|
+
/** A dense source is its own volume slot (K6 design §2.1): `source` is itself, `v` = 0. */
|
|
107
|
+
get source() {
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
v = 0;
|
|
86
111
|
texels;
|
|
87
112
|
lodLevels;
|
|
88
113
|
channels;
|
|
@@ -90,15 +115,27 @@ class DenseSource {
|
|
|
90
115
|
/** Local unit box → uvw: translate by 0.5 (column-major). */
|
|
91
116
|
boxToSource = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1]);
|
|
92
117
|
version = 0;
|
|
118
|
+
/** K4.22: every `replace` (same size included) bumps it: the content changed (`VDBVolumeSourceInfo.revision`). */
|
|
119
|
+
revision = 0;
|
|
93
120
|
#device;
|
|
94
121
|
#label;
|
|
95
122
|
#volume;
|
|
96
123
|
#textures = {};
|
|
97
124
|
#sampler;
|
|
98
125
|
#disposed = false;
|
|
126
|
+
#retire = new VDBRetireQueue();
|
|
127
|
+
#fillMode;
|
|
128
|
+
/** K4.22: one GPU filler per channel while that channel's LOD streams in. */
|
|
129
|
+
#fillers = new Map();
|
|
130
|
+
/** K4.22: channel fills done on the GPU and on the CPU (for tests and probes). */
|
|
131
|
+
fills = { gpu: 0, cpu: 0 };
|
|
99
132
|
constructor(device, volume, o) {
|
|
100
133
|
this.#device = device;
|
|
101
134
|
this.#label = o.label ?? "vdb dense source";
|
|
135
|
+
if (o.fill !== undefined && o.fill !== "gpu" && o.fill !== "cpu")
|
|
136
|
+
throw bad(`vdbDenseSource: fill must be 'gpu' or 'cpu', got ${JSON.stringify(o.fill)}.`);
|
|
137
|
+
this.#fillMode = o.fill ?? "gpu";
|
|
138
|
+
liveTextures.set(this, () => ({ ...this.#textures }));
|
|
102
139
|
this.#volume = volume;
|
|
103
140
|
this.channels = { mask: !!volume.mask, albedo: !!volume.albedo, emission: !!volume.emission };
|
|
104
141
|
// FrameRenderer.js L483–487 + Data3DTexture defaults: linear, clamp to edge, no mipmaps.
|
|
@@ -120,14 +157,55 @@ class DenseSource {
|
|
|
120
157
|
const textures = present(volume);
|
|
121
158
|
for (const name of CHANNELS) {
|
|
122
159
|
const tex = textures[name];
|
|
123
|
-
if (tex)
|
|
124
|
-
|
|
160
|
+
if (!tex)
|
|
161
|
+
continue;
|
|
162
|
+
const up = createChannel(this.#device, tex, `${this.#label} ${name}`);
|
|
163
|
+
this.#textures[name] = up;
|
|
164
|
+
this.#write(name, tex, up);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/** Writes a channel's texels and atlas; K4.22: a texture with pending bricks is filled first (GPU or CPU). */
|
|
168
|
+
#write(name, tex, up) {
|
|
169
|
+
const label = `${this.#label} ${name}`;
|
|
170
|
+
let t = tex;
|
|
171
|
+
if (tex.fill && tex.fill.count > 0) {
|
|
172
|
+
if (this.#fillMode === "gpu" && vdbDenseFillFits(this.#device, vdbDenseFillLayout(tex))) {
|
|
173
|
+
let filler = this.#fillers.get(name);
|
|
174
|
+
if (!filler)
|
|
175
|
+
this.#fillers.set(name, (filler = new VDBDenseFiller(this.#device, label)));
|
|
176
|
+
for (const b of filler.fill(up.map, up.mip, tex))
|
|
177
|
+
this.#retire.retireAfterTask(b);
|
|
178
|
+
this.fills.gpu++;
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
t = wvdbDenseResolveTexture(tex);
|
|
182
|
+
this.fills.cpu++;
|
|
125
183
|
}
|
|
184
|
+
write(this.#device, up.map, t.data, t.dimensions, t.texelBytes, label);
|
|
185
|
+
if (t.mip && up.mip)
|
|
186
|
+
write(this.#device, up.mip, t.mip.data, t.mip.dimensions, t.texelBytes, `${label} mip atlas`);
|
|
126
187
|
}
|
|
127
|
-
|
|
188
|
+
/** Retires the GPU fillers of channels that have no pending bricks in `volume` (their LOD is complete). */
|
|
189
|
+
#releaseFillers(volume) {
|
|
190
|
+
const textures = present(volume);
|
|
191
|
+
for (const [name, filler] of this.#fillers) {
|
|
192
|
+
const tex = textures[name];
|
|
193
|
+
if (tex?.fill && tex.fill.count > 0)
|
|
194
|
+
continue;
|
|
195
|
+
for (const b of filler.release())
|
|
196
|
+
this.#retire.retireAfterTask(b);
|
|
197
|
+
this.#fillers.delete(name);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* K6.10a: a replaced texture may be named by passes the host recorded but has not submitted yet (a `replace` between
|
|
202
|
+
* the frame's `update(encoder)` and `queue.submit`), so it is destroyed in a later task (the retire queue's rule).
|
|
203
|
+
* `dispose()` destroys at once.
|
|
204
|
+
*/
|
|
205
|
+
#retireTextures() {
|
|
128
206
|
for (const t of Object.values(this.#textures)) {
|
|
129
|
-
t.map
|
|
130
|
-
t.mip
|
|
207
|
+
this.#retire.retireAfterTask(t.map);
|
|
208
|
+
this.#retire.retireAfterTask(t.mip);
|
|
131
209
|
}
|
|
132
210
|
this.#textures = {};
|
|
133
211
|
}
|
|
@@ -142,7 +220,9 @@ class DenseSource {
|
|
|
142
220
|
/**
|
|
143
221
|
* Swap in another LOD (or frame) of the same grids. The channel set and mip
|
|
144
222
|
* presence must match; a size change makes new textures and bumps `version`
|
|
145
|
-
* (rebuild bind groups; the WGSL does not change).
|
|
223
|
+
* (rebuild bind groups; the WGSL does not change). The replaced textures are
|
|
224
|
+
* destroyed in a later task (K6.10a): passes recorded with them before the
|
|
225
|
+
* call stay valid when the host submits in the same task.
|
|
146
226
|
*/
|
|
147
227
|
replace(volume) {
|
|
148
228
|
this.#check();
|
|
@@ -154,26 +234,23 @@ class DenseSource {
|
|
|
154
234
|
}
|
|
155
235
|
}
|
|
156
236
|
const sameSize = (a, b) => !a || !b || (a.dimensions.every((v, i) => v === b.dimensions[i]) && (!a.mip || a.mip.dimensions.every((v, i) => v === b.mip.dimensions[i])));
|
|
237
|
+
this.#releaseFillers(volume);
|
|
157
238
|
if (CHANNELS.every((n) => sameSize(now[n], next[n]))) {
|
|
158
239
|
for (const name of CHANNELS) {
|
|
159
240
|
const tex = next[name];
|
|
160
241
|
const up = this.#textures[name];
|
|
161
242
|
if (!tex || !up)
|
|
162
243
|
continue;
|
|
163
|
-
|
|
164
|
-
this.#device.queue.writeTexture({ texture: up.map }, tex.data, { bytesPerRow: w * tex.texelBytes, rowsPerImage: h }, [w, h, d]);
|
|
165
|
-
if (tex.mip && up.mip) {
|
|
166
|
-
const [aw, ah, ad] = tex.mip.dimensions;
|
|
167
|
-
this.#device.queue.writeTexture({ texture: up.mip }, tex.mip.data, { bytesPerRow: aw * tex.texelBytes, rowsPerImage: ah }, [aw, ah, ad]);
|
|
168
|
-
}
|
|
244
|
+
this.#write(name, tex, up);
|
|
169
245
|
}
|
|
170
246
|
}
|
|
171
247
|
else {
|
|
172
|
-
this.#
|
|
248
|
+
this.#retireTextures();
|
|
173
249
|
this.#upload(volume);
|
|
174
250
|
this.version++;
|
|
175
251
|
}
|
|
176
252
|
this.#volume = volume;
|
|
253
|
+
this.revision++;
|
|
177
254
|
this.texels = [...volume.dimensions];
|
|
178
255
|
this.lodLevels = volume.density.mip?.levels ?? 0;
|
|
179
256
|
this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };
|
|
@@ -236,13 +313,24 @@ fn vdbSrcLodLevels(v: u32) -> f32 {
|
|
|
236
313
|
return ${this.#textures.density?.mip ? "vdbSrcLevelCount(textureDimensions(vdbSrcDensityMap))" : "0.0"};
|
|
237
314
|
}
|
|
238
315
|
`);
|
|
316
|
+
if (o.stochastic) {
|
|
317
|
+
// Issue #2: hardware trilinear is already one fetch; the stochastic form is the deterministic one.
|
|
318
|
+
lines.push(`fn vdbSrcDensityStochastic(v: u32, uvw: vec3f, lod: f32, xi: vec3f) -> f32 {
|
|
319
|
+
return vdbSrcDensity(v, uvw, lod);
|
|
320
|
+
}`);
|
|
321
|
+
}
|
|
239
322
|
if (o.profile === "march") {
|
|
240
|
-
// Dense: no empty-space structure; the march steps everywhere (R1 §4.2).
|
|
323
|
+
// Dense: no empty-space structure; the march steps everywhere (R1 §4.2). K4.22a: vdbSrcMaxIn is the r8unorm bound
|
|
324
|
+
// (every texel and every filtered sample is <= 1), not stats.max: baked into the WGSL, a max that moved with each
|
|
325
|
+
// partial LOD page rebuilt every frame kernel (demo 16: 7 builds at LOD 1's first page). stats.max stays on the CPU.
|
|
241
326
|
lines.push(`fn vdbSrcSkipEmpty(v: u32, o: vec3f, d: vec3f, t0: f32, t1: f32) -> f32 {
|
|
242
327
|
return t0;
|
|
243
328
|
}
|
|
329
|
+
fn vdbSrcSkipSpan(v: u32, o: vec3f, d: vec3f, t0: f32, t1: f32, lod: f32, cutoff: f32) -> vec2f {
|
|
330
|
+
return vec2f(t0, 1e30);
|
|
331
|
+
}
|
|
244
332
|
fn vdbSrcMaxIn(v: u32, uvwMin: vec3f, uvwMax: vec3f) -> f32 {
|
|
245
|
-
return
|
|
333
|
+
return 1.0;
|
|
246
334
|
}
|
|
247
335
|
`);
|
|
248
336
|
}
|
|
@@ -266,7 +354,12 @@ fn vdbSrcMaxIn(v: u32, uvwMin: vec3f, uvwMax: vec3f) -> f32 {
|
|
|
266
354
|
dispose() {
|
|
267
355
|
if (this.#disposed)
|
|
268
356
|
return;
|
|
269
|
-
this.#
|
|
357
|
+
for (const filler of this.#fillers.values())
|
|
358
|
+
for (const b of filler.release())
|
|
359
|
+
this.#retire.retireAfterTask(b);
|
|
360
|
+
this.#fillers.clear();
|
|
361
|
+
this.#retireTextures();
|
|
362
|
+
this.#retire.drain();
|
|
270
363
|
this.#disposed = true;
|
|
271
364
|
}
|
|
272
365
|
}
|
|
@@ -274,6 +367,10 @@ fn vdbSrcMaxIn(v: u32, uvwMin: vec3f, uvwMax: vec3f) -> f32 {
|
|
|
274
367
|
* Upload a dense `.wvdb` volume (`wvdbDenseVolume` from `@pmndrs/vdb/tools`) on
|
|
275
368
|
* the host's device. The source owns its textures and sampler; `dispose()` frees
|
|
276
369
|
* the textures (samplers have no destroy).
|
|
370
|
+
*
|
|
371
|
+
* @param device The host's `GPUDevice`; the source creates its textures on it.
|
|
372
|
+
* @param volume The decoded `.wvdb` level (`wvdbDenseVolume`).
|
|
373
|
+
* @param o Options ({@link VDBDenseSourceOptions}).
|
|
277
374
|
*/
|
|
278
375
|
export function vdbDenseSource(device, volume, o = {}) {
|
|
279
376
|
if (!device || typeof device.createTexture !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ACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF;AASD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAiB,EAAE,MAAuB,EAAE,IAA2B,EAAE;IACtG,IAAI,CAAC,MAAM,IAAI,OAAQ,MAAsC,CAAC,aAAa,KAAK,UAAU,EAAE,CAAC;QAC3F,MAAM,IAAI,QAAQ,CAAC,wBAAwB,EAAE,4CAA4C,CAAC,CAAC;IAC7F,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC1D,MAAM,GAAG,CAAC,iFAAiF,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/frameShaderChunks.js L834–1028 (createVolumeNodes: sampleMipAtlas,\n// sampleMipmapped, sample3D, sampleOptional), src/three-openvdb/frame/core/FrameVolume.js L14–22 and\n// src/three-openvdb/frame/webgpu/FrameRenderer.js L483–487 (texture setup: linear filter, clamp to edge,\n// no GPU mipmaps), src/three-openvdb/frame/webgpu/frameMipmaps.js L183–189 (mip atlas texture).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TSL → WGSL, raw WebGPU upload; mip level count from textureDimensions instead of a uniform.\n// Divergences: DIVERGES.md V23–V25.\n\n/**\n * `vdbDenseSource(device, volume)`: the dense `.wvdb` volume source on raw\n * WebGPU (K3.0, R1 §4.2). It uploads the bytes `wvdbDenseVolume` (tools) built,\n * as his renderer does: one 3D texture per channel (`r8unorm` density, mask and\n * emission; `rgba8unorm` albedo) plus a CPU box mip atlas per channel, sampled\n * with hardware trilinear (linear min/mag, clamp to edge, no GPU mipmaps).\n *\n * D10 says kernels need no textures; that holds for the sparse source. A\n * kernel compiled against a dense source binds textures, by the host's choice.\n */\n\nimport { VDBError } from \"../errors.js\";\nimport type { VDBSlot } from \"../types.js\";\nimport type { WvdbDenseTexture, WvdbDenseVolume } from \"../../tools/wvdb/dense.js\";\nimport type { VDBVolumeChannels, VDBVolumeSource, VDBVolumeSourceWgslOptions } from \"./types.js\";\n\n/** `GPUTextureUsage.TEXTURE_BINDING | COPY_DST` (0x04 | 0x02); the globals do not exist in Node. */\nconst TEXTURE_USAGE = 0x04 | 0x02;\n/** `GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE`. */\nconst STAGE_FRAGMENT_COMPUTE = 0x2 | 0x4;\n\ntype ChannelName = \"density\" | \"mask\" | \"albedo\" | \"emission\";\nconst CHANNELS: readonly ChannelName[] = [\"density\", \"mask\", \"albedo\", \"emission\"];\nconst CAP: Record<ChannelName, string> = { density: \"Density\", mask: \"Mask\", albedo: \"Albedo\", emission: \"Emission\" };\n\n/** Options of {@link vdbDenseSource}. */\nexport interface VDBDenseSourceOptions {\n /** Label prefix of the GPU objects. */\n label?: string;\n}\n\ninterface Uploaded {\n map: GPUTexture;\n mip: GPUTexture | null;\n}\n\nconst bad = (message: string) => new VDBError(\"VDB_BAD_OPTION\", message);\n\nfunction upload(device: GPUDevice, data: Uint8Array<ArrayBuffer>, dims: readonly number[], format: GPUTextureFormat, texelBytes: number, label: string): GPUTexture {\n const [w, h, d] = dims as [number, number, number];\n if (data.byteLength !== w * h * d * texelBytes) {\n throw bad(`vdbDenseSource: ${label} has ${data.byteLength} bytes, expected ${w}x${h}x${d}x${texelBytes}`);\n }\n const texture = device.createTexture({ label, size: [w, h, d], dimension: \"3d\", format, usage: TEXTURE_USAGE });\n // writeTexture has no 256-byte row alignment rule (only buffer copies do); FrameVolume uses unpackAlignment 1.\n device.queue.writeTexture({ texture }, data, { bytesPerRow: w * texelBytes, rowsPerImage: h }, [w, h, d]);\n return texture;\n}\n\nfunction uploadChannel(device: GPUDevice, tex: WvdbDenseTexture, label: string): Uploaded {\n const map = upload(device, tex.data, tex.dimensions, tex.format, tex.texelBytes, `${label}`);\n const mip = tex.mip ? upload(device, tex.mip.data, tex.mip.dimensions, tex.format, tex.texelBytes, `${label} mip atlas`) : null;\n return { map, mip };\n}\n\nfunction present(volume: WvdbDenseVolume): Record<ChannelName, WvdbDenseTexture | null> {\n return { density: volume.density, mask: volume.mask, albedo: volume.albedo, emission: volume.emission };\n}\n\nfunction checkSlot(slot: VDBSlot, where: string): VDBSlot {\n if (!slot || !Number.isInteger(slot.group) || slot.group < 0 || !Number.isInteger(slot.firstBinding) || slot.firstBinding < 0) {\n throw bad(`${where}: slot must be { group, firstBinding } with non-negative integers, got ${JSON.stringify(slot)}.`);\n }\n return slot;\n}\n\n/** WGSL for one channel's sample function (his sampleMipmapped / sampleMipAtlas, L838–877). */\nfunction channelWgsl(name: ChannelName, hasMip: boolean): string {\n const C = CAP[name];\n const map = `vdbSrc${C}Map`;\n if (!hasMip) {\n return `fn vdbSrcSample${C}(uvw: vec3f, lod: f32) -> vec4f {\\n return textureSampleLevel(${map}, vdbSrcSampler, uvw, 0.0);\\n}\\n`;\n }\n const mip = `vdbSrc${C}Mip`;\n return `fn vdbSrcMipAtlas${C}(level: f32, uvw: vec3f) -> vec4f {\n let texels = vec3f(textureDimensions(${map}));\n let atlas = vec3f(textureDimensions(${mip}));\n let size = max(vec3f(1.0), ceil(texels / exp2(level)));\n let offset = atlas.x - atlas.x / exp2(level - 1.0);\n let texel = clamp(uvw * size, vec3f(0.5), size - 0.5);\n return textureSampleLevel(${mip}, vdbSrcSampler, vec3f(texel.x + offset, texel.y, texel.z) / atlas, 0.0);\n}\nfn vdbSrcSample${C}(uvw: vec3f, lod: f32) -> vec4f {\n let level = min(lod, vdbSrcLevelCount(textureDimensions(${map})));\n if (level <= 0.0) {\n return textureSampleLevel(${map}, vdbSrcSampler, uvw, 0.0);\n }\n let level0 = floor(level);\n var low: vec4f;\n if (level0 < 0.5) {\n low = textureSampleLevel(${map}, vdbSrcSampler, uvw, 0.0);\n } else {\n low = vdbSrcMipAtlas${C}(level0, uvw);\n }\n let high = vdbSrcMipAtlas${C}(min(level0 + 1.0, vdbSrcLevelCount(textureDimensions(${map}))), uvw);\n return mix(low, high, level - level0);\n}\n`;\n}\n\nclass DenseSource implements VDBVolumeSource {\n readonly kind = \"dense\" as const;\n texels: [number, number, number];\n lodLevels: number;\n readonly channels: VDBVolumeChannels;\n stats: { meanNonZero: number; max: number; activeVoxels: number };\n /** Local unit box → uvw: translate by 0.5 (column-major). */\n readonly boxToSource = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1]);\n version = 0;\n readonly #device: GPUDevice;\n readonly #label: string;\n #volume: WvdbDenseVolume;\n #textures: Partial<Record<ChannelName, Uploaded>> = {};\n #sampler: GPUSampler;\n #disposed = false;\n\n constructor(device: GPUDevice, volume: WvdbDenseVolume, o: VDBDenseSourceOptions) {\n this.#device = device;\n this.#label = o.label ?? \"vdb dense source\";\n this.#volume = volume;\n this.channels = { mask: !!volume.mask, albedo: !!volume.albedo, emission: !!volume.emission };\n // FrameRenderer.js L483–487 + Data3DTexture defaults: linear, clamp to edge, no mipmaps.\n this.#sampler = device.createSampler({\n label: `${this.#label} sampler`,\n magFilter: \"linear\",\n minFilter: \"linear\",\n mipmapFilter: \"nearest\",\n addressModeU: \"clamp-to-edge\",\n addressModeV: \"clamp-to-edge\",\n addressModeW: \"clamp-to-edge\",\n });\n this.texels = [...volume.dimensions] as [number, number, number];\n this.lodLevels = volume.density.mip?.levels ?? 0;\n this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };\n this.#upload(volume);\n }\n\n #upload(volume: WvdbDenseVolume): void {\n const textures = present(volume);\n for (const name of CHANNELS) {\n const tex = textures[name];\n if (tex) this.#textures[name] = uploadChannel(this.#device, tex, `${this.#label} ${name}`);\n }\n }\n\n #destroyTextures(): void {\n for (const t of Object.values(this.#textures)) {\n t.map.destroy();\n t.mip?.destroy();\n }\n this.#textures = {};\n }\n\n #check(): void {\n if (this.#disposed) throw new VDBError(\"VDB_DISPOSED\", \"vdbDenseSource: the source was disposed; create a new one.\");\n }\n\n /** The textures as uploaded (for tests and adapters). */\n get volume(): WvdbDenseVolume {\n return this.#volume;\n }\n\n /**\n * Swap in another LOD (or frame) of the same grids. The channel set and mip\n * presence must match; a size change makes new textures and bumps `version`\n * (rebuild bind groups; the WGSL does not change).\n */\n replace(volume: WvdbDenseVolume): void {\n this.#check();\n const now = present(this.#volume);\n const next = present(volume);\n for (const name of CHANNELS) {\n if (!!now[name] !== !!next[name] || !!now[name]?.mip !== !!next[name]?.mip) {\n throw bad(`vdbDenseSource.replace: the ${name} channel or its mip atlas appears or disappears; create a new source (the WGSL differs).`);\n }\n }\n const sameSize = (a: WvdbDenseTexture | null, b: WvdbDenseTexture | null) =>\n !a || !b || (a.dimensions.every((v, i) => v === b.dimensions[i]) && (!a.mip || a.mip.dimensions.every((v, i) => v === b.mip!.dimensions[i])));\n if (CHANNELS.every((n) => sameSize(now[n], next[n]))) {\n for (const name of CHANNELS) {\n const tex = next[name];\n const up = this.#textures[name];\n if (!tex || !up) continue;\n const [w, h, d] = tex.dimensions;\n this.#device.queue.writeTexture({ texture: up.map }, tex.data, { bytesPerRow: w * tex.texelBytes, rowsPerImage: h }, [w, h, d]);\n if (tex.mip && up.mip) {\n const [aw, ah, ad] = tex.mip.dimensions;\n this.#device.queue.writeTexture({ texture: up.mip }, tex.mip.data, { bytesPerRow: aw * tex.texelBytes, rowsPerImage: ah }, [aw, ah, ad]);\n }\n }\n } else {\n this.#destroyTextures();\n this.#upload(volume);\n this.version++;\n }\n this.#volume = volume;\n this.texels = [...volume.dimensions] as [number, number, number];\n this.lodLevels = volume.density.mip?.levels ?? 0;\n this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };\n }\n\n /** Bindings in order: sampler, then per present channel its texture and its mip atlas. */\n #bindings(slot: VDBSlot): { name: string; binding: number; kind: \"sampler\" | \"texture\"; texture?: GPUTexture }[] {\n let b = slot.firstBinding;\n const out: { name: string; binding: number; kind: \"sampler\" | \"texture\"; texture?: GPUTexture }[] = [\n { name: \"vdbSrcSampler\", binding: b++, kind: \"sampler\" },\n ];\n for (const name of CHANNELS) {\n const t = this.#textures[name];\n if (!t) continue;\n out.push({ name: `vdbSrc${CAP[name]}Map`, binding: b++, kind: \"texture\", texture: t.map });\n if (t.mip) out.push({ name: `vdbSrc${CAP[name]}Mip`, binding: b++, kind: \"texture\", texture: t.mip });\n }\n return out;\n }\n\n wgsl(o: VDBVolumeSourceWgslOptions): string {\n this.#check();\n const slot = checkSlot(o.slot, \"vdbDenseSource.wgsl\");\n if (o.profile !== \"sample\" && o.profile !== \"march\") throw bad(`vdbDenseSource.wgsl: profile must be 'sample' or 'march', got ${JSON.stringify(o.profile)}.`);\n const on = (name: Exclude<ChannelName, \"density\">) => this.channels[name] && o.channels?.[name] !== false;\n const lines: string[] = [`// vdbDenseSource: dense .wvdb volume source (K3.0). ${this.#label}`];\n for (const b of this.#bindings(slot)) {\n lines.push(`@group(${slot.group}) @binding(${b.binding}) var ${b.name}: ${b.kind === \"sampler\" ? \"sampler\" : \"texture_3d<f32>\"};`);\n }\n lines.push(`\n// frameMipmaps.js getMipLevelCount: ceil(log2(max side)), exactly, in integers.\nfn vdbSrcLevelCount(dims: vec3u) -> f32 {\n let m = max(max(dims.x, dims.y), max(dims.z, 1u));\n if (m <= 1u) {\n return 0.0;\n }\n return f32(32u - countLeadingZeros(m - 1u));\n}\n`);\n const sampled: ChannelName[] = [\"density\", ...([\"mask\", \"albedo\", \"emission\"] as const).filter(on)];\n for (const name of sampled) lines.push(channelWgsl(name, !!this.#textures[name]?.mip));\n lines.push(`fn vdbSrcDensity(v: u32, uvw: vec3f, lod: f32) -> f32 {\n return vdbSrcSampleDensity(uvw, lod).r;\n}\nfn vdbSrcMask(v: u32, uvw: vec3f, lod: f32) -> f32 {\n return ${on(\"mask\") ? \"vdbSrcSampleMask(uvw, lod).r\" : \"1.0\"};\n}\nfn vdbSrcAlbedo(v: u32, uvw: vec3f, lod: f32) -> vec3f {\n return ${on(\"albedo\") ? \"vdbSrcSampleAlbedo(uvw, lod).rgb\" : \"vec3f(1.0)\"};\n}\nfn vdbSrcEmission(v: u32, uvw: vec3f, lod: f32) -> f32 {\n return ${on(\"emission\") ? \"vdbSrcSampleEmission(uvw, lod).r\" : \"0.0\"};\n}\nfn vdbSrcTexels(v: u32) -> vec3f {\n return vec3f(textureDimensions(vdbSrcDensityMap));\n}\nfn vdbSrcLodLevels(v: u32) -> f32 {\n return ${this.#textures.density?.mip ? \"vdbSrcLevelCount(textureDimensions(vdbSrcDensityMap))\" : \"0.0\"};\n}\n`);\n if (o.profile === \"march\") {\n // Dense: no empty-space structure; the march steps everywhere (R1 §4.2).\n lines.push(`fn vdbSrcSkipEmpty(v: u32, o: vec3f, d: vec3f, t0: f32, t1: f32) -> f32 {\n return t0;\n}\nfn vdbSrcMaxIn(v: u32, uvwMin: vec3f, uvwMax: vec3f) -> f32 {\n return ${this.stats.max.toFixed(9)};\n}\n`);\n }\n return lines.join(\"\\n\");\n }\n\n layoutEntries(slot: VDBSlot, visibility: GPUShaderStageFlags = STAGE_FRAGMENT_COMPUTE): GPUBindGroupLayoutEntry[] {\n this.#check();\n checkSlot(slot, \"vdbDenseSource.layoutEntries\");\n return this.#bindings(slot).map((b) =>\n b.kind === \"sampler\"\n ? { binding: b.binding, visibility, sampler: { type: \"filtering\" } }\n : { binding: b.binding, visibility, texture: { sampleType: \"float\", viewDimension: \"3d\" } },\n );\n }\n\n bindEntries(slot: VDBSlot): GPUBindGroupEntry[] {\n this.#check();\n checkSlot(slot, \"vdbDenseSource.bindEntries\");\n return this.#bindings(slot).map((b) => ({\n binding: b.binding,\n resource: b.kind === \"sampler\" ? this.#sampler : b.texture!.createView({ dimension: \"3d\" }),\n }));\n }\n\n dispose(): void {\n if (this.#disposed) return;\n this.#destroyTextures();\n this.#disposed = true;\n }\n}\n\n/** A dense source with `replace` (LOD swap). */\nexport type VDBDenseSource = VDBVolumeSource & {\n readonly kind: \"dense\";\n readonly volume: WvdbDenseVolume;\n replace(volume: WvdbDenseVolume): void;\n};\n\n/**\n * Upload a dense `.wvdb` volume (`wvdbDenseVolume` from `@pmndrs/vdb/tools`) on\n * the host's device. The source owns its textures and sampler; `dispose()` frees\n * the textures (samplers have no destroy).\n */\nexport function vdbDenseSource(device: GPUDevice, volume: WvdbDenseVolume, o: VDBDenseSourceOptions = {}): VDBDenseSource {\n if (!device || typeof (device as { createTexture?: unknown }).createTexture !== \"function\") {\n throw new VDBError(\"VDB_UNSUPPORTED_DEVICE\", \"vdbDenseSource: pass the host's GPUDevice.\");\n }\n if (!volume || volume.kind !== \"dense\" || !volume.density) {\n throw bad(\"vdbDenseSource: pass a dense volume from wvdbDenseVolume() (@pmndrs/vdb/tools).\");\n }\n return new DenseSource(device, volume, o);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dense.js","sourceRoot":"","sources":["../../../src/core/source/dense.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,sGAAsG;AACtG,uGAAuG;AACvG,2GAA2G;AAC3G,kGAAkG;AAClG,4GAA4G;AAC5G,uGAAuG;AACvG,oCAAoC;AAEpC;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGvF,sHAAsH;AACtH,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AACzC,0DAA0D;AAC1D,MAAM,sBAA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,GAAG,IAAI,CAAC;IACxB,CAAC;CACF;AAiBD;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,MAAiB,EAAE,MAAuB,EAAE,IAA2B,EAAE;IACtG,IAAI,CAAC,MAAM,IAAI,OAAQ,MAAsC,CAAC,aAAa,KAAK,UAAU,EAAE,CAAC;QAC3F,MAAM,IAAI,QAAQ,CAAC,wBAAwB,EAAE,4CAA4C,CAAC,CAAC;IAC7F,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC1D,MAAM,GAAG,CAAC,iFAAiF,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/frameShaderChunks.js L834–1028 (createVolumeNodes: sampleMipAtlas,\n// sampleMipmapped, sample3D, sampleOptional), src/three-openvdb/frame/core/FrameVolume.js L14–22 and\n// src/three-openvdb/frame/webgpu/FrameRenderer.js L483–487 (texture setup: linear filter, clamp to edge,\n// no GPU mipmaps), src/three-openvdb/frame/webgpu/frameMipmaps.js L183–189 (mip atlas texture).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TSL → WGSL, raw WebGPU upload; mip level count from textureDimensions instead of a uniform.\n// Divergences: DIVERGES.md V23–V25.\n\n/**\n * `vdbDenseSource(device, volume)`: the dense `.wvdb` volume source on raw\n * WebGPU (K3.0, R1 §4.2). It uploads the bytes `wvdbDenseVolume` (tools) built,\n * as his renderer does: one 3D texture per channel (`r8unorm` density, mask and\n * emission; `rgba8unorm` albedo) plus a CPU box mip atlas per channel, sampled\n * with hardware trilinear (linear min/mag, clamp to edge, no GPU mipmaps).\n *\n * D10 says kernels need no textures; that holds for the sparse source. A\n * kernel compiled against a dense source binds textures, by the host's choice.\n *\n * K4.22: a volume from `wvdbDensePartialVolume` (a `.wvdb` LOD still streaming) carries a `fill` on its\n * textures: the bricks stored but not decoded yet, and the coarser LOD to upsample there. The source fills them\n * on the GPU (`dense-fill.ts`: one compute pass, its own submit) and builds the mip atlas from the result; the\n * CPU twin (`wvdbDenseResolve`) gives the same bytes and is the fallback (`fill: 'cpu'`, or a texture too large\n * for one storage binding).\n */\n\nimport { VDBError } from \"../errors.js\";\nimport { VDBRetireQueue } from \"../frame/resources.js\";\nimport type { VDBSlot } from \"../types.js\";\nimport type { WvdbDenseTexture, WvdbDenseVolume } from \"../../tools/wvdb/dense.js\";\nimport { wvdbDenseResolveTexture } from \"../../tools/wvdb/partial.js\";\nimport { VDBDenseFiller, vdbDenseFillFits, vdbDenseFillLayout } from \"./dense-fill.js\";\nimport type { VDBVolumeChannels, VDBVolumeSlot, VDBVolumeSource, VDBVolumeSourceWgslInternalOptions, VDBVolumeSourceWgslOptions } from \"./types.js\";\n\n/** `GPUTextureUsage.TEXTURE_BINDING | COPY_DST | COPY_SRC` (0x04 | 0x02 | 0x01); the globals do not exist in Node. */\nconst TEXTURE_USAGE = 0x04 | 0x02 | 0x01;\n/** `GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE`. */\nconst STAGE_FRAGMENT_COMPUTE = 0x2 | 0x4;\n\ntype ChannelName = \"density\" | \"mask\" | \"albedo\" | \"emission\";\nconst CHANNELS: readonly ChannelName[] = [\"density\", \"mask\", \"albedo\", \"emission\"];\nconst CAP: Record<ChannelName, string> = { density: \"Density\", mask: \"Mask\", albedo: \"Albedo\", emission: \"Emission\" };\n\n/** Options of {@link vdbDenseSource}. */\nexport interface VDBDenseSourceOptions {\n /** Label prefix of the GPU objects. */\n label?: string;\n /**\n * K4.22: where a partial LOD's pending bricks (`WvdbDenseTexture.fill`) are filled: `'gpu'` (default, a compute\n * kernel) or `'cpu'` (`wvdbDenseResolve`, then an upload). Both give the same bytes; a texture whose fill buffer\n * would pass the device's storage binding or buffer size limit is filled on the CPU anyway.\n */\n fill?: \"gpu\" | \"cpu\";\n}\n\ninterface Uploaded {\n map: GPUTexture;\n mip: GPUTexture | null;\n}\n\n/** K4.22 probes: each source's live textures (core internal, `vdbDenseSourceTextures`). */\nconst liveTextures = new WeakMap<object, () => Partial<Record<ChannelName, Uploaded>>>();\n\n/**\n * @internal The textures a dense source holds now, per channel (`map`, and `mip` the atlas): for probes that read\n * them back (they have `COPY_SRC`). Null for an object that is not a dense source.\n */\nexport function vdbDenseSourceTextures(source: object): Partial<Record<ChannelName, { map: GPUTexture; mip: GPUTexture | null }>> | null {\n return liveTextures.get(source)?.() ?? null;\n}\n\nconst bad = (message: string) => new VDBError(\"VDB_BAD_OPTION\", message);\n\nfunction create(device: GPUDevice, dims: readonly number[], format: GPUTextureFormat, label: string): GPUTexture {\n const [w, h, d] = dims as [number, number, number];\n return device.createTexture({ label, size: [w, h, d], dimension: \"3d\", format, usage: TEXTURE_USAGE });\n}\n\nfunction write(device: GPUDevice, texture: GPUTexture, data: Uint8Array<ArrayBuffer>, dims: readonly number[], texelBytes: number, label: string): void {\n const [w, h, d] = dims as [number, number, number];\n if (data.byteLength !== w * h * d * texelBytes) {\n throw bad(`vdbDenseSource: ${label} has ${data.byteLength} bytes, expected ${w}x${h}x${d}x${texelBytes}`);\n }\n // writeTexture has no 256-byte row alignment rule (only buffer copies do); FrameVolume uses unpackAlignment 1.\n device.queue.writeTexture({ texture }, data, { bytesPerRow: w * texelBytes, rowsPerImage: h }, [w, h, d]);\n}\n\nfunction createChannel(device: GPUDevice, tex: WvdbDenseTexture, label: string): Uploaded {\n const map = create(device, tex.dimensions, tex.format, `${label}`);\n const mip = tex.mip ? create(device, tex.mip.dimensions, tex.format, `${label} mip atlas`) : null;\n return { map, mip };\n}\n\nfunction present(volume: WvdbDenseVolume): Record<ChannelName, WvdbDenseTexture | null> {\n return { density: volume.density, mask: volume.mask, albedo: volume.albedo, emission: volume.emission };\n}\n\nfunction checkSlot(slot: VDBSlot, where: string): VDBSlot {\n if (!slot || !Number.isInteger(slot.group) || slot.group < 0 || !Number.isInteger(slot.firstBinding) || slot.firstBinding < 0) {\n throw bad(`${where}: slot must be { group, firstBinding } with non-negative integers, got ${JSON.stringify(slot)}.`);\n }\n return slot;\n}\n\n/** WGSL for one channel's sample function (his sampleMipmapped / sampleMipAtlas, L838–877). */\nfunction channelWgsl(name: ChannelName, hasMip: boolean): string {\n const C = CAP[name];\n const map = `vdbSrc${C}Map`;\n if (!hasMip) {\n return `fn vdbSrcSample${C}(uvw: vec3f, lod: f32) -> vec4f {\\n return textureSampleLevel(${map}, vdbSrcSampler, uvw, 0.0);\\n}\\n`;\n }\n const mip = `vdbSrc${C}Mip`;\n return `fn vdbSrcMipAtlas${C}(level: f32, uvw: vec3f) -> vec4f {\n let texels = vec3f(textureDimensions(${map}));\n let atlas = vec3f(textureDimensions(${mip}));\n let size = max(vec3f(1.0), ceil(texels / exp2(level)));\n let offset = atlas.x - atlas.x / exp2(level - 1.0);\n let texel = clamp(uvw * size, vec3f(0.5), size - 0.5);\n return textureSampleLevel(${mip}, vdbSrcSampler, vec3f(texel.x + offset, texel.y, texel.z) / atlas, 0.0);\n}\nfn vdbSrcSample${C}(uvw: vec3f, lod: f32) -> vec4f {\n let level = min(lod, vdbSrcLevelCount(textureDimensions(${map})));\n if (level <= 0.0) {\n return textureSampleLevel(${map}, vdbSrcSampler, uvw, 0.0);\n }\n let level0 = floor(level);\n var low: vec4f;\n if (level0 < 0.5) {\n low = textureSampleLevel(${map}, vdbSrcSampler, uvw, 0.0);\n } else {\n low = vdbSrcMipAtlas${C}(level0, uvw);\n }\n let high = vdbSrcMipAtlas${C}(min(level0 + 1.0, vdbSrcLevelCount(textureDimensions(${map}))), uvw);\n return mix(low, high, level - level0);\n}\n`;\n}\n\nclass DenseSource implements VDBVolumeSource, VDBVolumeSlot {\n readonly kind = \"dense\" as const;\n /** A dense source is its own volume slot (K6 design §2.1): `source` is itself, `v` = 0. */\n get source(): VDBVolumeSource {\n return this;\n }\n readonly v = 0;\n texels: [number, number, number];\n lodLevels: number;\n readonly channels: VDBVolumeChannels;\n stats: { meanNonZero: number; max: number; activeVoxels: number };\n /** Local unit box → uvw: translate by 0.5 (column-major). */\n readonly boxToSource = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1]);\n version = 0;\n /** K4.22: every `replace` (same size included) bumps it: the content changed (`VDBVolumeSourceInfo.revision`). */\n revision = 0;\n readonly #device: GPUDevice;\n readonly #label: string;\n #volume: WvdbDenseVolume;\n #textures: Partial<Record<ChannelName, Uploaded>> = {};\n #sampler: GPUSampler;\n #disposed = false;\n readonly #retire = new VDBRetireQueue();\n readonly #fillMode: \"gpu\" | \"cpu\";\n /** K4.22: one GPU filler per channel while that channel's LOD streams in. */\n readonly #fillers = new Map<ChannelName, VDBDenseFiller>();\n /** K4.22: channel fills done on the GPU and on the CPU (for tests and probes). */\n readonly fills = { gpu: 0, cpu: 0 };\n\n constructor(device: GPUDevice, volume: WvdbDenseVolume, o: VDBDenseSourceOptions) {\n this.#device = device;\n this.#label = o.label ?? \"vdb dense source\";\n if (o.fill !== undefined && o.fill !== \"gpu\" && o.fill !== \"cpu\") throw bad(`vdbDenseSource: fill must be 'gpu' or 'cpu', got ${JSON.stringify(o.fill)}.`);\n this.#fillMode = o.fill ?? \"gpu\";\n liveTextures.set(this, () => ({ ...this.#textures }));\n this.#volume = volume;\n this.channels = { mask: !!volume.mask, albedo: !!volume.albedo, emission: !!volume.emission };\n // FrameRenderer.js L483–487 + Data3DTexture defaults: linear, clamp to edge, no mipmaps.\n this.#sampler = device.createSampler({\n label: `${this.#label} sampler`,\n magFilter: \"linear\",\n minFilter: \"linear\",\n mipmapFilter: \"nearest\",\n addressModeU: \"clamp-to-edge\",\n addressModeV: \"clamp-to-edge\",\n addressModeW: \"clamp-to-edge\",\n });\n this.texels = [...volume.dimensions] as [number, number, number];\n this.lodLevels = volume.density.mip?.levels ?? 0;\n this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };\n this.#upload(volume);\n }\n\n #upload(volume: WvdbDenseVolume): void {\n const textures = present(volume);\n for (const name of CHANNELS) {\n const tex = textures[name];\n if (!tex) continue;\n const up = createChannel(this.#device, tex, `${this.#label} ${name}`);\n this.#textures[name] = up;\n this.#write(name, tex, up);\n }\n }\n\n /** Writes a channel's texels and atlas; K4.22: a texture with pending bricks is filled first (GPU or CPU). */\n #write(name: ChannelName, tex: WvdbDenseTexture, up: Uploaded): void {\n const label = `${this.#label} ${name}`;\n let t = tex;\n if (tex.fill && tex.fill.count > 0) {\n if (this.#fillMode === \"gpu\" && vdbDenseFillFits(this.#device, vdbDenseFillLayout(tex))) {\n let filler = this.#fillers.get(name);\n if (!filler) this.#fillers.set(name, (filler = new VDBDenseFiller(this.#device, label)));\n for (const b of filler.fill(up.map, up.mip, tex)) this.#retire.retireAfterTask(b);\n this.fills.gpu++;\n return;\n }\n t = wvdbDenseResolveTexture(tex);\n this.fills.cpu++;\n }\n write(this.#device, up.map, t.data, t.dimensions, t.texelBytes, label);\n if (t.mip && up.mip) write(this.#device, up.mip, t.mip.data, t.mip.dimensions, t.texelBytes, `${label} mip atlas`);\n }\n\n /** Retires the GPU fillers of channels that have no pending bricks in `volume` (their LOD is complete). */\n #releaseFillers(volume: WvdbDenseVolume): void {\n const textures = present(volume);\n for (const [name, filler] of this.#fillers) {\n const tex = textures[name];\n if (tex?.fill && tex.fill.count > 0) continue;\n for (const b of filler.release()) this.#retire.retireAfterTask(b);\n this.#fillers.delete(name);\n }\n }\n\n /**\n * K6.10a: a replaced texture may be named by passes the host recorded but has not submitted yet (a `replace` between\n * the frame's `update(encoder)` and `queue.submit`), so it is destroyed in a later task (the retire queue's rule).\n * `dispose()` destroys at once.\n */\n #retireTextures(): void {\n for (const t of Object.values(this.#textures)) {\n this.#retire.retireAfterTask(t.map);\n this.#retire.retireAfterTask(t.mip);\n }\n this.#textures = {};\n }\n\n #check(): void {\n if (this.#disposed) throw new VDBError(\"VDB_DISPOSED\", \"vdbDenseSource: the source was disposed; create a new one.\");\n }\n\n /** The textures as uploaded (for tests and adapters). */\n get volume(): WvdbDenseVolume {\n return this.#volume;\n }\n\n /**\n * Swap in another LOD (or frame) of the same grids. The channel set and mip\n * presence must match; a size change makes new textures and bumps `version`\n * (rebuild bind groups; the WGSL does not change). The replaced textures are\n * destroyed in a later task (K6.10a): passes recorded with them before the\n * call stay valid when the host submits in the same task.\n */\n replace(volume: WvdbDenseVolume): void {\n this.#check();\n const now = present(this.#volume);\n const next = present(volume);\n for (const name of CHANNELS) {\n if (!!now[name] !== !!next[name] || !!now[name]?.mip !== !!next[name]?.mip) {\n throw bad(`vdbDenseSource.replace: the ${name} channel or its mip atlas appears or disappears; create a new source (the WGSL differs).`);\n }\n }\n const sameSize = (a: WvdbDenseTexture | null, b: WvdbDenseTexture | null) =>\n !a || !b || (a.dimensions.every((v, i) => v === b.dimensions[i]) && (!a.mip || a.mip.dimensions.every((v, i) => v === b.mip!.dimensions[i])));\n this.#releaseFillers(volume);\n if (CHANNELS.every((n) => sameSize(now[n], next[n]))) {\n for (const name of CHANNELS) {\n const tex = next[name];\n const up = this.#textures[name];\n if (!tex || !up) continue;\n this.#write(name, tex, up);\n }\n } else {\n this.#retireTextures();\n this.#upload(volume);\n this.version++;\n }\n this.#volume = volume;\n this.revision++;\n this.texels = [...volume.dimensions] as [number, number, number];\n this.lodLevels = volume.density.mip?.levels ?? 0;\n this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };\n }\n\n /** Bindings in order: sampler, then per present channel its texture and its mip atlas. */\n #bindings(slot: VDBSlot): { name: string; binding: number; kind: \"sampler\" | \"texture\"; texture?: GPUTexture }[] {\n let b = slot.firstBinding;\n const out: { name: string; binding: number; kind: \"sampler\" | \"texture\"; texture?: GPUTexture }[] = [\n { name: \"vdbSrcSampler\", binding: b++, kind: \"sampler\" },\n ];\n for (const name of CHANNELS) {\n const t = this.#textures[name];\n if (!t) continue;\n out.push({ name: `vdbSrc${CAP[name]}Map`, binding: b++, kind: \"texture\", texture: t.map });\n if (t.mip) out.push({ name: `vdbSrc${CAP[name]}Mip`, binding: b++, kind: \"texture\", texture: t.mip });\n }\n return out;\n }\n\n wgsl(o: VDBVolumeSourceWgslOptions): string {\n this.#check();\n const slot = checkSlot(o.slot, \"vdbDenseSource.wgsl\");\n if (o.profile !== \"sample\" && o.profile !== \"march\") throw bad(`vdbDenseSource.wgsl: profile must be 'sample' or 'march', got ${JSON.stringify(o.profile)}.`);\n const on = (name: Exclude<ChannelName, \"density\">) => this.channels[name] && o.channels?.[name] !== false;\n const lines: string[] = [`// vdbDenseSource: dense .wvdb volume source (K3.0). ${this.#label}`];\n for (const b of this.#bindings(slot)) {\n lines.push(`@group(${slot.group}) @binding(${b.binding}) var ${b.name}: ${b.kind === \"sampler\" ? \"sampler\" : \"texture_3d<f32>\"};`);\n }\n lines.push(`\n// frameMipmaps.js getMipLevelCount: ceil(log2(max side)), exactly, in integers.\nfn vdbSrcLevelCount(dims: vec3u) -> f32 {\n let m = max(max(dims.x, dims.y), max(dims.z, 1u));\n if (m <= 1u) {\n return 0.0;\n }\n return f32(32u - countLeadingZeros(m - 1u));\n}\n`);\n const sampled: ChannelName[] = [\"density\", ...([\"mask\", \"albedo\", \"emission\"] as const).filter(on)];\n for (const name of sampled) lines.push(channelWgsl(name, !!this.#textures[name]?.mip));\n lines.push(`fn vdbSrcDensity(v: u32, uvw: vec3f, lod: f32) -> f32 {\n return vdbSrcSampleDensity(uvw, lod).r;\n}\nfn vdbSrcMask(v: u32, uvw: vec3f, lod: f32) -> f32 {\n return ${on(\"mask\") ? \"vdbSrcSampleMask(uvw, lod).r\" : \"1.0\"};\n}\nfn vdbSrcAlbedo(v: u32, uvw: vec3f, lod: f32) -> vec3f {\n return ${on(\"albedo\") ? \"vdbSrcSampleAlbedo(uvw, lod).rgb\" : \"vec3f(1.0)\"};\n}\nfn vdbSrcEmission(v: u32, uvw: vec3f, lod: f32) -> f32 {\n return ${on(\"emission\") ? \"vdbSrcSampleEmission(uvw, lod).r\" : \"0.0\"};\n}\nfn vdbSrcTexels(v: u32) -> vec3f {\n return vec3f(textureDimensions(vdbSrcDensityMap));\n}\nfn vdbSrcLodLevels(v: u32) -> f32 {\n return ${this.#textures.density?.mip ? \"vdbSrcLevelCount(textureDimensions(vdbSrcDensityMap))\" : \"0.0\"};\n}\n`);\n if ((o as VDBVolumeSourceWgslInternalOptions).stochastic) {\n // Issue #2: hardware trilinear is already one fetch; the stochastic form is the deterministic one.\n lines.push(`fn vdbSrcDensityStochastic(v: u32, uvw: vec3f, lod: f32, xi: vec3f) -> f32 {\n return vdbSrcDensity(v, uvw, lod);\n}`);\n }\n if (o.profile === \"march\") {\n // Dense: no empty-space structure; the march steps everywhere (R1 §4.2). K4.22a: vdbSrcMaxIn is the r8unorm bound\n // (every texel and every filtered sample is <= 1), not stats.max: baked into the WGSL, a max that moved with each\n // partial LOD page rebuilt every frame kernel (demo 16: 7 builds at LOD 1's first page). stats.max stays on the CPU.\n lines.push(`fn vdbSrcSkipEmpty(v: u32, o: vec3f, d: vec3f, t0: f32, t1: f32) -> f32 {\n return t0;\n}\nfn vdbSrcSkipSpan(v: u32, o: vec3f, d: vec3f, t0: f32, t1: f32, lod: f32, cutoff: f32) -> vec2f {\n return vec2f(t0, 1e30);\n}\nfn vdbSrcMaxIn(v: u32, uvwMin: vec3f, uvwMax: vec3f) -> f32 {\n return 1.0;\n}\n`);\n }\n return lines.join(\"\\n\");\n }\n\n layoutEntries(slot: VDBSlot, visibility: GPUShaderStageFlags = STAGE_FRAGMENT_COMPUTE): GPUBindGroupLayoutEntry[] {\n this.#check();\n checkSlot(slot, \"vdbDenseSource.layoutEntries\");\n return this.#bindings(slot).map((b) =>\n b.kind === \"sampler\"\n ? { binding: b.binding, visibility, sampler: { type: \"filtering\" } }\n : { binding: b.binding, visibility, texture: { sampleType: \"float\", viewDimension: \"3d\" } },\n );\n }\n\n bindEntries(slot: VDBSlot): GPUBindGroupEntry[] {\n this.#check();\n checkSlot(slot, \"vdbDenseSource.bindEntries\");\n return this.#bindings(slot).map((b) => ({\n binding: b.binding,\n resource: b.kind === \"sampler\" ? this.#sampler : b.texture!.createView({ dimension: \"3d\" }),\n }));\n }\n\n dispose(): void {\n if (this.#disposed) return;\n for (const filler of this.#fillers.values()) for (const b of filler.release()) this.#retire.retireAfterTask(b);\n this.#fillers.clear();\n this.#retireTextures();\n this.#retire.drain();\n this.#disposed = true;\n }\n}\n\n/** A dense source with `replace` (LOD swap). */\nexport type VDBDenseSource = VDBVolumeSource & VDBVolumeSlot & {\n readonly kind: \"dense\";\n readonly volume: WvdbDenseVolume;\n /**\n * Swap in another LOD or frame. K4.22: a partial LOD (`wvdbDensePartialVolume`) is filled before the upload\n * (its pending bricks upsampled from the coarser LOD, on the GPU by default; see {@link VDBDenseSourceOptions}).\n */\n replace(volume: WvdbDenseVolume): void;\n /** K4.22: how many channel fills ran on the GPU and on the CPU (partial LODs). */\n readonly fills: { readonly gpu: number; readonly cpu: number };\n /** K4.22: bumps on every `replace` (the content changed; `version` only when the textures are new). */\n readonly revision: number;\n};\n\n/**\n * Upload a dense `.wvdb` volume (`wvdbDenseVolume` from `@pmndrs/vdb/tools`) on\n * the host's device. The source owns its textures and sampler; `dispose()` frees\n * the textures (samplers have no destroy).\n *\n * @param device The host's `GPUDevice`; the source creates its textures on it.\n * @param volume The decoded `.wvdb` level (`wvdbDenseVolume`).\n * @param o Options ({@link VDBDenseSourceOptions}).\n */\nexport function vdbDenseSource(device: GPUDevice, volume: WvdbDenseVolume, o: VDBDenseSourceOptions = {}): VDBDenseSource {\n if (!device || typeof (device as { createTexture?: unknown }).createTexture !== \"function\") {\n throw new VDBError(\"VDB_UNSUPPORTED_DEVICE\", \"vdbDenseSource: pass the host's GPUDevice.\");\n }\n if (!volume || volume.kind !== \"dense\" || !volume.density) {\n throw bad(\"vdbDenseSource: pass a dense volume from wvdbDenseVolume() (@pmndrs/vdb/tools).\");\n }\n return new DenseSource(device, volume, o);\n}\n"]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The WGSL and the uniform record of the core sparse source (K6.7, `vdbSparseSource`). Every `vdbSrc*` function
|
|
3
|
+
* takes `v: u32`, the volume's source-local slot, which indexes `vdbSrcVolumes`. The maths is the TSL source's
|
|
4
|
+
* (`three/sparse-source.ts`): the same sample position, the same three LOD strategies and the same HDDA rules.
|
|
5
|
+
*/
|
|
6
|
+
import type { VDBSlot } from "../types.js";
|
|
7
|
+
import type { VDBBrickKernelUse } from "../../tools/frame/brick-cache.js";
|
|
8
|
+
/** One field of the per-volume record: a name and a 16-byte WGSL type. */
|
|
9
|
+
interface RecordField {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly type: "vec4u" | "vec4f";
|
|
12
|
+
readonly doc: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The per-volume record (`VdbSrcVolume`), one field list for the WGSL struct and the TS packer. Every field is a
|
|
16
|
+
* 16-byte vector, so offsets are `index × 16` and the struct has no padding.
|
|
17
|
+
*/
|
|
18
|
+
export declare const VDB_SPARSE_RECORD_FIELDS: readonly RecordField[];
|
|
19
|
+
/** Bytes of one `VdbSrcVolume`. */
|
|
20
|
+
export declare const VDB_SPARSE_RECORD_BYTES: number;
|
|
21
|
+
/** Byte offset of a record field. */
|
|
22
|
+
export declare function sparseRecordOffset(name: string): number;
|
|
23
|
+
/** Record flags (`ids.w`). */
|
|
24
|
+
export declare const SPARSE_FLAG: {
|
|
25
|
+
readonly mask: 1;
|
|
26
|
+
readonly albedo: 2;
|
|
27
|
+
readonly albedoRgb: 4;
|
|
28
|
+
readonly emission: 8;
|
|
29
|
+
};
|
|
30
|
+
/** The values of one record (see {@link VDB_SPARSE_RECORD_FIELDS}). */
|
|
31
|
+
export interface SparseRecord {
|
|
32
|
+
ids: readonly [number, number, number, number];
|
|
33
|
+
albedo: readonly [number, number, number, number];
|
|
34
|
+
lod: readonly [number, number, number, number];
|
|
35
|
+
densityMin: readonly number[];
|
|
36
|
+
densitySize: readonly number[];
|
|
37
|
+
maskMin: readonly number[];
|
|
38
|
+
maskSize: readonly number[];
|
|
39
|
+
albedoMin: readonly number[];
|
|
40
|
+
albedoSize: readonly number[];
|
|
41
|
+
emissionMin: readonly number[];
|
|
42
|
+
emissionSize: readonly number[];
|
|
43
|
+
pyrBase: readonly number[];
|
|
44
|
+
pyrSize: readonly number[];
|
|
45
|
+
pyrMip: readonly number[];
|
|
46
|
+
}
|
|
47
|
+
/** Writes `record` at byte `offset` of `bytes` (the packer of the generated struct). */
|
|
48
|
+
export declare function packSparseRecord(bytes: ArrayBuffer, offset: number, record: SparseRecord): void;
|
|
49
|
+
/** The generated struct text. */
|
|
50
|
+
export declare function sparseRecordStructWgsl(): string;
|
|
51
|
+
/** What the WGSL depends on (the source's compile-time configuration). */
|
|
52
|
+
export interface SparseWgslConfig {
|
|
53
|
+
readonly slot: VDBSlot;
|
|
54
|
+
readonly profile: "sample" | "march";
|
|
55
|
+
readonly lod: "none" | "coarse-pyramid" | "node-average";
|
|
56
|
+
readonly channels: {
|
|
57
|
+
readonly mask: boolean;
|
|
58
|
+
readonly albedo: boolean;
|
|
59
|
+
readonly emission: boolean;
|
|
60
|
+
};
|
|
61
|
+
readonly fastTrilinear: boolean;
|
|
62
|
+
readonly cacheAccessor: boolean;
|
|
63
|
+
readonly clamp01: boolean;
|
|
64
|
+
readonly skipEmpty: boolean;
|
|
65
|
+
readonly maxVolumes: number;
|
|
66
|
+
/** Issue #2: emit `vdbSrcDensityStochastic` (one level-0 voxel per call). */
|
|
67
|
+
readonly stochastic?: boolean;
|
|
68
|
+
/** K3.2f: level-0 density through the brick cache (absent: off, the WGSL is the K6.7 text byte for byte). */
|
|
69
|
+
readonly brick?: "f32" | "f16";
|
|
70
|
+
/**
|
|
71
|
+
* K3.2f-e: how this kernel uses the cache (`tools` `vdbBrickKernelUse`). Absent: read and mark one section (the
|
|
72
|
+
* K3.2f text byte for byte).
|
|
73
|
+
*/
|
|
74
|
+
readonly brickUse?: VDBBrickKernelUse;
|
|
75
|
+
}
|
|
76
|
+
/** The brick cache's bindings (K3.2f): pages, marks, atlas and, for f16, its sampler. */
|
|
77
|
+
export interface SparseBrickBindings {
|
|
78
|
+
readonly pages: number;
|
|
79
|
+
readonly marks: number;
|
|
80
|
+
readonly atlas: number;
|
|
81
|
+
readonly sampler: number | null;
|
|
82
|
+
}
|
|
83
|
+
/** Bindings after the pool's (which is at `slot.firstBinding`, declared by the VDB module); the brick cache's last. */
|
|
84
|
+
export declare function sparseBindings(slot: VDBSlot, lod: SparseWgslConfig["lod"], brick?: SparseWgslConfig["brick"]): {
|
|
85
|
+
table: number;
|
|
86
|
+
pyramid: number | null;
|
|
87
|
+
sampler: number | null;
|
|
88
|
+
brick: SparseBrickBindings | null;
|
|
89
|
+
};
|
|
90
|
+
/** The `vdbSrc*` WGSL (without the VDB module, which must precede it in the same shader). */
|
|
91
|
+
export declare function sparseSourceWgsl(c: SparseWgslConfig): string;
|
|
92
|
+
export {};
|