@luma.gl/graph 10.0.0-alpha.5 → 10.0.0-alpha.7
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/LICENSE +38 -0
- package/README.md +11 -5
- package/dist/arrow/arrow-colors.cjs +190 -0
- package/dist/arrow/arrow-colors.d.ts +24 -0
- package/dist/arrow/arrow-colors.d.ts.map +1 -0
- package/dist/arrow/arrow-colors.js +185 -0
- package/dist/arrow/arrow-colors.js.map +1 -0
- package/dist/arrow/arrow-utils/arrow-column-info.cjs +77 -0
- package/dist/arrow/arrow-utils/arrow-column-info.d.ts +36 -0
- package/dist/arrow/arrow-utils/arrow-column-info.d.ts.map +1 -0
- package/dist/arrow/arrow-utils/arrow-column-info.js +86 -0
- package/dist/arrow/arrow-utils/arrow-column-info.js.map +1 -0
- package/dist/arrow/arrow-utils/arrow-paths.cjs +173 -0
- package/dist/arrow/arrow-utils/arrow-paths.d.ts +18 -0
- package/dist/arrow/arrow-utils/arrow-paths.d.ts.map +1 -0
- package/dist/arrow/arrow-utils/arrow-paths.js +153 -0
- package/dist/arrow/arrow-utils/arrow-paths.js.map +1 -0
- package/dist/arrow/arrow-utils/arrow-types.cjs +82 -0
- package/dist/arrow/arrow-utils/arrow-types.d.ts +36 -0
- package/dist/arrow/arrow-utils/arrow-types.d.ts.map +1 -0
- package/dist/arrow/arrow-utils/arrow-types.js +60 -0
- package/dist/arrow/arrow-utils/arrow-types.js.map +1 -0
- package/dist/arrow/dggs/dggs-gpu-polygons.cjs +667 -0
- package/dist/arrow/dggs/dggs-gpu-polygons.d.ts +75 -0
- package/dist/arrow/dggs/dggs-gpu-polygons.d.ts.map +1 -0
- package/dist/arrow/dggs/dggs-gpu-polygons.js +651 -0
- package/dist/arrow/dggs/dggs-gpu-polygons.js.map +1 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.cjs +411 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.d.ts +31 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.d.ts.map +1 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.js +395 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.js.map +1 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.cjs +304 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.d.ts +32 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.d.ts.map +1 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.js +293 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.js.map +1 -0
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.cjs +232 -0
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.d.ts +54 -0
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.d.ts.map +1 -0
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.js +222 -0
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.js.map +1 -0
- package/dist/arrow/gpu/arrow-column-gpu-vector.cjs +131 -0
- package/dist/arrow/gpu/arrow-column-gpu-vector.d.ts +34 -0
- package/dist/arrow/gpu/arrow-column-gpu-vector.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-column-gpu-vector.js +119 -0
- package/dist/arrow/gpu/arrow-column-gpu-vector.js.map +1 -0
- package/dist/arrow/gpu/arrow-compute-kernel.cjs +47 -0
- package/dist/arrow/gpu/arrow-compute-kernel.d.ts +8 -0
- package/dist/arrow/gpu/arrow-compute-kernel.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-compute-kernel.js +25 -0
- package/dist/arrow/gpu/arrow-compute-kernel.js.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.cjs +314 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.d.ts +42 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.js +318 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.js.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.cjs +204 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.d.ts +30 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.js +195 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.js.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-data.cjs +541 -0
- package/dist/arrow/gpu/arrow-gpu-data.d.ts +87 -0
- package/dist/arrow/gpu/arrow-gpu-data.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-data.js +519 -0
- package/dist/arrow/gpu/arrow-gpu-data.js.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-table-adapters.cjs +257 -0
- package/dist/arrow/gpu/arrow-gpu-table-adapters.d.ts +45 -0
- package/dist/arrow/gpu/arrow-gpu-table-adapters.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-table-adapters.js +257 -0
- package/dist/arrow/gpu/arrow-gpu-table-adapters.js.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-table-conversion.cjs +230 -0
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts +71 -0
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js +215 -0
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-vector-adapters.cjs +322 -0
- package/dist/arrow/gpu/arrow-gpu-vector-adapters.d.ts +45 -0
- package/dist/arrow/gpu/arrow-gpu-vector-adapters.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-vector-adapters.js +320 -0
- package/dist/arrow/gpu/arrow-gpu-vector-adapters.js.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.cjs +739 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts +106 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.js +796 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.js.map +1 -0
- package/dist/arrow/gpu/arrow-input-schema.cjs +36 -0
- package/dist/arrow/gpu/arrow-input-schema.d.ts +41 -0
- package/dist/arrow/gpu/arrow-input-schema.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-input-schema.js +17 -0
- package/dist/arrow/gpu/arrow-input-schema.js.map +1 -0
- package/dist/arrow/gpu/arrow-shader-layout.cjs +253 -0
- package/dist/arrow/gpu/arrow-shader-layout.d.ts +32 -0
- package/dist/arrow/gpu/arrow-shader-layout.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-shader-layout.js +236 -0
- package/dist/arrow/gpu/arrow-shader-layout.js.map +1 -0
- package/dist/arrow/index.cjs +203 -0
- package/dist/arrow/index.cjs.map +6 -0
- package/dist/arrow/index.d.ts +23 -0
- package/dist/arrow/index.d.ts.map +1 -0
- package/dist/arrow/index.js +28 -0
- package/dist/arrow/index.js.map +1 -0
- package/dist/arrow/internal.cjs +75 -0
- package/dist/arrow/internal.cjs.map +6 -0
- package/dist/arrow/internal.d.ts +36 -0
- package/dist/arrow/internal.d.ts.map +1 -0
- package/dist/arrow/internal.js +26 -0
- package/dist/arrow/internal.js.map +1 -0
- package/dist/arrow/vectors/arrow-fixed-size-list.cjs +78 -0
- package/dist/arrow/vectors/arrow-fixed-size-list.d.ts +25 -0
- package/dist/arrow/vectors/arrow-fixed-size-list.d.ts.map +1 -0
- package/dist/arrow/vectors/arrow-fixed-size-list.js +53 -0
- package/dist/arrow/vectors/arrow-fixed-size-list.js.map +1 -0
- package/dist/arrow/vectors/arrow-matrix-gpu-vector.cjs +301 -0
- package/dist/arrow/vectors/arrow-matrix-gpu-vector.d.ts +30 -0
- package/dist/arrow/vectors/arrow-matrix-gpu-vector.d.ts.map +1 -0
- package/dist/arrow/vectors/arrow-matrix-gpu-vector.js +284 -0
- package/dist/arrow/vectors/arrow-matrix-gpu-vector.js.map +1 -0
- package/dist/arrow/vectors/arrow-matrix-vector.cjs +194 -0
- package/dist/arrow/vectors/arrow-matrix-vector.d.ts +85 -0
- package/dist/arrow/vectors/arrow-matrix-vector.d.ts.map +1 -0
- package/dist/arrow/vectors/arrow-matrix-vector.js +169 -0
- package/dist/arrow/vectors/arrow-matrix-vector.js.map +1 -0
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.cjs +569 -0
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.d.ts +93 -0
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.d.ts.map +1 -0
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.js +564 -0
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.js.map +1 -0
- package/dist/arrow/vectors/arrow-vector-utils.cjs +245 -0
- package/dist/arrow/vectors/arrow-vector-utils.d.ts +30 -0
- package/dist/arrow/vectors/arrow-vector-utils.d.ts.map +1 -0
- package/dist/arrow/vectors/arrow-vector-utils.js +245 -0
- package/dist/arrow/vectors/arrow-vector-utils.js.map +1 -0
- package/dist/dist.dev.js +9812 -3216
- package/dist/dist.min.js +97 -71
- package/dist/execution/compute/kernel.cjs +112 -0
- package/dist/execution/compute/kernel.d.ts +54 -0
- package/dist/execution/compute/kernel.d.ts.map +1 -0
- package/dist/execution/compute/kernel.js +103 -0
- package/dist/execution/compute/kernel.js.map +1 -0
- package/dist/execution/compute/render-kernel.cjs +152 -0
- package/dist/execution/compute/render-kernel.d.ts +66 -0
- package/dist/execution/compute/render-kernel.d.ts.map +1 -0
- package/dist/execution/compute/render-kernel.js +148 -0
- package/dist/execution/compute/render-kernel.js.map +1 -0
- package/dist/execution/dynamic-buffer/dynamic-buffer.cjs +39 -0
- package/dist/execution/dynamic-buffer/dynamic-buffer.d.ts +2 -0
- package/dist/execution/dynamic-buffer/dynamic-buffer.d.ts.map +1 -0
- package/dist/execution/dynamic-buffer/dynamic-buffer.js +6 -0
- package/dist/execution/dynamic-buffer/dynamic-buffer.js.map +1 -0
- package/dist/execution/dynamic-texture/dynamic-texture.cjs +27 -0
- package/dist/execution/dynamic-texture/dynamic-texture.d.ts +2 -0
- package/dist/execution/dynamic-texture/dynamic-texture.d.ts.map +1 -0
- package/dist/execution/dynamic-texture/dynamic-texture.js +6 -0
- package/dist/execution/dynamic-texture/dynamic-texture.js.map +1 -0
- package/dist/execution/dynamic-texture/texture-binding-source.cjs +31 -0
- package/dist/execution/dynamic-texture/texture-binding-source.d.ts +2 -0
- package/dist/execution/dynamic-texture/texture-binding-source.d.ts.map +1 -0
- package/dist/execution/dynamic-texture/texture-binding-source.js +6 -0
- package/dist/execution/dynamic-texture/texture-binding-source.js.map +1 -0
- package/dist/execution/dynamic-texture/texture-data.cjs +53 -0
- package/dist/execution/dynamic-texture/texture-data.d.ts +2 -0
- package/dist/execution/dynamic-texture/texture-data.d.ts.map +1 -0
- package/dist/execution/dynamic-texture/texture-data.js +6 -0
- package/dist/execution/dynamic-texture/texture-data.js.map +1 -0
- package/dist/execution/utils/get-platform-info.cjs +37 -0
- package/dist/execution/utils/get-platform-info.d.ts +5 -0
- package/dist/execution/utils/get-platform-info.d.ts.map +1 -0
- package/dist/execution/utils/get-platform-info.js +16 -0
- package/dist/execution/utils/get-platform-info.js.map +1 -0
- package/dist/experimental/index.cjs +62 -5
- package/dist/experimental/index.cjs.map +3 -3
- package/dist/experimental/index.d.ts +2 -2
- package/dist/experimental/index.d.ts.map +1 -1
- package/dist/experimental/index.js +2 -2
- package/dist/experimental/index.js.map +1 -1
- package/dist/experimental/models/index.cjs.map +3 -3
- package/dist/experimental/models/path/gpu/path-storage-gpu-inputs.cjs +1 -1
- package/dist/experimental/models/path/gpu/path-storage-gpu-inputs.d.ts +1 -1
- package/dist/experimental/models/path/gpu/path-storage-gpu-inputs.js +1 -1
- package/dist/experimental/models/polygon/polygon-gpu-inputs.d.ts +3 -3
- package/dist/experimental/simulation/flow-particle-simulation.cjs +2 -2
- package/dist/experimental/simulation/flow-particle-simulation.js +1 -1
- package/dist/experimental/simulation/flow-particle-simulation.js.map +1 -1
- package/dist/experimental/simulation/index.cjs.map +3 -3
- package/dist/experimental/simulation/scientific-flow-compute.cjs +2 -2
- package/dist/experimental/simulation/scientific-flow-compute.d.ts +1 -1
- package/dist/experimental/simulation/scientific-flow-compute.d.ts.map +1 -1
- package/dist/experimental/simulation/scientific-flow-compute.js +1 -1
- package/dist/experimental/simulation/scientific-flow-compute.js.map +1 -1
- package/dist/experimental/simulation/scientific-flow-tracer.cjs +2 -2
- package/dist/experimental/simulation/scientific-flow-tracer.js +1 -1
- package/dist/experimental/simulation/scientific-flow-tracer.js.map +1 -1
- package/dist/geospatial/geospatial-utils.cjs +16 -14
- package/dist/geospatial/geospatial-utils.d.ts +2 -2
- package/dist/geospatial/geospatial-utils.d.ts.map +1 -1
- package/dist/geospatial/geospatial-utils.js +5 -3
- package/dist/geospatial/geospatial-utils.js.map +1 -1
- package/dist/geospatial/gpu-point-spatial-query.cjs +3 -3
- package/dist/geospatial/gpu-point-spatial-query.js +1 -1
- package/dist/geospatial/gpu-point-spatial-query.js.map +1 -1
- package/dist/geospatial/index.cjs.map +3 -3
- package/dist/gpu-a5/index.cjs.map +3 -3
- package/dist/gpu-core/compiled-gpu-graph.cjs +134 -0
- package/dist/gpu-core/compiled-gpu-graph.d.ts +17 -0
- package/dist/gpu-core/compiled-gpu-graph.d.ts.map +1 -0
- package/dist/gpu-core/compiled-gpu-graph.js +118 -0
- package/dist/gpu-core/compiled-gpu-graph.js.map +1 -0
- package/dist/gpu-core/dispatch-command-buffer.cjs +1 -1
- package/dist/gpu-core/dispatch-command-buffer.d.ts +1 -1
- package/dist/gpu-core/dispatch-command-buffer.js +1 -1
- package/dist/gpu-core/draw-command-buffer.cjs +1 -1
- package/dist/gpu-core/draw-command-buffer.d.ts +1 -1
- package/dist/gpu-core/draw-command-buffer.js +1 -1
- package/dist/gpu-core/gpu-adaptive-spmv.cjs +1 -1
- package/dist/gpu-core/gpu-adaptive-spmv.js +1 -1
- package/dist/gpu-core/gpu-ancestor-projection.cjs +2 -2
- package/dist/gpu-core/gpu-ancestor-projection.js +1 -1
- package/dist/gpu-core/gpu-ancestor-projection.js.map +1 -1
- package/dist/gpu-core/gpu-bvh-query.cjs +2 -2
- package/dist/gpu-core/gpu-bvh-query.js +1 -1
- package/dist/gpu-core/gpu-bvh-query.js.map +1 -1
- package/dist/gpu-core/gpu-bvh.cjs +3 -3
- package/dist/gpu-core/gpu-bvh.js +2 -2
- package/dist/gpu-core/gpu-bvh.js.map +1 -1
- package/dist/gpu-core/gpu-byte-range-gather.cjs +3 -3
- package/dist/gpu-core/gpu-byte-range-gather.js +2 -2
- package/dist/gpu-core/gpu-byte-range-gather.js.map +1 -1
- package/dist/gpu-core/gpu-chunk-utils.cjs +3 -3
- package/dist/gpu-core/gpu-chunk-utils.d.ts +1 -1
- package/dist/gpu-core/gpu-chunk-utils.js +2 -2
- package/dist/gpu-core/gpu-chunk-utils.js.map +1 -1
- package/dist/gpu-core/gpu-chunked-indexed-scatter.cjs +2 -2
- package/dist/gpu-core/gpu-chunked-indexed-scatter.js +1 -1
- package/dist/gpu-core/gpu-chunked-indexed-scatter.js.map +1 -1
- package/dist/gpu-core/gpu-command-graph-types.cjs +1 -1
- package/dist/gpu-core/gpu-command-graph-types.d.ts +3 -3
- package/dist/gpu-core/gpu-command-graph-types.js +1 -1
- package/dist/gpu-core/gpu-command-graph.cjs +1 -1
- package/dist/gpu-core/gpu-command-graph.d.ts +1 -1
- package/dist/gpu-core/gpu-command-graph.js +1 -1
- package/dist/gpu-core/gpu-compaction.cjs +3 -3
- package/dist/gpu-core/gpu-compaction.js +1 -1
- package/dist/gpu-core/gpu-compaction.js.map +1 -1
- package/dist/gpu-core/gpu-convolution.cjs +3 -3
- package/dist/gpu-core/gpu-convolution.js +2 -2
- package/dist/gpu-core/gpu-convolution.js.map +1 -1
- package/dist/gpu-core/gpu-dense-utils.cjs +3 -3
- package/dist/gpu-core/gpu-dense-utils.js +2 -2
- package/dist/gpu-core/gpu-dense-utils.js.map +1 -1
- package/dist/gpu-core/gpu-elementwise-scalar.cjs +2 -2
- package/dist/gpu-core/gpu-elementwise-scalar.js +1 -1
- package/dist/gpu-core/gpu-elementwise-scalar.js.map +1 -1
- package/dist/gpu-core/gpu-elementwise.cjs +2 -2
- package/dist/gpu-core/gpu-elementwise.js +1 -1
- package/dist/gpu-core/gpu-elementwise.js.map +1 -1
- package/dist/gpu-core/gpu-expression-cast.cjs +61 -0
- package/dist/gpu-core/gpu-expression-cast.d.ts +12 -0
- package/dist/gpu-core/gpu-expression-cast.d.ts.map +1 -0
- package/dist/gpu-core/gpu-expression-cast.js +38 -0
- package/dist/gpu-core/gpu-expression-cast.js.map +1 -0
- package/dist/gpu-core/gpu-expression-kernel.cjs +216 -0
- package/dist/gpu-core/gpu-expression-kernel.d.ts +17 -0
- package/dist/gpu-core/gpu-expression-kernel.d.ts.map +1 -0
- package/dist/gpu-core/gpu-expression-kernel.js +211 -0
- package/dist/gpu-core/gpu-expression-kernel.js.map +1 -0
- package/dist/gpu-core/gpu-expression-operation.cjs +247 -0
- package/dist/gpu-core/gpu-expression-operation.d.ts +77 -0
- package/dist/gpu-core/gpu-expression-operation.d.ts.map +1 -0
- package/dist/gpu-core/gpu-expression-operation.js +226 -0
- package/dist/gpu-core/gpu-expression-operation.js.map +1 -0
- package/dist/gpu-core/gpu-expression-plan.cjs +394 -0
- package/dist/gpu-core/gpu-expression-plan.d.ts +45 -0
- package/dist/gpu-core/gpu-expression-plan.d.ts.map +1 -0
- package/dist/gpu-core/gpu-expression-plan.js +421 -0
- package/dist/gpu-core/gpu-expression-plan.js.map +1 -0
- package/dist/gpu-core/gpu-fft1d.cjs +3 -3
- package/dist/gpu-core/gpu-fft1d.js +2 -2
- package/dist/gpu-core/gpu-fft1d.js.map +1 -1
- package/dist/gpu-core/gpu-fft2d.cjs +2 -2
- package/dist/gpu-core/gpu-fft2d.js +1 -1
- package/dist/gpu-core/gpu-fft2d.js.map +1 -1
- package/dist/gpu-core/gpu-finite-difference-utils.cjs +3 -3
- package/dist/gpu-core/gpu-finite-difference-utils.js +2 -2
- package/dist/gpu-core/gpu-finite-difference-utils.js.map +1 -1
- package/dist/gpu-core/gpu-flag-offsets.cjs +2 -2
- package/dist/gpu-core/gpu-flag-offsets.js +1 -1
- package/dist/gpu-core/gpu-flag-offsets.js.map +1 -1
- package/dist/gpu-core/gpu-galloping-search.cjs +3 -3
- package/dist/gpu-core/gpu-galloping-search.js +1 -1
- package/dist/gpu-core/gpu-galloping-search.js.map +1 -1
- package/dist/gpu-core/gpu-gather.cjs +3 -3
- package/dist/gpu-core/gpu-gather.d.ts +1 -1
- package/dist/gpu-core/gpu-gather.js +2 -2
- package/dist/gpu-core/gpu-gather.js.map +1 -1
- package/dist/gpu-core/gpu-graph-compiler.cjs +205 -142
- package/dist/gpu-core/gpu-graph-compiler.d.ts +6 -5
- package/dist/gpu-core/gpu-graph-compiler.d.ts.map +1 -1
- package/dist/gpu-core/gpu-graph-compiler.js +216 -141
- package/dist/gpu-core/gpu-graph-compiler.js.map +1 -1
- package/dist/gpu-core/gpu-graph-lowering.cjs +0 -25
- package/dist/gpu-core/gpu-graph-lowering.d.ts +10 -10
- package/dist/gpu-core/gpu-graph-lowering.d.ts.map +1 -1
- package/dist/gpu-core/gpu-graph-lowering.js +1 -14
- package/dist/gpu-core/gpu-graph-lowering.js.map +1 -1
- package/dist/gpu-core/gpu-graph-traversal.cjs +2 -2
- package/dist/gpu-core/gpu-graph-traversal.js +1 -1
- package/dist/gpu-core/gpu-graph-traversal.js.map +1 -1
- package/dist/gpu-core/gpu-graph-validation.cjs +15 -0
- package/dist/gpu-core/gpu-graph-validation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-graph-validation.js +17 -1
- package/dist/gpu-core/gpu-graph-validation.js.map +1 -1
- package/dist/gpu-core/gpu-graph-value.cjs +3 -2
- package/dist/gpu-core/gpu-graph-value.d.ts +6 -4
- package/dist/gpu-core/gpu-graph-value.d.ts.map +1 -1
- package/dist/gpu-core/gpu-graph-value.js +6 -3
- package/dist/gpu-core/gpu-graph-value.js.map +1 -1
- package/dist/gpu-core/gpu-graph.cjs +7 -2
- package/dist/gpu-core/gpu-graph.d.ts +9 -1
- package/dist/gpu-core/gpu-graph.d.ts.map +1 -1
- package/dist/gpu-core/gpu-graph.js +9 -2
- package/dist/gpu-core/gpu-graph.js.map +1 -1
- package/dist/gpu-core/gpu-group-aggregation.cjs +2 -2
- package/dist/gpu-core/gpu-group-aggregation.js +1 -1
- package/dist/gpu-core/gpu-group-aggregation.js.map +1 -1
- package/dist/gpu-core/gpu-hash-index.cjs +2 -2
- package/dist/gpu-core/gpu-hash-index.js +1 -1
- package/dist/gpu-core/gpu-hash-index.js.map +1 -1
- package/dist/gpu-core/gpu-hash-join.cjs +2 -2
- package/dist/gpu-core/gpu-hash-join.js +1 -1
- package/dist/gpu-core/gpu-hash-join.js.map +1 -1
- package/dist/gpu-core/gpu-hierarchy-layout.cjs +2 -2
- package/dist/gpu-core/gpu-hierarchy-layout.js +1 -1
- package/dist/gpu-core/gpu-hierarchy-layout.js.map +1 -1
- package/dist/gpu-core/gpu-histogram.cjs +2 -2
- package/dist/gpu-core/gpu-histogram.js +1 -1
- package/dist/gpu-core/gpu-histogram.js.map +1 -1
- package/dist/gpu-core/gpu-incremental-execution.cjs +1 -1
- package/dist/gpu-core/gpu-incremental-execution.d.ts +1 -1
- package/dist/gpu-core/gpu-incremental-execution.js +1 -1
- package/dist/gpu-core/gpu-index-picking-target.cjs +3 -3
- package/dist/gpu-core/gpu-index-picking-target.js +1 -1
- package/dist/gpu-core/gpu-index-picking-target.js.map +1 -1
- package/dist/gpu-core/gpu-indexed-range-compaction.cjs +2 -2
- package/dist/gpu-core/gpu-indexed-range-compaction.js +1 -1
- package/dist/gpu-core/gpu-indexed-range-compaction.js.map +1 -1
- package/dist/gpu-core/gpu-lz-byte-batch-decompressor.cjs +2 -2
- package/dist/gpu-core/gpu-lz-byte-batch-decompressor.js +1 -1
- package/dist/gpu-core/gpu-lz-byte-batch-decompressor.js.map +1 -1
- package/dist/gpu-core/gpu-lz-byte-decompressor.cjs +2 -2
- package/dist/gpu-core/gpu-lz-byte-decompressor.js +1 -1
- package/dist/gpu-core/gpu-lz-byte-decompressor.js.map +1 -1
- package/dist/gpu-core/gpu-mask.cjs +2 -2
- package/dist/gpu-core/gpu-mask.js +1 -1
- package/dist/gpu-core/gpu-mask.js.map +1 -1
- package/dist/gpu-core/gpu-operation-contract.cjs +63 -0
- package/dist/gpu-core/gpu-operation-contract.d.ts +30 -0
- package/dist/gpu-core/gpu-operation-contract.d.ts.map +1 -0
- package/dist/gpu-core/gpu-operation-contract.js +46 -0
- package/dist/gpu-core/gpu-operation-contract.js.map +1 -0
- package/dist/gpu-core/gpu-operation.d.ts +3 -0
- package/dist/gpu-core/gpu-operation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-operation.js.map +1 -1
- package/dist/gpu-core/gpu-predicate-conjunction.cjs +2 -2
- package/dist/gpu-core/gpu-predicate-conjunction.js +1 -1
- package/dist/gpu-core/gpu-predicate-conjunction.js.map +1 -1
- package/dist/gpu-core/gpu-reduction-substrate.cjs +2 -2
- package/dist/gpu-core/gpu-reduction-substrate.js +1 -1
- package/dist/gpu-core/gpu-reduction-substrate.js.map +1 -1
- package/dist/gpu-core/gpu-reduction.cjs +2 -2
- package/dist/gpu-core/gpu-reduction.js +1 -1
- package/dist/gpu-core/gpu-reduction.js.map +1 -1
- package/dist/gpu-core/gpu-scalar-dispatch-gate.cjs +2 -2
- package/dist/gpu-core/gpu-scalar-dispatch-gate.js +1 -1
- package/dist/gpu-core/gpu-scalar-dispatch-gate.js.map +1 -1
- package/dist/gpu-core/gpu-scalar-literal.cjs +2 -2
- package/dist/gpu-core/gpu-scalar-literal.js +1 -1
- package/dist/gpu-core/gpu-scalar-literal.js.map +1 -1
- package/dist/gpu-core/gpu-scalar-operation.cjs +2 -2
- package/dist/gpu-core/gpu-scalar-operation.js +1 -1
- package/dist/gpu-core/gpu-scalar-operation.js.map +1 -1
- package/dist/gpu-core/gpu-scan.cjs +3 -3
- package/dist/gpu-core/gpu-scan.js +1 -1
- package/dist/gpu-core/gpu-scan.js.map +1 -1
- package/dist/gpu-core/gpu-scatter.cjs +1 -1
- package/dist/gpu-core/gpu-scatter.d.ts +1 -1
- package/dist/gpu-core/gpu-scatter.js +1 -1
- package/dist/gpu-core/gpu-scene-draw-generation.cjs +2 -2
- package/dist/gpu-core/gpu-scene-draw-generation.js +1 -1
- package/dist/gpu-core/gpu-scene-draw-generation.js.map +1 -1
- package/dist/gpu-core/gpu-scene-resource-groups.cjs +2 -2
- package/dist/gpu-core/gpu-scene-resource-groups.js +1 -1
- package/dist/gpu-core/gpu-scene-resource-groups.js.map +1 -1
- package/dist/gpu-core/gpu-segment-offsets.cjs +2 -2
- package/dist/gpu-core/gpu-segment-offsets.js +1 -1
- package/dist/gpu-core/gpu-segment-offsets.js.map +1 -1
- package/dist/gpu-core/gpu-segmented-bvh.cjs +2 -2
- package/dist/gpu-core/gpu-segmented-bvh.js +1 -1
- package/dist/gpu-core/gpu-segmented-bvh.js.map +1 -1
- package/dist/gpu-core/gpu-segmented-layout.cjs +2 -2
- package/dist/gpu-core/gpu-segmented-layout.js +1 -1
- package/dist/gpu-core/gpu-segmented-layout.js.map +1 -1
- package/dist/gpu-core/gpu-segmented-reduction.cjs +2 -2
- package/dist/gpu-core/gpu-segmented-reduction.js +1 -1
- package/dist/gpu-core/gpu-segmented-reduction.js.map +1 -1
- package/dist/gpu-core/gpu-segmented-scan.cjs +2 -2
- package/dist/gpu-core/gpu-segmented-scan.js +1 -1
- package/dist/gpu-core/gpu-segmented-scan.js.map +1 -1
- package/dist/gpu-core/gpu-segmented-sort.cjs +2 -2
- package/dist/gpu-core/gpu-segmented-sort.js +1 -1
- package/dist/gpu-core/gpu-segmented-sort.js.map +1 -1
- package/dist/gpu-core/gpu-semantic-scalar-operation.cjs +9 -0
- package/dist/gpu-core/gpu-semantic-scalar-operation.d.ts +2 -0
- package/dist/gpu-core/gpu-semantic-scalar-operation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-semantic-scalar-operation.js +9 -0
- package/dist/gpu-core/gpu-semantic-scalar-operation.js.map +1 -1
- package/dist/gpu-core/gpu-semantic-spmv.cjs +13 -1
- package/dist/gpu-core/gpu-semantic-spmv.d.ts +2 -0
- package/dist/gpu-core/gpu-semantic-spmv.d.ts.map +1 -1
- package/dist/gpu-core/gpu-semantic-spmv.js +13 -1
- package/dist/gpu-core/gpu-semantic-spmv.js.map +1 -1
- package/dist/gpu-core/gpu-semantic-state-operation.cjs +3 -0
- package/dist/gpu-core/gpu-semantic-state-operation.d.ts +2 -0
- package/dist/gpu-core/gpu-semantic-state-operation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-semantic-state-operation.js +3 -0
- package/dist/gpu-core/gpu-semantic-state-operation.js.map +1 -1
- package/dist/gpu-core/gpu-semantic-vector-operation.cjs +24 -4
- package/dist/gpu-core/gpu-semantic-vector-operation.d.ts +3 -0
- package/dist/gpu-core/gpu-semantic-vector-operation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-semantic-vector-operation.js +28 -4
- package/dist/gpu-core/gpu-semantic-vector-operation.js.map +1 -1
- package/dist/gpu-core/gpu-sort.cjs +2 -2
- package/dist/gpu-core/gpu-sort.js +1 -1
- package/dist/gpu-core/gpu-sort.js.map +1 -1
- package/dist/gpu-core/gpu-spatial-utils.cjs +2 -2
- package/dist/gpu-core/gpu-spatial-utils.js +1 -1
- package/dist/gpu-core/gpu-spatial-utils.js.map +1 -1
- package/dist/gpu-core/gpu-text-selection.cjs +4 -4
- package/dist/gpu-core/gpu-text-selection.js +1 -1
- package/dist/gpu-core/gpu-text-selection.js.map +1 -1
- package/dist/gpu-core/gpu-transpose-benchmark.cjs +2 -2
- package/dist/gpu-core/gpu-transpose-benchmark.js +1 -1
- package/dist/gpu-core/gpu-transpose-benchmark.js.map +1 -1
- package/dist/gpu-core/gpu-transpose.cjs +3 -3
- package/dist/gpu-core/gpu-transpose.js +2 -2
- package/dist/gpu-core/gpu-transpose.js.map +1 -1
- package/dist/gpu-core/gpu-uint64-scan.cjs +2 -2
- package/dist/gpu-core/gpu-uint64-scan.js +1 -1
- package/dist/gpu-core/gpu-uint64-scan.js.map +1 -1
- package/dist/gpu-core/gpu-virtual-geometry-selection.cjs +3 -3
- package/dist/gpu-core/gpu-virtual-geometry-selection.js +2 -2
- package/dist/gpu-core/gpu-virtual-geometry-selection.js.map +1 -1
- package/dist/gpu-core/gpu-visibility-workflow.cjs +2 -2
- package/dist/gpu-core/gpu-visibility-workflow.js +1 -1
- package/dist/gpu-core/gpu-visibility-workflow.js.map +1 -1
- package/dist/gpu-core/gpu-workgroup-reduction-benchmark.cjs +2 -2
- package/dist/gpu-core/gpu-workgroup-reduction-benchmark.js +1 -1
- package/dist/gpu-core/gpu-workgroup-reduction-benchmark.js.map +1 -1
- package/dist/gpu-core/gpu-workgroup-scan-benchmark.cjs +2 -2
- package/dist/gpu-core/gpu-workgroup-scan-benchmark.js +1 -1
- package/dist/gpu-core/gpu-workgroup-scan-benchmark.js.map +1 -1
- package/dist/gpu-core/graph-data-view-utils.cjs +1 -1
- package/dist/gpu-core/graph-data-view-utils.d.ts +1 -1
- package/dist/gpu-core/graph-data-view-utils.js +1 -1
- package/dist/gpu-core/graph-vector-view-utils.d.ts +1 -1
- package/dist/gpu-core/index.cjs +6 -3
- package/dist/gpu-core/index.cjs.map +3 -3
- package/dist/gpu-core/index.d.ts +6 -1
- package/dist/gpu-core/index.d.ts.map +1 -1
- package/dist/gpu-core/index.js +2 -1
- package/dist/gpu-core/index.js.map +1 -1
- package/dist/gpu-core/utils/bound-kernel.cjs +3 -3
- package/dist/gpu-core/utils/bound-kernel.d.ts +1 -1
- package/dist/gpu-core/utils/bound-kernel.d.ts.map +1 -1
- package/dist/gpu-core/utils/bound-kernel.js +1 -1
- package/dist/gpu-core/utils/bound-kernel.js.map +1 -1
- package/dist/gpu-crossfilter/gpu-selection.cjs +2 -2
- package/dist/gpu-crossfilter/gpu-selection.js +1 -1
- package/dist/gpu-crossfilter/gpu-selection.js.map +1 -1
- package/dist/gpu-crossfilter/index.cjs.map +3 -3
- package/dist/gpu-data/gpu-constant.cjs +60 -0
- package/dist/gpu-data/gpu-constant.d.ts +20 -0
- package/dist/gpu-data/gpu-constant.d.ts.map +1 -0
- package/dist/gpu-data/gpu-constant.js +39 -0
- package/dist/gpu-data/gpu-constant.js.map +1 -0
- package/dist/gpu-data/gpu-data-format.cjs +133 -0
- package/dist/gpu-data/gpu-data-format.d.ts +88 -0
- package/dist/gpu-data/gpu-data-format.d.ts.map +1 -0
- package/dist/gpu-data/gpu-data-format.js +139 -0
- package/dist/gpu-data/gpu-data-format.js.map +1 -0
- package/dist/gpu-data/gpu-data-view.cjs +98 -0
- package/dist/gpu-data/gpu-data-view.d.ts +64 -0
- package/dist/gpu-data/gpu-data-view.d.ts.map +1 -0
- package/dist/gpu-data/gpu-data-view.js +85 -0
- package/dist/gpu-data/gpu-data-view.js.map +1 -0
- package/dist/gpu-data/gpu-data.cjs +180 -0
- package/dist/gpu-data/gpu-data.d.ts +178 -0
- package/dist/gpu-data/gpu-data.d.ts.map +1 -0
- package/dist/gpu-data/gpu-data.js +186 -0
- package/dist/gpu-data/gpu-data.js.map +1 -0
- package/dist/gpu-data/gpu-sparse-matrix.cjs +77 -0
- package/dist/gpu-data/gpu-sparse-matrix.d.ts +34 -0
- package/dist/gpu-data/gpu-sparse-matrix.d.ts.map +1 -0
- package/dist/gpu-data/gpu-sparse-matrix.js +54 -0
- package/dist/gpu-data/gpu-sparse-matrix.js.map +1 -0
- package/dist/gpu-data/gpu-vector-chunks.cjs +34 -0
- package/dist/gpu-data/gpu-vector-chunks.d.ts +13 -0
- package/dist/gpu-data/gpu-vector-chunks.d.ts.map +1 -0
- package/dist/gpu-data/gpu-vector-chunks.js +13 -0
- package/dist/gpu-data/gpu-vector-chunks.js.map +1 -0
- package/dist/gpu-data/gpu-vector-format.cjs +173 -0
- package/dist/gpu-data/gpu-vector-format.d.ts +81 -0
- package/dist/gpu-data/gpu-vector-format.d.ts.map +1 -0
- package/dist/gpu-data/gpu-vector-format.js +153 -0
- package/dist/gpu-data/gpu-vector-format.js.map +1 -0
- package/dist/gpu-data/gpu-vector-like.cjs +15 -0
- package/dist/gpu-data/gpu-vector-like.d.ts +22 -0
- package/dist/gpu-data/gpu-vector-like.d.ts.map +1 -0
- package/dist/gpu-data/gpu-vector-like.js +5 -0
- package/dist/gpu-data/gpu-vector-like.js.map +1 -0
- package/dist/gpu-data/gpu-vector-utils.cjs +86 -0
- package/dist/gpu-data/gpu-vector-utils.d.ts +21 -0
- package/dist/gpu-data/gpu-vector-utils.d.ts.map +1 -0
- package/dist/gpu-data/gpu-vector-utils.js +59 -0
- package/dist/gpu-data/gpu-vector-utils.js.map +1 -0
- package/dist/gpu-data/gpu-vector.cjs +273 -0
- package/dist/gpu-data/gpu-vector.d.ts +178 -0
- package/dist/gpu-data/gpu-vector.d.ts.map +1 -0
- package/dist/gpu-data/gpu-vector.js +263 -0
- package/dist/gpu-data/gpu-vector.js.map +1 -0
- package/dist/gpu-data/index.cjs +79 -0
- package/dist/gpu-data/index.cjs.map +6 -0
- package/dist/gpu-data/index.d.ts +11 -0
- package/dist/gpu-data/index.d.ts.map +1 -0
- package/dist/gpu-data/index.js +13 -0
- package/dist/gpu-data/index.js.map +1 -0
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.cjs +3 -3
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.js +2 -2
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.js.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame.cjs +1 -1
- package/dist/gpu-dataframe/gpu-data-frame.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-data-frame.js +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.cjs +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.cjs +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.js +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.cjs +3 -3
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.js +2 -2
- package/dist/gpu-dataframe/gpu-query-compiler.js.map +1 -1
- package/dist/gpu-dataframe/index.cjs.map +3 -3
- package/dist/gpu-dggs/benchmarks.cjs.map +3 -3
- package/dist/gpu-dggs/gpu-dggs-cell-projection.cjs +4 -4
- package/dist/gpu-dggs/gpu-dggs-cell-projection.js +2 -2
- package/dist/gpu-dggs/gpu-dggs-cell-projection.js.map +1 -1
- package/dist/gpu-dggs/index.cjs.map +3 -3
- package/dist/gpu-effects/index.cjs.map +3 -3
- package/dist/gpu-geometry/index.cjs.map +3 -3
- package/dist/gpu-graph/index.cjs +2 -5
- package/dist/gpu-graph/index.cjs.map +3 -3
- package/dist/gpu-graph/index.d.ts +3 -1
- package/dist/gpu-graph/index.d.ts.map +1 -1
- package/dist/gpu-graph/index.js +0 -1
- package/dist/gpu-graph/index.js.map +1 -1
- package/dist/gpu-graph-algorithms/benchmarks.cjs.map +3 -3
- package/dist/gpu-graph-algorithms/gpu-graph-benchmark.cjs +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-benchmark.js +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-breadth-first-search-internals.cjs +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-breadth-first-search-internals.js +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-breadth-first-search-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-breadth-first-search.d.ts +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-connected-components-internals.cjs +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-connected-components-internals.js +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-connected-components-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-connected-components.d.ts +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-core-number-internals.cjs +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-core-number-internals.js +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-core-number-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-core-number.d.ts +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-degree-internals.cjs +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-degree-internals.js +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-degree-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-degree.d.ts +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-force-layout-internals.cjs +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-force-layout-internals.js +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-force-layout-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-force-layout.d.ts +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-label-propagation-internals.cjs +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-label-propagation-internals.js +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-label-propagation-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-label-propagation.d.ts +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-local-clustering-coefficient-internals.cjs +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-local-clustering-coefficient-internals.js +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-local-clustering-coefficient-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-local-clustering-coefficient.d.ts +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-modularity-internals.cjs +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-modularity-internals.js +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-modularity-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-modularity-optimization-internals.cjs +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-modularity-optimization-internals.js +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-modularity-optimization-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-modularity-optimization.d.ts +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-modularity.d.ts +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-page-rank-internals.cjs +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-page-rank-internals.js +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-page-rank-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-page-rank.d.ts +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.cjs +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.js +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.d.ts +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-spatial-force-layout-internals.cjs +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-spatial-force-layout-internals.js +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-spatial-force-layout-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-spatial-force-layout.d.ts +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-topology-internals.cjs +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-topology-internals.js +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-topology-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-topology.d.ts +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph.d.ts +1 -1
- package/dist/gpu-graph-algorithms/index.cjs.map +3 -3
- package/dist/gpu-h3/index.cjs.map +3 -3
- package/dist/gpu-parse/index.cjs.map +3 -3
- package/dist/gpu-parse/parquet/gpu-parquet-bit-packed-decoder.cjs +2 -2
- package/dist/gpu-parse/parquet/gpu-parquet-bit-packed-decoder.js +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-bit-packed-decoder.js.map +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-byte-stream-split-batch-decoder.cjs +2 -2
- package/dist/gpu-parse/parquet/gpu-parquet-byte-stream-split-batch-decoder.js +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-byte-stream-split-batch-decoder.js.map +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-byte-stream-split-decoder.cjs +2 -2
- package/dist/gpu-parse/parquet/gpu-parquet-byte-stream-split-decoder.js +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-byte-stream-split-decoder.js.map +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-delta-binary-packed-int64-unpacker.cjs +2 -2
- package/dist/gpu-parse/parquet/gpu-parquet-delta-binary-packed-int64-unpacker.js +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-delta-binary-packed-int64-unpacker.js.map +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-delta-binary-packed-unpacker.cjs +2 -2
- package/dist/gpu-parse/parquet/gpu-parquet-delta-binary-packed-unpacker.js +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-delta-binary-packed-unpacker.js.map +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-delta-byte-array-decoder.cjs +2 -2
- package/dist/gpu-parse/parquet/gpu-parquet-delta-byte-array-decoder.js +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-delta-byte-array-decoder.js.map +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-dictionary-decoder.cjs +2 -2
- package/dist/gpu-parse/parquet/gpu-parquet-dictionary-decoder.js +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-dictionary-decoder.js.map +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-level-layout.cjs +2 -2
- package/dist/gpu-parse/parquet/gpu-parquet-level-layout.js +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-level-layout.js.map +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-nested-column-layout.cjs +2 -2
- package/dist/gpu-parse/parquet/gpu-parquet-nested-column-layout.js +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-nested-column-layout.js.map +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-plain-boolean-decoder.cjs +2 -2
- package/dist/gpu-parse/parquet/gpu-parquet-plain-boolean-decoder.js +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-plain-boolean-decoder.js.map +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-rle-bit-packed-decoder.cjs +2 -2
- package/dist/gpu-parse/parquet/gpu-parquet-rle-bit-packed-decoder.js +1 -1
- package/dist/gpu-parse/parquet/gpu-parquet-rle-bit-packed-decoder.js.map +1 -1
- package/dist/gpu-physics/index.cjs.map +3 -3
- package/dist/gpu-physics/rigid-body-broad-phase.cjs +2 -2
- package/dist/gpu-physics/rigid-body-broad-phase.js +1 -1
- package/dist/gpu-physics/rigid-body-broad-phase.js.map +1 -1
- package/dist/gpu-pointcloud/index.cjs.map +3 -3
- package/dist/gpu-project/benchmarks.cjs.map +3 -3
- package/dist/gpu-project/crs.cjs.map +3 -3
- package/dist/gpu-project/gpu-projection-table.cjs +1 -1
- package/dist/gpu-project/gpu-projection-table.js +1 -1
- package/dist/gpu-project/index.cjs.map +3 -3
- package/dist/gpu-project/projection-program.cjs +2 -2
- package/dist/gpu-project/projection-program.d.ts +1 -1
- package/dist/gpu-project/projection-program.d.ts.map +1 -1
- package/dist/gpu-project/projection-program.js +1 -1
- package/dist/gpu-project/projection-program.js.map +1 -1
- package/dist/gpu-project/projection-table-benchmark.cjs +1 -1
- package/dist/gpu-project/projection-table-benchmark.js +1 -1
- package/dist/gpu-raster/gpu-raster-band-math.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-band-math.js +1 -1
- package/dist/gpu-raster/gpu-raster-band-math.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-buffer-to-texture.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-buffer-to-texture.js +1 -1
- package/dist/gpu-raster/gpu-raster-buffer-to-texture.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-connected-components.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-connected-components.js +1 -1
- package/dist/gpu-raster/gpu-raster-connected-components.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-contours.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-contours.js +1 -1
- package/dist/gpu-raster/gpu-raster-contours.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-contrast.cjs +3 -3
- package/dist/gpu-raster/gpu-raster-contrast.js +1 -1
- package/dist/gpu-raster/gpu-raster-contrast.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-cross-tile-components.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-cross-tile-components.js +1 -1
- package/dist/gpu-raster/gpu-raster-cross-tile-components.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-dense-components.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-dense-components.js +1 -1
- package/dist/gpu-raster/gpu-raster-dense-components.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-edges.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-edges.js +1 -1
- package/dist/gpu-raster/gpu-raster-edges.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-global-statistics.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-global-statistics.js +1 -1
- package/dist/gpu-raster/gpu-raster-global-statistics.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-histogram.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-histogram.js +1 -1
- package/dist/gpu-raster/gpu-raster-histogram.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-morphology.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-morphology.js +1 -1
- package/dist/gpu-raster/gpu-raster-morphology.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-neighborhood.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-neighborhood.js +1 -1
- package/dist/gpu-raster/gpu-raster-neighborhood.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-overview.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-overview.js +1 -1
- package/dist/gpu-raster/gpu-raster-overview.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-region-measurements.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-region-measurements.js +1 -1
- package/dist/gpu-raster/gpu-raster-region-measurements.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-statistics.cjs +3 -3
- package/dist/gpu-raster/gpu-raster-statistics.js +1 -1
- package/dist/gpu-raster/gpu-raster-statistics.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-texture-to-buffer.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-texture-to-buffer.js +1 -1
- package/dist/gpu-raster/gpu-raster-texture-to-buffer.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-threshold.cjs +3 -3
- package/dist/gpu-raster/gpu-raster-threshold.js +1 -1
- package/dist/gpu-raster/gpu-raster-threshold.js.map +1 -1
- package/dist/gpu-raster/gpu-raster-tile-halo.cjs +2 -2
- package/dist/gpu-raster/gpu-raster-tile-halo.js +1 -1
- package/dist/gpu-raster/gpu-raster-tile-halo.js.map +1 -1
- package/dist/gpu-raster/index.cjs.map +3 -3
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.cjs +228 -0
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts +15 -0
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts.map +1 -0
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js +228 -0
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js.map +1 -0
- package/dist/gpu-simple-graph/gpu-expression-cast-operation.cjs +150 -0
- package/dist/gpu-simple-graph/gpu-expression-cast-operation.d.ts +18 -0
- package/dist/gpu-simple-graph/gpu-expression-cast-operation.d.ts.map +1 -0
- package/dist/gpu-simple-graph/gpu-expression-cast-operation.js +123 -0
- package/dist/gpu-simple-graph/gpu-expression-cast-operation.js.map +1 -0
- package/dist/gpu-simple-graph/gpu-expression-row-operation.cjs +100 -0
- package/dist/gpu-simple-graph/gpu-expression-row-operation.d.ts +15 -0
- package/dist/gpu-simple-graph/gpu-expression-row-operation.d.ts.map +1 -0
- package/dist/gpu-simple-graph/gpu-expression-row-operation.js +74 -0
- package/dist/gpu-simple-graph/gpu-expression-row-operation.js.map +1 -0
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.cjs +14 -12
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts +2 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js +3 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-operation.cjs +5 -4
- package/dist/gpu-simple-graph/gpu-simple-graph-operation.d.ts +3 -2
- package/dist/gpu-simple-graph/gpu-simple-graph-operation.d.ts.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-operation.js +2 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-operation.js.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-transfer.cjs +7 -5
- package/dist/gpu-simple-graph/gpu-simple-graph-transfer.d.ts.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-transfer.js +3 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-transfer.js.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-value.cjs +44 -31
- package/dist/gpu-simple-graph/gpu-simple-graph-value.d.ts +17 -3
- package/dist/gpu-simple-graph/gpu-simple-graph-value.d.ts.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-value.js +15 -2
- package/dist/gpu-simple-graph/gpu-simple-graph-value.js.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph.cjs +39 -14
- package/dist/gpu-simple-graph/gpu-simple-graph.d.ts +22 -5
- package/dist/gpu-simple-graph/gpu-simple-graph.d.ts.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph.js +34 -8
- package/dist/gpu-simple-graph/gpu-simple-graph.js.map +1 -1
- package/dist/gpu-simple-graph/index.cjs +99 -2
- package/dist/gpu-simple-graph/index.cjs.map +3 -3
- package/dist/gpu-simple-graph/index.d.ts +30 -0
- package/dist/gpu-simple-graph/index.d.ts.map +1 -1
- package/dist/gpu-simple-graph/index.js +25 -0
- package/dist/gpu-simple-graph/index.js.map +1 -1
- package/dist/gpu-simple-graph/operation/backend-registry.cjs +145 -0
- package/dist/gpu-simple-graph/operation/backend-registry.d.ts +44 -0
- package/dist/gpu-simple-graph/operation/backend-registry.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operation/backend-registry.js +135 -0
- package/dist/gpu-simple-graph/operation/backend-registry.js.map +1 -0
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.cjs +707 -0
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts +248 -0
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js +731 -0
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js.map +1 -0
- package/dist/gpu-simple-graph/operation/gpu-evaluation-scope.cjs +108 -0
- package/dist/gpu-simple-graph/operation/gpu-evaluation-scope.d.ts +39 -0
- package/dist/gpu-simple-graph/operation/gpu-evaluation-scope.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operation/gpu-evaluation-scope.js +99 -0
- package/dist/gpu-simple-graph/operation/gpu-evaluation-scope.js.map +1 -0
- package/dist/gpu-simple-graph/operation/gpu-evaluator-inspection.cjs +84 -0
- package/dist/gpu-simple-graph/operation/gpu-evaluator-inspection.d.ts +36 -0
- package/dist/gpu-simple-graph/operation/gpu-evaluator-inspection.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operation/gpu-evaluator-inspection.js +71 -0
- package/dist/gpu-simple-graph/operation/gpu-evaluator-inspection.js.map +1 -0
- package/dist/gpu-simple-graph/operation/gpu-table-format-types.cjs +15 -0
- package/dist/gpu-simple-graph/operation/gpu-table-format-types.d.ts +30 -0
- package/dist/gpu-simple-graph/operation/gpu-table-format-types.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operation/gpu-table-format-types.js +5 -0
- package/dist/gpu-simple-graph/operation/gpu-table-format-types.js.map +1 -0
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.cjs +236 -0
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts +107 -0
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js +232 -0
- package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js.map +1 -0
- package/dist/gpu-simple-graph/operation/operation.cjs +100 -0
- package/dist/gpu-simple-graph/operation/operation.d.ts +56 -0
- package/dist/gpu-simple-graph/operation/operation.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operation/operation.js +85 -0
- package/dist/gpu-simple-graph/operation/operation.js.map +1 -0
- package/dist/gpu-simple-graph/operations/arithmetic-expression.cjs +40 -0
- package/dist/gpu-simple-graph/operations/arithmetic-expression.d.ts +9 -0
- package/dist/gpu-simple-graph/operations/arithmetic-expression.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/arithmetic-expression.js +18 -0
- package/dist/gpu-simple-graph/operations/arithmetic-expression.js.map +1 -0
- package/dist/gpu-simple-graph/operations/arithmetic-operation.cjs +210 -0
- package/dist/gpu-simple-graph/operations/arithmetic-operation.d.ts +14 -0
- package/dist/gpu-simple-graph/operations/arithmetic-operation.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/arithmetic-operation.js +192 -0
- package/dist/gpu-simple-graph/operations/arithmetic-operation.js.map +1 -0
- package/dist/gpu-simple-graph/operations/arithmetic.cjs +94 -0
- package/dist/gpu-simple-graph/operations/arithmetic.d.ts +63 -0
- package/dist/gpu-simple-graph/operations/arithmetic.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/arithmetic.js +98 -0
- package/dist/gpu-simple-graph/operations/arithmetic.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cast-data.cjs +61 -0
- package/dist/gpu-simple-graph/operations/cast-data.d.ts +18 -0
- package/dist/gpu-simple-graph/operations/cast-data.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cast-data.js +41 -0
- package/dist/gpu-simple-graph/operations/cast-data.js.map +1 -0
- package/dist/gpu-simple-graph/operations/convert-colors.cjs +66 -0
- package/dist/gpu-simple-graph/operations/convert-colors.d.ts +12 -0
- package/dist/gpu-simple-graph/operations/convert-colors.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/convert-colors.js +45 -0
- package/dist/gpu-simple-graph/operations/convert-colors.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/arithmetic.cjs +110 -0
- package/dist/gpu-simple-graph/operations/cpu/arithmetic.d.ts +4 -0
- package/dist/gpu-simple-graph/operations/cpu/arithmetic.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/arithmetic.js +88 -0
- package/dist/gpu-simple-graph/operations/cpu/arithmetic.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/cast-data.cjs +83 -0
- package/dist/gpu-simple-graph/operations/cpu/cast-data.d.ts +5 -0
- package/dist/gpu-simple-graph/operations/cpu/cast-data.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/cast-data.js +62 -0
- package/dist/gpu-simple-graph/operations/cpu/cast-data.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/common.cjs +106 -0
- package/dist/gpu-simple-graph/operations/cpu/common.d.ts +23 -0
- package/dist/gpu-simple-graph/operations/cpu/common.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/common.js +85 -0
- package/dist/gpu-simple-graph/operations/cpu/common.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/convert-colors.cjs +60 -0
- package/dist/gpu-simple-graph/operations/cpu/convert-colors.d.ts +4 -0
- package/dist/gpu-simple-graph/operations/cpu/convert-colors.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/convert-colors.js +40 -0
- package/dist/gpu-simple-graph/operations/cpu/convert-colors.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/dot.cjs +42 -0
- package/dist/gpu-simple-graph/operations/cpu/dot.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/cpu/dot.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/dot.js +20 -0
- package/dist/gpu-simple-graph/operations/cpu/dot.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/equal-all.cjs +45 -0
- package/dist/gpu-simple-graph/operations/cpu/equal-all.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/cpu/equal-all.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/equal-all.js +23 -0
- package/dist/gpu-simple-graph/operations/cpu/equal-all.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/extent.cjs +62 -0
- package/dist/gpu-simple-graph/operations/cpu/extent.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/cpu/extent.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/extent.js +40 -0
- package/dist/gpu-simple-graph/operations/cpu/extent.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/fround.cjs +44 -0
- package/dist/gpu-simple-graph/operations/cpu/fround.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/cpu/fround.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/fround.js +22 -0
- package/dist/gpu-simple-graph/operations/cpu/fround.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/gather.cjs +54 -0
- package/dist/gpu-simple-graph/operations/cpu/gather.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/cpu/gather.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/gather.js +34 -0
- package/dist/gpu-simple-graph/operations/cpu/gather.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/index.cjs +66 -0
- package/dist/gpu-simple-graph/operations/cpu/index.cjs.map +6 -0
- package/dist/gpu-simple-graph/operations/cpu/index.d.ts +17 -0
- package/dist/gpu-simple-graph/operations/cpu/index.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/index.js +20 -0
- package/dist/gpu-simple-graph/operations/cpu/index.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/interleave.cjs +41 -0
- package/dist/gpu-simple-graph/operations/cpu/interleave.d.ts +4 -0
- package/dist/gpu-simple-graph/operations/cpu/interleave.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/interleave.js +19 -0
- package/dist/gpu-simple-graph/operations/cpu/interleave.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/length.cjs +41 -0
- package/dist/gpu-simple-graph/operations/cpu/length.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/cpu/length.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/length.js +19 -0
- package/dist/gpu-simple-graph/operations/cpu/length.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/segmented-map.cjs +72 -0
- package/dist/gpu-simple-graph/operations/cpu/segmented-map.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/cpu/segmented-map.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/segmented-map.js +52 -0
- package/dist/gpu-simple-graph/operations/cpu/segmented-map.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/select.cjs +48 -0
- package/dist/gpu-simple-graph/operations/cpu/select.d.ts +8 -0
- package/dist/gpu-simple-graph/operations/cpu/select.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/select.js +29 -0
- package/dist/gpu-simple-graph/operations/cpu/select.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/sequence.cjs +37 -0
- package/dist/gpu-simple-graph/operations/cpu/sequence.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/cpu/sequence.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/sequence.js +15 -0
- package/dist/gpu-simple-graph/operations/cpu/sequence.js.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/swizzle.cjs +40 -0
- package/dist/gpu-simple-graph/operations/cpu/swizzle.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/cpu/swizzle.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/cpu/swizzle.js +18 -0
- package/dist/gpu-simple-graph/operations/cpu/swizzle.js.map +1 -0
- package/dist/gpu-simple-graph/operations/dot.cjs +58 -0
- package/dist/gpu-simple-graph/operations/dot.d.ts +3 -0
- package/dist/gpu-simple-graph/operations/dot.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/dot.js +36 -0
- package/dist/gpu-simple-graph/operations/dot.js.map +1 -0
- package/dist/gpu-simple-graph/operations/equal-all.cjs +57 -0
- package/dist/gpu-simple-graph/operations/equal-all.d.ts +3 -0
- package/dist/gpu-simple-graph/operations/equal-all.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/equal-all.js +35 -0
- package/dist/gpu-simple-graph/operations/equal-all.js.map +1 -0
- package/dist/gpu-simple-graph/operations/extent.cjs +51 -0
- package/dist/gpu-simple-graph/operations/extent.d.ts +9 -0
- package/dist/gpu-simple-graph/operations/extent.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/extent.js +36 -0
- package/dist/gpu-simple-graph/operations/extent.js.map +1 -0
- package/dist/gpu-simple-graph/operations/fround.cjs +49 -0
- package/dist/gpu-simple-graph/operations/fround.d.ts +10 -0
- package/dist/gpu-simple-graph/operations/fround.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/fround.js +35 -0
- package/dist/gpu-simple-graph/operations/fround.js.map +1 -0
- package/dist/gpu-simple-graph/operations/gather.cjs +52 -0
- package/dist/gpu-simple-graph/operations/gather.d.ts +10 -0
- package/dist/gpu-simple-graph/operations/gather.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/gather.js +38 -0
- package/dist/gpu-simple-graph/operations/gather.js.map +1 -0
- package/dist/gpu-simple-graph/operations/interleave.cjs +59 -0
- package/dist/gpu-simple-graph/operations/interleave.d.ts +9 -0
- package/dist/gpu-simple-graph/operations/interleave.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/interleave.js +44 -0
- package/dist/gpu-simple-graph/operations/interleave.js.map +1 -0
- package/dist/gpu-simple-graph/operations/length.cjs +49 -0
- package/dist/gpu-simple-graph/operations/length.d.ts +3 -0
- package/dist/gpu-simple-graph/operations/length.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/length.js +27 -0
- package/dist/gpu-simple-graph/operations/length.js.map +1 -0
- package/dist/gpu-simple-graph/operations/segmented-map.cjs +91 -0
- package/dist/gpu-simple-graph/operations/segmented-map.d.ts +10 -0
- package/dist/gpu-simple-graph/operations/segmented-map.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/segmented-map.js +78 -0
- package/dist/gpu-simple-graph/operations/segmented-map.js.map +1 -0
- package/dist/gpu-simple-graph/operations/select.cjs +61 -0
- package/dist/gpu-simple-graph/operations/select.d.ts +9 -0
- package/dist/gpu-simple-graph/operations/select.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/select.js +46 -0
- package/dist/gpu-simple-graph/operations/select.js.map +1 -0
- package/dist/gpu-simple-graph/operations/sequence.cjs +65 -0
- package/dist/gpu-simple-graph/operations/sequence.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/sequence.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/sequence.js +47 -0
- package/dist/gpu-simple-graph/operations/sequence.js.map +1 -0
- package/dist/gpu-simple-graph/operations/swizzle.cjs +110 -0
- package/dist/gpu-simple-graph/operations/swizzle.d.ts +3 -0
- package/dist/gpu-simple-graph/operations/swizzle.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/swizzle.js +88 -0
- package/dist/gpu-simple-graph/operations/swizzle.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/arithmetic.cjs +77 -0
- package/dist/gpu-simple-graph/operations/webgl/arithmetic.d.ts +4 -0
- package/dist/gpu-simple-graph/operations/webgl/arithmetic.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/arithmetic.js +56 -0
- package/dist/gpu-simple-graph/operations/webgl/arithmetic.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/cast-data.cjs +27 -0
- package/dist/gpu-simple-graph/operations/webgl/cast-data.d.ts +2 -0
- package/dist/gpu-simple-graph/operations/webgl/cast-data.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/cast-data.js +6 -0
- package/dist/gpu-simple-graph/operations/webgl/cast-data.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/common/helper.cjs +147 -0
- package/dist/gpu-simple-graph/operations/webgl/common/helper.d.ts +10 -0
- package/dist/gpu-simple-graph/operations/webgl/common/helper.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/common/helper.js +114 -0
- package/dist/gpu-simple-graph/operations/webgl/common/helper.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/common/random-access-transform.cjs +68 -0
- package/dist/gpu-simple-graph/operations/webgl/common/random-access-transform.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/webgl/common/random-access-transform.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/common/random-access-transform.js +44 -0
- package/dist/gpu-simple-graph/operations/webgl/common/random-access-transform.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/common/row-transform.cjs +201 -0
- package/dist/gpu-simple-graph/operations/webgl/common/row-transform.d.ts +23 -0
- package/dist/gpu-simple-graph/operations/webgl/common/row-transform.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/common/row-transform.js +173 -0
- package/dist/gpu-simple-graph/operations/webgl/common/row-transform.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/common/transform-kernel.cjs +88 -0
- package/dist/gpu-simple-graph/operations/webgl/common/transform-kernel.d.ts +22 -0
- package/dist/gpu-simple-graph/operations/webgl/common/transform-kernel.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/common/transform-kernel.js +71 -0
- package/dist/gpu-simple-graph/operations/webgl/common/transform-kernel.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/convert-colors.cjs +27 -0
- package/dist/gpu-simple-graph/operations/webgl/convert-colors.d.ts +2 -0
- package/dist/gpu-simple-graph/operations/webgl/convert-colors.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/convert-colors.js +7 -0
- package/dist/gpu-simple-graph/operations/webgl/convert-colors.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/dot.cjs +45 -0
- package/dist/gpu-simple-graph/operations/webgl/dot.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/webgl/dot.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/dot.js +24 -0
- package/dist/gpu-simple-graph/operations/webgl/dot.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/equal-all.cjs +48 -0
- package/dist/gpu-simple-graph/operations/webgl/equal-all.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/webgl/equal-all.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/equal-all.js +27 -0
- package/dist/gpu-simple-graph/operations/webgl/equal-all.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/extent.cjs +193 -0
- package/dist/gpu-simple-graph/operations/webgl/extent.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/webgl/extent.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/extent.js +169 -0
- package/dist/gpu-simple-graph/operations/webgl/extent.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/fround.cjs +220 -0
- package/dist/gpu-simple-graph/operations/webgl/fround.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/webgl/fround.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/fround.js +196 -0
- package/dist/gpu-simple-graph/operations/webgl/fround.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/gather.cjs +143 -0
- package/dist/gpu-simple-graph/operations/webgl/gather.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/webgl/gather.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/gather.js +120 -0
- package/dist/gpu-simple-graph/operations/webgl/gather.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/index.cjs +66 -0
- package/dist/gpu-simple-graph/operations/webgl/index.cjs.map +6 -0
- package/dist/gpu-simple-graph/operations/webgl/index.d.ts +17 -0
- package/dist/gpu-simple-graph/operations/webgl/index.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/index.js +20 -0
- package/dist/gpu-simple-graph/operations/webgl/index.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/interleave.cjs +64 -0
- package/dist/gpu-simple-graph/operations/webgl/interleave.d.ts +4 -0
- package/dist/gpu-simple-graph/operations/webgl/interleave.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/interleave.js +47 -0
- package/dist/gpu-simple-graph/operations/webgl/interleave.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/length.cjs +45 -0
- package/dist/gpu-simple-graph/operations/webgl/length.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/webgl/length.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/length.js +24 -0
- package/dist/gpu-simple-graph/operations/webgl/length.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/segmented-map.cjs +102 -0
- package/dist/gpu-simple-graph/operations/webgl/segmented-map.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/webgl/segmented-map.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/segmented-map.js +82 -0
- package/dist/gpu-simple-graph/operations/webgl/segmented-map.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/select.cjs +52 -0
- package/dist/gpu-simple-graph/operations/webgl/select.d.ts +8 -0
- package/dist/gpu-simple-graph/operations/webgl/select.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/select.js +30 -0
- package/dist/gpu-simple-graph/operations/webgl/select.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/sequence.cjs +53 -0
- package/dist/gpu-simple-graph/operations/webgl/sequence.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/webgl/sequence.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/sequence.js +32 -0
- package/dist/gpu-simple-graph/operations/webgl/sequence.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/swizzle.cjs +38 -0
- package/dist/gpu-simple-graph/operations/webgl/swizzle.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/webgl/swizzle.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgl/swizzle.js +16 -0
- package/dist/gpu-simple-graph/operations/webgl/swizzle.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/arithmetic.cjs +79 -0
- package/dist/gpu-simple-graph/operations/webgpu/arithmetic.d.ts +4 -0
- package/dist/gpu-simple-graph/operations/webgpu/arithmetic.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/arithmetic.js +57 -0
- package/dist/gpu-simple-graph/operations/webgpu/arithmetic.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/cast-data.cjs +178 -0
- package/dist/gpu-simple-graph/operations/webgpu/cast-data.d.ts +5 -0
- package/dist/gpu-simple-graph/operations/webgpu/cast-data.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/cast-data.js +174 -0
- package/dist/gpu-simple-graph/operations/webgpu/cast-data.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/dispatch.cjs +54 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/dispatch.d.ts +9 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/dispatch.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/dispatch.js +29 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/dispatch.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/helper.cjs +78 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/helper.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/helper.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/helper.js +50 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/helper.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/random-access-transform.cjs +90 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/random-access-transform.d.ts +10 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/random-access-transform.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/random-access-transform.js +58 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/random-access-transform.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/row-transform.cjs +195 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/row-transform.d.ts +19 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/row-transform.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/row-transform.js +180 -0
- package/dist/gpu-simple-graph/operations/webgpu/common/row-transform.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/convert-colors.cjs +154 -0
- package/dist/gpu-simple-graph/operations/webgpu/convert-colors.d.ts +4 -0
- package/dist/gpu-simple-graph/operations/webgpu/convert-colors.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/convert-colors.js +130 -0
- package/dist/gpu-simple-graph/operations/webgpu/convert-colors.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/dot.cjs +47 -0
- package/dist/gpu-simple-graph/operations/webgpu/dot.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/webgpu/dot.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/dot.js +26 -0
- package/dist/gpu-simple-graph/operations/webgpu/dot.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/equal-all.cjs +50 -0
- package/dist/gpu-simple-graph/operations/webgpu/equal-all.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/webgpu/equal-all.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/equal-all.js +29 -0
- package/dist/gpu-simple-graph/operations/webgpu/equal-all.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/extent.cjs +235 -0
- package/dist/gpu-simple-graph/operations/webgpu/extent.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/webgpu/extent.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/extent.js +215 -0
- package/dist/gpu-simple-graph/operations/webgpu/extent.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/fround.cjs +187 -0
- package/dist/gpu-simple-graph/operations/webgpu/fround.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/webgpu/fround.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/fround.js +163 -0
- package/dist/gpu-simple-graph/operations/webgpu/fround.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/gather.cjs +131 -0
- package/dist/gpu-simple-graph/operations/webgpu/gather.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/webgpu/gather.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/gather.js +106 -0
- package/dist/gpu-simple-graph/operations/webgpu/gather.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/index.cjs +66 -0
- package/dist/gpu-simple-graph/operations/webgpu/index.cjs.map +6 -0
- package/dist/gpu-simple-graph/operations/webgpu/index.d.ts +17 -0
- package/dist/gpu-simple-graph/operations/webgpu/index.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/index.js +20 -0
- package/dist/gpu-simple-graph/operations/webgpu/index.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/interleave.cjs +66 -0
- package/dist/gpu-simple-graph/operations/webgpu/interleave.d.ts +4 -0
- package/dist/gpu-simple-graph/operations/webgpu/interleave.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/interleave.js +49 -0
- package/dist/gpu-simple-graph/operations/webgpu/interleave.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/length.cjs +47 -0
- package/dist/gpu-simple-graph/operations/webgpu/length.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/webgpu/length.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/length.js +26 -0
- package/dist/gpu-simple-graph/operations/webgpu/length.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/segmented-map.cjs +104 -0
- package/dist/gpu-simple-graph/operations/webgpu/segmented-map.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/webgpu/segmented-map.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/segmented-map.js +79 -0
- package/dist/gpu-simple-graph/operations/webgpu/segmented-map.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/select.cjs +53 -0
- package/dist/gpu-simple-graph/operations/webgpu/select.d.ts +8 -0
- package/dist/gpu-simple-graph/operations/webgpu/select.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/select.js +31 -0
- package/dist/gpu-simple-graph/operations/webgpu/select.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/sequence.cjs +65 -0
- package/dist/gpu-simple-graph/operations/webgpu/sequence.d.ts +6 -0
- package/dist/gpu-simple-graph/operations/webgpu/sequence.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/sequence.js +44 -0
- package/dist/gpu-simple-graph/operations/webgpu/sequence.js.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/swizzle.cjs +40 -0
- package/dist/gpu-simple-graph/operations/webgpu/swizzle.d.ts +7 -0
- package/dist/gpu-simple-graph/operations/webgpu/swizzle.d.ts.map +1 -0
- package/dist/gpu-simple-graph/operations/webgpu/swizzle.js +18 -0
- package/dist/gpu-simple-graph/operations/webgpu/swizzle.js.map +1 -0
- package/dist/gpu-simple-graph/utils/buffer-pool.cjs +76 -0
- package/dist/gpu-simple-graph/utils/buffer-pool.d.ts +13 -0
- package/dist/gpu-simple-graph/utils/buffer-pool.d.ts.map +1 -0
- package/dist/gpu-simple-graph/utils/buffer-pool.js +57 -0
- package/dist/gpu-simple-graph/utils/buffer-pool.js.map +1 -0
- package/dist/gpu-simple-graph/utils/clean-evaluate.cjs +123 -0
- package/dist/gpu-simple-graph/utils/clean-evaluate.d.ts +22 -0
- package/dist/gpu-simple-graph/utils/clean-evaluate.d.ts.map +1 -0
- package/dist/gpu-simple-graph/utils/clean-evaluate.js +113 -0
- package/dist/gpu-simple-graph/utils/clean-evaluate.js.map +1 -0
- package/dist/gpu-simple-graph/utils/expression.cjs +91 -0
- package/dist/gpu-simple-graph/utils/expression.d.ts +56 -0
- package/dist/gpu-simple-graph/utils/expression.d.ts.map +1 -0
- package/dist/gpu-simple-graph/utils/expression.js +79 -0
- package/dist/gpu-simple-graph/utils/expression.js.map +1 -0
- package/dist/gpu-simple-graph/utils/output-props.cjs +60 -0
- package/dist/gpu-simple-graph/utils/output-props.d.ts +9 -0
- package/dist/gpu-simple-graph/utils/output-props.d.ts.map +1 -0
- package/dist/gpu-simple-graph/utils/output-props.js +42 -0
- package/dist/gpu-simple-graph/utils/output-props.js.map +1 -0
- package/dist/gpu-simple-graph/utils/uid.cjs +32 -0
- package/dist/gpu-simple-graph/utils/uid.d.ts +7 -0
- package/dist/gpu-simple-graph/utils/uid.d.ts.map +1 -0
- package/dist/gpu-simple-graph/utils/uid.js +15 -0
- package/dist/gpu-simple-graph/utils/uid.js.map +1 -0
- package/dist/gpu-simulation/index.cjs.map +3 -3
- package/dist/gpu-sql/index.cjs.map +3 -3
- package/dist/gpu-sql/lu-sql.d.ts +1 -1
- package/dist/gpu-sql/lu-sql.js +1 -1
- package/dist/gpu-tables/engine/gpu-input-schema.d.ts +3 -3
- package/dist/gpu-tables/engine/gpu-table-computation.cjs +3 -3
- package/dist/gpu-tables/engine/gpu-table-computation.d.ts +2 -2
- package/dist/gpu-tables/engine/gpu-table-computation.d.ts.map +1 -1
- package/dist/gpu-tables/engine/gpu-table-computation.js +2 -2
- package/dist/gpu-tables/engine/gpu-table-computation.js.map +1 -1
- package/dist/gpu-tables/engine/gpu-table-shader-bindings.cjs +1 -1
- package/dist/gpu-tables/engine/gpu-table-shader-bindings.d.ts +1 -1
- package/dist/gpu-tables/engine/gpu-table-shader-bindings.d.ts.map +1 -1
- package/dist/gpu-tables/engine/gpu-table-shader-bindings.js +1 -1
- package/dist/gpu-tables/index.cjs.map +3 -3
- package/dist/gpu-tables/table/gpu-record-batch.cjs +1 -1
- package/dist/gpu-tables/table/gpu-record-batch.d.ts +1 -1
- package/dist/gpu-tables/table/gpu-record-batch.js +1 -1
- package/dist/gpu-tables/table/gpu-schema.d.ts +1 -1
- package/dist/gpu-tables/table/gpu-table.cjs +4 -4
- package/dist/gpu-tables/table/gpu-table.d.ts +3 -3
- package/dist/gpu-tables/table/gpu-table.js +4 -4
- package/dist/gpu-timeseries/gpu-time-series-envelope.d.ts +1 -1
- package/dist/gpu-timeseries/gpu-time-series.d.ts +1 -1
- package/dist/gpu-timeseries/index.cjs.map +3 -3
- package/dist/gpu-trace/gpu-trace-anomaly-scoring.cjs +2 -2
- package/dist/gpu-trace/gpu-trace-anomaly-scoring.js +1 -1
- package/dist/gpu-trace/gpu-trace-anomaly-scoring.js.map +1 -1
- package/dist/gpu-trace/gpu-trace-comparison.cjs +2 -2
- package/dist/gpu-trace/gpu-trace-comparison.js +1 -1
- package/dist/gpu-trace/gpu-trace-comparison.js.map +1 -1
- package/dist/gpu-trace/gpu-trace-critical-path.cjs +2 -2
- package/dist/gpu-trace/gpu-trace-critical-path.js +1 -1
- package/dist/gpu-trace/gpu-trace-critical-path.js.map +1 -1
- package/dist/gpu-trace/gpu-trace-interaction.cjs +2 -2
- package/dist/gpu-trace/gpu-trace-interaction.js +1 -1
- package/dist/gpu-trace/gpu-trace-interaction.js.map +1 -1
- package/dist/gpu-trace/gpu-trace-lane-index-builder.cjs +2 -2
- package/dist/gpu-trace/gpu-trace-lane-index-builder.js +1 -1
- package/dist/gpu-trace/gpu-trace-lane-index-builder.js.map +1 -1
- package/dist/gpu-trace/gpu-trace-mipmap-boundaries.cjs +3 -3
- package/dist/gpu-trace/gpu-trace-mipmap-boundaries.js +1 -1
- package/dist/gpu-trace/gpu-trace-mipmap-boundaries.js.map +1 -1
- package/dist/gpu-trace/gpu-trace-pixel-mipmap.cjs +3 -3
- package/dist/gpu-trace/gpu-trace-pixel-mipmap.js +1 -1
- package/dist/gpu-trace/gpu-trace-pixel-mipmap.js.map +1 -1
- package/dist/gpu-trace/gpu-trace-range-maximum-index.cjs +2 -2
- package/dist/gpu-trace/gpu-trace-range-maximum-index.js +1 -1
- package/dist/gpu-trace/gpu-trace-range-maximum-index.js.map +1 -1
- package/dist/gpu-trace/gpu-trace-temporal-index-builder.cjs +2 -2
- package/dist/gpu-trace/gpu-trace-temporal-index-builder.js +1 -1
- package/dist/gpu-trace/gpu-trace-temporal-index-builder.js.map +1 -1
- package/dist/gpu-trace/gpu-trace-temporal-index.cjs +4 -4
- package/dist/gpu-trace/gpu-trace-temporal-index.js +1 -1
- package/dist/gpu-trace/gpu-trace-temporal-index.js.map +1 -1
- package/dist/gpu-trace/gpu-trace-time-buckets.cjs +2 -2
- package/dist/gpu-trace/gpu-trace-time-buckets.js +1 -1
- package/dist/gpu-trace/gpu-trace-time-buckets.js.map +1 -1
- package/dist/gpu-trace/index.cjs.map +3 -3
- package/dist/gpu-vector-search/embedding-matrix.cjs +1 -1
- package/dist/gpu-vector-search/embedding-matrix.d.ts +1 -1
- package/dist/gpu-vector-search/embedding-matrix.js +1 -1
- package/dist/gpu-vector-search/gpu-clustering-utils.cjs +2 -2
- package/dist/gpu-vector-search/gpu-clustering-utils.js +1 -1
- package/dist/gpu-vector-search/gpu-clustering-utils.js.map +1 -1
- package/dist/gpu-vector-search/gpu-similarity-search.cjs +2 -2
- package/dist/gpu-vector-search/gpu-similarity-search.js +1 -1
- package/dist/gpu-vector-search/gpu-similarity-search.js.map +1 -1
- package/dist/gpu-vector-search/index.cjs.map +3 -3
- package/dist/index.cjs +49 -27
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +21 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/lucim/gpu-volume-connected-components.cjs +2 -2
- package/dist/lucim/gpu-volume-connected-components.js +1 -1
- package/dist/lucim/gpu-volume-connected-components.js.map +1 -1
- package/dist/lucim/gpu-volume-morphology.cjs +2 -2
- package/dist/lucim/gpu-volume-morphology.js +1 -1
- package/dist/lucim/gpu-volume-morphology.js.map +1 -1
- package/dist/lucim/gpu-volume-region-measurements.cjs +2 -2
- package/dist/lucim/gpu-volume-region-measurements.js +1 -1
- package/dist/lucim/gpu-volume-region-measurements.js.map +1 -1
- package/dist/lucim/gpu-volume-threshold.cjs +2 -2
- package/dist/lucim/gpu-volume-threshold.js +1 -1
- package/dist/lucim/gpu-volume-threshold.js.map +1 -1
- package/dist/lucim/index.cjs.map +3 -3
- package/dist/utils/assemble-compute-kernel.cjs +4 -4
- package/dist/utils/assemble-compute-kernel.d.ts +3 -2
- package/dist/utils/assemble-compute-kernel.d.ts.map +1 -1
- package/dist/utils/assemble-compute-kernel.js +3 -3
- package/dist/utils/assemble-compute-kernel.js.map +1 -1
- package/dist/webgpu.cjs +53 -0
- package/dist/webgpu.d.ts +3 -0
- package/dist/webgpu.d.ts.map +1 -0
- package/dist/webgpu.js +6 -0
- package/dist/webgpu.js.map +1 -0
- package/package.json +45 -8
- package/src/arrow/arrow-colors.ts +233 -0
- package/src/arrow/arrow-utils/arrow-column-info.ts +102 -0
- package/src/arrow/arrow-utils/arrow-paths.ts +195 -0
- package/src/arrow/arrow-utils/arrow-types.ts +104 -0
- package/src/arrow/dggs/dggs-gpu-polygons.ts +820 -0
- package/src/arrow/geoarrow/arrow-geoarrow-adapter.ts +519 -0
- package/src/arrow/geoarrow/arrow-geoarrow-conversion.ts +415 -0
- package/src/arrow/geoarrow/arrow-polygon-tessellation.ts +369 -0
- package/src/arrow/gpu/arrow-column-gpu-vector.ts +157 -0
- package/src/arrow/gpu/arrow-compute-kernel.ts +31 -0
- package/src/arrow/gpu/arrow-gpu-analytics-adapters.ts +474 -0
- package/src/arrow/gpu/arrow-gpu-analytics-readback.ts +294 -0
- package/src/arrow/gpu/arrow-gpu-data.ts +828 -0
- package/src/arrow/gpu/arrow-gpu-table-adapters.ts +378 -0
- package/src/arrow/gpu/arrow-gpu-table-conversion.ts +324 -0
- package/src/arrow/gpu/arrow-gpu-vector-adapters.ts +522 -0
- package/src/arrow/gpu/arrow-gpu-vector-conversion.ts +1139 -0
- package/src/arrow/gpu/arrow-input-schema.ts +98 -0
- package/src/arrow/gpu/arrow-shader-layout.ts +405 -0
- package/src/arrow/index.ts +203 -0
- package/src/arrow/internal.ts +46 -0
- package/src/arrow/vectors/arrow-fixed-size-list.ts +172 -0
- package/src/arrow/vectors/arrow-matrix-gpu-vector.ts +396 -0
- package/src/arrow/vectors/arrow-matrix-vector.ts +370 -0
- package/src/arrow/vectors/arrow-temporal-gpu-vector.ts +864 -0
- package/src/arrow/vectors/arrow-vector-utils.ts +359 -0
- package/src/execution/compute/kernel.ts +146 -0
- package/src/execution/compute/render-kernel.ts +213 -0
- package/src/execution/dynamic-buffer/dynamic-buffer.ts +19 -0
- package/src/execution/dynamic-texture/dynamic-texture.ts +9 -0
- package/src/execution/dynamic-texture/texture-binding-source.ts +12 -0
- package/src/execution/dynamic-texture/texture-data.ts +35 -0
- package/src/execution/utils/get-platform-info.ts +19 -0
- package/src/experimental/index.ts +59 -2
- package/src/experimental/models/path/gpu/path-storage-gpu-inputs.ts +3 -3
- package/src/experimental/models/polygon/polygon-gpu-inputs.ts +3 -3
- package/src/experimental/simulation/flow-particle-simulation.ts +1 -1
- package/src/experimental/simulation/scientific-flow-compute.ts +1 -1
- package/src/experimental/simulation/scientific-flow-tracer.ts +1 -1
- package/src/geospatial/geospatial-utils.ts +6 -9
- package/src/geospatial/gpu-point-spatial-query.ts +1 -1
- package/src/gpu-core/compiled-gpu-graph.ts +128 -0
- package/src/gpu-core/dispatch-command-buffer.ts +1 -1
- package/src/gpu-core/draw-command-buffer.ts +1 -1
- package/src/gpu-core/gpu-adaptive-spmv.ts +1 -1
- package/src/gpu-core/gpu-ancestor-projection.ts +1 -1
- package/src/gpu-core/gpu-bvh-query.ts +1 -1
- package/src/gpu-core/gpu-bvh.ts +2 -2
- package/src/gpu-core/gpu-byte-range-gather.ts +2 -2
- package/src/gpu-core/gpu-chunk-utils.ts +2 -2
- package/src/gpu-core/gpu-chunked-indexed-scatter.ts +1 -1
- package/src/gpu-core/gpu-command-graph-types.ts +3 -3
- package/src/gpu-core/gpu-command-graph.ts +1 -1
- package/src/gpu-core/gpu-compaction.ts +1 -1
- package/src/gpu-core/gpu-convolution.ts +2 -2
- package/src/gpu-core/gpu-dense-utils.ts +2 -2
- package/src/gpu-core/gpu-elementwise-scalar.ts +1 -1
- package/src/gpu-core/gpu-elementwise.ts +1 -1
- package/src/gpu-core/gpu-expression-cast.ts +45 -0
- package/src/gpu-core/gpu-expression-kernel.ts +268 -0
- package/src/gpu-core/gpu-expression-operation.ts +306 -0
- package/src/gpu-core/gpu-expression-plan.ts +528 -0
- package/src/gpu-core/gpu-fft1d.ts +2 -2
- package/src/gpu-core/gpu-fft2d.ts +1 -1
- package/src/gpu-core/gpu-finite-difference-utils.ts +2 -2
- package/src/gpu-core/gpu-flag-offsets.ts +1 -1
- package/src/gpu-core/gpu-galloping-search.ts +1 -1
- package/src/gpu-core/gpu-gather.ts +2 -2
- package/src/gpu-core/gpu-graph-compiler.ts +242 -147
- package/src/gpu-core/gpu-graph-lowering.ts +14 -21
- package/src/gpu-core/gpu-graph-traversal.ts +1 -1
- package/src/gpu-core/gpu-graph-validation.ts +15 -1
- package/src/gpu-core/gpu-graph-value.ts +9 -6
- package/src/gpu-core/gpu-graph.ts +15 -2
- package/src/gpu-core/gpu-group-aggregation.ts +1 -1
- package/src/gpu-core/gpu-hash-index.ts +1 -1
- package/src/gpu-core/gpu-hash-join.ts +1 -1
- package/src/gpu-core/gpu-hierarchy-layout.ts +1 -1
- package/src/gpu-core/gpu-histogram.ts +1 -1
- package/src/gpu-core/gpu-incremental-execution.ts +1 -1
- package/src/gpu-core/gpu-index-picking-target.ts +1 -1
- package/src/gpu-core/gpu-indexed-range-compaction.ts +1 -1
- package/src/gpu-core/gpu-lz-byte-batch-decompressor.ts +1 -1
- package/src/gpu-core/gpu-lz-byte-decompressor.ts +1 -1
- package/src/gpu-core/gpu-mask.ts +1 -1
- package/src/gpu-core/gpu-operation-contract.ts +85 -0
- package/src/gpu-core/gpu-operation.ts +3 -0
- package/src/gpu-core/gpu-predicate-conjunction.ts +1 -1
- package/src/gpu-core/gpu-reduction-substrate.ts +1 -1
- package/src/gpu-core/gpu-reduction.ts +1 -1
- package/src/gpu-core/gpu-scalar-dispatch-gate.ts +1 -1
- package/src/gpu-core/gpu-scalar-literal.ts +1 -1
- package/src/gpu-core/gpu-scalar-operation.ts +1 -1
- package/src/gpu-core/gpu-scan.ts +1 -1
- package/src/gpu-core/gpu-scatter.ts +1 -1
- package/src/gpu-core/gpu-scene-draw-generation.ts +1 -1
- package/src/gpu-core/gpu-scene-resource-groups.ts +1 -1
- package/src/gpu-core/gpu-segment-offsets.ts +1 -1
- package/src/gpu-core/gpu-segmented-bvh.ts +1 -1
- package/src/gpu-core/gpu-segmented-layout.ts +1 -1
- package/src/gpu-core/gpu-segmented-reduction.ts +1 -1
- package/src/gpu-core/gpu-segmented-scan.ts +1 -1
- package/src/gpu-core/gpu-segmented-sort.ts +1 -1
- package/src/gpu-core/gpu-semantic-scalar-operation.ts +10 -0
- package/src/gpu-core/gpu-semantic-spmv.ts +14 -1
- package/src/gpu-core/gpu-semantic-state-operation.ts +4 -0
- package/src/gpu-core/gpu-semantic-vector-operation.ts +37 -4
- package/src/gpu-core/gpu-sort.ts +1 -1
- package/src/gpu-core/gpu-spatial-utils.ts +1 -1
- package/src/gpu-core/gpu-text-selection.ts +1 -1
- package/src/gpu-core/gpu-transpose-benchmark.ts +1 -1
- package/src/gpu-core/gpu-transpose.ts +2 -2
- package/src/gpu-core/gpu-uint64-scan.ts +1 -1
- package/src/gpu-core/gpu-virtual-geometry-selection.ts +2 -2
- package/src/gpu-core/gpu-visibility-workflow.ts +1 -1
- package/src/gpu-core/gpu-workgroup-reduction-benchmark.ts +1 -1
- package/src/gpu-core/gpu-workgroup-scan-benchmark.ts +1 -1
- package/src/gpu-core/graph-data-view-utils.ts +1 -1
- package/src/gpu-core/graph-vector-view-utils.ts +1 -1
- package/src/gpu-core/index.ts +17 -1
- package/src/gpu-core/utils/bound-kernel.ts +1 -1
- package/src/gpu-crossfilter/gpu-selection.ts +1 -1
- package/src/gpu-data/gpu-constant.ts +60 -0
- package/src/gpu-data/gpu-data-format.ts +249 -0
- package/src/gpu-data/gpu-data-view.ts +155 -0
- package/src/gpu-data/gpu-data.ts +459 -0
- package/src/gpu-data/gpu-sparse-matrix.ts +76 -0
- package/src/gpu-data/gpu-vector-chunks.ts +24 -0
- package/src/gpu-data/gpu-vector-format.ts +256 -0
- package/src/gpu-data/gpu-vector-like.ts +30 -0
- package/src/gpu-data/gpu-vector-utils.ts +87 -0
- package/src/gpu-data/gpu-vector.ts +461 -0
- package/src/gpu-data/index.ts +70 -0
- package/src/gpu-dataframe/gpu-analytics-compiler-utils.ts +2 -2
- package/src/gpu-dataframe/gpu-data-frame.ts +1 -1
- package/src/gpu-dataframe/gpu-global-aggregation-compiler.ts +1 -1
- package/src/gpu-dataframe/gpu-global-sort-compiler.ts +1 -1
- package/src/gpu-dataframe/gpu-group-aggregation-compiler.ts +1 -1
- package/src/gpu-dataframe/gpu-histogram-compiler.ts +1 -1
- package/src/gpu-dataframe/gpu-join-compiler.ts +1 -1
- package/src/gpu-dataframe/gpu-query-compiler.ts +2 -2
- package/src/gpu-dggs/gpu-dggs-cell-projection.ts +2 -2
- package/src/gpu-graph/index.ts +9 -1
- package/src/gpu-graph-algorithms/gpu-graph-benchmark.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-breadth-first-search-internals.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-breadth-first-search.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-connected-components-internals.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-connected-components.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-core-number-internals.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-core-number.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-degree-internals.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-degree.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-force-layout-internals.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-force-layout.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-label-propagation-internals.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-label-propagation.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-local-clustering-coefficient-internals.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-local-clustering-coefficient.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-modularity-internals.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-modularity-optimization-internals.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-modularity-optimization.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-modularity.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-page-rank-internals.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-page-rank.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-spatial-force-layout-internals.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-spatial-force-layout.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-topology-internals.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph-topology.ts +1 -1
- package/src/gpu-graph-algorithms/gpu-graph.ts +1 -1
- package/src/gpu-parse/parquet/gpu-parquet-bit-packed-decoder.ts +1 -1
- package/src/gpu-parse/parquet/gpu-parquet-byte-stream-split-batch-decoder.ts +1 -1
- package/src/gpu-parse/parquet/gpu-parquet-byte-stream-split-decoder.ts +1 -1
- package/src/gpu-parse/parquet/gpu-parquet-delta-binary-packed-int64-unpacker.ts +1 -1
- package/src/gpu-parse/parquet/gpu-parquet-delta-binary-packed-unpacker.ts +1 -1
- package/src/gpu-parse/parquet/gpu-parquet-delta-byte-array-decoder.ts +1 -1
- package/src/gpu-parse/parquet/gpu-parquet-dictionary-decoder.ts +1 -1
- package/src/gpu-parse/parquet/gpu-parquet-level-layout.ts +1 -1
- package/src/gpu-parse/parquet/gpu-parquet-nested-column-layout.ts +1 -1
- package/src/gpu-parse/parquet/gpu-parquet-plain-boolean-decoder.ts +1 -1
- package/src/gpu-parse/parquet/gpu-parquet-rle-bit-packed-decoder.ts +1 -1
- package/src/gpu-physics/rigid-body-broad-phase.ts +1 -1
- package/src/gpu-project/gpu-projection-table.ts +1 -1
- package/src/gpu-project/projection-program-benchmark.ts +1 -1
- package/src/gpu-project/projection-program.ts +1 -1
- package/src/gpu-project/projection-table-benchmark.ts +1 -1
- package/src/gpu-raster/gpu-raster-band-math.ts +1 -1
- package/src/gpu-raster/gpu-raster-buffer-to-texture.ts +1 -1
- package/src/gpu-raster/gpu-raster-connected-components.ts +1 -1
- package/src/gpu-raster/gpu-raster-contours.ts +1 -1
- package/src/gpu-raster/gpu-raster-contrast.ts +1 -1
- package/src/gpu-raster/gpu-raster-cross-tile-components.ts +1 -1
- package/src/gpu-raster/gpu-raster-dense-components.ts +1 -1
- package/src/gpu-raster/gpu-raster-edges.ts +1 -1
- package/src/gpu-raster/gpu-raster-global-statistics.ts +1 -1
- package/src/gpu-raster/gpu-raster-histogram.ts +1 -1
- package/src/gpu-raster/gpu-raster-morphology.ts +1 -1
- package/src/gpu-raster/gpu-raster-neighborhood.ts +1 -1
- package/src/gpu-raster/gpu-raster-overview.ts +1 -1
- package/src/gpu-raster/gpu-raster-region-measurements.ts +1 -1
- package/src/gpu-raster/gpu-raster-statistics.ts +1 -1
- package/src/gpu-raster/gpu-raster-texture-to-buffer.ts +1 -1
- package/src/gpu-raster/gpu-raster-threshold.ts +1 -1
- package/src/gpu-raster/gpu-raster-tile-halo.ts +1 -1
- package/src/gpu-simple-graph/README.md +1 -1
- package/src/gpu-simple-graph/compiled-gpu-expression-graph.ts +303 -0
- package/src/gpu-simple-graph/gpu-expression-cast-operation.ts +149 -0
- package/src/gpu-simple-graph/gpu-expression-row-operation.ts +90 -0
- package/src/gpu-simple-graph/gpu-simple-graph-lowering.ts +3 -9
- package/src/gpu-simple-graph/gpu-simple-graph-operation.ts +4 -2
- package/src/gpu-simple-graph/gpu-simple-graph-transfer.ts +4 -6
- package/src/gpu-simple-graph/gpu-simple-graph-value.ts +18 -17
- package/src/gpu-simple-graph/gpu-simple-graph.ts +60 -16
- package/src/gpu-simple-graph/index.ts +74 -0
- package/src/gpu-simple-graph/operation/backend-registry.ts +152 -0
- package/src/gpu-simple-graph/operation/gpu-data-evaluator.ts +954 -0
- package/src/gpu-simple-graph/operation/gpu-evaluation-scope.ts +113 -0
- package/src/gpu-simple-graph/operation/gpu-evaluator-inspection.ts +105 -0
- package/src/gpu-simple-graph/operation/gpu-table-format-types.ts +255 -0
- package/src/gpu-simple-graph/operation/gpu-vector-evaluator.ts +300 -0
- package/src/gpu-simple-graph/operation/operation.ts +142 -0
- package/src/gpu-simple-graph/operations/arithmetic-expression.ts +40 -0
- package/src/gpu-simple-graph/operations/arithmetic-operation.ts +257 -0
- package/src/gpu-simple-graph/operations/arithmetic.ts +115 -0
- package/src/gpu-simple-graph/operations/cast-data.ts +67 -0
- package/src/gpu-simple-graph/operations/convert-colors.ts +76 -0
- package/src/gpu-simple-graph/operations/cpu/arithmetic.ts +121 -0
- package/src/gpu-simple-graph/operations/cpu/cast-data.ts +72 -0
- package/src/gpu-simple-graph/operations/cpu/common.ts +128 -0
- package/src/gpu-simple-graph/operations/cpu/convert-colors.ts +56 -0
- package/src/gpu-simple-graph/operations/cpu/dot.ts +29 -0
- package/src/gpu-simple-graph/operations/cpu/equal-all.ts +32 -0
- package/src/gpu-simple-graph/operations/cpu/extent.ts +50 -0
- package/src/gpu-simple-graph/operations/cpu/fround.ts +26 -0
- package/src/gpu-simple-graph/operations/cpu/gather.ts +44 -0
- package/src/gpu-simple-graph/operations/cpu/index.ts +36 -0
- package/src/gpu-simple-graph/operations/cpu/interleave.ts +23 -0
- package/src/gpu-simple-graph/operations/cpu/length.ts +24 -0
- package/src/gpu-simple-graph/operations/cpu/segmented-map.ts +79 -0
- package/src/gpu-simple-graph/operations/cpu/select.ts +40 -0
- package/src/gpu-simple-graph/operations/cpu/sequence.ts +21 -0
- package/src/gpu-simple-graph/operations/cpu/swizzle.ts +26 -0
- package/src/gpu-simple-graph/operations/dot.ts +48 -0
- package/src/gpu-simple-graph/operations/equal-all.ts +46 -0
- package/src/gpu-simple-graph/operations/extent.ts +46 -0
- package/src/gpu-simple-graph/operations/fround.ts +45 -0
- package/src/gpu-simple-graph/operations/gather.ts +51 -0
- package/src/gpu-simple-graph/operations/interleave.ts +54 -0
- package/src/gpu-simple-graph/operations/length.ts +38 -0
- package/src/gpu-simple-graph/operations/segmented-map.ts +108 -0
- package/src/gpu-simple-graph/operations/select.ts +76 -0
- package/src/gpu-simple-graph/operations/sequence.ts +60 -0
- package/src/gpu-simple-graph/operations/swizzle.ts +108 -0
- package/src/gpu-simple-graph/operations/webgl/arithmetic.ts +65 -0
- package/src/gpu-simple-graph/operations/webgl/cast-data.ts +6 -0
- package/src/gpu-simple-graph/operations/webgl/common/helper.ts +155 -0
- package/src/gpu-simple-graph/operations/webgl/common/random-access-transform.ts +60 -0
- package/src/gpu-simple-graph/operations/webgl/common/row-transform.ts +229 -0
- package/src/gpu-simple-graph/operations/webgl/common/transform-kernel.ts +101 -0
- package/src/gpu-simple-graph/operations/webgl/convert-colors.ts +7 -0
- package/src/gpu-simple-graph/operations/webgl/dot.ts +32 -0
- package/src/gpu-simple-graph/operations/webgl/equal-all.ts +35 -0
- package/src/gpu-simple-graph/operations/webgl/extent.ts +182 -0
- package/src/gpu-simple-graph/operations/webgl/fround.ts +201 -0
- package/src/gpu-simple-graph/operations/webgl/gather.ts +142 -0
- package/src/gpu-simple-graph/operations/webgl/index.ts +36 -0
- package/src/gpu-simple-graph/operations/webgl/interleave.ts +70 -0
- package/src/gpu-simple-graph/operations/webgl/length.ts +28 -0
- package/src/gpu-simple-graph/operations/webgl/segmented-map.ts +90 -0
- package/src/gpu-simple-graph/operations/webgl/select.ts +54 -0
- package/src/gpu-simple-graph/operations/webgl/sequence.ts +39 -0
- package/src/gpu-simple-graph/operations/webgl/swizzle.ts +23 -0
- package/src/gpu-simple-graph/operations/webgpu/arithmetic.ts +68 -0
- package/src/gpu-simple-graph/operations/webgpu/cast-data.ts +181 -0
- package/src/gpu-simple-graph/operations/webgpu/common/dispatch.ts +58 -0
- package/src/gpu-simple-graph/operations/webgpu/common/helper.ts +66 -0
- package/src/gpu-simple-graph/operations/webgpu/common/random-access-transform.ts +79 -0
- package/src/gpu-simple-graph/operations/webgpu/common/row-transform.ts +239 -0
- package/src/gpu-simple-graph/operations/webgpu/convert-colors.ts +147 -0
- package/src/gpu-simple-graph/operations/webgpu/dot.ts +36 -0
- package/src/gpu-simple-graph/operations/webgpu/equal-all.ts +39 -0
- package/src/gpu-simple-graph/operations/webgpu/extent.ts +277 -0
- package/src/gpu-simple-graph/operations/webgpu/fround.ts +174 -0
- package/src/gpu-simple-graph/operations/webgpu/gather.ts +137 -0
- package/src/gpu-simple-graph/operations/webgpu/index.ts +36 -0
- package/src/gpu-simple-graph/operations/webgpu/interleave.ts +73 -0
- package/src/gpu-simple-graph/operations/webgpu/length.ts +36 -0
- package/src/gpu-simple-graph/operations/webgpu/segmented-map.ts +101 -0
- package/src/gpu-simple-graph/operations/webgpu/select.ts +56 -0
- package/src/gpu-simple-graph/operations/webgpu/sequence.ts +56 -0
- package/src/gpu-simple-graph/operations/webgpu/swizzle.ts +27 -0
- package/src/gpu-simple-graph/utils/buffer-pool.ts +66 -0
- package/src/gpu-simple-graph/utils/clean-evaluate.ts +152 -0
- package/src/gpu-simple-graph/utils/expression.ts +140 -0
- package/src/gpu-simple-graph/utils/output-props.ts +50 -0
- package/src/gpu-simple-graph/utils/uid.ts +16 -0
- package/src/gpu-sql/lu-sql.ts +1 -1
- package/src/gpu-tables/engine/gpu-input-schema.ts +3 -3
- package/src/gpu-tables/engine/gpu-scene-adapters.ts +1 -1
- package/src/gpu-tables/engine/gpu-table-computation.ts +2 -2
- package/src/gpu-tables/engine/gpu-table-shader-bindings.ts +4 -4
- package/src/gpu-tables/table/gpu-record-batch.ts +2 -2
- package/src/gpu-tables/table/gpu-schema.ts +1 -1
- package/src/gpu-tables/table/gpu-table.ts +4 -4
- package/src/gpu-timeseries/gpu-time-series-envelope.ts +1 -1
- package/src/gpu-timeseries/gpu-time-series.ts +1 -1
- package/src/gpu-trace/gpu-trace-anomaly-scoring.ts +1 -1
- package/src/gpu-trace/gpu-trace-comparison.ts +1 -1
- package/src/gpu-trace/gpu-trace-critical-path.ts +1 -1
- package/src/gpu-trace/gpu-trace-interaction.ts +1 -1
- package/src/gpu-trace/gpu-trace-lane-index-builder.ts +1 -1
- package/src/gpu-trace/gpu-trace-mipmap-boundaries.ts +1 -1
- package/src/gpu-trace/gpu-trace-pixel-mipmap.ts +1 -1
- package/src/gpu-trace/gpu-trace-range-maximum-index.ts +1 -1
- package/src/gpu-trace/gpu-trace-temporal-index-builder.ts +1 -1
- package/src/gpu-trace/gpu-trace-temporal-index.ts +1 -1
- package/src/gpu-trace/gpu-trace-time-buckets.ts +1 -1
- package/src/gpu-vector-search/embedding-matrix.ts +1 -1
- package/src/gpu-vector-search/gpu-clustering-utils.ts +1 -1
- package/src/gpu-vector-search/gpu-similarity-search.ts +1 -1
- package/src/index.ts +176 -4
- package/src/lucim/gpu-volume-connected-components.ts +1 -1
- package/src/lucim/gpu-volume-morphology.ts +1 -1
- package/src/lucim/gpu-volume-region-measurements.ts +1 -1
- package/src/lucim/gpu-volume-threshold.ts +1 -1
- package/src/utils/assemble-compute-kernel.ts +5 -8
- package/src/webgpu.ts +21 -0
package/dist/dist.min.js
CHANGED
|
@@ -4,57 +4,57 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['luma'] = factory();
|
|
6
6
|
else root['luma'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var Pi=Object.create;var It=Object.defineProperty;var Si=Object.getOwnPropertyDescriptor;var Bi=Object.getOwnPropertyNames;var Ei=Object.getPrototypeOf,Li=Object.prototype.hasOwnProperty;var b=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(o){throw t=[o],o}};var Gi=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Di=(r,e)=>{for(var t in e)It(r,t,{get:e[t],enumerable:!0})},Dt=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Bi(e))!Li.call(r,n)&&n!==t&&It(r,n,{get:()=>e[n],enumerable:!(o=Si(e,n))||o.enumerable});return r},At=(r,e,t)=>(Dt(r,e,"default"),t&&Dt(t,e,"default")),ee=(r,e,t)=>(t=r!=null?Pi(Ei(r)):{},Dt(e||!r||!r.__esModule?It(t,"default",{value:r,enumerable:!0}):t,r)),Ii=r=>Dt(It({},"__esModule",{value:!0}),r);var K=Gi((Ts,Mo)=>{Mo.exports=globalThis.luma});var ot,Ai,Ut,Ui,$i,vr=b(()=>{ot=globalThis,Ai=globalThis.document||{},Ut=globalThis.process||{},Ui=globalThis.console,$i=globalThis.navigator||{}});function $t(r){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=r||e;return!!(t&&t.indexOf("Electron")>=0)}var _t=b(()=>{});function he(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||$t()}var Cr=b(()=>{_t()});var Oo=b(()=>{Cr();_t();vr()});var Fo=b(()=>{});var Pr,Rt=b(()=>{vr();Cr();Oo();_t();Fo();Pr="5.0.0"});function Fe(r,e){if(!r)throw new Error(e||"Assertion failed")}var Sr=b(()=>{});function Mt(r){if(!r)return 0;let e;switch(typeof r){case"number":e=r;break;case"object":e=r.logLevel||r.priority||0;break;default:return 0}return Fe(Number.isFinite(e)&&e>=0),e}function Br(r){let{logLevel:e,message:t}=r;r.logLevel=Mt(e);let o=r.args?Array.from(r.args):[];for(;o.length&&o.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&o.unshift(t),r.message=e;break;case"object":Object.assign(r,e);break;default:}typeof r.message=="function"&&(r.message=r.message());let n=typeof r.message;return Fe(n==="string"||n==="object"),Object.assign(r,{args:o},r.opts)}var kt=b(()=>{Sr()});var ge,Ee,nt=b(()=>{kt();ge=()=>{},Ee=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...t){return this._log("warn",0,e,t,{once:!0})}error(e,...t){return this._log("error",0,e,t)}log(e,t,...o){return this._log("log",e,t,o)}info(e,t,...o){return this._log("info",e,t,o)}once(e,t,...o){return this._log("once",e,t,o,{once:!0})}_log(e,t,o,n,i={}){let a=Br({logLevel:t,message:o,args:this._buildArgs(t,o,n),opts:i});return this._createLogFunction(e,a,i)}_buildArgs(e,t,o){return[e,t,...o]}_createLogFunction(e,t,o){if(!this._shouldLog(t.logLevel))return ge;let n=this._getOnceTag(o.tag??t.tag??t.message);if((o.once||t.once)&&n!==void 0){if(this._onceCache.has(n))return ge;this._onceCache.add(n)}return this._emit(e,t)}_shouldLog(e){return this.getLevel()>=Mt(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}});function Ri(r){try{let e=window[r],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var it,Er=b(()=>{it=class{constructor(e,t,o="sessionStorage"){this.storage=Ri(o),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}});function No(r){let e;return r<10?e=`${r.toFixed(2)}ms`:r<100?e=`${r.toFixed(1)}ms`:r<1e3?e=`${r.toFixed(0)}ms`:e=`${(r/1e3).toFixed(2)}s`,e}function Lr(r,e=8){let t=Math.max(e-r.length,0);return`${" ".repeat(t)}${r}`}var Gr=b(()=>{});function zo(r){return typeof r!="string"?r:(r=r.toUpperCase(),at[r]||at.WHITE)}function Dr(r,e,t){return!he&&typeof r=="string"&&(e&&(r=`\x1B[${zo(e)}m${r}\x1B[39m`),t&&(r=`\x1B[${zo(t)+Mi}m${r}\x1B[49m`)),r}var at,Mi,Ot=b(()=>{Rt();(function(r){r[r.BLACK=30]="BLACK",r[r.RED=31]="RED",r[r.GREEN=32]="GREEN",r[r.YELLOW=33]="YELLOW",r[r.BLUE=34]="BLUE",r[r.MAGENTA=35]="MAGENTA",r[r.CYAN=36]="CYAN",r[r.WHITE=37]="WHITE",r[r.BRIGHT_BLACK=90]="BRIGHT_BLACK",r[r.BRIGHT_RED=91]="BRIGHT_RED",r[r.BRIGHT_GREEN=92]="BRIGHT_GREEN",r[r.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",r[r.BRIGHT_BLUE=94]="BRIGHT_BLUE",r[r.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",r[r.BRIGHT_CYAN=96]="BRIGHT_CYAN",r[r.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(at||(at={}));Mi=10});function Ir(r,e=["constructor"]){let t=Object.getPrototypeOf(r),o=Object.getOwnPropertyNames(t),n=r;for(let i of o){let a=n[i];typeof a=="function"&&(e.find(s=>i===s)||(n[i]=a.bind(r)))}}var Ar=b(()=>{});var Ft,j,st=b(()=>{Rt();Ft=class{getHighResolutionTimer(){let e;if(he()&&ot.performance)e=ot?.performance?.now?.();else if("hrtime"in Ut){let t=Ut?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}getMemoryUsageMB(){let t=ot?.performance?.memory?.usedJSHeapSize;return t==null?null:Math.trunc(t/1024/1024)}},j=new Ft;globalThis.Probe=Ft;globalThis.probe=j});function ki(r,e,t){if(typeof e=="string"){let o=t.time?Lr(No(t.total)):"";e=t.time?`${r}: ${o} ${e}`:`${r}: ${e}`,e=Dr(e,t.color,t.background)}return e}function Oi(r){for(let e in r)for(let t in r[e])return t||"untitled";return"empty"}var Ne,Ur,ae,$r=b(()=>{Rt();nt();Er();Gr();Ot();Ar();Sr();st();kt();kt();Ne={debug:he()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Ur={enabled:!0,level:0},ae=class extends Ee{constructor({id:e}={id:""}){super({level:0}),this.VERSION=Pr,this._startTs=j.getHighResolutionTimer(),this._deltaTs=j.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new it(`__probe-${this.id}__`,{[this.id]:Ur}),this.timeStamp(`${this.id} started`),Ir(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((j.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((j.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,t){this._updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e,...t){return this._log("warn",0,e,t,{method:Ne.warn,once:!0})}error(e,...t){return this._log("error",0,e,t,{method:Ne.error})}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t,...o){let n=j.getMemoryUsageMB();if(n!==null){let i=`${n}MB `;typeof t=="function"?t=()=>`${i}${t()}`:typeof t=="string"&&(t=`${i}${t}`)}return this._log("log",e,t,o,{method:Ne.log,time:!0,once:!0})}log(e,t,...o){return this._log("log",e,t,o,{method:Ne.debug})}info(e,t,...o){return this._log("info",e,t,o,{method:console.info})}once(e,t,...o){return this._log("once",e,t,o,{method:Ne.debug||Ne.info,once:!0})}table(e,t,o){return t?this._log("table",e,t,o&&[o]||[],{method:console.table||ge,tag:Oi(t)}):ge}time(e,t){return this._log("time",e,t,[],{method:console.time?console.time:console.info})}timeEnd(e,t){return this._log("time",e,t,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,t){return this._log("time",e,t,[],{method:console.timeStamp||ge})}group(e,t,o={collapsed:!1}){let n=(o.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,t,[],{method:n})}groupCollapsed(e,t,o={}){return this.group(e,t,Object.assign({},o,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||ge})}withGroup(e,t,o){this.group(e,t)();try{o()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,t){let o=t.method;Fe(o),t.total=this.getTotal(),t.delta=this.getDelta(),this._deltaTs=j.getHighResolutionTimer();let n=ki(this.id,t.message,t);return o.bind(console,n,...t.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(Ur),this._storage.config[this.id]}_updateConfiguration(e){let t=this._storage.config[this.id]||{...Ur};this._storage.setConfiguration({[this.id]:{...t,...e}})}};ae.VERSION=Pr});var Vo=b(()=>{nt()});var Wo=b(()=>{nt()});var jo=b(()=>{st()});var Ho=b(()=>{st();globalThis.probe||(globalThis.probe=j)});var vu,qo=b(()=>{$r();st();$r();Vo();nt();Wo();Ot();Ot();Gr();Ar();Er();jo();Ho();vu=new ae({id:"@probe.gl/log"})});var Z,_r=b(()=>{"use strict";qo();Z=new ae({id:"luma.gl"})});function ze(r="id"){Rr[r]=Rr[r]||1;let e=Rr[r]++;return`${r}-${e}`}var Rr,Nt=b(()=>{"use strict";Rr={}});function ji(r,e){let t={...e};for(let o in r)r[o]!==void 0&&(t[o]=r[o]);return t}function Jo(r,e){let t=r.stats,o=!1;for(let u of e)t[u]||(r.get(u),o=!0);let n=Object.keys(t).length,i=Zo.get(r);if(!o&&i?.orderedStatNames===e&&i.statCount===n)return;let a={},s=Qo.get(e);s||(s=new Set(e),Qo.set(e,s));for(let u of e)t[u]&&(a[u]=t[u]);for(let[u,d]of Object.entries(t))s.has(u)||(a[u]=d);for(let u of Object.keys(t))delete t[u];Object.assign(t,a),Zo.set(r,{orderedStatNames:e,statCount:n})}function en(r){return r.type==="webgl"?Wi:Vi}function ut(r){let e=r.userData[Fi];return e?.enabled?e:null}function ye(){return globalThis.performance?.now?.()??Date.now()}function Hi(r,e){let t=ut(r);if(!(!t||!t.activeDefaultFramebufferAcquireDepth))switch(t.transientCanvasResourceCreates=(t.transientCanvasResourceCreates||0)+1,e){case"Texture":t.transientCanvasTextureCreates=(t.transientCanvasTextureCreates||0)+1;break;case"TextureView":t.transientCanvasTextureViewCreates=(t.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":t.transientCanvasSamplerCreates=(t.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":t.transientCanvasFramebufferCreates=(t.transientCanvasFramebufferCreates||0)+1;break;default:break}}function qi(r){let e=Object.getPrototypeOf(r);for(;e;){let t=Object.getPrototypeOf(e);if(!t||t===H.prototype)return Yi(e)||r[Symbol.toStringTag]||r.constructor.name;e=t}return r[Symbol.toStringTag]||r.constructor.name}function Yi(r){let e=Object.getOwnPropertyDescriptor(r,Symbol.toStringTag);return typeof e?.get=="function"?e.get.call(r):typeof e?.value=="string"?e.value:null}var Fi,Yo,Xo,Ko,Ni,zi,Vi,Wi,Zo,Qo,H,zt=b(()=>{"use strict";Nt();Fi="cpu-hotspot-profiler",Yo="GPU Resource Counts",Xo="Resource Counts",Ko="GPU Time and Memory",Ni=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],zi=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],Vi=Ni.flatMap(r=>[`${r} Created`,`${r} Active`]),Wi=zi.flatMap(r=>[`${r} Created`,`${r} Active`]),Zo=new WeakMap,Qo=new WeakMap,H=class{static defaultProps={id:"undefined",handle:void 0,_isHandleBorrowed:!1,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}toJSON(){return this.toString()}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;get ownsHandle(){return(this.props.handle===void 0||this.props.handle===null)&&!this.isHandleBorrowed}get isHandleBorrowed(){return!!this.props._isHandleBorrowed}constructor(e,t,o){if(!e)throw new Error("no device");this._device=e,this.props=ji(t,o);let n=this.props.id!=="undefined"?this.props.id:ze(this[Symbol.toStringTag]);this.props.id=n,this.id=n,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=ut(this._device),t=e?ye():0,o=[this._device.statsManager.getStats(Yo),this._device.statsManager.getStats(Xo)],n=en(this._device);for(let a of o)Jo(a,n);let i=this.getStatsName();for(let a of o)a.get("Resources Active").decrementCount(),a.get(`${i}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(ye()-t))}trackAllocatedMemory(e,t=this.getStatsName()){let o=ut(this._device),n=o?ye():0,i=this._device.statsManager.getStats(Ko);this.allocatedBytes>0&&this.allocatedBytesName&&(i.get("GPU Memory").subtractCount(this.allocatedBytes),i.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),i.get("GPU Memory").addCount(e),i.get(`${t} Memory`).addCount(e),o&&(o.statsBookkeepingCalls=(o.statsBookkeepingCalls||0)+1,o.statsBookkeepingTimeMs=(o.statsBookkeepingTimeMs||0)+(ye()-n)),this.allocatedBytes=e,this.allocatedBytesName=t}trackReferencedMemory(e,t=this.getStatsName()){this.trackAllocatedMemory(e,`External ${t}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let t=ut(this._device),o=t?ye():0,n=this._device.statsManager.getStats(Ko);n.get("GPU Memory").subtractCount(this.allocatedBytes),n.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(ye()-o)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),t=ut(this._device),o=t?ye():0,n=[this._device.statsManager.getStats(Yo),this._device.statsManager.getStats(Xo)],i=en(this._device);for(let a of n)Jo(a,i);for(let a of n)a.get("Resources Created").incrementCount(),a.get("Resources Active").incrementCount(),a.get(`${e}s Created`).incrementCount(),a.get(`${e}s Active`).incrementCount();t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(ye()-o)),Hi(this._device,e)}getStatsName(){return qi(this)}}});var te,tn=b(()=>{"use strict";zt();te=class r extends H{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let o={...t};(t.usage||0)&r.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?o.indexType="uint32":t.data instanceof Uint16Array?o.indexType="uint16":t.data instanceof Uint8Array&&(o.indexType="uint8")),delete o.data,super(e,o,r.defaultProps),this.usage=o.usage||0,this.indexType=o.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(e,t,o){if(!this.device.props.debug)return;let n=null,i;ArrayBuffer.isView(e)?(n=e,i=e.buffer):i=e;let a=Math.min(e?e.byteLength:o,r.DEBUG_DATA_MAX_LENGTH);if(i===null)this.debugData=new ArrayBuffer(a);else{let s=Math.min(n?.byteOffset||0,i.byteLength),u=Math.max(0,i.byteLength-s),d=Math.min(a,u);this.debugData=new Uint8Array(i,s,d).slice().buffer}}static defaultProps={...H.defaultProps,handle:void 0,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0}}});function rn(){return Mr??Uint16Array}function on(r){return!!(Mr&&r===Mr)}var Mr,nn=b(()=>{"use strict";Mr=globalThis.Float16Array});function an(r){let e=r.includes("norm"),t=!e&&!r.startsWith("float"),o=r.startsWith("s"),n=kr[r],[i,a,s]=n||["uint8 ","i32",1];return{signedType:i,primitiveType:a,byteLength:s,normalized:e,integer:t,signed:o}}function sn(r){let e=r;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function un(r,e){switch(e){case 1:return r;case 2:return r+r%2;default:return r+(4-r%4)%4}}function Xi(r){let e=ArrayBuffer.isView(r)?r.constructor:r;if(on(e))return"float16";if(e===Uint8ClampedArray)return"uint8";let t=Object.values(kr).find(o=>e===o[4]);if(!t)throw new Error(e.name);return t[0]}function dn(r){return Xi(r)}function Ki(r){if(r==="float16")return rn();let e=kr[r];if(!e)throw new Error(r);let[,,,,t]=e;return t}function cn(r){return Ki(r)}var kr,mn=b(()=>{"use strict";nn();kr={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});var Or,ln,fn=b(()=>{"use strict";mn();Or=class{getDataTypeInfo(e){return an(e)}getNormalizedDataType(e){return sn(e)}alignTo(e,t){return un(e,t)}getDataType(e){return dn(e)}getTypedArrayConstructor(e){return cn(e)}},ln=new Or});function Yt(r){let e=na[r];if(!e)throw new Error(`Unsupported texture format ${r}`);return e}var _,v,re,Zi,Vt,Fr,Wt,Nr,Qi,zr,xe,Vr,Wr,jt,pn,dt,ct,qr,Yr,We,qt,gn,U,Ht,se,oe,Ji,Hr,hn,ea,F,Ve,ta,jr,ra,oa,na,yn=b(()=>{"use strict";_="texture-compression-bc",v="texture-compression-astc",re="texture-compression-etc2",Zi="texture-compression-etc1-webgl",Vt="texture-compression-pvrtc-webgl",Fr="texture-compression-atc-webgl",Wt="float32-renderable-webgl",Nr="float16-renderable-webgl",Qi="rgb9e5ufloat-renderable-webgl",zr="snorm8-renderable-webgl",xe="norm16-webgl",Vr="norm16-renderable-webgl",Wr="snorm16-renderable-webgl",jt="float32-filterable",pn="float16-filterable-webgl",dt=1,ct=2,qr=4,Yr=8,We=16,qt=5,gn=10,U=dt|ct,Ht=dt|qr,se=dt|ct|qr|Yr,oe=dt|ct|We,Ji=dt|qr|We,Hr=se|We,hn=(ct|Yr|We)<<qt,ea=(ct|Yr)<<qt,F=We<<qt,Ve=Hr<<qt,ta=se<<gn,jr=We<<gn;ra={r8unorm:{webgpu:se|F},rg8unorm:{webgpu:se|F},"rgb8unorm-webgl":{},rgba8unorm:{webgpu:Hr},"rgba8unorm-srgb":{webgpu:se},r8snorm:{render:zr,webgpu:Ht|hn},rg8snorm:{render:zr,webgpu:Ht|hn},"rgb8snorm-webgl":{},rgba8snorm:{render:zr,webgpu:Ji|ea},r8uint:{webgpu:U|F},rg8uint:{webgpu:U|F},rgba8uint:{webgpu:oe},r8sint:{webgpu:U|F},rg8sint:{webgpu:U|F},rgba8sint:{webgpu:oe},bgra8unorm:{webgpu:se},"bgra8unorm-srgb":{webgpu:ta},r16unorm:{f:xe,render:Vr,webgpu:Ve},rg16unorm:{f:xe,render:Vr,webgpu:Ve},"rgb16unorm-webgl":{f:xe,render:!1},rgba16unorm:{f:xe,render:Vr,webgpu:Ve},r16snorm:{f:xe,render:Wr,webgpu:Ve},rg16snorm:{f:xe,render:Wr,webgpu:Ve},"rgb16snorm-webgl":{f:xe,render:!1},rgba16snorm:{f:xe,render:Wr,webgpu:Ve},r16uint:{webgpu:U|F},rg16uint:{webgpu:U|F},rgba16uint:{webgpu:oe},r16sint:{webgpu:U|F},rg16sint:{webgpu:U|F},rgba16sint:{webgpu:oe},r16float:{render:Nr,filter:"float16-filterable-webgl",webgpu:se|F},rg16float:{render:Nr,filter:pn,webgpu:se|F},rgba16float:{render:Nr,filter:pn,webgpu:Hr},r32uint:{webgpu:oe},rg32uint:{webgpu:U|jr},rgba32uint:{webgpu:oe},r32sint:{webgpu:oe},rg32sint:{webgpu:U|jr},rgba32sint:{webgpu:oe},r32float:{render:Wt,filter:jt,webgpu:oe},rg32float:{render:!1,filter:jt,webgpu:U|jr},"rgb32float-webgl":{render:Wt,filter:jt},rgba32float:{render:Wt,filter:jt,webgpu:oe},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:Qi,webgpu:Ht},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Wt,webgpu:Ht|F},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:se|F},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:U|F},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8",webgpu:U},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16",webgpu:U},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32",webgpu:U},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32",webgpu:U},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0,webgpu:U},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0,f:"depth32float-stencil8",webgpu:U}},oa={"bc1-rgb-unorm-webgl":{f:_},"bc1-rgb-unorm-srgb-webgl":{f:_},"bc1-rgba-unorm":{f:_},"bc1-rgba-unorm-srgb":{f:_},"bc2-rgba-unorm":{f:_},"bc2-rgba-unorm-srgb":{f:_},"bc3-rgba-unorm":{f:_},"bc3-rgba-unorm-srgb":{f:_},"bc4-r-unorm":{f:_},"bc4-r-snorm":{f:_},"bc5-rg-unorm":{f:_},"bc5-rg-snorm":{f:_},"bc6h-rgb-ufloat":{f:_},"bc6h-rgb-float":{f:_},"bc7-rgba-unorm":{f:_},"bc7-rgba-unorm-srgb":{f:_},"etc2-rgb8unorm":{f:re},"etc2-rgb8unorm-srgb":{f:re},"etc2-rgb8a1unorm":{f:re},"etc2-rgb8a1unorm-srgb":{f:re},"etc2-rgba8unorm":{f:re},"etc2-rgba8unorm-srgb":{f:re},"eac-r11unorm":{f:re},"eac-r11snorm":{f:re},"eac-rg11unorm":{f:re},"eac-rg11snorm":{f:re},"astc-4x4-unorm":{f:v},"astc-4x4-unorm-srgb":{f:v},"astc-5x4-unorm":{f:v},"astc-5x4-unorm-srgb":{f:v},"astc-5x5-unorm":{f:v},"astc-5x5-unorm-srgb":{f:v},"astc-6x5-unorm":{f:v},"astc-6x5-unorm-srgb":{f:v},"astc-6x6-unorm":{f:v},"astc-6x6-unorm-srgb":{f:v},"astc-8x5-unorm":{f:v},"astc-8x5-unorm-srgb":{f:v},"astc-8x6-unorm":{f:v},"astc-8x6-unorm-srgb":{f:v},"astc-8x8-unorm":{f:v},"astc-8x8-unorm-srgb":{f:v},"astc-10x5-unorm":{f:v},"astc-10x5-unorm-srgb":{f:v},"astc-10x6-unorm":{f:v},"astc-10x6-unorm-srgb":{f:v},"astc-10x8-unorm":{f:v},"astc-10x8-unorm-srgb":{f:v},"astc-10x10-unorm":{f:v},"astc-10x10-unorm-srgb":{f:v},"astc-12x10-unorm":{f:v},"astc-12x10-unorm-srgb":{f:v},"astc-12x12-unorm":{f:v},"astc-12x12-unorm-srgb":{f:v},"pvrtc-rgb4unorm-webgl":{f:Vt},"pvrtc-rgba4unorm-webgl":{f:Vt},"pvrtc-rgb2unorm-webgl":{f:Vt},"pvrtc-rgba2unorm-webgl":{f:Vt},"etc1-rbg-unorm-webgl":{f:Zi},"atc-rgb-unorm-webgl":{f:Fr},"atc-rgba-unorm-webgl":{f:Fr},"atc-rgbai-unorm-webgl":{f:Fr}},na={...ra,...oa}});function ca({format:r,width:e,height:t,depth:o,byteAlignment:n}){let i=Le.getInfo(r),{bytesPerPixel:a,bytesPerBlock:s=a,blockWidth:u=1,blockHeight:d=1,compressed:c=!1}=i,m=c?Math.ceil(e/u):e,l=c?Math.ceil(t/d):t,f=m*s,h=Math.ceil(f/n)*n,y=l,w=h*y*o;return{bytesPerPixel:a,bytesPerRow:h,rowsPerImage:y,depthOrArrayLayers:o,bytesPerImage:h*y,byteLength:w}}function ma(r){let e=Yt(r),t={format:r,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},o=xn(r),n=r.startsWith("depth")||r.startsWith("stencil"),i=o?.signed,a=o?.integer,s=o?.webgl,u=!!o?.compressed;return t.render&&=!n&&!u,t.filter&&=!n&&!i&&!a&&!s,t}function xn(r){let e=la(r);if(Le.isCompressed(r)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=pa(r);let o=fa(r);o&&(e.blockWidth=o.blockWidth,e.blockHeight=o.blockHeight)}let t=e.packed?null:ia.exec(r);if(t){let[,o,n,i,a,s]=t,u=`${i}${n}`,d=ln.getDataTypeInfo(u),c=d.byteLength*8,m=o?.length??1,l=[c,m>=2?c:0,m>=3?c:0,m>=4?c:0];e={format:r,attachment:e.attachment,dataType:d.signedType,components:m,channels:o,integer:d.integer,signed:d.signed,normalized:d.normalized,bitsPerChannel:l,bytesPerPixel:d.byteLength*m,packed:e.packed,srgb:e.srgb},s==="-webgl"&&(e.webgl=!0),a==="-srgb"&&(e.srgb=!0)}return r.endsWith("-webgl")&&(e.webgl=!0),r.endsWith("-srgb")&&(e.srgb=!0),e}function la(r){let e={...Yt(r)},t=e.bytesPerPixel||1,o=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,delete e.webgpu,{...e,format:r,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:t,bitsPerChannel:o,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function fa(r){let t=/.*-(\d+)x(\d+)-.*/.exec(r);if(t){let[,o,n]=t;return{blockWidth:Number(o),blockHeight:Number(n)}}return r.startsWith("bc")||r.startsWith("etc1")||r.startsWith("etc2")||r.startsWith("eac")||r.startsWith("atc")?{blockWidth:4,blockHeight:4}:r.startsWith("pvrtc-rgb4")||r.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:r.startsWith("pvrtc-rgb2")||r.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function pa(r){return r.startsWith("bc1")||r.startsWith("bc4")||r.startsWith("etc1")||r.startsWith("etc2-rgb8")||r.startsWith("etc2-rgb8a1")||r.startsWith("eac-r11")||r==="atc-rgb-unorm-webgl"?8:r.startsWith("bc2")||r.startsWith("bc3")||r.startsWith("bc5")||r.startsWith("bc6h")||r.startsWith("bc7")||r.startsWith("etc2-rgba8")||r.startsWith("eac-rg11")||r.startsWith("astc")||r==="atc-rgba-unorm-webgl"||r==="atc-rgbai-unorm-webgl"?16:r.startsWith("pvrtc")?8:16}var ia,aa,sa,ua,da,Xr,Le,bn=b(()=>{"use strict";fn();yn();ia=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,aa=["rgb","rgba","bgra"],sa=["depth","stencil"],ua=5,da=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Xr=class{isColor(e){return aa.some(t=>e.startsWith(t))}isDepthStencil(e){return sa.some(t=>e.startsWith(t))}isCompressed(e){return da.some(t=>e.startsWith(t))}getInfo(e){return xn(e)}getCapabilities(e){return ma(e)}getWebGPUCapabilities(e){let t=Yt(e);return t.webgpu!==void 0?t.webgpu:this.isCompressed(e)&&!e.endsWith("-webgl")?ua:0}computeMemoryLayout(e){return ca(e)}},Le=new Xr});function mt(r){return typeof ImageData<"u"&&r instanceof ImageData||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement||typeof VideoFrame<"u"&&r instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas}function Xt(r){if(typeof ImageData<"u"&&r instanceof ImageData||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas)return{width:r.width,height:r.height};if(typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement)return{width:r.naturalWidth,height:r.naturalHeight};if(typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement)return{width:r.videoWidth,height:r.videoHeight};if(typeof VideoFrame<"u"&&r instanceof VideoFrame)return{width:r.displayWidth,height:r.displayHeight};throw new Error("Unknown image type")}var wn=b(()=>{"use strict"});var be,Kr=b(()=>{"use strict";zt();be=class r extends H{static defaultProps={...H.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=r.normalizeProps(e,t),super(e,t,r.defaultProps)}static normalizeProps(e,t){return t}}});var ha,R,Tn=b(()=>{"use strict";zt();Kr();_r();bn();ha={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},R=class r extends H{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,t,o){if(t=r.normalizeProps(e,t),super(e,t,r.defaultProps),this.dimension=this.props.dimension,this.baseDimension=ha[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(t.data)){let n=e.getExternalImageSize(t.data);this.width=n?.width||1,this.height=n?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&Z.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=o?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof be?e:this.device.createSampler(e)}copyImageData(e){let{data:t,depth:o,...n}=e;this.writeData(t,{...n,depthOrArrayLayers:n.depthOrArrayLayers??o})}computeMemoryLayout(e={}){let t=this._normalizeTextureReadOptions(e),{width:o=this.width,height:n=this.height,depthOrArrayLayers:i=this.depth}=t,{format:a,byteAlignment:s}=this;return Le.computeMemoryLayout({format:a,width:o,height:n,depth:i,byteAlignment:s})}readBuffer(e,t){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,t){throw new Error("readBuffer not implemented")}writeData(e,t){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,t){let o={...t},{width:n,height:i}=o;return typeof n=="number"&&(o.width=Math.max(1,Math.ceil(n))),typeof i=="number"&&(o.height=Math.max(1,Math.ceil(i))),o}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{data:t,depth:o,...n}=e,i=this._normalizeTextureWriteOptions({...n,depthOrArrayLayers:n.depthOrArrayLayers??o});return{data:t,depth:i.depthOrArrayLayers,...i}}_normalizeCopyExternalImageOptions(e){let t=r._omitUndefined(e),o=t.mipLevel??0,n=this._getMipLevelSize(o),i=this.device.getExternalImageSize(e.image),a={...r.defaultCopyExternalImageOptions,...n,...i,...t};return a.width=Math.min(a.width,n.width-a.x),a.height=Math.min(a.height,n.height-a.y),a.depth=Math.min(a.depth,n.depthOrArrayLayers-a.z),a}_normalizeCopyElementImageOptions(e){let t=r._omitUndefined(e),o=t.mipLevel??0,n=this._getMipLevelSize(o),i={...r.defaultCopyElementImageOptions,...n,...t};return i.width=Math.min(i.width,n.width-i.x),i.height=Math.min(i.height,n.height-i.y),i.depth=Math.min(i.depth,n.depthOrArrayLayers-i.z),i}_normalizeTextureReadOptions(e){let t=r._omitUndefined(e),o=t.mipLevel??0,n=this._getMipLevelSize(o),i={...r.defaultTextureReadOptions,...n,...t};return i.width=Math.min(i.width,n.width-i.x),i.height=Math.min(i.height,n.height-i.y),i.depthOrArrayLayers=Math.min(i.depthOrArrayLayers,n.depthOrArrayLayers-i.z),i}_getSupportedColorReadOptions(e){let t=this._normalizeTextureReadOptions(e),o=Le.getInfo(this.format);switch(this._validateColorReadAspect(t),this._validateColorReadFormat(o),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return t;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(e){let t=r._omitUndefined(e),o=t.mipLevel??0,n=this._getMipLevelSize(o),i={...r.defaultTextureWriteOptions,...n,...t};i.width=Math.min(i.width,n.width-i.x),i.height=Math.min(i.height,n.height-i.y),i.depthOrArrayLayers=Math.min(i.depthOrArrayLayers,n.depthOrArrayLayers-i.z);let a=Le.computeMemoryLayout({format:this.format,width:i.width,height:i.height,depth:i.depthOrArrayLayers,byteAlignment:this.byteAlignment}),s=a.bytesPerPixel*i.width;if(i.bytesPerRow=t.bytesPerRow??a.bytesPerRow,i.rowsPerImage=t.rowsPerImage??i.height,i.bytesPerRow<s)throw new Error(`bytesPerRow (${i.bytesPerRow}) must be at least ${s} for ${this.format}`);if(i.rowsPerImage<i.height)throw new Error(`rowsPerImage (${i.rowsPerImage}) must be at least ${i.height} for ${this.format}`);let u=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(u&&i.bytesPerRow%u!==0)throw new Error(`bytesPerRow (${i.bytesPerRow}) must be a multiple of bytesPerPixel (${u}) for ${this.format}`);return i}_getMipLevelSize(e){let t=Math.max(1,this.width>>e),o=this.baseDimension==="1d"?1:Math.max(1,this.height>>e),n=this.dimension==="3d"?Math.max(1,this.depth>>e):this.depth;return{width:t,height:o,depthOrArrayLayers:n}}getAllocatedByteLength(){let e=0;for(let t=0;t<this.mipLevels;t++){let{width:o,height:n,depthOrArrayLayers:i}=this._getMipLevelSize(t);e+=Le.computeMemoryLayout({format:this.format,width:o,height:n,depth:i,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}static defaultProps={...H.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:r.SAMPLE|r.RENDER|r.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultCopyElementImageOptions={element:void 0,width:void 0,height:void 0,sourceX:0,sourceY:0,sourceWidth:void 0,sourceHeight:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}}});var lt=b(()=>{"use strict";tn();Tn();Kr();_r()});var vn=b(()=>{"use strict";wn()});var Kt=b(()=>{"use strict";lt();lt();lt();vn();lt()});var ga,Ge,Cn=b(()=>{"use strict";Kt();Nt();ga=te.DEBUG_DATA_MAX_LENGTH,Ge=class{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(e,t){let{debugData:o=!1,buffer:n,ownsBuffer:i=!0,...a}=t;if(n&&n.device!==e)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(n&&(a.byteLength!==void 0||a.data!==void 0))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");let s=t.id||n?.id||ze("dynamic-buffer"),u={...a,id:s,usage:a.usage??n?.usage,indexType:a.indexType??n?.indexType};(u.usage||0)&te.INDEX&&!u.indexType&&(a.data instanceof Uint32Array?u.indexType="uint32":a.data instanceof Uint16Array?u.indexType="uint16":a.data instanceof Uint8Array&&(u.indexType="uint8")),delete u.data,delete u.byteOffset,this.device=e,this.id=s,this.props=u,this.usage=u.usage||0,this._debugDataEnabled=!!o,this._maxDebugDataByteLength=typeof o=="object"&&o.maxByteLength!==void 0?o.maxByteLength:ga,this._ownsBuffer=i,this._buffer=n??this.device.createBuffer({...a,id:s}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),a.data&&this._writeDebugData(a.data,a.byteOffset||0)}write(e,t=0){this._buffer.write(e,t),this._touch(),this._writeDebugData(e,t)}async mapAndWriteAsync(e,t=0,o=this.byteLength-t){let n=null;await this._buffer.mapAndWriteAsync(async(i,a)=>{await e(i,a),n=new Uint8Array(i.slice(0,o))},t,o),this._touch(),n&&this._writeDebugData(n,t)}async readAsync(e=0,t=this.byteLength-e){let o=await this._buffer.readAsync(e,t);return this._writeDebugData(o,e)&&this._touch(),o}async mapAndReadAsync(e,t=0,o=this.byteLength-t){let n=null,i=await this._buffer.mapAndReadAsync(async(a,s)=>(n=new Uint8Array(a.slice(0)),await e(a,s)),t,o);return n&&this._writeDebugData(n,t)&&this._touch(),i}resize(e){let{byteLength:t,preserveData:o=!1}=e;if(t===this.byteLength)return!1;let n=Math.min(e.copyByteLength??Math.min(this.byteLength,t),this.byteLength,t),i=this._buffer,a=this.debugData.slice(0),{data:s,byteOffset:u,...d}=this.props,c=this.device.createBuffer({...d,byteLength:t});return o&&n>0&&this._copyBufferContents(i,c,n),this._buffer=c,this._resetDebugData(t),o&&a.byteLength>0&&this._writeDebugData(a,0),this._ownsBuffer&&i.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(e,t){return e<=this.byteLength?!1:this.resize({byteLength:e,preserveData:t?.preserveData})}getBinding(e){return e?.offset===void 0&&e?.size===void 0?this._buffer:{buffer:this._buffer,offset:e?.offset,size:e?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(e,t,o){let n=this.device.type==="webgpu"?Math.ceil(o/4)*4:o,i=this.device.createCommandEncoder();i.copyBufferToBuffer({sourceBuffer:e,destinationBuffer:t,size:n}),this.device.submit(i.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(e){if(!this._debugDataEnabled){this.debugData=new ArrayBuffer(0);return}this.debugData=new ArrayBuffer(Math.min(e,this._maxDebugDataByteLength))}_writeDebugData(e,t){if(!this._debugDataEnabled||this.debugData.byteLength===0||t>=this.debugData.byteLength)return!1;let o=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),n=new Uint8Array(this.debugData),i=Math.min(o.byteLength,n.byteLength-t);return n.set(o.subarray(0,i),t),i>0}}});function ft(r){return r?Array.isArray(r)?r[0]??null:r:null}function Pn(r){let{dimension:e,data:t}=r;if(!t)return null;switch(e){case"1d":{let o=ft(t);if(!o)return null;let{width:n}=pt(o);return{width:n,height:1}}case"2d":{if(ArrayBuffer.isView(t))return null;let o=ft(t);return o?pt(o):null}case"3d":case"2d-array":{if(!Array.isArray(t)||t.length===0)return null;let o=ft(t[0]);return o?pt(o):null}case"cube":{let o=Object.keys(t)[0]??null;if(!o)return null;let n=t[o],i=ft(n);return i?pt(i):null}case"cube-array":{if(!Array.isArray(t)||t.length===0)return null;let o=t[0],n=Object.keys(o)[0]??null;if(!n)return null;let i=ft(o[n]);return i?pt(i):null}default:return null}}function pt(r){if(mt(r))return Xt(r);if(typeof r=="object"&&"width"in r&&"height"in r)return{width:r.width,height:r.height};throw new Error("Unsupported mip-level data")}function ya(r){return typeof r=="object"&&r!==null&&"data"in r&&"width"in r&&"height"in r}function xa(r){return ArrayBuffer.isView(r)}function Qr(r){let{textureFormat:e,format:t}=r;if(e&&t&&e!==t)throw new Error(`Conflicting texture formats "${e}" and "${t}" provided for the same mip level`);return e??t}function Sn(r){let e=Zr[r];if(e===void 0)throw new Error(`Invalid cube face: ${r}`);return e}function ba(r,e){return 6*r+Sn(e)}function Jr(r){throw new Error("setTexture1DData not supported in WebGL.")}function wa(r){return Array.isArray(r)?r:[r]}function De(r,e,t,o){let n=wa(e),i=r,a=[];for(let s=0;s<n.length;s++){let u=n[s];if(mt(u))a.push({type:"external-image",image:u,z:i,mipLevel:s});else if(ya(u))a.push({type:"texture-data",data:u,textureFormat:Qr(u),z:i,mipLevel:s});else if(xa(u)&&t)a.push({type:"texture-data",data:{data:u,width:Math.max(1,t.width>>s),height:Math.max(1,t.height>>s),...o?{format:o}:{}},textureFormat:o,z:i,mipLevel:s});else throw new Error("Unsupported 2D mip-level payload")}return a}function eo(r){let e=[];for(let t=0;t<r.length;t++)e.push(...De(t,r[t]));return e}function to(r){let e=[];for(let t=0;t<r.length;t++)e.push(...De(t,r[t]));return e}function ro(r){let e=[];for(let[t,o]of Object.entries(r)){let n=Sn(t);e.push(...De(n,o))}return e}function oo(r){let e=[];return r.forEach((t,o)=>{for(let[n,i]of Object.entries(t)){let a=ba(o,n);e.push(...De(a,i))}}),e}var Zr,no=b(()=>{"use strict";Kt();Zr={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5}});function Ta(r){if(!r.data)return[];let e=r.width&&r.height?{width:r.width,height:r.height}:void 0,t="format"in r?r.format:void 0;switch(r.dimension){case"1d":return Jr(r.data);case"2d":return De(0,r.data,e,t);case"3d":return eo(r.data);case"2d-array":return to(r.data);case"cube":return ro(r.data);case"cube-array":return oo(r.data);default:throw new Error(`Unhandled dimension ${r.dimension}`)}}function va(r,e,t,o){if(e.length===0)return{subresources:e,mipLevels:1,format:o.format,hasExplicitMipChain:!1};let n=new Map;for(let c of e){let m=n.get(c.z)??[];m.push(c),n.set(c.z,m)}let i=e.some(c=>c.mipLevel>0),a=o.format,s=Number.POSITIVE_INFINITY,u=[];for(let[c,m]of n){let l=[...m].sort((L,P)=>L.mipLevel-P.mipLevel),f=l[0];if(!f||f.mipLevel!==0)throw new Error(`DynamicTexture: slice ${c} is missing mip level 0`);let h=En(r,f);if(h.width!==t.width||h.height!==t.height)throw new Error(`DynamicTexture: slice ${c} base level dimensions ${h.width}x${h.height} do not match expected ${t.width}x${t.height}`);let y=Bn(f);if(y){if(a&&a!==y)throw new Error(`DynamicTexture: slice ${c} base level format "${y}" does not match texture format "${a}"`);a=y}let w=a&&r.isTextureFormatCompressed(a)?Ca(r,h.width,h.height,a):r.getMipLevelCount(h.width,h.height),I=0;for(let L=0;L<l.length;L++){let P=l[L];if(!P||P.mipLevel!==L||L>=w)break;let W=En(r,P),g=Math.max(1,h.width>>L),p=Math.max(1,h.height>>L);if(W.width!==g||W.height!==p)break;let T=Bn(P);if(T&&(a||(a=T),T!==a))break;I++,u.push(P)}s=Math.min(s,I)}let d=Number.isFinite(s)?Math.max(1,s):1;return{subresources:u.filter(c=>c.mipLevel<d),mipLevels:d,format:a,hasExplicitMipChain:i}}function Bn(r){if(r.type==="texture-data")return r.textureFormat??Qr(r.data)}function En(r,e){switch(e.type){case"external-image":return r.getExternalImageSize(e.image);case"texture-data":return{width:e.data.width,height:e.data.height};default:throw new Error("Unsupported texture subresource")}}function Ca(r,e,t,o){let{blockWidth:n=1,blockHeight:i=1}=r.getTextureFormatInfo(o),a=1;for(let s=1;;s++){let u=Math.max(1,e>>s),d=Math.max(1,t>>s);if(u<n||d<i)break;a++}return a}async function io(r){if(r=await r,Array.isArray(r))return await Promise.all(r.map(io));if(r&&typeof r=="object"&&r.constructor===Object){let e=r,t=await Promise.all(Object.values(e).map(io)),o=Object.keys(e),n={};for(let i=0;i<o.length;i++)n[o[i]]=t[i];return n}return r}var Zt,Ln=b(()=>{"use strict";Kt();Nt();no();Zt=class r{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;generation=0;updateTimestamp;resolveReady=()=>{};rejectReady=()=>{};get texture(){if(!this._texture)throw new Error("Texture not initialized yet");return this._texture}get sampler(){if(!this._sampler)throw new Error("Sampler not initialized yet");return this._sampler}get view(){if(!this._view)throw new Error("View not initialized yet");return this._view}get[Symbol.toStringTag](){return"DynamicTexture"}toString(){let e=this._texture?.width??this.props.width??"?",t=this._texture?.height??this.props.height??"?";return`DynamicTexture:"${this.id}":${e}x${t}px:(${this.isReady?"ready":"loading..."})`}resolveTextureBinding(e){return this.isReady?this.texture:null}constructor(e,t){this.device=e;let o=ze("dynamic-texture"),n=t;this.props={...r.defaultProps,id:o,...t,data:null},this.id=this.props.id,this.ready=new Promise((i,a)=>{this.resolveReady=i,this.rejectReady=a}),this.updateTimestamp=this.device.incrementTimestamp(),this.initAsync(n)}async initAsync(e){try{let t=await this._loadAllData(e);this._checkNotDestroyed();let o=t.data?Ta({...t,width:e.width,height:e.height,format:e.format}):[],n="format"in e&&e.format!==void 0,i="usage"in e&&e.usage!==void 0,s=(()=>{if(this.props.width&&this.props.height)return{width:this.props.width,height:this.props.height};let y=Pn(t);return y||{width:this.props.width||1,height:this.props.height||1}})();if(!s||s.width<=0||s.height<=0)throw new Error(`${this} size could not be determined or was zero`);let u=va(this.device,o,s,{format:n?e.format:void 0}),d=u.format??this.props.format,c={...this.props,...s,format:d,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(d)&&!i&&(c.usage=R.SAMPLE|R.COPY_DST);let m=this.props.mipmaps&&!u.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(d);if(this.device.type==="webgpu"&&m){let y=this.props.dimension==="3d"?R.SAMPLE|R.STORAGE|R.COPY_DST|R.COPY_SRC:R.SAMPLE|R.RENDER|R.COPY_DST|R.COPY_SRC;c.usage|=y}let l=this.device.getMipLevelCount(c.width,c.height),f=u.hasExplicitMipChain?u.mipLevels:this.props.mipLevels==="auto"?l:Math.max(1,Math.min(l,this.props.mipLevels??1)),h={...c,mipLevels:f};this._texture=this.device.createTexture(h),this._sampler=this.texture.sampler,this._view=this.texture.view,this._touchGeneration(),u.subresources.length&&this._setTextureSubresources(u.subresources),this.props.mipmaps&&!u.hasExplicitMipChain&&!m&&Z.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),m&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),Z.info(1,`${this} created`)()}catch(t){let o=t instanceof Error?t:new Error(String(t));this.rejectReady(o)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.isReady=!1,this.destroyed=!0}generateMipmaps(){this.device.type==="webgl"?(this.texture.generateMipmapsWebGL(),this._touch()):this.device.type==="webgpu"?(this.device.generateMipmapsWebGPU(this.texture),this._touch()):Z.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();let t=e instanceof be?e:this.device.createSampler(e);this.texture.setSampler(t),this._sampler=t,this._touchGeneration()}async readBuffer(e={}){this.isReady||await this.ready;let t=e.width??this.texture.width,o=e.height??this.texture.height,n=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:t,height:o,depthOrArrayLayers:n}),a=this.device.createBuffer({byteLength:i.byteLength,usage:te.COPY_DST|te.MAP_READ});this.texture.readBuffer({...e,width:t,height:o,depthOrArrayLayers:n},a);let s=this.device.createFence();return await s.signaled,s.destroy(),a}async readAsync(e={}){this.isReady||await this.ready;let t=e.width??this.texture.width,o=e.height??this.texture.height,n=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:t,height:o,depthOrArrayLayers:n}),a=await this.readBuffer(e),s=await a.readAsync(0,i.byteLength);return a.destroy(),s.buffer instanceof ArrayBuffer?s.buffer:s.slice().buffer}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;let t=this.texture;return this._texture=t.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,t.destroy(),this._touchGeneration(),Z.info(`${this} resized`),!0}getCubeFaceIndex(e){let t=Zr[e];if(t===void 0)throw new Error(`Invalid cube face: ${e}`);return t}getCubeArrayFaceIndex(e,t){return 6*e+this.getCubeFaceIndex(t)}setTexture1DData(e){if(this._checkReady(),this.texture.props.dimension!=="1d")throw new Error(`${this} is not 1d`);let t=Jr(e);this._setTextureSubresources(t)}setTexture2DData(e,t=0){if(this._checkReady(),this.texture.props.dimension!=="2d")throw new Error(`${this} is not 2d`);let o=De(t,e);this._setTextureSubresources(o)}setTexture3DData(e){if(this.texture.props.dimension!=="3d")throw new Error(`${this} is not 3d`);let t=eo(e);this._setTextureSubresources(t)}setTextureArrayData(e){if(this.texture.props.dimension!=="2d-array")throw new Error(`${this} is not 2d-array`);let t=to(e);this._setTextureSubresources(t)}setTextureCubeData(e){if(this.texture.props.dimension!=="cube")throw new Error(`${this} is not cube`);let t=ro(e);this._setTextureSubresources(t)}setTextureCubeArrayData(e){if(this.texture.props.dimension!=="cube-array")throw new Error(`${this} is not cube-array`);let t=oo(e);this._setTextureSubresources(t)}_setTextureSubresources(e){for(let t of e){let{z:o,mipLevel:n}=t;switch(t.type){case"external-image":let{image:i,flipY:a}=t;this.texture.copyExternalImage({image:i,z:o,mipLevel:n,flipY:a});break;case"texture-data":let{data:s,textureFormat:u}=t;if(u&&u!==this.texture.format)throw new Error(`${this} mip level ${n} uses format "${u}" but texture format is "${this.texture.format}"`);this.texture.writeData(s.data,{x:0,y:0,z:o,width:s.width,height:s.height,depthOrArrayLayers:1,mipLevel:n});break;default:throw new Error("Unsupported 2D mip-level payload")}}e.length>0&&this._touch()}async _loadAllData(e){let t=await io(e.data);return{dimension:e.dimension??"2d",data:t??null}}_checkNotDestroyed(){this.destroyed&&Z.warn(`${this} already destroyed`)}_checkReady(){this.isReady||Z.warn(`${this} Cannot perform this operation before ready`)}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_touchGeneration(){this.generation++,this._touch()}static defaultProps={...R.defaultProps,dimension:"2d",data:null,mipmaps:!1}}});var Gn=b(()=>{"use strict"});var Dn=b(()=>{"use strict";Cn();Ln();no();Gn()});function we(r){return In.test(r)}function Te(r){return An.test(r)}function Un(r){let e=In.exec(r),t=An.exec(r),n=$n(r)?.elementFormat??e?.[1]??t?.[1]??r;try{ht.vertexFormatDecoder.getVertexFormatInfo(n)}catch{throw new Error(`Unsupported GPUVector format ${r}`)}return n}function N(r){let e=Un(r),t=we(r),o=Te(r),n=$n(r),i=ht.vertexFormatDecoder.getVertexFormatInfo(e),a=i.byteLength*(n?.listSize??1);if(!Number.isSafeInteger(a))throw new Error(`Unsupported GPUVector format ${r}`);let s=i.type,u=i.normalized,d=Sa(s,u);return{format:r,elementFormat:e,vertexList:t,valueList:o,fixedSizeList:!!n,...n?{listSize:n.listSize}:{},type:s,signedDataType:Ba(e,s),primitiveType:d,components:i.components,elementByteLength:i.byteLength,byteLength:a,integer:i.integer,signed:i.signed,normalized:u,...i.webglOnly?{webglOnly:!0}:{}}}function $n(r){let e=Pa.exec(r);if(!e)return;let t=Number(e[2]);if(!Number.isSafeInteger(t))return;let o=e[1];try{let n=ht.vertexFormatDecoder.getVertexFormatInfo(o);if(!Number.isSafeInteger(t*n.components)||!Number.isSafeInteger(t*n.byteLength))return}catch{return}return{elementFormat:o,listSize:t}}function Sa(r,e){if(e)return"f32";switch(r){case"float32":return"f32";case"float16":return"f16";case"uint8":case"uint16":case"uint32":return"u32";case"sint8":case"sint16":case"sint32":return"i32";default:throw new Error(`Unsupported GPUVector component type ${r}`)}}function Ba(r,e){if(r==="unorm10-10-10-2")return"uint32";switch(e){case"unorm8":return"uint8";case"snorm8":return"sint8";case"unorm16":return"uint16";case"snorm16":return"sint16";default:return e}}var ht,In,An,Pa,_n=b(()=>{"use strict";ht=ee(K(),1),In=/^vertex-list<([^<>]+)>$/,An=/^value-list<([^<>]+)>$/,Pa=/^fixed-size-list<([^<>,]+),([1-9][0-9]*)>$/});function Ie(r){let e=0;return Object.freeze(r.map(t=>{let o=Object.freeze({offset:e,length:t.length,data:t});return e+=t.length,o}))}var Rn=b(()=>{"use strict"});var ao,Ae=b(()=>{"use strict";_n();ao=ee(K(),1);Rn()});var me,A,ai=b(()=>{"use strict";me=ee(K(),1),A=class r{static async createAsync(e,t){let o=!me.PipelineFactory.getAsyncCompilation(e),n=o?me.PipelineFactory.beginAsyncCompilation(e):me.PipelineFactory.getAsyncCompilation(e),i;try{i=new r(e,t)}finally{o&&me.PipelineFactory.endAsyncCompilation(e,n)}try{return o?await Promise.all(n):await i._pipelineInitialization,i}catch(a){throw i.destroy(),a}}device;id;source;pipelineFactory;shaderFactory;shader;pipeline;_pipelineInitialization;_destroyed=!1;constructor(e,t){if(e.type!=="webgpu")throw new Error("Kernel is only supported in WebGPU");let{source:o,pipelineFactory:n,shaderFactory:i,debugShaders:a,...s}=t;this.device=e,this.id=t.id??"kernel",this.source=o,this.pipelineFactory=n??me.PipelineFactory.getDefaultPipelineFactory(e),this.shaderFactory=i??me.ShaderFactory.getDefaultShaderFactory(e),this.shader=this.shaderFactory.createShader({id:`${this.id}-compute`,stage:"compute",source:this.source,debugShaders:a});let u={...s,shader:this.shader},d=me.PipelineFactory.getAsyncCompilation(e);if(d){let c=this.pipelineFactory.createComputePipelineAsync(u);this._pipelineInitialization=c,d.push(c.then(m=>(this.pipeline=m,m)))}else this.pipeline=this.pipelineFactory.createComputePipeline(u)}dispatch(e,t){this._setPipeline(e,t.bindings),e.dispatch(t.x,t.y,t.z)}dispatchIndirect(e,t){this._setPipeline(e,t.bindings),e.dispatchIndirect(t.indirectBuffer,t.indirectOffset??0)}destroy(){this._destroyed||(this.pipeline&&this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._destroyed=!0)}_setPipeline(e,t={}){e.setPipeline(this.pipeline),e.setBindings(t)}}});var le=b(()=>{"use strict";ai()});var Lt={};Di(Lt,{CompiledGPUCommandGraph:()=>qe,GPUCommandGraph:()=>He,GPUCommandGraphAutotuner:()=>Eo,GPUCommandGraphEncoding:()=>Ct,GPUCommandGraphExecution:()=>vt,GPUCommandGraphExecutionBudgetController:()=>Lo,GPUCommandGraphInspector:()=>Go,GPUGraph:()=>Jt,GPUGraphCompiler:()=>yr,GPUGraphScalar:()=>Ye,GPUGraphTexture:()=>Ke,GPUGraphTextureView:()=>ce,GPUGraphVector:()=>Xe,GPUOperationLoweringRegistry:()=>rt,GraphBufferHandle:()=>Ce,GraphDataView:()=>de,GraphExternalTextureHandle:()=>$e,GraphTextureHandle:()=>ne,GraphTextureView:()=>Pe,GraphVectorView:()=>B,composite:()=>oi,getGPUCommandGraphAdapterIdentity:()=>ms,getGPUCommandGraphExecutionPlan:()=>go,inspectGPUGraphCompilation:()=>hi,validateGPUGraph:()=>gr});At(Lt,ee(K(),1));var Be=ee(K(),1);async function ko(r,e){if(r.destroyed)throw new Error("Resource has been destroyed.");if(r instanceof Be.Buffer){if(!(r.usage&Be.Buffer.COPY_SRC))throw new Error("Preview requires COPY_SRC usage.");let d=e.byteOffset??0,c=Math.min(256,e.byteLength??r.byteLength-d);if(d<0||c<0||d+c>r.byteLength)throw new Error("Preview range is outside the buffer.");return{data:c?await r.readAsync(d,c):new Uint8Array,format:e.format}}let t=r.device.getTextureFormatInfo(r.format);if(t.packed)throw new Error("Packed texture previews are not supported.");if(r.device.type!=="webgpu")throw new Error("Texture previews require WebGPU.");if(!((r.props.usage??0)&Be.Texture.COPY_SRC))throw new Error("Preview requires COPY_SRC usage.");if(r.samples!==1||t.compressed||r.format.startsWith("depth")||r.format.startsWith("stencil"))throw new Error("Preview requires a single-sample, uncompressed color texture.");let o=e.baseMipLevel??0,n=Math.min(32,e.width??Math.max(1,r.width>>o)),i=Math.min(32,e.height??Math.max(1,r.height>>o)),a=r.computeMemoryLayout({width:n,height:i,depthOrArrayLayers:1}),s=r.device.createBuffer({byteLength:a.byteLength,usage:Be.Buffer.MAP_READ|Be.Buffer.COPY_DST}),u=r.device.createCommandEncoder();try{u.copyTextureToBuffer({sourceTexture:r,destinationBuffer:s,mipLevel:o,origin:[0,0,e.baseArrayLayer??0],width:n,height:i,depthOrArrayLayers:1,bytesPerRow:a.bytesPerRow}),r.device.submit(u.finish());let d=await s.readAsync(),c=n*t.bytesPerPixel,m=new Uint8Array(c*i);for(let l=0;l<i;l++)m.set(d.subarray(l*a.bytesPerRow,l*a.bytesPerRow+c),l*c);return{data:m,width:n,height:i,format:r.format}}finally{s.destroy(),u.destroy()}}var z=ee(K(),1);Dn();Ae();var gt=class{compare;values=[];constructor(e){this.compare=e}peek(){return this.values[0]}push(e){let t=this.values.length;for(this.values.push(e);t>0;){let o=Math.floor((t-1)/2);if(this.compare(this.values[o],e)<=0)break;this.values[t]=this.values[o],t=o}this.values[t]=e}pop(){let e=this.values[0],t=this.values.pop();if(this.values.length&&t!==void 0){let o=0;for(;o*2+1<this.values.length;){let n=o*2+1;if(n+1<this.values.length&&this.compare(this.values[n+1],this.values[n])<0&&n++,this.compare(t,this.values[n])<=0)break;this.values[o]=this.values[n],o=n}this.values[o]=t}return e}};var yt=ee(K(),1);function Nn(r){let e=jn(r.nodes),t=Hn(e,r.buffers.values()),o=qn(e,r.textures.values()),n=new Map,i=new Map,a=[];try{for(let s of t){s.buffer=r.device.createBuffer({id:`${r.id}-transient-buffer-${t.indexOf(s)}`,byteLength:s.byteLength,usage:s.usage});for(let u of s.handles)n.set(u,s.buffer)}for(let s of o){s.texture=r.device.createTexture({...s.descriptor,id:`${r.id}-transient-texture-${o.indexOf(s)}`});for(let u of s.handles)i.set(u,s.texture)}for(let s of e)a.push({node:s,executable:s.compile({device:r.device})})}catch(s){for(let u of a)u.executable.destroy?.();for(let u of t)u.buffer?.destroy();for(let u of o)u.texture?.destroy();throw s}return Vn(r,e,a,n,i,t,o)}async function zn(r){let e=jn(r.nodes),t=Hn(e,r.buffers.values()),o=qn(e,r.textures.values()),n=new Map,i=new Map;try{for(let f of t){f.buffer=r.device.createBuffer({id:`${r.id}-transient-buffer-${t.indexOf(f)}`,byteLength:f.byteLength,usage:f.usage});for(let h of f.handles)n.set(h,f.buffer)}for(let f of o){f.texture=r.device.createTexture({...f.descriptor,id:`${r.id}-transient-texture-${o.indexOf(f)}`});for(let h of f.handles)i.set(h,f.texture)}let a=yt.PipelineFactory.beginAsyncCompilation(r.device),s=e.map(async f=>({node:f,executable:f.compileAsync?await f.compileAsync({device:r.device}):f.compile({device:r.device})}));yt.PipelineFactory.endAsyncCompilation(r.device,a);let[u,d]=await Promise.all([Promise.allSettled(s),Promise.allSettled(a)]),c=[],m=d.find(f=>f.status==="rejected"),l=m?.status==="rejected"?m.reason:void 0;for(let f of u)f.status==="fulfilled"?c.push(f.value):l??=f.reason;if(l){for(let f of c)f.executable.destroy?.();throw l}return Vn(r,e,c,n,i,t,o)}catch(a){for(let s of t)s.buffer?.destroy();for(let s of o)s.texture?.destroy();throw a}}function Vn(r,e,t,o,n,i,a){let s=Array.from(r.buffers.values()),u=s.filter(x=>!x.transient),d=s.filter(x=>x.transient),c=je(u.map(x=>x.byteLength),"imported buffer capacities"),m=je(d.map(x=>x.byteLength),"logical transient buffer capacities"),l=Ue(c,m,"logical buffer capacities"),f=je(i.map(x=>x.byteLength),"physical transient buffer capacities"),h=Math.max(0,m-f),y=Array.from(r.textures.values()),w=y.filter(x=>!x.transient),I=y.filter(x=>x.transient),L=je(w.map(mo),"imported texture estimates"),P=je(I.map(mo),"logical transient texture estimates"),W=Ue(L,P,"logical texture estimates"),g=je(a.map(x=>x.byteLength),"physical transient texture estimates"),p=Math.max(0,P-g),T={nodeOrder:e.map(x=>x.id),importedBufferCount:u.length,importedBufferBytes:c,logicalBufferCount:s.length,logicalBufferBytes:l,logicalTransientBufferCount:d.length,physicalTransientBufferCount:i.length,logicalTransientBytes:m,physicalTransientBytes:f,reusedTransientBytes:h,reusePercentage:m>0?h/m*100:0,importedTextureCount:w.length,importedTextureBytes:L,logicalTextureCount:y.length,logicalTextureBytes:W,logicalTransientTextureCount:I.length,physicalTransientTextureCount:a.length,logicalTransientTextureBytes:P,physicalTransientTextureBytes:g,reusedTransientTextureBytes:p,textureReusePercentage:P>0?p/P*100:0,logicalResourceBytes:Ue(l,W,"logical resource estimates"),physicalTransientResourceBytes:Ue(f,g,"physical transient resource estimates")},C=La(r.device,s,e);return{device:r.device,id:r.id,buffers:new Map(r.buffers),textures:new Map(r.textures),externalTextures:new Map(r.externalTextures),compiledNodes:t,transientBuffers:o,transientTextures:n,bufferTransientAllocations:i,textureTransientAllocations:a,stats:T,preflight:C}}function Ea(r){if("buffer"in r){let t=r.buffer,o="buffer"in t?t:void 0;return Object.freeze({id:o?o.buffer.id:t.id,kind:"buffer",usage:r.usage,byteOffset:o?.byteOffset??0,byteLength:o?o.length===0?0:(o.length-1)*o.byteStride+o.rowByteLength:t.byteLength,...o?{format:o.format,length:o.length}:{}})}let e="texture"in r?r.texture:r.externalTexture;return Object.freeze({id:"texture"in e?e.texture.id:e.id,kind:"externalTexture"in r?"external-texture":"texture",usage:r.usage,width:e.width,height:e.height,..."texture"in e?{baseMipLevel:e.baseMipLevel,baseArrayLayer:e.baseArrayLayer,mipLevelCount:e.mipLevelCount,arrayLayerCount:e.arrayLayerCount,aspect:e.aspect}:{},..."format"in e?{format:e.format,depth:e.depth}:{}})}function La(r,e,t){let o=t.map(s=>{let u=s.workload??{};return Object.freeze({id:s.id,...s.description===void 0?{}:{description:s.description},type:s.type,resources:Object.freeze((s.resources??[]).map(Ea)),...u.operation?{operation:u.operation}:{},...u.variant?{variant:u.variant}:{},...s.publication?{publication:Object.freeze({...s.publication})}:{},...s.condition?{condition:Object.freeze(s.condition.source==="cpu"?{id:s.condition.id,source:"cpu",mode:"skip"}:{id:s.condition.id,source:"gpu",mode:"indirect",bufferId:s.condition.buffer.id,byteOffset:s.condition.byteOffset??0})}:{},commandCount:u.commandCount??0,maximumWorkgroupCount:u.maximumWorkgroupCount??0,maximumInvocationCount:u.maximumInvocationCount??0,readByteLength:u.readByteLength??0,writeByteLength:u.writeByteLength??0})}),n=e.reduce((s,u)=>Math.max(s,u.byteLength),0),i=t.reduce((s,u)=>{for(let d of u.resources??[])ve(d)&&(d.usage==="storage-read"||d.usage==="storage-write"||d.usage==="storage-read-write")&&(s=Math.max(s,uo(d.buffer).size));return s},0),a=s=>o.reduce((u,d)=>{let c=d[s];return typeof c=="number"?Ue(u,c,"workload estimates"):u},0);return Object.freeze({nodes:Object.freeze(o),annotatedNodeCount:t.filter(s=>s.workload!==void 0).length,conditionalNodeCount:t.filter(s=>s.condition!==void 0).length,commandCount:a("commandCount"),maximumWorkgroupCount:a("maximumWorkgroupCount"),maximumInvocationCount:a("maximumInvocationCount"),readByteLength:a("readByteLength"),writeByteLength:a("writeByteLength"),largestBufferByteLength:n,largestStorageBufferBindingByteLength:i,maxBufferByteLength:r.limits.maxBufferSize,maxStorageBufferBindingByteLength:r.limits.maxStorageBufferBindingSize,fitsDeviceLimits:n<=r.limits.maxBufferSize&&i<=r.limits.maxStorageBufferBindingSize})}function Q(r){return"buffer"in r?r.buffer:r}function ue(r){return"texture"in r?r.texture:r}function ve(r){return"buffer"in r}function xt(r){return"texture"in r}function Wn(r){if(r.type==="copy")return;let e=(r.resources??[]).filter(t=>ve(t)&&(t.usage==="storage-read"||t.usage==="storage-write"||t.usage==="storage-read-write"));for(let t=0;t<e.length;t++){let o=e[t];for(let n=t+1;n<e.length;n++){let i=e[n];if(o.buffer===i.buffer||Q(o.buffer)!==Q(i.buffer)||!co(o.usage)&&!co(i.usage))continue;let a=uo(o.buffer),s=uo(i.buffer);if(a.offset<s.offset+s.size&&s.offset<a.offset+a.size){let u=Q(o.buffer);throw new Error(`GPUCommandGraph node "${r.id}" has overlapping writable storage bindings for buffer "${u.id}" (${Mn(a)} and ${Mn(s)}). Bind the shared range once or align the views to non-overlapping storage binding ranges.`)}}}}function uo(r){if(!("buffer"in r))return{offset:0,size:r.byteLength};let e=256,t=Math.floor(r.byteOffset/e)*e,o=r.byteOffset-t,n=r.length===0?r.rowByteLength:(r.length-1)*r.byteStride+r.rowByteLength;return{offset:t,size:o+Math.max(n,r.rowByteLength)}}function Mn(r){return`${r.offset}\u2013${r.offset+r.size} bytes`}function Ga(r){return r==="storage-read"||r==="storage-read-write"||r==="uniform"||r==="copy-source"||r==="indirect"||r==="vertex"||r==="index"}function co(r){return r==="storage-write"||r==="storage-read-write"||r==="copy-destination"}function kn(r){return r==="sampled"||r==="storage-read"||r==="storage-read-write"||r==="render-attachment"||r==="copy-source"}function so(r){return r==="storage-write"||r==="storage-read-write"||r==="render-attachment"||r==="copy-destination"}function jn(r){let e=new Map(r.map(m=>[m.id,m])),t=new Map,o=new Map,n=new Map,i=new Map;for(let m of r){let l=new Set(m.dependsOn??[]);for(let f of l)if(!e.has(f))throw new Error(`GPUCommandGraph node "${m.id}" depends on missing node "${f}"`);for(let f of m.resources??[])if(ve(f)){let h=Q(f.buffer);if(Ga(f.usage)){let y=o.get(h);y&&l.add(y);let w=n.get(h)??new Set;w.add(m.id),n.set(h,w)}if(co(f.usage)){let y=o.get(h);y&&l.add(y);for(let w of n.get(h)??[])w!==m.id&&l.add(w);n.set(h,new Set),o.set(h,m.id)}}else if(xt(f)){let h=ue(f.texture),y=i.get(h)??[];for(let w of y)w.nodeId!==m.id&&Da(w.resource,f)&&(kn(f.usage)&&so(w.resource.usage)||so(f.usage)&&(kn(w.resource.usage)||so(w.resource.usage)))&&l.add(w.nodeId);y.push({nodeId:m.id,resource:f}),i.set(h,y)}l.delete(m.id),t.set(m.id,l)}let a=r.map(()=>[]),s=new Map(r.map((m,l)=>[m.id,l])),u=r.map(m=>t.get(m.id).size);for(let[m,l]of r.entries())for(let f of t.get(l.id))a[s.get(f)].push(m);let d=u.flatMap((m,l)=>m===0?[l]:[]),c=[];for(;d.length;){let m=[];for(let l of d){c.push(r[l]);for(let f of a[l])--u[f]===0&&m.push(f)}d=m.sort((l,f)=>l-f)}if(c.length!==r.length)throw new Error("GPUCommandGraph contains a dependency cycle");return c}function Da(r,e){let t=ue(r.texture),o=ue(e.texture);if(t!==o)return!1;let n=On(r.texture),i=On(e.texture);return Ia(n.aspect,i.aspect)&&Fn(n.baseMipLevel,n.mipLevelCount,i.baseMipLevel,i.mipLevelCount)&&Fn(n.baseArrayLayer,n.arrayLayerCount,i.baseArrayLayer,i.arrayLayerCount)}function On(r){return"texture"in r?r:{aspect:"all",baseMipLevel:0,mipLevelCount:r.mipLevels,baseArrayLayer:0,arrayLayerCount:r.dimension==="3d"?1:r.depth}}function Ia(r,e){return r==="all"||e==="all"||r===e}function Fn(r,e,t,o){return r<t+o&&t<r+e}function Hn(r,e){let t=Yn(r,s=>ve(s)?Q(s.buffer):null),o=[],n=Array.from(e).filter(s=>s.transient).map(s=>({buffer:s,lifetime:t.get(s)})).sort((s,u)=>(s.lifetime?.firstUse??Number.MAX_SAFE_INTEGER)-(u.lifetime?.firstUse??Number.MAX_SAFE_INTEGER)),i=new gt((s,u)=>s.allocation.lastUse-u.allocation.lastUse||s.index-u.index),a=new gt((s,u)=>s.allocation.byteLength-u.allocation.byteLength||s.index-u.index);for(let{buffer:s,lifetime:u}of n){if(!u)continue;for(;i.peek()&&i.peek().allocation.lastUse<u.firstUse;)a.push(i.pop());let d=a.pop();d||(d={allocation:{byteLength:0,usage:0,lastUse:-1,handles:[]},index:o.length},o.push(d.allocation));let{allocation:c}=d;c.byteLength=Math.max(c.byteLength,s.byteLength),c.usage|=s.usage,c.lastUse=u.lastUse,c.handles.push(s),i.push(d)}return o}function qn(r,e){let t=Yn(r,i=>xt(i)?ue(i.texture):null),o=[],n=Array.from(e).filter(i=>i.transient).map(i=>({texture:i,lifetime:t.get(i)})).sort((i,a)=>(i.lifetime?.firstUse??Number.MAX_SAFE_INTEGER)-(a.lifetime?.firstUse??Number.MAX_SAFE_INTEGER));for(let{texture:i,lifetime:a}of n){if(!a)continue;let s=o.find(u=>u.lastUse<a.firstUse&&Ua(u.descriptor,i));s||(s={descriptor:Aa(i),byteLength:mo(i),lastUse:-1,handles:[]},o.push(s)),s.descriptor.usage|=i.usage,s.lastUse=a.lastUse,s.handles.push(i)}return o}function Yn(r,e){let t=new Map;return r.forEach((o,n)=>{for(let i of o.resources??[]){let a=e(i);if(!a||!("transient"in a)||!a.transient)continue;let s=t.get(a);s?s.lastUse=n:t.set(a,{firstUse:n,lastUse:n})}}),t}function Aa(r){return{id:r.id,format:r.format,width:r.width,height:r.height,usage:r.usage,dimension:r.dimension,depth:r.depth,mipLevels:r.mipLevels,samples:r.samples}}function Ua(r,e){return r.format===e.format&&r.width===e.width&&r.height===e.height&&r.dimension===e.dimension&&r.depth===e.depth&&r.mipLevels===e.mipLevels&&r.samples===e.samples}function mo(r){let e=0;for(let o=0;o<r.mipLevels;o++)e=Ue(e,yt.textureFormatDecoder.computeMemoryLayout({format:r.format,width:Math.max(1,r.width>>o),height:r.dimension==="1d"?1:Math.max(1,r.height>>o),depth:r.dimension==="3d"?Math.max(1,r.depth>>o):r.depth,byteAlignment:1}).byteLength,`texture "${r.id}" mip estimates`);let t=e*r.samples;if(!Number.isSafeInteger(t))throw new Error(`GPUCommandGraph texture "${r.id}" byte estimate exceeds safe integer range`);return t}function Ue(r,e,t){let o=r+e;if(!Number.isSafeInteger(o))throw new Error(`GPUCommandGraph ${t} exceed safe integer range`);return o}function je(r,e){return r.reduce((t,o)=>Ue(t,o,e),0)}Ae();var Ce=class{id;byteLength;usage;transient;graph;defaultBuffer;constructor(e,t,o,n){this.graph=e,this.id=t.id,this.byteLength=t.byteLength,this.usage=t.usage,this.transient=o,this.defaultBuffer=n}},de=class{buffer;format;length;byteOffset;byteStride;rowByteLength;constructor(e,t){this.buffer=e,this.format=t.format,this.length=t.length,this.byteOffset=t.byteOffset,this.byteStride=t.byteStride,this.rowByteLength=t.rowByteLength}},B=class{chunks;id;name;format;length;valueLength;stride;byteStride;rowByteLength;data;constructor(e){if(this.id=e.id,this.name=e.name,this.format=e.format,this.length=e.length,this.valueLength=e.valueLength,this.stride=e.stride,this.byteStride=e.byteStride,this.rowByteLength=e.rowByteLength,e.data.some(t=>t.format!==e.format)||e.data.reduce((t,o)=>t+o.length,0)!==e.length)throw new Error(`${e.id} length must equal its ordered source chunks, with matching formats`);this.data=Object.freeze([...e.data]),this.chunks=Ie(this.data)}},ne=class{id;format;width;height;usage;dimension;depth;mipLevels;samples;transient;frameScoped;graph;defaultTexture;constructor(e,t,o,n,i=!1){this.graph=e,this.id=t.id,this.format=t.format,this.width=t.width,this.height=t.height,this.usage=t.usage,this.dimension=t.dimension,this.depth=t.depth,this.mipLevels=t.mipLevels,this.samples=t.samples,this.transient=o,this.frameScoped=i,this.defaultTexture=n}},$e=class{id;width;height;graph;constructor(e,t){this.graph=e,this.id=t.id,this.width=t.width,this.height=t.height}},Pe=class{texture;format;dimension;aspect;baseMipLevel;mipLevelCount;baseArrayLayer;arrayLayerCount;width;height;depth;constructor(e,t){this.texture=e,this.format=e.format,this.dimension=t.dimension,this.aspect=t.aspect,this.baseMipLevel=t.baseMipLevel,this.mipLevelCount=t.mipLevelCount,this.baseArrayLayer=t.baseArrayLayer,this.arrayLayerCount=t.arrayLayerCount,this.width=t.width,this.height=t.height,this.depth=t.depth}};function lo(r,e){switch(e.type){case"compute":{let{type:t,...o}=e;r.addComputePass(o);return}case"render":{let{type:t,...o}=e;r.addRenderPass(o);return}case"copy":{let{type:t,...o}=e;r.addCopyPass(o);return}}}function _e(r,e){for(let t of e)lo(r,t)}function M(r){return{...r,type:"compute"}}var $a=4,vt=class{nodeCount;budget;plan;encodeNodeRange;nextStepIndex=0;currentPublishedProgress=0;constructor(e){ei(e.budget),this.plan=e.plan,this.nodeCount=e.plan.nodeCount,this.budget=Object.freeze({...e.budget}),this.encodeNodeRange=e.encodeNodeRange}get completed(){return this.nextStepIndex>=this.plan.stepCount}get progress(){return this.plan.stepCount===0?1:this.nextStepIndex/this.plan.stepCount}get publishedProgress(){return this.currentPublishedProgress}encodeNext(e,t){if(this.completed)throw new Error("GPUCommandGraph execution has already completed");let o=this.plan.steps[this.nextStepIndex],n=this.encodeNodeRange(e,t,o.firstNodeIndex,o.nextNodeIndex);return this.nextStepIndex++,o.publishable&&(this.currentPublishedProgress=this.progress),{...o,encoding:n,progress:this.progress,completed:this.completed,publishedProgress:this.publishedProgress}}};function go(r,e,t={}){ei(e);let o=t.latencyPriority??"normal",n=t.publicationPolicy??"final";if(!["interactive","normal","background"].includes(o))throw new Error(`GPUCommandGraph execution latency priority "${o}" is invalid`);if(!["final","progressive"].includes(n))throw new Error(`GPUCommandGraph execution publication policy "${n}" is invalid`);let i=r.nodes,a=[],s=0;for(;s<i.length;){let d=s,c=Xn();for(;s<i.length;){let f=Kn(c,i[s]);if(s>d&&Zn(f,e)||(c=f,s++,n==="progressive"&&i[s-1].publication)||_a(c,e))break}let m=Object.freeze(n==="progressive"?i.slice(d,s).flatMap(f=>f.publication?[f.publication]:[]):[]),l=s===i.length;a.push(Object.freeze({stepIndex:a.length,firstNodeIndex:d,nextNodeIndex:s,...c,exceedsBudget:Zn(c,e),latencyPriority:o,publications:m,publishable:l||m.length>0}))}let u=i.reduce((d,c)=>Kn(d,c),Xn());return Object.freeze({...u,annotatedNodeCount:r.annotatedNodeCount,stepCount:a.length,oversizedStepCount:a.filter(d=>d.exceedsBudget).length,latencyPriority:o,publicationPolicy:n,publicationCount:a.reduce((d,c)=>d+c.publications.length,0),steps:Object.freeze(a)})}function Xn(){return{nodeCount:0,commandCount:0,maximumInvocationCount:0,readByteLength:0,writeByteLength:0,conditionalNodeCount:0}}function Kn(r,e){return{nodeCount:r.nodeCount+1,commandCount:r.commandCount+e.commandCount,maximumInvocationCount:r.maximumInvocationCount+e.maximumInvocationCount,readByteLength:r.readByteLength+e.readByteLength,writeByteLength:r.writeByteLength+e.writeByteLength,conditionalNodeCount:r.conditionalNodeCount+(e.condition?1:0)}}function Zn(r,e){return r.maximumInvocationCount>e.maximumInvocationCount||e.maximumNodeCount!==void 0&&r.nodeCount>e.maximumNodeCount||e.maximumCommandCount!==void 0&&r.commandCount>e.maximumCommandCount||e.maximumReadByteLength!==void 0&&r.readByteLength>e.maximumReadByteLength||e.maximumWriteByteLength!==void 0&&r.writeByteLength>e.maximumWriteByteLength}function _a(r,e){return r.maximumInvocationCount>=e.maximumInvocationCount||e.maximumNodeCount!==void 0&&r.nodeCount>=e.maximumNodeCount||e.maximumCommandCount!==void 0&&r.commandCount>=e.maximumCommandCount||e.maximumReadByteLength!==void 0&&r.readByteLength>=e.maximumReadByteLength||e.maximumWriteByteLength!==void 0&&r.writeByteLength>=e.maximumWriteByteLength}function ei(r){let e=[["maximumInvocationCount",r.maximumInvocationCount],["maximumNodeCount",r.maximumNodeCount],["maximumCommandCount",r.maximumCommandCount],["maximumReadByteLength",r.maximumReadByteLength],["maximumWriteByteLength",r.maximumWriteByteLength]];for(let[t,o]of e)if(o!==void 0&&(!Number.isSafeInteger(o)||o<=0))throw new Error(`GPUCommandGraph execution ${t} must be a positive safe integer`)}function Ra(r,e,t,o){let n=0;return{computePass:new Proxy(r,{get(a,s){if(s==="dispatch")return()=>{if(n>0)throw new Error(`GPUCommandGraph GPU-conditional compute node "${o}" must encode exactly one dispatch`);n++,a.dispatchIndirect(e,t)};if(s==="dispatchIndirect")return()=>{throw new Error(`GPUCommandGraph GPU-conditional compute node "${o}" must use dispatch(); the graph supplies its indirect command`)};let u=Reflect.get(a,s,a);return typeof u=="function"?u.bind(a):u}}),assertDispatched:()=>{if(n!==1)throw new Error(`GPUCommandGraph GPU-conditional compute node "${o}" must encode exactly one dispatch`)}}}var Ct=class{readResource;stats;canReadGPUTimings;nodes;constructor(e,t,o=e.filter(s=>s.stats.type==="compute"&&s.stats.condition?.outcome!=="skipped").length,n,i,a){this.readResource=a,this.nodes=e,this.canReadGPUTimings=e.some(d=>d.timestamp!==void 0);let s=e.filter(d=>d.stats.condition?.outcome!=="skipped"),u=s.filter(d=>d.stats.type==="compute").length;this.stats={cpuEncodeTimeMilliseconds:t,cpuEncodeStartTimeMilliseconds:n,cpuEncodeEndTimeMilliseconds:i,nodeCount:s.length,skippedNodeCount:e.length-s.length,computePassCount:o,coalescedComputeNodeCount:u-o,timestampedNodeCount:e.filter(d=>d.timestamp!==void 0).length,nodes:e.map(d=>d.stats)}}async readTimings(){let e=await Promise.all(this.nodes.map(async({stats:a,timestamp:s})=>{if(!s)return{...a};let{querySet:u,snapshot:d,beginIndex:c,endIndex:m}=s;if(u.device.type!=="webgpu")return{...a,gpuTimeMilliseconds:await u.readTimestampDuration(c,m)};let l=await(d??u).readResults({firstQuery:c,queryCount:m-c+1}),f=l[0],h=l[l.length-1];return{...a,gpuStartTimeMilliseconds:Number(f)/1e6,gpuEndTimeMilliseconds:Number(h)/1e6,gpuTimeMilliseconds:Number(h-f)/1e6}})),t=e.filter(a=>a.gpuTimeMilliseconds!==void 0),o=e.filter(a=>a.gpuStartTimeMilliseconds!==void 0),i=this.nodes.flatMap(a=>a.timestamp?.snapshot?.clockCorrelation?[a.timestamp.snapshot.clockCorrelation]:[]).sort((a,s)=>a.uncertaintyMilliseconds-s.uncertaintyMilliseconds)[0];return{...i?{clockCorrelation:i}:{},cpuEncodeStartTimeMilliseconds:this.stats.cpuEncodeStartTimeMilliseconds,cpuEncodeEndTimeMilliseconds:this.stats.cpuEncodeEndTimeMilliseconds,...o.length>0?{gpuStartTimeMilliseconds:Math.min(...o.map(a=>a.gpuStartTimeMilliseconds)),gpuEndTimeMilliseconds:Math.max(...o.map(a=>a.gpuEndTimeMilliseconds))}:{},cpuEncodeTimeMilliseconds:this.stats.cpuEncodeTimeMilliseconds,...t.length>0?{gpuTimeMilliseconds:t.reduce((a,s)=>a+(s.gpuTimeMilliseconds??0),0)}:{},nodes:e}}},He=class{device;id;autotuner;buffers=new Map;textures=new Map;externalTextures=new Map;importedBufferHandles=new Map;dynamicBufferHandles=new Map;nodes=[];nodeIds=new Set;compiled=!1;constructor(e,t={}){if(e.type!=="webgpu")throw new Error("GPUCommandGraph requires a WebGPU device");Qt(e,"construction"),this.device=e,this.id=t.id??"gpu-command-graph",this.autotuner=t.autotuner}importBuffer(e,t){this.assertMutable(),Jn(e,this.device),t&&ti(t,e,this.device);let o=this.addBuffer(new Ce(this,e,!1,t));if(t){let n=Tt(t);this.importedBufferHandles.has(n)||this.importedBufferHandles.set(n,o),t instanceof Ge&&!this.dynamicBufferHandles.has(t)&&this.dynamicBufferHandles.set(t,o)}return o}createTransientBuffer(e){return this.assertMutable(),Jn(e,this.device),this.addBuffer(new Ce(this,e,!0))}createDataView(e,t){this.assertBuffer(e);let o=N(t.format),n=t.byteOffset??0,i=t.rowByteLength??o.byteLength,a=t.byteStride??i;return za(e,{length:t.length,byteOffset:n,byteStride:a,rowByteLength:i}),new de(e,{format:t.format,length:t.length,byteOffset:n,byteStride:a,rowByteLength:i})}importGPUData(e,t){return this.importGPUDataView(e,t)}importGPUVector(e,t){if(t.bufferLayout)throw new Error(`GPUCommandGraph import "${e}" does not accept interleaved GPUVector data`);let o=t.format??t.data[0]?.format;if(!o)throw new Error(`GPUCommandGraph import "${e}" requires GPUVector.format`);if(we(o)||Te(o))throw new Error(`GPUCommandGraph import "${e}" requires a fixed-width GPUVector format`);let n=N(o),i=t.data.map((a,s)=>{if(a.format!==o)throw new Error(`GPUCommandGraph import "${e}" requires matching GPUVector chunk formats`);let u=t.data.length===1?e:`${e}-chunk-${s}`;return this.importGPUDataView(u,a)});return new B({id:e,name:t.name??e,format:o,length:t.length,valueLength:t.valueLength??t.data.reduce((a,s)=>a+s.valueLength,0),stride:t.stride??t.data[0]?.stride??n.components*(n.listSize??1),byteStride:t.byteStride??i[0]?.byteStride??n.byteLength,rowByteLength:t.rowByteLength??i[0]?.rowByteLength??n.byteLength,data:i})}importTexture(e,t){this.assertMutable();let o=fo(e,this.device);return t&&ho(t,o,this.device),this.addTexture(new ne(this,o,!1,t))}importFrameTexture(e){this.assertMutable();let t=fo(e,this.device);return this.addTexture(new ne(this,t,!1,void 0,!0))}importExternalTexture(e){return this.assertMutable(),Fa(e,this.device),this.addExternalTexture(new $e(this,e))}createTransientTexture(e){this.assertMutable();let t=fo(e,this.device);return this.addTexture(new ne(this,t,!0))}createTextureView(e,t={}){this.assertTexture(e);let o=Na(e,t);return new Pe(e,o)}add(e){if(this.assertMutable(),"getNodes"in e)for(let t of e.getNodes())this.add(t);else if("getCommandNodes"in e)_e(this,e.getCommandNodes(this));else if("type"in e)lo(this,e);else for(let t of e)this.add(t)}addComputePass(e){this.addNode({...e,type:"compute"})}addRenderPass(e){e.attachments&&this.validateRenderAttachments(e.id,e.attachments);let t=e.attachments?[...e.attachments.colorAttachments.map(o=>({texture:o,usage:"render-attachment"})),...(e.attachments.resolveTargets??[]).filter(o=>o!==null).map(o=>({texture:o,usage:"render-attachment"})),...e.attachments.depthStencilAttachment?[{texture:e.attachments.depthStencilAttachment,usage:"render-attachment"}]:[]]:[];this.addNode({...e,resources:[...e.resources??[],...t],type:"render"})}addCopyPass(e){this.addNode({...e,type:"copy"})}compile(){return this.assertMutable(),Qt(this.device,"compilation"),this.compiled=!0,new qe(Nn({device:this.device,id:this.id,buffers:this.buffers,textures:this.textures,externalTextures:this.externalTextures,nodes:this.nodes}))}async compileAsync(){return this.assertMutable(),Qt(this.device,"compilation"),this.compiled=!0,new qe(await zn({device:this.device,id:this.id,buffers:this.buffers,textures:this.textures,externalTextures:this.externalTextures,nodes:this.nodes}))}addNode(e){if(this.assertMutable(),!e.id)throw new Error("GPUCommandGraph node id is required");if(this.nodeIds.has(e.id))throw new Error(`GPUCommandGraph node id "${e.id}" is already in use`);for(let[t,o]of Object.entries(e.workload??{}))if(t==="operation"||t==="variant"){if(typeof o!="string"||!o)throw new Error(`GPUCommandGraph node "${e.id}" workload ${t} must be nonempty`)}else if(typeof o!="number"||!Number.isSafeInteger(o)||o<0)throw new Error(`GPUCommandGraph node "${e.id}" workload ${t} must be a nonnegative safe integer`);if(e.condition){if(!e.condition.id)throw new Error(`GPUCommandGraph node "${e.id}" condition id is required`);if(e.condition.source==="cpu"){if(typeof e.condition.evaluate!="function")throw new Error(`GPUCommandGraph node "${e.id}" CPU condition requires an evaluate function`)}else{let t=e.condition;if(e.type!=="compute"||t.mode!=="indirect")throw new Error(`GPUCommandGraph node "${e.id}" GPU conditions require an indirect compute node`);if(!t.buffer)throw new Error(`GPUCommandGraph node "${e.id}" GPU condition requires an indirect command buffer`);this.assertBuffer(t.buffer);let o=t.byteOffset??0;if(!Number.isSafeInteger(o)||o<0||o%4!==0)throw new Error(`GPUCommandGraph node "${e.id}" GPU condition byteOffset must be a nonnegative multiple of 4`);if(o+3*$a>t.buffer.byteLength)throw new Error(`GPUCommandGraph node "${e.id}" GPU condition indirect command exceeds buffer "${t.buffer.id}"`);(e.resources??[]).some(n=>ve(n)&&Q(n.buffer)===t.buffer&&n.usage==="indirect")||(e={...e,resources:[...e.resources??[],{buffer:t.buffer,usage:"indirect"}]})}}if(e.publication){if(e.condition)throw new Error(`GPUCommandGraph node "${e.id}" cannot combine conditional execution with a publication boundary`);if(!e.publication.id)throw new Error(`GPUCommandGraph node "${e.id}" publication id is required`);if(!["partial","complete"].includes(e.publication.completeness))throw new Error(`GPUCommandGraph node "${e.id}" publication completeness is invalid`)}for(let t of e.resources??[])if(ve(t)){let o=Q(t.buffer);this.assertBuffer(o),Wa(o,t.usage)}else if(xt(t)){let o=ue(t.texture);this.assertTexture(o),ja(o,t.usage),Ha(t.texture,t.usage)}else{if(this.assertExternalTexture(t.externalTexture),t.usage!=="sampled")throw new Error("GPUCommandGraph external textures support sampled access only");if(e.type!=="render")throw new Error("GPUCommandGraph external textures can be sampled only by render nodes")}Wn(e),this.nodeIds.add(e.id),this.nodes.push(e)}addBuffer(e){if(this.buffers.has(e.id)||this.textures.has(e.id)||this.externalTextures.has(e.id))throw new Error(`GPUCommandGraph resource id "${e.id}" is already in use`);return this.buffers.set(e.id,e),e}addTexture(e){if(this.buffers.has(e.id)||this.textures.has(e.id)||this.externalTextures.has(e.id))throw new Error(`GPUCommandGraph resource id "${e.id}" is already in use`);return this.textures.set(e.id,e),e}addExternalTexture(e){if(this.buffers.has(e.id)||this.textures.has(e.id)||this.externalTextures.has(e.id))throw new Error(`GPUCommandGraph resource id "${e.id}" is already in use`);return this.externalTextures.set(e.id,e),e}importGPUDataView(e,t){if(!t.format)throw new Error(`GPUCommandGraph import "${e}" requires GPUData.format`);let o=Tt(t.buffer),n={byteLength:Ma(t),usage:o.usage},i=t.buffer instanceof Ge?this.getDynamicBufferHandle(t.buffer,n):this.getImportedBufferHandle(o,n);return i||(i=this.importBuffer({id:e,byteLength:o.byteLength,usage:o.usage},t.buffer),t.buffer instanceof Ge?this.dynamicBufferHandles.set(t.buffer,i):this.importedBufferHandles.set(o,i)),this.createDataView(i,{format:t.format,length:t.length,byteOffset:t.byteOffset,byteStride:t.byteStride,rowByteLength:t.rowByteLength})}getDynamicBufferHandle(e,t){let o=this.dynamicBufferHandles.get(e);if(o?.defaultBuffer===e&&bt(o,t))return o;this.dynamicBufferHandles.delete(e);for(let n of this.buffers.values())if(n.defaultBuffer===e&&bt(n,t))return this.dynamicBufferHandles.set(e,n),n}getImportedBufferHandle(e,t){let o=this.importedBufferHandles.get(e);if(o?.defaultBuffer&&Tt(o.defaultBuffer)===e&&bt(o,t))return o;this.importedBufferHandles.delete(e);for(let[n,i]of this.dynamicBufferHandles)if(n.buffer===e&&bt(i,t))return this.importedBufferHandles.set(e,i),i;for(let n of this.buffers.values())if(n.defaultBuffer===e&&bt(n,t))return this.importedBufferHandles.set(e,n),n}assertBuffer(e){if(e.graph!==this||this.buffers.get(e.id)!==e)throw new Error(`Graph buffer "${e.id}" does not belong to ${this.id}`)}assertTexture(e){if(e.graph!==this||this.textures.get(e.id)!==e)throw new Error(`Graph texture "${e.id}" does not belong to ${this.id}`)}assertExternalTexture(e){if(e.graph!==this||this.externalTextures.get(e.id)!==e)throw new Error(`Graph external texture "${e.id}" does not belong to ${this.id}`)}assertMutable(){if(this.compiled)throw new Error(`GPUCommandGraph "${this.id}" has already been compiled`)}validateRenderAttachments(e,t){if(t.colorAttachments.length===0&&!t.depthStencilAttachment)throw new Error(`GPUCommandGraph render node "${e}" requires at least one attachment`);let o=[...t.colorAttachments,...t.depthStencilAttachment?[t.depthStencilAttachment]:[]];for(let a of o)if(this.assertTexture(a.texture),a.dimension!=="2d"||a.mipLevelCount!==1||a.arrayLayerCount!==1)throw new Error(`GPUCommandGraph render node "${e}" attachments must be single-mip, single-layer 2d views`);let[n,...i]=o;for(let a of i)if(a.width!==n.width||a.height!==n.height||a.texture.samples!==n.texture.samples)throw new Error(`GPUCommandGraph render node "${e}" attachments must have matching extent and samples`);this.validateResolveTargets(e,t)}validateResolveTargets(e,t){let o=t.resolveTargets;if(o){if(this.device.type!=="webgpu")throw new Error(`GPUCommandGraph render node "${e}" resolve targets require WebGPU`);if(o.length!==t.colorAttachments.length)throw new Error(`GPUCommandGraph render node "${e}" requires one resolve entry per color attachment`);for(let n=0;n<o.length;n++){let i=o[n];if(!i)continue;let a=t.colorAttachments[n];if(this.assertTexture(i.texture),a.texture.samples<=1||i.texture.samples!==1||a.format!==i.format||a.width!==i.width||a.height!==i.height)throw new Error(`GPUCommandGraph render node "${e}" resolve target ${n} must match a multisampled source and be single-sampled`);if(i.dimension!=="2d"||i.aspect!=="all"||i.mipLevelCount!==1||i.arrayLayerCount!==1)throw new Error(`GPUCommandGraph render node "${e}" resolve targets must be single-mip, single-layer 2d color views`)}}}},qe=class{device;id;stats;preflight;capabilities;buffers;textures;externalTextures;compiledNodes;activeImportedBufferHandles=new Set;writableImportedBufferHandles=new Set;activeImportedTextureHandles=new Set;writableImportedTextureHandles=new Set;transientBuffers;transientTextures;bufferTransientAllocations;textureTransientAllocations;cachedTextureViews=[];cachedFramebuffers=[];lastFrameIds=new Map;lastExternalTextureFrameIds=new Map;consumedExternalTextures=new WeakSet;destroyed=!1;get[Symbol.toStringTag](){return"CompiledGPUCommandGraph"}toString(){let e=this.destroyed?"destroyed":"active";return`${this[Symbol.toStringTag]}:"${this.id}":${this.stats.nodeOrder.length} nodes:${this.stats.physicalTransientResourceBytes}B transient:${e}`}toJSON(){return this.toString()}constructor(e){this.device=e.device,this.id=e.id,this.buffers=e.buffers,this.textures=e.textures,this.externalTextures=e.externalTextures,this.compiledNodes=e.compiledNodes;for(let{node:t}of this.compiledNodes)for(let o of t.resources??[])if(ve(o)){let n=Q(o.buffer);n.transient||(this.activeImportedBufferHandles.add(n),(o.usage==="storage-write"||o.usage==="storage-read-write"||o.usage==="copy-destination")&&this.writableImportedBufferHandles.add(n))}else if(xt(o)){let n=ue(o.texture);n.transient||(this.activeImportedTextureHandles.add(n),(o.usage==="storage-write"||o.usage==="storage-read-write"||o.usage==="render-attachment"||o.usage==="copy-destination")&&this.writableImportedTextureHandles.add(n))}this.transientBuffers=e.transientBuffers,this.transientTextures=e.transientTextures,this.bufferTransientAllocations=e.bufferTransientAllocations,this.textureTransientAllocations=e.textureTransientAllocations,this.stats=e.stats,this.preflight=e.preflight,this.capabilities=Oa(this.device)}encode(e,t){return this.encodeNodeRange(e,t,0,this.compiledNodes.length)}getExecutionPlan(e,t={}){return go(this.preflight,e,t)}createExecution(e,t={}){return new vt({plan:this.getExecutionPlan(e,t),budget:e,encodeNodeRange:(o,n,i,a)=>this.encodeNodeRange(o,n,i,a)})}encodeNodeRange(e,t,o,n){if(this.destroyed)throw new Error(`CompiledGPUCommandGraph "${this.id}" has been destroyed`);if(Qt(this.device,"encoding"),e.device!==this.device)throw new Error("GPUCommandGraph command encoder must belong to the graph device");let i=wt(),a=this.resolveImportedBuffers(t.buffers??{});ka(t.frameTextures??{},t.externalTextures??{});let s=this.resolveImportedTextures(t.textures??{},t.frameTextures??{}),u=this.resolveExternalTextures(t.externalTextures??{});for(let[g,p]of s.frameIds)this.lastFrameIds.set(g,p);for(let[g,p]of u.frameIds)this.lastExternalTextureFrameIds.set(g,p);for(let g of u.textures.values())this.consumedExternalTextures.add(g);let d=s.textures,c=g=>{let p=Q(g),T=p.transient?this.transientBuffers.get(p):a.get(p);if(!T)throw new Error(`GPUCommandGraph buffer "${p.id}" is not bound`);return T},m=g=>{let p=ue(g),T=p.transient?this.transientTextures.get(p):d.get(p);if(!T)throw new Error(`GPUCommandGraph texture "${p.id}" is not bound`);return T},l=g=>{let p=m(g);if(g instanceof ne||Xa(g))return p.view;if(g.texture.frameScoped){let x=this.lastFrameIds.get(g.texture);for(let O=this.cachedTextureViews.length-1;O>=0;O--){let S=this.cachedTextureViews[O];S.logicalView===g&&S.frameId!==x&&(this.destroyFramebuffersUsingView(S.view),S.view.destroy(),this.cachedTextureViews.splice(O,1))}}let T=this.cachedTextureViews.find(x=>x.logicalView===g&&x.texture===p&&(!g.texture.frameScoped||x.frameId===this.lastFrameIds.get(g.texture)));if(T)return T.view;let C=p.createView({format:g.format,dimension:g.dimension,aspect:g.aspect,baseMipLevel:g.baseMipLevel,mipLevelCount:g.mipLevelCount,baseArrayLayer:g.baseArrayLayer,arrayLayerCount:g.arrayLayerCount});return this.cachedTextureViews.push({logicalView:g,texture:p,view:C,...g.texture.frameScoped?{frameId:this.lastFrameIds.get(g.texture)}:{}}),C},f=g=>{let p=u.textures.get(g);if(!p)throw new Error(`GPUCommandGraph external texture "${g.id}" is not bound`);return p},h={commandEncoder:e,parameters:t.parameters,getBuffer:c,getTexture:m,getTextureView:l,getExternalTexture:f},y=[],w,I=0,L=t.coalesceComputePasses!==!1&&e.getTimeProfilingQuerySet()===null,P=()=>{let g=w;w=void 0,g?.end()};try{for(let g=o;g<n;g++){let{node:p,executable:T}=this.compiledNodes[g],C=wt();if(p.condition?.source==="cpu"){let S=!1;try{S=p.condition.evaluate(t.parameters)}catch(G){let $=G instanceof Error?G.message:String(G);throw new Error(`GPUCommandGraph CPU condition "${p.condition.id}" failed for node "${p.id}": ${$}`)}if(!S){let G=wt();y.push({stats:{id:p.id,description:p.description,resources:this.preflight.nodes[g].resources,operation:p.workload?.operation,type:p.type,cpuEncodeStartTimeMilliseconds:C,cpuEncodeEndTimeMilliseconds:G,cpuEncodeTimeMilliseconds:G-C,hasGPUTimestamps:!1,condition:{id:p.condition.id,source:"cpu",outcome:"skipped"}}});continue}}let x;switch(p.type){case"compute":{w||(w=e.beginComputePass({id:p.id}),I++);let S=w;x=Qn(S,e),x&&(L=!1),S.pushDebugGroup(p.id);try{let G=p.condition?.source==="gpu"?p.condition:void 0,$=G?Ra(S,c(G.buffer),G.byteOffset??0,p.id):void 0;T.encode({...h,computePass:$?.computePass??S}),$?.assertDispatched()}finally{S.popDebugGroup()}L||P();break}case"render":{P();let S=T,G=S.getRenderPassProps?.(h)??{id:p.id};if(p.attachments&&G.framebuffer!==void 0)throw new Error(`GPUCommandGraph render node "${p.id}" cannot supply framebuffer with graph attachments`);if(p.attachments?.resolveTargets&&G.resolveTargets!==void 0)throw new Error(`GPUCommandGraph render node "${p.id}" cannot supply resolveTargets with graph attachments`);let $=p.attachments?this.getFramebuffer(p.id,p.attachments,l):void 0,X=p.attachments?.resolveTargets?.map(pe=>pe?l(pe):null),ie=e.beginRenderPass({...G,...$?{framebuffer:$}:{},...X?{resolveTargets:X}:{}});x=Qn(ie,e),ie.pushDebugGroup(p.id);try{S.encode({...h,renderPass:ie})}finally{ie.popDebugGroup(),ie.end()}break}case"copy":P(),T.encode(h);break}let O=wt();y.push({stats:{id:p.id,description:p.description,resources:this.preflight.nodes[g].resources,operation:p.workload?.operation,type:p.type,cpuEncodeStartTimeMilliseconds:C,cpuEncodeEndTimeMilliseconds:O,cpuEncodeTimeMilliseconds:O-C,hasGPUTimestamps:x!==void 0,...p.condition?{condition:{id:p.condition.id,source:p.condition.source,outcome:p.condition.source==="gpu"?"gpu-resolved":"executed"}}:{}},timestamp:x})}}finally{P()}let W=wt();return new Ct(y,W-i,I,i,W,async(g,p)=>{if(this.destroyed)throw new Error("Graph has been destroyed.");let T=this.compiledNodes.findIndex(({node:$})=>$.id===g),C=this.compiledNodes[T]?.node.resources?.[p],x=this.preflight.nodes[T]?.resources?.[p];if(!C||!x)throw new Error("Resource is unavailable.");if("externalTexture"in C)throw new Error("External images cannot be read back.");let O="buffer"in C?Q(C.buffer):ue(C.texture);if("frameScoped"in O&&O.frameScoped)throw new Error("Frame textures expire after presentation.");let S="buffer"in C?c(C.buffer):m(C.texture),G=S instanceof z.Buffer?this.transientBuffers:this.transientTextures;if(O.transient&&[...G].some(([$,X])=>$!==O&&X===S))throw new Error("Transient allocation is reused; logical contents are no longer available.");return ko(S,x)})}destroy(){if(!this.destroyed){for(let{executable:e}of this.compiledNodes)e.destroy?.();for(let e of this.cachedFramebuffers)e.framebuffer.destroy();for(let e of this.cachedTextureViews)e.view.destroy();for(let e of this.bufferTransientAllocations)e.buffer?.destroy();for(let e of this.textureTransientAllocations)e.texture?.destroy();this.destroyed=!0}}resolveImportedBuffers(e){let t=new Map,o=new Map;for(let[n,i]of this.buffers){if(i.transient)continue;let a=e[n]??i.defaultBuffer;if(!a)throw new Error(`GPUCommandGraph imported buffer "${n}" is required`);ti(a,i,this.device);let s=Tt(a);if(this.activeImportedBufferHandles.has(i)){let u=s.handle,d=typeof u=="object"&&u!==null||typeof u=="function"?u:s,c=o.get(d);if(c&&(this.writableImportedBufferHandles.has(c)||this.writableImportedBufferHandles.has(i)))throw new Error(`GPUCommandGraph imported buffers "${c.id}" and "${n}" resolve to the same physical buffer`);c||o.set(d,i)}t.set(i,s)}for(let n of Object.keys(e)){let i=this.buffers.get(n);if(!i||i.transient)throw new Error(`GPUCommandGraph has no imported buffer named "${n}"`)}return t}resolveImportedTextures(e,t){let o=new Map,n=new Map;for(let[a,s]of this.textures){if(s.transient)continue;if(s.frameScoped){let d=t[a];if(!d)throw new Error(`GPUCommandGraph frame texture "${a}" is required`);let c=this.lastFrameIds.get(s);if(c!==void 0&&d.frameId<=c)throw new Error(`GPUCommandGraph frame texture "${a}" frameId ${d.frameId} is stale; expected greater than ${c}`);ho(d.texture,s,this.device),o.set(s,po(d.texture)),n.set(s,d.frameId);continue}let u=e[a]??s.defaultTexture;if(!u)throw new Error(`GPUCommandGraph imported texture "${a}" is required`);ho(u,s,this.device),o.set(s,po(u))}for(let a of Object.keys(e)){let s=this.textures.get(a);if(!s||s.transient||s.frameScoped)throw new Error(`GPUCommandGraph has no imported texture named "${a}"`)}for(let a of Object.keys(t))if(!this.textures.get(a)?.frameScoped)throw new Error(`GPUCommandGraph has no frame texture named "${a}"`);let i=new Map;for(let[a,s]of o){if(!this.activeImportedTextureHandles.has(a))continue;let u=s.handle,d=typeof u=="object"&&u!==null||typeof u=="function"?u:s,c=i.get(d);if(c&&(this.writableImportedTextureHandles.has(c)||this.writableImportedTextureHandles.has(a)))throw new Error(`GPUCommandGraph imported textures "${c.id}" and "${a.id}" resolve to the same physical texture`);c||i.set(d,a)}return{textures:o,frameIds:n}}resolveExternalTextures(e){let t=new Map,o=new Map;for(let[n,i]of this.externalTextures){let a=e[n];if(!a)throw new Error(`GPUCommandGraph external texture "${n}" is required`);let s=this.lastExternalTextureFrameIds.get(i);if(s!==void 0&&a.frameId<=s)throw new Error(`GPUCommandGraph external texture "${n}" frameId ${a.frameId} is stale; expected greater than ${s}`);if(this.consumedExternalTextures.has(a.texture))throw new Error(`GPUCommandGraph external texture "${n}" requires a fresh binding for each frame`);Va(a.texture,i,this.device),t.set(i,a.texture),o.set(i,a.frameId)}for(let n of Object.keys(e))if(!this.externalTextures.has(n))throw new Error(`GPUCommandGraph has no external texture named "${n}"`);return{textures:t,frameIds:o}}getFramebuffer(e,t,o){let n=t.colorAttachments.map(o),i=t.depthStencilAttachment?o(t.depthStencilAttachment):void 0,a=this.cachedFramebuffers.find(d=>d.nodeId===e&&d.depthStencilAttachment===i&&d.colorAttachments.length===n.length&&d.colorAttachments.every((c,m)=>c===n[m]));if(a)return a.framebuffer;let s=t.colorAttachments[0]??t.depthStencilAttachment,u=this.device.createFramebuffer({id:`${this.id}-${e}-framebuffer-${this.cachedFramebuffers.length}`,width:s.width,height:s.height,colorAttachments:n,depthStencilAttachment:i??null});return this.cachedFramebuffers.push({nodeId:e,colorAttachments:n,depthStencilAttachment:i,framebuffer:u}),u}destroyFramebuffersUsingView(e){for(let t=this.cachedFramebuffers.length-1;t>=0;t--){let o=this.cachedFramebuffers[t];(o.depthStencilAttachment===e||o.colorAttachments.some(n=>n===e))&&(o.framebuffer.destroy(),this.cachedFramebuffers.splice(t,1))}}};function Tt(r){return r instanceof Ge?r.buffer:r}function Ma(r){let e=r.length===0?0:(r.length-1)*r.byteStride+r.rowByteLength;return r.byteOffset+e}function bt(r,e){return r.byteLength>=e.byteLength&&(r.usage&e.usage)===e.usage}function po(r){if(r instanceof Zt){if(!r.isReady)throw new Error(`GPUCommandGraph dynamic texture "${r.id}" is not ready`);return r.texture}return r}function ka(r,e){let t;for(let[o,n]of[...Object.entries(r),...Object.entries(e)]){if(!Number.isSafeInteger(n.frameId)||n.frameId<0)throw new Error(`GPUCommandGraph frame resource "${o}" requires a valid frameId`);if(t!==void 0&&n.frameId!==t)throw new Error("GPUCommandGraph frame resources must share one frameId per encoding");t=n.frameId}}function Qn(r,e){let{timestampQuerySet:t,beginTimestampIndex:o,endTimestampIndex:n}=r.props;return t&&Number.isSafeInteger(o)&&Number.isSafeInteger(n)&&o>=0&&n>o?{querySet:t,snapshot:t.device.type==="webgpu"?e.captureTimestampQuerySet?.(t):void 0,beginIndex:o,endIndex:n}:void 0}function Oa(r){return Object.freeze({timestampQueries:r.features.has("timestamp-query"),subgroups:r.features.has("subgroups"),subgroupId:r.wgslLanguageFeatures.has("subgroup_id"),subgroupMinSize:r.info.subgroupMinSize,subgroupMaxSize:r.info.subgroupMaxSize,softwareAdapter:r.info.gpu==="software"||r.info.gpuType==="cpu"||!!r.info.fallback,maxBufferByteLength:r.limits.maxBufferSize,maxStorageBufferBindingByteLength:r.limits.maxStorageBufferBindingSize,maxComputeInvocationsPerWorkgroup:r.limits.maxComputeInvocationsPerWorkgroup,maxComputeWorkgroupsPerDimension:r.limits.maxComputeWorkgroupsPerDimension})}function Qt(r,e){if(r.isLost)throw new Error(`GPUCommandGraph cannot perform ${e} after device loss`)}function wt(){return globalThis.performance?.now()??Date.now()}function Jn(r,e){if(!r.id)throw new Error("GPUCommandGraph buffer id is required");if(!Number.isSafeInteger(r.byteLength)||r.byteLength<0)throw new Error(`GPUCommandGraph buffer "${r.id}" requires a valid byteLength`);if(r.byteLength>e.limits.maxBufferSize)throw new Error(`GPUCommandGraph buffer "${r.id}" exceeds the device buffer limit`);if(!Number.isSafeInteger(r.usage)||r.usage<=0)throw new Error(`GPUCommandGraph buffer "${r.id}" requires buffer usage flags`)}function Fa(r,e){if(!r.id)throw new Error("GPUCommandGraph external texture id is required");for(let[t,o]of Object.entries({width:r.width,height:r.height}))if(!Number.isSafeInteger(o)||o<=0)throw new Error(`GPUCommandGraph external texture "${r.id}" ${t} must be a positive safe integer`);if(r.width>e.limits.maxTextureDimension2D||r.height>e.limits.maxTextureDimension2D)throw new Error(`GPUCommandGraph external texture "${r.id}" exceeds device dimension limits`)}function fo(r,e){if(!r.id)throw new Error("GPUCommandGraph texture id is required");let t=r.dimension??"2d",o=t==="cube"?6:r.depth??1,n=r.mipLevels??1,i=r.samples??1;for(let[d,c]of Object.entries({width:r.width,height:r.height,depth:o,mipLevels:n,samples:i}))if(!Number.isSafeInteger(c)||c<=0)throw new Error(`GPUCommandGraph texture "${r.id}" ${d} must be a positive safe integer`);if(!Number.isSafeInteger(r.usage)||r.usage<=0)throw new Error(`GPUCommandGraph texture "${r.id}" requires texture usage flags`);if(!e.isTextureFormatSupported(r.format))throw new Error(`GPUCommandGraph texture "${r.id}" format ${r.format} is unsupported`);if(t==="1d"&&(r.height!==1||o!==1))throw new Error(`GPUCommandGraph 1d texture "${r.id}" requires height and depth 1`);if(t==="cube"&&r.width!==r.height)throw new Error(`GPUCommandGraph cube texture "${r.id}" must be square`);if(t==="cube-array"&&(r.width!==r.height||o%6!==0))throw new Error(`GPUCommandGraph cube-array texture "${r.id}" must be square with depth divisible by 6`);if(n>e.getMipLevelCount(r.width,r.height,t==="3d"?o:1))throw new Error(`GPUCommandGraph texture "${r.id}" declares too many mip levels`);let a=t==="1d"?e.limits.maxTextureDimension1D:t==="3d"?e.limits.maxTextureDimension3D:e.limits.maxTextureDimension2D,s=t==="3d"?e.limits.maxTextureDimension3D:e.limits.maxTextureDimension2D,u=t==="3d"?e.limits.maxTextureDimension3D:e.limits.maxTextureArrayLayers;if(r.width>a||r.height>s||o>u)throw new Error(`GPUCommandGraph texture "${r.id}" exceeds device dimension limits`);return{id:r.id,format:r.format,width:r.width,height:r.height,usage:r.usage,dimension:t,depth:o,mipLevels:n,samples:i}}function Na(r,e){let t=e.dimension??r.dimension,o=e.aspect??"all",n=e.baseMipLevel??0,i=e.mipLevelCount??r.mipLevels-n,a=e.baseArrayLayer??0,s=r.dimension==="3d"?1:r.depth,u=e.arrayLayerCount??s-a;for(let[l,f]of Object.entries({baseMipLevel:n,mipLevelCount:i,baseArrayLayer:a,arrayLayerCount:u}))if(!Number.isSafeInteger(f)||f<0)throw new Error(`Graph texture view ${l} must be a non-negative safe integer`);if(i===0||n+i>r.mipLevels)throw new Error(`Graph texture view exceeds texture "${r.id}" mip levels`);if(u===0||a+u>s||r.dimension==="3d"&&(a!==0||u!==1))throw new Error(`Graph texture view exceeds texture "${r.id}" array layers`);let d=Math.max(1,r.width>>n),c=r.dimension==="1d"?1:Math.max(1,r.height>>n),m=r.dimension==="3d"?Math.max(1,r.depth>>n):u;return{dimension:t,aspect:o,baseMipLevel:n,mipLevelCount:i,baseArrayLayer:a,arrayLayerCount:u,width:d,height:c,depth:m}}function za(r,e){for(let[n,i]of Object.entries(e))if(!Number.isSafeInteger(i)||i<0)throw new Error(`Graph data view ${n} must be a non-negative safe integer`);if(e.length>1&&e.byteStride===0)throw new Error("Graph data view byteStride must be positive for multiple rows");if(e.rowByteLength>e.byteStride&&e.length>1)throw new Error("Graph data view rowByteLength cannot exceed byteStride");let t=e.length===0?0:(e.length-1)*e.byteStride+e.rowByteLength,o=e.byteOffset+t;if(!Number.isSafeInteger(t)||!Number.isSafeInteger(o))throw new Error("Graph data view byte range exceeds safe integer precision");if(o>r.byteLength)throw new Error(`Graph data view exceeds buffer "${r.id}" byte length`)}function ti(r,e,t){let o=Tt(r);if(o.device!==t)throw new Error(`GPUCommandGraph buffer "${e.id}" belongs to another device`);if(o.byteLength<e.byteLength)throw new Error(`GPUCommandGraph buffer "${e.id}" is smaller than compiled capacity`);if((o.usage&e.usage)!==e.usage)throw new Error(`GPUCommandGraph buffer "${e.id}" has incompatible usage flags`)}function ho(r,e,t){let o=po(r);if(o.device!==t)throw new Error(`GPUCommandGraph texture "${e.id}" belongs to another device`);for(let[n,i,a]of[["format",e.format,o.format],["dimension",e.dimension,o.dimension],["width",e.width,o.width],["height",e.height,o.height],["depth",e.depth,o.depth],["mipLevels",e.mipLevels,o.mipLevels],["samples",e.samples,o.samples]])if(a!==i)throw new Error(`GPUCommandGraph texture "${e.id}" has incompatible ${n} (${a} !== ${i})`);if((o.props.usage&e.usage)!==e.usage)throw new Error(`GPUCommandGraph texture "${e.id}" has incompatible usage flags`)}function Va(r,e,t){if(r.device!==t)throw new Error(`GPUCommandGraph external texture "${e.id}" belongs to another device`);if(r.destroyed)throw new Error(`GPUCommandGraph external texture "${e.id}" has been destroyed`);if(r.width!==e.width||r.height!==e.height)throw new Error(`GPUCommandGraph external texture "${e.id}" has incompatible dimensions (${r.width}x${r.height} !== ${e.width}x${e.height})`)}function Wa(r,e){let t=qa(e);if((r.usage&t)!==t)throw new Error(`GPUCommandGraph buffer "${r.id}" does not declare usage required by ${e}`)}function ja(r,e){let t=Ya(e);if((r.usage&t)!==t)throw new Error(`GPUCommandGraph texture "${r.id}" does not declare usage required by ${e}`)}function Ha(r,e){if(r instanceof Pe&&e.startsWith("storage-")&&r.mipLevelCount!==1)throw new Error("GPUCommandGraph storage texture views must contain exactly one mip level")}function qa(r){switch(r){case"storage-read":case"storage-write":case"storage-read-write":return z.Buffer.STORAGE;case"uniform":return z.Buffer.UNIFORM;case"copy-source":return z.Buffer.COPY_SRC;case"copy-destination":return z.Buffer.COPY_DST;case"indirect":return z.Buffer.INDIRECT;case"vertex":return z.Buffer.VERTEX;case"index":return z.Buffer.INDEX}}function Ya(r){switch(r){case"sampled":return z.Texture.SAMPLE;case"storage-read":case"storage-write":case"storage-read-write":return z.Texture.STORAGE;case"render-attachment":return z.Texture.RENDER;case"copy-source":return z.Texture.COPY_SRC;case"copy-destination":return z.Texture.COPY_DST}}function Xa(r){let e=r.texture;return r.dimension===e.dimension&&r.aspect==="all"&&r.baseMipLevel===0&&r.mipLevelCount===e.mipLevels&&r.baseArrayLayer===0&&r.arrayLayerCount===(e.dimension==="3d"?1:e.depth)}var q=class{id;type="composite";operations;metadata;constructor(e){let t=Array.isArray(e)?{operations:e}:e;this.id=t.id??"gpu-composite-operation",this.operations=Object.freeze([...t.operations]),this.metadata=t.metadata}};function yo(r){let e=r;return typeof e.id=="string"&&typeof e.type=="string"}function xo(r){return r instanceof q?Object.freeze({id:r.id,type:r.type,...r.metadata?{metadata:r.metadata}:{},children:Object.freeze(r.operations.map(xo))}):yo(r)?Object.freeze({id:r.id,type:r.type,...r.metadata?{metadata:r.metadata}:{}}):Object.freeze({id:r.constructor?.name??"gpu-command-node-producer",type:"command-node-producer"})}function ri(r){return typeof r.getCommandNodes=="function"}var Ye=class{id;format;constructor(e,t){if(!e)throw new Error("GPUGraphScalar id is required");this.id=e,this.format=t}},Xe=class{id;format;length;external;chunkLengths;constructor(e){if(!e.id)throw new Error("GPUGraphVector id is required");if(!Number.isSafeInteger(e.length)||e.length<0)throw new Error(`${e.id} vector length must be a non-negative safe integer`);if(this.id=e.id,this.format=e.format,this.length=e.length,this.external=e.external??!1,e.chunkLengths){if(e.chunkLengths.some(t=>!Number.isSafeInteger(t)||t<0)||e.chunkLengths.reduce((t,o)=>t+o,0)!==e.length)throw new Error(`${e.id} chunk lengths must partition its logical length`);this.chunkLengths=Object.freeze([...e.chunkLengths])}}},Ke=class{id;format;width;height;usage;dimension;depth;mipLevels;samples;external;constructor(e){this.id=e.id,this.format=e.format,this.width=e.width,this.height=e.height,this.usage=e.usage,this.dimension=e.dimension,this.depth=e.depth,this.mipLevels=e.mipLevels,this.samples=e.samples,this.external=e.external??!1}},ce=class{texture;props;constructor(e,t={}){this.texture=e,this.props=Object.freeze({...t})}};var Jt=class{id;programOperations=[];programScalars=new Map;programVectors=new Map;programTextures=new Map;constructor(e={}){this.id=e.id??"gpu-program"}add(e){return this.assertOperationLike(e),this.addOperationLike(e),this}scalar(e,t){this.assertValueId(e);let o=new Ye(e,t);return this.programScalars.set(e,o),o}vector(e,t,o,n={}){this.assertValueId(e);let i=new Xe({id:e,format:t,length:o,...n});return this.programVectors.set(e,i),i}texture(e,t){this.assertValueId(e);let o=new Ke({...t,id:e});return this.programTextures.set(e,o),o}textureView(e,t={}){if(this.programTextures.get(e.id)!==e)throw new Error(`Undeclared program texture "${e.id}"`);return new ce(e,t)}get textures(){return Object.freeze([...this.programTextures.values()])}get scalars(){return Object.freeze([...this.programScalars.values()])}get vectors(){return Object.freeze([...this.programVectors.values()])}get operations(){return Object.freeze([...this.programOperations])}get operationTree(){return Object.freeze(this.programOperations.map(xo))}assertValueId(e){if(this.programScalars.has(e)||this.programVectors.has(e)||this.programTextures.has(e))throw new Error(`${this.id} value "${e}" already exists`)}addOperationLike(e){if(Array.isArray(e)){for(let t of e)this.addOperationLike(t);return}this.programOperations.push(e)}assertOperationLike(e){if(Array.isArray(e)){for(let t of e)this.assertOperationLike(t);return}if(!e||typeof e!="object")throw new Error(`${this.id} accepts GPU operations only`)}};function oi(r,e={}){return new q({id:e.id,operations:r})}var er=class extends He{computeLowerings=[];loweringsSuspended=0;otherLowerings=[];addRenderPass(e){let t={...e,type:"render"},o=this.otherLowerings.at(-1);o&&(t=o(t)),super.addRenderPass(t)}addCopyPass(e){let t={...e,type:"copy"},o=this.otherLowerings.at(-1);o&&(t=o(t)),super.addCopyPass(t)}withOtherLowering(e,t){this.otherLowerings.push(e);try{return t()}finally{this.otherLowerings.pop()}}constructor(e,t={}){super(e,t)}addComputePass(e){let t=e;if(this.loweringsSuspended===0)for(let o=this.computeLowerings.length-1;o>=0;o--)t=this.computeLowerings[o](t);super.addComputePass(t)}withComputeLowering(e,t){this.computeLowerings.push(e);try{return t()}finally{this.computeLowerings.pop()}}withoutComputeLowering(e){this.loweringsSuspended++;try{return e()}finally{this.loweringsSuspended--}}};var bo=ee(K(),1);Ae();var wo=Uint32Array.BYTES_PER_ELEMENT,To=256;function Re(r,e,t){let o=N(r.format);if(!e.includes(r.format)||r.byteStride!==o.byteLength||r.rowByteLength!==o.byteLength||r.byteOffset%wo!==0)throw new Error(`${t} must be packed, uint32-aligned ${e.join(" or ")} GPU data`)}function ni(r,e){Re(r,["uint32"],e)}function V(r,e){let t=Pt(r),o={buffer:e(r),...t};if(o.offset+o.size>r.buffer.byteLength)throw new Error("GraphDataView storage binding exceeds its logical buffer");return o}function Pt(r){let e=Math.floor(r.byteOffset/To)*To,t=r.byteOffset-e,o=r.length===0?r.rowByteLength:(r.length-1)*r.byteStride+r.rowByteLength;return{offset:e,size:t+Math.max(o,r.rowByteLength)}}function E(r){if(r.byteOffset%wo!==0)throw new Error("GraphDataView storage binding must be uint32-aligned");return r.byteOffset%To/wo}function Me(r,e,t,o,n=bo.Buffer.STORAGE){if(!Number.isSafeInteger(o)||o<0)throw new Error("Transient GraphDataView length must be a non-negative safe integer");if((n&bo.Buffer.STORAGE)===0)throw new Error("Transient GraphDataView usage must include Buffer.STORAGE");if(we(t)||Te(t))throw new Error("Transient GraphDataView requires a fixed-width GPUVector format");let i=N(t),a=r.createTransientBuffer({id:e,byteLength:Math.max(o,1)*i.byteLength,usage:n});return r.createDataView(a,{format:t,length:o})}function ii(r,e,t){if(!Number.isSafeInteger(t)||t<0||t>e.length)throw new Error("Graph prefix must fit within the input");if(t===e.length)return e;let o=e instanceof B?e.data:[e],n=t,i=[];for(let a of o){let s=Math.min(n,a.length);if(i.push(s===a.length?a:r.createDataView(a.buffer,{format:a.format,length:s,byteOffset:a.byteOffset,byteStride:a.byteStride,rowByteLength:a.rowByteLength})),n-=s,n===0)break}return e instanceof B?new B({...e,length:t,valueLength:t*(N(e.format).listSize??1),data:i}):i[0]}var or=ee(K(),1);le();function k(r,e){let[t,o,n]=e;for(let[i,a]of[["x",t],["y",o],["z",n]])if(!Number.isSafeInteger(a)||a<0)throw new Error(`compute dispatch ${i} workgroup count must be a non-negative safe integer`);return{...r,dispatchWorkgroups:Object.freeze([t,o,n])}}function tr(r){return r.dispatchWorkgroups}var rr=ee(K(),1);var Ka=16*1024,si=new WeakMap;function ui(r){let e=r,t=si.get(e);return t||(t=new vo(r),si.set(e,t)),t}var vo=class{id;graph;buffer;capacityByteLength;nextByteOffset=0;slots=new Map;views=new Map;constructor(e,t="gpu-value-arena",o=Ka){if(this.id=t,this.graph=e,!Number.isSafeInteger(o)||o<=0||o%4!==0)throw new Error(`${this.id} capacityByteLength must be a positive multiple of 4`);this.capacityByteLength=o,this.buffer=e.createTransientBuffer({id:`${this.id}-buffer`,byteLength:o,usage:rr.Buffer.STORAGE|rr.Buffer.COPY_SRC|rr.Buffer.COPY_DST})}allocate(e,t){if(!e)throw new Error(`${this.id} slot id must not be empty`);if(this.slots.has(e))throw new Error(`${this.id} slot "${e}" already exists`);if(!["float32","uint32","sint32"].includes(t))throw new Error(`${this.id} unsupported slot format ${t}`);if(this.nextByteOffset+4>this.capacityByteLength)throw new Error(`${this.id} capacity exceeded while allocating "${e}"`);let o=Object.freeze({id:e,format:t,byteOffset:this.nextByteOffset});return this.nextByteOffset+=4,this.slots.set(e,o),this.views.set(e,new de(this.buffer,{format:t,length:1,byteOffset:o.byteOffset,byteStride:4,rowByteLength:4})),o}get(e){return this.slots.get(e)}getSlots(){return Object.freeze([...this.slots.values()])}getView(e){let t=this.views.get(e.id);if(!t)throw new Error(`${this.id} does not contain slot "${e.id}"`);return t}get byteLength(){return this.nextByteOffset}get size(){return this.slots.size}get availableByteLength(){return this.capacityByteLength-this.nextByteOffset}};var Co=class{id;format;arena;slot;constructor(e,t){this.id=t.id,this.format=t.format,this.arena=e,this.slot=t}get byteOffset(){return this.slot.byteOffset}get wordOffset(){return this.slot.byteOffset>>>2}get view(){return this.arena.getView(this.slot)}};function Po(r,e,t){let o=ui(r);return new Co(o,o.allocate(e,t))}function J(r,e="gpuValues"){let t=`${e}[${r.wordOffset}u]`;switch(r.format){case"float32":return`bitcast<f32>(${t})`;case"uint32":return t;case"sint32":return`bitcast<i32>(${t})`}}function Se(r,e,t="gpuValues"){let o=`${t}[${r.wordOffset}u]`;switch(r.format){case"float32":return`${o} = bitcast<u32>(${e});`;case"uint32":return`${o} = ${e};`;case"sint32":return`${o} = bitcast<u32>(${e});`}}function Y(r,e,t="gpuValues"){return`@group(${r}) @binding(${e}) var<storage, read_write> ${t}: array<u32>;`}var St=class{id;active;workgroups;dispatchBuffer;constructor(e,t){if(this.id=t.id,this.active=t.active,this.workgroups=t.workgroups,t.active.arena.graph!==e)throw new Error(`${this.id} active scalar must belong to target graph`);this.dispatchBuffer=e.createTransientBuffer({id:`${this.id}-dispatch`,byteLength:12,usage:or.Buffer.STORAGE|or.Buffer.INDIRECT|or.Buffer.COPY_SRC})}getUpdateCommandNodes(e,t=`${this.id}-update`){if(this.active.arena.graph!==e)throw new Error(`${this.id} active scalar must belong to target graph`);let o=this.active.arena.buffer,[n,i,a]=this.workgroups,s=`${Y(0,0)}
|
|
7
|
+
"use strict";var __exports__=(()=>{var oc=Object.create;var Lr=Object.defineProperty;var ic=Object.getOwnPropertyDescriptor;var sc=Object.getOwnPropertyNames;var ac=Object.getPrototypeOf,cc=Object.prototype.hasOwnProperty;var uc=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Un=(r,e)=>{for(var t in e)Lr(r,t,{get:e[t],enumerable:!0})},vr=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of sc(e))!cc.call(r,o)&&o!==t&&Lr(r,o,{get:()=>e[o],enumerable:!(n=ic(e,o))||n.enumerable});return r},Br=(r,e,t)=>(vr(r,e,"default"),t&&vr(t,e,"default")),X=(r,e,t)=>(t=r!=null?oc(ac(r)):{},vr(e||!r||!r.__esModule?Lr(t,"default",{value:r,enumerable:!0}):t,r)),hc=r=>vr(Lr({},"__esModule",{value:!0}),r);var V=uc((od,bi)=>{bi.exports=globalThis.luma});var Pr={};Un(Pr,{CompiledGPUCommandGraph:()=>yt,CompiledGPUGraph:()=>Zt,DynamicBuffer:()=>xe,DynamicTexture:()=>Ke,GPUCommandGraph:()=>xt,GPUCommandGraphAutotuner:()=>In,GPUCommandGraphEncoding:()=>Ut,GPUCommandGraphExecution:()=>_t,GPUCommandGraphExecutionBudgetController:()=>Rn,GPUCommandGraphInspector:()=>Gn,GPUExpressionOperation:()=>Ie,GPUGraph:()=>Lt,GPUGraphCompiler:()=>Pt,GPUGraphScalar:()=>bt,GPUGraphTexture:()=>wt,GPUGraphTextureView:()=>Le,GPUGraphVector:()=>ve,GraphBufferHandle:()=>Ue,GraphDataView:()=>Ce,GraphExternalTextureHandle:()=>tt,GraphTextureHandle:()=>be,GraphTextureView:()=>ke,GraphVectorView:()=>_,Kernel:()=>k,RenderKernel:()=>_n,composite:()=>pi,getGPUCommandGraphAdapterIdentity:()=>Ja,getGPUCommandGraphExecutionPlan:()=>qr,getPlatformInfo:()=>nc,inspectGPUGraphCompilation:()=>gi,validateGPUGraph:()=>br});Br(Pr,X(V(),1));var dt=X(V(),1);async function wi(r,e){if(r.destroyed)throw new Error("Resource has been destroyed.");if(r instanceof dt.Buffer){if(!(r.usage&dt.Buffer.COPY_SRC))throw new Error("Preview requires COPY_SRC usage.");let u=e.byteOffset??0,d=Math.min(256,e.byteLength??r.byteLength-u);if(u<0||d<0||u+d>r.byteLength)throw new Error("Preview range is outside the buffer.");return{data:d?await r.readAsync(u,d):new Uint8Array,format:e.format}}let t=r.device.getTextureFormatInfo(r.format);if(t.packed)throw new Error("Packed texture previews are not supported.");if(r.device.type!=="webgpu")throw new Error("Texture previews require WebGPU.");if(!((r.props.usage??0)&dt.Texture.COPY_SRC))throw new Error("Preview requires COPY_SRC usage.");if(r.samples!==1||t.compressed||r.format.startsWith("depth")||r.format.startsWith("stencil"))throw new Error("Preview requires a single-sample, uncompressed color texture.");let n=e.baseMipLevel??0,o=Math.min(32,e.width??Math.max(1,r.width>>n)),i=Math.min(32,e.height??Math.max(1,r.height>>n)),s=r.computeMemoryLayout({width:o,height:i,depthOrArrayLayers:1}),a=r.device.createBuffer({byteLength:s.byteLength,usage:dt.Buffer.MAP_READ|dt.Buffer.COPY_DST}),c=r.device.createCommandEncoder();try{c.copyTextureToBuffer({sourceTexture:r,destinationBuffer:a,mipLevel:n,origin:[0,0,e.baseArrayLayer??0],width:o,height:i,depthOrArrayLayers:1,bytesPerRow:s.bytesPerRow}),r.device.submit(c.finish());let u=await a.readAsync(),d=o*t.bytesPerPixel,h=new Uint8Array(d*i);for(let f=0;f<i;f++)h.set(u.subarray(f*s.bytesPerRow,f*s.bytesPerRow+d),f*d);return{data:h,width:o,height:i,format:r.format}}finally{a.destroy(),c.destroy()}}var ie=X(V(),1);var er=globalThis,fc=globalThis.document||{},Ar=globalThis.process||{},dc=globalThis.console,lc=globalThis.navigator||{};function Or(r){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=r||e;return!!(t&&t.indexOf("Electron")>=0)}function je(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Or()}var kn="5.0.0";function Bt(r,e){if(!r)throw new Error(e||"Assertion failed")}function Ir(r){if(!r)return 0;let e;switch(typeof r){case"number":e=r;break;case"object":e=r.logLevel||r.priority||0;break;default:return 0}return Bt(Number.isFinite(e)&&e>=0),e}function zn(r){let{logLevel:e,message:t}=r;r.logLevel=Ir(e);let n=r.args?Array.from(r.args):[];for(;n.length&&n.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&n.unshift(t),r.message=e;break;case"object":Object.assign(r,e);break;default:}typeof r.message=="function"&&(r.message=r.message());let o=typeof r.message;return Bt(o==="string"||o==="object"),Object.assign(r,{args:n},r.opts)}var Ye=()=>{},lt=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...t){return this._log("warn",0,e,t,{once:!0})}error(e,...t){return this._log("error",0,e,t)}log(e,t,...n){return this._log("log",e,t,n)}info(e,t,...n){return this._log("info",e,t,n)}once(e,t,...n){return this._log("once",e,t,n,{once:!0})}_log(e,t,n,o,i={}){let s=zn({logLevel:t,message:n,args:this._buildArgs(t,n,o),opts:i});return this._createLogFunction(e,s,i)}_buildArgs(e,t,n){return[e,t,...n]}_createLogFunction(e,t,n){if(!this._shouldLog(t.logLevel))return Ye;let o=this._getOnceTag(n.tag??t.tag??t.message);if((n.once||t.once)&&o!==void 0){if(this._onceCache.has(o))return Ye;this._onceCache.add(o)}return this._emit(e,t)}_shouldLog(e){return this.getLevel()>=Ir(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}};function pc(r){try{let e=window[r],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var tr=class{constructor(e,t,n="sessionStorage"){this.storage=pc(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}};function Ti(r){let e;return r<10?e=`${r.toFixed(2)}ms`:r<100?e=`${r.toFixed(1)}ms`:r<1e3?e=`${r.toFixed(0)}ms`:e=`${(r/1e3).toFixed(2)}s`,e}function $n(r,e=8){let t=Math.max(e-r.length,0);return`${" ".repeat(t)}${r}`}var rr;(function(r){r[r.BLACK=30]="BLACK",r[r.RED=31]="RED",r[r.GREEN=32]="GREEN",r[r.YELLOW=33]="YELLOW",r[r.BLUE=34]="BLUE",r[r.MAGENTA=35]="MAGENTA",r[r.CYAN=36]="CYAN",r[r.WHITE=37]="WHITE",r[r.BRIGHT_BLACK=90]="BRIGHT_BLACK",r[r.BRIGHT_RED=91]="BRIGHT_RED",r[r.BRIGHT_GREEN=92]="BRIGHT_GREEN",r[r.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",r[r.BRIGHT_BLUE=94]="BRIGHT_BLUE",r[r.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",r[r.BRIGHT_CYAN=96]="BRIGHT_CYAN",r[r.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(rr||(rr={}));var gc=10;function Mi(r){return typeof r!="string"?r:(r=r.toUpperCase(),rr[r]||rr.WHITE)}function Fn(r,e,t){return!je&&typeof r=="string"&&(e&&(r=`\x1B[${Mi(e)}m${r}\x1B[39m`),t&&(r=`\x1B[${Mi(t)+gc}m${r}\x1B[49m`)),r}function Vn(r,e=["constructor"]){let t=Object.getPrototypeOf(r),n=Object.getOwnPropertyNames(t),o=r;for(let i of n){let s=o[i];typeof s=="function"&&(e.find(a=>i===a)||(o[i]=s.bind(r)))}}var Rr=class{getHighResolutionTimer(){let e;if(je()&&er.performance)e=er?.performance?.now?.();else if("hrtime"in Ar){let t=Ar?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}getMemoryUsageMB(){let t=er?.performance?.memory?.usedJSHeapSize;return t==null?null:Math.trunc(t/1024/1024)}},ue=new Rr;globalThis.Probe=Rr;globalThis.probe=ue;var At={debug:je()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Wn={enabled:!0,level:0},De=class extends lt{constructor({id:e}={id:""}){super({level:0}),this.VERSION=kn,this._startTs=ue.getHighResolutionTimer(),this._deltaTs=ue.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new tr(`__probe-${this.id}__`,{[this.id]:Wn}),this.timeStamp(`${this.id} started`),Vn(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((ue.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((ue.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,t){this._updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e,...t){return this._log("warn",0,e,t,{method:At.warn,once:!0})}error(e,...t){return this._log("error",0,e,t,{method:At.error})}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t,...n){let o=ue.getMemoryUsageMB();if(o!==null){let i=`${o}MB `;typeof t=="function"?t=()=>`${i}${t()}`:typeof t=="string"&&(t=`${i}${t}`)}return this._log("log",e,t,n,{method:At.log,time:!0,once:!0})}log(e,t,...n){return this._log("log",e,t,n,{method:At.debug})}info(e,t,...n){return this._log("info",e,t,n,{method:console.info})}once(e,t,...n){return this._log("once",e,t,n,{method:At.debug||At.info,once:!0})}table(e,t,n){return t?this._log("table",e,t,n&&[n]||[],{method:console.table||Ye,tag:yc(t)}):Ye}time(e,t){return this._log("time",e,t,[],{method:console.time?console.time:console.info})}timeEnd(e,t){return this._log("time",e,t,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,t){return this._log("time",e,t,[],{method:console.timeStamp||Ye})}group(e,t,n={collapsed:!1}){let o=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,t,[],{method:o})}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||Ye})}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,t){let n=t.method;Bt(n),t.total=this.getTotal(),t.delta=this.getDelta(),this._deltaTs=ue.getHighResolutionTimer();let o=xc(this.id,t.message,t);return n.bind(console,o,...t.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(Wn),this._storage.config[this.id]}_updateConfiguration(e){let t=this._storage.config[this.id]||{...Wn};this._storage.setConfiguration({[this.id]:{...t,...e}})}};De.VERSION=kn;function xc(r,e,t){if(typeof e=="string"){let n=t.time?$n(Ti(t.total)):"";e=t.time?`${r}: ${n} ${e}`:`${r}: ${e}`,e=Fn(e,t.color,t.background)}return e}function yc(r){for(let e in r)for(let t in r[e])return t||"untitled";return"empty"}globalThis.probe||(globalThis.probe=ue);var il=new De({id:"@probe.gl/log"});var ge=new De({id:"luma.gl"});var qn={};function Ot(r="id"){qn[r]=qn[r]||1;let e=qn[r]++;return`${r}-${e}`}var bc="cpu-hotspot-profiler",Ei="GPU Resource Counts",Si="Resource Counts",Pi="GPU Time and Memory",wc=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],Tc=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],Mc=wc.flatMap(r=>[`${r} Created`,`${r} Active`]),Ec=Tc.flatMap(r=>[`${r} Created`,`${r} Active`]),Ci=new WeakMap,vi=new WeakMap,he=class{static defaultProps={id:"undefined",handle:void 0,_isHandleBorrowed:!1,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}toJSON(){return this.toString()}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;get ownsHandle(){return(this.props.handle===void 0||this.props.handle===null)&&!this.isHandleBorrowed}get isHandleBorrowed(){return!!this.props._isHandleBorrowed}constructor(e,t,n){if(!e)throw new Error("no device");this._device=e,this.props=Sc(t,n);let o=this.props.id!=="undefined"?this.props.id:Ot(this[Symbol.toStringTag]);this.props.id=o,this.id=o,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=nr(this._device),t=e?He():0,n=[this._device.statsManager.getStats(Ei),this._device.statsManager.getStats(Si)],o=Bi(this._device);for(let s of n)Li(s,o);let i=this.getStatsName();for(let s of n)s.get("Resources Active").decrementCount(),s.get(`${i}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(He()-t))}trackAllocatedMemory(e,t=this.getStatsName()){let n=nr(this._device),o=n?He():0,i=this._device.statsManager.getStats(Pi);this.allocatedBytes>0&&this.allocatedBytesName&&(i.get("GPU Memory").subtractCount(this.allocatedBytes),i.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),i.get("GPU Memory").addCount(e),i.get(`${t} Memory`).addCount(e),n&&(n.statsBookkeepingCalls=(n.statsBookkeepingCalls||0)+1,n.statsBookkeepingTimeMs=(n.statsBookkeepingTimeMs||0)+(He()-o)),this.allocatedBytes=e,this.allocatedBytesName=t}trackReferencedMemory(e,t=this.getStatsName()){this.trackAllocatedMemory(e,`External ${t}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let t=nr(this._device),n=t?He():0,o=this._device.statsManager.getStats(Pi);o.get("GPU Memory").subtractCount(this.allocatedBytes),o.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(He()-n)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),t=nr(this._device),n=t?He():0,o=[this._device.statsManager.getStats(Ei),this._device.statsManager.getStats(Si)],i=Bi(this._device);for(let s of o)Li(s,i);for(let s of o)s.get("Resources Created").incrementCount(),s.get("Resources Active").incrementCount(),s.get(`${e}s Created`).incrementCount(),s.get(`${e}s Active`).incrementCount();t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(He()-n)),Pc(this._device,e)}getStatsName(){return Cc(this)}};function Sc(r,e){let t={...e};for(let n in r)r[n]!==void 0&&(t[n]=r[n]);return t}function Li(r,e){let t=r.stats,n=!1;for(let c of e)t[c]||(r.get(c),n=!0);let o=Object.keys(t).length,i=Ci.get(r);if(!n&&i?.orderedStatNames===e&&i.statCount===o)return;let s={},a=vi.get(e);a||(a=new Set(e),vi.set(e,a));for(let c of e)t[c]&&(s[c]=t[c]);for(let[c,u]of Object.entries(t))a.has(c)||(s[c]=u);for(let c of Object.keys(t))delete t[c];Object.assign(t,s),Ci.set(r,{orderedStatNames:e,statCount:o})}function Bi(r){return r.type==="webgl"?Ec:Mc}function nr(r){let e=r.userData[bc];return e?.enabled?e:null}function He(){return globalThis.performance?.now?.()??Date.now()}function Pc(r,e){let t=nr(r);if(!(!t||!t.activeDefaultFramebufferAcquireDepth))switch(t.transientCanvasResourceCreates=(t.transientCanvasResourceCreates||0)+1,e){case"Texture":t.transientCanvasTextureCreates=(t.transientCanvasTextureCreates||0)+1;break;case"TextureView":t.transientCanvasTextureViewCreates=(t.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":t.transientCanvasSamplerCreates=(t.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":t.transientCanvasFramebufferCreates=(t.transientCanvasFramebufferCreates||0)+1;break;default:break}}function Cc(r){let e=Object.getPrototypeOf(r);for(;e;){let t=Object.getPrototypeOf(e);if(!t||t===he.prototype)return vc(e)||r[Symbol.toStringTag]||r.constructor.name;e=t}return r[Symbol.toStringTag]||r.constructor.name}function vc(r){let e=Object.getOwnPropertyDescriptor(r,Symbol.toStringTag);return typeof e?.get=="function"?e.get.call(r):typeof e?.value=="string"?e.value:null}var Ee=class r extends he{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let n={...t};(t.usage||0)&r.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?n.indexType="uint32":t.data instanceof Uint16Array?n.indexType="uint16":t.data instanceof Uint8Array&&(n.indexType="uint8")),delete n.data,super(e,n,r.defaultProps),this.usage=n.usage||0,this.indexType=n.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(e,t,n){if(!this.device.props.debug)return;let o=null,i;ArrayBuffer.isView(e)?(o=e,i=e.buffer):i=e;let s=Math.min(e?e.byteLength:n,r.DEBUG_DATA_MAX_LENGTH);if(i===null)this.debugData=new ArrayBuffer(s);else{let a=Math.min(o?.byteOffset||0,i.byteLength),c=Math.max(0,i.byteLength-a),u=Math.min(s,c);this.debugData=new Uint8Array(i,a,u).slice().buffer}}static defaultProps={...he.defaultProps,handle:void 0,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0}};var jn=globalThis.Float16Array;function Ai(){return jn??Uint16Array}function Oi(r){return!!(jn&&r===jn)}function Dr(r,e){switch(e){case 1:return r;case 2:return r+r%2;default:return r+(4-r%4)%4}}function Ii(r){let e=r.includes("norm"),t=!e&&!r.startsWith("float"),n=r.startsWith("s"),o=Yn[r],[i,s,a]=o||["uint8 ","i32",1];return{signedType:i,primitiveType:s,byteLength:a,normalized:e,integer:t,signed:n}}function Ri(r){let e=r;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function Lc(r){let e=ArrayBuffer.isView(r)?r.constructor:r;if(Oi(e))return"float16";if(e===Uint8ClampedArray)return"uint8";let t=Object.values(Yn).find(n=>e===n[4]);if(!t)throw new Error(e.name);return t[0]}function Di(r){return Lc(r)}function Bc(r){if(r==="float16")return Ai();let e=Yn[r];if(!e)throw new Error(r);let[,,,,t]=e;return t}function Gi(r){return Bc(r)}var Yn={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};var Hn=class{getDataTypeInfo(e){return Ii(e)}getNormalizedDataType(e){return Ri(e)}alignTo(e,t){return Dr(e,t)}getDataType(e){return Di(e)}getTypedArrayConstructor(e){return Gi(e)}},Ni=new Hn;var ee="texture-compression-bc",R="texture-compression-astc",Se="texture-compression-etc2",Ac="texture-compression-etc1-webgl",Gr="texture-compression-pvrtc-webgl",Xn="texture-compression-atc-webgl",Nr="float32-renderable-webgl",Zn="float16-renderable-webgl",Oc="rgb9e5ufloat-renderable-webgl",Kn="snorm8-renderable-webgl",Xe="norm16-webgl",Qn="norm16-renderable-webgl",Jn="snorm16-renderable-webgl",_r="float32-filterable",_i="float16-filterable-webgl",or=1,ir=2,ro=4,no=8,Rt=16,kr=5,ki=10,W=or|ir,Ur=or|ro,Ge=or|ir|ro|no,Pe=or|ir|Rt,Ic=or|ro|Rt,to=Ge|Rt,Ui=(ir|no|Rt)<<kr,Rc=(ir|no)<<kr,oe=Rt<<kr,It=to<<kr,Dc=Ge<<ki,eo=Rt<<ki;function zr(r){let e=_c[r];if(!e)throw new Error(`Unsupported texture format ${r}`);return e}var Gc={r8unorm:{webgpu:Ge|oe},rg8unorm:{webgpu:Ge|oe},"rgb8unorm-webgl":{},rgba8unorm:{webgpu:to},"rgba8unorm-srgb":{webgpu:Ge},r8snorm:{render:Kn,webgpu:Ur|Ui},rg8snorm:{render:Kn,webgpu:Ur|Ui},"rgb8snorm-webgl":{},rgba8snorm:{render:Kn,webgpu:Ic|Rc},r8uint:{webgpu:W|oe},rg8uint:{webgpu:W|oe},rgba8uint:{webgpu:Pe},r8sint:{webgpu:W|oe},rg8sint:{webgpu:W|oe},rgba8sint:{webgpu:Pe},bgra8unorm:{webgpu:Ge},"bgra8unorm-srgb":{webgpu:Dc},r16unorm:{f:Xe,render:Qn,webgpu:It},rg16unorm:{f:Xe,render:Qn,webgpu:It},"rgb16unorm-webgl":{f:Xe,render:!1},rgba16unorm:{f:Xe,render:Qn,webgpu:It},r16snorm:{f:Xe,render:Jn,webgpu:It},rg16snorm:{f:Xe,render:Jn,webgpu:It},"rgb16snorm-webgl":{f:Xe,render:!1},rgba16snorm:{f:Xe,render:Jn,webgpu:It},r16uint:{webgpu:W|oe},rg16uint:{webgpu:W|oe},rgba16uint:{webgpu:Pe},r16sint:{webgpu:W|oe},rg16sint:{webgpu:W|oe},rgba16sint:{webgpu:Pe},r16float:{render:Zn,filter:"float16-filterable-webgl",webgpu:Ge|oe},rg16float:{render:Zn,filter:_i,webgpu:Ge|oe},rgba16float:{render:Zn,filter:_i,webgpu:to},r32uint:{webgpu:Pe},rg32uint:{webgpu:W|eo},rgba32uint:{webgpu:Pe},r32sint:{webgpu:Pe},rg32sint:{webgpu:W|eo},rgba32sint:{webgpu:Pe},r32float:{render:Nr,filter:_r,webgpu:Pe},rg32float:{render:!1,filter:_r,webgpu:W|eo},"rgb32float-webgl":{render:Nr,filter:_r},rgba32float:{render:Nr,filter:_r,webgpu:Pe},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:Oc,webgpu:Ur},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Nr,webgpu:Ur|oe},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:Ge|oe},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:W|oe},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8",webgpu:W},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16",webgpu:W},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32",webgpu:W},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32",webgpu:W},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0,webgpu:W},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0,f:"depth32float-stencil8",webgpu:W}},Nc={"bc1-rgb-unorm-webgl":{f:ee},"bc1-rgb-unorm-srgb-webgl":{f:ee},"bc1-rgba-unorm":{f:ee},"bc1-rgba-unorm-srgb":{f:ee},"bc2-rgba-unorm":{f:ee},"bc2-rgba-unorm-srgb":{f:ee},"bc3-rgba-unorm":{f:ee},"bc3-rgba-unorm-srgb":{f:ee},"bc4-r-unorm":{f:ee},"bc4-r-snorm":{f:ee},"bc5-rg-unorm":{f:ee},"bc5-rg-snorm":{f:ee},"bc6h-rgb-ufloat":{f:ee},"bc6h-rgb-float":{f:ee},"bc7-rgba-unorm":{f:ee},"bc7-rgba-unorm-srgb":{f:ee},"etc2-rgb8unorm":{f:Se},"etc2-rgb8unorm-srgb":{f:Se},"etc2-rgb8a1unorm":{f:Se},"etc2-rgb8a1unorm-srgb":{f:Se},"etc2-rgba8unorm":{f:Se},"etc2-rgba8unorm-srgb":{f:Se},"eac-r11unorm":{f:Se},"eac-r11snorm":{f:Se},"eac-rg11unorm":{f:Se},"eac-rg11snorm":{f:Se},"astc-4x4-unorm":{f:R},"astc-4x4-unorm-srgb":{f:R},"astc-5x4-unorm":{f:R},"astc-5x4-unorm-srgb":{f:R},"astc-5x5-unorm":{f:R},"astc-5x5-unorm-srgb":{f:R},"astc-6x5-unorm":{f:R},"astc-6x5-unorm-srgb":{f:R},"astc-6x6-unorm":{f:R},"astc-6x6-unorm-srgb":{f:R},"astc-8x5-unorm":{f:R},"astc-8x5-unorm-srgb":{f:R},"astc-8x6-unorm":{f:R},"astc-8x6-unorm-srgb":{f:R},"astc-8x8-unorm":{f:R},"astc-8x8-unorm-srgb":{f:R},"astc-10x5-unorm":{f:R},"astc-10x5-unorm-srgb":{f:R},"astc-10x6-unorm":{f:R},"astc-10x6-unorm-srgb":{f:R},"astc-10x8-unorm":{f:R},"astc-10x8-unorm-srgb":{f:R},"astc-10x10-unorm":{f:R},"astc-10x10-unorm-srgb":{f:R},"astc-12x10-unorm":{f:R},"astc-12x10-unorm-srgb":{f:R},"astc-12x12-unorm":{f:R},"astc-12x12-unorm-srgb":{f:R},"pvrtc-rgb4unorm-webgl":{f:Gr},"pvrtc-rgba4unorm-webgl":{f:Gr},"pvrtc-rgb2unorm-webgl":{f:Gr},"pvrtc-rgba2unorm-webgl":{f:Gr},"etc1-rbg-unorm-webgl":{f:Ac},"atc-rgb-unorm-webgl":{f:Xn},"atc-rgba-unorm-webgl":{f:Xn},"atc-rgbai-unorm-webgl":{f:Xn}},_c={...Gc,...Nc};var Uc=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,kc=["rgb","rgba","bgra"],zc=["depth","stencil"],$c=5,Fc=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],oo=class{isColor(e){return kc.some(t=>e.startsWith(t))}isDepthStencil(e){return zc.some(t=>e.startsWith(t))}isCompressed(e){return Fc.some(t=>e.startsWith(t))}getInfo(e){return zi(e)}getCapabilities(e){return Wc(e)}getWebGPUCapabilities(e){let t=zr(e);return t.webgpu!==void 0?t.webgpu:this.isCompressed(e)&&!e.endsWith("-webgl")?$c:0}computeMemoryLayout(e){return Vc(e)}},mt=new oo;function Vc({format:r,width:e,height:t,depth:n,byteAlignment:o}){let i=mt.getInfo(r),{bytesPerPixel:s,bytesPerBlock:a=s,blockWidth:c=1,blockHeight:u=1,compressed:d=!1}=i,h=d?Math.ceil(e/c):e,f=d?Math.ceil(t/u):t,l=h*a,m=Math.ceil(l/o)*o,g=f,x=m*g*n;return{bytesPerPixel:s,bytesPerRow:m,rowsPerImage:g,depthOrArrayLayers:n,bytesPerImage:m*g,byteLength:x}}function Wc(r){let e=zr(r),t={format:r,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},n=zi(r),o=r.startsWith("depth")||r.startsWith("stencil"),i=n?.signed,s=n?.integer,a=n?.webgl,c=!!n?.compressed;return t.render&&=!o&&!c,t.filter&&=!o&&!i&&!s&&!a,t}function zi(r){let e=qc(r);if(mt.isCompressed(r)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=Yc(r);let n=jc(r);n&&(e.blockWidth=n.blockWidth,e.blockHeight=n.blockHeight)}let t=e.packed?null:Uc.exec(r);if(t){let[,n,o,i,s,a]=t,c=`${i}${o}`,u=Ni.getDataTypeInfo(c),d=u.byteLength*8,h=n?.length??1,f=[d,h>=2?d:0,h>=3?d:0,h>=4?d:0];e={format:r,attachment:e.attachment,dataType:u.signedType,components:h,channels:n,integer:u.integer,signed:u.signed,normalized:u.normalized,bitsPerChannel:f,bytesPerPixel:u.byteLength*h,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),s==="-srgb"&&(e.srgb=!0)}return r.endsWith("-webgl")&&(e.webgl=!0),r.endsWith("-srgb")&&(e.srgb=!0),e}function qc(r){let e={...zr(r)},t=e.bytesPerPixel||1,n=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,delete e.webgpu,{...e,format:r,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:t,bitsPerChannel:n,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function jc(r){let t=/.*-(\d+)x(\d+)-.*/.exec(r);if(t){let[,n,o]=t;return{blockWidth:Number(n),blockHeight:Number(o)}}return r.startsWith("bc")||r.startsWith("etc1")||r.startsWith("etc2")||r.startsWith("eac")||r.startsWith("atc")?{blockWidth:4,blockHeight:4}:r.startsWith("pvrtc-rgb4")||r.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:r.startsWith("pvrtc-rgb2")||r.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function Yc(r){return r.startsWith("bc1")||r.startsWith("bc4")||r.startsWith("etc1")||r.startsWith("etc2-rgb8")||r.startsWith("etc2-rgb8a1")||r.startsWith("eac-r11")||r==="atc-rgb-unorm-webgl"?8:r.startsWith("bc2")||r.startsWith("bc3")||r.startsWith("bc5")||r.startsWith("bc6h")||r.startsWith("bc7")||r.startsWith("etc2-rgba8")||r.startsWith("eac-rg11")||r.startsWith("astc")||r==="atc-rgba-unorm-webgl"||r==="atc-rgbai-unorm-webgl"?16:r.startsWith("pvrtc")?8:16}function sr(r){return typeof ImageData<"u"&&r instanceof ImageData||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement||typeof VideoFrame<"u"&&r instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas}function $r(r){if(typeof ImageData<"u"&&r instanceof ImageData||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas)return{width:r.width,height:r.height};if(typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement)return{width:r.naturalWidth,height:r.naturalHeight};if(typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement)return{width:r.videoWidth,height:r.videoHeight};if(typeof VideoFrame<"u"&&r instanceof VideoFrame)return{width:r.displayWidth,height:r.displayHeight};throw new Error("Unknown image type")}var Ze=class r extends he{static defaultProps={...he.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=r.normalizeProps(e,t),super(e,t,r.defaultProps)}static normalizeProps(e,t){return t}};var Hc={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},te=class r extends he{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,t,n){if(t=r.normalizeProps(e,t),super(e,t,r.defaultProps),this.dimension=this.props.dimension,this.baseDimension=Hc[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(t.data)){let o=e.getExternalImageSize(t.data);this.width=o?.width||1,this.height=o?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&ge.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=n?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof Ze?e:this.device.createSampler(e)}copyImageData(e){let{data:t,depth:n,...o}=e;this.writeData(t,{...o,depthOrArrayLayers:o.depthOrArrayLayers??n})}computeMemoryLayout(e={}){let t=this._normalizeTextureReadOptions(e),{width:n=this.width,height:o=this.height,depthOrArrayLayers:i=this.depth}=t,{format:s,byteAlignment:a}=this;return mt.computeMemoryLayout({format:s,width:n,height:o,depth:i,byteAlignment:a})}readBuffer(e,t){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,t){throw new Error("readBuffer not implemented")}writeData(e,t){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,t){let n={...t},{width:o,height:i}=n;return typeof o=="number"&&(n.width=Math.max(1,Math.ceil(o))),typeof i=="number"&&(n.height=Math.max(1,Math.ceil(i))),n}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{data:t,depth:n,...o}=e,i=this._normalizeTextureWriteOptions({...o,depthOrArrayLayers:o.depthOrArrayLayers??n});return{data:t,depth:i.depthOrArrayLayers,...i}}_normalizeCopyExternalImageOptions(e){let t=r._omitUndefined(e),n=t.mipLevel??0,o=this._getMipLevelSize(n),i=this.device.getExternalImageSize(e.image),s={...r.defaultCopyExternalImageOptions,...o,...i,...t};return s.width=Math.min(s.width,o.width-s.x),s.height=Math.min(s.height,o.height-s.y),s.depth=Math.min(s.depth,o.depthOrArrayLayers-s.z),s}_normalizeCopyElementImageOptions(e){let t=r._omitUndefined(e),n=t.mipLevel??0,o=this._getMipLevelSize(n),i={...r.defaultCopyElementImageOptions,...o,...t};return i.width=Math.min(i.width,o.width-i.x),i.height=Math.min(i.height,o.height-i.y),i.depth=Math.min(i.depth,o.depthOrArrayLayers-i.z),i}_normalizeTextureReadOptions(e){let t=r._omitUndefined(e),n=t.mipLevel??0,o=this._getMipLevelSize(n),i={...r.defaultTextureReadOptions,...o,...t};return i.width=Math.min(i.width,o.width-i.x),i.height=Math.min(i.height,o.height-i.y),i.depthOrArrayLayers=Math.min(i.depthOrArrayLayers,o.depthOrArrayLayers-i.z),i}_getSupportedColorReadOptions(e){let t=this._normalizeTextureReadOptions(e),n=mt.getInfo(this.format);switch(this._validateColorReadAspect(t),this._validateColorReadFormat(n),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return t;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(e){let t=r._omitUndefined(e),n=t.mipLevel??0,o=this._getMipLevelSize(n),i={...r.defaultTextureWriteOptions,...o,...t};i.width=Math.min(i.width,o.width-i.x),i.height=Math.min(i.height,o.height-i.y),i.depthOrArrayLayers=Math.min(i.depthOrArrayLayers,o.depthOrArrayLayers-i.z);let s=mt.computeMemoryLayout({format:this.format,width:i.width,height:i.height,depth:i.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=s.bytesPerPixel*i.width;if(i.bytesPerRow=t.bytesPerRow??s.bytesPerRow,i.rowsPerImage=t.rowsPerImage??i.height,i.bytesPerRow<a)throw new Error(`bytesPerRow (${i.bytesPerRow}) must be at least ${a} for ${this.format}`);if(i.rowsPerImage<i.height)throw new Error(`rowsPerImage (${i.rowsPerImage}) must be at least ${i.height} for ${this.format}`);let c=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(c&&i.bytesPerRow%c!==0)throw new Error(`bytesPerRow (${i.bytesPerRow}) must be a multiple of bytesPerPixel (${c}) for ${this.format}`);return i}_getMipLevelSize(e){let t=Math.max(1,this.width>>e),n=this.baseDimension==="1d"?1:Math.max(1,this.height>>e),o=this.dimension==="3d"?Math.max(1,this.depth>>e):this.depth;return{width:t,height:n,depthOrArrayLayers:o}}getAllocatedByteLength(){let e=0;for(let t=0;t<this.mipLevels;t++){let{width:n,height:o,depthOrArrayLayers:i}=this._getMipLevelSize(t);e+=mt.computeMemoryLayout({format:this.format,width:n,height:o,depth:i,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}static defaultProps={...he.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:r.SAMPLE|r.RENDER|r.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultCopyElementImageOptions={element:void 0,width:void 0,height:void 0,sourceX:0,sourceY:0,sourceWidth:void 0,sourceHeight:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}};var Xc=Ee.DEBUG_DATA_MAX_LENGTH,xe=class{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(e,t){let{debugData:n=!1,buffer:o,ownsBuffer:i=!0,...s}=t;if(o&&o.device!==e)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(o&&(s.byteLength!==void 0||s.data!==void 0))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");let a=t.id||o?.id||Ot("dynamic-buffer"),c={...s,id:a,usage:s.usage??o?.usage,indexType:s.indexType??o?.indexType};(c.usage||0)&Ee.INDEX&&!c.indexType&&(s.data instanceof Uint32Array?c.indexType="uint32":s.data instanceof Uint16Array?c.indexType="uint16":s.data instanceof Uint8Array&&(c.indexType="uint8")),delete c.data,delete c.byteOffset,this.device=e,this.id=a,this.props=c,this.usage=c.usage||0,this._debugDataEnabled=!!n,this._maxDebugDataByteLength=typeof n=="object"&&n.maxByteLength!==void 0?n.maxByteLength:Xc,this._ownsBuffer=i,this._buffer=o??this.device.createBuffer({...s,id:a}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),s.data&&this._writeDebugData(s.data,s.byteOffset||0)}write(e,t=0){this._buffer.write(e,t),this._touch(),this._writeDebugData(e,t)}async mapAndWriteAsync(e,t=0,n=this.byteLength-t){let o=null;await this._buffer.mapAndWriteAsync(async(i,s)=>{await e(i,s),o=new Uint8Array(i.slice(0,n))},t,n),this._touch(),o&&this._writeDebugData(o,t)}async readAsync(e=0,t=this.byteLength-e){let n=await this._buffer.readAsync(e,t);return this._writeDebugData(n,e)&&this._touch(),n}async mapAndReadAsync(e,t=0,n=this.byteLength-t){let o=null,i=await this._buffer.mapAndReadAsync(async(s,a)=>(o=new Uint8Array(s.slice(0)),await e(s,a)),t,n);return o&&this._writeDebugData(o,t)&&this._touch(),i}resize(e){let{byteLength:t,preserveData:n=!1}=e;if(t===this.byteLength)return!1;let o=Math.min(e.copyByteLength??Math.min(this.byteLength,t),this.byteLength,t),i=this._buffer,s=this.debugData.slice(0),{data:a,byteOffset:c,...u}=this.props,d=this.device.createBuffer({...u,byteLength:t});return n&&o>0&&this._copyBufferContents(i,d,o),this._buffer=d,this._resetDebugData(t),n&&s.byteLength>0&&this._writeDebugData(s,0),this._ownsBuffer&&i.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(e,t){return e<=this.byteLength?!1:this.resize({byteLength:e,preserveData:t?.preserveData})}getBinding(e){return e?.offset===void 0&&e?.size===void 0?this._buffer:{buffer:this._buffer,offset:e?.offset,size:e?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(e,t,n){let o=this.device.type==="webgpu"?Math.ceil(n/4)*4:n,i=this.device.createCommandEncoder();i.copyBufferToBuffer({sourceBuffer:e,destinationBuffer:t,size:o}),this.device.submit(i.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(e){if(!this._debugDataEnabled){this.debugData=new ArrayBuffer(0);return}this.debugData=new ArrayBuffer(Math.min(e,this._maxDebugDataByteLength))}_writeDebugData(e,t){if(!this._debugDataEnabled||this.debugData.byteLength===0||t>=this.debugData.byteLength)return!1;let n=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),o=new Uint8Array(this.debugData),i=Math.min(n.byteLength,o.byteLength-t);return o.set(n.subarray(0,i),t),i>0}};var io={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function ar(r){return r?Array.isArray(r)?r[0]??null:r:null}function $i(r){let{dimension:e,data:t}=r;if(!t)return null;switch(e){case"1d":{let n=ar(t);if(!n)return null;let{width:o}=cr(n);return{width:o,height:1}}case"2d":{if(ArrayBuffer.isView(t))return null;let n=ar(t);return n?cr(n):null}case"3d":case"2d-array":{if(!Array.isArray(t)||t.length===0)return null;let n=ar(t[0]);return n?cr(n):null}case"cube":{let n=Object.keys(t)[0]??null;if(!n)return null;let o=t[n],i=ar(o);return i?cr(i):null}case"cube-array":{if(!Array.isArray(t)||t.length===0)return null;let n=t[0],o=Object.keys(n)[0]??null;if(!o)return null;let i=ar(n[o]);return i?cr(i):null}default:return null}}function cr(r){if(sr(r))return $r(r);if(typeof r=="object"&&"width"in r&&"height"in r)return{width:r.width,height:r.height};throw new Error("Unsupported mip-level data")}function Zc(r){return typeof r=="object"&&r!==null&&"data"in r&&"width"in r&&"height"in r}function Kc(r){return ArrayBuffer.isView(r)}function so(r){let{textureFormat:e,format:t}=r;if(e&&t&&e!==t)throw new Error(`Conflicting texture formats "${e}" and "${t}" provided for the same mip level`);return e??t}function Fi(r){let e=io[r];if(e===void 0)throw new Error(`Invalid cube face: ${r}`);return e}function Qc(r,e){return 6*r+Fi(e)}function ao(r){throw new Error("setTexture1DData not supported in WebGL.")}function Jc(r){return Array.isArray(r)?r:[r]}function pt(r,e,t,n){let o=Jc(e),i=r,s=[];for(let a=0;a<o.length;a++){let c=o[a];if(sr(c))s.push({type:"external-image",image:c,z:i,mipLevel:a});else if(Zc(c))s.push({type:"texture-data",data:c,textureFormat:so(c),z:i,mipLevel:a});else if(Kc(c)&&t)s.push({type:"texture-data",data:{data:c,width:Math.max(1,t.width>>a),height:Math.max(1,t.height>>a),...n?{format:n}:{}},textureFormat:n,z:i,mipLevel:a});else throw new Error("Unsupported 2D mip-level payload")}return s}function co(r){let e=[];for(let t=0;t<r.length;t++)e.push(...pt(t,r[t]));return e}function uo(r){let e=[];for(let t=0;t<r.length;t++)e.push(...pt(t,r[t]));return e}function ho(r){let e=[];for(let[t,n]of Object.entries(r)){let o=Fi(t);e.push(...pt(o,n))}return e}function fo(r){let e=[];return r.forEach((t,n)=>{for(let[o,i]of Object.entries(t)){let s=Qc(n,o);e.push(...pt(s,i))}}),e}var Ke=class r{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;generation=0;updateTimestamp;resolveReady=()=>{};rejectReady=()=>{};get texture(){if(!this._texture)throw new Error("Texture not initialized yet");return this._texture}get sampler(){if(!this._sampler)throw new Error("Sampler not initialized yet");return this._sampler}get view(){if(!this._view)throw new Error("View not initialized yet");return this._view}get[Symbol.toStringTag](){return"DynamicTexture"}toString(){let e=this._texture?.width??this.props.width??"?",t=this._texture?.height??this.props.height??"?";return`DynamicTexture:"${this.id}":${e}x${t}px:(${this.isReady?"ready":"loading..."})`}resolveTextureBinding(e){return this.isReady?this.texture:null}constructor(e,t){this.device=e;let n=Ot("dynamic-texture"),o=t;this.props={...r.defaultProps,id:n,...t,data:null},this.id=this.props.id,this.ready=new Promise((i,s)=>{this.resolveReady=i,this.rejectReady=s}),this.updateTimestamp=this.device.incrementTimestamp(),this.initAsync(o)}async initAsync(e){try{let t=await this._loadAllData(e);this._checkNotDestroyed();let n=t.data?eu({...t,width:e.width,height:e.height,format:e.format}):[],o="format"in e&&e.format!==void 0,i="usage"in e&&e.usage!==void 0,a=(()=>{if(this.props.width&&this.props.height)return{width:this.props.width,height:this.props.height};let g=$i(t);return g||{width:this.props.width||1,height:this.props.height||1}})();if(!a||a.width<=0||a.height<=0)throw new Error(`${this} size could not be determined or was zero`);let c=tu(this.device,n,a,{format:o?e.format:void 0}),u=c.format??this.props.format,d={...this.props,...a,format:u,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(u)&&!i&&(d.usage=te.SAMPLE|te.COPY_DST);let h=this.props.mipmaps&&!c.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(u);if(this.device.type==="webgpu"&&h){let g=this.props.dimension==="3d"?te.SAMPLE|te.STORAGE|te.COPY_DST|te.COPY_SRC:te.SAMPLE|te.RENDER|te.COPY_DST|te.COPY_SRC;d.usage|=g}let f=this.device.getMipLevelCount(d.width,d.height),l=c.hasExplicitMipChain?c.mipLevels:this.props.mipLevels==="auto"?f:Math.max(1,Math.min(f,this.props.mipLevels??1)),m={...d,mipLevels:l};this._texture=this.device.createTexture(m),this._sampler=this.texture.sampler,this._view=this.texture.view,this._touchGeneration(),c.subresources.length&&this._setTextureSubresources(c.subresources),this.props.mipmaps&&!c.hasExplicitMipChain&&!h&&ge.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),h&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),ge.info(1,`${this} created`)()}catch(t){let n=t instanceof Error?t:new Error(String(t));this.rejectReady(n)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.isReady=!1,this.destroyed=!0}generateMipmaps(){this.device.type==="webgl"?(this.texture.generateMipmapsWebGL(),this._touch()):this.device.type==="webgpu"?(this.device.generateMipmapsWebGPU(this.texture),this._touch()):ge.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();let t=e instanceof Ze?e:this.device.createSampler(e);this.texture.setSampler(t),this._sampler=t,this._touchGeneration()}async readBuffer(e={}){this.isReady||await this.ready;let t=e.width??this.texture.width,n=e.height??this.texture.height,o=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:t,height:n,depthOrArrayLayers:o}),s=this.device.createBuffer({byteLength:i.byteLength,usage:Ee.COPY_DST|Ee.MAP_READ});this.texture.readBuffer({...e,width:t,height:n,depthOrArrayLayers:o},s);let a=this.device.createFence();return await a.signaled,a.destroy(),s}async readAsync(e={}){this.isReady||await this.ready;let t=e.width??this.texture.width,n=e.height??this.texture.height,o=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:t,height:n,depthOrArrayLayers:o}),s=await this.readBuffer(e),a=await s.readAsync(0,i.byteLength);return s.destroy(),a.buffer instanceof ArrayBuffer?a.buffer:a.slice().buffer}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;let t=this.texture;return this._texture=t.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,t.destroy(),this._touchGeneration(),ge.info(`${this} resized`),!0}getCubeFaceIndex(e){let t=io[e];if(t===void 0)throw new Error(`Invalid cube face: ${e}`);return t}getCubeArrayFaceIndex(e,t){return 6*e+this.getCubeFaceIndex(t)}setTexture1DData(e){if(this._checkReady(),this.texture.props.dimension!=="1d")throw new Error(`${this} is not 1d`);let t=ao(e);this._setTextureSubresources(t)}setTexture2DData(e,t=0){if(this._checkReady(),this.texture.props.dimension!=="2d")throw new Error(`${this} is not 2d`);let n=pt(t,e);this._setTextureSubresources(n)}setTexture3DData(e){if(this.texture.props.dimension!=="3d")throw new Error(`${this} is not 3d`);let t=co(e);this._setTextureSubresources(t)}setTextureArrayData(e){if(this.texture.props.dimension!=="2d-array")throw new Error(`${this} is not 2d-array`);let t=uo(e);this._setTextureSubresources(t)}setTextureCubeData(e){if(this.texture.props.dimension!=="cube")throw new Error(`${this} is not cube`);let t=ho(e);this._setTextureSubresources(t)}setTextureCubeArrayData(e){if(this.texture.props.dimension!=="cube-array")throw new Error(`${this} is not cube-array`);let t=fo(e);this._setTextureSubresources(t)}_setTextureSubresources(e){for(let t of e){let{z:n,mipLevel:o}=t;switch(t.type){case"external-image":let{image:i,flipY:s}=t;this.texture.copyExternalImage({image:i,z:n,mipLevel:o,flipY:s});break;case"texture-data":let{data:a,textureFormat:c}=t;if(c&&c!==this.texture.format)throw new Error(`${this} mip level ${o} uses format "${c}" but texture format is "${this.texture.format}"`);this.texture.writeData(a.data,{x:0,y:0,z:n,width:a.width,height:a.height,depthOrArrayLayers:1,mipLevel:o});break;default:throw new Error("Unsupported 2D mip-level payload")}}e.length>0&&this._touch()}async _loadAllData(e){let t=await lo(e.data);return{dimension:e.dimension??"2d",data:t??null}}_checkNotDestroyed(){this.destroyed&&ge.warn(`${this} already destroyed`)}_checkReady(){this.isReady||ge.warn(`${this} Cannot perform this operation before ready`)}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_touchGeneration(){this.generation++,this._touch()}static defaultProps={...te.defaultProps,dimension:"2d",data:null,mipmaps:!1}};function eu(r){if(!r.data)return[];let e=r.width&&r.height?{width:r.width,height:r.height}:void 0,t="format"in r?r.format:void 0;switch(r.dimension){case"1d":return ao(r.data);case"2d":return pt(0,r.data,e,t);case"3d":return co(r.data);case"2d-array":return uo(r.data);case"cube":return ho(r.data);case"cube-array":return fo(r.data);default:throw new Error(`Unhandled dimension ${r.dimension}`)}}function tu(r,e,t,n){if(e.length===0)return{subresources:e,mipLevels:1,format:n.format,hasExplicitMipChain:!1};let o=new Map;for(let d of e){let h=o.get(d.z)??[];h.push(d),o.set(d.z,h)}let i=e.some(d=>d.mipLevel>0),s=n.format,a=Number.POSITIVE_INFINITY,c=[];for(let[d,h]of o){let f=[...h].sort((M,w)=>M.mipLevel-w.mipLevel),l=f[0];if(!l||l.mipLevel!==0)throw new Error(`DynamicTexture: slice ${d} is missing mip level 0`);let m=Wi(r,l);if(m.width!==t.width||m.height!==t.height)throw new Error(`DynamicTexture: slice ${d} base level dimensions ${m.width}x${m.height} do not match expected ${t.width}x${t.height}`);let g=Vi(l);if(g){if(s&&s!==g)throw new Error(`DynamicTexture: slice ${d} base level format "${g}" does not match texture format "${s}"`);s=g}let x=s&&r.isTextureFormatCompressed(s)?ru(r,m.width,m.height,s):r.getMipLevelCount(m.width,m.height),T=0;for(let M=0;M<f.length;M++){let w=f[M];if(!w||w.mipLevel!==M||M>=x)break;let b=Wi(r,w),p=Math.max(1,m.width>>M),y=Math.max(1,m.height>>M);if(b.width!==p||b.height!==y)break;let S=Vi(w);if(S&&(s||(s=S),S!==s))break;T++,c.push(w)}a=Math.min(a,T)}let u=Number.isFinite(a)?Math.max(1,a):1;return{subresources:c.filter(d=>d.mipLevel<u),mipLevels:u,format:s,hasExplicitMipChain:i}}function Vi(r){if(r.type==="texture-data")return r.textureFormat??so(r.data)}function Wi(r,e){switch(e.type){case"external-image":return r.getExternalImageSize(e.image);case"texture-data":return{width:e.data.width,height:e.data.height};default:throw new Error("Unsupported texture subresource")}}function ru(r,e,t,n){let{blockWidth:o=1,blockHeight:i=1}=r.getTextureFormatInfo(n),s=1;for(let a=1;;a++){let c=Math.max(1,e>>a),u=Math.max(1,t>>a);if(c<o||u<i)break;s++}return s}async function lo(r){if(r=await r,Array.isArray(r))return await Promise.all(r.map(lo));if(r&&typeof r=="object"&&r.constructor===Object){let e=r,t=await Promise.all(Object.values(e).map(lo)),n=Object.keys(e),o={};for(let i=0;i<n.length;i++)o[n[i]]=t[i];return o}return r}var ur=X(V(),1),qi=/^vertex-list<([^<>]+)>$/,ji=/^value-list<([^<>]+)>$/,uu=/^fixed-size-list<([^<>,]+),([1-9][0-9]*)>$/;function Qe(r){return qi.test(r)}function Je(r){return ji.test(r)}function Yi(r){let e=qi.exec(r),t=ji.exec(r),o=Hi(r)?.elementFormat??e?.[1]??t?.[1]??r;try{ur.vertexFormatDecoder.getVertexFormatInfo(o)}catch{throw new Error(`Unsupported GPUVector format ${r}`)}return o}function D(r){let e=Yi(r),t=Qe(r),n=Je(r),o=Hi(r),i=ur.vertexFormatDecoder.getVertexFormatInfo(e),s=i.byteLength*(o?.listSize??1);if(!Number.isSafeInteger(s))throw new Error(`Unsupported GPUVector format ${r}`);let a=i.type,c=i.normalized,u=hu(a,c);return{format:r,elementFormat:e,vertexList:t,valueList:n,fixedSizeList:!!o,...o?{listSize:o.listSize}:{},type:a,signedDataType:fu(e,a),primitiveType:u,components:i.components,elementByteLength:i.byteLength,byteLength:s,integer:i.integer,signed:i.signed,normalized:c,...i.webglOnly?{webglOnly:!0}:{}}}function Hi(r){let e=uu.exec(r);if(!e)return;let t=Number(e[2]);if(!Number.isSafeInteger(t))return;let n=e[1];try{let o=ur.vertexFormatDecoder.getVertexFormatInfo(n);if(!Number.isSafeInteger(t*o.components)||!Number.isSafeInteger(t*o.byteLength))return}catch{return}return{elementFormat:n,listSize:t}}function hu(r,e){if(e)return"f32";switch(r){case"float32":return"f32";case"float16":return"f16";case"uint8":case"uint16":case"uint32":return"u32";case"sint8":case"sint16":case"sint32":return"i32";default:throw new Error(`Unsupported GPUVector component type ${r}`)}}function fu(r,e){if(r==="unorm10-10-10-2")return"uint32";switch(e){case"unorm8":return"uint8";case"snorm8":return"sint8";case"unorm16":return"uint16";case"snorm16":return"sint16";default:return e}}var po=X(V(),1),hr=class{buffer;format;length;byteOffset;byteStride;constructor(e){let t=po.vertexFormatDecoder.getVertexFormatInfo(e.format).byteLength,n=e.byteOffset??0,o=e.byteStride??t;if(mo(e.length,"GPUDataView length"),mo(n,"GPUDataView byteOffset"),mo(o,"GPUDataView byteStride"),o<t)throw new Error(`GPUDataView byteStride ${o} is smaller than ${e.format} byte length ${t}`);let i=e.length===0?0:(e.length-1)*o+t,s=n+i;if(!Number.isSafeInteger(i)||!Number.isSafeInteger(s))throw new Error("GPUDataView byte range must use safe integers");if(s>e.buffer.byteLength)throw new Error("GPUDataView exceeds its backing buffer byte length");this.buffer=e.buffer,this.format=e.format,this.length=e.length,this.byteOffset=n,this.byteStride=o}get elementByteLength(){return po.vertexFormatDecoder.getVertexFormatInfo(this.format).byteLength}get byteLength(){return this.length===0?0:(this.length-1)*this.byteStride+this.elementByteLength}};function mo(r,e){if(!Number.isSafeInteger(r)||r<0)throw new Error(`${e} must be a non-negative safe integer`)}var Dt=X(V(),1);function Vr(r){return!!(r&&typeof r=="object"&&r.type==="struct")}function Zi(r,e){let t=Object.entries(r);if(t.length===0)throw new Error("GPUData struct format must declare at least one field");return e==="packed"?du(t):lu(t)}function du(r){let e=[],t=0,n=0;for(let[o,i]of r){let s=Dt.vertexFormatDecoder.getVertexFormatInfo(i);if(s.webglOnly)throw new Error(`Packed GPUData struct field "${o}" uses WebGL-only format ${i}`);t=Xi(t,Math.min(4,s.byteLength)),e.push([o,Object.freeze({format:i,byteOffset:t,byteLength:s.byteLength})]),t+=s.byteLength,n+=s.components}return Object.freeze({type:"struct",layout:"packed",fields:Object.freeze(Object.fromEntries(e)),components:n,byteStride:Xi(t,4),rowByteLength:t})}function lu(r){let e=Object.fromEntries(r.map(([s,a])=>[s,mu(a)])),t=(0,Dt.makeShaderBlockLayout)(e,{layout:"wgsl-storage"}),n=[],o=0,i=0;for(let[s,a]of r){let c=Dt.vertexFormatDecoder.getVertexFormatInfo(a),u=t.fields[s].offset*4;n.push([s,Object.freeze({format:a,byteOffset:u,byteLength:c.byteLength})]),o=Math.max(o,u+c.byteLength),i+=c.components}return Object.freeze({type:"struct",layout:"wgsl-storage",fields:Object.freeze(Object.fromEntries(n)),components:i,byteStride:t.byteLength,rowByteLength:o})}function mu(r){let e=Dt.vertexFormatDecoder.getVertexFormatInfo(r);switch(e.type){case"float32":return Fr("f32",e.components);case"sint32":return Fr("i32",e.components);case"uint32":return Fr("u32",e.components);default:{let t=Math.ceil(e.byteLength/4);return Fr("u32",t)}}}function Fr(r,e){return e===1?r:`vec${e}<${r}>`}function Xi(r,e){return Math.ceil(r/e)*e}var go=class{buffer;ownsDataBuffer;constructor(e,t){this.buffer=e,this.ownsDataBuffer=t}get ownsBuffer(){return this.ownsDataBuffer}transferBufferOwnership(e){if(e.buffer!==this.buffer)throw new Error("GPUData ownership can only be transferred to the same buffer");e.ownsDataBuffer=this.ownsDataBuffer,this.ownsDataBuffer=!1}destroy(){this.ownsDataBuffer&&(this.buffer.destroy(),this.ownsDataBuffer=!1)}},xo=class extends go{dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;readbackMetadata;valueOffsets;nullBitmap;valueByteLength;constructor(e){let{buffer:t,format:n,length:o,valueLength:i,stride:s,byteOffset:a=0,byteStride:c,rowByteLength:u,ownsBuffer:d=!1,readbackMetadata:h,valueOffsets:f,nullBitmap:l,valueByteLength:m,dataType:g}=e;super(t,d);let x;n?typeof n=="string"?x=n:x=Zi(n,e.layout??"wgsl-storage"):x=void 0;let T=Vr(x)?x:void 0,M=typeof x=="string"?D(x):void 0;if(this.dataType=g,this.format=x,this.length=o,this.valueLength=i??o*(M?.listSize??1),this.stride=s??(M?M.components*(M.listSize??1):void 0)??T?.components??c??u??1,this.byteOffset=a,this.rowByteLength=u??T?.rowByteLength??M?.byteLength??c??this.stride,this.byteStride=c??T?.byteStride??this.rowByteLength,M?.fixedSizeList){let w=o*M.listSize;if(!Number.isSafeInteger(o)||o<0||!Number.isSafeInteger(w)||!Number.isSafeInteger(this.byteOffset)||this.byteOffset<0||!Number.isSafeInteger(this.byteStride)||!Number.isSafeInteger(this.rowByteLength)||!Number.isSafeInteger(this.stride))throw new Error("GPUData fixed-size-list row layout must use safe non-negative integers");if(this.valueLength!==w)throw new Error("GPUData fixed-size-list valueLength must equal its flattened row elements");if(this.stride<M.components*M.listSize)throw new Error("GPUData fixed-size-list stride cannot truncate its row components");if(this.rowByteLength<M.byteLength)throw new Error("GPUData fixed-size-list rowByteLength cannot truncate its row payload");if(this.byteStride<this.rowByteLength)throw new Error("GPUData fixed-size-list byteStride cannot overlap its row payload");let b=o===0?0:(o-1)*this.byteStride+this.rowByteLength,p=this.byteOffset+b;if(!Number.isSafeInteger(b)||!Number.isSafeInteger(p))throw new Error("GPUData fixed-size-list byte range must use safe integers");if(p>t.byteLength)throw new Error("GPUData fixed-size-list exceeds its backing buffer byte length")}if(T){if(this.rowByteLength<T.rowByteLength)throw new Error(`GPUData rowByteLength ${this.rowByteLength} is smaller than struct format row byte length ${T.rowByteLength}`);if(this.byteStride<Math.max(T.byteStride,this.rowByteLength))throw new Error(`GPUData byteStride ${this.byteStride} is smaller than its struct row layout`)}this.readbackMetadata=h,this.valueOffsets=f,this.nullBitmap=l,this.valueByteLength=m}getChild(e){if(!Vr(this.format))return null;let t=this.format.fields[e];return t?new hr({buffer:this.buffer,format:t.format,length:this.length,byteOffset:this.byteOffset+t.byteOffset,byteStride:this.byteStride}):null}getChildAt(e){if(!Vr(this.format))return null;let t=Object.values(this.format.fields)[e];return t?new hr({buffer:this.buffer,format:t.format,length:this.length,byteOffset:this.byteOffset+t.byteOffset,byteStride:this.byteStride}):null}},Gt=xo;function Ne(r){let e=0;return Object.freeze(r.map(t=>{let n=Object.freeze({offset:e,length:t.length,data:t});return e+=t.length,n}))}var Z=class{name;dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;bufferLayout;data=[];device;bufferProps;isAppendable=!1;ownsDataChunks=!0;ownedVectors=[];appendableByteLength=0;get chunks(){return Ne(this.data)}constructor(e){switch(e.type){case"buffer":{let{name:t,buffer:n,format:o,length:i,valueLength:s,byteOffset:a=0,ownsBuffer:c=!1}=e,{stride:u,byteStride:d,rowByteLength:h,listSize:f}=Ki(e),l=s??i*(f??1);this.name=t,this.dataType=e.dataType,this.format=o,this.length=i,this.valueLength=l,this.stride=u,this.byteOffset=a,this.byteStride=d,this.rowByteLength=h,this.data.push(new Gt({buffer:n,format:o,length:i,valueLength:l,stride:u,byteOffset:a,byteStride:d,rowByteLength:h,ownsBuffer:c,dataType:e.dataType}));return}case"interleaved":{let{name:t,buffer:n,format:o,length:i,valueLength:s,byteOffset:a=0,byteStride:c,attributes:u,ownsBuffer:d=!1}=e,h=o?D(o):void 0,f=s??i*(h?.listSize??1),l=h?.fixedSizeList?h.components*h.listSize:c,m=h?.fixedSizeList?h.byteLength:c;this.name=t,this.dataType=e.dataType,this.format=o,this.length=i,this.valueLength=f,this.stride=l,this.byteOffset=a,this.byteStride=c,this.rowByteLength=m,this.bufferLayout={name:t,byteStride:c,attributes:u},this.data.push(new Gt({buffer:n,format:o,length:i,valueLength:f,stride:l,byteOffset:a,byteStride:c,rowByteLength:m,ownsBuffer:d,dataType:e.dataType}));return}case"data":{let t=e.format??pu(e.data),n=t?D(t):void 0,{name:o,data:i,stride:s=i[0]?.stride??(n?n.components*(n.listSize??1):1),valueLength:a=i.reduce((f,l)=>f+l.valueLength,0),byteStride:c=i[0]?.byteStride??n?.byteLength,rowByteLength:u=i[0]?.rowByteLength??n?.byteLength,bufferLayout:d,ownsData:h=!1}=e;if(c===void 0||u===void 0)throw new Error("GPUVector requires format or explicit byte layout metadata");t&&gu(i,t),this.name=o,this.dataType=e.dataType,this.format=t,this.length=i.reduce((f,l)=>f+l.length,0),this.valueLength=a,this.stride=s,this.byteOffset=i.length===1?i[0].byteOffset:0,this.byteStride=c,this.rowByteLength=u,this.bufferLayout=d,this.ownsDataChunks=h,this.data.push(...i);return}case"appendable":{let{name:t,device:n,format:o,valueLength:i=0,bufferProps:s}=e,{stride:a,byteStride:c,rowByteLength:u}=Ki(e);this.name=t,this.dataType=e.dataType,this.format=o,this.length=0,this.valueLength=i,this.stride=a,this.byteOffset=0,this.byteStride=c,this.rowByteLength=u,this.device=n,this.bufferProps=s,this.isAppendable=!0;return}}}get ownsBuffer(){return this.ownsDataChunks&&this.data.some(e=>e.ownsBuffer)||this.ownedVectors.some(e=>e.ownsBuffer)}get capacityRows(){return this.isAppendable?this.length:void 0}get appendedByteLength(){return this.appendableByteLength}addData(e){if(this.format&&e.format!==this.format)throw new Error("GPUVector.addData() requires matching formats");if(e.byteStride!==this.byteStride)throw new Error("GPUVector.addData() requires matching byteStride");if(e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.addData() requires matching rowByteLength");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this}appendDataChunk(e,t=this.appendableByteLength+e.buffer.byteLength){if(!this.isAppendable)throw new Error("GPUVector.appendDataChunk() requires appendable vector storage");if(this.format&&e.format!==this.format)throw new Error("GPUVector.appendDataChunk() requires matching formats");if(e.byteStride!==this.byteStride||e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.appendDataChunk() requires matching byte layout metadata");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this.appendableByteLength=t,this}resetLastBatch(){if(!this.isAppendable)throw new Error("GPUVector.resetLastBatch() requires appendable vector storage");for(let e of this.data.splice(0))e.destroy();return this.length=0,this.valueLength=0,this.appendableByteLength=0,this}retainOwnedVectors(e){return this.ownedVectors.push(...e),this}transferBufferOwnership(e){let t=this.data[0],n=e.data[0];if(!t||!n||t.buffer!==n.buffer)throw new Error("GPUVector ownership can only be transferred to the same buffer");t.transferBufferOwnership(n)}destroy(){if(this.ownsDataChunks)for(let e of this.data)e.destroy();for(let e of this.ownedVectors.splice(0))e.destroy()}};function Ki(r){let e=r.format?D(r.format):void 0,t=r.rowByteLength??(e?.fixedSizeList?e.byteLength:r.byteStride)??e?.byteLength;if(t===void 0)throw new Error("GPUVector requires format or explicit rowByteLength");return{stride:r.stride??(e?e.components*(e.listSize??1):1),byteStride:r.byteStride??t,rowByteLength:t,...e?.listSize?{listSize:e.listSize}:{}}}function pu(r){return r[0]?.format}function gu(r,e){if(r.find(n=>n.format!==e))throw new Error("GPUVector data chunks must share the declared format")}var yo=X(V(),1);var fr=class{compare;values=[];constructor(e){this.compare=e}peek(){return this.values[0]}push(e){let t=this.values.length;for(this.values.push(e);t>0;){let n=Math.floor((t-1)/2);if(this.compare(this.values[n],e)<=0)break;this.values[t]=this.values[n],t=n}this.values[t]=e}pop(){let e=this.values[0],t=this.values.pop();if(this.values.length&&t!==void 0){let n=0;for(;n*2+1<this.values.length;){let o=n*2+1;if(o+1<this.values.length&&this.compare(this.values[o+1],this.values[o])<0&&o++,this.compare(t,this.values[o])<=0)break;this.values[n]=this.values[o],n=o}this.values[n]=t}return e}};var dr=X(V(),1);function rs(r){let e=ss(r.nodes),t=as(e,r.buffers.values()),n=cs(e,r.textures.values()),o=new Map,i=new Map,s=[];try{for(let a of t){a.buffer=r.device.createBuffer({id:`${r.id}-transient-buffer-${t.indexOf(a)}`,byteLength:a.byteLength,usage:a.usage});for(let c of a.handles)o.set(c,a.buffer)}for(let a of n){a.texture=r.device.createTexture({...a.descriptor,id:`${r.id}-transient-texture-${n.indexOf(a)}`});for(let c of a.handles)i.set(c,a.texture)}for(let a of e)s.push({node:a,executable:a.compile({device:r.device})})}catch(a){for(let c of s)c.executable.destroy?.();for(let c of t)c.buffer?.destroy();for(let c of n)c.texture?.destroy();throw a}return os(r,e,s,o,i,t,n)}async function ns(r){let e=ss(r.nodes),t=as(e,r.buffers.values()),n=cs(e,r.textures.values()),o=new Map,i=new Map;try{for(let l of t){l.buffer=r.device.createBuffer({id:`${r.id}-transient-buffer-${t.indexOf(l)}`,byteLength:l.byteLength,usage:l.usage});for(let m of l.handles)o.set(m,l.buffer)}for(let l of n){l.texture=r.device.createTexture({...l.descriptor,id:`${r.id}-transient-texture-${n.indexOf(l)}`});for(let m of l.handles)i.set(m,l.texture)}let s=dr.PipelineFactory.beginAsyncCompilation(r.device),a=e.map(async l=>({node:l,executable:l.compileAsync?await l.compileAsync({device:r.device}):l.compile({device:r.device})}));dr.PipelineFactory.endAsyncCompilation(r.device,s);let[c,u]=await Promise.all([Promise.allSettled(a),Promise.allSettled(s)]),d=[],h=u.find(l=>l.status==="rejected"),f=h?.status==="rejected"?h.reason:void 0;for(let l of c)l.status==="fulfilled"?d.push(l.value):f??=l.reason;if(f){for(let l of d)l.executable.destroy?.();throw f}return os(r,e,d,o,i,t,n)}catch(s){for(let a of t)a.buffer?.destroy();for(let a of n)a.texture?.destroy();throw s}}function os(r,e,t,n,o,i,s){let a=Array.from(r.buffers.values()),c=a.filter(E=>!E.transient),u=a.filter(E=>E.transient),d=Nt(c.map(E=>E.byteLength),"imported buffer capacities"),h=Nt(u.map(E=>E.byteLength),"logical transient buffer capacities"),f=gt(d,h,"logical buffer capacities"),l=Nt(i.map(E=>E.byteLength),"physical transient buffer capacities"),m=Math.max(0,h-l),g=Array.from(r.textures.values()),x=g.filter(E=>!E.transient),T=g.filter(E=>E.transient),M=Nt(x.map(Mo),"imported texture estimates"),w=Nt(T.map(Mo),"logical transient texture estimates"),b=gt(M,w,"logical texture estimates"),p=Nt(s.map(E=>E.byteLength),"physical transient texture estimates"),y=Math.max(0,w-p),S={nodeOrder:e.map(E=>E.id),importedBufferCount:c.length,importedBufferBytes:d,logicalBufferCount:a.length,logicalBufferBytes:f,logicalTransientBufferCount:u.length,physicalTransientBufferCount:i.length,logicalTransientBytes:h,physicalTransientBytes:l,reusedTransientBytes:m,reusePercentage:h>0?m/h*100:0,importedTextureCount:x.length,importedTextureBytes:M,logicalTextureCount:g.length,logicalTextureBytes:b,logicalTransientTextureCount:T.length,physicalTransientTextureCount:s.length,logicalTransientTextureBytes:w,physicalTransientTextureBytes:p,reusedTransientTextureBytes:y,textureReusePercentage:w>0?y/w*100:0,logicalResourceBytes:gt(f,b,"logical resource estimates"),physicalTransientResourceBytes:gt(l,p,"physical transient resource estimates")},P=yu(r.device,a,e);return{device:r.device,id:r.id,buffers:new Map(r.buffers),textures:new Map(r.textures),externalTextures:new Map(r.externalTextures),compiledNodes:t,transientBuffers:n,transientTextures:o,bufferTransientAllocations:i,textureTransientAllocations:s,stats:S,preflight:P}}function xu(r){if("buffer"in r){let t=r.buffer,n="buffer"in t?t:void 0;return Object.freeze({id:n?n.buffer.id:t.id,kind:"buffer",usage:r.usage,byteOffset:n?.byteOffset??0,byteLength:n?n.length===0?0:(n.length-1)*n.byteStride+n.rowByteLength:t.byteLength,...n?{format:n.format,length:n.length}:{}})}let e="texture"in r?r.texture:r.externalTexture;return Object.freeze({id:"texture"in e?e.texture.id:e.id,kind:"externalTexture"in r?"external-texture":"texture",usage:r.usage,width:e.width,height:e.height,..."texture"in e?{baseMipLevel:e.baseMipLevel,baseArrayLayer:e.baseArrayLayer,mipLevelCount:e.mipLevelCount,arrayLayerCount:e.arrayLayerCount,aspect:e.aspect}:{},..."format"in e?{format:e.format,depth:e.depth}:{}})}function yu(r,e,t){let n=t.map(a=>{let c=a.workload??{};return Object.freeze({id:a.id,...a.description===void 0?{}:{description:a.description},type:a.type,resources:Object.freeze((a.resources??[]).map(xu)),...c.operation?{operation:c.operation}:{},...c.variant?{variant:c.variant}:{},...a.publication?{publication:Object.freeze({...a.publication})}:{},...a.condition?{condition:Object.freeze(a.condition.source==="cpu"?{id:a.condition.id,source:"cpu",mode:"skip"}:{id:a.condition.id,source:"gpu",mode:"indirect",bufferId:a.condition.buffer.id,byteOffset:a.condition.byteOffset??0})}:{},commandCount:c.commandCount??0,maximumWorkgroupCount:c.maximumWorkgroupCount??0,maximumInvocationCount:c.maximumInvocationCount??0,readByteLength:c.readByteLength??0,writeByteLength:c.writeByteLength??0})}),o=e.reduce((a,c)=>Math.max(a,c.byteLength),0),i=t.reduce((a,c)=>{for(let u of c.resources??[])et(u)&&(u.usage==="storage-read"||u.usage==="storage-write"||u.usage==="storage-read-write")&&(a=Math.max(a,wo(u.buffer).size));return a},0),s=a=>n.reduce((c,u)=>{let d=u[a];return typeof d=="number"?gt(c,d,"workload estimates"):c},0);return Object.freeze({nodes:Object.freeze(n),annotatedNodeCount:t.filter(a=>a.workload!==void 0).length,conditionalNodeCount:t.filter(a=>a.condition!==void 0).length,commandCount:s("commandCount"),maximumWorkgroupCount:s("maximumWorkgroupCount"),maximumInvocationCount:s("maximumInvocationCount"),readByteLength:s("readByteLength"),writeByteLength:s("writeByteLength"),largestBufferByteLength:o,largestStorageBufferBindingByteLength:i,maxBufferByteLength:r.limits.maxBufferSize,maxStorageBufferBindingByteLength:r.limits.maxStorageBufferBindingSize,fitsDeviceLimits:o<=r.limits.maxBufferSize&&i<=r.limits.maxStorageBufferBindingSize})}function ye(r){return"buffer"in r?r.buffer:r}function _e(r){return"texture"in r?r.texture:r}function et(r){return"buffer"in r}function lr(r){return"texture"in r}function is(r){if(r.type==="copy")return;let e=(r.resources??[]).filter(t=>et(t)&&(t.usage==="storage-read"||t.usage==="storage-write"||t.usage==="storage-read-write"));for(let t=0;t<e.length;t++){let n=e[t];for(let o=t+1;o<e.length;o++){let i=e[o];if(n.buffer===i.buffer||ye(n.buffer)!==ye(i.buffer)||!To(n.usage)&&!To(i.usage))continue;let s=wo(n.buffer),a=wo(i.buffer);if(s.offset<a.offset+a.size&&a.offset<s.offset+s.size){let c=ye(n.buffer);throw new Error(`GPUCommandGraph node "${r.id}" has overlapping writable storage bindings for buffer "${c.id}" (${Qi(s)} and ${Qi(a)}). Bind the shared range once or align the views to non-overlapping storage binding ranges.`)}}}}function wo(r){if(!("buffer"in r))return{offset:0,size:r.byteLength};let e=256,t=Math.floor(r.byteOffset/e)*e,n=r.byteOffset-t,o=r.length===0?r.rowByteLength:(r.length-1)*r.byteStride+r.rowByteLength;return{offset:t,size:n+Math.max(o,r.rowByteLength)}}function Qi(r){return`${r.offset}\u2013${r.offset+r.size} bytes`}function bu(r){return r==="storage-read"||r==="storage-read-write"||r==="uniform"||r==="copy-source"||r==="indirect"||r==="vertex"||r==="index"}function To(r){return r==="storage-write"||r==="storage-read-write"||r==="copy-destination"}function Ji(r){return r==="sampled"||r==="storage-read"||r==="storage-read-write"||r==="render-attachment"||r==="copy-source"}function bo(r){return r==="storage-write"||r==="storage-read-write"||r==="render-attachment"||r==="copy-destination"}function ss(r){let e=new Map(r.map(h=>[h.id,h])),t=new Map,n=new Map,o=new Map,i=new Map;for(let h of r){let f=new Set(h.dependsOn??[]);for(let l of f)if(!e.has(l))throw new Error(`GPUCommandGraph node "${h.id}" depends on missing node "${l}"`);for(let l of h.resources??[])if(et(l)){let m=ye(l.buffer);if(bu(l.usage)){let g=n.get(m);g&&f.add(g);let x=o.get(m)??new Set;x.add(h.id),o.set(m,x)}if(To(l.usage)){let g=n.get(m);g&&f.add(g);for(let x of o.get(m)??[])x!==h.id&&f.add(x);o.set(m,new Set),n.set(m,h.id)}}else if(lr(l)){let m=_e(l.texture),g=i.get(m)??[];for(let x of g)x.nodeId!==h.id&&wu(x.resource,l)&&(Ji(l.usage)&&bo(x.resource.usage)||bo(l.usage)&&(Ji(x.resource.usage)||bo(x.resource.usage)))&&f.add(x.nodeId);g.push({nodeId:h.id,resource:l}),i.set(m,g)}f.delete(h.id),t.set(h.id,f)}let s=r.map(()=>[]),a=new Map(r.map((h,f)=>[h.id,f])),c=r.map(h=>t.get(h.id).size);for(let[h,f]of r.entries())for(let l of t.get(f.id))s[a.get(l)].push(h);let u=c.flatMap((h,f)=>h===0?[f]:[]),d=[];for(;u.length;){let h=[];for(let f of u){d.push(r[f]);for(let l of s[f])--c[l]===0&&h.push(l)}u=h.sort((f,l)=>f-l)}if(d.length!==r.length)throw new Error("GPUCommandGraph contains a dependency cycle");return d}function wu(r,e){let t=_e(r.texture),n=_e(e.texture);if(t!==n)return!1;let o=es(r.texture),i=es(e.texture);return Tu(o.aspect,i.aspect)&&ts(o.baseMipLevel,o.mipLevelCount,i.baseMipLevel,i.mipLevelCount)&&ts(o.baseArrayLayer,o.arrayLayerCount,i.baseArrayLayer,i.arrayLayerCount)}function es(r){return"texture"in r?r:{aspect:"all",baseMipLevel:0,mipLevelCount:r.mipLevels,baseArrayLayer:0,arrayLayerCount:r.dimension==="3d"?1:r.depth}}function Tu(r,e){return r==="all"||e==="all"||r===e}function ts(r,e,t,n){return r<t+n&&t<r+e}function as(r,e){let t=us(r,a=>et(a)?ye(a.buffer):null),n=[],o=Array.from(e).filter(a=>a.transient).map(a=>({buffer:a,lifetime:t.get(a)})).sort((a,c)=>(a.lifetime?.firstUse??Number.MAX_SAFE_INTEGER)-(c.lifetime?.firstUse??Number.MAX_SAFE_INTEGER)),i=new fr((a,c)=>a.allocation.lastUse-c.allocation.lastUse||a.index-c.index),s=new fr((a,c)=>a.allocation.byteLength-c.allocation.byteLength||a.index-c.index);for(let{buffer:a,lifetime:c}of o){if(!c)continue;for(;i.peek()&&i.peek().allocation.lastUse<c.firstUse;)s.push(i.pop());let u=s.pop();u||(u={allocation:{byteLength:0,usage:0,lastUse:-1,handles:[]},index:n.length},n.push(u.allocation));let{allocation:d}=u;d.byteLength=Math.max(d.byteLength,a.byteLength),d.usage|=a.usage,d.lastUse=c.lastUse,d.handles.push(a),i.push(u)}return n}function cs(r,e){let t=us(r,i=>lr(i)?_e(i.texture):null),n=[],o=Array.from(e).filter(i=>i.transient).map(i=>({texture:i,lifetime:t.get(i)})).sort((i,s)=>(i.lifetime?.firstUse??Number.MAX_SAFE_INTEGER)-(s.lifetime?.firstUse??Number.MAX_SAFE_INTEGER));for(let{texture:i,lifetime:s}of o){if(!s)continue;let a=n.find(c=>c.lastUse<s.firstUse&&Eu(c.descriptor,i));a||(a={descriptor:Mu(i),byteLength:Mo(i),lastUse:-1,handles:[]},n.push(a)),a.descriptor.usage|=i.usage,a.lastUse=s.lastUse,a.handles.push(i)}return n}function us(r,e){let t=new Map;return r.forEach((n,o)=>{for(let i of n.resources??[]){let s=e(i);if(!s||!("transient"in s)||!s.transient)continue;let a=t.get(s);a?a.lastUse=o:t.set(s,{firstUse:o,lastUse:o})}}),t}function Mu(r){return{id:r.id,format:r.format,width:r.width,height:r.height,usage:r.usage,dimension:r.dimension,depth:r.depth,mipLevels:r.mipLevels,samples:r.samples}}function Eu(r,e){return r.format===e.format&&r.width===e.width&&r.height===e.height&&r.dimension===e.dimension&&r.depth===e.depth&&r.mipLevels===e.mipLevels&&r.samples===e.samples}function Mo(r){let e=0;for(let n=0;n<r.mipLevels;n++)e=gt(e,dr.textureFormatDecoder.computeMemoryLayout({format:r.format,width:Math.max(1,r.width>>n),height:r.dimension==="1d"?1:Math.max(1,r.height>>n),depth:r.dimension==="3d"?Math.max(1,r.depth>>n):r.depth,byteAlignment:1}).byteLength,`texture "${r.id}" mip estimates`);let t=e*r.samples;if(!Number.isSafeInteger(t))throw new Error(`GPUCommandGraph texture "${r.id}" byte estimate exceeds safe integer range`);return t}function gt(r,e,t){let n=r+e;if(!Number.isSafeInteger(n))throw new Error(`GPUCommandGraph ${t} exceed safe integer range`);return n}function Nt(r,e){return r.reduce((t,n)=>gt(t,n,e),0)}var Ue=class{id;byteLength;usage;transient;graph;defaultBuffer;constructor(e,t,n,o){this.graph=e,this.id=t.id,this.byteLength=t.byteLength,this.usage=t.usage,this.transient=n,this.defaultBuffer=o}},Ce=class{buffer;format;length;byteOffset;byteStride;rowByteLength;constructor(e,t){this.buffer=e,this.format=t.format,this.length=t.length,this.byteOffset=t.byteOffset,this.byteStride=t.byteStride,this.rowByteLength=t.rowByteLength}},_=class{chunks;id;name;format;length;valueLength;stride;byteStride;rowByteLength;data;constructor(e){if(this.id=e.id,this.name=e.name,this.format=e.format,this.length=e.length,this.valueLength=e.valueLength,this.stride=e.stride,this.byteStride=e.byteStride,this.rowByteLength=e.rowByteLength,e.data.some(t=>t.format!==e.format)||e.data.reduce((t,n)=>t+n.length,0)!==e.length)throw new Error(`${e.id} length must equal its ordered source chunks, with matching formats`);this.data=Object.freeze([...e.data]),this.chunks=Ne(this.data)}},be=class{id;format;width;height;usage;dimension;depth;mipLevels;samples;transient;frameScoped;graph;defaultTexture;constructor(e,t,n,o,i=!1){this.graph=e,this.id=t.id,this.format=t.format,this.width=t.width,this.height=t.height,this.usage=t.usage,this.dimension=t.dimension,this.depth=t.depth,this.mipLevels=t.mipLevels,this.samples=t.samples,this.transient=n,this.frameScoped=i,this.defaultTexture=o}},tt=class{id;width;height;graph;constructor(e,t){this.graph=e,this.id=t.id,this.width=t.width,this.height=t.height}},ke=class{texture;format;dimension;aspect;baseMipLevel;mipLevelCount;baseArrayLayer;arrayLayerCount;width;height;depth;constructor(e,t){this.texture=e,this.format=e.format,this.dimension=t.dimension,this.aspect=t.aspect,this.baseMipLevel=t.baseMipLevel,this.mipLevelCount=t.mipLevelCount,this.baseArrayLayer=t.baseArrayLayer,this.arrayLayerCount=t.arrayLayerCount,this.width=t.width,this.height=t.height,this.depth=t.depth}};function Eo(r,e){switch(e.type){case"compute":{let{type:t,...n}=e;r.addComputePass(n);return}case"render":{let{type:t,...n}=e;r.addRenderPass(n);return}case"copy":{let{type:t,...n}=e;r.addCopyPass(n);return}}}function ze(r,e){for(let t of e)Eo(r,t)}function q(r){return{...r,type:"compute"}}var Su=4,_t=class{nodeCount;budget;plan;encodeNodeRange;nextStepIndex=0;currentPublishedProgress=0;constructor(e){ps(e.budget),this.plan=e.plan,this.nodeCount=e.plan.nodeCount,this.budget=Object.freeze({...e.budget}),this.encodeNodeRange=e.encodeNodeRange}get completed(){return this.nextStepIndex>=this.plan.stepCount}get progress(){return this.plan.stepCount===0?1:this.nextStepIndex/this.plan.stepCount}get publishedProgress(){return this.currentPublishedProgress}encodeNext(e,t){if(this.completed)throw new Error("GPUCommandGraph execution has already completed");let n=this.plan.steps[this.nextStepIndex],o=this.encodeNodeRange(e,t,n.firstNodeIndex,n.nextNodeIndex);return this.nextStepIndex++,n.publishable&&(this.currentPublishedProgress=this.progress),{...n,encoding:o,progress:this.progress,completed:this.completed,publishedProgress:this.publishedProgress}}};function qr(r,e,t={}){ps(e);let n=t.latencyPriority??"normal",o=t.publicationPolicy??"final";if(!["interactive","normal","background"].includes(n))throw new Error(`GPUCommandGraph execution latency priority "${n}" is invalid`);if(!["final","progressive"].includes(o))throw new Error(`GPUCommandGraph execution publication policy "${o}" is invalid`);let i=r.nodes,s=[],a=0;for(;a<i.length;){let u=a,d=hs();for(;a<i.length;){let l=fs(d,i[a]);if(a>u&&ds(l,e)||(d=l,a++,o==="progressive"&&i[a-1].publication)||Pu(d,e))break}let h=Object.freeze(o==="progressive"?i.slice(u,a).flatMap(l=>l.publication?[l.publication]:[]):[]),f=a===i.length;s.push(Object.freeze({stepIndex:s.length,firstNodeIndex:u,nextNodeIndex:a,...d,exceedsBudget:ds(d,e),latencyPriority:n,publications:h,publishable:f||h.length>0}))}let c=i.reduce((u,d)=>fs(u,d),hs());return Object.freeze({...c,annotatedNodeCount:r.annotatedNodeCount,stepCount:s.length,oversizedStepCount:s.filter(u=>u.exceedsBudget).length,latencyPriority:n,publicationPolicy:o,publicationCount:s.reduce((u,d)=>u+d.publications.length,0),steps:Object.freeze(s)})}function hs(){return{nodeCount:0,commandCount:0,maximumInvocationCount:0,readByteLength:0,writeByteLength:0,conditionalNodeCount:0}}function fs(r,e){return{nodeCount:r.nodeCount+1,commandCount:r.commandCount+e.commandCount,maximumInvocationCount:r.maximumInvocationCount+e.maximumInvocationCount,readByteLength:r.readByteLength+e.readByteLength,writeByteLength:r.writeByteLength+e.writeByteLength,conditionalNodeCount:r.conditionalNodeCount+(e.condition?1:0)}}function ds(r,e){return r.maximumInvocationCount>e.maximumInvocationCount||e.maximumNodeCount!==void 0&&r.nodeCount>e.maximumNodeCount||e.maximumCommandCount!==void 0&&r.commandCount>e.maximumCommandCount||e.maximumReadByteLength!==void 0&&r.readByteLength>e.maximumReadByteLength||e.maximumWriteByteLength!==void 0&&r.writeByteLength>e.maximumWriteByteLength}function Pu(r,e){return r.maximumInvocationCount>=e.maximumInvocationCount||e.maximumNodeCount!==void 0&&r.nodeCount>=e.maximumNodeCount||e.maximumCommandCount!==void 0&&r.commandCount>=e.maximumCommandCount||e.maximumReadByteLength!==void 0&&r.readByteLength>=e.maximumReadByteLength||e.maximumWriteByteLength!==void 0&&r.writeByteLength>=e.maximumWriteByteLength}function ps(r){let e=[["maximumInvocationCount",r.maximumInvocationCount],["maximumNodeCount",r.maximumNodeCount],["maximumCommandCount",r.maximumCommandCount],["maximumReadByteLength",r.maximumReadByteLength],["maximumWriteByteLength",r.maximumWriteByteLength]];for(let[t,n]of e)if(n!==void 0&&(!Number.isSafeInteger(n)||n<=0))throw new Error(`GPUCommandGraph execution ${t} must be a positive safe integer`)}function Cu(r,e,t,n){let o=0;return{computePass:new Proxy(r,{get(s,a){if(a==="dispatch")return()=>{if(o>0)throw new Error(`GPUCommandGraph GPU-conditional compute node "${n}" must encode exactly one dispatch`);o++,s.dispatchIndirect(e,t)};if(a==="dispatchIndirect")return()=>{throw new Error(`GPUCommandGraph GPU-conditional compute node "${n}" must use dispatch(); the graph supplies its indirect command`)};let c=Reflect.get(s,a,s);return typeof c=="function"?c.bind(s):c}}),assertDispatched:()=>{if(o!==1)throw new Error(`GPUCommandGraph GPU-conditional compute node "${n}" must encode exactly one dispatch`)}}}var Ut=class{readResource;stats;canReadGPUTimings;nodes;constructor(e,t,n=e.filter(a=>a.stats.type==="compute"&&a.stats.condition?.outcome!=="skipped").length,o,i,s){this.readResource=s,this.nodes=e,this.canReadGPUTimings=e.some(u=>u.timestamp!==void 0);let a=e.filter(u=>u.stats.condition?.outcome!=="skipped"),c=a.filter(u=>u.stats.type==="compute").length;this.stats={cpuEncodeTimeMilliseconds:t,cpuEncodeStartTimeMilliseconds:o,cpuEncodeEndTimeMilliseconds:i,nodeCount:a.length,skippedNodeCount:e.length-a.length,computePassCount:n,coalescedComputeNodeCount:c-n,timestampedNodeCount:e.filter(u=>u.timestamp!==void 0).length,nodes:e.map(u=>u.stats)}}async readTimings(){let e=await Promise.all(this.nodes.map(async({stats:s,timestamp:a})=>{if(!a)return{...s};let{querySet:c,snapshot:u,beginIndex:d,endIndex:h}=a;if(c.device.type!=="webgpu")return{...s,gpuTimeMilliseconds:await c.readTimestampDuration(d,h)};let f=await(u??c).readResults({firstQuery:d,queryCount:h-d+1}),l=f[0],m=f[f.length-1];return{...s,gpuStartTimeMilliseconds:Number(l)/1e6,gpuEndTimeMilliseconds:Number(m)/1e6,gpuTimeMilliseconds:Number(m-l)/1e6}})),t=e.filter(s=>s.gpuTimeMilliseconds!==void 0),n=e.filter(s=>s.gpuStartTimeMilliseconds!==void 0),i=this.nodes.flatMap(s=>s.timestamp?.snapshot?.clockCorrelation?[s.timestamp.snapshot.clockCorrelation]:[]).sort((s,a)=>s.uncertaintyMilliseconds-a.uncertaintyMilliseconds)[0];return{...i?{clockCorrelation:i}:{},cpuEncodeStartTimeMilliseconds:this.stats.cpuEncodeStartTimeMilliseconds,cpuEncodeEndTimeMilliseconds:this.stats.cpuEncodeEndTimeMilliseconds,...n.length>0?{gpuStartTimeMilliseconds:Math.min(...n.map(s=>s.gpuStartTimeMilliseconds)),gpuEndTimeMilliseconds:Math.max(...n.map(s=>s.gpuEndTimeMilliseconds))}:{},cpuEncodeTimeMilliseconds:this.stats.cpuEncodeTimeMilliseconds,...t.length>0?{gpuTimeMilliseconds:t.reduce((s,a)=>s+(a.gpuTimeMilliseconds??0),0)}:{},nodes:e}}},xt=class{device;id;autotuner;buffers=new Map;textures=new Map;externalTextures=new Map;importedBufferHandles=new Map;dynamicBufferHandles=new Map;nodes=[];nodeIds=new Set;compiled=!1;constructor(e,t={}){if(e.type!=="webgpu")throw new Error("GPUCommandGraph requires a WebGPU device");Wr(e,"construction"),this.device=e,this.id=t.id??"gpu-command-graph",this.autotuner=t.autotuner}importBuffer(e,t){this.assertMutable(),ms(e,this.device),t&&gs(t,e,this.device);let n=this.addBuffer(new Ue(this,e,!1,t));if(t){let o=gr(t);this.importedBufferHandles.has(o)||this.importedBufferHandles.set(o,n),t instanceof xe&&!this.dynamicBufferHandles.has(t)&&this.dynamicBufferHandles.set(t,n)}return n}createTransientBuffer(e){return this.assertMutable(),ms(e,this.device),this.addBuffer(new Ue(this,e,!0))}createDataView(e,t){this.assertBuffer(e);let n=D(t.format),o=t.byteOffset??0,i=t.rowByteLength??n.byteLength,s=t.byteStride??i;return Iu(e,{length:t.length,byteOffset:o,byteStride:s,rowByteLength:i}),new Ce(e,{format:t.format,length:t.length,byteOffset:o,byteStride:s,rowByteLength:i})}importGPUData(e,t){return this.importGPUDataView(e,t)}importGPUVector(e,t){if(t.bufferLayout)throw new Error(`GPUCommandGraph import "${e}" does not accept interleaved GPUVector data`);let n=t.format??t.data[0]?.format;if(!n)throw new Error(`GPUCommandGraph import "${e}" requires GPUVector.format`);if(Qe(n)||Je(n))throw new Error(`GPUCommandGraph import "${e}" requires a fixed-width GPUVector format`);let o=D(n),i=t.data.map((s,a)=>{if(s.format!==n)throw new Error(`GPUCommandGraph import "${e}" requires matching GPUVector chunk formats`);let c=t.data.length===1?e:`${e}-chunk-${a}`;return this.importGPUDataView(c,s)});return new _({id:e,name:t.name??e,format:n,length:t.length,valueLength:t.valueLength??t.data.reduce((s,a)=>s+a.valueLength,0),stride:t.stride??t.data[0]?.stride??o.components*(o.listSize??1),byteStride:t.byteStride??i[0]?.byteStride??o.byteLength,rowByteLength:t.rowByteLength??i[0]?.rowByteLength??o.byteLength,data:i})}importTexture(e,t){this.assertMutable();let n=So(e,this.device);return t&&Co(t,n,this.device),this.addTexture(new be(this,n,!1,t))}importFrameTexture(e){this.assertMutable();let t=So(e,this.device);return this.addTexture(new be(this,t,!1,void 0,!0))}importExternalTexture(e){return this.assertMutable(),Au(e,this.device),this.addExternalTexture(new tt(this,e))}createTransientTexture(e){this.assertMutable();let t=So(e,this.device);return this.addTexture(new be(this,t,!0))}createTextureView(e,t={}){this.assertTexture(e);let n=Ou(e,t);return new ke(e,n)}add(e){if(this.assertMutable(),"getNodes"in e)for(let t of e.getNodes())this.add(t);else if("getCommandNodes"in e)ze(this,e.getCommandNodes(this));else if("type"in e)Eo(this,e);else for(let t of e)this.add(t)}addComputePass(e){this.addNode({...e,type:"compute"})}addRenderPass(e){e.attachments&&this.validateRenderAttachments(e.id,e.attachments);let t=e.attachments?[...e.attachments.colorAttachments.map(n=>({texture:n,usage:"render-attachment"})),...(e.attachments.resolveTargets??[]).filter(n=>n!==null).map(n=>({texture:n,usage:"render-attachment"})),...e.attachments.depthStencilAttachment?[{texture:e.attachments.depthStencilAttachment,usage:"render-attachment"}]:[]]:[];this.addNode({...e,resources:[...e.resources??[],...t],type:"render"})}addCopyPass(e){this.addNode({...e,type:"copy"})}compile(){return this.assertMutable(),Wr(this.device,"compilation"),this.compiled=!0,new yt(rs({device:this.device,id:this.id,buffers:this.buffers,textures:this.textures,externalTextures:this.externalTextures,nodes:this.nodes}))}async compileAsync(){return this.assertMutable(),Wr(this.device,"compilation"),this.compiled=!0,new yt(await ns({device:this.device,id:this.id,buffers:this.buffers,textures:this.textures,externalTextures:this.externalTextures,nodes:this.nodes}))}addNode(e){if(this.assertMutable(),!e.id)throw new Error("GPUCommandGraph node id is required");if(this.nodeIds.has(e.id))throw new Error(`GPUCommandGraph node id "${e.id}" is already in use`);for(let[t,n]of Object.entries(e.workload??{}))if(t==="operation"||t==="variant"){if(typeof n!="string"||!n)throw new Error(`GPUCommandGraph node "${e.id}" workload ${t} must be nonempty`)}else if(typeof n!="number"||!Number.isSafeInteger(n)||n<0)throw new Error(`GPUCommandGraph node "${e.id}" workload ${t} must be a nonnegative safe integer`);if(e.condition){if(!e.condition.id)throw new Error(`GPUCommandGraph node "${e.id}" condition id is required`);if(e.condition.source==="cpu"){if(typeof e.condition.evaluate!="function")throw new Error(`GPUCommandGraph node "${e.id}" CPU condition requires an evaluate function`)}else{let t=e.condition;if(e.type!=="compute"||t.mode!=="indirect")throw new Error(`GPUCommandGraph node "${e.id}" GPU conditions require an indirect compute node`);if(!t.buffer)throw new Error(`GPUCommandGraph node "${e.id}" GPU condition requires an indirect command buffer`);this.assertBuffer(t.buffer);let n=t.byteOffset??0;if(!Number.isSafeInteger(n)||n<0||n%4!==0)throw new Error(`GPUCommandGraph node "${e.id}" GPU condition byteOffset must be a nonnegative multiple of 4`);if(n+3*Su>t.buffer.byteLength)throw new Error(`GPUCommandGraph node "${e.id}" GPU condition indirect command exceeds buffer "${t.buffer.id}"`);(e.resources??[]).some(o=>et(o)&&ye(o.buffer)===t.buffer&&o.usage==="indirect")||(e={...e,resources:[...e.resources??[],{buffer:t.buffer,usage:"indirect"}]})}}if(e.publication){if(e.condition)throw new Error(`GPUCommandGraph node "${e.id}" cannot combine conditional execution with a publication boundary`);if(!e.publication.id)throw new Error(`GPUCommandGraph node "${e.id}" publication id is required`);if(!["partial","complete"].includes(e.publication.completeness))throw new Error(`GPUCommandGraph node "${e.id}" publication completeness is invalid`)}for(let t of e.resources??[])if(et(t)){let n=ye(t.buffer);this.assertBuffer(n),Du(n,t.usage)}else if(lr(t)){let n=_e(t.texture);this.assertTexture(n),Gu(n,t.usage),Nu(t.texture,t.usage)}else{if(this.assertExternalTexture(t.externalTexture),t.usage!=="sampled")throw new Error("GPUCommandGraph external textures support sampled access only");if(e.type!=="render")throw new Error("GPUCommandGraph external textures can be sampled only by render nodes")}is(e),this.nodeIds.add(e.id),this.nodes.push(e)}addBuffer(e){if(this.buffers.has(e.id)||this.textures.has(e.id)||this.externalTextures.has(e.id))throw new Error(`GPUCommandGraph resource id "${e.id}" is already in use`);return this.buffers.set(e.id,e),e}addTexture(e){if(this.buffers.has(e.id)||this.textures.has(e.id)||this.externalTextures.has(e.id))throw new Error(`GPUCommandGraph resource id "${e.id}" is already in use`);return this.textures.set(e.id,e),e}addExternalTexture(e){if(this.buffers.has(e.id)||this.textures.has(e.id)||this.externalTextures.has(e.id))throw new Error(`GPUCommandGraph resource id "${e.id}" is already in use`);return this.externalTextures.set(e.id,e),e}importGPUDataView(e,t){if(!t.format)throw new Error(`GPUCommandGraph import "${e}" requires GPUData.format`);let n=gr(t.buffer),o={byteLength:vu(t),usage:n.usage},i=t.buffer instanceof xe?this.getDynamicBufferHandle(t.buffer,o):this.getImportedBufferHandle(n,o);return i||(i=this.importBuffer({id:e,byteLength:n.byteLength,usage:n.usage},t.buffer),t.buffer instanceof xe?this.dynamicBufferHandles.set(t.buffer,i):this.importedBufferHandles.set(n,i)),this.createDataView(i,{format:t.format,length:t.length,byteOffset:t.byteOffset,byteStride:t.byteStride,rowByteLength:t.rowByteLength})}getDynamicBufferHandle(e,t){let n=this.dynamicBufferHandles.get(e);if(n?.defaultBuffer===e&&mr(n,t))return n;this.dynamicBufferHandles.delete(e);for(let o of this.buffers.values())if(o.defaultBuffer===e&&mr(o,t))return this.dynamicBufferHandles.set(e,o),o}getImportedBufferHandle(e,t){let n=this.importedBufferHandles.get(e);if(n?.defaultBuffer&&gr(n.defaultBuffer)===e&&mr(n,t))return n;this.importedBufferHandles.delete(e);for(let[o,i]of this.dynamicBufferHandles)if(o.buffer===e&&mr(i,t))return this.importedBufferHandles.set(e,i),i;for(let o of this.buffers.values())if(o.defaultBuffer===e&&mr(o,t))return this.importedBufferHandles.set(e,o),o}assertBuffer(e){if(e.graph!==this||this.buffers.get(e.id)!==e)throw new Error(`Graph buffer "${e.id}" does not belong to ${this.id}`)}assertTexture(e){if(e.graph!==this||this.textures.get(e.id)!==e)throw new Error(`Graph texture "${e.id}" does not belong to ${this.id}`)}assertExternalTexture(e){if(e.graph!==this||this.externalTextures.get(e.id)!==e)throw new Error(`Graph external texture "${e.id}" does not belong to ${this.id}`)}assertMutable(){if(this.compiled)throw new Error(`GPUCommandGraph "${this.id}" has already been compiled`)}validateRenderAttachments(e,t){if(t.colorAttachments.length===0&&!t.depthStencilAttachment)throw new Error(`GPUCommandGraph render node "${e}" requires at least one attachment`);let n=[...t.colorAttachments,...t.depthStencilAttachment?[t.depthStencilAttachment]:[]];for(let s of n)if(this.assertTexture(s.texture),s.dimension!=="2d"||s.mipLevelCount!==1||s.arrayLayerCount!==1)throw new Error(`GPUCommandGraph render node "${e}" attachments must be single-mip, single-layer 2d views`);let[o,...i]=n;for(let s of i)if(s.width!==o.width||s.height!==o.height||s.texture.samples!==o.texture.samples)throw new Error(`GPUCommandGraph render node "${e}" attachments must have matching extent and samples`);this.validateResolveTargets(e,t)}validateResolveTargets(e,t){let n=t.resolveTargets;if(n){if(this.device.type!=="webgpu")throw new Error(`GPUCommandGraph render node "${e}" resolve targets require WebGPU`);if(n.length!==t.colorAttachments.length)throw new Error(`GPUCommandGraph render node "${e}" requires one resolve entry per color attachment`);for(let o=0;o<n.length;o++){let i=n[o];if(!i)continue;let s=t.colorAttachments[o];if(this.assertTexture(i.texture),s.texture.samples<=1||i.texture.samples!==1||s.format!==i.format||s.width!==i.width||s.height!==i.height)throw new Error(`GPUCommandGraph render node "${e}" resolve target ${o} must match a multisampled source and be single-sampled`);if(i.dimension!=="2d"||i.aspect!=="all"||i.mipLevelCount!==1||i.arrayLayerCount!==1)throw new Error(`GPUCommandGraph render node "${e}" resolve targets must be single-mip, single-layer 2d color views`)}}}},yt=class{device;id;stats;preflight;capabilities;buffers;textures;externalTextures;compiledNodes;activeImportedBufferHandles=new Set;writableImportedBufferHandles=new Set;activeImportedTextureHandles=new Set;writableImportedTextureHandles=new Set;transientBuffers;transientTextures;bufferTransientAllocations;textureTransientAllocations;cachedTextureViews=[];cachedFramebuffers=[];lastFrameIds=new Map;lastExternalTextureFrameIds=new Map;consumedExternalTextures=new WeakSet;destroyed=!1;get[Symbol.toStringTag](){return"CompiledGPUCommandGraph"}toString(){let e=this.destroyed?"destroyed":"active";return`${this[Symbol.toStringTag]}:"${this.id}":${this.stats.nodeOrder.length} nodes:${this.stats.physicalTransientResourceBytes}B transient:${e}`}toJSON(){return this.toString()}constructor(e){this.device=e.device,this.id=e.id,this.buffers=e.buffers,this.textures=e.textures,this.externalTextures=e.externalTextures,this.compiledNodes=e.compiledNodes;for(let{node:t}of this.compiledNodes)for(let n of t.resources??[])if(et(n)){let o=ye(n.buffer);o.transient||(this.activeImportedBufferHandles.add(o),(n.usage==="storage-write"||n.usage==="storage-read-write"||n.usage==="copy-destination")&&this.writableImportedBufferHandles.add(o))}else if(lr(n)){let o=_e(n.texture);o.transient||(this.activeImportedTextureHandles.add(o),(n.usage==="storage-write"||n.usage==="storage-read-write"||n.usage==="render-attachment"||n.usage==="copy-destination")&&this.writableImportedTextureHandles.add(o))}this.transientBuffers=e.transientBuffers,this.transientTextures=e.transientTextures,this.bufferTransientAllocations=e.bufferTransientAllocations,this.textureTransientAllocations=e.textureTransientAllocations,this.stats=e.stats,this.preflight=e.preflight,this.capabilities=Bu(this.device)}encode(e,t){return this.encodeNodeRange(e,t,0,this.compiledNodes.length)}getExecutionPlan(e,t={}){return qr(this.preflight,e,t)}createExecution(e,t={}){return new _t({plan:this.getExecutionPlan(e,t),budget:e,encodeNodeRange:(n,o,i,s)=>this.encodeNodeRange(n,o,i,s)})}encodeNodeRange(e,t,n,o){if(this.destroyed)throw new Error(`CompiledGPUCommandGraph "${this.id}" has been destroyed`);if(Wr(this.device,"encoding"),e.device!==this.device)throw new Error("GPUCommandGraph command encoder must belong to the graph device");let i=pr(),s=this.resolveImportedBuffers(t.buffers??{});Lu(t.frameTextures??{},t.externalTextures??{});let a=this.resolveImportedTextures(t.textures??{},t.frameTextures??{}),c=this.resolveExternalTextures(t.externalTextures??{});for(let[p,y]of a.frameIds)this.lastFrameIds.set(p,y);for(let[p,y]of c.frameIds)this.lastExternalTextureFrameIds.set(p,y);for(let p of c.textures.values())this.consumedExternalTextures.add(p);let u=a.textures,d=p=>{let y=ye(p),S=y.transient?this.transientBuffers.get(y):s.get(y);if(!S)throw new Error(`GPUCommandGraph buffer "${y.id}" is not bound`);return S},h=p=>{let y=_e(p),S=y.transient?this.transientTextures.get(y):u.get(y);if(!S)throw new Error(`GPUCommandGraph texture "${y.id}" is not bound`);return S},f=p=>{let y=h(p);if(p instanceof be||ku(p))return y.view;if(p.texture.frameScoped){let E=this.lastFrameIds.get(p.texture);for(let C=this.cachedTextureViews.length-1;C>=0;C--){let L=this.cachedTextureViews[C];L.logicalView===p&&L.frameId!==E&&(this.destroyFramebuffersUsingView(L.view),L.view.destroy(),this.cachedTextureViews.splice(C,1))}}let S=this.cachedTextureViews.find(E=>E.logicalView===p&&E.texture===y&&(!p.texture.frameScoped||E.frameId===this.lastFrameIds.get(p.texture)));if(S)return S.view;let P=y.createView({format:p.format,dimension:p.dimension,aspect:p.aspect,baseMipLevel:p.baseMipLevel,mipLevelCount:p.mipLevelCount,baseArrayLayer:p.baseArrayLayer,arrayLayerCount:p.arrayLayerCount});return this.cachedTextureViews.push({logicalView:p,texture:y,view:P,...p.texture.frameScoped?{frameId:this.lastFrameIds.get(p.texture)}:{}}),P},l=p=>{let y=c.textures.get(p);if(!y)throw new Error(`GPUCommandGraph external texture "${p.id}" is not bound`);return y},m={commandEncoder:e,parameters:t.parameters,getBuffer:d,getTexture:h,getTextureView:f,getExternalTexture:l},g=[],x,T=0,M=t.coalesceComputePasses!==!1&&e.getTimeProfilingQuerySet()===null,w=()=>{let p=x;x=void 0,p?.end()};try{for(let p=n;p<o;p++){let{node:y,executable:S}=this.compiledNodes[p],P=pr();if(y.condition?.source==="cpu"){let L=!1;try{L=y.condition.evaluate(t.parameters)}catch(v){let I=v instanceof Error?v.message:String(v);throw new Error(`GPUCommandGraph CPU condition "${y.condition.id}" failed for node "${y.id}": ${I}`)}if(!L){let v=pr();g.push({stats:{id:y.id,description:y.description,resources:this.preflight.nodes[p].resources,operation:y.workload?.operation,type:y.type,cpuEncodeStartTimeMilliseconds:P,cpuEncodeEndTimeMilliseconds:v,cpuEncodeTimeMilliseconds:v-P,hasGPUTimestamps:!1,condition:{id:y.condition.id,source:"cpu",outcome:"skipped"}}});continue}}let E;switch(y.type){case"compute":{x||(x=e.beginComputePass({id:y.id}),T++);let L=x;E=ls(L,e),E&&(M=!1),L.pushDebugGroup(y.id);try{let v=y.condition?.source==="gpu"?y.condition:void 0,I=v?Cu(L,d(v.buffer),v.byteOffset??0,y.id):void 0;S.encode({...m,computePass:I?.computePass??L}),I?.assertDispatched()}finally{L.popDebugGroup()}M||w();break}case"render":{w();let L=S,v=L.getRenderPassProps?.(m)??{id:y.id};if(y.attachments&&v.framebuffer!==void 0)throw new Error(`GPUCommandGraph render node "${y.id}" cannot supply framebuffer with graph attachments`);if(y.attachments?.resolveTargets&&v.resolveTargets!==void 0)throw new Error(`GPUCommandGraph render node "${y.id}" cannot supply resolveTargets with graph attachments`);let I=y.attachments?this.getFramebuffer(y.id,y.attachments,f):void 0,A=y.attachments?.resolveTargets?.map(F=>F?f(F):null),G=e.beginRenderPass({...v,...I?{framebuffer:I}:{},...A?{resolveTargets:A}:{}});E=ls(G,e),G.pushDebugGroup(y.id);try{L.encode({...m,renderPass:G})}finally{G.popDebugGroup(),G.end()}break}case"copy":w(),S.encode(m);break}let C=pr();g.push({stats:{id:y.id,description:y.description,resources:this.preflight.nodes[p].resources,operation:y.workload?.operation,type:y.type,cpuEncodeStartTimeMilliseconds:P,cpuEncodeEndTimeMilliseconds:C,cpuEncodeTimeMilliseconds:C-P,hasGPUTimestamps:E!==void 0,...y.condition?{condition:{id:y.condition.id,source:y.condition.source,outcome:y.condition.source==="gpu"?"gpu-resolved":"executed"}}:{}},timestamp:E})}}finally{w()}let b=pr();return new Ut(g,b-i,T,i,b,async(p,y)=>{if(this.destroyed)throw new Error("Graph has been destroyed.");let S=this.compiledNodes.findIndex(({node:I})=>I.id===p),P=this.compiledNodes[S]?.node.resources?.[y],E=this.preflight.nodes[S]?.resources?.[y];if(!P||!E)throw new Error("Resource is unavailable.");if("externalTexture"in P)throw new Error("External images cannot be read back.");let C="buffer"in P?ye(P.buffer):_e(P.texture);if("frameScoped"in C&&C.frameScoped)throw new Error("Frame textures expire after presentation.");let L="buffer"in P?d(P.buffer):h(P.texture),v=L instanceof ie.Buffer?this.transientBuffers:this.transientTextures;if(C.transient&&[...v].some(([I,A])=>I!==C&&A===L))throw new Error("Transient allocation is reused; logical contents are no longer available.");return wi(L,E)})}destroy(){if(!this.destroyed){for(let{executable:e}of this.compiledNodes)e.destroy?.();for(let e of this.cachedFramebuffers)e.framebuffer.destroy();for(let e of this.cachedTextureViews)e.view.destroy();for(let e of this.bufferTransientAllocations)e.buffer?.destroy();for(let e of this.textureTransientAllocations)e.texture?.destroy();this.destroyed=!0}}resolveImportedBuffers(e){let t=new Map,n=new Map;for(let[o,i]of this.buffers){if(i.transient)continue;let s=e[o]??i.defaultBuffer;if(!s)throw new Error(`GPUCommandGraph imported buffer "${o}" is required`);gs(s,i,this.device);let a=gr(s);if(this.activeImportedBufferHandles.has(i)){let c=a.handle,u=typeof c=="object"&&c!==null||typeof c=="function"?c:a,d=n.get(u);if(d&&(this.writableImportedBufferHandles.has(d)||this.writableImportedBufferHandles.has(i)))throw new Error(`GPUCommandGraph imported buffers "${d.id}" and "${o}" resolve to the same physical buffer`);d||n.set(u,i)}t.set(i,a)}for(let o of Object.keys(e)){let i=this.buffers.get(o);if(!i||i.transient)throw new Error(`GPUCommandGraph has no imported buffer named "${o}"`)}return t}resolveImportedTextures(e,t){let n=new Map,o=new Map;for(let[s,a]of this.textures){if(a.transient)continue;if(a.frameScoped){let u=t[s];if(!u)throw new Error(`GPUCommandGraph frame texture "${s}" is required`);let d=this.lastFrameIds.get(a);if(d!==void 0&&u.frameId<=d)throw new Error(`GPUCommandGraph frame texture "${s}" frameId ${u.frameId} is stale; expected greater than ${d}`);Co(u.texture,a,this.device),n.set(a,Po(u.texture)),o.set(a,u.frameId);continue}let c=e[s]??a.defaultTexture;if(!c)throw new Error(`GPUCommandGraph imported texture "${s}" is required`);Co(c,a,this.device),n.set(a,Po(c))}for(let s of Object.keys(e)){let a=this.textures.get(s);if(!a||a.transient||a.frameScoped)throw new Error(`GPUCommandGraph has no imported texture named "${s}"`)}for(let s of Object.keys(t))if(!this.textures.get(s)?.frameScoped)throw new Error(`GPUCommandGraph has no frame texture named "${s}"`);let i=new Map;for(let[s,a]of n){if(!this.activeImportedTextureHandles.has(s))continue;let c=a.handle,u=typeof c=="object"&&c!==null||typeof c=="function"?c:a,d=i.get(u);if(d&&(this.writableImportedTextureHandles.has(d)||this.writableImportedTextureHandles.has(s)))throw new Error(`GPUCommandGraph imported textures "${d.id}" and "${s.id}" resolve to the same physical texture`);d||i.set(u,s)}return{textures:n,frameIds:o}}resolveExternalTextures(e){let t=new Map,n=new Map;for(let[o,i]of this.externalTextures){let s=e[o];if(!s)throw new Error(`GPUCommandGraph external texture "${o}" is required`);let a=this.lastExternalTextureFrameIds.get(i);if(a!==void 0&&s.frameId<=a)throw new Error(`GPUCommandGraph external texture "${o}" frameId ${s.frameId} is stale; expected greater than ${a}`);if(this.consumedExternalTextures.has(s.texture))throw new Error(`GPUCommandGraph external texture "${o}" requires a fresh binding for each frame`);Ru(s.texture,i,this.device),t.set(i,s.texture),n.set(i,s.frameId)}for(let o of Object.keys(e))if(!this.externalTextures.has(o))throw new Error(`GPUCommandGraph has no external texture named "${o}"`);return{textures:t,frameIds:n}}getFramebuffer(e,t,n){let o=t.colorAttachments.map(n),i=t.depthStencilAttachment?n(t.depthStencilAttachment):void 0,s=this.cachedFramebuffers.find(u=>u.nodeId===e&&u.depthStencilAttachment===i&&u.colorAttachments.length===o.length&&u.colorAttachments.every((d,h)=>d===o[h]));if(s)return s.framebuffer;let a=t.colorAttachments[0]??t.depthStencilAttachment,c=this.device.createFramebuffer({id:`${this.id}-${e}-framebuffer-${this.cachedFramebuffers.length}`,width:a.width,height:a.height,colorAttachments:o,depthStencilAttachment:i??null});return this.cachedFramebuffers.push({nodeId:e,colorAttachments:o,depthStencilAttachment:i,framebuffer:c}),c}destroyFramebuffersUsingView(e){for(let t=this.cachedFramebuffers.length-1;t>=0;t--){let n=this.cachedFramebuffers[t];(n.depthStencilAttachment===e||n.colorAttachments.some(o=>o===e))&&(n.framebuffer.destroy(),this.cachedFramebuffers.splice(t,1))}}};function gr(r){return r instanceof xe?r.buffer:r}function vu(r){let e=r.length===0?0:(r.length-1)*r.byteStride+r.rowByteLength;return r.byteOffset+e}function mr(r,e){return r.byteLength>=e.byteLength&&(r.usage&e.usage)===e.usage}function Po(r){if(r instanceof Ke){if(!r.isReady)throw new Error(`GPUCommandGraph dynamic texture "${r.id}" is not ready`);return r.texture}return r}function Lu(r,e){let t;for(let[n,o]of[...Object.entries(r),...Object.entries(e)]){if(!Number.isSafeInteger(o.frameId)||o.frameId<0)throw new Error(`GPUCommandGraph frame resource "${n}" requires a valid frameId`);if(t!==void 0&&o.frameId!==t)throw new Error("GPUCommandGraph frame resources must share one frameId per encoding");t=o.frameId}}function ls(r,e){let{timestampQuerySet:t,beginTimestampIndex:n,endTimestampIndex:o}=r.props;return t&&Number.isSafeInteger(n)&&Number.isSafeInteger(o)&&n>=0&&o>n?{querySet:t,snapshot:t.device.type==="webgpu"?e.captureTimestampQuerySet?.(t):void 0,beginIndex:n,endIndex:o}:void 0}function Bu(r){return Object.freeze({timestampQueries:r.features.has("timestamp-query"),subgroups:r.features.has("subgroups"),subgroupId:r.wgslLanguageFeatures.has("subgroup_id"),subgroupMinSize:r.info.subgroupMinSize,subgroupMaxSize:r.info.subgroupMaxSize,softwareAdapter:r.info.gpu==="software"||r.info.gpuType==="cpu"||!!r.info.fallback,maxBufferByteLength:r.limits.maxBufferSize,maxStorageBufferBindingByteLength:r.limits.maxStorageBufferBindingSize,maxComputeInvocationsPerWorkgroup:r.limits.maxComputeInvocationsPerWorkgroup,maxComputeWorkgroupsPerDimension:r.limits.maxComputeWorkgroupsPerDimension})}function Wr(r,e){if(r.isLost)throw new Error(`GPUCommandGraph cannot perform ${e} after device loss`)}function pr(){return globalThis.performance?.now()??Date.now()}function ms(r,e){if(!r.id)throw new Error("GPUCommandGraph buffer id is required");if(!Number.isSafeInteger(r.byteLength)||r.byteLength<0)throw new Error(`GPUCommandGraph buffer "${r.id}" requires a valid byteLength`);if(r.byteLength>e.limits.maxBufferSize)throw new Error(`GPUCommandGraph buffer "${r.id}" exceeds the device buffer limit`);if(!Number.isSafeInteger(r.usage)||r.usage<=0)throw new Error(`GPUCommandGraph buffer "${r.id}" requires buffer usage flags`)}function Au(r,e){if(!r.id)throw new Error("GPUCommandGraph external texture id is required");for(let[t,n]of Object.entries({width:r.width,height:r.height}))if(!Number.isSafeInteger(n)||n<=0)throw new Error(`GPUCommandGraph external texture "${r.id}" ${t} must be a positive safe integer`);if(r.width>e.limits.maxTextureDimension2D||r.height>e.limits.maxTextureDimension2D)throw new Error(`GPUCommandGraph external texture "${r.id}" exceeds device dimension limits`)}function So(r,e){if(!r.id)throw new Error("GPUCommandGraph texture id is required");let t=r.dimension??"2d",n=t==="cube"?6:r.depth??1,o=r.mipLevels??1,i=r.samples??1;for(let[u,d]of Object.entries({width:r.width,height:r.height,depth:n,mipLevels:o,samples:i}))if(!Number.isSafeInteger(d)||d<=0)throw new Error(`GPUCommandGraph texture "${r.id}" ${u} must be a positive safe integer`);if(!Number.isSafeInteger(r.usage)||r.usage<=0)throw new Error(`GPUCommandGraph texture "${r.id}" requires texture usage flags`);if(!e.isTextureFormatSupported(r.format))throw new Error(`GPUCommandGraph texture "${r.id}" format ${r.format} is unsupported`);if(t==="1d"&&(r.height!==1||n!==1))throw new Error(`GPUCommandGraph 1d texture "${r.id}" requires height and depth 1`);if(t==="cube"&&r.width!==r.height)throw new Error(`GPUCommandGraph cube texture "${r.id}" must be square`);if(t==="cube-array"&&(r.width!==r.height||n%6!==0))throw new Error(`GPUCommandGraph cube-array texture "${r.id}" must be square with depth divisible by 6`);if(o>e.getMipLevelCount(r.width,r.height,t==="3d"?n:1))throw new Error(`GPUCommandGraph texture "${r.id}" declares too many mip levels`);let s=t==="1d"?e.limits.maxTextureDimension1D:t==="3d"?e.limits.maxTextureDimension3D:e.limits.maxTextureDimension2D,a=t==="3d"?e.limits.maxTextureDimension3D:e.limits.maxTextureDimension2D,c=t==="3d"?e.limits.maxTextureDimension3D:e.limits.maxTextureArrayLayers;if(r.width>s||r.height>a||n>c)throw new Error(`GPUCommandGraph texture "${r.id}" exceeds device dimension limits`);return{id:r.id,format:r.format,width:r.width,height:r.height,usage:r.usage,dimension:t,depth:n,mipLevels:o,samples:i}}function Ou(r,e){let t=e.dimension??r.dimension,n=e.aspect??"all",o=e.baseMipLevel??0,i=e.mipLevelCount??r.mipLevels-o,s=e.baseArrayLayer??0,a=r.dimension==="3d"?1:r.depth,c=e.arrayLayerCount??a-s;for(let[f,l]of Object.entries({baseMipLevel:o,mipLevelCount:i,baseArrayLayer:s,arrayLayerCount:c}))if(!Number.isSafeInteger(l)||l<0)throw new Error(`Graph texture view ${f} must be a non-negative safe integer`);if(i===0||o+i>r.mipLevels)throw new Error(`Graph texture view exceeds texture "${r.id}" mip levels`);if(c===0||s+c>a||r.dimension==="3d"&&(s!==0||c!==1))throw new Error(`Graph texture view exceeds texture "${r.id}" array layers`);let u=Math.max(1,r.width>>o),d=r.dimension==="1d"?1:Math.max(1,r.height>>o),h=r.dimension==="3d"?Math.max(1,r.depth>>o):c;return{dimension:t,aspect:n,baseMipLevel:o,mipLevelCount:i,baseArrayLayer:s,arrayLayerCount:c,width:u,height:d,depth:h}}function Iu(r,e){for(let[o,i]of Object.entries(e))if(!Number.isSafeInteger(i)||i<0)throw new Error(`Graph data view ${o} must be a non-negative safe integer`);if(e.length>1&&e.byteStride===0)throw new Error("Graph data view byteStride must be positive for multiple rows");if(e.rowByteLength>e.byteStride&&e.length>1)throw new Error("Graph data view rowByteLength cannot exceed byteStride");let t=e.length===0?0:(e.length-1)*e.byteStride+e.rowByteLength,n=e.byteOffset+t;if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n))throw new Error("Graph data view byte range exceeds safe integer precision");if(n>r.byteLength)throw new Error(`Graph data view exceeds buffer "${r.id}" byte length`)}function gs(r,e,t){let n=gr(r);if(n.device!==t)throw new Error(`GPUCommandGraph buffer "${e.id}" belongs to another device`);if(n.byteLength<e.byteLength)throw new Error(`GPUCommandGraph buffer "${e.id}" is smaller than compiled capacity`);if((n.usage&e.usage)!==e.usage)throw new Error(`GPUCommandGraph buffer "${e.id}" has incompatible usage flags`)}function Co(r,e,t){let n=Po(r);if(n.device!==t)throw new Error(`GPUCommandGraph texture "${e.id}" belongs to another device`);for(let[o,i,s]of[["format",e.format,n.format],["dimension",e.dimension,n.dimension],["width",e.width,n.width],["height",e.height,n.height],["depth",e.depth,n.depth],["mipLevels",e.mipLevels,n.mipLevels],["samples",e.samples,n.samples]])if(s!==i)throw new Error(`GPUCommandGraph texture "${e.id}" has incompatible ${o} (${s} !== ${i})`);if((n.props.usage&e.usage)!==e.usage)throw new Error(`GPUCommandGraph texture "${e.id}" has incompatible usage flags`)}function Ru(r,e,t){if(r.device!==t)throw new Error(`GPUCommandGraph external texture "${e.id}" belongs to another device`);if(r.destroyed)throw new Error(`GPUCommandGraph external texture "${e.id}" has been destroyed`);if(r.width!==e.width||r.height!==e.height)throw new Error(`GPUCommandGraph external texture "${e.id}" has incompatible dimensions (${r.width}x${r.height} !== ${e.width}x${e.height})`)}function Du(r,e){let t=_u(e);if((r.usage&t)!==t)throw new Error(`GPUCommandGraph buffer "${r.id}" does not declare usage required by ${e}`)}function Gu(r,e){let t=Uu(e);if((r.usage&t)!==t)throw new Error(`GPUCommandGraph texture "${r.id}" does not declare usage required by ${e}`)}function Nu(r,e){if(r instanceof ke&&e.startsWith("storage-")&&r.mipLevelCount!==1)throw new Error("GPUCommandGraph storage texture views must contain exactly one mip level")}function _u(r){switch(r){case"storage-read":case"storage-write":case"storage-read-write":return ie.Buffer.STORAGE;case"uniform":return ie.Buffer.UNIFORM;case"copy-source":return ie.Buffer.COPY_SRC;case"copy-destination":return ie.Buffer.COPY_DST;case"indirect":return ie.Buffer.INDIRECT;case"vertex":return ie.Buffer.VERTEX;case"index":return ie.Buffer.INDEX}}function Uu(r){switch(r){case"sampled":return ie.Texture.SAMPLE;case"storage-read":case"storage-write":case"storage-read-write":return ie.Texture.STORAGE;case"render-attachment":return ie.Texture.RENDER;case"copy-source":return ie.Texture.COPY_SRC;case"copy-destination":return ie.Texture.COPY_DST}}function ku(r){let e=r.texture;return r.dimension===e.dimension&&r.aspect==="all"&&r.baseMipLevel===0&&r.mipLevelCount===e.mipLevels&&r.baseArrayLayer===0&&r.arrayLayerCount===(e.dimension==="3d"?1:e.depth)}var Ha=X(V(),1);var bt=class{id;format;constructor(e,t){if(!e)throw new Error("GPUGraphScalar id is required");this.id=e,this.format=t}},ve=class{id;format;length;external;chunkLengths;constructor(e){if(!e.id)throw new Error("GPUGraphVector id is required");if(e.length!==void 0&&(!Number.isSafeInteger(e.length)||e.length<0))throw new Error(`${e.id} vector length must be a non-negative safe integer`);if(this.id=e.id,this.format=e.format,this.length=e.length,this.external=e.external??!1,e.chunkLengths){if(e.chunkLengths.some(t=>!Number.isSafeInteger(t)||t<0)||e.length!==void 0&&e.chunkLengths.reduce((t,n)=>t+n,0)!==e.length)throw new Error(`${e.id} chunk lengths must partition its logical length`);this.chunkLengths=Object.freeze([...e.chunkLengths])}}},wt=class{id;format;width;height;usage;dimension;depth;mipLevels;samples;external;constructor(e){this.id=e.id,this.format=e.format,this.width=e.width,this.height=e.height,this.usage=e.usage,this.dimension=e.dimension,this.depth=e.depth,this.mipLevels=e.mipLevels,this.samples=e.samples,this.external=e.external??!1}},Le=class{texture;props;constructor(e,t={}){this.texture=e,this.props=Object.freeze({...t})}};var Bs=X(V(),1);var jr=class extends xt{computeLowerings=[];loweringsSuspended=0;otherLowerings=[];addRenderPass(e){let t={...e,type:"render"},n=this.otherLowerings.at(-1);n&&(t=n(t)),super.addRenderPass(t)}addCopyPass(e){let t={...e,type:"copy"},n=this.otherLowerings.at(-1);n&&(t=n(t)),super.addCopyPass(t)}withOtherLowering(e,t){this.otherLowerings.push(e);try{return t()}finally{this.otherLowerings.pop()}}constructor(e,t={}){super(e,t)}addComputePass(e){let t=e;if(this.loweringsSuspended===0)for(let n=this.computeLowerings.length-1;n>=0;n--)t=this.computeLowerings[n](t);super.addComputePass(t)}withComputeLowering(e,t){this.computeLowerings.push(e);try{return t()}finally{this.computeLowerings.pop()}}withoutComputeLowering(e){this.loweringsSuspended++;try{return e()}finally{this.loweringsSuspended--}}};var vo=X(V(),1);var Lo=Uint32Array.BYTES_PER_ELEMENT,Bo=256;function Tt(r,e,t){let n=D(r.format);if(!e.includes(r.format)||r.byteStride!==n.byteLength||r.rowByteLength!==n.byteLength||r.byteOffset%Lo!==0)throw new Error(`${t} must be packed, uint32-aligned ${e.join(" or ")} GPU data`)}function xs(r,e){Tt(r,["uint32"],e)}function K(r,e){let t=xr(r),n={buffer:e(r),...t};if(n.offset+n.size>r.buffer.byteLength)throw new Error("GraphDataView storage binding exceeds its logical buffer");return n}function xr(r){let e=Math.floor(r.byteOffset/Bo)*Bo,t=r.byteOffset-e,n=r.length===0?r.rowByteLength:(r.length-1)*r.byteStride+r.rowByteLength;return{offset:e,size:t+Math.max(n,r.rowByteLength)}}function N(r){if(r.byteOffset%Lo!==0)throw new Error("GraphDataView storage binding must be uint32-aligned");return r.byteOffset%Bo/Lo}function Mt(r,e,t,n,o=vo.Buffer.STORAGE){if(!Number.isSafeInteger(n)||n<0)throw new Error("Transient GraphDataView length must be a non-negative safe integer");if((o&vo.Buffer.STORAGE)===0)throw new Error("Transient GraphDataView usage must include Buffer.STORAGE");if(Qe(t)||Je(t))throw new Error("Transient GraphDataView requires a fixed-width GPUVector format");let i=D(t),s=r.createTransientBuffer({id:e,byteLength:Math.max(n,1)*i.byteLength,usage:o});return r.createDataView(s,{format:t,length:n})}function ys(r,e,t){if(!Number.isSafeInteger(t)||t<0||t>e.length)throw new Error("Graph prefix must fit within the input");if(t===e.length)return e;let n=e instanceof _?e.data:[e],o=t,i=[];for(let s of n){let a=Math.min(o,s.length);if(i.push(a===s.length?s:r.createDataView(s.buffer,{format:s.format,length:a,byteOffset:s.byteOffset,byteStride:s.byteStride,rowByteLength:s.rowByteLength})),o-=a,o===0)break}return e instanceof _?new _({...e,length:t,valueLength:t*(D(e.format).listSize??1),data:i}):i[0]}var Xr=X(V(),1);var $e=X(V(),1),k=class r{static async createAsync(e,t){let n=!$e.PipelineFactory.getAsyncCompilation(e),o=n?$e.PipelineFactory.beginAsyncCompilation(e):$e.PipelineFactory.getAsyncCompilation(e),i;try{i=new r(e,t)}finally{n&&$e.PipelineFactory.endAsyncCompilation(e,o)}try{return n?await Promise.all(o):await i._pipelineInitialization,i}catch(s){throw i.destroy(),s}}device;id;source;pipelineFactory;shaderFactory;shader;pipeline;_pipelineInitialization;_destroyed=!1;constructor(e,t){if(e.type!=="webgpu")throw new Error("Kernel is only supported in WebGPU");let{source:n,pipelineFactory:o,shaderFactory:i,debugShaders:s,...a}=t;this.device=e,this.id=t.id??"kernel",this.source=n,this.pipelineFactory=o??$e.PipelineFactory.getDefaultPipelineFactory(e),this.shaderFactory=i??$e.ShaderFactory.getDefaultShaderFactory(e),this.shader=this.shaderFactory.createShader({id:`${this.id}-compute`,stage:"compute",source:this.source,debugShaders:s});let c={...a,shader:this.shader},u=$e.PipelineFactory.getAsyncCompilation(e);if(u){let d=this.pipelineFactory.createComputePipelineAsync(c);this._pipelineInitialization=d,u.push(d.then(h=>(this.pipeline=h,h)))}else this.pipeline=this.pipelineFactory.createComputePipeline(c)}dispatch(e,t){this._setPipeline(e,t.bindings),e.dispatch(t.x,t.y,t.z)}dispatchIndirect(e,t){this._setPipeline(e,t.bindings),e.dispatchIndirect(t.indirectBuffer,t.indirectOffset??0)}destroy(){this._destroyed||(this.pipeline&&this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._destroyed=!0)}_setPipeline(e,t={}){e.setPipeline(this.pipeline),e.setBindings(t)}};function j(r,e){let[t,n,o]=e;for(let[i,s]of[["x",t],["y",n],["z",o]])if(!Number.isSafeInteger(s)||s<0)throw new Error(`compute dispatch ${i} workgroup count must be a non-negative safe integer`);return{...r,dispatchWorkgroups:Object.freeze([t,n,o])}}function Yr(r){return r.dispatchWorkgroups}var Hr=X(V(),1);var zu=16*1024,bs=new WeakMap;function ws(r){let e=r,t=bs.get(e);return t||(t=new Ao(r),bs.set(e,t)),t}var Ao=class{id;graph;buffer;capacityByteLength;nextByteOffset=0;slots=new Map;views=new Map;constructor(e,t="gpu-value-arena",n=zu){if(this.id=t,this.graph=e,!Number.isSafeInteger(n)||n<=0||n%4!==0)throw new Error(`${this.id} capacityByteLength must be a positive multiple of 4`);this.capacityByteLength=n,this.buffer=e.createTransientBuffer({id:`${this.id}-buffer`,byteLength:n,usage:Hr.Buffer.STORAGE|Hr.Buffer.COPY_SRC|Hr.Buffer.COPY_DST})}allocate(e,t){if(!e)throw new Error(`${this.id} slot id must not be empty`);if(this.slots.has(e))throw new Error(`${this.id} slot "${e}" already exists`);if(!["float32","uint32","sint32"].includes(t))throw new Error(`${this.id} unsupported slot format ${t}`);if(this.nextByteOffset+4>this.capacityByteLength)throw new Error(`${this.id} capacity exceeded while allocating "${e}"`);let n=Object.freeze({id:e,format:t,byteOffset:this.nextByteOffset});return this.nextByteOffset+=4,this.slots.set(e,n),this.views.set(e,new Ce(this.buffer,{format:t,length:1,byteOffset:n.byteOffset,byteStride:4,rowByteLength:4})),n}get(e){return this.slots.get(e)}getSlots(){return Object.freeze([...this.slots.values()])}getView(e){let t=this.views.get(e.id);if(!t)throw new Error(`${this.id} does not contain slot "${e.id}"`);return t}get byteLength(){return this.nextByteOffset}get size(){return this.slots.size}get availableByteLength(){return this.capacityByteLength-this.nextByteOffset}};var Oo=class{id;format;arena;slot;constructor(e,t){this.id=t.id,this.format=t.format,this.arena=e,this.slot=t}get byteOffset(){return this.slot.byteOffset}get wordOffset(){return this.slot.byteOffset>>>2}get view(){return this.arena.getView(this.slot)}};function Io(r,e,t){let n=ws(r);return new Oo(n,n.allocate(e,t))}function we(r,e="gpuValues"){let t=`${e}[${r.wordOffset}u]`;switch(r.format){case"float32":return`bitcast<f32>(${t})`;case"uint32":return t;case"sint32":return`bitcast<i32>(${t})`}}function rt(r,e,t="gpuValues"){let n=`${t}[${r.wordOffset}u]`;switch(r.format){case"float32":return`${n} = bitcast<u32>(${e});`;case"uint32":return`${n} = ${e};`;case"sint32":return`${n} = bitcast<u32>(${e});`}}function fe(r,e,t="gpuValues"){return`@group(${r}) @binding(${e}) var<storage, read_write> ${t}: array<u32>;`}var yr=class{id;active;workgroups;dispatchBuffer;constructor(e,t){if(this.id=t.id,this.active=t.active,this.workgroups=t.workgroups,t.active.arena.graph!==e)throw new Error(`${this.id} active scalar must belong to target graph`);this.dispatchBuffer=e.createTransientBuffer({id:`${this.id}-dispatch`,byteLength:12,usage:Xr.Buffer.STORAGE|Xr.Buffer.INDIRECT|Xr.Buffer.COPY_SRC})}getUpdateCommandNodes(e,t=`${this.id}-update`){if(this.active.arena.graph!==e)throw new Error(`${this.id} active scalar must belong to target graph`);let n=this.active.arena.buffer,[o,i,s]=this.workgroups,a=`${fe(0,0)}
|
|
8
8
|
@group(0) @binding(1) var<storage, read_write> dispatch: array<u32>;
|
|
9
9
|
@compute @workgroup_size(1)
|
|
10
10
|
fn main() {
|
|
11
|
-
let enabled = ${
|
|
12
|
-
dispatch[0] = select(0u, ${
|
|
11
|
+
let enabled = ${we(this.active)} != 0u;
|
|
12
|
+
dispatch[0] = select(0u, ${o}u, enabled);
|
|
13
13
|
dispatch[1] = ${i}u;
|
|
14
|
-
dispatch[2] = ${
|
|
15
|
-
}`;return[
|
|
16
|
-
@compute @workgroup_size(1) fn main(){${
|
|
17
|
-
${
|
|
14
|
+
dispatch[2] = ${s}u;
|
|
15
|
+
}`;return[q({id:t,workload:{operation:"GPUScalarDispatchGate",commandCount:1,maximumWorkgroupCount:1,maximumInvocationCount:1,readByteLength:4,writeByteLength:12},resources:[{buffer:n,usage:"storage-read"},{buffer:this.dispatchBuffer,usage:"storage-write"}],compile:({device:c})=>{let u=new k(c,{id:t,source:a,shaderLayout:{bindings:[{name:"gpuValues",type:"read-only-storage",group:0,location:0},{name:"dispatch",type:"storage",group:0,location:1}]}});return{encode:({computePass:d,getBuffer:h})=>{let f={gpuValues:h(n),dispatch:h(this.dispatchBuffer)};u.dispatch(d,{bindings:f,x:1,y:1,z:1})},destroy:()=>u.destroy()}}})]}get condition(){return{id:`${this.id}-active`,source:"gpu",mode:"indirect",buffer:this.dispatchBuffer}}};function Zr(r,e,t){return e.flatMap(n=>{let o=Yr(n);if(n.type!=="compute"||n.condition||!o)throw new Error("Gated primitives must expose unconditional compute nodes with exact dispatch geometry");let i=new yr(r,{id:`${n.id}-gate`,active:t,workgroups:o});return[...i.getUpdateCommandNodes(r).map(s=>j(s,[1,1,1])),{...n,condition:i.condition}]})}var Kr=class{id;operation;left;right;output;constructor(e){this.id=e.id??`gpu-scalar-${e.operation}`,this.operation=e.operation,this.left=e.left,this.right=e.right,this.output=e.output,$u(this)}getCommandNodes(e){let t=this.left.arena;if(this.right&&this.right.arena!==t)throw new Error(`${this.id} operands must belong to the same GPUValueArena`);if(this.output.arena!==t)throw new Error(`${this.id} output must belong to the same GPUValueArena`);if(t.graph!==e)throw new Error(`${this.id} scalars must belong to the target graph`);let n=t.buffer,o=Fu(this);return[j(q({id:this.id,workload:{operation:"GPUScalarCompute",commandCount:1,maximumWorkgroupCount:1,maximumInvocationCount:1,readByteLength:this.right?8:4,writeByteLength:4},resources:[{buffer:n,usage:"storage-write"}],compile:({device:i})=>{let s=new k(i,{id:this.id,source:o,shaderLayout:{bindings:[{name:"gpuValues",type:"storage",group:0,location:0}]}});return{encode:({computePass:a,getBuffer:c})=>{let u={gpuValues:c(n)};s.dispatch(a,{bindings:u,x:1,y:1,z:1})},destroy:()=>s.destroy()}}}),[1,1,1])]}};function $u(r){let e=r.operation==="copy"||r.operation==="sqrt",t=Wu(r.operation);if(!e&&!r.right)throw new Error(`${r.id} ${r.operation} requires a right operand`);if(e&&r.right)throw new Error(`${r.id} ${r.operation} does not accept a right operand`);if(r.right&&r.right.format!==r.left.format)throw new Error(`${r.id} input scalar formats must match`);if(r.operation==="sqrt"&&r.left.format!=="float32")throw new Error(`${r.id} sqrt currently requires float32 input`);if(t){if(r.output.format!=="uint32")throw new Error(`${r.id} comparison output must be uint32`)}else if(r.output.format!==r.left.format)throw new Error(`${r.id} arithmetic output format must match input format`)}function Fu(r){let e=we(r.left),t=r.right?we(r.right):void 0,n=Vu(r.operation,e,t);return`${fe(0,0)}
|
|
16
|
+
@compute @workgroup_size(1) fn main(){${rt(r.output,n)}}`}function Vu(r,e,t){switch(r){case"copy":return e;case"add":return`(${e} + ${t})`;case"subtract":return`(${e} - ${t})`;case"multiply":return`(${e} * ${t})`;case"divide":return`(${e} / ${t})`;case"sqrt":return`sqrt(${e})`;case"min":return`min(${e}, ${t})`;case"max":return`max(${e}, ${t})`;case"equal":return`select(0u,1u,${e} == ${t})`;case"not-equal":return`select(0u,1u,${e} != ${t})`;case"less-than":return`select(0u,1u,${e} < ${t})`;case"less-than-or-equal":return`select(0u,1u,${e} <= ${t})`;case"greater-than":return`select(0u,1u,${e} > ${t})`;case"greater-than-or-equal":return`select(0u,1u,${e} >= ${t})`}}function Wu(r){return["equal","not-equal","less-than","less-than-or-equal","greater-than","greater-than-or-equal"].includes(r)}var kt=class{props;id;constructor(e){this.props=e,this.id=e.id??`${e.output.id}-literal`}getCommandNodes(e){let{output:t,value:n}=this.props;if(t.arena.graph!==e)throw new Error(`${this.id} output must belong to target graph`);let o=t.format==="float32"?`f32(${n})`:t.format==="uint32"?`${n}u`:`${n}i`,i=`
|
|
17
|
+
${fe(0,0)}
|
|
18
18
|
|
|
19
19
|
@compute @workgroup_size(1)
|
|
20
20
|
fn main() {
|
|
21
|
-
${
|
|
21
|
+
${rt(t,o)}
|
|
22
22
|
}
|
|
23
|
-
`,
|
|
23
|
+
`,s=t.arena.buffer;return[j(q({id:this.id,workload:{operation:"GPUScalarLiteral",commandCount:1,maximumWorkgroupCount:1,maximumInvocationCount:1,readByteLength:0,writeByteLength:4},resources:[{buffer:s,usage:"storage-write"}],compile:({device:a})=>{let c=new k(a,{id:this.id,source:i,shaderLayout:{bindings:[{name:"gpuValues",type:"storage",group:0,location:0}]}});return{encode:({computePass:u,getBuffer:d})=>{let h={gpuValues:d(s)};c.dispatch(u,{bindings:h,x:1,y:1,z:1})},destroy:()=>c.destroy()}}}),[1,1,1])]}};function Qr(r,e,t,n){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new Error(`${r} element count must be a non-negative uint32`);Ts(r,t);let o=Math.floor(n);if(!Number.isSafeInteger(o)||o<1)throw new Error("maxComputeWorkgroupsPerDimension must be a positive integer");let i=Math.max(1,Math.ceil(e/t)),s=Math.min(i,o),a=Math.min(Math.ceil(i/s),o),c=Math.ceil(i/s/a);if(c>o)throw new Error(`${r} requires ${i} workgroups, exceeding the 3D dispatch limit of ${o} per dimension`);return{x:s,y:a,z:c}}function Et(r,e){Ts("GPU dispatch",e);let t=Math.floor(4294967295/e)+1;return`let workgroupIndex = (workgroupId.z * ${r.y}u + workgroupId.y) * ${r.x}u + workgroupId.x;
|
|
24
24
|
if (workgroupIndex >= ${t}u) { return; }
|
|
25
|
-
let index = workgroupIndex * ${e}u + localInvocationIndex;`}function
|
|
25
|
+
let index = workgroupIndex * ${e}u + localInvocationIndex;`}function Ts(r,e){if(!Number.isSafeInteger(e)||e<2||e>4294967295||4294967296%e!==0)throw new Error(`${r} workgroup size must be a power of two greater than one`)}function $(r){return r instanceof _?r.data:[r]}function Fe(r,e){let t=e[0]?.length??0;if(e.some(c=>c.length!==t))throw new Error("Aligned vectors must have equal logical lengths");let n=e.map($),o=e.map(()=>0),i=e.map(()=>0),s=[],a=0;for(;a<t;){for(let h=0;h<n.length;h++)for(;n[h][o[h]]?.length===i[h];)o[h]++,i[h]=0;let c=n.map((h,f)=>h[o[f]]),u=Math.min(...c.map((h,f)=>h.length-i[f])),d=[];for(let h=0;h<c.length;h++){let f=c[h],l=c.findIndex((m,g)=>g<h&&m===f&&i[g]===i[h]);d.push(l>=0?d[l]:i[h]===0&&u===f.length?f:r.createDataView(f.buffer,{format:f.format,length:u,byteOffset:f.byteOffset+i[h]*f.byteStride,byteStride:f.byteStride,rowByteLength:f.rowByteLength}))}s.push(d);for(let h=0;h<i.length;h++)i[h]+=u;a+=u}return s}var Jr=256,en=class r{props;id;constructor(e){this.props=e,this.id=e.id??"gpu-vector-scalar-madd";for(let[t,n]of Object.entries({input:e.input,addend:e.addend,output:e.output}))for(let o of $(n))Tt(o,["float32"],`${this.id} ${t}`);if(e.input.length!==e.addend.length||e.input.length!==e.output.length)throw new Error(`${this.id} vector lengths must match`)}getCommandNodes(e){let{input:t,scale:n,addend:o,output:i,gate:s}=this.props;if(t instanceof _||o instanceof _||i instanceof _)return Fe(e,[t,o,i]).flatMap(([l,m,g],x)=>new r({id:`${this.id}-chunk-${x}`,input:l,addend:m,output:g,scale:n,gate:s}).getCommandNodes(e));if([t,o,i].some(l=>l.buffer.graph!==e)||n.arena.graph!==e)throw new Error(`${this.id} resources must belong to target graph`);if(i.length===0)return[];let a=n.arena.buffer,c=Qr("GPUVectorScalarMADD",i.length,Jr,e.device.limits.maxComputeWorkgroupsPerDimension),u=t===i?"outputValues":"inputValues",d=o===i?"outputValues":"addendValues",h=`
|
|
26
26
|
const LENGTH: u32 = ${i.length}u;
|
|
27
|
-
const I: u32 = ${
|
|
28
|
-
const A: u32 = ${
|
|
29
|
-
const O: u32 = ${
|
|
27
|
+
const I: u32 = ${N(t)}u;
|
|
28
|
+
const A: u32 = ${N(o)}u;
|
|
29
|
+
const O: u32 = ${N(i)}u;
|
|
30
30
|
|
|
31
31
|
${t===i?"":"@group(0) @binding(0) var<storage, read> inputValues: array<f32>;"}
|
|
32
|
-
${
|
|
32
|
+
${o===i?"":"@group(0) @binding(1) var<storage, read> addendValues: array<f32>;"}
|
|
33
33
|
@group(0) @binding(2) var<storage, read_write> outputValues: array<f32>;
|
|
34
|
-
${
|
|
34
|
+
${fe(0,3)}
|
|
35
35
|
|
|
36
|
-
@compute @workgroup_size(${
|
|
36
|
+
@compute @workgroup_size(${Jr})
|
|
37
37
|
fn main(
|
|
38
38
|
@builtin(workgroup_id) workgroupId: vec3u,
|
|
39
39
|
@builtin(local_invocation_index) localInvocationIndex: u32
|
|
40
40
|
) {
|
|
41
|
-
${
|
|
41
|
+
${Et(c,Jr)}
|
|
42
42
|
if (index >= LENGTH) {
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
let x = ${
|
|
47
|
-
let y = ${
|
|
48
|
-
outputValues[O + index] = ${
|
|
46
|
+
let x = ${u}[I + index];
|
|
47
|
+
let y = ${d}[A + index];
|
|
48
|
+
outputValues[O + index] = ${we(n)} * x + y;
|
|
49
49
|
}
|
|
50
|
-
`,
|
|
50
|
+
`,f=[j(q({id:this.id,workload:{operation:"GPUVectorScalarMADD",commandCount:1,maximumWorkgroupCount:c.x*c.y*c.z,maximumInvocationCount:c.x*c.y*c.z*Jr,readByteLength:t.length*8+4,writeByteLength:i.length*4},resources:[...t===i?[]:[{buffer:t,usage:"storage-read"}],...o===i?[]:[{buffer:o,usage:"storage-read"}],{buffer:i,usage:t===i||o===i?"storage-read-write":"storage-write"},{buffer:a,usage:"storage-read"}],compile:({device:l})=>{let m=new k(l,{id:this.id,source:h,shaderLayout:{bindings:[...t===i?[]:[{name:"inputValues",type:"read-only-storage",group:0,location:0}],...o===i?[]:[{name:"addendValues",type:"read-only-storage",group:0,location:1}],{name:"outputValues",type:"storage",group:0,location:2},{name:"gpuValues",type:"read-only-storage",group:0,location:3}]}});return{encode:({computePass:g,getBuffer:x})=>{let T={...t===i?{}:{inputValues:K(t,x)},...o===i?{}:{addendValues:K(o,x)},outputValues:K(i,x),gpuValues:x(a)};m.dispatch(g,{bindings:T,x:c.x,y:c.y,z:c.z})},destroy:()=>m.destroy()}}}),[c.x,c.y,c.z])];return s?Zr(e,f,s.active):f}};function tn(r,e={}){let t=r.features?.has("subgroups"),n=!e.requiresSubgroupId||r.wgslLanguageFeatures?.has("subgroup_id");return t&&n?"subgroups":"portable"}function Ro(r,e,t,n){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<0||t+n>e.length)throw new Error("Graph range must fit the source");let o=[],i=e instanceof _?e.chunks:[{offset:0,length:e.length,data:e}],s=0,a=i.length;for(;s<a;){let c=Math.floor((s+a)/2);i[c].offset+i[c].length<=t?s=c+1:a=c}for(let c=s;c<i.length&&i[c].offset<t+n;c++){let{data:u,offset:d}=i[c],h=Math.max(t,d),f=Math.min(t+n,d+u.length);h<f&&o.push(h===d&&f===d+u.length?u:r.createDataView(u.buffer,{format:u.format,length:f-h,byteOffset:u.byteOffset+(h-d)*u.byteStride,byteStride:u.byteStride,rowByteLength:u.rowByteLength}))}return new _({id:`graph-range-${t}-${n}`,name:`graph-range-${t}-${n}`,stride:e instanceof _?e.stride:D(e.format).components*(D(e.format).listSize??1),format:e.format,length:n,valueLength:n*(D(e.format).listSize??1),byteStride:e.byteStride,rowByteLength:e.rowByteLength,data:o})}function Ms(r,e,t){if([...e,...t].some(a=>a.length>4294967295))throw new Error("Logical lengths must fit uint32 addressing");let n=e.flatMap($),o=t.flatMap($);for(let a of[...n,...o])if(a.buffer.graph!==r)throw new Error("Views must belong to the target graph");let i=new Set(n.map(a=>a.buffer)),s=new Map;for(let a of o){if(i.has(a.buffer))throw new Error("Outputs must use separate buffers from inputs");if(!a.length)continue;let c=s.get(a.buffer)??[];c.push(a),s.set(a.buffer,c)}for(let a of s.values()){a.sort((u,d)=>u.byteOffset-d.byteOffset);let c=0;for(let u of a){if(u.byteOffset<c)throw new Error("Writable chunks must not overlap");c=u.byteOffset+(u.length-1)*u.byteStride+u.rowByteLength}}}function zt(r,e){if(!Number.isSafeInteger(r)||r<1||r>4294967295||!Number.isSafeInteger(e)||e<1)throw new Error("Invalid chunk dispatch");let t=Math.min(r,e),n=Math.min(Math.ceil(r/t),e),o=Math.ceil(r/t/n);if(o>e)throw new Error("Chunk operation exceeds the 3D dispatch limit");return{x:t,y:n,z:o}}function rn(r,e){let t=[...Object.entries(e.inputs??{}),...Object.entries(e.outputs)];for(let[,o]of t)if(xr(o).size>r.device.limits.maxStorageBufferBindingSize)throw new Error("Active chunks must fit a storage binding");let n=e.dispatch.x*e.dispatch.y*e.dispatch.z;return j(q({id:e.id,workload:{commandCount:1,maximumWorkgroupCount:n,maximumInvocationCount:n*(e.workgroupSize??256)},resources:[...Object.values(e.inputs??{}).map(o=>({buffer:o,usage:"storage-read"})),...Object.values(e.outputs).map(o=>({buffer:o,usage:"storage-read-write"}))],compile:({device:o})=>{let i=new k(o,{id:e.id,source:e.source,shaderLayout:{bindings:t.map(([s],a)=>({name:s,group:0,location:a,type:a<Object.keys(e.inputs??{}).length?"read-only-storage":"storage"}))}});return{encode:({computePass:s,getBuffer:a})=>{let c={};for(let[u,d]of t)c[u]=K(d,a);i.dispatch(s,{bindings:c,x:e.dispatch.x,y:e.dispatch.y,z:e.dispatch.z})},destroy:()=>i.destroy()}}}),[e.dispatch.x,e.dispatch.y,e.dispatch.z])}var St=256;function qu(r){if(!Number.isSafeInteger(r)||r<1)throw new Error("reduction length must be positive");let e=[];do r=Math.ceil(r/St),e.push(r);while(r>1);return e}function Es(r,e){let t=[],n=e.input,o=e.inputB===n?void 0:e.inputB,i=e.inputB===n;for(let[s,a]of qu(n.length).entries()){let c=a>1?Mt(r,`${e.id}-partials-${s}`,"float32",a):void 0;t.push(ju(r,{id:`${e.id}-level-${s}`,input:n,inputB:o,square:i,output:c,finalScalar:c?void 0:e.output,accumulate:e.accumulate})),c&&(n=c),o=void 0,i=!1}return t}function ju(r,e){let t=e.output?.length??1,n=zt(t,r.device.limits.maxComputeWorkgroupsPerDimension),o=e.finalScalar?.arena.buffer,i=e.inputB?2:1,s=tn(r.device,{requiresSubgroupId:!0})==="subgroups",a=Yu(e,n,s);return j(q({id:e.id,workload:{operation:"GPUDotProductScalar",commandCount:1,maximumWorkgroupCount:n.x*n.y*n.z,maximumInvocationCount:n.x*n.y*n.z*St,readByteLength:e.input.length*4*(e.inputB?2:1),writeByteLength:t*4},resources:[{buffer:e.input,usage:"storage-read"},...e.inputB?[{buffer:e.inputB,usage:"storage-read"}]:[],...e.output?[{buffer:e.output,usage:"storage-write"}]:[],...o?[{buffer:o,usage:"storage-read-write"}]:[]],compile:({device:c})=>{let u=new k(c,{id:e.id,source:a,shaderLayout:{bindings:[{name:"inputValues",type:"read-only-storage",group:0,location:0},...e.inputB?[{name:"inputBValues",type:"read-only-storage",group:0,location:1}]:[],{name:e.output?"outputValues":"gpuValues",type:"storage",group:0,location:i}]}});return{encode:({computePass:d,getBuffer:h})=>{let f={inputValues:K(e.input,h)};e.inputB&&(f.inputBValues=K(e.inputB,h)),e.output&&(f.outputValues=K(e.output,h)),o&&(f.gpuValues=h(o)),u.dispatch(d,{bindings:f,...n})},destroy:()=>u.destroy()}}}),[n.x,n.y,n.z])}function Yu(r,e,t){let n=r.inputB?2:1,o=`inputValues[${N(r.input)}u + index]`,i=r.inputB?`${o} * inputBValues[${N(r.inputB)}u + index]`:r.square?`${o} * ${o}`:o,s=r.output?`outputValues[${N(r.output)}u + groupIndex] = total;`:rt(r.finalScalar,r.accumulate?`${we(r.finalScalar)} + total`:"total");return`${t?`enable subgroups;
|
|
51
51
|
requires subgroup_id;
|
|
52
52
|
`:""}
|
|
53
53
|
@group(0) @binding(0) var<storage, read> inputValues: array<f32>;
|
|
54
54
|
${r.inputB?"@group(0) @binding(1) var<storage, read> inputBValues: array<f32>;":""}
|
|
55
|
-
${r.output?`@group(0) @binding(${
|
|
56
|
-
${t?
|
|
57
|
-
@compute @workgroup_size(${
|
|
55
|
+
${r.output?`@group(0) @binding(${n}) var<storage, read_write> outputValues: array<f32>;`:fe(0,n)}
|
|
56
|
+
${t?Xu:Hu}
|
|
57
|
+
@compute @workgroup_size(${St})
|
|
58
58
|
fn main(
|
|
59
59
|
@builtin(local_invocation_index) lane: u32,
|
|
60
60
|
@builtin(workgroup_id) workgroupId: vec3u${t?`,
|
|
@@ -64,57 +64,57 @@ fn main(
|
|
|
64
64
|
) {
|
|
65
65
|
let groupIndex = workgroupId.x + ${e.x}u * (workgroupId.y + ${e.y}u * workgroupId.z);
|
|
66
66
|
if (groupIndex >= ${r.output?.length??1}u) { return; }
|
|
67
|
-
let index = groupIndex * ${
|
|
67
|
+
let index = groupIndex * ${St}u + lane;
|
|
68
68
|
var value = 0.0;
|
|
69
69
|
if (index < ${r.input.length}u) { value = ${i}; }
|
|
70
70
|
let total = reduceValue(value, lane${t?", subgroupInvocationId, subgroupSize, subgroupId":""});
|
|
71
|
-
if (lane == 0u) { ${
|
|
72
|
-
}`}var
|
|
73
|
-
var<workgroup> reductionScratch: array<f32, ${
|
|
71
|
+
if (lane == 0u) { ${s} }
|
|
72
|
+
}`}var Hu=`
|
|
73
|
+
var<workgroup> reductionScratch: array<f32, ${St}>;
|
|
74
74
|
fn reduceValue(value: f32, lane: u32) -> f32 {
|
|
75
75
|
reductionScratch[lane] = value;
|
|
76
76
|
workgroupBarrier();
|
|
77
|
-
for (var stride = ${
|
|
77
|
+
for (var stride = ${St/2}u; stride > 0u; stride /= 2u) {
|
|
78
78
|
if (lane < stride) { reductionScratch[lane] += reductionScratch[lane + stride]; }
|
|
79
79
|
workgroupBarrier();
|
|
80
80
|
}
|
|
81
81
|
return reductionScratch[0];
|
|
82
|
-
}`,
|
|
82
|
+
}`,Xu=`
|
|
83
83
|
var<workgroup> subgroupTotals: array<f32, 64>;
|
|
84
84
|
fn reduceValue(value: f32, lane: u32, subgroupInvocationId: u32, subgroupSize: u32, subgroupId: u32) -> f32 {
|
|
85
85
|
let subtotal = subgroupAdd(value);
|
|
86
86
|
if (subgroupInvocationId == 0u) { subgroupTotals[subgroupId] = subtotal; }
|
|
87
87
|
workgroupBarrier();
|
|
88
|
-
let subgroupCount = ${
|
|
88
|
+
let subgroupCount = ${St}u / subgroupSize;
|
|
89
89
|
for (var stride = subgroupCount / 2u; stride > 0u; stride /= 2u) {
|
|
90
90
|
if (lane < stride) { subgroupTotals[lane] += subgroupTotals[lane + stride]; }
|
|
91
91
|
workgroupBarrier();
|
|
92
92
|
}
|
|
93
93
|
return subgroupTotals[0];
|
|
94
|
-
}`;var
|
|
95
|
-
const WORDS_PER_ROW: u32 = ${
|
|
96
|
-
const OUTPUT_OFFSET: u32 = ${
|
|
94
|
+
}`;var nn=class{props;id;constructor(e){this.props=e,this.id=e.id??"gpu-dot-product-scalar";for(let t of[e.left,e.right])for(let n of $(t))Tt(n,["float32"],this.id);if(e.left.length!==e.right.length||e.left.length>4294967295)throw new Error(`${this.id} inputs must have equal uint32-addressable lengths`)}getCommandNodes(e){let{left:t,right:n,output:o,gate:i}=this.props;if(o.arena.graph!==e||i&&i.active.arena.graph!==e||[t,n].flatMap($).some(c=>c.buffer.graph!==e))throw new Error(`${this.id} resources must belong to target graph`);let s=[],a=0;for(let c of Fe(e,[t,n]))for(let u=0;u<c[0].length;){let d=Math.min(c[0].length-u,...c.map(l=>Math.floor((e.device.limits.maxStorageBufferBindingSize-(l.byteOffset+u*4)%256)/4)));if(d<1)throw new Error("Dot product span must fit a storage binding");let h=e.createDataView(c[0].buffer,{format:"float32",byteOffset:c[0].byteOffset+u*4,length:d}),f=c[1]===c[0]?h:e.createDataView(c[1].buffer,{format:"float32",byteOffset:c[1].byteOffset+u*4,length:d});s.push(...Es(e,{id:`${this.id}-chunk-${a}`,input:h,inputB:f,output:o,accumulate:a>0})),a++,u+=d}return a||s.push(...new kt({id:this.id,output:o,value:0}).getCommandNodes(e)),i?Zr(e,s,i.active):s}};var on=256,$t=Uint32Array.BYTES_PER_ELEMENT,sn=class{id;source;indices;output;wordsPerRow;constructor(e){this.id=e.id??"gpu-gather",this.source=e.source,this.indices=e.indices,this.output=e.output;for(let n of $(this.indices))xs(n,`${this.id} indices`);for(let n of[this.source,this.output])for(let o of $(n))Ku(o,this.id,n===this.output);if(this.source.format!==this.output.format)throw new Error(`${this.id} source and output must use the same format`);if(this.output.length<this.indices.length)throw new Error(`${this.id} output must contain at least indices.length rows`);let t=new Set([...$(this.source).map(n=>n.buffer),...$(this.indices).map(n=>n.buffer)]);if($(this.output).some(n=>t.has(n.buffer)))throw new Error(`${this.id} output must use a separate buffer`);this.wordsPerRow=D(this.source.format).byteLength/$t}getCommandNodes(e){return Zu(e,this)}};function Zu(r,e,t=0,n="GPUGather"){let o=[];for(let u of[e.source,e.indices,e.output])for(let d of $(u))if(d.buffer.graph!==r)throw new Error(`${e.id} views must belong to the target graph`);if(e.indices.length===0)return o;let i=ys(r,e.output,e.indices.length),s=Fe(r,[e.indices,i]),a=Ne($(e.source)).filter(u=>u.length),c=a.length?a:[void 0];for(let[u,[d,h]]of s.entries()){let f=Qr(n,d.length,on,r.device.limits.maxComputeWorkgroupsPerDimension);for(let[l,m]of c.entries()){let g=m?.data;for(let M of[h,...g?[g,d]:[]])if(xr(M).size>r.device.limits.maxStorageBufferBindingSize)throw new Error("Active chunks must fit a storage binding");let x=s.length===1&&c.length===1?e.id:`${e.id}-span-${u}-source-${l}`,T=Qu({source:g,sourceOffset:m?.offset??0,indices:d,output:h,wordsPerRow:e.wordsPerRow,initialize:l===0,invalidValue:t,dispatchLayout:f});o.push(j(q({id:x,workload:{operation:n,commandCount:1,maximumWorkgroupCount:f.x*f.y*f.z,maximumInvocationCount:f.x*f.y*f.z*on,readByteLength:g?d.length*($t+g.rowByteLength):0,writeByteLength:d.length*h.rowByteLength},resources:[...g?[{buffer:g,usage:"storage-read"},{buffer:d,usage:"storage-read"}]:[],{buffer:h,usage:"storage-write"}],compile:({device:M})=>{let w=new k(M,{id:x,source:T,shaderLayout:{bindings:[{name:"outputWords",type:"storage",group:0,location:0},...g?[{name:"sourceWords",type:"read-only-storage",group:0,location:1},{name:"indices",type:"read-only-storage",group:0,location:2}]:[]]}});return{encode:({computePass:b,getBuffer:p})=>{let y={outputWords:K(h,p)};g&&(y.sourceWords=K(g,p),y.indices=K(d,p)),w.dispatch(b,{bindings:y,x:f.x,y:f.y,z:f.z})},destroy:()=>w.destroy()}}}),[f.x,f.y,f.z]))}}return o}function Ku(r,e,t){if(Qe(r.format)||Je(r.format))throw new Error(`${e} must use a fixed-width GPU data format`);let n=D(r.format);if((t?r.byteStride!==n.byteLength:r.byteStride<n.byteLength||r.byteStride%$t!==0)||r.rowByteLength!==n.byteLength||r.byteOffset%$t!==0||r.rowByteLength%$t!==0)throw new Error(`${e} must be packed, uint32-aligned GPU data with 32-bit-word rows`)}function Qu(r){let{source:e,indices:t,output:n,wordsPerRow:o,initialize:i,invalidValue:s,dispatchLayout:a}=r;return`const INDEX_COUNT: u32 = ${t.length}u;
|
|
95
|
+
const WORDS_PER_ROW: u32 = ${o}u;
|
|
96
|
+
const OUTPUT_OFFSET: u32 = ${N(n)}u;
|
|
97
97
|
@group(0) @binding(0) var<storage, read_write> outputWords: array<u32>;
|
|
98
98
|
${e?`
|
|
99
99
|
const SOURCE_LENGTH: u32 = ${e.length}u;
|
|
100
100
|
const SOURCE_ROW_OFFSET: u32 = ${r.sourceOffset}u;
|
|
101
|
-
const SOURCE_OFFSET: u32 = ${
|
|
102
|
-
const INDEX_OFFSET: u32 = ${
|
|
101
|
+
const SOURCE_OFFSET: u32 = ${N(e)}u;
|
|
102
|
+
const INDEX_OFFSET: u32 = ${N(t)}u;
|
|
103
103
|
@group(0) @binding(1) var<storage, read> sourceWords: array<u32>;
|
|
104
104
|
@group(0) @binding(2) var<storage, read> indices: array<u32>;
|
|
105
105
|
`:""}
|
|
106
|
-
@compute @workgroup_size(${
|
|
106
|
+
@compute @workgroup_size(${on})
|
|
107
107
|
fn main(
|
|
108
108
|
@builtin(workgroup_id) workgroupId: vec3u,
|
|
109
109
|
@builtin(local_invocation_index) localInvocationIndex: u32
|
|
110
110
|
) {
|
|
111
|
-
${
|
|
111
|
+
${Et(a,on)}
|
|
112
112
|
if (index >= INDEX_COUNT) { return; }
|
|
113
113
|
let outputBase = OUTPUT_OFFSET + index * WORDS_PER_ROW;
|
|
114
114
|
${e?`
|
|
115
115
|
let sourceIndex = indices[INDEX_OFFSET + index];
|
|
116
116
|
if (sourceIndex >= SOURCE_ROW_OFFSET && sourceIndex - SOURCE_ROW_OFFSET < SOURCE_LENGTH) {
|
|
117
|
-
let sourceBase = SOURCE_OFFSET + (sourceIndex - SOURCE_ROW_OFFSET) * ${e.byteStride
|
|
117
|
+
let sourceBase = SOURCE_OFFSET + (sourceIndex - SOURCE_ROW_OFFSET) * ${e.byteStride/$t}u;
|
|
118
118
|
for (var word = 0u; word < WORDS_PER_ROW; word++) {
|
|
119
119
|
outputWords[outputBase + word] = sourceWords[sourceBase + word];
|
|
120
120
|
}
|
|
@@ -123,73 +123,73 @@ ${e?`
|
|
|
123
123
|
`:""}
|
|
124
124
|
${i?`
|
|
125
125
|
for (var word = 0u; word < WORDS_PER_ROW; word++) {
|
|
126
|
-
outputWords[outputBase + word] = ${
|
|
126
|
+
outputWords[outputBase + word] = ${s}u;
|
|
127
127
|
}
|
|
128
128
|
`:""}
|
|
129
|
-
}`}function
|
|
129
|
+
}`}function Ps(r){if(r.candidates.length===0)throw new Error("GPU strategy candidate list must not be empty");let e={device:r.device,workload:r.workload},t=r.candidates.filter(i=>i.isSupported?.(e)??!0);if(t.length===0)throw new Error("no supported GPU strategy candidate");if(r.preferredId){let i=t.find(s=>s.id===r.preferredId);if(!i)throw new Error(`preferred GPU strategy "${r.preferredId}" is not supported`);return Ss(i,e)}let n=t[0],o=n.score(e);for(let i=1;i<t.length;i++){let s=t[i],a=s.score(e);a>o&&(n=s,o=a)}return Ss(n,e,o)}function Ss(r,e,t=r.score(e)){return Object.freeze({id:r.id,score:t,reason:r.reason(e),details:Object.freeze(r.createDetails(e))})}function Cs(r,e,t){if(!Number.isSafeInteger(e.rows)||e.rows<0)throw new Error("SpMV rows must be non-negative");if(!Number.isSafeInteger(e.nonZeros)||e.nonZeros<0)throw new Error("SpMV nonZeros must be non-negative");let n=e.nonZeros/Math.max(1,e.rows),o=e.statistics?.maxNonZerosPerRow,i=e.statistics?.shortRowFraction,s=tn(r,{requiresSubgroupId:!0})==="subgroups";return Ps({device:r,workload:e,preferredId:t,candidates:[{id:"scalar-row",score:()=>n<=8?100:n<=16?60:10,reason:()=>`average row length ${n.toFixed(1)} favors one invocation per row`,createDetails:()=>({rowsPerWorkgroup:64,workgroupSize:64,workgroupsPerLongRow:1})},{id:"subgroup-row",isSupported:()=>s,score:()=>n<=64&&(i===void 0||i<.9)?110:35,reason:()=>"subgroups available; medium CSR rows can reduce within a subgroup",createDetails:()=>({rowsPerWorkgroup:1,workgroupSize:128,workgroupsPerLongRow:1})},{id:"workgroup-row",score:()=>n>32&&(o===void 0||o<=2048)?100:50,reason:()=>`average row length ${n.toFixed(1)} favors cooperative row reduction`,createDetails:()=>({rowsPerWorkgroup:1,workgroupSize:256,workgroupsPerLongRow:1})},{id:"long-row",score:()=>o!==void 0&&o>2048||n>1024?140:0,reason:()=>"very long rows favor multi-workgroup partial reduction",createDetails:()=>({rowsPerWorkgroup:1,workgroupSize:256,workgroupsPerLongRow:4})}]})}var an=class{id;props;constructor(e){this.id=e.id??"gpu-adaptive-spmv",this.props=e;for(let[t,n]of Object.entries({rowOffsets:e.rowOffsets,columnIndices:e.columnIndices,values:e.values,vector:e.vector,output:e.output})){for(let o of $(n))Tt(o,[t==="rowOffsets"||t==="columnIndices"?"uint32":"float32"],`${this.id} ${t}`);if(n.length>4294967295)throw new Error("SpMV logical lengths must fit in uint32")}if(e.rowOffsets.length!==e.output.length+1)throw new Error(`${this.id} rowOffsets length must equal output.length + 1`);if(e.columnIndices.length!==e.values.length)throw new Error(`${this.id} columnIndices and values must have equal length`);if(!Number.isSafeInteger(e.columns)||e.columns<0)throw new Error(`${this.id} columns must be a non-negative integer`);if(e.vector.length!==e.columns)throw new Error(`${this.id} vector length must equal columns`)}getStrategy(e){return Cs(e.device,{rows:this.props.output.length,nonZeros:this.props.values.length,statistics:this.props.statistics},this.props.strategy)}explain(e){let t=this.getStrategy(e);return Object.freeze({operation:"GPUSpMV",strategy:t.id,score:t.score,reason:t.reason,...t.details})}getCommandNodes(e){let{rowOffsets:t,columnIndices:n,values:o,vector:i,output:s}=this.props;if(Ms(e,[t,n,o,i],[s]),!s.length)return[];let a=[],c=this.getStrategy(e),u=c.id,d=c.details.workgroupSize,h=u==="long-row"?c.details.workgroupsPerLongRow:1,f=Fe(e,[Ro(e,t,0,s.length),Ro(e,t,1,s.length),s]),l=Fe(e,[n,o]),m=Ne($(i)).filter(y=>y.length),g=e.device.limits.maxComputeWorkgroupsPerDimension,x=Math.min(4096,Math.floor(e.device.limits.maxStorageBufferBindingSize/(h*4)));if(x<1)throw new Error("SpMV count scratch must fit a storage binding");let T=[];for(let y of f)for(let S=0;S<y[0].length;S+=x){let P=Math.min(x,y[0].length-S);T.push(y.map(E=>e.createDataView(E.buffer,{format:E.format,length:P,byteOffset:E.byteOffset+S*4})))}let M=T.map(([y],S)=>u==="long-row"?Mt(e,`${this.id}-rows-${S}-partials`,"float32",y.length*h):void 0),w=m.length>1&&T.length*m.length>m.length+T.length,b=0,p=[];for(let[y,[S,P]]of l.entries()){let E;if(w){E=Mt(e,`${this.id}-gather-${y}`,"float32",S.length);let v=new sn({id:`${this.id}-gather-${y}`,source:i,indices:S,output:E}).getCommandNodes(e);for(let[I,A]of v.entries())a.push(I===0?{...A,dependsOn:[...A.dependsOn??[],...p]}:A)}let C=E?[{data:E,offset:0}]:m,L=[];for(let[v,[I,A,G]]of T.entries()){let F=I.length,ht=M[v];for(let[ft,Re]of C.entries()){let Kt=y===0&&ft===0,pe=`${this.id}-rows-${v}-nonzeros-${y}-vector-${ft}-${u}`,Cr=u==="scalar-row"?Math.ceil(F/d):F*h,ce=zt(Cr,g),Qt=ht??G;if(a.push(rn(e,{id:pe,source:Ju({strategy:u,workgroupSize:d,parts:h,length:F,begins:I,ends:A,indices:S,matrixValues:P,vector:Re.data,output:Qt,nonzeroStart:b,vectorStart:Re.offset,initialize:Kt,dispatch:ce,gathered:!!E,columns:this.props.columns}),inputs:{rowBegins:I,rowEnds:A,columnIndices:S,matrixValues:P,vectorValues:Re.data},outputs:{[ht?"rowPartials":"outputValues"]:Qt},dispatch:ce,workgroupSize:d})),ht){let Jt=zt(Math.ceil(F/64),g);a.push(rn(e,{id:`${pe}-finalize`,inputs:{rowPartials:ht},outputs:{outputValues:G},dispatch:Jt,workgroupSize:64,source:`
|
|
130
130
|
@group(0) @binding(0) var<storage, read> rowPartials: array<f32>;
|
|
131
131
|
@group(0) @binding(1) var<storage, read_write> outputValues: array<f32>;
|
|
132
132
|
@compute @workgroup_size(64)
|
|
133
133
|
fn main(@builtin(workgroup_id) workgroupId: vec3u, @builtin(local_invocation_index) localInvocationIndex: u32) {
|
|
134
|
-
${
|
|
135
|
-
if (index >= ${
|
|
134
|
+
${Et(Jt,64)}
|
|
135
|
+
if (index >= ${F}u) { return; }
|
|
136
136
|
var sum = 0.0;
|
|
137
|
-
for (var part = 0u; part < ${
|
|
138
|
-
sum += rowPartials[index * ${
|
|
137
|
+
for (var part = 0u; part < ${h}u; part++) {
|
|
138
|
+
sum += rowPartials[index * ${h}u + part];
|
|
139
139
|
}
|
|
140
|
-
outputValues[${
|
|
141
|
-
}`}))}}
|
|
140
|
+
outputValues[${N(G)}u + index] ${Kt?"=":"+="} sum;
|
|
141
|
+
}`}))}}C.length&&L.push(a[a.length-1].id)}p=L,b+=S.length}if(!l.length||!m.length)for(let[y,[S,,P]]of T.entries()){let E=zt(Math.ceil(S.length/256),g);a.push(rn(e,{id:`${this.id}-rows-${y}-clear`,outputs:{outputValues:P},dispatch:E,source:`
|
|
142
142
|
@group(0) @binding(0) var<storage, read_write> outputValues: array<f32>;
|
|
143
143
|
@compute @workgroup_size(256)
|
|
144
144
|
fn main(@builtin(workgroup_id) workgroupId: vec3u, @builtin(local_invocation_index) localInvocationIndex: u32) {
|
|
145
|
-
${
|
|
146
|
-
if (index < ${
|
|
147
|
-
outputValues[${
|
|
145
|
+
${Et(E,256)}
|
|
146
|
+
if (index < ${S.length}u) {
|
|
147
|
+
outputValues[${N(P)}u + index] = 0.0;
|
|
148
148
|
}
|
|
149
|
-
}`}))}return
|
|
150
|
-
${
|
|
149
|
+
}`}))}return a}};function Ju(r){let{strategy:e,workgroupSize:t,parts:n,length:o,dispatch:i}=r,s=e==="subgroup-row",a=e==="workgroup-row"||e==="long-row",c=e==="long-row",u=c?"rowPartials":"outputValues";return`
|
|
150
|
+
${s?`enable subgroups;
|
|
151
151
|
requires subgroup_id;`:""}
|
|
152
152
|
@group(0) @binding(0) var<storage, read> rowBegins: array<u32>;
|
|
153
153
|
@group(0) @binding(1) var<storage, read> rowEnds: array<u32>;
|
|
154
154
|
@group(0) @binding(2) var<storage, read> columnIndices: array<u32>;
|
|
155
155
|
@group(0) @binding(3) var<storage, read> matrixValues: array<f32>;
|
|
156
156
|
@group(0) @binding(4) var<storage, read> vectorValues: array<f32>;
|
|
157
|
-
@group(0) @binding(5) var<storage, read_write> ${
|
|
158
|
-
${
|
|
157
|
+
@group(0) @binding(5) var<storage, read_write> ${u}: array<f32>;
|
|
158
|
+
${a?`var<workgroup> scratch: array<f32, ${t}>;`:""}
|
|
159
159
|
@compute @workgroup_size(${t}) fn main(
|
|
160
160
|
@builtin(workgroup_id) workgroupId: vec3u,
|
|
161
|
-
@builtin(local_invocation_index) localInvocationIndex: u32${
|
|
161
|
+
@builtin(local_invocation_index) localInvocationIndex: u32${s?`,
|
|
162
162
|
@builtin(subgroup_id) subgroupId: u32,
|
|
163
163
|
@builtin(subgroup_invocation_id) subgroupLane: u32,
|
|
164
164
|
@builtin(subgroup_size) subgroupSize: u32`:""}
|
|
165
165
|
) {
|
|
166
166
|
let workgroupIndex = (workgroupId.z * ${i.y}u + workgroupId.y) * ${i.x}u + workgroupId.x;
|
|
167
|
-
${e==="scalar-row"?`let row = workgroupIndex * ${t}u + localInvocationIndex;`:`let row = workgroupIndex / ${
|
|
168
|
-
if (row >= ${
|
|
169
|
-
${
|
|
170
|
-
let begin = max(rowBegins[${
|
|
171
|
-
let end = min(rowEnds[${
|
|
172
|
-
let part = workgroupIndex % ${
|
|
173
|
-
let lane = ${
|
|
174
|
-
let stride = ${
|
|
167
|
+
${e==="scalar-row"?`let row = workgroupIndex * ${t}u + localInvocationIndex;`:`let row = workgroupIndex / ${n}u;`}
|
|
168
|
+
if (row >= ${o}u) { return; }
|
|
169
|
+
${s?"if (subgroupId != 0u) { return; }":""}
|
|
170
|
+
let begin = max(rowBegins[${N(r.begins)}u + row], ${r.nonzeroStart}u);
|
|
171
|
+
let end = min(rowEnds[${N(r.ends)}u + row], ${r.nonzeroStart+r.indices.length}u);
|
|
172
|
+
let part = workgroupIndex % ${n}u;
|
|
173
|
+
let lane = ${s?"subgroupLane":a?"localInvocationIndex":"0u"};
|
|
174
|
+
let stride = ${s?"subgroupSize":`${a?t*n:1}u`};
|
|
175
175
|
var sum = 0.0;
|
|
176
176
|
// Test the lane offset before addition so an empty or final uint32 range cannot wrap.
|
|
177
177
|
var localIndex = part * ${t}u + lane;
|
|
178
178
|
loop {
|
|
179
179
|
if (begin >= end || localIndex >= end - begin) { break; }
|
|
180
180
|
let nonzero = begin - ${r.nonzeroStart}u + localIndex;
|
|
181
|
-
let column = columnIndices[${
|
|
181
|
+
let column = columnIndices[${N(r.indices)}u + nonzero];
|
|
182
182
|
${r.gathered?`if (column < ${r.columns}u) {
|
|
183
|
-
sum += matrixValues[${
|
|
183
|
+
sum += matrixValues[${N(r.matrixValues)}u + nonzero] * vectorValues[${N(r.vector)}u + nonzero];
|
|
184
184
|
}`:`if (column >= ${r.vectorStart}u && column - ${r.vectorStart}u < ${r.vector.length}u) {
|
|
185
|
-
sum += matrixValues[${
|
|
185
|
+
sum += matrixValues[${N(r.matrixValues)}u + nonzero] * vectorValues[${N(r.vector)}u + column - ${r.vectorStart}u];
|
|
186
186
|
}`}
|
|
187
187
|
|
|
188
188
|
if (end - begin - localIndex <= stride) { break; }
|
|
189
189
|
localIndex += stride;
|
|
190
190
|
}
|
|
191
|
-
${
|
|
192
|
-
${
|
|
191
|
+
${s?"sum = subgroupAdd(sum);":""}
|
|
192
|
+
${a?`scratch[lane] = sum;
|
|
193
193
|
workgroupBarrier();
|
|
194
194
|
for (var reductionStride = ${t/2}u; reductionStride > 0u; reductionStride /= 2u) {
|
|
195
195
|
if (lane < reductionStride) { scratch[lane] += scratch[lane + reductionStride]; }
|
|
@@ -197,9 +197,35 @@ ${s?`var<workgroup> scratch: array<f32, ${t}>;`:""}
|
|
|
197
197
|
}
|
|
198
198
|
sum = scratch[0];`:""}
|
|
199
199
|
if (lane == 0u) {
|
|
200
|
-
${
|
|
200
|
+
${u}[${N(r.output)}u + row * ${n}u + ${c?"part":"0u"}] ${c||r.initialize?"=":"+="} sum;
|
|
201
201
|
}
|
|
202
|
-
}`}
|
|
203
|
-
@compute @workgroup_size(1)fn main(){${Se(o,`select(0u,1u,${i})`)}}`;return[M({id:this.id,workload:{operation:"GPUPredicateConjunction",commandCount:1,maximumWorkgroupCount:1,maximumInvocationCount:1,readByteLength:t.length*4,writeByteLength:4},resources:[{buffer:n,usage:"storage-write"}],compile:({device:s})=>{let u=new A(s,{id:this.id,source:a,shaderLayout:{bindings:[{name:"gpuValues",type:"storage",group:0,location:0}]}});return{encode:({computePass:d,getBuffer:c})=>{let m={gpuValues:c(n)};u.dispatch(d,{bindings:m,x:1,y:1,z:1})},destroy:()=>u.destroy()}}})]}};var et=class extends q{type="conditional";predicate;lowering;constructor(e){let t=Array.isArray(e.body)?e.body:[e.body];super({id:e.id??"gpu-conditional-operation",operations:t,metadata:e.metadata}),this.predicate=Object.freeze({...e.predicate}),this.lowering=e.lowering??"auto"}},tt=class extends q{type="loop";predicate;maximumIterations;minimumIterations;lowering;constructor(e){let t=Array.isArray(e.body)?e.body:[e.body];if(super({id:e.id??"gpu-loop-operation",operations:t,metadata:e.metadata}),!Number.isSafeInteger(e.maximumIterations)||e.maximumIterations<1)throw new Error(`${this.id} maximumIterations must be a positive safe integer`);let o=e.minimumIterations??0;if(!Number.isSafeInteger(o)||o<0||o>e.maximumIterations)throw new Error(`${this.id} minimumIterations must be between zero and maximumIterations`);this.predicate=e.predicate?Object.freeze({...e.predicate}):void 0,this.maximumIterations=e.maximumIterations,this.minimumIterations=o,this.lowering=e.lowering??"auto"}};var rt=class{lowerers=new Map;register(e,t){if(!e)throw new Error("GPU operation lowering type is required");if(this.lowerers.has(e))throw new Error(`GPU operation lowering for "${e}" is already registered`);return this.lowerers.set(e,t),this}get(e){return this.lowerers.get(e)}};function gr(r,e={}){let t=[],o=new Set(r.scalars.map(i=>i.id));for(let i of r.vectors)i.external&&!e.vectors?.[i.id]&&t.push({level:"error",code:"missing-external-vector",valueId:i.id,message:`External vector "${i.id}" has no WebGPU binding`});let n=i=>{let a="id"in i&&typeof i.id=="string"?i.id:void 0;if(i instanceof et||i instanceof tt){let s=i.predicate;s?.source==="gpu"&&(s.value.format!=="uint32"&&t.push({level:"error",code:"invalid-predicate-format",operationId:a,valueId:s.value.id,message:`GPU predicate "${s.id}" must use uint32 state`}),o.has(s.value.id)||t.push({level:"error",code:"missing-predicate-scalar",operationId:a,valueId:s.value.id,message:`GPU predicate "${s.id}" references undeclared scalar "${s.value.id}"`}))}if(i instanceof q)for(let s of i.operations)n(s)};for(let i of r.operations)n(i);return Object.freeze({valid:!t.some(i=>i.level==="error"),issues:Object.freeze(t.map(i=>Object.freeze({...i})))})}var yr=class{device;capabilities;lowerings=new rt;constructor(e){this.device=e,this.capabilities=Object.freeze({backend:"webgpu",gpuConditionals:!0,nativeLoops:!1,childGraphs:!1}),this.registerCoreLowerings()}compile(e,t={}){let o=gr(e,t);if(!o.valid)throw new Error(`GPUGraph "${e.id}" validation failed: ${o.issues.filter(d=>d.level==="error").map(d=>d.message).join("; ")}`);let n=new er(this.device,{id:`${e.id}-commands`}),i=new Map;for(let d of e.scalars)i.set(d.id,Po(n,d.id,d.format));let a=new Map;for(let d of e.vectors){let c;if(d.external){let m=t.vectors[d.id],l="data"in m?m:{format:d.format,length:d.length,data:"buffer"in m?[m]:m};if(c=n.importGPUVector(d.id,l),c.format!==d.format||c.length!==d.length)throw new Error(`${d.id} binding format and length must match its logical vector`);if(d.chunkLengths&&(d.chunkLengths.length!==c.data.length||d.chunkLengths.some((f,h)=>f!==c.data[h].length)))throw new Error(`${d.id} binding must preserve its declared chunk topology`)}else{let m=d.chunkLengths??cs(d.length,this.device),l=m.map((f,h)=>Me(n,m.length===1?d.id:`${d.id}-chunk-${h}`,d.format,f));c=new B({id:d.id,name:d.id,format:d.format,length:d.length,valueLength:d.length,stride:1,byteStride:4,rowByteLength:4,data:l})}a.set(d.id,c)}let s=new Map;for(let d of e.textures){let c=d.external?n.importTexture(d,t.textures?.[d.id]):n.createTransientTexture(d);s.set(d.id,c)}let u={path:[],nodes:[],decisions:[],predicates:[],scalars:i,vectors:a,textures:s,textureValues:e.textures,predicateConjunctions:new Map,commandNodeIds:new Set};for(let d of e.operations)this.lower(n,d,u);return Object.freeze({program:e,graph:n,scalars:i,vectors:a,textures:s,validation:o,lowering:Object.freeze({operations:e.operationTree,nodes:Object.freeze(u.nodes.map(d=>Object.freeze({...d,operationPath:Object.freeze([...d.operationPath])}))),decisions:Object.freeze(u.decisions.map(d=>Object.freeze({...d})))})})}registerCoreLowerings(){this.lowerings.register("scalar-literal",(e,t)=>{let o=new Ze({id:e.id,output:t.resolveScalar(e.props.output),value:e.props.value});this.emitProducer(t.graph,o,[[1,1,1]]),t.recordDecision({operationId:e.id,operationType:e.type,lowering:"webgpu-scalar-literal",reason:"host-known literal lowers to one compute command node"})}),this.lowerings.register("scalar-operation",(e,t)=>{let o=new ir({id:e.id,operation:e.operation,left:t.resolveScalar(e.left),right:e.right?t.resolveScalar(e.right):void 0,output:t.resolveScalar(e.output)});this.emitProducer(t.graph,o,[[1,1,1]]),t.recordDecision({operationId:e.id,operationType:e.type,lowering:"webgpu-scalar-kernel",reason:"scalar operation lowers to one compute command node"})}),this.lowerings.register("vector-madd",(e,t)=>{let o=e.props,n=new ur({id:e.id,input:t.resolveVector(o.input),scale:t.resolveScalar(o.scale),addend:t.resolveVector(o.addend),output:t.resolveVector(o.output)});this.emitProducer(t.graph,n),t.recordDecision({operationId:e.id,operationType:e.type,lowering:"webgpu-vector-madd",reason:"dense float32 MADD lowers through explicit command nodes"})}),this.lowerings.register("dot-product",(e,t)=>{let o=e.props,n=new mr({id:e.id,left:t.resolveVector(o.left),right:t.resolveVector(o.right),output:t.resolveScalar(o.output)});this.emitProducer(t.graph,n),t.recordDecision({operationId:e.id,operationType:e.type,lowering:"webgpu-hierarchical-dot",reason:"chunk dot products use bounded hierarchical reductions into the scalar arena"})}),this.lowerings.register("spmv",(e,t)=>{let o=e.props,n=o.matrix,i=new pr({id:e.id,rowOffsets:t.resolveVector(n.rowOffsets),columnIndices:t.resolveVector(n.columnIndices),values:t.resolveVector(n.values),vector:t.resolveVector(o.vector),output:t.resolveVector(o.output),columns:n.columns,statistics:n.statistics,strategy:o.strategy}),a=i.getStrategy(t.graph);this.emitProducer(t.graph,i),t.recordDecision({operationId:e.id,operationType:e.type,lowering:`webgpu-spmv:${a.id}`,reason:a.reason})}),this.lowerings.register("conditional",(e,t)=>{t.recordDecision({operationId:e.id,operationType:e.type,lowering:"gpu-indirect-gate",reason:"WebGPU realizes runtime predicates with zero/nonzero indirect dispatch"});for(let o of e.operations)t.lowerConditional(e.predicate,o)}),this.lowerings.register("loop",(e,t)=>{if(!e.predicate||e.lowering==="unroll"){t.recordDecision({operationId:e.id,operationType:e.type,lowering:"bounded-unroll",reason:e.predicate?"explicit unroll preference":"loop has no runtime predicate"});for(let o=0;o<e.maximumIterations;o++)for(let n of e.operations)t.lower(n);return}t.recordDecision({operationId:e.id,operationType:e.type,lowering:"gpu-gated-bounded-sequence",reason:"WebGPU has indirect dispatch but no native graph loop"});for(let o=0;o<e.maximumIterations;o++){let n=o>=e.minimumIterations;for(let i of e.operations)n?t.lowerConditional(e.predicate,i):t.lower(i)}})}lower(e,t,o){let n="id"in t&&typeof t.id=="string"?t.id:t.constructor?.name??"command-node-producer";o.path.push(n);try{if(t instanceof q&&t.type==="composite"){o.decisions.push({operationId:t.id,operationType:t.type,lowering:"flatten",reason:"WebGPU has no executable child-graph primitive"});for(let i of t.operations)this.lower(e,i,o);return}if(yo(t)){let i=this.lowerings.get(t.type);if(i){let a=()=>i(t,{graph:e,capabilities:this.capabilities,lower:s=>this.lower(e,s,o),lowerConditional:(s,u)=>{o.predicates.push(s);try{this.lower(e,u,o)}finally{o.predicates.pop()}},resolveScalar:s=>this.resolveScalar(s,o),resolveVector:s=>this.resolveVector(s,o),resolveTexture:s=>this.resolveTexture(s,o),resolveTextureView:s=>{let u=s instanceof ce?s.texture:s,d=s instanceof ce?s.props:{};return e.createTextureView(this.resolveTexture(u,o),d)},recordDecision:s=>o.decisions.push(s)});t instanceof et||t instanceof tt?a():this.withNodeDecoration(e,o,a);return}}if("getNodes"in t||ri(t)){o.decisions.push({operationId:n,operationType:"command-node-producer",lowering:"explicit-command-nodes",reason:"execution primitive constructs explicit command nodes"}),this.withNodeDecoration(e,o,()=>e.add(t));return}throw new Error(`GPUGraph operation "${n}" has no WebGPU lowering`)}finally{o.path.pop()}}emitProducer(e,t,o){let n=t.getCommandNodes(e);if(!o){_e(e,n);return}if(n.length!==o.length)throw new Error(`lowering produced ${n.length} command nodes but declared ${o.length} dispatches`);let i=n.map((a,s)=>this.attachDispatch(a,o[s]));_e(e,i)}attachDispatch(e,t){if(e.type!=="compute")throw new Error(`dispatch geometry can only be attached to compute command nodes; got ${e.type} node "${e.id}"`);return k(e,t)}withNodeDecoration(e,t,o){return e.withComputeLowering(n=>this.decorateComputeNode(e,n,t),()=>e.withOtherLowering(n=>{if(t.predicates.length)throw new Error(`GPU predicates do not support ${n.type} node "${n.id}"`);let i=this.makeCommandNodeIdUnique(n,t);return t.nodes.push({nodeId:i.id,nodeType:i.type,operationPath:[...t.path]}),i},o))}decorateComputeNode(e,t,o){if(t=this.makeCommandNodeIdUnique(t,o),o.path.length&&o.nodes.push({nodeId:t.id,nodeType:"compute",operationPath:[...o.path]}),!o.predicates.length)return t;if(t.condition)throw new Error(`compute node "${t.id}" already has condition`);let n=tr(t);if(!n)throw new Error(`compute node "${t.id}" under runtime predicate must declare exact dispatch geometry`);let i;if(o.predicates.length===1)i=o.scalars.get(o.predicates[0].value.id);else{let u=o.predicates.map(l=>l.value.id).join("&&"),d=o.predicateConjunctions.get(u);d||(d=Po(e,`predicate-and-${o.predicateConjunctions.size}`,"uint32"),o.predicateConjunctions.set(u,d));let c=o.predicates.map(l=>o.scalars.get(l.value.id)),m=new hr({id:`${t.id}-predicate-and`,inputs:c,output:d}).getCommandNodes(e).map(l=>this.attachDispatch(l,[1,1,1]));e.withoutComputeLowering(()=>_e(e,m)),i=d}if(!i)throw new Error(`runtime predicate for "${t.id}" could not be resolved`);let a=new St(e,{id:`${t.id}-predicate`,active:i,workgroups:n}),s=a.getUpdateCommandNodes(e,`${t.id}-predicate-update`).map(u=>this.attachDispatch(u,[1,1,1]));return e.withoutComputeLowering(()=>_e(e,s)),{...t,condition:a.condition}}makeCommandNodeIdUnique(e,t){if(!t.commandNodeIds.has(e.id))return t.commandNodeIds.add(e.id),e;let o=1,n=`${e.id}-iteration-${o}`;for(;t.commandNodeIds.has(n);)o++,n=`${e.id}-iteration-${o}`;return t.commandNodeIds.add(n),{...e,id:n}}resolveTexture(e,t){if(!t.textureValues.includes(e))throw new Error(`Undeclared program texture "${e.id}"`);return t.textures.get(e.id)}resolveScalar(e,t){let o=t.scalars.get(e.id);if(!o||o.format!==e.format)throw new Error(`GPUGraph scalar "${e.id}" is not part of compilation`);return o}resolveVector(e,t){let o=t.vectors.get(e.id);if(!o||o.format!==e.format||o.length!==e.length)throw new Error(`GPUGraph vector "${e.id}" is not part of compilation`);return o}};function cs(r,e){let t=Math.floor(e.limits.maxStorageBufferBindingSize/4);if(t<1||r<=t)return[r];let o=[];for(let n=0;n<r;n+=t)o.push(Math.min(t,r-n));return o}function hi(r){let e=r.lowering.decisions.map(t=>`${t.operationId}: ${t.lowering} \u2014 ${t.reason}`);return Object.freeze({programId:r.program.id,semanticOperationCount:gi(r.program.operationTree),loweredNodeCount:r.lowering.nodes.length,loweringDecisionCount:r.lowering.decisions.length,scalarCount:r.program.scalars.length,vectorCount:r.program.vectors.length,externalVectorCount:r.program.vectors.filter(t=>t.external).length,cpuReadbackCount:0,backend:"webgpu",decisions:Object.freeze(e)})}function gi(r){return r.reduce((e,t)=>e+1+gi(t.children??[]),0)}var Eo=class{adapter;minimumSampleCount;explorationEnabled;calibrations=new Map;constructor(e){if(!Number.isSafeInteger(e.minimumSampleCount??1)||(e.minimumSampleCount??1)<=0)throw new Error("GPUCommandGraph autotuner minimumSampleCount must be a positive safe integer");if(this.adapter=ls(e.adapter),this.minimumSampleCount=e.minimumSampleCount??1,this.explorationEnabled=e.explorationEnabled??!0,e.profile?.adapter.key===this.adapter.key&&e.profile.version===1)for(let t of e.profile.calibrations)this.importCalibration(t)}selectKernel(e){xr(e.operation,"operation"),bi(e.workloadSize);let t=e.candidates.filter(s=>s.supported!==!1);if(t.length===0)throw new Error(`GPUCommandGraph autotuner operation "${e.operation}" has no supported variants`);for(let s of t)xr(s.id,"variant");let o=xi(e.workloadSize),n=t.map(s=>{let u=this.findNearestCalibration(e.operation,s.id,o);return{candidate:s,calibration:u,sampleCount:u?.workloadBucket===o?u.sampleCount:0,estimatedDurationMilliseconds:u?fs(u,e.workloadSize):void 0}});if(this.explorationEnabled){let s=n.find(u=>u.sampleCount<this.minimumSampleCount);if(s)return Object.freeze({operation:e.operation,variant:s.candidate.id,workloadSize:e.workloadSize,workloadBucket:o,reason:"exploration",sampleCount:s.sampleCount,...s.estimatedDurationMilliseconds===void 0?{}:{estimatedDurationMilliseconds:s.estimatedDurationMilliseconds}})}let i=n.filter(s=>s.estimatedDurationMilliseconds!==void 0).sort((s,u)=>(s.estimatedDurationMilliseconds??Number.POSITIVE_INFINITY)-(u.estimatedDurationMilliseconds??Number.POSITIVE_INFINITY))[0],a=i??n[0];return Object.freeze({operation:e.operation,variant:a.candidate.id,workloadSize:e.workloadSize,workloadBucket:o,reason:i?"calibrated":"fallback",sampleCount:a.calibration?.sampleCount??0,...a.estimatedDurationMilliseconds===void 0?{}:{estimatedDurationMilliseconds:a.estimatedDurationMilliseconds}})}observeKernel(e){if(xr(e.operation,"operation"),xr(e.variant,"variant"),bi(e.workloadSize),!Number.isFinite(e.durationMilliseconds)||e.durationMilliseconds<0)throw new Error("GPUCommandGraph autotuner durationMilliseconds must be nonnegative");let t=xi(e.workloadSize),o=Bo(e.operation,e.variant,t),n=this.calibrations.get(o)??{operation:e.operation,variant:e.variant,workloadBucket:t,sampleCount:0,meanWorkloadSize:0,meanDurationMilliseconds:0,durationSquaredDifferenceSum:0};n.sampleCount++,n.meanWorkloadSize+=(e.workloadSize-n.meanWorkloadSize)/n.sampleCount;let i=e.durationMilliseconds-n.meanDurationMilliseconds;return n.meanDurationMilliseconds+=i/n.sampleCount,n.durationSquaredDifferenceSum+=i*(e.durationMilliseconds-n.meanDurationMilliseconds),this.calibrations.set(o,n),yi(n)}observeTimingReport(e,t){let o=new Map(t.nodes.map(i=>[i.id,i])),n=0;for(let i of e.nodes){let a=o.get(i.id);i.gpuTimeMilliseconds===void 0||!a?.operation||!a.variant||(this.observeKernel({operation:a.operation,variant:a.variant,workloadSize:Math.max(a.maximumInvocationCount,1),durationMilliseconds:i.gpuTimeMilliseconds}),n++)}return n}exportProfile(){let e=[...this.calibrations.values()].sort((t,o)=>t.operation.localeCompare(o.operation)||t.variant.localeCompare(o.variant)||t.workloadBucket-o.workloadBucket).map(yi);return Object.freeze({version:1,adapter:this.adapter,calibrations:Object.freeze(e)})}reset(){this.calibrations.clear()}importCalibration(e){!e.operation||!e.variant||!Number.isSafeInteger(e.workloadBucket)||!Number.isSafeInteger(e.sampleCount)||e.sampleCount<=0||!Number.isFinite(e.meanWorkloadSize)||e.meanWorkloadSize<=0||!Number.isFinite(e.meanDurationMilliseconds)||e.meanDurationMilliseconds<0||this.calibrations.set(Bo(e.operation,e.variant,e.workloadBucket),{operation:e.operation,variant:e.variant,workloadBucket:e.workloadBucket,sampleCount:e.sampleCount,meanWorkloadSize:e.meanWorkloadSize,meanDurationMilliseconds:e.meanDurationMilliseconds,durationSquaredDifferenceSum:e.sampleCount>1?e.durationStandardDeviationMilliseconds**2*(e.sampleCount-1):0})}findNearestCalibration(e,t,o){let n=this.calibrations.get(Bo(e,t,o));if(n)return n;let i;for(let a of this.calibrations.values())a.operation!==e||a.variant!==t||(!i||Math.abs(a.workloadBucket-o)<Math.abs(i.workloadBucket-o))&&(i=a);return i}};function ms(r){let e=[...r.features].sort(),t={type:r.info.type,vendor:r.info.vendor,renderer:r.info.renderer,version:r.info.version,gpu:r.info.gpu,gpuType:r.info.gpuType,...r.info.gpuArchitecture?{gpuArchitecture:r.info.gpuArchitecture}:{},...r.info.gpuBackend?{gpuBackend:r.info.gpuBackend}:{},...r.info.featureLevel?{featureLevel:r.info.featureLevel}:{},features:Object.freeze(e),...r.info.subgroupMinSize===void 0?{}:{subgroupMinSize:r.info.subgroupMinSize},...r.info.subgroupMaxSize===void 0?{}:{subgroupMaxSize:r.info.subgroupMaxSize},maxComputeInvocationsPerWorkgroup:r.limits.maxComputeInvocationsPerWorkgroup,maxComputeWorkgroupsPerDimension:r.limits.maxComputeWorkgroupsPerDimension};return Object.freeze({key:JSON.stringify(t),...t})}function ls(r){return Object.freeze({...r,features:Object.freeze([...r.features])})}function yi(r){return Object.freeze({operation:r.operation,variant:r.variant,workloadBucket:r.workloadBucket,sampleCount:r.sampleCount,meanWorkloadSize:r.meanWorkloadSize,meanDurationMilliseconds:r.meanDurationMilliseconds,durationStandardDeviationMilliseconds:r.sampleCount>1?Math.sqrt(r.durationSquaredDifferenceSum/(r.sampleCount-1)):0})}function fs(r,e){return r.meanDurationMilliseconds*(e/Math.max(r.meanWorkloadSize,1))}function xi(r){return Math.floor(Math.log2(Math.max(r,1)))}function Bo(r,e,t){return`${r}\0${e}\0${t}`}function xr(r,e){if(!r)throw new Error(`GPUCommandGraph autotuner ${e} is required`)}function bi(r){if(!Number.isSafeInteger(r)||r<=0)throw new Error("GPUCommandGraph autotuner workloadSize must be a positive safe integer")}var ps={interactive:4,normal:8,background:16},Lo=class{targetStepMilliseconds;latencyPriority;minimumScale;maximumScale;responsiveness;maximumAdjustmentFactor;initialBudget;currentBudget;currentScale=1;currentSampleCount=0;constructor(e){wi(e.initialBudget);let t=e.latencyPriority??"normal",o=e.targetStepMilliseconds??ps[t];Et(o,"targetStepMilliseconds");let n=e.minimumScale??.125,i=e.maximumScale??4,a=e.responsiveness??.25,s=e.maximumAdjustmentFactor??2;if(Et(n,"minimumScale"),Et(i,"maximumScale"),Et(s,"maximumAdjustmentFactor"),n>1||i<1)throw new Error("GPUCommandGraph budget scale range must contain the initial scale 1");if(!Number.isFinite(a)||a<=0||a>1)throw new Error("GPUCommandGraph budget responsiveness must be in the interval (0, 1]");if(s<1)throw new Error("GPUCommandGraph budget maximumAdjustmentFactor must be at least 1");this.initialBudget=vi(e.initialBudget),this.currentBudget=this.initialBudget,this.latencyPriority=t,this.targetStepMilliseconds=o,this.minimumScale=n,this.maximumScale=i,this.responsiveness=a,this.maximumAdjustmentFactor=s}get budget(){return this.currentBudget}get sampleCount(){return this.currentSampleCount}reset(){this.currentBudget=this.initialBudget,this.currentScale=1,this.currentSampleCount=0}observeStep(e,t,o=this.currentBudget){Et(t,"durationMilliseconds"),wi(o);let n=hs(e,o);if(n>0){let i=this.targetStepMilliseconds*Math.min(n,1)/t,s=1+(Ti(i,1/this.maximumAdjustmentFactor,this.maximumAdjustmentFactor)-1)*this.responsiveness;this.currentScale=Ti(this.currentScale*s,this.minimumScale,this.maximumScale),this.currentBudget=gs(this.initialBudget,this.currentScale)}return this.currentSampleCount++,Object.freeze({sampleCount:this.currentSampleCount,durationMilliseconds:t,targetStepMilliseconds:this.targetStepMilliseconds,latencyPriority:this.latencyPriority,saturation:n,scale:this.currentScale,budget:this.currentBudget})}};function hs(r,e){let t=[r.maximumInvocationCount/e.maximumInvocationCount];return e.maximumNodeCount!==void 0&&t.push(r.nodeCount/e.maximumNodeCount),e.maximumCommandCount!==void 0&&t.push(r.commandCount/e.maximumCommandCount),e.maximumReadByteLength!==void 0&&t.push(r.readByteLength/e.maximumReadByteLength),e.maximumWriteByteLength!==void 0&&t.push(r.writeByteLength/e.maximumWriteByteLength),Math.max(...t)}function gs(r,e){return vi({maximumInvocationCount:Bt(r.maximumInvocationCount,e),...r.maximumNodeCount===void 0?{}:{maximumNodeCount:Bt(r.maximumNodeCount,e)},...r.maximumCommandCount===void 0?{}:{maximumCommandCount:Bt(r.maximumCommandCount,e)},...r.maximumReadByteLength===void 0?{}:{maximumReadByteLength:Bt(r.maximumReadByteLength,e)},...r.maximumWriteByteLength===void 0?{}:{maximumWriteByteLength:Bt(r.maximumWriteByteLength,e)}})}function Bt(r,e){return Math.max(1,Math.min(Number.MAX_SAFE_INTEGER,Math.round(r*e)))}function vi(r){return Object.freeze({...r})}function Et(r,e){if(!Number.isFinite(r)||r<=0)throw new Error(`GPUCommandGraph budget ${e} must be positive`)}function wi(r){for(let[e,t]of[["maximumInvocationCount",r.maximumInvocationCount],["maximumNodeCount",r.maximumNodeCount],["maximumCommandCount",r.maximumCommandCount],["maximumReadByteLength",r.maximumReadByteLength],["maximumWriteByteLength",r.maximumWriteByteLength]])if(t!==void 0&&(!Number.isSafeInteger(t)||t<=0))throw new Error(`GPUCommandGraph budget ${e} must be a positive safe integer`)}function Ti(r,e,t){return Math.max(e,Math.min(t,r))}var Go=class{maxSamples;getNodeGroup;graphs=new Map;encodingGraphs=new WeakMap;constructor(e={}){let t=e.maxSamples??120;if(!Number.isSafeInteger(t)||t<=0)throw new Error("GPUCommandGraphInspector maxSamples must be a positive safe integer");this.maxSamples=t,this.getNodeGroup=e.getNodeGroup}registerGraph(e){this.graphs.set(e.id,{id:e.id,stats:ys(e.stats),capabilities:Object.freeze({...e.capabilities}),...e.preflight?{preflight:xs(e.preflight)}:{},encodingCount:0,timingReadFailureCount:0,cpuSamples:[],gpuSamples:[],counters:new Map,nodes:new Map});let t=this.getGraph(e.id);for(let o of e.preflight?.nodes??[])this.getNode(t,o)}observeGraph(e){this.registerGraph(e);let t=this.getGraph(e.id),o=new WeakMap,n=!0,i=()=>n&&this.graphs.get(e.id)===t;return Object.freeze({graph:e,encode:(a,s)=>{let u=e.encode(a,s);return i()&&this.recordGraphEncoding(t,u),u},recordGPUTimings:async a=>{let s=o.get(a);if(s)return await s;if(i()&&this.encodingGraphs.get(a)===t){let u=this.recordGraphGPUTimings(e.id,t,a);return o.set(a,u),await u}},recordCounters:a=>{i()&&this.recordGraphCounters(t,a)},detach:()=>{n&&(n=!1,this.graphs.get(e.id)===t&&this.graphs.delete(e.id))}})}clear(){this.graphs.clear()}recordEncoding(e,t){let o=this.getGraph(e);this.recordGraphEncoding(o,t)}async readResource(e,t,o){let n=this.getGraph(e);if(!n.encoding?.readResource)throw new Error("No live resource readback is available.");let i=await n.encoding.readResource(t,o);if(this.graphs.get(e)!==n)throw new Error("Graph registration changed during readback.");return i}recordCounters(e,t){this.recordGraphCounters(this.getGraph(e),t)}recordGraphEncoding(e,t){e.encoding=t,this.encodingGraphs.set(t,e);let{stats:o}=t;e.encodingCount++,this.addSample(e.cpuSamples,o.cpuEncodeTimeMilliseconds);for(let n of o.nodes){let i=this.getNode(e,n);this.addSample(i.cpuSamples,n.cpuEncodeTimeMilliseconds)}}recordGraphCounters(e,t){let o=Object.entries(t);for(let[n,i]of o)if(!n||!Number.isFinite(i)||i<0)throw new Error("GPUCommandGraphInspector counters require an ID and a finite, non-negative value");for(let[n,i]of o){let a=e.counters.get(n);a||(a=[],e.counters.set(n,a)),this.addSample(a,i)}}async recordGPUTimings(e,t){let n=this.encodingGraphs.get(t)??this.getGraph(e);return await this.recordGraphGPUTimings(e,n,t)}async recordGraphGPUTimings(e,t,o){if(this.graphs.get(e)!==t)return;let n;try{n=await o.readTimings()}catch{this.graphs.get(e)===t&&t.timingReadFailureCount++;return}if(this.graphs.get(e)===t){n.gpuTimeMilliseconds!==void 0&&this.addSample(t.gpuSamples,n.gpuTimeMilliseconds);for(let i of n.nodes)if(i.gpuTimeMilliseconds!==void 0){let a=this.getNode(t,i);this.addSample(a.gpuSamples,i.gpuTimeMilliseconds)}return n}}getSnapshot(){let e=Array.from(this.graphs.values(),t=>this.getGraphSnapshot(t));return Object.freeze({graphs:Object.freeze(e)})}getGraph(e){let t=this.graphs.get(e);if(!t)throw new Error(`GPUCommandGraphInspector graph "${e}" is not registered`);return t}getNode(e,t){let o=e.nodes.get(t.id);if(o)return t.description!==void 0&&(o.description=t.description),t.resources!==void 0&&(o.resources=Do(t.resources)),o;let n=Do(t.resources),i=this.getNodeGroup?.({graphId:e.id,id:t.id,type:t.type,description:t.description,resources:n}),a={id:t.id,resources:n,...t.description===void 0?{}:{description:t.description},type:t.type,...i===void 0?{}:{group:i},cpuSamples:[],gpuSamples:[]};return e.nodes.set(a.id,a),a}addSample(e,t){e.push(t),e.length>this.maxSamples&&e.splice(0,e.length-this.maxSamples)}getGraphSnapshot(e){let t=[],o=new Set;for(let a of e.stats.nodeOrder){let s=e.nodes.get(a);s&&(t.push(s),o.add(a))}for(let a of e.nodes.values())o.has(a.id)||t.push(a);let n=t.map(a=>Object.freeze({id:a.id,resources:a.resources,...a.description===void 0?{}:{description:a.description},type:a.type,...a.group===void 0?{}:{group:a.group},cpu:br(a.cpuSamples),gpu:br(a.gpuSamples)})),i=Array.from(e.counters,([a,s])=>bs(a,s));return Object.freeze({id:e.id,stats:e.stats,capabilities:e.capabilities,...e.preflight?{preflight:e.preflight}:{},encodingCount:e.encodingCount,timingReadFailureCount:e.timingReadFailureCount,totals:Object.freeze({cpu:br(e.cpuSamples),gpu:br(e.gpuSamples)}),counters:Object.freeze(i),nodes:Object.freeze(n)})}};function ys(r){return Object.freeze({...r,nodeOrder:Object.freeze([...r.nodeOrder])})}function xs(r){return Object.freeze({...r,nodes:Object.freeze(r.nodes.map(e=>Object.freeze({...e,resources:Do(e.resources)})))})}function br(r){if(r.length===0)return Object.freeze({sampleCount:0});let e=[...r].sort((t,o)=>t-o);return Object.freeze({sampleCount:r.length,latestMilliseconds:r[r.length-1],p50Milliseconds:wr(e,.5),p95Milliseconds:wr(e,.95)})}function bs(r,e){let t=[...e].sort((o,n)=>o-n);return Object.freeze({id:r,sampleCount:e.length,latestValue:e[e.length-1],p50Value:wr(t,.5),p95Value:wr(t,.95)})}function wr(r,e){return r[Math.ceil(e*r.length)-1]}function Do(r){return r&&Object.freeze(r.map(e=>Object.freeze({...e})))}return Ii(Lt);})();
|
|
202
|
+
}`}var cn=class{props;id;constructor(e){if(this.props=e,this.id=e.id??"gpu-predicate-conjunction",e.inputs.length<2)throw new Error(`${this.id} requires at least two predicates`);let t=e.output.arena;if(e.inputs.some(n=>n.arena!==t))throw new Error(`${this.id} predicates must share one GPUValueArena`)}getCommandNodes(e){let{inputs:t,output:n}=this.props;if(n.arena.graph!==e)throw new Error(`${this.id} predicates must belong to target graph`);let o=n.arena.buffer,i=t.map(a=>`(${we(a)} != 0u)`).join(" && "),s=`${fe(0,0)}
|
|
203
|
+
@compute @workgroup_size(1)fn main(){${rt(n,`select(0u,1u,${i})`)}}`;return[q({id:this.id,workload:{operation:"GPUPredicateConjunction",commandCount:1,maximumWorkgroupCount:1,maximumInvocationCount:1,readByteLength:t.length*4,writeByteLength:4},resources:[{buffer:o,usage:"storage-write"}],compile:({device:a})=>{let c=new k(a,{id:this.id,source:s,shaderLayout:{bindings:[{name:"gpuValues",type:"storage",group:0,location:0}]}});return{encode:({computePass:u,getBuffer:d})=>{let h={gpuValues:d(o)};c.dispatch(u,{bindings:h,x:1,y:1,z:1})},destroy:()=>c.destroy()}}})]}};var Q=class{id;type="composite";operations;metadata;constructor(e){let t=Array.isArray(e)?{operations:e}:e;this.id=t.id??"gpu-composite-operation",this.operations=Object.freeze([...t.operations]),this.metadata=t.metadata}};function nt(r){let e=r;return typeof e.id=="string"&&typeof e.type=="string"}function Do(r){return r instanceof Q?Object.freeze({id:r.id,type:r.type,...r.metadata?{metadata:r.metadata}:{},children:Object.freeze(r.operations.map(Do))}):nt(r)?Object.freeze({id:r.id,type:r.type,...r.metadata?{metadata:r.metadata}:{}}):Object.freeze({id:r.constructor?.name??"gpu-command-node-producer",type:"command-node-producer"})}function vs(r){return typeof r.getCommandNodes=="function"}var Ft=class extends Q{type="conditional";predicate;lowering;constructor(e){let t=Array.isArray(e.body)?e.body:[e.body];super({id:e.id??"gpu-conditional-operation",operations:t,metadata:e.metadata}),this.predicate=Object.freeze({...e.predicate}),this.lowering=e.lowering??"auto"}},ot=class extends Q{type="loop";predicate;maximumIterations;minimumIterations;lowering;constructor(e){let t=Array.isArray(e.body)?e.body:[e.body];if(super({id:e.id??"gpu-loop-operation",operations:t,metadata:e.metadata}),!Number.isSafeInteger(e.maximumIterations)||e.maximumIterations<1)throw new Error(`${this.id} maximumIterations must be a positive safe integer`);let n=e.minimumIterations??0;if(!Number.isSafeInteger(n)||n<0||n>e.maximumIterations)throw new Error(`${this.id} minimumIterations must be between zero and maximumIterations`);this.predicate=e.predicate?Object.freeze({...e.predicate}):void 0,this.maximumIterations=e.maximumIterations,this.minimumIterations=n,this.lowering=e.lowering??"auto"}};function Y(r){return typeof r=="string"?r:r.id}function Ls(r,e){let t=Y(e),n=[...r.scalars,...r.vectors,...r.textures].find(o=>o.id===t);if(!n)throw new Error(`Undeclared operation value ${t}`);if(typeof e!="string"&&(e.constructor!==n.constructor||e.format!==n.format))throw new Error(`Incompatible operation reference ${t}`);return n}function un(r,e){for(let t of e.values){let n=Ls(r,t.value);if(t.shape){if(!(n instanceof ve)||t.access==="read")throw new Error("Operation shapes require writable vectors");if("like"in t.shape){if(!(Ls(r,t.shape.like)instanceof ve))throw new Error("Operation shape source must be a vector");let o=Y(t.shape.like);if(!e.values.some(i=>i.access!=="write"&&Y(i.value)===o))throw new Error("Operation shape source must be a declared read")}else{let{length:o,chunkLengths:i}=t.shape;if(!Number.isSafeInteger(o)||o<0||i&&(i.some(s=>!Number.isSafeInteger(s)||s<0)||i.reduce((s,a)=>s+a,0)!==o))throw new Error("Invalid operation output shape")}}}}function br(r,e={}){let t=[],n=new Set(r.scalars.map(i=>i.id));for(let i of r.vectors)i.external&&!e.vectors?.[i.id]&&t.push({level:"error",code:"missing-external-vector",valueId:i.id,message:`External vector "${i.id}" has no WebGPU binding`});let o=i=>{let s="id"in i&&typeof i.id=="string"?i.id:void 0;if(nt(i))try{let a=i.contract;a&&un(r,a)}catch(a){t.push({level:"error",code:"invalid-operation-contract",operationId:s,message:`${s}: ${a instanceof Error?a.message:String(a)}`})}if(i instanceof Ft||i instanceof ot){let a=i.predicate;a?.source==="gpu"&&(a.value.format!=="uint32"&&t.push({level:"error",code:"invalid-predicate-format",operationId:s,valueId:a.value.id,message:`GPU predicate "${a.id}" must use uint32 state`}),n.has(a.value.id)||t.push({level:"error",code:"missing-predicate-scalar",operationId:s,valueId:a.value.id,message:`GPU predicate "${a.id}" references undeclared scalar "${a.value.id}"`}))}if(i instanceof Q)for(let a of i.operations)o(a)};for(let i of r.operations)o(i);return Object.freeze({valid:!t.some(i=>i.level==="error"),issues:Object.freeze(t.map(i=>Object.freeze({...i})))})}var Pt=class{device;capabilities;lowerings;constructor(e,t=[]){this.device=e,this.capabilities=Object.freeze({backend:"webgpu",gpuConditionals:!0,nativeLoops:!1,childGraphs:!1});let n=[...this.createCoreLowerings(),...t],o=new Set;for(let i of n){if(!i.type||o.has(i.type))throw new Error(`Duplicate or empty lowering type: ${i.type}`);o.add(i.type)}this.lowerings=Object.freeze(n.map(i=>Object.freeze({type:i.type,lower:i.lower.bind(i)})))}compile(e,t={}){let n=br(e,t);if(!n.valid)throw new Error(`GPUGraph "${e.id}" validation failed: ${n.issues.filter(u=>u.level==="error").map(u=>u.message).join("; ")}`);let o=new jr(this.device,{id:`${e.id}-commands`}),i=new Map;for(let u of e.scalars)i.set(u.id,Io(o,u.id,u.format));for(let[u,d]of Object.entries(t.scalars??{})){let h=i.get(u);if(!h)throw new Error(`Undeclared scalar binding ${u}`);let f=h.view;o.addCopyPass({id:`${u}-binding`,resources:[{buffer:f,usage:"copy-destination"}],compile:({device:l})=>{let m=h.format==="float32"?new Float32Array([d]):h.format==="uint32"?new Uint32Array([d]):new Int32Array([d]),g=l.createBuffer({data:m,usage:Bs.Buffer.COPY_SRC});return{encode:({commandEncoder:x,getBuffer:T})=>x.copyBufferToBuffer({sourceBuffer:g,destinationBuffer:T(f),destinationOffset:f.byteOffset,size:4}),destroy:()=>g.destroy()}}})}let s=new Map;for(let u of e.vectors){if(u.length===void 0)throw new Error(`${u.id}: bind dynamic dimensions through program.compile(device).run(bindings)`);let d;if(u.external){let h=t.vectors[u.id],f="data"in h?h:{format:u.format,length:u.length,data:"buffer"in h?[h]:h};if(d=o.importGPUVector(u.id,f),d.format!==u.format||d.length!==u.length)throw new Error(`${u.id} binding format and length must match its logical vector`);if(u.chunkLengths&&(u.chunkLengths.length!==d.data.length||u.chunkLengths.some((l,m)=>l!==d.data[m].length)))throw new Error(`${u.id} binding must preserve its declared chunk topology`)}else{let h=u.chunkLengths??eh(u.length,this.device,D(u.format).byteLength),f=h.map((m,g)=>Mt(o,h.length===1?u.id:`${u.id}-chunk-${g}`,u.format,m)),l=D(u.format);d=new _({id:u.id,name:u.id,format:u.format,length:u.length,valueLength:u.length,stride:l.components,byteStride:l.byteLength,rowByteLength:l.byteLength,data:f})}s.set(u.id,d)}let a=new Map;for(let u of e.textures){let d=u.external?o.importTexture(u,t.textures?.[u.id]):o.createTransientTexture(u);a.set(u.id,d)}let c={path:[],nodes:[],decisions:[],predicates:[],scalars:i,vectors:s,textures:a,textureValues:e.textures,predicateConjunctions:new Map,commandNodeIds:new Set};for(let u of e.operations)this.lower(o,u,c);return Object.freeze({program:e,graph:o,scalars:i,vectors:s,textures:a,validation:n,lowering:Object.freeze({operations:e.operationTree,nodes:Object.freeze(c.nodes.map(u=>Object.freeze({...u,operationPath:Object.freeze([...u.operationPath])}))),decisions:Object.freeze(c.decisions.map(u=>Object.freeze({...u})))})})}createCoreLowerings(){return[{type:"scalar-literal",lower:(e,t)=>{let n=new kt({id:e.id,output:t.resolveScalar(e.props.output),value:e.props.value});this.emitProducer(t.graph,n,[[1,1,1]]),t.recordDecision({operationId:e.id,operationType:e.type,lowering:"webgpu-scalar-literal",reason:"host-known literal lowers to one compute command node"})}},{type:"scalar-operation",lower:(e,t)=>{let n=new Kr({id:e.id,operation:e.operation,left:t.resolveScalar(e.left),right:e.right?t.resolveScalar(e.right):void 0,output:t.resolveScalar(e.output)});this.emitProducer(t.graph,n,[[1,1,1]]),t.recordDecision({operationId:e.id,operationType:e.type,lowering:"webgpu-scalar-kernel",reason:"scalar operation lowers to one compute command node"})}},{type:"vector-madd",lower:(e,t)=>{let n=e.props,o=new en({id:e.id,input:t.resolveVector(n.input),scale:t.resolveScalar(n.scale),addend:t.resolveVector(n.addend),output:t.resolveVector(n.output)});this.emitProducer(t.graph,o),t.recordDecision({operationId:e.id,operationType:e.type,lowering:"webgpu-vector-madd",reason:"dense float32 MADD lowers through explicit command nodes"})}},{type:"dot-product",lower:(e,t)=>{let n=e.props,o=new nn({id:e.id,left:t.resolveVector(n.left),right:t.resolveVector(n.right),output:t.resolveScalar(n.output)});this.emitProducer(t.graph,o),t.recordDecision({operationId:e.id,operationType:e.type,lowering:"webgpu-hierarchical-dot",reason:"chunk dot products use bounded hierarchical reductions into the scalar arena"})}},{type:"spmv",lower:(e,t)=>{let n=e.props,o=n.matrix,i=new an({id:e.id,rowOffsets:t.resolveVector(o.rowOffsets),columnIndices:t.resolveVector(o.columnIndices),values:t.resolveVector(o.values),vector:t.resolveVector(n.vector),output:t.resolveVector(n.output),columns:o.columns,statistics:o.statistics,strategy:n.strategy}),s=i.getStrategy(t.graph);this.emitProducer(t.graph,i),t.recordDecision({operationId:e.id,operationType:e.type,lowering:`webgpu-spmv:${s.id}`,reason:s.reason})}},{type:"conditional",lower:(e,t)=>{t.recordDecision({operationId:e.id,operationType:e.type,lowering:"gpu-indirect-gate",reason:"WebGPU realizes runtime predicates with zero/nonzero indirect dispatch"});for(let n of e.operations)t.lowerConditional(e.predicate,n)}},{type:"loop",lower:(e,t)=>{if(!e.predicate||e.lowering==="unroll"){t.recordDecision({operationId:e.id,operationType:e.type,lowering:"bounded-unroll",reason:e.predicate?"explicit unroll preference":"loop has no runtime predicate"});for(let n=0;n<e.maximumIterations;n++)for(let o of e.operations)t.lower(o);return}t.recordDecision({operationId:e.id,operationType:e.type,lowering:"gpu-gated-bounded-sequence",reason:"WebGPU has indirect dispatch but no native graph loop"});for(let n=0;n<e.maximumIterations;n++){let o=n>=e.minimumIterations;for(let i of e.operations)o?t.lowerConditional(e.predicate,i):t.lower(i)}}}]}lower(e,t,n){let o="id"in t&&typeof t.id=="string"?t.id:t.constructor?.name??"command-node-producer";n.path.push(o);try{if(t instanceof Q&&t.type==="composite"){n.decisions.push({operationId:t.id,operationType:t.type,lowering:"flatten",reason:"WebGPU has no executable child-graph primitive"});for(let i of t.operations)this.lower(e,i,n);return}if(nt(t)){for(let s of t.contract?.requiredFeatures??[])if(!this.device.features.has(s))throw new Error(`${o} requires ${s}`);let i=this.lowerings.find(s=>s.type===t.type)?.lower;if(i){let s=()=>i(t,{graph:e,capabilities:this.capabilities,lower:a=>this.lower(e,a,n),lowerConditional:(a,c)=>{n.predicates.push(a);try{this.lower(e,c,n)}finally{n.predicates.pop()}},resolveScalar:a=>this.resolveScalar(a,n),resolveVector:a=>this.resolveVector(a,n),resolveTexture:a=>this.resolveTexture(a,n),resolveTextureView:a=>{let c=a instanceof Le?a.texture:a,u=a instanceof Le?a.props:{};return e.createTextureView(this.resolveTexture(c,n),u)},recordDecision:a=>n.decisions.push(a)});t instanceof Ft||t instanceof ot?s():this.withNodeDecoration(e,n,s);return}}if("getNodes"in t||vs(t)){n.decisions.push({operationId:o,operationType:"command-node-producer",lowering:"explicit-command-nodes",reason:"execution primitive constructs explicit command nodes"}),this.withNodeDecoration(e,n,()=>e.add(t));return}throw new Error(`GPUGraph operation "${o}" has no WebGPU lowering`)}finally{n.path.pop()}}emitProducer(e,t,n){let o=t.getCommandNodes(e);if(!n){ze(e,o);return}if(o.length!==n.length)throw new Error(`lowering produced ${o.length} command nodes but declared ${n.length} dispatches`);let i=o.map((s,a)=>this.attachDispatch(s,n[a]));ze(e,i)}attachDispatch(e,t){if(e.type!=="compute")throw new Error(`dispatch geometry can only be attached to compute command nodes; got ${e.type} node "${e.id}"`);return j(e,t)}withNodeDecoration(e,t,n){return e.withComputeLowering(o=>this.decorateComputeNode(e,o,t),()=>e.withOtherLowering(o=>{if(t.predicates.length)throw new Error(`GPU predicates do not support ${o.type} node "${o.id}"`);let i=this.makeCommandNodeIdUnique(o,t);return t.nodes.push({nodeId:i.id,nodeType:i.type,operationPath:[...t.path]}),i},n))}decorateComputeNode(e,t,n){if(t=this.makeCommandNodeIdUnique(t,n),n.path.length&&n.nodes.push({nodeId:t.id,nodeType:"compute",operationPath:[...n.path]}),!n.predicates.length)return t;if(t.condition)throw new Error(`compute node "${t.id}" already has condition`);let o=Yr(t);if(!o)throw new Error(`compute node "${t.id}" under runtime predicate must declare exact dispatch geometry`);let i;if(n.predicates.length===1)i=n.scalars.get(n.predicates[0].value.id);else{let c=n.predicates.map(f=>f.value.id).join("&&"),u=n.predicateConjunctions.get(c);u||(u=Io(e,`predicate-and-${n.predicateConjunctions.size}`,"uint32"),n.predicateConjunctions.set(c,u));let d=n.predicates.map(f=>n.scalars.get(f.value.id)),h=new cn({id:`${t.id}-predicate-and`,inputs:d,output:u}).getCommandNodes(e).map(f=>this.attachDispatch(f,[1,1,1]));e.withoutComputeLowering(()=>ze(e,h)),i=u}if(!i)throw new Error(`runtime predicate for "${t.id}" could not be resolved`);let s=new yr(e,{id:`${t.id}-predicate`,active:i,workgroups:o}),a=s.getUpdateCommandNodes(e,`${t.id}-predicate-update`).map(c=>this.attachDispatch(c,[1,1,1]));return e.withoutComputeLowering(()=>ze(e,a)),{...t,condition:s.condition}}makeCommandNodeIdUnique(e,t){if(!t.commandNodeIds.has(e.id))return t.commandNodeIds.add(e.id),e;let n=1,o=`${e.id}-iteration-${n}`;for(;t.commandNodeIds.has(o);)n++,o=`${e.id}-iteration-${n}`;return t.commandNodeIds.add(o),{...e,id:o}}resolveTexture(e,t){let n=typeof e=="string"?e:e.id;if(typeof e=="string"?!t.textures.has(n):!t.textureValues.includes(e))throw new Error(`Undeclared program texture "${n}"`);return t.textures.get(n)}resolveScalar(e,t){let n=typeof e=="string"?e:e.id,o=t.scalars.get(n);if(!o||typeof e!="string"&&o.format!==e.format)throw new Error(`GPUGraph scalar "${n}" is not part of compilation`);return o}resolveVector(e,t){let n=typeof e=="string"?e:e.id,o=t.vectors.get(n);if(!o||typeof e!="string"&&(o.format!==e.format||e.length!==void 0&&o.length!==e.length))throw new Error(`GPUGraph vector "${n}" is not part of compilation`);return o}};function eh(r,e,t){let n=Math.floor(e.limits.maxStorageBufferBindingSize/t);if(n<1||r<=n)return[r];let o=[];for(let i=0;i<r;i+=n)o.push(Math.min(n,r-i));return o}var Ht=X(V(),1);var Go=class{add(e,t,n){if(typeof arguments[0]!="string")for(let o in arguments[0])this.add(o,arguments[0][o],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(o){this[o]=this[o]||[],t&&this[o][n?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(n){n.call(t&&t.context?t.context:t,t)})}},No=class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(t=>{if(typeof t!="object"||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");this.registered[t.name]||(t.init(this.jsep),this.registered[t.name]=t)})}},se=class r{static get version(){return"1.6.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+r.version}static addUnaryOp(e){return r.max_unop_len=Math.max(e.length,r.max_unop_len),r.unary_ops[e]=1,r}static addBinaryOp(e,t,n){return r.max_binop_len=Math.max(e.length,r.max_binop_len),r.binary_ops[e]=t,n?r.right_associative.add(e):r.right_associative.delete(e),r}static addIdentifierChar(e){return r.additional_identifier_chars.add(e),r}static addLiteral(e,t){return r.literals[e]=t,r}static removeUnaryOp(e){return delete r.unary_ops[e],e.length===r.max_unop_len&&(r.max_unop_len=r.getMaxKeyLen(r.unary_ops)),r}static removeAllUnaryOps(){return r.unary_ops={},r.max_unop_len=0,r}static removeIdentifierChar(e){return r.additional_identifier_chars.delete(e),r}static removeBinaryOp(e){return delete r.binary_ops[e],e.length===r.max_binop_len&&(r.max_binop_len=r.getMaxKeyLen(r.binary_ops)),r.right_associative.delete(e),r}static removeAllBinaryOps(){return r.binary_ops={},r.max_binop_len=0,r}static removeLiteral(e){return delete r.literals[e],r}static removeAllLiterals(){return r.literals={},r}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new r(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(t=>t.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return r.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!r.binary_ops[String.fromCharCode(e)]||r.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return r.isIdentifierStart(e)||r.isDecimalDigit(e)}throwError(e){let t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(r.hooks[e]){let n={context:this,node:t};return r.hooks.run(e,n),n.node}return t}searchHook(e){if(r.hooks[e]){let t={context:this};return r.hooks[e].find(function(n){return n.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===r.SPACE_CODE||e===r.TAB_CODE||e===r.LF_CODE||e===r.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=e.length===1?e[0]:{type:r.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],n,o;for(;this.index<this.expr.length;)if(n=this.code,n===r.SEMCOL_CODE||n===r.COMMA_CODE)this.index++;else if(o=this.gobbleExpression())t.push(o);else if(this.index<this.expr.length){if(n===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,r.max_binop_len),t=e.length;for(;t>0;){if(r.binary_ops.hasOwnProperty(e)&&(!r.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!r.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,n,o,i,s,a,c,u;if(s=this.gobbleToken(),!s||(t=this.gobbleBinaryOp(),!t))return s;for(i={value:t,prec:r.binaryPrecedence(t),right_a:r.right_associative.has(t)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+t),o=[s,i,a];t=this.gobbleBinaryOp();){if(n=r.binaryPrecedence(t),n===0){this.index-=t.length;break}i={value:t,prec:n,right_a:r.right_associative.has(t)},u=t;let d=h=>i.right_a&&h.right_a?n>h.prec:n<=h.prec;for(;o.length>2&&d(o[o.length-2]);)a=o.pop(),t=o.pop().value,s=o.pop(),e={type:r.BINARY_EXP,operator:t,left:s,right:a},o.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+u),o.push(i,e)}for(c=o.length-1,e=o[c];c>1;)e={type:r.BINARY_EXP,operator:o[c-1].value,left:o[c-2],right:e},c-=2;return e}gobbleToken(){let e,t,n,o;if(this.gobbleSpaces(),o=this.searchHook("gobble-token"),o)return this.runHook("after-token",o);if(e=this.code,r.isDecimalDigit(e)||e===r.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===r.SQUOTE_CODE||e===r.DQUOTE_CODE)o=this.gobbleStringLiteral();else if(e===r.OBRACK_CODE)o=this.gobbleArray();else{for(t=this.expr.substr(this.index,r.max_unop_len),n=t.length;n>0;){if(r.unary_ops.hasOwnProperty(t)&&(!r.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!r.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=n;let i=this.gobbleToken();return i||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:r.UNARY_EXP,operator:t,argument:i,prefix:!0})}t=t.substr(0,--n)}r.isIdentifierStart(e)?(o=this.gobbleIdentifier(),r.literals.hasOwnProperty(o.name)?o={type:r.LITERAL,value:r.literals[o.name],raw:o.name}:o.name===r.this_str&&(o={type:r.THIS_EXP})):e===r.OPAREN_CODE&&(o=this.gobbleGroup())}return o?(o=this.gobbleTokenProperty(o),this.runHook("after-token",o)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===r.PERIOD_CODE||t===r.OBRACK_CODE||t===r.OPAREN_CODE||t===r.QUMARK_CODE;){let n;if(t===r.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==r.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===r.OBRACK_CODE?(e={type:r.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()},e.property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),t=this.code,t!==r.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===r.OPAREN_CODE?e={type:r.CALL_EXP,arguments:this.gobbleArguments(r.CPAREN_CODE),callee:e}:(t===r.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),e={type:r.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),n&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,n;for(;r.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===r.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);r.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(t=this.char,t==="e"||t==="E"){for(e+=this.expr.charAt(this.index++),t=this.char,(t==="+"||t==="-")&&(e+=this.expr.charAt(this.index++));r.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);r.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return n=this.code,r.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(n===r.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===r.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:r.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,n=this.expr.charAt(this.index++),o=!1;for(;this.index<this.expr.length;){let i=this.expr.charAt(this.index++);if(i===n){o=!0;break}else if(i==="\\")switch(i=this.expr.charAt(this.index++),i){case"n":e+=`
|
|
204
|
+
`;break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=i}else e+=i}return o||this.throwError('Unclosed quote after "'+e+'"'),{type:r.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(r.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,r.isIdentifierPart(e));)this.index++;return{type:r.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],n=!1,o=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let i=this.code;if(i===e){n=!0,this.index++,e===r.CPAREN_CODE&&o&&o>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}else if(i===r.COMMA_CODE){if(this.index++,o++,o!==t.length){if(e===r.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===r.CBRACK_CODE)for(let s=t.length;s<o;s++)t.push(null)}}else if(t.length!==o&&o!==0)this.throwError("Expected comma");else{let s=this.gobbleExpression();(!s||s.type===r.COMPOUND)&&this.throwError("Expected comma"),t.push(s)}}return n||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(r.CPAREN_CODE);if(this.code===r.CPAREN_CODE)return this.index++,e.length===1?e[0]:e.length?{type:r.SEQUENCE_EXP,expressions:e}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:r.ARRAY_EXP,elements:this.gobbleArguments(r.CBRACK_CODE)}}},th=new Go;Object.assign(se,{hooks:th,plugins:new No(se),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});se.max_unop_len=se.getMaxKeyLen(se.unary_ops);se.max_binop_len=se.getMaxKeyLen(se.binary_ops);var Vt=r=>new se(r).parse(),rh=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(se).filter(r=>!rh.includes(r)&&Vt[r]===void 0).forEach(r=>{Vt[r]=se[r]});Vt.Jsep=se;var nh="ConditionalExpression",oh={name:"ternary",init(r){r.hooks.add("after-expression",function(t){if(t.node&&this.code===r.QUMARK_CODE){this.index++;let n=t.node,o=this.gobbleExpression();if(o||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===r.COLON_CODE){this.index++;let i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:nh,test:n,consequent:o,alternate:i},n.operator&&r.binary_ops[n.operator]<=.9){let s=n;for(;s.right.operator&&r.binary_ops[s.right.operator]<=.9;)s=s.right;t.node.test=s.right,s.right=t.node,t.node=n}}else this.throwError("Expected :")}})}};Vt.plugins.register(oh);var it={};Un(it,{EPSILON1:()=>ih,EPSILON10:()=>mh,EPSILON11:()=>ph,EPSILON12:()=>gh,EPSILON13:()=>xh,EPSILON14:()=>yh,EPSILON15:()=>bh,EPSILON16:()=>wh,EPSILON17:()=>Th,EPSILON18:()=>Mh,EPSILON19:()=>Eh,EPSILON2:()=>sh,EPSILON20:()=>Sh,EPSILON3:()=>ah,EPSILON4:()=>ch,EPSILON5:()=>uh,EPSILON6:()=>hh,EPSILON7:()=>fh,EPSILON8:()=>dh,EPSILON9:()=>lh,PI:()=>Lh,PI_OVER_FOUR:()=>Ch,PI_OVER_SIX:()=>vh,PI_OVER_TWO:()=>Ph,TWO_PI:()=>Bh});var ih=.1,sh=.01,ah=.001,ch=1e-4,uh=1e-5,hh=1e-6,fh=1e-7,dh=1e-8,lh=1e-9,mh=1e-10,ph=1e-11,gh=1e-12,xh=1e-13,yh=1e-14,bh=1e-15,wh=1e-16,Th=1e-17,Mh=1e-18,Eh=1e-19,Sh=1e-20,Ph=Math.PI/2,Ch=Math.PI/4,vh=Math.PI/6,Lh=Math.PI,Bh=Math.PI*2;var Ah=1/Math.PI*180,Oh=1/180*Math.PI,Ih={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Ih}};var U=globalThis.mathgl.config;function _o(r,{precision:e=U.precision}={}){return r=Rh(r),`${parseFloat(r.toPrecision(e))}`}function de(r){return Array.isArray(r)||ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Uo(r){return zo(r)}function ko(r){return $o(r)}function zo(r,e){return As(r,t=>t*Oh,e)}function $o(r,e){return As(r,t=>t*Ah,e)}function Ve(r,e,t){let n=U.EPSILON;t&&(U.EPSILON=t);try{if(r===e)return!0;if(de(r)&&de(e)){if(r.length!==e.length)return!1;for(let o=0;o<r.length;++o)if(!Ve(r[o],e[o]))return!1;return!0}return r&&r.equals?r.equals(e):e&&e.equals?e.equals(r):typeof r=="number"&&typeof e=="number"?Math.abs(r-e)<=U.EPSILON*Math.max(1,Math.abs(r),Math.abs(e)):!1}finally{U.EPSILON=n}}function Rh(r){return Math.round(r/U.EPSILON)*U.EPSILON}function Dh(r){return r.clone?r.clone():new Array(r.length)}function As(r,e,t){if(de(r)){let n=r;t=t||Dh(n);for(let o=0;o<t.length&&o<n.length;++o){let i=typeof r=="number"?r:r[o];t[o]=e(i,o,t)}return t}return e(r)}var Wt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+t];return this.check()}toArray(e=[],t=0){for(let n=0;n<this.ELEMENTS;++n)e[t+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:de(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toString(){return this.formatString(U)}formatString(e){let t="";for(let n=0;n<this.ELEMENTS;++n)t+=(n>0?", ":"")+_o(this[n],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!Ve(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,n){if(n===void 0)return this.lerp(this,e,t);for(let o=0;o<this.ELEMENTS;++o){let i=e[o],s=typeof t=="number"?t:t[o];this[o]=i+n*(s-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),t[n]);return this.check()}add(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=t[n];return this.check()}subtract(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=t[n];return this.check()}scale(e){if(typeof e=="number")for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(U.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}};function Gh(r,e){if(r.length!==e)return!1;for(let t=0;t<r.length;++t)if(!Number.isFinite(r[t]))return!1;return!0}function z(r){if(!Number.isFinite(r))throw new Error(`Invalid number ${JSON.stringify(r)}`);return r}function hn(r,e,t=""){if(U.debug&&!Gh(r,e))throw new Error(`math.gl: ${t} some fields set to invalid numbers'`);return r}var fn=class extends Wt{toString(){let e="[";if(U.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+t]}`}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,n){return this[t*this.RANK+e]=z(n),this}getColumn(e,t=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)t[o]=this[n+o];return t}setColumn(e,t){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)this[n+o]=t[o];return this}};function le(r,e){if(!r)throw new Error(`math.gl assertion ${e}`)}var qt=class extends Wt{get x(){return this[0]}set x(e){this[0]=z(e)}get y(){return this[1]}set y(e){this[1]=z(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let n=0;n<this.ELEMENTS;++n){let o=this[n]-e[n];t+=o*o}return z(t)}dot(e){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return z(t)}normalize(){let e=this.magnitude();if(e!==0)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]*=t[n];return this.check()}divide(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return le(e>=0&&e<this.ELEMENTS,"index is out of range"),z(this[e])}setComponent(e,t){return le(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=e[n]*t;return this.check()}};function Os(r,e,t){let n=e[0],o=e[1];return r[0]=t[0]*n+t[2]*o,r[1]=t[1]*n+t[3]*o,r}function Is(r,e,t){let n=e[0],o=e[1];return r[0]=t[0]*n+t[2]*o+t[4],r[1]=t[1]*n+t[3]*o+t[5],r}function Rs(r,e,t){let n=e[0],o=e[1];return r[0]=t[0]*n+t[3]*o+t[6],r[1]=t[1]*n+t[4]*o+t[7],r}function dn(r,e,t){let n=e[0],o=e[1];return r[0]=t[0]*n+t[4]*o+t[12],r[1]=t[1]*n+t[5]*o+t[13],r}function ln(r,e,t){let n=e[0],o=e[1],i=t[3]*n+t[7]*o||1;return r[0]=(t[0]*n+t[4]*o)/i,r[1]=(t[1]*n+t[5]*o)/i,r}function mn(r,e,t){let n=e[0],o=e[1],i=e[2],s=t[3]*n+t[7]*o+t[11]*i||1;return r[0]=(t[0]*n+t[4]*o+t[8]*i)/s,r[1]=(t[1]*n+t[5]*o+t[9]*i)/s,r[2]=(t[2]*n+t[6]*o+t[10]*i)/s,r}function Ds(r,e,t){let n=e[0],o=e[1];return r[0]=t[0]*n+t[2]*o,r[1]=t[1]*n+t[3]*o,r[2]=e[2],r}var Te=class extends qt{constructor(e=0,t=0){super(2),de(e)&&arguments.length===1?this.copy(e):(U.debug&&(z(e),z(t)),this[0]=e,this[1]=t)}set(e,t){return this[0]=e,this[1]=t,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return U.debug&&(z(e.x),z(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return dn(this,this,e),this.check()}transformAsVector(e){return ln(this,this,e),this.check()}transformByMatrix3(e){return Rs(this,this,e),this.check()}transformByMatrix2x3(e){return Is(this,this,e),this.check()}transformByMatrix2(e){return Os(this,this,e),this.check()}};function Gs(r){let e=r[0],t=r[1],n=r[2];return Math.sqrt(e*e+t*t+n*n)}function Fo(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]}function Ns(r,e,t){let n=e[0],o=e[1],i=e[2],s=t[0],a=t[1],c=t[2];return r[0]=o*c-i*a,r[1]=i*s-n*c,r[2]=n*a-o*s,r}function pn(r,e,t){let n=e[0],o=e[1],i=e[2],s=t[3]*n+t[7]*o+t[11]*i+t[15];return s=s||1,r[0]=(t[0]*n+t[4]*o+t[8]*i+t[12])/s,r[1]=(t[1]*n+t[5]*o+t[9]*i+t[13])/s,r[2]=(t[2]*n+t[6]*o+t[10]*i+t[14])/s,r}function _s(r,e,t){let n=e[0],o=e[1],i=e[2];return r[0]=n*t[0]+o*t[3]+i*t[6],r[1]=n*t[1]+o*t[4]+i*t[7],r[2]=n*t[2]+o*t[5]+i*t[8],r}function Us(r,e,t){let n=t[0],o=t[1],i=t[2],s=t[3],a=e[0],c=e[1],u=e[2],d=o*u-i*c,h=i*a-n*u,f=n*c-o*a,l=o*f-i*h,m=i*d-n*f,g=n*h-o*d,x=s*2;return d*=x,h*=x,f*=x,l*=2,m*=2,g*=2,r[0]=a+d+l,r[1]=c+h+m,r[2]=u+f+g,r}function ks(r,e,t,n){let o=[],i=[];return o[0]=e[0]-t[0],o[1]=e[1]-t[1],o[2]=e[2]-t[2],i[0]=o[0],i[1]=o[1]*Math.cos(n)-o[2]*Math.sin(n),i[2]=o[1]*Math.sin(n)+o[2]*Math.cos(n),r[0]=i[0]+t[0],r[1]=i[1]+t[1],r[2]=i[2]+t[2],r}function zs(r,e,t,n){let o=[],i=[];return o[0]=e[0]-t[0],o[1]=e[1]-t[1],o[2]=e[2]-t[2],i[0]=o[2]*Math.sin(n)+o[0]*Math.cos(n),i[1]=o[1],i[2]=o[2]*Math.cos(n)-o[0]*Math.sin(n),r[0]=i[0]+t[0],r[1]=i[1]+t[1],r[2]=i[2]+t[2],r}function $s(r,e,t,n){let o=[],i=[];return o[0]=e[0]-t[0],o[1]=e[1]-t[1],o[2]=e[2]-t[2],i[0]=o[0]*Math.cos(n)-o[1]*Math.sin(n),i[1]=o[0]*Math.sin(n)+o[1]*Math.cos(n),i[2]=o[2],r[0]=i[0]+t[0],r[1]=i[1]+t[1],r[2]=i[2]+t[2],r}function Fs(r,e){let t=r[0],n=r[1],o=r[2],i=e[0],s=e[1],a=e[2],c=Math.sqrt((t*t+n*n+o*o)*(i*i+s*s+a*a)),u=c&&Fo(r,e)/c;return Math.acos(Math.min(Math.max(u,-1),1))}var Vo=[0,0,0],gn,B=class r extends qt{static get ZERO(){return gn||(gn=new r(0,0,0),Object.freeze(gn)),gn}constructor(e=0,t=0,n=0){super(-0,-0,-0),arguments.length===1&&de(e)?this.copy(e):(U.debug&&(z(e),z(t),z(n)),this[0]=e,this[1]=t,this[2]=n)}set(e,t,n){return this[0]=e,this[1]=t,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return U.debug&&(z(e.x),z(e.y),z(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=z(e)}angle(e){return Fs(this,e)}cross(e){return Ns(this,this,e),this.check()}rotateX({radians:e,origin:t=Vo}){return ks(this,this,t,e),this.check()}rotateY({radians:e,origin:t=Vo}){return zs(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=Vo}){return $s(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return pn(this,this,e),this.check()}transformAsVector(e){return mn(this,this,e),this.check()}transformByMatrix3(e){return _s(this,this,e),this.check()}transformByMatrix2(e){return Ds(this,this,e),this.check()}transformByQuaternion(e){return Us(this,this,e),this.check()}};function Nh(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function Vs(r,e){if(r===e){let t=e[1],n=e[2],o=e[3],i=e[6],s=e[7],a=e[11];r[1]=e[4],r[2]=e[8],r[3]=e[12],r[4]=t,r[6]=e[9],r[7]=e[13],r[8]=n,r[9]=i,r[11]=e[14],r[12]=o,r[13]=s,r[14]=a}else r[0]=e[0],r[1]=e[4],r[2]=e[8],r[3]=e[12],r[4]=e[1],r[5]=e[5],r[6]=e[9],r[7]=e[13],r[8]=e[2],r[9]=e[6],r[10]=e[10],r[11]=e[14],r[12]=e[3],r[13]=e[7],r[14]=e[11],r[15]=e[15];return r}function Ws(r,e){let t=e[0],n=e[1],o=e[2],i=e[3],s=e[4],a=e[5],c=e[6],u=e[7],d=e[8],h=e[9],f=e[10],l=e[11],m=e[12],g=e[13],x=e[14],T=e[15],M=t*a-n*s,w=t*c-o*s,b=t*u-i*s,p=n*c-o*a,y=n*u-i*a,S=o*u-i*c,P=d*g-h*m,E=d*x-f*m,C=d*T-l*m,L=h*x-f*g,v=h*T-l*g,I=f*T-l*x,A=M*I-w*v+b*L+p*C-y*E+S*P;return A?(A=1/A,r[0]=(a*I-c*v+u*L)*A,r[1]=(o*v-n*I-i*L)*A,r[2]=(g*S-x*y+T*p)*A,r[3]=(f*y-h*S-l*p)*A,r[4]=(c*C-s*I-u*E)*A,r[5]=(t*I-o*C+i*E)*A,r[6]=(x*b-m*S-T*w)*A,r[7]=(d*S-f*b+l*w)*A,r[8]=(s*v-a*C+u*P)*A,r[9]=(n*C-t*v-i*P)*A,r[10]=(m*y-g*b+T*M)*A,r[11]=(h*b-d*y-l*M)*A,r[12]=(a*E-s*L-c*P)*A,r[13]=(t*L-n*E+o*P)*A,r[14]=(g*w-m*p-x*M)*A,r[15]=(d*p-h*w+f*M)*A,r):null}function qs(r){let e=r[0],t=r[1],n=r[2],o=r[3],i=r[4],s=r[5],a=r[6],c=r[7],u=r[8],d=r[9],h=r[10],f=r[11],l=r[12],m=r[13],g=r[14],x=r[15],T=e*s-t*i,M=e*a-n*i,w=t*a-n*s,b=u*m-d*l,p=u*g-h*l,y=d*g-h*m,S=e*y-t*p+n*b,P=i*y-s*p+a*b,E=u*w-d*M+h*T,C=l*w-m*M+g*T;return c*S-o*P+x*E-f*C}function qo(r,e,t){let n=e[0],o=e[1],i=e[2],s=e[3],a=e[4],c=e[5],u=e[6],d=e[7],h=e[8],f=e[9],l=e[10],m=e[11],g=e[12],x=e[13],T=e[14],M=e[15],w=t[0],b=t[1],p=t[2],y=t[3];return r[0]=w*n+b*a+p*h+y*g,r[1]=w*o+b*c+p*f+y*x,r[2]=w*i+b*u+p*l+y*T,r[3]=w*s+b*d+p*m+y*M,w=t[4],b=t[5],p=t[6],y=t[7],r[4]=w*n+b*a+p*h+y*g,r[5]=w*o+b*c+p*f+y*x,r[6]=w*i+b*u+p*l+y*T,r[7]=w*s+b*d+p*m+y*M,w=t[8],b=t[9],p=t[10],y=t[11],r[8]=w*n+b*a+p*h+y*g,r[9]=w*o+b*c+p*f+y*x,r[10]=w*i+b*u+p*l+y*T,r[11]=w*s+b*d+p*m+y*M,w=t[12],b=t[13],p=t[14],y=t[15],r[12]=w*n+b*a+p*h+y*g,r[13]=w*o+b*c+p*f+y*x,r[14]=w*i+b*u+p*l+y*T,r[15]=w*s+b*d+p*m+y*M,r}function js(r,e,t){let n=t[0],o=t[1],i=t[2],s,a,c,u,d,h,f,l,m,g,x,T;return e===r?(r[12]=e[0]*n+e[4]*o+e[8]*i+e[12],r[13]=e[1]*n+e[5]*o+e[9]*i+e[13],r[14]=e[2]*n+e[6]*o+e[10]*i+e[14],r[15]=e[3]*n+e[7]*o+e[11]*i+e[15]):(s=e[0],a=e[1],c=e[2],u=e[3],d=e[4],h=e[5],f=e[6],l=e[7],m=e[8],g=e[9],x=e[10],T=e[11],r[0]=s,r[1]=a,r[2]=c,r[3]=u,r[4]=d,r[5]=h,r[6]=f,r[7]=l,r[8]=m,r[9]=g,r[10]=x,r[11]=T,r[12]=s*n+d*o+m*i+e[12],r[13]=a*n+h*o+g*i+e[13],r[14]=c*n+f*o+x*i+e[14],r[15]=u*n+l*o+T*i+e[15]),r}function Ys(r,e,t){let n=t[0],o=t[1],i=t[2];return r[0]=e[0]*n,r[1]=e[1]*n,r[2]=e[2]*n,r[3]=e[3]*n,r[4]=e[4]*o,r[5]=e[5]*o,r[6]=e[6]*o,r[7]=e[7]*o,r[8]=e[8]*i,r[9]=e[9]*i,r[10]=e[10]*i,r[11]=e[11]*i,r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r}function Hs(r,e,t,n){let o=n[0],i=n[1],s=n[2],a=Math.sqrt(o*o+i*i+s*s),c,u,d,h,f,l,m,g,x,T,M,w,b,p,y,S,P,E,C,L,v,I,A,G;return a<1e-6?null:(a=1/a,o*=a,i*=a,s*=a,u=Math.sin(t),c=Math.cos(t),d=1-c,h=e[0],f=e[1],l=e[2],m=e[3],g=e[4],x=e[5],T=e[6],M=e[7],w=e[8],b=e[9],p=e[10],y=e[11],S=o*o*d+c,P=i*o*d+s*u,E=s*o*d-i*u,C=o*i*d-s*u,L=i*i*d+c,v=s*i*d+o*u,I=o*s*d+i*u,A=i*s*d-o*u,G=s*s*d+c,r[0]=h*S+g*P+w*E,r[1]=f*S+x*P+b*E,r[2]=l*S+T*P+p*E,r[3]=m*S+M*P+y*E,r[4]=h*C+g*L+w*v,r[5]=f*C+x*L+b*v,r[6]=l*C+T*L+p*v,r[7]=m*C+M*L+y*v,r[8]=h*I+g*A+w*G,r[9]=f*I+x*A+b*G,r[10]=l*I+T*A+p*G,r[11]=m*I+M*A+y*G,e!==r&&(r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r)}function Xs(r,e,t){let n=Math.sin(t),o=Math.cos(t),i=e[4],s=e[5],a=e[6],c=e[7],u=e[8],d=e[9],h=e[10],f=e[11];return e!==r&&(r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[4]=i*o+u*n,r[5]=s*o+d*n,r[6]=a*o+h*n,r[7]=c*o+f*n,r[8]=u*o-i*n,r[9]=d*o-s*n,r[10]=h*o-a*n,r[11]=f*o-c*n,r}function Zs(r,e,t){let n=Math.sin(t),o=Math.cos(t),i=e[0],s=e[1],a=e[2],c=e[3],u=e[8],d=e[9],h=e[10],f=e[11];return e!==r&&(r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[0]=i*o-u*n,r[1]=s*o-d*n,r[2]=a*o-h*n,r[3]=c*o-f*n,r[8]=i*n+u*o,r[9]=s*n+d*o,r[10]=a*n+h*o,r[11]=c*n+f*o,r}function Ks(r,e,t){let n=Math.sin(t),o=Math.cos(t),i=e[0],s=e[1],a=e[2],c=e[3],u=e[4],d=e[5],h=e[6],f=e[7];return e!==r&&(r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[0]=i*o+u*n,r[1]=s*o+d*n,r[2]=a*o+h*n,r[3]=c*o+f*n,r[4]=u*o-i*n,r[5]=d*o-s*n,r[6]=h*o-a*n,r[7]=f*o-c*n,r}function Qs(r,e){let t=e[0],n=e[1],o=e[2],i=e[3],s=t+t,a=n+n,c=o+o,u=t*s,d=n*s,h=n*a,f=o*s,l=o*a,m=o*c,g=i*s,x=i*a,T=i*c;return r[0]=1-h-m,r[1]=d+T,r[2]=f-x,r[3]=0,r[4]=d-T,r[5]=1-u-m,r[6]=l+g,r[7]=0,r[8]=f+x,r[9]=l-g,r[10]=1-u-h,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function Js(r,e,t,n,o,i,s){let a=1/(t-e),c=1/(o-n),u=1/(i-s);return r[0]=i*2*a,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=i*2*c,r[6]=0,r[7]=0,r[8]=(t+e)*a,r[9]=(o+n)*c,r[10]=(s+i)*u,r[11]=-1,r[12]=0,r[13]=0,r[14]=s*i*2*u,r[15]=0,r}function _h(r,e,t,n,o){let i=1/Math.tan(e/2);if(r[0]=i/t,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=i,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,o!=null&&o!==1/0){let s=1/(n-o);r[10]=(o+n)*s,r[14]=2*o*n*s}else r[10]=-1,r[14]=-2*n;return r}var ea=_h;function Uh(r,e,t,n,o,i,s){let a=1/(e-t),c=1/(n-o),u=1/(i-s);return r[0]=-2*a,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-2*c,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=2*u,r[11]=0,r[12]=(e+t)*a,r[13]=(o+n)*c,r[14]=(s+i)*u,r[15]=1,r}var ta=Uh;function ra(r,e,t,n){let o,i,s,a,c,u,d,h,f,l,m=e[0],g=e[1],x=e[2],T=n[0],M=n[1],w=n[2],b=t[0],p=t[1],y=t[2];return Math.abs(m-b)<1e-6&&Math.abs(g-p)<1e-6&&Math.abs(x-y)<1e-6?Nh(r):(h=m-b,f=g-p,l=x-y,o=1/Math.sqrt(h*h+f*f+l*l),h*=o,f*=o,l*=o,i=M*l-w*f,s=w*h-T*l,a=T*f-M*h,o=Math.sqrt(i*i+s*s+a*a),o?(o=1/o,i*=o,s*=o,a*=o):(i=0,s=0,a=0),c=f*a-l*s,u=l*i-h*a,d=h*s-f*i,o=Math.sqrt(c*c+u*u+d*d),o?(o=1/o,c*=o,u*=o,d*=o):(c=0,u=0,d=0),r[0]=i,r[1]=c,r[2]=h,r[3]=0,r[4]=s,r[5]=u,r[6]=f,r[7]=0,r[8]=a,r[9]=d,r[10]=l,r[11]=0,r[12]=-(i*m+s*g+a*x),r[13]=-(c*m+u*g+d*x),r[14]=-(h*m+f*g+l*x),r[15]=1,r)}function na(r,e,t){let n=e[0],o=e[1],i=e[2],s=e[3];return r[0]=t[0]*n+t[4]*o+t[8]*i+t[12]*s,r[1]=t[1]*n+t[5]*o+t[9]*i+t[13]*s,r[2]=t[2]*n+t[6]*o+t[10]*i+t[14]*s,r[3]=t[3]*n+t[7]*o+t[11]*i+t[15]*s,r}var Ho;(function(r){r[r.COL0ROW0=0]="COL0ROW0",r[r.COL0ROW1=1]="COL0ROW1",r[r.COL0ROW2=2]="COL0ROW2",r[r.COL0ROW3=3]="COL0ROW3",r[r.COL1ROW0=4]="COL1ROW0",r[r.COL1ROW1=5]="COL1ROW1",r[r.COL1ROW2=6]="COL1ROW2",r[r.COL1ROW3=7]="COL1ROW3",r[r.COL2ROW0=8]="COL2ROW0",r[r.COL2ROW1=9]="COL2ROW1",r[r.COL2ROW2=10]="COL2ROW2",r[r.COL2ROW3=11]="COL2ROW3",r[r.COL3ROW0=12]="COL3ROW0",r[r.COL3ROW1=13]="COL3ROW1",r[r.COL3ROW2=14]="COL3ROW2",r[r.COL3ROW3=15]="COL3ROW3"})(Ho||(Ho={}));var kh=45*Math.PI/180,zh=1,jo=.1,Yo=500,$h=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Be=class extends fn{static get IDENTITY(){return Vh()}static get ZERO(){return Fh()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Ho}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,n,o,i,s,a,c,u,d,h,f,l,m,g,x){return this[0]=e,this[1]=t,this[2]=n,this[3]=o,this[4]=i,this[5]=s,this[6]=a,this[7]=c,this[8]=u,this[9]=d,this[10]=h,this[11]=f,this[12]=l,this[13]=m,this[14]=g,this[15]=x,this.check()}setRowMajor(e,t,n,o,i,s,a,c,u,d,h,f,l,m,g,x){return this[0]=e,this[1]=i,this[2]=u,this[3]=l,this[4]=t,this[5]=s,this[6]=d,this[7]=m,this[8]=n,this[9]=a,this[10]=h,this[11]=g,this[12]=o,this[13]=c,this[14]=f,this[15]=x,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy($h)}fromObject(e){return this.check()}fromQuaternion(e){return Qs(this,e),this.check()}fromMatrix3(e){return this.set(e[0],e[1],e[2],0,e[3],e[4],e[5],0,e[6],e[7],e[8],0,0,0,0,1)}frustum(e){let{left:t,right:n,bottom:o,top:i,near:s=jo,far:a=Yo}=e;return a===1/0?Wh(this,t,n,o,i,s):Js(this,t,n,o,i,s,a),this.check()}lookAt(e){let{eye:t,center:n=[0,0,0],up:o=[0,1,0]}=e;return ra(this,t,n,o),this.check()}ortho(e){let{left:t,right:n,bottom:o,top:i,near:s=jo,far:a=Yo}=e;return ta(this,t,n,o,i,s,a),this.check()}orthographic(e){let{fovy:t=kh,aspect:n=zh,focalDistance:o=1,near:i=jo,far:s=Yo}=e;oa(t);let a=t/2,c=o*Math.tan(a),u=c*n;return this.ortho({left:-u,right:u,bottom:-c,top:c,near:i,far:s})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:n=1,near:o=.1,far:i=500}=e;return oa(t),ea(this,t,n,o,i),this.check()}determinant(){return qs(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let n=this.getScale(t),o=1/n[0],i=1/n[1],s=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*s,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*i,e[6]=this[6]*s,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*i,e[10]=this[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let n=this.getScale(t),o=1/n[0],i=1/n[1],s=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*s,e[3]=this[4]*o,e[4]=this[5]*i,e[5]=this[6]*s,e[6]=this[8]*o,e[7]=this[9]*i,e[8]=this[10]*s,e}transpose(){return Vs(this,this),this.check()}invert(){return Ws(this,this),this.check()}multiplyLeft(e){return qo(this,e,this),this.check()}multiplyRight(e){return qo(this,this,e),this.check()}rotateX(e){return Xs(this,this,e),this.check()}rotateY(e){return Zs(this,this,e),this.check()}rotateZ(e){return Ks(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return Hs(this,this,e,t),this.check()}scale(e){return Ys(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return js(this,this,e),this.check()}transform(e,t){return e.length===4?(t=na(t||[-0,-0,-0,-0],e,this),hn(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:n}=e,o;switch(n){case 2:o=dn(t||[-0,-0],e,this);break;case 3:o=pn(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return hn(o,e.length),o}transformAsVector(e,t){let n;switch(e.length){case 2:n=ln(t||[-0,-0],e,this);break;case 3:n=mn(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return hn(n,e.length),n}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,n){return this.identity().translate([e,t,n])}},xn,yn;function Fh(){return xn||(xn=new Be([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(xn)),xn}function Vh(){return yn||(yn=new Be,Object.freeze(yn)),yn}function oa(r){if(r>Math.PI*2)throw Error("expected radians")}function Wh(r,e,t,n,o,i){let s=2*i/(t-e),a=2*i/(o-n),c=(t+e)/(t-e),u=(o+n)/(o-n),d=-1,h=-1,f=-2*i;return r[0]=s,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=a,r[6]=0,r[7]=0,r[8]=c,r[9]=u,r[10]=d,r[11]=h,r[12]=0,r[13]=0,r[14]=f,r[15]=0,r}function sa(r,e,t=r){let n=r.x,o=r.y,i=r.z,{semiMajorAxis:s,semiMinorAxis:a,eccentricitySquared:c}=e,u=Math.sin(o),d=Math.cos(o),h=a/s,f=c<.9?s/Math.sqrt(1-c*u*u):s/Math.hypot(d,h*u),l=(f+i)*d*Math.cos(n),m=(f+i)*d*Math.sin(n),g=(f*(c<.9?1-c:h*h)+i)*u;return at(t,l,m,g)}function aa(r,e,t=r){let n=r.x,o=r.y,i=r.z,{semiMajorAxis:s,semiMinorAxis:a,eccentricitySquared:c}=e,u=Math.hypot(n,o),d=Math.hypot(n,o,i);if(!(d>0)||!Number.isFinite(d))return!1;if(c===0)return at(t,u===0?0:Math.atan2(o,n),Math.atan2(i,u),d-s);if(u===0)return at(t,0,Math.sign(i)*Math.PI/2,Math.abs(i)-a);let h=u/s,f=i/a;if(h*h+f*f<1-16*Number.EPSILON)return qh(n,o,i,u,s,a,t);if(c>=.9)return ia(n,o,i,u,s,a,t);let l=i/d,m=u/d,g=1/Math.sqrt(1-c*(2-c)*m*m),x=m*(1-c)*g,T=l*g;for(let M=0;M<30;M++){let w=s/Math.sqrt(1-c*T*T),b=u*x+i*T-w*(1-c*T*T),p=c*w/(w+b);g=1/Math.sqrt(1-p*(2-p)*m*m);let y=m*(1-p)*g,S=l*g;if(Math.abs(S*x-y*T)<=1e-12){if(!Number.isFinite(b)||!Number.isFinite(S)||!Number.isFinite(y))break;return at(t,Math.atan2(o,n),Math.atan2(S,Math.abs(y)),b)}x=y,T=S}return ia(n,o,i,u,s,a,t)}function qh(r,e,t,n,o,i,s){let a=i/o,c=a*a,u=n/o,d=t/o,h=1-c;if(!(c>0)||a>1)return!1;if(t===0)return u<h?!1:at(s,Math.atan2(e,r),0,n-o);let f=o*o,l=i*i,m=Number.isFinite(f)&&f>0?(l-c*f+st(i,i,l)-c*st(o,o,f)-st(c,f,c*f))/f:0,g=n*n,x=r*r,T=e*e,M=x+T,w=Number.isFinite(g)&&g>0?(M-g+Xo(x,T,M)+st(r,r,x)+st(e,e,T)-st(n,n,g))/(2*n):0,b=o*c,p=n-o+b,y=w+Xo(n-o,b,p)+st(o,c,b)+o*m,S=Math.abs(d)*a;if(!(S>0))return!1;let P=0,E=c,C=Math.max(S,u-h);C>P&&C<E||(C=E/2);for(let L=0;L<128;L++){let v=h+C,I=u/v,A=S/C,G=o*C,F=p-G,ft=(F+(Xo(p,-G,F)+y-st(o,C,G)))/(o*v)*(I+1),Re=ft+A*A;if(Math.abs(Re)<=4*Number.EPSILON*(Math.abs(ft)+A*A)||E-P<=4*Number.EPSILON*C){let ce=Math.atan2(d/C,u/v),Qt=Math.sin(ce),Jt=Math.cos(ce);return at(s,Math.atan2(e,r),ce,n*Jt+t*Qt-o*Math.hypot(Jt,a*Qt))}Re>0?P=C:E=C;let Kt=-2*(I*I/v+A*A/C),pe=C-Re/Kt,Cr=Number.isFinite(pe)&&pe>P&&pe<E?pe:P+(E-P)/2;if(Cr===C){let ce=Math.atan2(d/C,u/v);return at(s,Math.atan2(e,r),ce,n*Math.cos(ce)+t*Math.sin(ce)-o*Math.hypot(Math.cos(ce),a*Math.sin(ce)))}C=Cr}return!1}function Xo(r,e,t){let n=t-r;return r-(t-n)+(e-n)}function st(r,e,t){let n=134217729*r,o=134217729*e;if(!Number.isFinite(n)||!Number.isFinite(o))return 0;let i=n-(n-r),s=o-(o-e),a=r-i,c=e-s;return i*s-t+i*c+a*s+a*c}function ia(r,e,t,n,o,i,s){let a=i/o,c=a*a,u=n/o,d=t/o,h=Math.hypot(u,t/i);if(!Number.isFinite(h)||h<1-8*Number.EPSILON||!(c>0))return!1;let f=0,l=Math.hypot(u,d*a);if(!Number.isFinite(l))return!1;let m=h<=1+8*Number.EPSILON?0:l/2;for(let g=0;g<96;g++){let x=1+m,T=c+m,M=u/x,w=d*a/T,b=Math.hypot(M,w),p=b-1;if(Math.abs(p)<=4*Number.EPSILON){let P=Math.atan2(d/T,u/x),E=Math.sin(P),C=Math.cos(P),L=n*C+t*E-o*Math.hypot(C,a*E);return at(s,Math.atan2(e,r),P,L)}p>0?f=m:l=m;let y=-(M*M/x+w*w/T)/b,S=m-p/y;m=Number.isFinite(S)&&S>f&&S<l?S:(f+l)/2}return!1}function at(r,e,t,n){return!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)?!1:(r.x=e,r.y=t,r.z=n,!0)}var We=6356752314245179e-9,jh={radii:[6378137,6378137,We],radiiSquared:[6378137*6378137,6378137*6378137,We*We],oneOverRadii:[1/6378137,1/6378137,1/We],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(We*We)],maximumRadius:Math.max(6378137,6378137,We),centerToleranceSquared:.1};function Zo(r){return r}var dy=new B;function Yh(r,e=[],t=Zo){return"longitude"in r?(e[0]=t(r.longitude),e[1]=t(r.latitude),e[2]=r.height):"x"in r?(e[0]=t(r.x),e[1]=t(r.y),e[2]=r.z):(e[0]=t(r[0]),e[1]=t(r[1]),e[2]=r[2]),e}function Ko(r,e=[]){return Yh(r,e,U._cartographicRadians?Zo:Uo)}function Qo(r,e,t,n){let o=U._cartographicRadians?Zo:ko,i=o(r),s=o(e);return"longitude"in n?(n.longitude=i,n.latitude=s,n.height=t):"x"in n?(n.x=i,n.y=s,n.z=t):(n[0]=i,n[1]=s,n[2]=t),n}function ca(){return{eastX:0,eastY:1,northZ:1,upX:1,upY:0,upZ:0}}function ua(r,e,t){let n=r.x,o=r.y,i=r.z,s=e.x,a=e.y,c=e.z;return i!==0?!1:Hh(t,n,o,s*o-a*n,s,a,c)}function ha(r,e,t,n,o,i){let s=Jo(t),a=Jo(n),c=Jo(o),u=Math.abs(s),d=Math.abs(a),h=Math.abs(c);if(!u||!d||!h||u===d||u===h||d===h||(u%3+1===d?1:-1)*Math.sign(s*a*c)!==1||!Array.isArray(i)&&i.length<16)return!1;let l=r.eastX,m=r.eastY,g=r.northZ,x=r.upX,T=r.upY,M=r.upZ,w=-M*m,b=M*l,p=e.x,y=e.y,S=e.z,P=(u===1?l:u===2?w:x)*Math.sign(s),E=(u===1?m:u===2?b:T)*Math.sign(s),C=(u===1?0:u===2?g:M)*Math.sign(s),L=(d===1?l:d===2?w:x)*Math.sign(a),v=(d===1?m:d===2?b:T)*Math.sign(a),I=(d===1?0:d===2?g:M)*Math.sign(a),A=(h===1?l:h===2?w:x)*Math.sign(c),G=(h===1?m:h===2?b:T)*Math.sign(c),F=(h===1?0:h===2?g:M)*Math.sign(c);return!Number.isFinite(P)||!Number.isFinite(E)||!Number.isFinite(C)||!Number.isFinite(L)||!Number.isFinite(v)||!Number.isFinite(I)||!Number.isFinite(A)||!Number.isFinite(G)||!Number.isFinite(F)||!Number.isFinite(p)||!Number.isFinite(y)||!Number.isFinite(S)||i instanceof Float32Array&&(!Number.isFinite(Math.fround(P))||!Number.isFinite(Math.fround(E))||!Number.isFinite(Math.fround(C))||!Number.isFinite(Math.fround(L))||!Number.isFinite(Math.fround(v))||!Number.isFinite(Math.fround(I))||!Number.isFinite(Math.fround(A))||!Number.isFinite(Math.fround(G))||!Number.isFinite(Math.fround(F))||!Number.isFinite(Math.fround(p))||!Number.isFinite(Math.fround(y))||!Number.isFinite(Math.fround(S)))?!1:(i[0]=P,i[1]=E,i[2]=C,i[3]=0,i[4]=L,i[5]=v,i[6]=I,i[7]=0,i[8]=A,i[9]=G,i[10]=F,i[11]=0,i[12]=p,i[13]=y,i[14]=S,i[15]=1,!0)}function Jo(r){switch(r){case"east":return 1;case"west":return-1;case"north":return 2;case"south":return-2;case"up":return 3;case"down":return-3;default:return 0}}function Hh(r,e,t,n,o,i,s){return!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(i)||!Number.isFinite(s)?!1:(r.eastX=e,r.eastY=t,r.northZ=n,r.upX=o,r.upY=i,r.upZ=s,!0)}var fa=1e-14,Xh=new B,da=ca(),la={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},ei={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},jt={east:new B,north:new B,up:new B,west:new B,south:new B,down:new B},Zh=new B,Kh=new B,Qh=new B;function ti(r,e,t,n,o,i){let s=la[e]&&la[e][t];le(s&&(!n||n===s));let a,c,u,d=Xh.copy(o),h=Ve(d.x,0,fa)&&Ve(d.y,0,fa),f=r.radii;if(f.x===f.y&&f.x>0&&f.z>0&&f.z<=f.x&&(!h||d.z!==0)){let{east:E,up:C}=jt;if(h?(E.set(0,1,0),C.set(0,0,Math.sign(d.z))):(E.set(-d.y,d.x,0).normalize(),r.geodeticSurfaceNormal(d,C)),!ua(E,C,da)||!ha(da,d,e,t,n,i))throw new Error("Unsupported local frame");return i}if(h){let E=Math.sign(d.z);a=Zh.fromArray(ei[e]),e!=="east"&&e!=="west"&&a.scale(E),c=Kh.fromArray(ei[t]),t!=="east"&&t!=="west"&&c.scale(E),u=Qh.fromArray(ei[n]),n!=="east"&&n!=="west"&&u.scale(E)}else{let{up:E,east:C,north:L}=jt;C.set(-d.y,d.x,0).normalize(),r.geodeticSurfaceNormal(d,E),L.copy(E).cross(C);let{down:v,west:I,south:A}=jt;v.copy(E).scale(-1),I.copy(C).scale(-1),A.copy(L).scale(-1),a=jt[e],c=jt[t],u=jt[n]}let l=a.x,m=a.y,g=a.z,x=c.x,T=c.y,M=c.z,w=u.x,b=u.y,p=u.z,y=d.x,S=d.y,P=d.z;return i[0]=l,i[1]=m,i[2]=g,i[3]=0,i[4]=x,i[5]=T,i[6]=M,i[7]=0,i[8]=w,i[9]=b,i[10]=p,i[11]=0,i[12]=y,i[13]=S,i[14]=P,i[15]=1,i}var ma=new B,Jh=new B,ef=new B;function pa(r,e,t=[]){let{oneOverRadii:n,oneOverRadiiSquared:o,centerToleranceSquared:i}=e,s=r,a="x"in r?s.x:r[0],c="x"in r?s.y:r[1],u="x"in r?s.z:r[2];if(!Number.isFinite(a)||!Number.isFinite(c)||!Number.isFinite(u))return;ma.set(a,c,u);let d=n.x,h=n.y,f=n.z,l=a*a*d*d,m=c*c*h*h,g=u*u*f*f,x=l+m+g,T=Math.sqrt(1/x);if(!Number.isFinite(T)||!Number.isFinite(x))return;let M=Jh;if(M.set(a,c,u).scale(T),x<i)return bn(t,M.x,M.y,M.z);let w=o.x,b=o.y,p=o.z,y=ef;y.set(M.x*w*2,M.y*b*2,M.z*p*2);let S=(1-T)*ma.len()/(.5*y.len()),P=0,E,C,L,v;for(let I=0;I<64;I++){S-=P,E=1/(1+S*w),C=1/(1+S*b),L=1/(1+S*p);let A=E*E,G=C*C,F=L*L,ht=A*E,ft=G*C,Re=F*L;if(v=l*A+m*G+g*F-1,!Number.isFinite(v))return;if(Math.abs(v)<=it.EPSILON12)return bn(t,a*E,c*C,u*L);let pe=-2*(l*ht*w+m*ft*b+g*Re*p);if(!Number.isFinite(pe)||pe===0||(P=v/pe,!Number.isFinite(P)))return}}function bn(r,e,t,n){if(de(r))r[0]=e,r[1]=t,r[2]=n;else{let o=r;o.x=e,o.y=t,o.z=n}return r}var ae={x:0,y:0,z:0},wn=new B,ga=new B,nf=new B,Me=new B,of=new B,wr=new B,ct=class r{static fromSpheroid(e){let{semiMajorAxis:t,semiMinorAxis:n}=e;return xa(t,n),new r(t,t,n)}constructor(e=0,t=0,n=0){this.centerToleranceSquared=it.EPSILON1,le(e>=0),le(t>=0),le(n>=0),this.radii=new B(e,t,n),this.radiiSquared=new B(e*e,t*t,n*n),this.radiiToTheFourth=new B(e*e*e*e,t*t*t*t,n*n*n*n),this.oneOverRadii=new B(e===0?0:1/e,t===0?0:1/t,n===0?0:1/n),this.oneOverRadiiSquared=new B(e===0?0:1/(e*e),t===0?0:1/(t*t),n===0?0:1/(n*n)),this.minimumRadius=Math.min(e,t,n),this.maximumRadius=Math.max(e,t,n),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),e===t&&n>0&&n<=e&&Number.isFinite(this.radiiSquared.x)&&this.radiiSquared.z>0&&(this.spheroidGeometry=Object.freeze({semiMajorAxis:e,semiMinorAxis:n,eccentricitySquared:1-this.radiiSquared.z/this.radiiSquared.x})),Object.freeze(this)}toSpheroid(){let{x:e,y:t,z:n}=this.radii;if(e!==t)throw new Error("Spheroid requires equal X/Y radii");return xa(e,n),Object.freeze({semiMajorAxis:e,semiMinorAxis:n})}equals(e){return this===e||!!(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,t=[0,0,0]){if(this.spheroidGeometry){let a=Ko(e,wr);return ae.x=a[0],ae.y=a[1],ae.z=a[2],sa(ae,this.spheroidGeometry)?bn(t,ae.x,ae.y,ae.z):void 0}let n=ga,o=nf,[,,i]=e;this.geodeticSurfaceNormalCartographic(e,n),o.copy(this.radiiSquared).scale(n);let s=Math.sqrt(n.dot(o));return o.scale(1/s),n.scale(i),o.add(n),o.to(t)}cartesianToCartographic(e,t=[0,0,0]){let n=e,o="x"in e?n.x:e[0],i="x"in e?n.y:e[1],s="x"in e?n.z:e[2];if(!Number.isFinite(o)||!Number.isFinite(i)||!Number.isFinite(s))return;if(this.spheroidGeometry&&Number.isFinite(o*o+i*i+s*s)&&Number.isFinite(this.oneOverRadiiSquared.x)&&Number.isFinite(this.oneOverRadiiSquared.z)){if(ae.x=o,ae.y=i,ae.z=s,!aa(ae,this.spheroidGeometry))return;let l=o===0&&i===0?Math.atan2(i,o):ae.x;return Qo(l,ae.y,ae.z,t)}wr.set(o,i,s);let a=this.scaleToGeodeticSurface(wr,Me);if(!a)return;let c=this.geodeticSurfaceNormal(a,ga),u=of;u.copy(wr).subtract(a);let d=Math.atan2(c.y,c.x),h=Math.atan2(c.z,Math.hypot(c.x,c.y)),f=Math.sign(Fo(u,wr))*Gs(u);return Qo(d,h,f,t)}eastNorthUpToFixedFrame(e,t=new Be){return ti(this,"east","north","up",e,t)}localFrameToFixedFrame(e,t,n,o,i=new Be){return ti(this,e,t,n,o,i)}geocentricSurfaceNormal(e,t=[0,0,0]){return wn.from(e).normalize().to(t)}geodeticSurfaceNormalCartographic(e,t=[0,0,0]){let n=Ko(e),o=n[0],i=n[1],s=Math.cos(i);return wn.set(s*Math.cos(o),s*Math.sin(o),Math.sin(i)).normalize(),wn.to(t)}geodeticSurfaceNormal(e,t=[0,0,0]){return wn.from(e).scale(this.oneOverRadiiSquared).normalize().to(t)}scaleToGeodeticSurface(e,t){return pa(e,this,t)}scaleToGeocentricSurface(e,t=[0,0,0]){Me.from(e);let n=Me.x,o=Me.y,i=Me.z,s=this.oneOverRadiiSquared,a=1/Math.sqrt(n*n*s.x+o*o*s.y+i*i*s.z);return Me.multiplyByScalar(a).to(t)}transformPositionToScaledSpace(e,t=[0,0,0]){return Me.from(e).scale(this.oneOverRadii).to(t)}transformPositionFromScaledSpace(e,t=[0,0,0]){return Me.from(e).scale(this.radii).to(t)}getSurfaceNormalIntersectionWithZAxis(e,t=0,n=[0,0,0]){le(Ve(this.radii.x,this.radii.y,it.EPSILON15)),le(this.radii.z>0),Me.from(e);let o=Me.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(o)>=this.radii.z-t))return Me.set(0,0,o).to(n)}};ct.WGS84=new ct(6378137,6378137,We);function xa(r,e){if(!Number.isFinite(r)||!Number.isFinite(e)||r<=0||e<=0||e>r)throw new Error("Spheroid requires finite positive axes with semiMinorAxis <= semiMajorAxis")}var Tr={};Un(Tr,{EPSILON1:()=>sf,EPSILON10:()=>pf,EPSILON11:()=>gf,EPSILON12:()=>xf,EPSILON13:()=>yf,EPSILON14:()=>bf,EPSILON15:()=>wf,EPSILON16:()=>Tf,EPSILON17:()=>Mf,EPSILON18:()=>Ef,EPSILON19:()=>Sf,EPSILON2:()=>af,EPSILON20:()=>Pf,EPSILON3:()=>cf,EPSILON4:()=>uf,EPSILON5:()=>hf,EPSILON6:()=>ff,EPSILON7:()=>df,EPSILON8:()=>lf,EPSILON9:()=>mf,PI:()=>Bf,PI_OVER_FOUR:()=>vf,PI_OVER_SIX:()=>Lf,PI_OVER_TWO:()=>Cf,TWO_PI:()=>Af});var sf=.1,af=.01,cf=.001,uf=1e-4,hf=1e-5,ff=1e-6,df=1e-7,lf=1e-8,mf=1e-9,pf=1e-10,gf=1e-11,xf=1e-12,yf=1e-13,bf=1e-14,wf=1e-15,Tf=1e-16,Mf=1e-17,Ef=1e-18,Sf=1e-19,Pf=1e-20,Cf=Math.PI/2,vf=Math.PI/4,Lf=Math.PI/6,Bf=Math.PI,Af=Math.PI*2;var Ly=1/Math.PI*180,By=1/180*Math.PI,Of={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Of}};var H=globalThis.mathgl.config;function ri(r,{precision:e=H.precision}={}){return r=If(r),`${parseFloat(r.toPrecision(e))}`}function Ct(r){return Array.isArray(r)||ArrayBuffer.isView(r)&&!(r instanceof DataView)}function ut(r,e,t){let n=H.EPSILON;t&&(H.EPSILON=t);try{if(r===e)return!0;if(Ct(r)&&Ct(e)){if(r.length!==e.length)return!1;for(let o=0;o<r.length;++o)if(!ut(r[o],e[o]))return!1;return!0}return r&&r.equals?r.equals(e):e&&e.equals?e.equals(r):typeof r=="number"&&typeof e=="number"?Math.abs(r-e)<=H.EPSILON*Math.max(1,Math.abs(r),Math.abs(e)):!1}finally{H.EPSILON=n}}function If(r){return Math.round(r/H.EPSILON)*H.EPSILON}var Yt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+t];return this.check()}toArray(e=[],t=0){for(let n=0;n<this.ELEMENTS;++n)e[t+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Ct(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toString(){return this.formatString(H)}formatString(e){let t="";for(let n=0;n<this.ELEMENTS;++n)t+=(n>0?", ":"")+ri(this[n],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!ut(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,n){if(n===void 0)return this.lerp(this,e,t);for(let o=0;o<this.ELEMENTS;++o){let i=e[o],s=typeof t=="number"?t:t[o];this[o]=i+n*(s-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),t[n]);return this.check()}add(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=t[n];return this.check()}subtract(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=t[n];return this.check()}scale(e){if(typeof e=="number")for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(H.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}};function Rf(r,e){if(r.length!==e)return!1;for(let t=0;t<r.length;++t)if(!Number.isFinite(r[t]))return!1;return!0}function re(r){if(!Number.isFinite(r))throw new Error(`Invalid number ${JSON.stringify(r)}`);return r}function ya(r,e,t=""){if(H.debug&&!Rf(r,e))throw new Error(`math.gl: ${t} some fields set to invalid numbers'`);return r}var Tn=class extends Yt{toString(){let e="[";if(H.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+t]}`}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,n){return this[t*this.RANK+e]=re(n),this}getColumn(e,t=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)t[o]=this[n+o];return t}setColumn(e,t){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)this[n+o]=t[o];return this}};function Ae(r,e){if(!r)throw new Error(`math.gl assertion ${e}`)}var Mn=class extends Yt{get x(){return this[0]}set x(e){this[0]=re(e)}get y(){return this[1]}set y(e){this[1]=re(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let n=0;n<this.ELEMENTS;++n){let o=this[n]-e[n];t+=o*o}return re(t)}dot(e){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return re(t)}normalize(){let e=this.magnitude();if(e!==0)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]*=t[n];return this.check()}divide(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Ae(e>=0&&e<this.ELEMENTS,"index is out of range"),re(this[e])}setComponent(e,t){return Ae(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=e[n]*t;return this.check()}};function ba(r,e,t){let n=e[0],o=e[1];return r[0]=t[0]*n+t[3]*o+t[6],r[1]=t[1]*n+t[4]*o+t[7],r}function wa(r,e,t){let n=e[0],o=e[1],i=e[2],s=t[3]*n+t[7]*o+t[11]*i||1;return r[0]=(t[0]*n+t[4]*o+t[8]*i)/s,r[1]=(t[1]*n+t[5]*o+t[9]*i)/s,r[2]=(t[2]*n+t[6]*o+t[10]*i)/s,r}function Ta(r,e,t){let n=e[0],o=e[1];return r[0]=t[0]*n+t[2]*o,r[1]=t[1]*n+t[3]*o,r[2]=e[2],r}function Ma(r,e,t){let n=e[0],o=e[1],i=e[2];return r[0]=t[0]*n+t[3]*o+t[6]*i,r[1]=t[1]*n+t[4]*o+t[7]*i,r[2]=t[2]*n+t[5]*o+t[8]*i,r[3]=e[3],r}function Df(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]}function Ea(r,e,t){let n=e[0],o=e[1],i=e[2],s=t[0],a=t[1],c=t[2];return r[0]=o*c-i*a,r[1]=i*s-n*c,r[2]=n*a-o*s,r}function Sa(r,e,t){let n=e[0],o=e[1],i=e[2],s=t[3]*n+t[7]*o+t[11]*i+t[15];return s=s||1,r[0]=(t[0]*n+t[4]*o+t[8]*i+t[12])/s,r[1]=(t[1]*n+t[5]*o+t[9]*i+t[13])/s,r[2]=(t[2]*n+t[6]*o+t[10]*i+t[14])/s,r}function En(r,e,t){let n=e[0],o=e[1],i=e[2];return r[0]=n*t[0]+o*t[3]+i*t[6],r[1]=n*t[1]+o*t[4]+i*t[7],r[2]=n*t[2]+o*t[5]+i*t[8],r}function Pa(r,e,t){let n=t[0],o=t[1],i=t[2],s=t[3],a=e[0],c=e[1],u=e[2],d=o*u-i*c,h=i*a-n*u,f=n*c-o*a,l=o*f-i*h,m=i*d-n*f,g=n*h-o*d,x=s*2;return d*=x,h*=x,f*=x,l*=2,m*=2,g*=2,r[0]=a+d+l,r[1]=c+h+m,r[2]=u+f+g,r}function Ca(r,e,t,n){let o=[],i=[];return o[0]=e[0]-t[0],o[1]=e[1]-t[1],o[2]=e[2]-t[2],i[0]=o[0],i[1]=o[1]*Math.cos(n)-o[2]*Math.sin(n),i[2]=o[1]*Math.sin(n)+o[2]*Math.cos(n),r[0]=i[0]+t[0],r[1]=i[1]+t[1],r[2]=i[2]+t[2],r}function va(r,e,t,n){let o=[],i=[];return o[0]=e[0]-t[0],o[1]=e[1]-t[1],o[2]=e[2]-t[2],i[0]=o[2]*Math.sin(n)+o[0]*Math.cos(n),i[1]=o[1],i[2]=o[2]*Math.cos(n)-o[0]*Math.sin(n),r[0]=i[0]+t[0],r[1]=i[1]+t[1],r[2]=i[2]+t[2],r}function La(r,e,t,n){let o=[],i=[];return o[0]=e[0]-t[0],o[1]=e[1]-t[1],o[2]=e[2]-t[2],i[0]=o[0]*Math.cos(n)-o[1]*Math.sin(n),i[1]=o[0]*Math.sin(n)+o[1]*Math.cos(n),i[2]=o[2],r[0]=i[0]+t[0],r[1]=i[1]+t[1],r[2]=i[2]+t[2],r}function Ba(r,e){let t=r[0],n=r[1],o=r[2],i=e[0],s=e[1],a=e[2],c=Math.sqrt((t*t+n*n+o*o)*(i*i+s*s+a*a)),u=c&&Df(r,e)/c;return Math.acos(Math.min(Math.max(u,-1),1))}var ni=[0,0,0],Sn,O=class r extends Mn{static get ZERO(){return Sn||(Sn=new r(0,0,0),Object.freeze(Sn)),Sn}constructor(e=0,t=0,n=0){super(-0,-0,-0),arguments.length===1&&Ct(e)?this.copy(e):(H.debug&&(re(e),re(t),re(n)),this[0]=e,this[1]=t,this[2]=n)}set(e,t,n){return this[0]=e,this[1]=t,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return H.debug&&(re(e.x),re(e.y),re(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=re(e)}angle(e){return Ba(this,e)}cross(e){return Ea(this,this,e),this.check()}rotateX({radians:e,origin:t=ni}){return Ca(this,this,t,e),this.check()}rotateY({radians:e,origin:t=ni}){return va(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=ni}){return La(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Sa(this,this,e),this.check()}transformAsVector(e){return wa(this,this,e),this.check()}transformByMatrix3(e){return En(this,this,e),this.check()}transformByMatrix2(e){return Ta(this,this,e),this.check()}transformByQuaternion(e){return Pa(this,this,e),this.check()}};function Aa(r,e){if(r===e){let t=e[1],n=e[2],o=e[5];r[1]=e[3],r[2]=e[6],r[3]=t,r[5]=e[7],r[6]=n,r[7]=o}else r[0]=e[0],r[1]=e[3],r[2]=e[6],r[3]=e[1],r[4]=e[4],r[5]=e[7],r[6]=e[2],r[7]=e[5],r[8]=e[8];return r}function Oa(r,e){let t=e[0],n=e[1],o=e[2],i=e[3],s=e[4],a=e[5],c=e[6],u=e[7],d=e[8],h=d*s-a*u,f=-d*i+a*c,l=u*i-s*c,m=t*h+n*f+o*l;return m?(m=1/m,r[0]=h*m,r[1]=(-d*n+o*u)*m,r[2]=(a*n-o*s)*m,r[3]=f*m,r[4]=(d*t-o*c)*m,r[5]=(-a*t+o*i)*m,r[6]=l*m,r[7]=(-u*t+n*c)*m,r[8]=(s*t-n*i)*m,r):null}function Ia(r){let e=r[0],t=r[1],n=r[2],o=r[3],i=r[4],s=r[5],a=r[6],c=r[7],u=r[8];return e*(u*i-s*c)+t*(-u*o+s*a)+n*(c*o-i*a)}function oi(r,e,t){let n=e[0],o=e[1],i=e[2],s=e[3],a=e[4],c=e[5],u=e[6],d=e[7],h=e[8],f=t[0],l=t[1],m=t[2],g=t[3],x=t[4],T=t[5],M=t[6],w=t[7],b=t[8];return r[0]=f*n+l*s+m*u,r[1]=f*o+l*a+m*d,r[2]=f*i+l*c+m*h,r[3]=g*n+x*s+T*u,r[4]=g*o+x*a+T*d,r[5]=g*i+x*c+T*h,r[6]=M*n+w*s+b*u,r[7]=M*o+w*a+b*d,r[8]=M*i+w*c+b*h,r}function Ra(r,e,t){let n=e[0],o=e[1],i=e[2],s=e[3],a=e[4],c=e[5],u=e[6],d=e[7],h=e[8],f=t[0],l=t[1];return r[0]=n,r[1]=o,r[2]=i,r[3]=s,r[4]=a,r[5]=c,r[6]=f*n+l*s+u,r[7]=f*o+l*a+d,r[8]=f*i+l*c+h,r}function Da(r,e,t){let n=e[0],o=e[1],i=e[2],s=e[3],a=e[4],c=e[5],u=e[6],d=e[7],h=e[8],f=Math.sin(t),l=Math.cos(t);return r[0]=l*n+f*s,r[1]=l*o+f*a,r[2]=l*i+f*c,r[3]=l*s-f*n,r[4]=l*a-f*o,r[5]=l*c-f*i,r[6]=u,r[7]=d,r[8]=h,r}function ii(r,e,t){let n=t[0],o=t[1];return r[0]=n*e[0],r[1]=n*e[1],r[2]=n*e[2],r[3]=o*e[3],r[4]=o*e[4],r[5]=o*e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r}function Ga(r,e){let t=e[0],n=e[1],o=e[2],i=e[3],s=t+t,a=n+n,c=o+o,u=t*s,d=n*s,h=n*a,f=o*s,l=o*a,m=o*c,g=i*s,x=i*a,T=i*c;return r[0]=1-h-m,r[3]=d-T,r[6]=f+x,r[1]=d+T,r[4]=1-u-m,r[7]=l-g,r[2]=f-x,r[5]=l+g,r[8]=1-u-h,r}var si;(function(r){r[r.COL0ROW0=0]="COL0ROW0",r[r.COL0ROW1=1]="COL0ROW1",r[r.COL0ROW2=2]="COL0ROW2",r[r.COL1ROW0=3]="COL1ROW0",r[r.COL1ROW1=4]="COL1ROW1",r[r.COL1ROW2=5]="COL1ROW2",r[r.COL2ROW0=6]="COL2ROW0",r[r.COL2ROW1=7]="COL2ROW1",r[r.COL2ROW2=8]="COL2ROW2"})(si||(si={}));var Gf=Object.freeze([1,0,0,0,1,0,0,0,1]),ne=class extends Tn{static get IDENTITY(){return _f()}static get ZERO(){return Nf()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return si}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(Gf)}fromObject(e){return this.check()}fromQuaternion(e){return Ga(this,e),this.check()}fromMatrix4(e){return this.set(e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10])}set(e,t,n,o,i,s,a,c,u){return this[0]=e,this[1]=t,this[2]=n,this[3]=o,this[4]=i,this[5]=s,this[6]=a,this[7]=c,this[8]=u,this.check()}setRowMajor(e,t,n,o,i,s,a,c,u){return this[0]=e,this[1]=o,this[2]=a,this[3]=t,this[4]=i,this[5]=c,this[6]=n,this[7]=s,this[8]=u,this.check()}determinant(){return Ia(this)}transpose(){return Aa(this,this),this.check()}invert(){return Oa(this,this),this.check()}multiplyLeft(e){return oi(this,e,this),this.check()}multiplyRight(e){return oi(this,this,e),this.check()}rotate(e){return Da(this,this,e),this.check()}scale(e){return Array.isArray(e)?ii(this,this,e):ii(this,this,[e,e]),this.check()}translate(e){return Ra(this,this,e),this.check()}transform(e,t){let n;switch(e.length){case 2:n=ba(t||[-0,-0],e,this);break;case 3:n=En(t||[-0,-0,-0],e,this);break;case 4:n=Ma(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return ya(n,e.length),n}},Pn,Cn=null;function Nf(){return Pn||(Pn=new ne([0,0,0,0,0,0,0,0,0]),Object.freeze(Pn)),Pn}function _f(){return Cn||(Cn=new ne,Object.freeze(Cn)),Cn}var P0=new O,C0=new O;var B0=new O,A0=new O;var G0=new O,N0=new O,_0=new O,U0=new O,k0=new O,z0=new O,$0=new O;var Na=new O,_a=new O,Oe=class r{constructor(e=[0,0,1],t=0){this.normal=new O,this.distance=-0,this.fromNormalDistance(e,t)}fromNormalDistance(e,t){return Ae(Number.isFinite(t)),this.normal.from(e).normalize(),this.distance=t,this}fromPointNormal(e,t){e=Na.from(e),this.normal.from(t).normalize();let n=-this.normal.dot(e);return this.distance=n,this}fromCoefficients(e,t,n,o){return this.normal.set(e,t,n),Ae(ut(this.normal.len(),1)),this.distance=o,this}clone(){return new r(this.normal,this.distance)}equals(e){return ut(this.distance,e.distance)&&ut(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){let t=_a.copy(this.normal).transformAsVector(e).normalize(),n=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(n,t)}projectPointOntoPlane(e,t=[0,0,0]){let n=Na.from(e),o=this.getPointDistance(n),i=_a.copy(this.normal).scale(o);return n.subtract(i).to(t)}intersectWithRay(e,t=new O){let n=e.origin,o=e.direction,i=this.normal,s=i.dot(o);if(Math.abs(s)<Tr.EPSILON15)return;let a=(-this.distance-i.dot(n))/s;if(!(a<0))return t.copy(o).multiplyByScalar(a).add(n)}};var Ua=[new O([1,0,0]),new O([0,1,0]),new O([0,0,1])],ka=new O,Uf=new O,vt=class r{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*Ua.length;let t=e.center,n=e.radius,o=0;for(let i of Ua){let s=this.planes[o],a=this.planes[o+1];s||(s=this.planes[o]=new Oe),a||(a=this.planes[o+1]=new Oe);let c=ka.copy(i).scale(-n).add(t);s.fromPointNormal(c,i);let u=ka.copy(i).scale(n).add(t),d=Uf.copy(i).negate();a.fromPointNormal(u,d),o+=2}return this}computeVisibility(e){let t="inside";for(let n of this.planes)switch(e.intersectPlane(n)){case"outside":return"outside";case"intersecting":t="intersecting";break;default:}return t}computeVisibilityWithPlaneMask(e,t){if(Ae(Number.isFinite(t),"parentPlaneMask is required."),t===r.MASK_OUTSIDE||t===r.MASK_INSIDE)return t;let n=r.MASK_INSIDE,o=this.planes;for(let i=0;i<this.planes.length;++i){let s=i<31?1<<i:0;if(i<31&&(t&s)===0)continue;let a=o[i],c=e.intersectPlane(a);if(c==="outside")return r.MASK_OUTSIDE;c==="intersecting"&&(n|=s)}return n}};vt.MASK_OUTSIDE=4294967295;vt.MASK_INSIDE=0;vt.MASK_INDETERMINATE=2147483647;var l1=new O,m1=new O,p1=new O,g1=new O,x1=new O;var E1=new O,S1=new O,P1=new O,C1=new O,v1=new O,L1=new O,B1=new O,A1=new O,O1=new O,I1=new O,R1=new O,D1=new O;var _1=new ne,U1=new ne,k1=new ne,z1=new ne,$1=new ne;var Y1=new O,H1=new O,X1=new O,Z1=new O,K1=new O,Q1=new ne,J1={diagonal:new ne,unitary:new ne};var kb=new B,zb=new B,$b=new Be,Fb=new B;var Kb=new B,Qb=new B,Jb=new B,ew=new B,tw=new B,rw=new B,nw=new B,ow=new B,iw=new B,sw=new B,aw=new B,cw=new B,uw=new Te,hw=new Te,fw=new Te,dw=new Te,lw=new Te,mw=new Oe,pw=new B,gw=new B,xw=new B,yw=new B,bw=new Te,ww=new B,Tw=new B,Mw=new B(1,0,0),Ew=new B(0,0,1);function Ln(r){return typeof r=="string"?Vt(r):r}var Ie=class{get contract(){return{values:[...hi(ui(this.expression)).map(e=>({value:e,access:"read"})),{value:this.output,access:"write"}]}}type="expression";id;output;expression;integerRounding;constructor(e){this.id=e.id??`${e.output}-expression`,this.output=e.output,this.expression=e.expression,this.integerRounding=e.integerRounding??"truncate"}};function ci(r){return/^(float32|sint32|uint32)(x[234])?$/.test(r)}function J(r){let e=D(r);return{components:e.components,componentType:e.signedDataType}}function Mr(r,e){return e===1?r:`${r}x${e}`}function ui(r){let e=t=>{let n=t;switch(n.type){case"Identifier":return{kind:"reference",name:n.name};case"Literal":if(typeof n.value=="number"&&Number.isFinite(Math.fround(n.value)))return{kind:"literal",value:n.value};break;case"UnaryExpression":if(n.operator==="-")return{kind:"negate",argument:e(n.argument)};break;case"MemberExpression":{let o=n.property;if(n.computed||o.type!=="Identifier")throw new Error("Computed component access is unsupported");if(!/^[xyzw]{1,4}$/.test(o.name))throw new Error(`Invalid swizzle .${o.name}: expected 1\u20134 xyzw components`);return{kind:"swizzle",argument:e(n.object),components:[...o.name].map(i=>"xyzw".indexOf(i))}}case"CallExpression":{let o=n.callee;if(o.type!=="Identifier")break;let i=o.name;if(/^vec[234]$/.test(i)){if(n.arguments.length<1||n.arguments.length>4)throw new Error(`${i}: expected 1\u20134 arguments, received ${n.arguments.length}`);return{kind:"construct",width:Number(i[3]),arguments:n.arguments.map(e)}}if(Hf(i)){if(n.arguments.length!==1)throw new Error(`Invalid argument count for ${i}`);return{kind:"cast",format:i,argument:e(n.arguments[0])}}if(!["abs","sqrt","pow","sin","cos","tan","exp","log","dot","length","equalAll","select"].includes(i))break;let s=i==="select"?3:["pow","dot","equalAll"].includes(i)?2:1;if(n.arguments.length!==s)throw new Error(`Invalid argument count for GPU expression function ${i}`);return{kind:"call",name:i,arguments:n.arguments.map(e)}}case"BinaryExpression":if(["+","-","*","/"].includes(n.operator))return{kind:"binary",operator:n.operator,left:e(n.left),right:e(n.right)};break}throw new Error(`Unsupported GPU expression syntax: ${n.type}`)};return e(typeof r=="string"?Ln(r):r)}function hi(r){let e=new Set,t=n=>{switch(n.kind){case"reference":e.add(n.name);break;case"swizzle":case"cast":case"negate":t(n.argument);break;case"construct":case"call":n.arguments.forEach(t);break;case"binary":t(n.left),t(n.right);break}};return t(r),[...e]}function Hf(r){return r==="float32"||r==="sint32"||r==="uint32"}function me(r,e){switch(r.kind){case"literal":return"float32";case"reference":{let t=e.get(r.name);if(!t)throw new Error(`Undeclared numeric input ${r.name}`);return t}case"swizzle":{let t=J(me(r.argument,e)),n=Math.max(...r.components)+1;if(n>t.components){let o=r.components.map(s=>"xyzw"[s]).join(""),i=r.argument.kind==="reference"?r.argument.name:"input";throw new Error(`.${o} needs ${n} components; ${i} has ${t.components}`)}return Mr(t.componentType,r.components.length)}case"construct":{let t=r.arguments.map(i=>J(me(i,e))),n=t[0].componentType;if(t.some(i=>i.componentType!==n))throw new Error(`vec${r.width}: mixed component types (${t.map(i=>i.componentType).join(", ")})`);let o=t.reduce((i,s)=>i+s.components,0);if(!(t.length===1&&o===1)&&o!==r.width)throw new Error(`vec${r.width}(...) needs ${r.width} components; received ${o}`);return Mr(n,r.width)}case"cast":return Mr(r.format,J(me(r.argument,e)).components);default:{let n=(r.kind==="call"?r.arguments:r.kind==="negate"?[r.argument]:[r.left,r.right]).map(i=>J(me(i,e)));if(r.kind==="call"){let[i,s,a]=n;if(r.name==="equalAll"){if(i.componentType!==s.componentType||i.components!==s.components)throw new Error("equalAll requires matching types and row widths");return"uint32"}if(r.name==="select"){if(s.componentType!==a.componentType)throw new Error("select branches require matching component types");let c=Math.max(s.components,a.components);if(n.some(u=>u.components!==1&&u.components!==c))throw new Error("select widths must match its branches or be one component");return Mr(s.componentType,c)}if(r.name==="dot"&&i.components!==s.components)throw new Error("dot requires matching row widths")}if(n.some(i=>i.componentType!=="float32"))throw new Error("Arithmetic requires float32 operands; use an explicit float32 cast");if(r.kind==="call"&&(r.name==="dot"||r.name==="length"))return"float32";let o=Math.max(...n.map(i=>i.components));if(n.some(i=>i.components!==1&&i.components!==o))throw new Error("Expression row widths must match or broadcast from one component");return Mr("float32",o)}}}var Bn=class{contracts=new Map;expressions;operations;outputs;scalars;vectors;constructor(e,t={}){this.scalars=e.scalars,this.vectors=e.vectors;let n=[],o=f=>{if(f instanceof Q&&f.type==="composite")f.operations.forEach(o);else{if(f instanceof Q){let l=m=>m instanceof Ie||m instanceof Q&&m.operations.some(l);if(f.operations.some(l))throw new Error("Expression operations inside control flow are not supported")}n.push(f)}};e.operations.forEach(o),this.operations=n;let i=new Map([...this.scalars,...this.vectors].map(f=>[f.id,f])),s=n.filter(f=>f instanceof Ie),a=new Set,c=new Map;for(let f of n)if(f instanceof Ie&&c.set(f,new Set(a)),!!nt(f))try{let l=Wa(f,this.scalars);if(!l)continue;un(e,l),this.contracts.set(f,l);for(let m of l.values){let g=Y(m.value);m.access!=="read"&&this.scalars.some(x=>x.id===g)&&a.add(g)}}catch(l){throw new Error(`${f.id}: ${l instanceof Error?l.message:String(l)}`,{cause:l})}let u=new Set;for(let f of s){if(u.has(f.output))throw new Error(`Multiple expression writers for ${f.output}`);u.add(f.output)}let d=new Set([...i.keys()].filter(f=>!u.has(f))),h=[];for(let f of n){let l=this.contracts.get(f);if(!(f instanceof Ie)){for(let m of l?.values??[]){let g=Y(m.value);if(m.access!=="write"&&!d.has(g))throw new Error(`${"id"in f?f.id:"Operation"}: Reads ${g} before it is produced`)}for(let m of l?.values??[])m.access!=="read"&&d.add(Y(m.value));continue}try{let m=i.get(f.output);if(!m||!ci(m.format))throw new Error(`Expression output ${f.output} must declare a 32-bit numeric row of width 1\u20134`);let g=ui(f.expression),x=hi(g);if(x.includes(f.output))throw new Error(`Reads ${f.output} before it is produced`);let T=new Map;for(let b of x){let p=i.get(b);if(!p||!ci(p.format))throw new Error(`Expression input ${b} must declare a 32-bit numeric row of width 1\u20134`);if(T.set(b,p.format),!d.has(b))throw new Error(`Reads ${b} before it is produced`)}if(this.scalars.some(b=>b.id===m.id)&&x.some(b=>this.vectors.some(p=>p.id===b)))throw new Error(`Vector expression cannot write scalar ${f.output}`);if(this.vectors.some(b=>b.id===f.output)&&!x.some(b=>this.vectors.some(p=>p.id===b)))throw new Error(`Vector expression ${f.output} requires a vector input to determine its shape`);let M=me(g,T);if(m.format!==M)throw new Error("Expression result type must match its output declaration");d.add(f.output);let w=x.filter(b=>c.get(f).has(b));h.push({operation:f,expression:g,format:M,formats:T,references:x,gpuScalarInputs:w})}catch(m){throw m instanceof Error?new Error(`${f.id}: ${m.message}`,{cause:m}):m}}this.expressions=h,this.outputs=[...t.outputs??s.map(f=>f.output)];for(let f of this.outputs){if(!i.has(f))throw new Error(`Undeclared output ${f}`);if(this.scalars.some(l=>l.id===f)&&!u.has(f)&&!a.has(f))throw new Error(`Selected scalar ${f} must be produced by a graph operation`)}}prepare(e,t,n={}){let o=new Map,i=new Set,s=new Set(this.expressions.map(h=>h.operation.output)),a=new Map(Object.entries(n.outputTargets??{})),c=new Set([...this.contracts.values()].flatMap(h=>h.values.filter(f=>f.access!=="read"&&this.vectors.some(l=>l.id===Y(f.value))).map(f=>Y(f.value)))),u=new Set,d=new Set;try{for(let[h,f]of Object.entries(t)){if(s.has(h))throw new Error(`Use outputTargets for expression output ${h}`);let l=this.scalars.find(g=>g.id===h),m=this.vectors.find(g=>g.id===h);if(l){if(typeof f!="number"||!Number.isFinite(f))throw new Error(`Expected numeric scalar ${h}`);if(l.format!=="float32"&&(!Number.isInteger(f)||f<(l.format==="uint32"?0:-2147483648)||f>(l.format==="uint32"?4294967295:2147483647)))throw new Error(`Scalar ${h} is outside its declared integer format`)}else if(m){if(!(f instanceof Z))throw new Error(`Expected GPUVector ${h}`);di(e,f,m.format,m.length,m.chunkLengths)}else throw new Error(`Undeclared binding ${h}`);o.set(h,f)}for(let h of this.operations){for(let w of this.contracts.get(h)?.values??[]){let b=Y(w.value);w.access!=="write"&&o.get(b)instanceof Z&&d.add(b)}if(!(h instanceof Ie)){let w=this.contracts.get(h);for(let b of w?.values??[]){let p=Y(b.value);if(b.access!=="write"&&!o.has(p)&&!u.has(p))throw new Error(`Missing ${b.access==="read-write"?"read-write":"execution"} binding ${p}`)}for(let b of w?.values??[]){let p=Y(b.value);b.access!=="read"&&this.scalars.some(y=>y.id===p)&&u.add(p)}for(let b of w?.requiredFeatures??[])if(!e.features.has(b))throw new Error(`Operation requires ${b}`);for(let b of w?.values??[]){if(b.access==="read")continue;let p=this.vectors.find(v=>v.id===Y(b.value));if(!p)continue;let y=o.get(p.id),S=a.get(p.id)??(y instanceof Z?y:void 0),P=b.shape,E=P&&"like"in P?o.get(Y(P.like)):void 0;if(P&&"like"in P&&!(E instanceof Z))throw new Error(`Missing shape input ${Y(P.like)}`);let C=E instanceof Z?E.data.map(v=>v.length):P&&"length"in P?P.chunkLengths??p.chunkLengths??[P.length]:p.chunkLengths??(p.length===void 0?void 0:[p.length]);if(b.access==="read-write"&&!(y instanceof Z))throw new Error(`Missing read-write binding ${p.id}`);if(b.access==="read-write"&&S!==y)throw new Error(`Read-write target must use its bound storage: ${p.id}`);if(d.has(p.id)&&S!==y)throw new Error(`Output target replaces an earlier read: ${p.id}`);if(!S&&!C)throw new Error(`Cannot infer length of produced vector ${p.id}`);let L=C?.reduce((v,I)=>v+I,0)??S.length;if(p.length!==void 0&&p.length!==L||P&&"length"in P&&P.length!==L)throw new Error(`Length constraint failed for ${p.id}`);if(p.chunkLengths&&C&&(p.chunkLengths.length!==C.length||p.chunkLengths.some((v,I)=>v!==C[I])))throw new Error(`Chunk constraint failed for ${p.id}`);if(S)di(e,S,p.format,L,C),Va(p.id,S,o),o.set(p.id,S);else{let v=fi(e,p.id,C,p.format);i.add(v),o.set(p.id,v)}}continue}let f=this.expressions.find(w=>w.operation===h),l=[];for(let w of f.references){let b=o.get(w);if(b===void 0&&!f.gpuScalarInputs.includes(w))throw new Error(`Missing execution binding ${w}`);b instanceof Z&&this.vectors.some(p=>p.id===w)&&l.push(b)}let m=this.vectors.find(w=>w.id===f.operation.output),g=l[0],x=m?g?.data.map(w=>w.length)??m.chunkLengths??(m.length===void 0?void 0:[m.length]):[1];if(!x)throw new Error(`Cannot infer length of ${f.operation.output}`);for(let w of l)if(w.data.length!==x.length||w.data.some((b,p)=>b.length!==x[p]))throw new Error(`Expression ${f.operation.id} requires matching vector chunk boundaries`);let T=x.reduce((w,b)=>w+b,0);if(m?.length!==void 0&&m.length!==T)throw new Error(`Length constraint failed for ${m.id}`);if(m?.chunkLengths&&(m.chunkLengths.length!==x.length||m.chunkLengths.some((w,b)=>w!==x[b])))throw new Error(`Chunk constraint failed for ${m.id}`);let M=a.get(f.operation.output);if(M)di(e,M,f.format,T,x),Va(f.operation.output,M,o),o.set(f.operation.output,M);else{let w=fi(e,f.operation.output,x,f.format);i.add(w),o.set(f.operation.output,w)}}for(let h of Object.keys(n.outputTargets??{}))if(!s.has(h)&&!c.has(h))throw new Error(`Unknown graph output target ${h}`);for(let h of this.outputs)if(!(o.get(h)instanceof Z)&&this.scalars.some(f=>f.id===h)){let f=fi(e,h,[1],this.scalars.find(l=>l.id===h).format);i.add(f),o.set(h,f)}return new li(this,o,i)}catch(h){for(let f of i)f.destroy();throw h}}};function Wa(r,e){if(r instanceof Q&&(r.type==="composite"||r instanceof ot&&!r.predicate)){let t=new Set,n=new Set;for(let o of r.operations){let i=(Wa(o,e)?.values??[]).filter(s=>e.some(a=>a.id===Y(s.value)));for(let s of i){let a=Y(s.value);s.access!=="write"&&!n.has(a)&&t.add(a)}for(let s of i)s.access!=="read"&&n.add(Y(s.value))}return{values:[...new Set([...t,...n])].map(o=>({value:o,access:t.has(o)?n.has(o)?"read-write":"read":"write"}))}}return nt(r)?r.contract:void 0}var li=class{program;values;owned;constructor(e,t,n){this.program=e,this.values=t,this.owned=n}finish(){let e=Object.create(null);for(let t of this.program.outputs){let n=this.values.get(t);if(!(n instanceof Z))throw new Error(`Output ${t} has no materialized vector`);e[t]=n}for(let t of Object.values(e))this.owned.delete(t);return this.destroy(),e}destroy(){for(let e of this.owned)e.destroy();this.owned.clear()}};function fi(r,e,t,n="float32"){let o=[];try{for(let i of t)o.push(new Gt({buffer:r.createBuffer({byteLength:Math.max(1,i)*J(n).components*4,usage:Ht.Buffer.STORAGE|Ht.Buffer.VERTEX|Ht.Buffer.COPY_SRC|Ht.Buffer.COPY_DST}),format:n,length:i,ownsBuffer:!0}));return new Z({type:"data",name:e,format:n,data:o,ownsData:!0})}catch(i){for(let s of o)s.destroy();throw i}}function di(r,e,t,n,o){if(e.format!==t||n!==void 0&&e.length!==n)throw new Error(`Incompatible vector ${e.name}`);if(o&&(o.length!==e.data.length||o.some((s,a)=>s!==e.data[a].length)))throw new Error(`Incompatible chunks for ${e.name}`);let i=D(e.format).byteLength;for(let s of e.data)if(s.buffer.device!==r||s.byteStride!==i||s.byteOffset%4!==0||s.rowByteLength!==i)throw new Error(`Expression vector ${e.name} must contain packed 32-bit numeric chunks on the execution device`)}function Va(r,e,t){let n=i=>i.buffer instanceof Ht.Buffer?i.buffer:i.buffer.buffer,o=new Map;for(let i of e.data){if(i.length===0)continue;let s=n(i),a=o.get(s)??[];a.push({start:i.byteOffset,end:i.byteOffset+i.length*i.byteStride}),o.set(s,a)}for(let i of o.values())if(i.sort((s,a)=>s.start-a.start),i.some((s,a)=>a>0&&s.start<i[a-1].end))throw new Error(`Output ${r} has overlapping writable chunks`);for(let[i,s]of t)if(i!==r&&s instanceof Z&&s.data.some(a=>o.has(n(a))))throw new Error("Expression output targets must not alias inputs or earlier outputs")}var Ya=X(V(),1);var Xt={float32:"f32",sint32:"i32",uint32:"u32"};function qa(r,e,t,n){if(e===t)return r;let o=Xt;if(t==="float32")return`${o.float32}(${r})`;if(e==="float32"){let s=n==="nearest"?`expression_round_nearest(${r})`:r;return`expression_to_${t}(${s})`}let i=t==="uint32"?`max(${r}, 0)`:`min(${r}, 2147483647u)`;return`${o[t]}(${i})`}var ja=`
|
|
205
|
+
fn expression_round_nearest(value: f32) -> f32 {
|
|
206
|
+
let magnitude = abs(value);
|
|
207
|
+
let integral = floor(magnitude);
|
|
208
|
+
let rounded = integral + select(0.0, 1.0, magnitude - integral >= 0.5);
|
|
209
|
+
return sign(value) * rounded;
|
|
210
|
+
}
|
|
211
|
+
fn expression_to_sint32(value: f32) -> i32 {
|
|
212
|
+
if (value >= 2147483648.0) { return 2147483647i; }
|
|
213
|
+
if (value <= -2147483648.0) { return -2147483647i - 1i; }
|
|
214
|
+
return i32(value);
|
|
215
|
+
}
|
|
216
|
+
fn expression_to_uint32(value: f32) -> u32 {
|
|
217
|
+
if (value >= 4294967296.0) { return 4294967295u; }
|
|
218
|
+
if (value <= 0.0) { return 0u; }
|
|
219
|
+
return u32(value);
|
|
220
|
+
}`;var mi=64,An=class{program;plan;kernel;vectorNames;scalarNames;outputIsScalar;constructor(e,t,n){this.program=t,this.plan=n,this.vectorNames=n.references.filter(h=>t.vectors.some(f=>f.id===h)),this.scalarNames=n.references.filter(h=>t.scalars.some(f=>f.id===h)),this.outputIsScalar=t.scalars.some(h=>h.id===n.operation.output);let o=this.scalarNames.length>0||this.outputIsScalar,i=h=>`metadata[${Math.floor(h/4)}][${h%4}]`,s=(h,f)=>{switch(J(me(h,n.formats)).components===1&&(f=0),h.kind){case"literal":return`f32(${Object.is(h.value,-0)?"-0.0":h.value.toExponential()})`;case"swizzle":return s(h.argument,h.components[f]);case"construct":{let l=h.arguments.flatMap(g=>Array.from({length:J(me(g,n.formats)).components},(x,T)=>({argument:g,component:T}))),m=l[l.length===1?0:f];return s(m.argument,m.component)}case"negate":return`(-${s(h.argument,f)})`;case"cast":return qa(s(h.argument,f),J(me(h.argument,n.formats)).componentType,h.format,n.operation.integerRounding);case"call":{let[l,m,g]=h.arguments;if(h.name==="select"){let x=J(me(l,n.formats)).componentType;return`select(${s(g,f)}, ${s(m,f)}, ${s(l,f)} != ${Xt[x]}(0))`}if(["dot","length","equalAll"].includes(h.name)){let x=J(me(l,n.formats)).components,T=Array.from({length:x},(w,b)=>{let p=s(l,b),y=s(h.name==="length"?l:m,b);return`(${p} ${h.name==="equalAll"?"==":"*"} ${y})`});if(h.name==="equalAll")return`select(0u, 1u, ${T.join(" && ")})`;let M=T.reduce((w,b)=>`(${w} + ${b})`,"0.0");return h.name==="length"?`sqrt(${M})`:M}return`${h.name}(${h.arguments.map(x=>s(x,f)).join(", ")})`}case"binary":return`(${s(h.left,f)} ${h.operator} ${s(h.right,f)})`;case"reference":{let l=this.vectorNames.indexOf(h.name),{components:m,componentType:g}=J(n.formats.get(h.name));return l>=0?`input${l}[${i(l+2)} + index * ${m}u + ${m===1?0:f}u]`:`bitcast<${Xt[g]}>(gpuValues[${t.scalars.findIndex(x=>x.id===h.name)}])`}}},a=this.vectorNames.map((h,f)=>({name:`input${f}`,type:"read-only-storage",group:0,location:f})),c=[...a],u=a.map((h,f)=>`@group(0) @binding(${h.location}) var<storage, read> ${h.name}: array<${Xt[J(n.formats.get(this.vectorNames[f])).componentType]}>;`);this.outputIsScalar||(u.push(`@group(0) @binding(${c.length}) var<storage, read_write> outputValues: array<${Xt[J(n.format).componentType]}>;`),c.push({name:"outputValues",type:"storage",group:0,location:c.length})),o&&(u.push(`@group(0) @binding(${c.length}) var<storage, ${this.outputIsScalar?"read_write":"read"}> gpuValues: array<u32>;`),c.push({name:"gpuValues",type:this.outputIsScalar?"storage":"read-only-storage",group:0,location:c.length})),u.push(`@group(0) @binding(${c.length}) var<uniform> metadata: array<vec4u, ${Math.ceil((this.vectorNames.length+2)/4)}>;`),c.push({name:"metadata",type:"uniform",group:0,location:c.length});let d=this.outputIsScalar?`gpuValues[${t.scalars.findIndex(h=>h.id===n.operation.output)}] = bitcast<u32>(${s(n.expression,0)});`:Array.from({length:J(n.format).components},(h,f)=>`outputValues[${i(1)} + index * ${J(n.format).components}u + ${f}u] = ${s(n.expression,f)};`).join(`
|
|
221
|
+
`);this.kernel=new k(e,{id:n.operation.id,source:`${u.join(`
|
|
222
|
+
`)}
|
|
223
|
+
${ja}
|
|
224
|
+
@compute @workgroup_size(${mi})
|
|
225
|
+
fn main(@builtin(workgroup_id) workgroup: vec3u, @builtin(num_workgroups) dimensions: vec3u, @builtin(local_invocation_index) localIndex: u32) {
|
|
226
|
+
let index = (workgroup.y * dimensions.x + workgroup.x) * ${mi}u + localIndex;
|
|
227
|
+
if (index >= ${i(0)}) { return; }
|
|
228
|
+
${d}
|
|
229
|
+
}`,shaderLayout:{bindings:c}})}lower(e){let t=this.vectorNames.map(c=>e.resolveVector(this.program.vectors.find(u=>u.id===c))),n=this.outputIsScalar?e.resolveScalar(this.program.scalars.find(c=>c.id===this.plan.operation.output)):void 0,o=this.outputIsScalar?void 0:e.resolveVector(this.program.vectors.find(c=>c.id===this.plan.operation.output)),i=n?.arena??(this.scalarNames.length?e.resolveScalar(this.program.scalars.find(c=>c.id===this.scalarNames[0])).arena:void 0),a=(o?.data??[n.view]).flatMap((c,u)=>{if(c.length===0)return[];let d=t.map(x=>x.data[u]);if(d.some(x=>!x||x.length!==c.length))throw new Error("Expression chunk mismatch");let h=Math.ceil(c.length/mi),f=e.graph.device.limits.maxComputeWorkgroupsPerDimension,l=Math.min(h,f),m=Math.ceil(h/l);if(m>f)throw new Error("Expression chunk exceeds dispatch limits");let g=[...d.map(x=>({buffer:x,usage:"storage-read"})),...o?[{buffer:c,usage:"storage-write"}]:[],...i?[{buffer:i.buffer,usage:this.outputIsScalar?"storage-read-write":"storage-read"}]:[]];return[j(q({id:`${this.plan.operation.id}-chunk-${u}`,resources:g,compile:({device:x})=>{let T=new Uint32Array(Math.ceil((this.vectorNames.length+2)/4)*4);T.set([c.length,N(c),...d.map(N)]);let M=x.createBuffer({data:T,usage:Ya.Buffer.UNIFORM});return{encode:({computePass:w,getBuffer:b})=>{let p={metadata:M};d.forEach((y,S)=>{p[`input${S}`]=K(y,b)}),o&&(p.outputValues=K(c,b)),i&&(p.gpuValues=b(i.buffer)),this.kernel.dispatch(w,{bindings:p,x:l,y:m,z:1})},destroy:()=>M.destroy()}}}),[l,m,1])]});ze(e.graph,a),e.recordDecision({operationId:this.plan.operation.id,operationType:"expression",lowering:"webgpu-expression",reason:"shape-independent expression shader with execution-time chunk dimensions"})}destroy(){this.kernel.destroy()}};var Zt=class{device;program;compiler;kernels=new Map;destroyed=!1;constructor(e,t,n={},o){if(this.device=e,e.type!=="webgpu")throw new Error("GPUGraph execution requires WebGPU");if(t.textures.length)throw new Error("Reusable expression programs do not yet support texture declarations");this.program=new Bn(t,n),this.compiler=new Pt(e,[...o??n.lowerings??[],{type:"expression",lower:(i,s)=>this.kernels.get(i).lower(s)}]);try{for(let i of this.program.expressions)this.kernels.set(i.operation,new An(e,this.program,i))}catch(i){throw this.destroy(),i}}async run(e,t={}){(0,Ha.assert)(!this.destroyed);let n=this.program.prepare(this.device,e,t),o,i=this.device.createCommandEncoder();try{let s=new Lt;for(let d of this.program.scalars)s.scalar(d.id,d.format);let a=Object.create(null),c=Object.create(null);for(let[d,h]of n.values)typeof h=="number"?c[d]=h:this.program.vectors.some(f=>f.id===d)&&(a[d]=h);for(let[d,h]of Object.entries(e))typeof h=="number"&&(c[d]=h);for(let d of this.program.vectors){let h=a[d.id];if(!h&&d.length===void 0)throw new Error(`Missing length or execution binding for ${d.id}`);s.vector(d.id,d.format,h?.length??d.length,{external:!!h,chunkLengths:h?.data.map(f=>f.length)??d.chunkLengths})}s.add(this.program.operations);let u=this.compiler.compile(s,{vectors:a,scalars:c});for(let d of this.program.scalars){let h=n.values.get(d.id);if(!(h instanceof Z))continue;let f=u.scalars.get(d.id).view,l=u.graph.importGPUVector(`${d.id}-result`,h).data[0];u.graph.addCopyPass({id:`${d.id}-result-copy`,resources:[{buffer:f,usage:"copy-source"},{buffer:l,usage:"copy-destination"}],compile:()=>({encode:({commandEncoder:m,getBuffer:g})=>m.copyBufferToBuffer({sourceBuffer:g(f),sourceOffset:f.byteOffset,destinationBuffer:g(l),destinationOffset:l.byteOffset,size:4})})})}return o=u.graph.compile(),o.encode(i,{parameters:void 0}),this.device.submit(i.finish()),n.finish()}catch(s){throw n.destroy(),s}finally{o?.destroy(),i.destroy()}}destroy(){for(let e of this.kernels.values())e.destroy();this.kernels.clear(),this.destroyed=!0}};var Lt=class{id;programOperations=[];programScalars=new Map;programVectors=new Map;programTextures=new Map;constructor(e={}){this.id=e.id??"gpu-program"}add(e){return this.assertOperationLike(e),this.addOperationLike(e),this}scalar(e,t){this.assertValueId(e);let n=new bt(e,t);return this.programScalars.set(e,n),n}vector(e,t,n,o={}){this.assertValueId(e);let i=typeof n=="number"?{length:n,...o}:n??o,s=new ve({id:e,format:t,...i});return this.programVectors.set(e,s),s}texture(e,t){this.assertValueId(e);let n=new wt({...t,id:e});return this.programTextures.set(e,n),n}textureView(e,t={}){if(this.programTextures.get(e.id)!==e)throw new Error(`Undeclared program texture "${e.id}"`);return new Le(e,t)}compile(e,t={}){return new Zt(e,this,t)}get textures(){return Object.freeze([...this.programTextures.values()])}get scalars(){return Object.freeze([...this.programScalars.values()])}get vectors(){return Object.freeze([...this.programVectors.values()])}get operations(){return Object.freeze([...this.programOperations])}get operationTree(){return Object.freeze(this.programOperations.map(Do))}assertValueId(e){if(this.programScalars.has(e)||this.programVectors.has(e)||this.programTextures.has(e))throw new Error(`${this.id} value "${e}" already exists`)}addOperationLike(e){if(Array.isArray(e)){for(let t of e)this.addOperationLike(t);return}this.programOperations.push(e)}assertOperationLike(e){if(Array.isArray(e)){for(let t of e)this.assertOperationLike(t);return}if(!e||typeof e!="object")throw new Error(`${this.id} accepts GPU operations only`)}};function pi(r,e={}){return new Q({id:e.id,operations:r})}function gi(r){let e=r.lowering.decisions.map(t=>`${t.operationId}: ${t.lowering} \u2014 ${t.reason}`);return Object.freeze({programId:r.program.id,semanticOperationCount:Xa(r.program.operationTree),loweredNodeCount:r.lowering.nodes.length,loweringDecisionCount:r.lowering.decisions.length,scalarCount:r.program.scalars.length,vectorCount:r.program.vectors.length,externalVectorCount:r.program.vectors.filter(t=>t.external).length,cpuReadbackCount:0,backend:"webgpu",decisions:Object.freeze(e)})}function Xa(r){return r.reduce((e,t)=>e+1+Xa(t.children??[]),0)}var In=class{adapter;minimumSampleCount;explorationEnabled;calibrations=new Map;constructor(e){if(!Number.isSafeInteger(e.minimumSampleCount??1)||(e.minimumSampleCount??1)<=0)throw new Error("GPUCommandGraph autotuner minimumSampleCount must be a positive safe integer");if(this.adapter=Xf(e.adapter),this.minimumSampleCount=e.minimumSampleCount??1,this.explorationEnabled=e.explorationEnabled??!0,e.profile?.adapter.key===this.adapter.key&&e.profile.version===1)for(let t of e.profile.calibrations)this.importCalibration(t)}selectKernel(e){On(e.operation,"operation"),Qa(e.workloadSize);let t=e.candidates.filter(a=>a.supported!==!1);if(t.length===0)throw new Error(`GPUCommandGraph autotuner operation "${e.operation}" has no supported variants`);for(let a of t)On(a.id,"variant");let n=Ka(e.workloadSize),o=t.map(a=>{let c=this.findNearestCalibration(e.operation,a.id,n);return{candidate:a,calibration:c,sampleCount:c?.workloadBucket===n?c.sampleCount:0,estimatedDurationMilliseconds:c?Zf(c,e.workloadSize):void 0}});if(this.explorationEnabled){let a=o.find(c=>c.sampleCount<this.minimumSampleCount);if(a)return Object.freeze({operation:e.operation,variant:a.candidate.id,workloadSize:e.workloadSize,workloadBucket:n,reason:"exploration",sampleCount:a.sampleCount,...a.estimatedDurationMilliseconds===void 0?{}:{estimatedDurationMilliseconds:a.estimatedDurationMilliseconds}})}let i=o.filter(a=>a.estimatedDurationMilliseconds!==void 0).sort((a,c)=>(a.estimatedDurationMilliseconds??Number.POSITIVE_INFINITY)-(c.estimatedDurationMilliseconds??Number.POSITIVE_INFINITY))[0],s=i??o[0];return Object.freeze({operation:e.operation,variant:s.candidate.id,workloadSize:e.workloadSize,workloadBucket:n,reason:i?"calibrated":"fallback",sampleCount:s.calibration?.sampleCount??0,...s.estimatedDurationMilliseconds===void 0?{}:{estimatedDurationMilliseconds:s.estimatedDurationMilliseconds}})}observeKernel(e){if(On(e.operation,"operation"),On(e.variant,"variant"),Qa(e.workloadSize),!Number.isFinite(e.durationMilliseconds)||e.durationMilliseconds<0)throw new Error("GPUCommandGraph autotuner durationMilliseconds must be nonnegative");let t=Ka(e.workloadSize),n=xi(e.operation,e.variant,t),o=this.calibrations.get(n)??{operation:e.operation,variant:e.variant,workloadBucket:t,sampleCount:0,meanWorkloadSize:0,meanDurationMilliseconds:0,durationSquaredDifferenceSum:0};o.sampleCount++,o.meanWorkloadSize+=(e.workloadSize-o.meanWorkloadSize)/o.sampleCount;let i=e.durationMilliseconds-o.meanDurationMilliseconds;return o.meanDurationMilliseconds+=i/o.sampleCount,o.durationSquaredDifferenceSum+=i*(e.durationMilliseconds-o.meanDurationMilliseconds),this.calibrations.set(n,o),Za(o)}observeTimingReport(e,t){let n=new Map(t.nodes.map(i=>[i.id,i])),o=0;for(let i of e.nodes){let s=n.get(i.id);i.gpuTimeMilliseconds===void 0||!s?.operation||!s.variant||(this.observeKernel({operation:s.operation,variant:s.variant,workloadSize:Math.max(s.maximumInvocationCount,1),durationMilliseconds:i.gpuTimeMilliseconds}),o++)}return o}exportProfile(){let e=[...this.calibrations.values()].sort((t,n)=>t.operation.localeCompare(n.operation)||t.variant.localeCompare(n.variant)||t.workloadBucket-n.workloadBucket).map(Za);return Object.freeze({version:1,adapter:this.adapter,calibrations:Object.freeze(e)})}reset(){this.calibrations.clear()}importCalibration(e){!e.operation||!e.variant||!Number.isSafeInteger(e.workloadBucket)||!Number.isSafeInteger(e.sampleCount)||e.sampleCount<=0||!Number.isFinite(e.meanWorkloadSize)||e.meanWorkloadSize<=0||!Number.isFinite(e.meanDurationMilliseconds)||e.meanDurationMilliseconds<0||this.calibrations.set(xi(e.operation,e.variant,e.workloadBucket),{operation:e.operation,variant:e.variant,workloadBucket:e.workloadBucket,sampleCount:e.sampleCount,meanWorkloadSize:e.meanWorkloadSize,meanDurationMilliseconds:e.meanDurationMilliseconds,durationSquaredDifferenceSum:e.sampleCount>1?e.durationStandardDeviationMilliseconds**2*(e.sampleCount-1):0})}findNearestCalibration(e,t,n){let o=this.calibrations.get(xi(e,t,n));if(o)return o;let i;for(let s of this.calibrations.values())s.operation!==e||s.variant!==t||(!i||Math.abs(s.workloadBucket-n)<Math.abs(i.workloadBucket-n))&&(i=s);return i}};function Ja(r){let e=[...r.features].sort(),t={type:r.info.type,vendor:r.info.vendor,renderer:r.info.renderer,version:r.info.version,gpu:r.info.gpu,gpuType:r.info.gpuType,...r.info.gpuArchitecture?{gpuArchitecture:r.info.gpuArchitecture}:{},...r.info.gpuBackend?{gpuBackend:r.info.gpuBackend}:{},...r.info.featureLevel?{featureLevel:r.info.featureLevel}:{},features:Object.freeze(e),...r.info.subgroupMinSize===void 0?{}:{subgroupMinSize:r.info.subgroupMinSize},...r.info.subgroupMaxSize===void 0?{}:{subgroupMaxSize:r.info.subgroupMaxSize},maxComputeInvocationsPerWorkgroup:r.limits.maxComputeInvocationsPerWorkgroup,maxComputeWorkgroupsPerDimension:r.limits.maxComputeWorkgroupsPerDimension};return Object.freeze({key:JSON.stringify(t),...t})}function Xf(r){return Object.freeze({...r,features:Object.freeze([...r.features])})}function Za(r){return Object.freeze({operation:r.operation,variant:r.variant,workloadBucket:r.workloadBucket,sampleCount:r.sampleCount,meanWorkloadSize:r.meanWorkloadSize,meanDurationMilliseconds:r.meanDurationMilliseconds,durationStandardDeviationMilliseconds:r.sampleCount>1?Math.sqrt(r.durationSquaredDifferenceSum/(r.sampleCount-1)):0})}function Zf(r,e){return r.meanDurationMilliseconds*(e/Math.max(r.meanWorkloadSize,1))}function Ka(r){return Math.floor(Math.log2(Math.max(r,1)))}function xi(r,e,t){return`${r}\0${e}\0${t}`}function On(r,e){if(!r)throw new Error(`GPUCommandGraph autotuner ${e} is required`)}function Qa(r){if(!Number.isSafeInteger(r)||r<=0)throw new Error("GPUCommandGraph autotuner workloadSize must be a positive safe integer")}var Kf={interactive:4,normal:8,background:16},Rn=class{targetStepMilliseconds;latencyPriority;minimumScale;maximumScale;responsiveness;maximumAdjustmentFactor;initialBudget;currentBudget;currentScale=1;currentSampleCount=0;constructor(e){ec(e.initialBudget);let t=e.latencyPriority??"normal",n=e.targetStepMilliseconds??Kf[t];Sr(n,"targetStepMilliseconds");let o=e.minimumScale??.125,i=e.maximumScale??4,s=e.responsiveness??.25,a=e.maximumAdjustmentFactor??2;if(Sr(o,"minimumScale"),Sr(i,"maximumScale"),Sr(a,"maximumAdjustmentFactor"),o>1||i<1)throw new Error("GPUCommandGraph budget scale range must contain the initial scale 1");if(!Number.isFinite(s)||s<=0||s>1)throw new Error("GPUCommandGraph budget responsiveness must be in the interval (0, 1]");if(a<1)throw new Error("GPUCommandGraph budget maximumAdjustmentFactor must be at least 1");this.initialBudget=rc(e.initialBudget),this.currentBudget=this.initialBudget,this.latencyPriority=t,this.targetStepMilliseconds=n,this.minimumScale=o,this.maximumScale=i,this.responsiveness=s,this.maximumAdjustmentFactor=a}get budget(){return this.currentBudget}get sampleCount(){return this.currentSampleCount}reset(){this.currentBudget=this.initialBudget,this.currentScale=1,this.currentSampleCount=0}observeStep(e,t,n=this.currentBudget){Sr(t,"durationMilliseconds"),ec(n);let o=Qf(e,n);if(o>0){let i=this.targetStepMilliseconds*Math.min(o,1)/t,a=1+(tc(i,1/this.maximumAdjustmentFactor,this.maximumAdjustmentFactor)-1)*this.responsiveness;this.currentScale=tc(this.currentScale*a,this.minimumScale,this.maximumScale),this.currentBudget=Jf(this.initialBudget,this.currentScale)}return this.currentSampleCount++,Object.freeze({sampleCount:this.currentSampleCount,durationMilliseconds:t,targetStepMilliseconds:this.targetStepMilliseconds,latencyPriority:this.latencyPriority,saturation:o,scale:this.currentScale,budget:this.currentBudget})}};function Qf(r,e){let t=[r.maximumInvocationCount/e.maximumInvocationCount];return e.maximumNodeCount!==void 0&&t.push(r.nodeCount/e.maximumNodeCount),e.maximumCommandCount!==void 0&&t.push(r.commandCount/e.maximumCommandCount),e.maximumReadByteLength!==void 0&&t.push(r.readByteLength/e.maximumReadByteLength),e.maximumWriteByteLength!==void 0&&t.push(r.writeByteLength/e.maximumWriteByteLength),Math.max(...t)}function Jf(r,e){return rc({maximumInvocationCount:Er(r.maximumInvocationCount,e),...r.maximumNodeCount===void 0?{}:{maximumNodeCount:Er(r.maximumNodeCount,e)},...r.maximumCommandCount===void 0?{}:{maximumCommandCount:Er(r.maximumCommandCount,e)},...r.maximumReadByteLength===void 0?{}:{maximumReadByteLength:Er(r.maximumReadByteLength,e)},...r.maximumWriteByteLength===void 0?{}:{maximumWriteByteLength:Er(r.maximumWriteByteLength,e)}})}function Er(r,e){return Math.max(1,Math.min(Number.MAX_SAFE_INTEGER,Math.round(r*e)))}function rc(r){return Object.freeze({...r})}function Sr(r,e){if(!Number.isFinite(r)||r<=0)throw new Error(`GPUCommandGraph budget ${e} must be positive`)}function ec(r){for(let[e,t]of[["maximumInvocationCount",r.maximumInvocationCount],["maximumNodeCount",r.maximumNodeCount],["maximumCommandCount",r.maximumCommandCount],["maximumReadByteLength",r.maximumReadByteLength],["maximumWriteByteLength",r.maximumWriteByteLength]])if(t!==void 0&&(!Number.isSafeInteger(t)||t<=0))throw new Error(`GPUCommandGraph budget ${e} must be a positive safe integer`)}function tc(r,e,t){return Math.max(e,Math.min(t,r))}var Gn=class{maxSamples;getNodeGroup;graphs=new Map;encodingGraphs=new WeakMap;constructor(e={}){let t=e.maxSamples??120;if(!Number.isSafeInteger(t)||t<=0)throw new Error("GPUCommandGraphInspector maxSamples must be a positive safe integer");this.maxSamples=t,this.getNodeGroup=e.getNodeGroup}registerGraph(e){this.graphs.set(e.id,{id:e.id,stats:ed(e.stats),capabilities:Object.freeze({...e.capabilities}),...e.preflight?{preflight:td(e.preflight)}:{},encodingCount:0,timingReadFailureCount:0,cpuSamples:[],gpuSamples:[],counters:new Map,nodes:new Map});let t=this.getGraph(e.id);for(let n of e.preflight?.nodes??[])this.getNode(t,n)}observeGraph(e){this.registerGraph(e);let t=this.getGraph(e.id),n=new WeakMap,o=!0,i=()=>o&&this.graphs.get(e.id)===t;return Object.freeze({graph:e,encode:(s,a)=>{let c=e.encode(s,a);return i()&&this.recordGraphEncoding(t,c),c},recordGPUTimings:async s=>{let a=n.get(s);if(a)return await a;if(i()&&this.encodingGraphs.get(s)===t){let c=this.recordGraphGPUTimings(e.id,t,s);return n.set(s,c),await c}},recordCounters:s=>{i()&&this.recordGraphCounters(t,s)},detach:()=>{o&&(o=!1,this.graphs.get(e.id)===t&&this.graphs.delete(e.id))}})}clear(){this.graphs.clear()}recordEncoding(e,t){let n=this.getGraph(e);this.recordGraphEncoding(n,t)}async readResource(e,t,n){let o=this.getGraph(e);if(!o.encoding?.readResource)throw new Error("No live resource readback is available.");let i=await o.encoding.readResource(t,n);if(this.graphs.get(e)!==o)throw new Error("Graph registration changed during readback.");return i}recordCounters(e,t){this.recordGraphCounters(this.getGraph(e),t)}recordGraphEncoding(e,t){e.encoding=t,this.encodingGraphs.set(t,e);let{stats:n}=t;e.encodingCount++,this.addSample(e.cpuSamples,n.cpuEncodeTimeMilliseconds);for(let o of n.nodes){let i=this.getNode(e,o);this.addSample(i.cpuSamples,o.cpuEncodeTimeMilliseconds)}}recordGraphCounters(e,t){let n=Object.entries(t);for(let[o,i]of n)if(!o||!Number.isFinite(i)||i<0)throw new Error("GPUCommandGraphInspector counters require an ID and a finite, non-negative value");for(let[o,i]of n){let s=e.counters.get(o);s||(s=[],e.counters.set(o,s)),this.addSample(s,i)}}async recordGPUTimings(e,t){let o=this.encodingGraphs.get(t)??this.getGraph(e);return await this.recordGraphGPUTimings(e,o,t)}async recordGraphGPUTimings(e,t,n){if(this.graphs.get(e)!==t)return;let o;try{o=await n.readTimings()}catch{this.graphs.get(e)===t&&t.timingReadFailureCount++;return}if(this.graphs.get(e)===t){o.gpuTimeMilliseconds!==void 0&&this.addSample(t.gpuSamples,o.gpuTimeMilliseconds);for(let i of o.nodes)if(i.gpuTimeMilliseconds!==void 0){let s=this.getNode(t,i);this.addSample(s.gpuSamples,i.gpuTimeMilliseconds)}return o}}getSnapshot(){let e=Array.from(this.graphs.values(),t=>this.getGraphSnapshot(t));return Object.freeze({graphs:Object.freeze(e)})}getGraph(e){let t=this.graphs.get(e);if(!t)throw new Error(`GPUCommandGraphInspector graph "${e}" is not registered`);return t}getNode(e,t){let n=e.nodes.get(t.id);if(n)return t.description!==void 0&&(n.description=t.description),t.resources!==void 0&&(n.resources=yi(t.resources)),n;let o=yi(t.resources),i=this.getNodeGroup?.({graphId:e.id,id:t.id,type:t.type,description:t.description,resources:o}),s={id:t.id,resources:o,...t.description===void 0?{}:{description:t.description},type:t.type,...i===void 0?{}:{group:i},cpuSamples:[],gpuSamples:[]};return e.nodes.set(s.id,s),s}addSample(e,t){e.push(t),e.length>this.maxSamples&&e.splice(0,e.length-this.maxSamples)}getGraphSnapshot(e){let t=[],n=new Set;for(let s of e.stats.nodeOrder){let a=e.nodes.get(s);a&&(t.push(a),n.add(s))}for(let s of e.nodes.values())n.has(s.id)||t.push(s);let o=t.map(s=>Object.freeze({id:s.id,resources:s.resources,...s.description===void 0?{}:{description:s.description},type:s.type,...s.group===void 0?{}:{group:s.group},cpu:Dn(s.cpuSamples),gpu:Dn(s.gpuSamples)})),i=Array.from(e.counters,([s,a])=>rd(s,a));return Object.freeze({id:e.id,stats:e.stats,capabilities:e.capabilities,...e.preflight?{preflight:e.preflight}:{},encodingCount:e.encodingCount,timingReadFailureCount:e.timingReadFailureCount,totals:Object.freeze({cpu:Dn(e.cpuSamples),gpu:Dn(e.gpuSamples)}),counters:Object.freeze(i),nodes:Object.freeze(o)})}};function ed(r){return Object.freeze({...r,nodeOrder:Object.freeze([...r.nodeOrder])})}function td(r){return Object.freeze({...r,nodes:Object.freeze(r.nodes.map(e=>Object.freeze({...e,resources:yi(e.resources)})))})}function Dn(r){if(r.length===0)return Object.freeze({sampleCount:0});let e=[...r].sort((t,n)=>t-n);return Object.freeze({sampleCount:r.length,latestMilliseconds:r[r.length-1],p50Milliseconds:Nn(e,.5),p95Milliseconds:Nn(e,.95)})}function rd(r,e){let t=[...e].sort((n,o)=>n-o);return Object.freeze({id:r,sampleCount:e.length,latestValue:e[e.length-1],p50Value:Nn(t,.5),p95Value:Nn(t,.95)})}function Nn(r,e){return r[Math.ceil(e*r.length)-1]}function yi(r){return r&&Object.freeze(r.map(e=>Object.freeze({...e})))}function nc(r){return{type:r.type,shaderLanguage:r.info.shadingLanguage,shaderLanguageVersion:r.info.shadingLanguageVersion,gpu:r.info.gpu,limits:r.limits,features:r.features}}var qe=X(V(),1),_n=class r{static async createAsync(e,t){let n=!qe.PipelineFactory.getAsyncCompilation(e),o=n?qe.PipelineFactory.beginAsyncCompilation(e):qe.PipelineFactory.getAsyncCompilation(e),i;try{i=new r(e,t)}finally{n&&qe.PipelineFactory.endAsyncCompilation(e,o)}try{return n?await Promise.all(o):await i._pipelineInitialization,i}catch(s){throw i.destroy(),s}}device;id;vertexSource;fragmentSource;pipelineFactory;shaderFactory;vertexShader;fragmentShader;pipeline;_pipelineInitialization;_destroyed=!1;drawDefaults;constructor(e,t){if(e.type!=="webgpu"&&e.type!=="webgl")throw new Error("RenderKernel requires WebGL or WebGPU");if(e.type==="webgl"&&!t.fragmentSource)throw new Error("WebGL RenderKernel requires a fragment shader");let{vertexSource:n,fragmentSource:o,pipelineFactory:i,shaderFactory:s,debugShaders:a,...c}=t;this.device=e,this.drawDefaults={parameters:t.parameters??{},topology:t.topology??"triangle-list"},this.id=t.id??"render-kernel",this.vertexSource=n,this.fragmentSource=o,this.pipelineFactory=i??qe.PipelineFactory.getDefaultPipelineFactory(e),this.shaderFactory=s??qe.ShaderFactory.getDefaultShaderFactory(e),this.vertexShader=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.vertexSource,debugShaders:a}),this.fragmentShader=this.fragmentSource?this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.fragmentSource,debugShaders:a}):null;let u={...c,vs:this.vertexShader,fs:this.fragmentShader},d=qe.PipelineFactory.getAsyncCompilation(e);if(d){let h=this.pipelineFactory.createRenderPipelineAsync(u);this._pipelineInitialization=h,d.push(h.then(f=>(this.pipeline=f,f)))}else this.pipeline=this.pipelineFactory.createRenderPipeline(u)}draw(e,t){let{bindings:n={},vertexArray:o,...i}=t;return this._setPipeline(e,n,o),e.draw(this.device.type==="webgl"?{...this.drawDefaults,...i,isInstanced:i.isInstanced??i.instanceCount!==void 0}:i)}drawIndirect(e,t){if(this.device.type!=="webgpu")throw new Error("Indirect drawing is only supported in WebGPU");let{bindings:n={},vertexArray:o,indirectBuffer:i,indirectOffset:s=0}=t;this._setPipeline(e,n,o),e.drawIndirect(i,s)}drawIndexedIndirect(e,t){if(this.device.type!=="webgpu")throw new Error("Indirect drawing is only supported in WebGPU");let{bindings:n={},vertexArray:o,indirectBuffer:i,indirectOffset:s=0}=t;this._setPipeline(e,n,o),e.drawIndexedIndirect(i,s)}destroy(){this._destroyed||(this.pipeline&&this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.vertexShader),this.fragmentShader&&this.shaderFactory.release(this.fragmentShader),this._destroyed=!0)}_setPipeline(e,t,n){e.setPipeline(this.pipeline),e.setBindings(t),e.setVertexArray(n)}};return hc(Pr);})();
|
|
204
230
|
return __exports__;
|
|
205
231
|
});
|