@luma.gl/graph 10.0.0-beta.2 → 10.0.0-beta.4
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/dist/arrow/gpu/arrow-gpu-analytics-adapters.cjs +22 -9
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.d.ts +11 -2
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.js +27 -10
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.cjs +24 -13
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.d.ts +9 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.js +41 -14
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.cjs +82 -23
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts +16 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js +98 -24
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.cjs +7 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts +2 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.js +14 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.js.map +1 -1
- package/dist/arrow/index.cjs +2 -0
- package/dist/arrow/index.cjs.map +3 -3
- package/dist/arrow/index.d.ts +1 -1
- package/dist/arrow/index.d.ts.map +1 -1
- package/dist/arrow/index.js +1 -1
- package/dist/arrow/index.js.map +1 -1
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.cjs +1 -2
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.js +2 -2
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.js.map +1 -1
- package/dist/dist.dev.js +62 -27
- package/dist/dist.min.js +48 -47
- package/dist/gpu-core/gpu-bvh-bounds.cjs +63 -0
- package/dist/gpu-core/gpu-bvh-bounds.d.ts +32 -0
- package/dist/gpu-core/gpu-bvh-bounds.d.ts.map +1 -0
- package/dist/gpu-core/gpu-bvh-bounds.js +56 -0
- package/dist/gpu-core/gpu-bvh-bounds.js.map +1 -0
- package/dist/gpu-core/gpu-command-graph-budget-controller.cjs +10 -2
- package/dist/gpu-core/gpu-command-graph-budget-controller.d.ts +4 -0
- package/dist/gpu-core/gpu-command-graph-budget-controller.d.ts.map +1 -1
- package/dist/gpu-core/gpu-command-graph-budget-controller.js +10 -2
- package/dist/gpu-core/gpu-command-graph-budget-controller.js.map +1 -1
- package/dist/gpu-core/gpu-command-graph-submission-pacer.cjs +92 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.d.ts +41 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.d.ts.map +1 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.js +85 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.js.map +1 -0
- package/dist/gpu-core/gpu-group-aggregation.cjs +45 -21
- package/dist/gpu-core/gpu-group-aggregation.d.ts +4 -0
- package/dist/gpu-core/gpu-group-aggregation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-group-aggregation.js +58 -24
- package/dist/gpu-core/gpu-group-aggregation.js.map +1 -1
- package/dist/gpu-core/index.cjs +6 -0
- package/dist/gpu-core/index.cjs.map +3 -3
- package/dist/gpu-core/index.d.ts +4 -0
- package/dist/gpu-core/index.d.ts.map +1 -1
- package/dist/gpu-core/index.js +2 -0
- package/dist/gpu-core/index.js.map +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.cjs +6 -6
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.js +6 -6
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.js.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame-query.cjs +55 -14
- package/dist/gpu-dataframe/gpu-data-frame-query.d.ts +13 -2
- package/dist/gpu-dataframe/gpu-data-frame-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame-query.js +58 -17
- package/dist/gpu-dataframe/gpu-data-frame-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame.cjs +1 -3
- package/dist/gpu-dataframe/gpu-data-frame.d.ts +10 -0
- package/dist/gpu-dataframe/gpu-data-frame.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame.js +1 -3
- package/dist/gpu-dataframe/gpu-data-frame.js.map +1 -1
- package/dist/gpu-dataframe/gpu-expression-shader.cjs +94 -44
- package/dist/gpu-dataframe/gpu-expression-shader.d.ts +8 -5
- package/dist/gpu-dataframe/gpu-expression-shader.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression-shader.js +110 -47
- package/dist/gpu-dataframe/gpu-expression-shader.js.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.cjs +14 -8
- package/dist/gpu-dataframe/gpu-expression.d.ts +12 -1
- package/dist/gpu-dataframe/gpu-expression.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.js +11 -6
- package/dist/gpu-dataframe/gpu-expression.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.cjs +8 -4
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.d.ts +2 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js +10 -4
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.cjs +2 -2
- package/dist/gpu-dataframe/gpu-global-aggregation-query.d.ts +5 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.js +6 -2
- package/dist/gpu-dataframe/gpu-global-aggregation-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.cjs +156 -124
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts +12 -2
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js +160 -128
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.cjs +366 -53
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts +26 -4
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js +378 -47
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.cjs +20 -9
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts +15 -2
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.js +22 -8
- package/dist/gpu-dataframe/gpu-group-by-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.cjs +61 -8
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts +10 -2
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.js +60 -7
- package/dist/gpu-dataframe/gpu-join-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.cjs +61 -11
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts +5 -1
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.js +61 -10
- package/dist/gpu-dataframe/gpu-query-compiler.js.map +1 -1
- package/dist/gpu-dataframe/index.cjs +4 -2
- package/dist/gpu-dataframe/index.cjs.map +3 -3
- package/dist/gpu-dataframe/index.d.ts +1 -1
- package/dist/gpu-dataframe/index.d.ts.map +1 -1
- package/dist/gpu-dataframe/index.js +1 -1
- package/dist/gpu-dataframe/index.js.map +1 -1
- package/dist/gpu-graph/index.cjs.map +1 -1
- package/dist/gpu-graph-algorithms/benchmarks.cjs.map +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.cjs +182 -62
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.d.ts +29 -2
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.d.ts.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.js +200 -64
- 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.cjs +135 -9
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.d.ts +55 -8
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.d.ts.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.js +145 -14
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.js.map +1 -1
- package/dist/gpu-graph-algorithms/index.cjs.map +3 -3
- package/dist/gpu-physics/articulation-tree-shader.cjs +177 -0
- package/dist/gpu-physics/articulation-tree-shader.d.ts +3 -0
- package/dist/gpu-physics/articulation-tree-shader.d.ts.map +1 -0
- package/dist/gpu-physics/articulation-tree-shader.js +159 -0
- package/dist/gpu-physics/articulation-tree-shader.js.map +1 -0
- package/dist/gpu-physics/gpu-articulation-tree.cjs +203 -0
- package/dist/gpu-physics/gpu-articulation-tree.d.ts +81 -0
- package/dist/gpu-physics/gpu-articulation-tree.d.ts.map +1 -0
- package/dist/gpu-physics/gpu-articulation-tree.js +205 -0
- package/dist/gpu-physics/gpu-articulation-tree.js.map +1 -0
- package/dist/gpu-physics/gpu-physics-batch.cjs +11 -10
- package/dist/gpu-physics/gpu-physics-batch.d.ts +1 -0
- package/dist/gpu-physics/gpu-physics-batch.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-physics-batch.js +14 -10
- package/dist/gpu-physics/gpu-physics-batch.js.map +1 -1
- package/dist/gpu-physics/gpu-physics-ensemble.cjs +9 -4
- package/dist/gpu-physics/gpu-physics-ensemble.d.ts +10 -1
- package/dist/gpu-physics/gpu-physics-ensemble.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-physics-ensemble.js +11 -4
- package/dist/gpu-physics/gpu-physics-ensemble.js.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.cjs +323 -68
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts +59 -2
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.js +400 -75
- package/dist/gpu-physics/gpu-rigid-body-world.js.map +1 -1
- package/dist/gpu-physics/index.cjs +3 -0
- package/dist/gpu-physics/index.cjs.map +3 -3
- package/dist/gpu-physics/index.d.ts +3 -1
- package/dist/gpu-physics/index.d.ts.map +1 -1
- package/dist/gpu-physics/index.js +1 -0
- package/dist/gpu-physics/index.js.map +1 -1
- package/dist/gpu-physics/rigid-body-cache-shaders.cjs +10 -6
- package/dist/gpu-physics/rigid-body-cache-shaders.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-cache-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-cache-shaders.js +15 -6
- package/dist/gpu-physics/rigid-body-cache-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-capacity.cjs +15 -2
- package/dist/gpu-physics/rigid-body-capacity.d.ts +3 -1
- package/dist/gpu-physics/rigid-body-capacity.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-capacity.js +21 -2
- package/dist/gpu-physics/rigid-body-capacity.js.map +1 -1
- package/dist/gpu-physics/rigid-body-cast-index.cjs +192 -0
- package/dist/gpu-physics/rigid-body-cast-index.d.ts +44 -0
- package/dist/gpu-physics/rigid-body-cast-index.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-cast-index.js +194 -0
- package/dist/gpu-physics/rigid-body-cast-index.js.map +1 -0
- package/dist/gpu-physics/rigid-body-ensemble-layout.cjs +4 -2
- package/dist/gpu-physics/rigid-body-ensemble-layout.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-ensemble-layout.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-layout.js +5 -2
- package/dist/gpu-physics/rigid-body-ensemble-layout.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.cjs +11 -9
- package/dist/gpu-physics/rigid-body-ensemble-reset.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.js +13 -9
- package/dist/gpu-physics/rigid-body-ensemble-reset.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-shaders.cjs +14 -7
- package/dist/gpu-physics/rigid-body-ensemble-shaders.d.ts +5 -0
- package/dist/gpu-physics/rigid-body-ensemble-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-shaders.js +17 -7
- package/dist/gpu-physics/rigid-body-ensemble-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.cjs +21 -11
- package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts +2 -2
- package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.js +28 -12
- package/dist/gpu-physics/rigid-body-ensemble-transaction.js.map +1 -1
- package/dist/gpu-physics/rigid-body-event-compaction.cjs +184 -0
- package/dist/gpu-physics/rigid-body-event-compaction.d.ts +35 -0
- package/dist/gpu-physics/rigid-body-event-compaction.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-event-compaction.js +168 -0
- package/dist/gpu-physics/rigid-body-event-compaction.js.map +1 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.cjs +51 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.d.ts +33 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.js +34 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.js.map +1 -0
- package/dist/gpu-physics/rigid-body-events.cjs +57 -25
- package/dist/gpu-physics/rigid-body-events.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-events.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-events.js +60 -25
- package/dist/gpu-physics/rigid-body-events.js.map +1 -1
- package/dist/gpu-physics/rigid-body-joints.cjs +8 -3
- package/dist/gpu-physics/rigid-body-joints.d.ts +2 -0
- package/dist/gpu-physics/rigid-body-joints.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-joints.js +10 -6
- package/dist/gpu-physics/rigid-body-joints.js.map +1 -1
- package/dist/gpu-physics/rigid-body-queries.cjs +159 -16
- package/dist/gpu-physics/rigid-body-queries.d.ts +24 -1
- package/dist/gpu-physics/rigid-body-queries.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-queries.js +166 -14
- package/dist/gpu-physics/rigid-body-queries.js.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.cjs +3 -3
- package/dist/gpu-physics/rigid-body-shaders.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.js +3 -3
- package/dist/gpu-physics/rigid-body-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-triggers.cjs +53 -15
- package/dist/gpu-physics/rigid-body-triggers.d.ts +1 -0
- package/dist/gpu-physics/rigid-body-triggers.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-triggers.js +55 -15
- package/dist/gpu-physics/rigid-body-triggers.js.map +1 -1
- package/dist/gpu-physics/sphere-world-shaders.cjs +48 -20
- package/dist/gpu-physics/sphere-world-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/sphere-world-shaders.js +51 -21
- package/dist/gpu-physics/sphere-world-shaders.js.map +1 -1
- package/dist/gpu-project/benchmarks.cjs.map +2 -2
- package/dist/gpu-project/crs.cjs.map +2 -2
- package/dist/gpu-project/graph.cjs.map +2 -2
- package/dist/gpu-project/index.cjs.map +2 -2
- package/dist/gpu-project/projection-program.cjs +2 -9
- package/dist/gpu-project/projection-program.d.ts.map +1 -1
- package/dist/gpu-project/projection-program.js +1 -8
- package/dist/gpu-project/projection-program.js.map +1 -1
- package/dist/gpu-simple-graph/index.cjs.map +2 -2
- package/dist/gpu-sql/gpu-sql.cjs +345 -81
- package/dist/gpu-sql/gpu-sql.d.ts +42 -2
- package/dist/gpu-sql/gpu-sql.d.ts.map +1 -1
- package/dist/gpu-sql/gpu-sql.js +393 -90
- package/dist/gpu-sql/gpu-sql.js.map +1 -1
- package/dist/gpu-sql/index.cjs.map +3 -3
- package/dist/gpu-sql/index.d.ts +1 -1
- package/dist/gpu-sql/index.d.ts.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/utils/float32.cjs +35 -0
- package/dist/utils/float32.d.ts +3 -0
- package/dist/utils/float32.d.ts.map +1 -0
- package/dist/utils/float32.js +16 -0
- package/dist/utils/float32.js.map +1 -0
- package/package.json +8 -8
- package/src/arrow/gpu/arrow-gpu-analytics-adapters.ts +77 -25
- package/src/arrow/gpu/arrow-gpu-analytics-readback.ts +52 -16
- package/src/arrow/gpu/arrow-gpu-table-conversion.ts +130 -31
- package/src/arrow/gpu/arrow-gpu-vector-conversion.ts +19 -0
- package/src/arrow/index.ts +1 -0
- package/src/arrow/vectors/arrow-temporal-gpu-vector.ts +2 -2
- package/src/gpu-core/gpu-bvh-bounds.ts +84 -0
- package/src/gpu-core/gpu-command-graph-budget-controller.ts +22 -2
- package/src/gpu-core/gpu-command-graph-submission-pacer.ts +102 -0
- package/src/gpu-core/gpu-group-aggregation.ts +68 -30
- package/src/gpu-core/index.ts +5 -0
- package/src/gpu-dataframe/gpu-analytics-compiler-utils.ts +7 -10
- package/src/gpu-dataframe/gpu-data-frame-query.ts +106 -25
- package/src/gpu-dataframe/gpu-data-frame.ts +35 -2
- package/src/gpu-dataframe/gpu-expression-shader.ts +172 -58
- package/src/gpu-dataframe/gpu-expression.ts +62 -9
- package/src/gpu-dataframe/gpu-global-aggregation-compiler.ts +15 -4
- package/src/gpu-dataframe/gpu-global-aggregation-query.ts +12 -3
- package/src/gpu-dataframe/gpu-global-sort-compiler.ts +231 -156
- package/src/gpu-dataframe/gpu-group-aggregation-compiler.ts +645 -61
- package/src/gpu-dataframe/gpu-group-by-query.ts +51 -14
- package/src/gpu-dataframe/gpu-join-compiler.ts +87 -6
- package/src/gpu-dataframe/gpu-query-compiler.ts +100 -18
- package/src/gpu-dataframe/index.ts +1 -1
- package/src/gpu-graph-algorithms/README.md +4 -2
- package/src/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.ts +248 -66
- package/src/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.ts +218 -20
- package/src/gpu-physics/articulation-tree-shader.ts +169 -0
- package/src/gpu-physics/gpu-articulation-tree.ts +279 -0
- package/src/gpu-physics/gpu-physics-batch.ts +19 -13
- package/src/gpu-physics/gpu-physics-ensemble.ts +20 -4
- package/src/gpu-physics/gpu-rigid-body-world.ts +510 -93
- package/src/gpu-physics/index.ts +16 -0
- package/src/gpu-physics/rigid-body-cache-shaders.ts +18 -6
- package/src/gpu-physics/rigid-body-capacity.ts +25 -4
- package/src/gpu-physics/rigid-body-cast-index.ts +277 -0
- package/src/gpu-physics/rigid-body-ensemble-layout.ts +6 -2
- package/src/gpu-physics/rigid-body-ensemble-reset.ts +21 -9
- package/src/gpu-physics/rigid-body-ensemble-shaders.ts +18 -7
- package/src/gpu-physics/rigid-body-ensemble-transaction.ts +31 -13
- package/src/gpu-physics/rigid-body-event-compaction.ts +252 -0
- package/src/gpu-physics/rigid-body-event-snapshot.ts +76 -0
- package/src/gpu-physics/rigid-body-events.ts +63 -25
- package/src/gpu-physics/rigid-body-joints.ts +11 -11
- package/src/gpu-physics/rigid-body-queries.ts +202 -14
- package/src/gpu-physics/rigid-body-shaders.ts +4 -3
- package/src/gpu-physics/rigid-body-triggers.ts +64 -20
- package/src/gpu-physics/sphere-world-shaders.ts +53 -21
- package/src/gpu-project/projection-program.ts +1 -9
- package/src/gpu-sql/gpu-sql.ts +629 -124
- package/src/gpu-sql/index.ts +1 -1
- package/src/utils/float32.ts +16 -0
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuDF.
|
|
5
5
|
|
|
6
|
+
import type {GPUExpressionNumericValue} from './gpu-expression';
|
|
7
|
+
import {
|
|
8
|
+
getGPUVectorWGSLLayout,
|
|
9
|
+
type GPUVectorWGSLFormat as GPUExpressionNumericFormat
|
|
10
|
+
} from '@luma.gl/graph/gpu-data';
|
|
6
11
|
import type {GPUTypeMap} from '@luma.gl/graph/gpu-tables';
|
|
7
12
|
import type {GPUCommandGraph} from '@luma.gl/graph/gpu-core';
|
|
8
13
|
import type {GPUDataFrame} from './gpu-data-frame';
|
|
9
14
|
import {
|
|
10
15
|
getGPUExpressionColumnNames,
|
|
11
|
-
getGPUExpressionResultFormats,
|
|
12
16
|
GPUExpression,
|
|
13
17
|
isBooleanExpressionNode,
|
|
14
18
|
isGPUScalarFunction,
|
|
@@ -43,14 +47,14 @@ import {
|
|
|
43
47
|
} from './gpu-sort-query';
|
|
44
48
|
|
|
45
49
|
/** Portable scalar storage formats supported by computed dataframe columns. */
|
|
46
|
-
export type GPUDataFrameDerivedColumnFormat =
|
|
50
|
+
export type GPUDataFrameDerivedColumnFormat = GPUExpressionNumericFormat;
|
|
47
51
|
|
|
48
52
|
/** Immutable numerical expression materialized only when its dataframe query is compiled. */
|
|
49
53
|
export type GPUDataFrameDerivedColumn = Readonly<{
|
|
50
54
|
/** Logical dataframe field name, distinct from every existing source and derived field. */
|
|
51
55
|
name: string;
|
|
52
56
|
/** Numeric expression referencing currently available source or derived columns. */
|
|
53
|
-
expression: GPUExpression<
|
|
57
|
+
expression: GPUExpression<GPUExpressionNumericValue | boolean, string>;
|
|
54
58
|
/** Optional explicit scalar format, which must agree with the referenced input format. */
|
|
55
59
|
format?: GPUDataFrameDerivedColumnFormat;
|
|
56
60
|
}>;
|
|
@@ -96,7 +100,10 @@ export class GPUDataFrameQuery<
|
|
|
96
100
|
selectedColumns: readonly SelectedColumns[],
|
|
97
101
|
derivedColumns: readonly GPUDataFrameDerivedColumn[] = []
|
|
98
102
|
) {
|
|
99
|
-
const logicalColumns =
|
|
103
|
+
const {logicalColumns, resolvedColumns} = resolveDataFrameDerivedColumns(
|
|
104
|
+
source,
|
|
105
|
+
derivedColumns
|
|
106
|
+
);
|
|
100
107
|
assertSelectedQueryColumns(selectedColumns, logicalColumns);
|
|
101
108
|
for (const predicate of predicates) {
|
|
102
109
|
assertDataFrameQueryPredicate(source, predicate, logicalColumns, logicalColumns);
|
|
@@ -105,7 +112,7 @@ export class GPUDataFrameQuery<
|
|
|
105
112
|
this.source = source;
|
|
106
113
|
this.predicates = Object.freeze([...predicates]);
|
|
107
114
|
this.selectedColumns = Object.freeze([...selectedColumns]);
|
|
108
|
-
this.derivedColumns = Object.freeze(
|
|
115
|
+
this.derivedColumns = Object.freeze(resolvedColumns);
|
|
109
116
|
Object.freeze(this);
|
|
110
117
|
}
|
|
111
118
|
|
|
@@ -145,6 +152,17 @@ export class GPUDataFrameQuery<
|
|
|
145
152
|
}
|
|
146
153
|
|
|
147
154
|
/** Adds one selected derived column without allocating GPU storage or retaining source leases. */
|
|
155
|
+
withColumn<
|
|
156
|
+
Name extends string,
|
|
157
|
+
ReferencedColumns extends SelectedColumns,
|
|
158
|
+
Format extends GPUDataFrameDerivedColumnFormat
|
|
159
|
+
>(
|
|
160
|
+
name: Name,
|
|
161
|
+
expression: GPUExpression<GPUExpressionNumericValue, ReferencedColumns> & {
|
|
162
|
+
readonly node: {readonly kind: 'cast'; readonly format: Format};
|
|
163
|
+
},
|
|
164
|
+
options?: GPUDataFrameDerivedColumnOptions<Format>
|
|
165
|
+
): GPUDataFrameQuery<Logical & Record<Name, Format>, SelectedColumns | Name, Source>;
|
|
148
166
|
withColumn<
|
|
149
167
|
Name extends string,
|
|
150
168
|
ReferencedColumns extends SelectedColumns,
|
|
@@ -155,6 +173,23 @@ export class GPUDataFrameQuery<
|
|
|
155
173
|
>(
|
|
156
174
|
name: Name,
|
|
157
175
|
expression: GPUExpression<number | null, ReferencedColumns>,
|
|
176
|
+
options?: GPUDataFrameDerivedColumnOptions<Format>
|
|
177
|
+
): GPUDataFrameQuery<Logical & Record<Name, Format>, SelectedColumns | Name, Source>;
|
|
178
|
+
withColumn<Name extends string, Format extends GPUDataFrameDerivedColumnFormat>(
|
|
179
|
+
name: Name,
|
|
180
|
+
expression: GPUExpression<GPUExpressionNumericValue | boolean, string>,
|
|
181
|
+
options: GPUDataFrameDerivedColumnOptions<Format> & {format: Format}
|
|
182
|
+
): GPUDataFrameQuery<Logical & Record<Name, Format>, SelectedColumns | Name, Source>;
|
|
183
|
+
withColumn<
|
|
184
|
+
Name extends string,
|
|
185
|
+
ReferencedColumns extends SelectedColumns,
|
|
186
|
+
Format extends GPUDataFrameDerivedColumnFormat = GPUDataFrameDerivedColumnFormatForExpression<
|
|
187
|
+
Logical,
|
|
188
|
+
ReferencedColumns
|
|
189
|
+
>
|
|
190
|
+
>(
|
|
191
|
+
name: Name,
|
|
192
|
+
expression: GPUExpression<GPUExpressionNumericValue | boolean, string>,
|
|
158
193
|
options: GPUDataFrameDerivedColumnOptions<Format> = {}
|
|
159
194
|
): GPUDataFrameQuery<Logical & Record<Name, Format>, SelectedColumns | Name, Source> {
|
|
160
195
|
assertDataFrameDerivedColumnName(name);
|
|
@@ -320,10 +355,11 @@ export function assertDataFrameQueryPredicate<T extends GPUTypeMap>(
|
|
|
320
355
|
}
|
|
321
356
|
|
|
322
357
|
/** Validates computed definitions in dependency order and returns all available logical fields. */
|
|
323
|
-
function
|
|
358
|
+
function resolveDataFrameDerivedColumns<T extends GPUTypeMap>(
|
|
324
359
|
source: GPUDataFrame<T>,
|
|
325
360
|
derivedColumns: readonly GPUDataFrameDerivedColumn[]
|
|
326
|
-
)
|
|
361
|
+
) {
|
|
362
|
+
const resolvedColumns: GPUDataFrameDerivedColumn[] = [];
|
|
327
363
|
const logicalColumns = [...source.columnNames];
|
|
328
364
|
const logicalFormats = new Map<string, string | undefined>(
|
|
329
365
|
source.schema.fields.map(
|
|
@@ -338,35 +374,23 @@ function assertDataFrameDerivedColumns<T extends GPUTypeMap>(
|
|
|
338
374
|
}
|
|
339
375
|
assertDataFrameDerivedExpression(derivedColumn.expression, logicalColumns);
|
|
340
376
|
|
|
341
|
-
const
|
|
342
|
-
derivedColumn.expression.node,
|
|
343
|
-
logicalFormats
|
|
344
|
-
);
|
|
345
|
-
if (referencedFormats.size > 1) {
|
|
346
|
-
throw new Error(`GPUDataFrame derived column "${derivedColumn.name}" mixes scalar formats`);
|
|
347
|
-
}
|
|
348
|
-
const inferredFormat = referencedFormats.values().next().value ?? 'float32';
|
|
349
|
-
if (
|
|
350
|
-
inferredFormat !== 'float32' &&
|
|
351
|
-
inferredFormat !== 'sint32' &&
|
|
352
|
-
inferredFormat !== 'uint32'
|
|
353
|
-
) {
|
|
354
|
-
throw new Error(`GPUDataFrame derived column "${derivedColumn.name}" requires scalar inputs`);
|
|
355
|
-
}
|
|
377
|
+
const inferredFormat =
|
|
378
|
+
inferNumericFormat(derivedColumn.expression.node, logicalFormats) ?? 'float32';
|
|
356
379
|
if (derivedColumn.format !== undefined && derivedColumn.format !== inferredFormat) {
|
|
357
380
|
throw new Error(`GPUDataFrame derived column "${derivedColumn.name}" format does not match`);
|
|
358
381
|
}
|
|
359
382
|
|
|
383
|
+
resolvedColumns.push(Object.freeze({...derivedColumn, format: inferredFormat}));
|
|
360
384
|
logicalFormats.set(derivedColumn.name, inferredFormat);
|
|
361
385
|
logicalColumns.push(derivedColumn.name);
|
|
362
386
|
}
|
|
363
387
|
|
|
364
|
-
return logicalColumns;
|
|
388
|
+
return {logicalColumns, resolvedColumns};
|
|
365
389
|
}
|
|
366
390
|
|
|
367
391
|
/** Validates one numerical derived expression against its currently selected logical inputs. */
|
|
368
392
|
function assertDataFrameDerivedExpression(
|
|
369
|
-
expression: GPUExpression<
|
|
393
|
+
expression: GPUExpression<GPUExpressionNumericValue | boolean, string>,
|
|
370
394
|
selectedColumns: readonly string[]
|
|
371
395
|
): void {
|
|
372
396
|
if (!(expression instanceof GPUExpression) || !isNumericExpressionNode(expression.node)) {
|
|
@@ -431,7 +455,9 @@ function isNumericExpressionNode(node: GPUExpressionNode): boolean {
|
|
|
431
455
|
isNumericExpressionNode(node.otherwise)
|
|
432
456
|
);
|
|
433
457
|
case 'cast':
|
|
434
|
-
return
|
|
458
|
+
return isNumericExpressionNode(node.operand);
|
|
459
|
+
case 'vector':
|
|
460
|
+
return node.components.every(isNumericExpressionNode);
|
|
435
461
|
case 'column':
|
|
436
462
|
return true;
|
|
437
463
|
case 'literal':
|
|
@@ -452,3 +478,58 @@ function isNumericExpressionNode(node: GPUExpressionNode): boolean {
|
|
|
452
478
|
return false;
|
|
453
479
|
}
|
|
454
480
|
}
|
|
481
|
+
|
|
482
|
+
/** Checks numeric shape and explicit casts before any GPU resources are allocated. */
|
|
483
|
+
function inferNumericFormat(
|
|
484
|
+
node: GPUExpressionNode,
|
|
485
|
+
formats: ReadonlyMap<string, string | undefined>
|
|
486
|
+
): GPUExpressionNumericFormat | undefined {
|
|
487
|
+
switch (node.kind) {
|
|
488
|
+
case 'vector': {
|
|
489
|
+
const layout = getGPUVectorWGSLLayout(node.format);
|
|
490
|
+
if (layout.components === 1 || node.components.length !== layout.components)
|
|
491
|
+
throw new Error('Vector width must match its format');
|
|
492
|
+
for (const component of node.components) {
|
|
493
|
+
if (
|
|
494
|
+
getGPUVectorWGSLLayout(inferNumericFormat(component, formats) ?? 'float32').components !==
|
|
495
|
+
1
|
|
496
|
+
)
|
|
497
|
+
throw new Error('Vector components must be scalar');
|
|
498
|
+
}
|
|
499
|
+
return node.format;
|
|
500
|
+
}
|
|
501
|
+
case 'cast': {
|
|
502
|
+
const source = inferNumericFormat(node.operand, formats) ?? 'float32';
|
|
503
|
+
if (
|
|
504
|
+
getGPUVectorWGSLLayout(source).components !== getGPUVectorWGSLLayout(node.format).components
|
|
505
|
+
)
|
|
506
|
+
throw new Error('Numeric casts must preserve width');
|
|
507
|
+
return node.format;
|
|
508
|
+
}
|
|
509
|
+
case 'column': {
|
|
510
|
+
const format = formats.get(node.name) as GPUExpressionNumericFormat;
|
|
511
|
+
getGPUVectorWGSLLayout(format);
|
|
512
|
+
return format;
|
|
513
|
+
}
|
|
514
|
+
case 'literal':
|
|
515
|
+
case 'parameter':
|
|
516
|
+
if (typeof node.value === 'boolean') throw new Error('Numeric expression required');
|
|
517
|
+
return undefined;
|
|
518
|
+
case 'unary':
|
|
519
|
+
if (isGPUScalarFunction(node.operator))
|
|
520
|
+
return inferNumericFormat(node.operand, formats) ?? 'float32';
|
|
521
|
+
if (node.operator !== 'negate') throw new Error('Numeric expression required');
|
|
522
|
+
return inferNumericFormat(node.operand, formats);
|
|
523
|
+
case 'binary':
|
|
524
|
+
case 'conditional': {
|
|
525
|
+
const left = inferNumericFormat(node.kind === 'binary' ? node.left : node.whenTrue, formats);
|
|
526
|
+
const right = inferNumericFormat(
|
|
527
|
+
node.kind === 'binary' ? node.right : node.otherwise,
|
|
528
|
+
formats
|
|
529
|
+
);
|
|
530
|
+
if (left && right && left !== right)
|
|
531
|
+
throw new Error('GPUDataFrame derived column mixes scalar formats');
|
|
532
|
+
return left ?? right;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuDF.
|
|
5
5
|
|
|
6
6
|
import type {BufferLayout} from '@luma.gl/core';
|
|
7
|
+
import type {GPUExpressionNumericValue} from './gpu-expression';
|
|
7
8
|
import {GPUData, GPUVector, type GPUVectorFormat} from '@luma.gl/graph/gpu-data';
|
|
8
9
|
import {
|
|
9
10
|
GPURecordBatch,
|
|
@@ -196,6 +197,17 @@ export class GPUDataFrame<T extends GPUTypeMap = GPUTypeMap> {
|
|
|
196
197
|
}
|
|
197
198
|
|
|
198
199
|
/** Plans one selected numeric derived column without allocating or submitting GPU work. */
|
|
200
|
+
withColumn<
|
|
201
|
+
Name extends string,
|
|
202
|
+
ReferencedColumns extends keyof T & string,
|
|
203
|
+
Format extends GPUDataFrameDerivedColumnFormat
|
|
204
|
+
>(
|
|
205
|
+
name: Name,
|
|
206
|
+
expression: GPUExpression<GPUExpressionNumericValue, ReferencedColumns> & {
|
|
207
|
+
readonly node: {readonly kind: 'cast'; readonly format: Format};
|
|
208
|
+
},
|
|
209
|
+
options?: GPUDataFrameDerivedColumnOptions<Format>
|
|
210
|
+
): GPUDataFrameQuery<T & Record<Name, Format>, (keyof T & string) | Name, T>;
|
|
199
211
|
withColumn<
|
|
200
212
|
Name extends string,
|
|
201
213
|
ReferencedColumns extends keyof T & string,
|
|
@@ -206,11 +218,32 @@ export class GPUDataFrame<T extends GPUTypeMap = GPUTypeMap> {
|
|
|
206
218
|
>(
|
|
207
219
|
name: Name,
|
|
208
220
|
expression: GPUExpression<number | null, ReferencedColumns>,
|
|
221
|
+
options?: GPUDataFrameDerivedColumnOptions<Format>
|
|
222
|
+
): GPUDataFrameQuery<T & Record<Name, Format>, (keyof T & string) | Name, T>;
|
|
223
|
+
withColumn<Name extends string, Format extends GPUDataFrameDerivedColumnFormat>(
|
|
224
|
+
name: Name,
|
|
225
|
+
expression: GPUExpression<GPUExpressionNumericValue | boolean, string>,
|
|
226
|
+
options: GPUDataFrameDerivedColumnOptions<Format> & {format: Format}
|
|
227
|
+
): GPUDataFrameQuery<T & Record<Name, Format>, (keyof T & string) | Name, T>;
|
|
228
|
+
withColumn<
|
|
229
|
+
Name extends string,
|
|
230
|
+
ReferencedColumns extends keyof T & string,
|
|
231
|
+
Format extends GPUDataFrameDerivedColumnFormat = GPUDataFrameDerivedColumnFormatForExpression<
|
|
232
|
+
T,
|
|
233
|
+
ReferencedColumns
|
|
234
|
+
>
|
|
235
|
+
>(
|
|
236
|
+
name: Name,
|
|
237
|
+
expression: GPUExpression<GPUExpressionNumericValue | boolean, string>,
|
|
209
238
|
options: GPUDataFrameDerivedColumnOptions<Format> = {}
|
|
210
239
|
): GPUDataFrameQuery<T & Record<Name, Format>, (keyof T & string) | Name, T> {
|
|
211
240
|
this.assertAvailable();
|
|
212
|
-
|
|
213
|
-
|
|
241
|
+
return new GPUDataFrameQuery<T & Record<Name, Format>, (keyof T & string) | Name, T>(
|
|
242
|
+
this,
|
|
243
|
+
[],
|
|
244
|
+
[...this.columnNames, name],
|
|
245
|
+
[Object.freeze({name, expression, ...options})]
|
|
246
|
+
);
|
|
214
247
|
}
|
|
215
248
|
|
|
216
249
|
/** Plans dense unsigned grouping without allocating GPU resources or retaining source leases. */
|
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuDF.
|
|
5
5
|
|
|
6
|
+
import {
|
|
7
|
+
getGPUVectorWGSLLayout,
|
|
8
|
+
type GPUVectorWGSLFormat as GPUExpressionNumericFormat
|
|
9
|
+
} from '@luma.gl/graph/gpu-data';
|
|
10
|
+
import {getGPUExpressionCastWGSL, GPU_EXPRESSION_CAST_WGSL} from '../gpu-core/gpu-expression-cast';
|
|
6
11
|
import type {GPUTypeMap} from '@luma.gl/graph/gpu-tables';
|
|
7
12
|
import type {GPUDataFrame} from './gpu-data-frame';
|
|
8
|
-
import {getGPUExpressionCastWGSL} from '../gpu-core/gpu-expression-cast';
|
|
9
13
|
import type {GPUDataFrameDerivedColumn} from './gpu-data-frame-query';
|
|
10
14
|
import {isGPUScalarFunction, type GPUExpressionUnaryOperator} from './gpu-expression';
|
|
11
15
|
import type {
|
|
@@ -25,7 +29,7 @@ export type GPUQueryScalarFormat = 'float32' | 'sint32' | 'uint32';
|
|
|
25
29
|
/** One deduplicated source vector and optional validity sidecar consumed by a predicate. @internal */
|
|
26
30
|
export type GPUQueryExpressionColumn = {
|
|
27
31
|
name: string;
|
|
28
|
-
format:
|
|
32
|
+
format: GPUExpressionNumericFormat;
|
|
29
33
|
nullable: boolean;
|
|
30
34
|
index: number;
|
|
31
35
|
};
|
|
@@ -33,6 +37,7 @@ export type GPUQueryExpressionColumn = {
|
|
|
33
37
|
/** One fixed-size literal or caller-controlled parameter stored outside shader source. @internal */
|
|
34
38
|
export type GPUQueryExpressionControl = {
|
|
35
39
|
name?: string;
|
|
40
|
+
convertInteger?: boolean;
|
|
36
41
|
value: GPUExpressionValue;
|
|
37
42
|
format: GPUQueryScalarFormat | 'boolean';
|
|
38
43
|
index: number;
|
|
@@ -41,7 +46,7 @@ export type GPUQueryExpressionControl = {
|
|
|
41
46
|
/** One selected numeric expression materialized into a source-aligned GPU vector. @internal */
|
|
42
47
|
export type GPUQueryExpressionOutput = {
|
|
43
48
|
name: string;
|
|
44
|
-
format:
|
|
49
|
+
format: GPUExpressionNumericFormat;
|
|
45
50
|
nullable: boolean;
|
|
46
51
|
value: string;
|
|
47
52
|
valid: string;
|
|
@@ -54,11 +59,12 @@ export type GPUQueryExpressionShaderPlan = {
|
|
|
54
59
|
controls: readonly GPUQueryExpressionControl[];
|
|
55
60
|
outputs: readonly GPUQueryExpressionOutput[];
|
|
56
61
|
statements: readonly string[];
|
|
57
|
-
|
|
62
|
+
helpers: readonly string[];
|
|
58
63
|
condition: string;
|
|
59
64
|
};
|
|
60
65
|
|
|
61
|
-
|
|
66
|
+
/** The WGSL value formats accepted by DataFrame expression lowering. */
|
|
67
|
+
type GPUQueryValueFormat = GPUExpressionNumericFormat | 'boolean';
|
|
62
68
|
|
|
63
69
|
type GPUQueryExpressionShaderValue = {
|
|
64
70
|
format: GPUQueryValueFormat;
|
|
@@ -116,7 +122,7 @@ export function makeGPUQueryExpressionShaderPlan<T extends GPUTypeMap>(
|
|
|
116
122
|
controls: planner.controls,
|
|
117
123
|
outputs,
|
|
118
124
|
statements: planner.statements,
|
|
119
|
-
|
|
125
|
+
helpers: planner.helpers,
|
|
120
126
|
condition: conditions.join(' && ') || 'true'
|
|
121
127
|
};
|
|
122
128
|
}
|
|
@@ -130,7 +136,7 @@ export function encodeGPUQueryExpressionControls(
|
|
|
130
136
|
const floatingPointWords = new Float32Array(words.buffer);
|
|
131
137
|
|
|
132
138
|
for (const control of controls) {
|
|
133
|
-
|
|
139
|
+
let value =
|
|
134
140
|
control.name !== undefined && Object.prototype.hasOwnProperty.call(parameters, control.name)
|
|
135
141
|
? parameters[control.name]
|
|
136
142
|
: control.value;
|
|
@@ -161,6 +167,7 @@ export function encodeGPUQueryExpressionControls(
|
|
|
161
167
|
} else {
|
|
162
168
|
const minimum = control.format === 'sint32' ? MINIMUM_SINT32 : 0;
|
|
163
169
|
const maximum = control.format === 'sint32' ? MAXIMUM_SINT32 : MAXIMUM_UINT32;
|
|
170
|
+
if (control.convertInteger) value = Math.min(maximum, Math.max(minimum, Math.trunc(value)));
|
|
164
171
|
if (!Number.isInteger(value) || value < minimum || value > maximum) {
|
|
165
172
|
throw new Error('GPUDataFrame numeric parameters must fit their integer column');
|
|
166
173
|
}
|
|
@@ -177,7 +184,7 @@ class GPUQueryExpressionShaderPlanner<T extends GPUTypeMap> {
|
|
|
177
184
|
readonly columns: GPUQueryExpressionColumn[] = [];
|
|
178
185
|
readonly controls: GPUQueryExpressionControl[] = [];
|
|
179
186
|
readonly statements: string[] = [];
|
|
180
|
-
|
|
187
|
+
readonly helpers: string[] = [];
|
|
181
188
|
|
|
182
189
|
private readonly source: GPUDataFrame<T>;
|
|
183
190
|
private readonly columnsByName = new Map<string, GPUQueryExpressionColumn>();
|
|
@@ -225,34 +232,16 @@ class GPUQueryExpressionShaderPlanner<T extends GPUTypeMap> {
|
|
|
225
232
|
|
|
226
233
|
emit(node: GPUExpressionNode, expected?: GPUQueryValueFormat): GPUQueryExpressionShaderValue {
|
|
227
234
|
switch (node.kind) {
|
|
235
|
+
case 'vector':
|
|
236
|
+
return this.emitVector(node);
|
|
237
|
+
case 'cast':
|
|
238
|
+
return this.emitCast(node);
|
|
228
239
|
case 'column':
|
|
229
240
|
return this.emitColumn(node.name, expected);
|
|
230
241
|
case 'literal':
|
|
231
242
|
return this.emitControl(node.value, undefined, expected);
|
|
232
243
|
case 'parameter':
|
|
233
244
|
return this.emitControl(node.value, node.name, expected);
|
|
234
|
-
case 'cast': {
|
|
235
|
-
const format = node.format;
|
|
236
|
-
if (format !== 'float32' && format !== 'sint32' && format !== 'uint32') {
|
|
237
|
-
throw new Error('GPUDataFrame casts require scalar 32-bit formats');
|
|
238
|
-
}
|
|
239
|
-
const operand = this.emit(node.operand, this.inferFormat(node.operand) ?? 'float32');
|
|
240
|
-
if (operand.format === 'boolean') {
|
|
241
|
-
throw new Error('GPUDataFrame casts require numeric expressions');
|
|
242
|
-
}
|
|
243
|
-
const floatToInteger = operand.format === 'float32' && format !== 'float32';
|
|
244
|
-
const valid = floatToInteger
|
|
245
|
-
? `(${operand.valid} && (bitcast<u32>(${operand.value}) & 0x7fffffffu) < 0x7f800000u)`
|
|
246
|
-
: operand.valid;
|
|
247
|
-
const input = floatToInteger ? `select(0.0, ${operand.value}, ${valid})` : operand.value;
|
|
248
|
-
this.usesCasts ||= floatToInteger;
|
|
249
|
-
return this.addValue(
|
|
250
|
-
format,
|
|
251
|
-
getGPUExpressionCastWGSL(input, operand.format, format, 'truncate'),
|
|
252
|
-
valid,
|
|
253
|
-
operand.nullable || floatToInteger
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
245
|
case 'conditional': {
|
|
257
246
|
const condition = this.emit(node.condition, 'boolean');
|
|
258
247
|
this.assertBoolean(condition);
|
|
@@ -297,26 +286,141 @@ class GPUQueryExpressionShaderPlanner<T extends GPUTypeMap> {
|
|
|
297
286
|
if (expected && expected !== column.format && expected !== 'boolean') {
|
|
298
287
|
throw new Error('GPUDataFrame expression combines incompatible scalar column formats');
|
|
299
288
|
}
|
|
300
|
-
const value = `
|
|
289
|
+
const value = `readInput${column.index}(index)`;
|
|
301
290
|
const valid = column.nullable
|
|
302
291
|
? `validity${column.index}[VALIDITY_${column.index}_OFFSET + index] != 0u`
|
|
303
292
|
: 'true';
|
|
304
293
|
return this.addValue(column.format, value, valid, column.nullable);
|
|
305
294
|
}
|
|
306
295
|
|
|
296
|
+
/** Constructs a vector and combines validity across all of its components. */
|
|
297
|
+
private emitVector(
|
|
298
|
+
node: Extract<GPUExpressionNode, {kind: 'vector'}>
|
|
299
|
+
): GPUQueryExpressionShaderValue {
|
|
300
|
+
const layout = getGPUVectorWGSLLayout(node.format);
|
|
301
|
+
if (layout.components === 1 || node.components.length !== layout.components)
|
|
302
|
+
throw new Error('Vector width must match its format');
|
|
303
|
+
const components = node.components.map(component =>
|
|
304
|
+
this.emitConversion(component, layout.componentType)
|
|
305
|
+
);
|
|
306
|
+
return this.addValue(
|
|
307
|
+
node.format,
|
|
308
|
+
`${layout.shaderType}(${components.map(component => component.value).join(', ')})`,
|
|
309
|
+
components.map(component => component.valid).join(' && '),
|
|
310
|
+
components.some(component => component.nullable)
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** Lowers a width-preserving numeric cast. */
|
|
315
|
+
private emitCast(
|
|
316
|
+
node: Extract<GPUExpressionNode, {kind: 'cast'}>
|
|
317
|
+
): GPUQueryExpressionShaderValue {
|
|
318
|
+
if (getGPUVectorWGSLLayout(node.format).components > 1) {
|
|
319
|
+
return this.emitConversion(node.operand, node.format);
|
|
320
|
+
}
|
|
321
|
+
const format = node.format;
|
|
322
|
+
if (format !== 'float32' && format !== 'sint32' && format !== 'uint32') {
|
|
323
|
+
throw new Error('GPUDataFrame casts require scalar 32-bit formats');
|
|
324
|
+
}
|
|
325
|
+
const operand = this.emit(node.operand, this.inferFormat(node.operand) ?? 'float32');
|
|
326
|
+
if (
|
|
327
|
+
operand.format !== 'float32' &&
|
|
328
|
+
operand.format !== 'uint32' &&
|
|
329
|
+
operand.format !== 'sint32'
|
|
330
|
+
) {
|
|
331
|
+
throw new Error('GPUDataFrame scalar casts require scalar numeric expressions');
|
|
332
|
+
}
|
|
333
|
+
const floatToInteger = operand.format === 'float32' && format !== 'float32';
|
|
334
|
+
const valid = floatToInteger
|
|
335
|
+
? `(${operand.valid} && (bitcast<u32>(${operand.value}) & 0x7fffffffu) < 0x7f800000u)`
|
|
336
|
+
: operand.valid;
|
|
337
|
+
const input = floatToInteger ? `select(0.0, ${operand.value}, ${valid})` : operand.value;
|
|
338
|
+
if (floatToInteger && !this.helpers.includes(GPU_EXPRESSION_CAST_WGSL))
|
|
339
|
+
this.helpers.push(GPU_EXPRESSION_CAST_WGSL);
|
|
340
|
+
return this.addValue(
|
|
341
|
+
format,
|
|
342
|
+
getGPUExpressionCastWGSL(input, operand.format, format, 'truncate'),
|
|
343
|
+
valid,
|
|
344
|
+
operand.nullable || floatToInteger
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** Encodes integer controls directly and lowers other conversions into WGSL. */
|
|
349
|
+
private emitConversion(
|
|
350
|
+
node: GPUExpressionNode,
|
|
351
|
+
target: GPUExpressionNumericFormat
|
|
352
|
+
): GPUQueryExpressionShaderValue {
|
|
353
|
+
if (
|
|
354
|
+
(target === 'sint32' || target === 'uint32') &&
|
|
355
|
+
(node.kind === 'literal' || node.kind === 'parameter') &&
|
|
356
|
+
(node.value === null || typeof node.value === 'number')
|
|
357
|
+
) {
|
|
358
|
+
// Convert controls before upload to retain values above f32 integer precision.
|
|
359
|
+
return this.emitControl(
|
|
360
|
+
node.value,
|
|
361
|
+
node.kind === 'parameter' ? node.name : undefined,
|
|
362
|
+
target,
|
|
363
|
+
true
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
return this.convertValue(this.emit(node, this.inferFormat(node) ?? 'float32'), target);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** Converts each component while preserving width and row validity. */
|
|
370
|
+
private convertValue(
|
|
371
|
+
source: GPUQueryExpressionShaderValue,
|
|
372
|
+
target: GPUExpressionNumericFormat
|
|
373
|
+
): GPUQueryExpressionShaderValue {
|
|
374
|
+
if (source.format === 'boolean') throw new Error('Numeric casts require numeric inputs');
|
|
375
|
+
const sourceLayout = getGPUVectorWGSLLayout(source.format);
|
|
376
|
+
const targetLayout = getGPUVectorWGSLLayout(target);
|
|
377
|
+
if (sourceLayout.components !== targetLayout.components)
|
|
378
|
+
throw new Error('Numeric casts must preserve width');
|
|
379
|
+
if (source.format === target) return source;
|
|
380
|
+
if (!this.helpers.includes(GPU_EXPRESSION_CAST_WGSL))
|
|
381
|
+
this.helpers.push(GPU_EXPRESSION_CAST_WGSL);
|
|
382
|
+
const components = Array.from({length: sourceLayout.components}, (_, index) => {
|
|
383
|
+
const value = sourceLayout.components === 1 ? source.value : `${source.value}[${index}]`;
|
|
384
|
+
return getGPUExpressionCastWGSL(
|
|
385
|
+
value,
|
|
386
|
+
sourceLayout.componentType,
|
|
387
|
+
targetLayout.componentType,
|
|
388
|
+
'truncate'
|
|
389
|
+
);
|
|
390
|
+
});
|
|
391
|
+
// Float NaN/Inf has no portable integer value: mark the entire row invalid.
|
|
392
|
+
const finite =
|
|
393
|
+
sourceLayout.componentType === 'float32' && targetLayout.componentType !== 'float32';
|
|
394
|
+
const valid = finite
|
|
395
|
+
? `${source.valid} && ${sourceLayout.components === 1 ? `abs(${source.value}) <= 3.4028234663852886e38f` : `all(abs(${source.value}) <= ${sourceLayout.shaderType}(3.4028234663852886e38f))`}`
|
|
396
|
+
: source.valid;
|
|
397
|
+
return this.addValue(
|
|
398
|
+
target,
|
|
399
|
+
targetLayout.components === 1
|
|
400
|
+
? components[0]
|
|
401
|
+
: `${targetLayout.shaderType}(${components.join(', ')})`,
|
|
402
|
+
valid,
|
|
403
|
+
source.nullable || finite
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
|
|
307
407
|
private emitControl(
|
|
308
408
|
value: GPUExpressionValue,
|
|
309
409
|
name: string | undefined,
|
|
310
|
-
expected?: GPUQueryValueFormat
|
|
410
|
+
expected?: GPUQueryValueFormat,
|
|
411
|
+
convertInteger = false
|
|
311
412
|
): GPUQueryExpressionShaderValue {
|
|
312
413
|
const inferred = typeof value === 'boolean' ? 'boolean' : (expected ?? 'float32');
|
|
414
|
+
if (inferred !== 'boolean' && getGPUVectorWGSLLayout(inferred).components !== 1)
|
|
415
|
+
throw new Error('Scalar literals cannot broadcast to vectors');
|
|
313
416
|
if (value !== null && (typeof value === 'boolean') !== (inferred === 'boolean')) {
|
|
314
417
|
throw new Error('GPUDataFrame expression combines incompatible literal and column formats');
|
|
315
418
|
}
|
|
316
419
|
const control: GPUQueryExpressionControl = {
|
|
317
420
|
...(name !== undefined ? {name} : {}),
|
|
318
421
|
value,
|
|
319
|
-
|
|
422
|
+
...(convertInteger ? {convertInteger} : {}),
|
|
423
|
+
format: inferred as GPUQueryScalarFormat | 'boolean',
|
|
320
424
|
index: this.controls.length
|
|
321
425
|
};
|
|
322
426
|
this.controls.push(control);
|
|
@@ -382,7 +486,10 @@ class GPUQueryExpressionShaderPlanner<T extends GPUTypeMap> {
|
|
|
382
486
|
case 'round':
|
|
383
487
|
case 'trunc': {
|
|
384
488
|
const format = this.inferFormat(operandNode) ?? 'float32';
|
|
385
|
-
if (
|
|
489
|
+
if (
|
|
490
|
+
(format !== 'float32' && format !== 'sint32' && format !== 'uint32') ||
|
|
491
|
+
(operator === 'abs' && format === 'sint32')
|
|
492
|
+
) {
|
|
386
493
|
throw new Error('GPUDataFrame scalar function requires a supported numeric format');
|
|
387
494
|
}
|
|
388
495
|
const operand = this.emit(operandNode, format);
|
|
@@ -400,7 +507,7 @@ class GPUQueryExpressionShaderPlanner<T extends GPUTypeMap> {
|
|
|
400
507
|
}
|
|
401
508
|
case 'negate': {
|
|
402
509
|
const format = this.inferFormat(operandNode) ?? expected ?? 'float32';
|
|
403
|
-
if (format === 'boolean' || format === 'uint32') {
|
|
510
|
+
if (format === 'boolean' || getGPUVectorWGSLLayout(format).componentType === 'uint32') {
|
|
404
511
|
throw new Error('GPUDataFrame negation requires a signed numeric expression');
|
|
405
512
|
}
|
|
406
513
|
const operand = this.emit(operandNode, format);
|
|
@@ -460,16 +567,23 @@ class GPUQueryExpressionShaderPlanner<T extends GPUTypeMap> {
|
|
|
460
567
|
left.nullable && right.nullable
|
|
461
568
|
);
|
|
462
569
|
}
|
|
570
|
+
const vector = format !== 'boolean' && getGPUVectorWGSLLayout(format).components > 1;
|
|
463
571
|
if (operator === 'nullif') {
|
|
572
|
+
const equals = `(${left.value} == ${right.value})`;
|
|
464
573
|
return this.addValue(
|
|
465
574
|
format,
|
|
466
575
|
left.value,
|
|
467
|
-
`(${left.valid} && !(${right.valid} && ${
|
|
576
|
+
`(${left.valid} && !(${right.valid} && ${vector ? `all(${equals})` : equals}))`,
|
|
468
577
|
true
|
|
469
578
|
);
|
|
470
579
|
}
|
|
471
580
|
const symbol = getGPUQueryBinaryOperator(operator);
|
|
472
|
-
|
|
581
|
+
let value = `(${left.value} ${symbol} ${right.value})`;
|
|
582
|
+
if (vector && !arithmetic) {
|
|
583
|
+
if (operator !== 'equal' && operator !== 'not-equal')
|
|
584
|
+
throw new Error('Vector ordering is unsupported');
|
|
585
|
+
value = `${operator === 'equal' ? 'all' : 'any'}(${value})`;
|
|
586
|
+
}
|
|
473
587
|
const valid = `${left.valid} && ${right.valid}`;
|
|
474
588
|
return this.addValue(
|
|
475
589
|
arithmetic ? format : 'boolean',
|
|
@@ -481,6 +595,9 @@ class GPUQueryExpressionShaderPlanner<T extends GPUTypeMap> {
|
|
|
481
595
|
|
|
482
596
|
private inferFormat(node: GPUExpressionNode): GPUQueryValueFormat | undefined {
|
|
483
597
|
switch (node.kind) {
|
|
598
|
+
case 'vector':
|
|
599
|
+
case 'cast':
|
|
600
|
+
return node.format;
|
|
484
601
|
case 'column':
|
|
485
602
|
return this.derivedByName.has(node.name)
|
|
486
603
|
? this.emitDerived(this.derivedByName.get(node.name)!).format
|
|
@@ -488,11 +605,6 @@ class GPUQueryExpressionShaderPlanner<T extends GPUTypeMap> {
|
|
|
488
605
|
case 'literal':
|
|
489
606
|
case 'parameter':
|
|
490
607
|
return typeof node.value === 'boolean' ? 'boolean' : undefined;
|
|
491
|
-
case 'cast':
|
|
492
|
-
if (node.format === 'float32' || node.format === 'sint32' || node.format === 'uint32') {
|
|
493
|
-
return node.format;
|
|
494
|
-
}
|
|
495
|
-
throw new Error('GPUDataFrame casts require scalar 32-bit formats');
|
|
496
608
|
case 'conditional': {
|
|
497
609
|
const whenTrue = this.inferFormat(node.whenTrue);
|
|
498
610
|
const otherwise = this.inferFormat(node.otherwise);
|
|
@@ -571,14 +683,27 @@ class GPUQueryExpressionShaderPlanner<T extends GPUTypeMap> {
|
|
|
571
683
|
throw new Error(`GPUDataFrame expression column "${name}" is not a GPU vector`);
|
|
572
684
|
}
|
|
573
685
|
const format = vector?.format ?? field.format;
|
|
574
|
-
|
|
575
|
-
|
|
686
|
+
const layout = getGPUVectorWGSLLayout(format as GPUExpressionNumericFormat);
|
|
687
|
+
if (
|
|
688
|
+
vector?.data.some(
|
|
689
|
+
chunk =>
|
|
690
|
+
chunk.byteStride !== layout.packedByteStride ||
|
|
691
|
+
chunk.rowByteLength !== layout.byteLength ||
|
|
692
|
+
chunk.byteOffset % 4 !== 0
|
|
693
|
+
)
|
|
694
|
+
) {
|
|
695
|
+
throw new Error('GPUDataFrame expressions require packed, 32-bit-aligned numeric columns');
|
|
576
696
|
}
|
|
577
697
|
const nullable = field.nullable === true;
|
|
578
698
|
if (nullable && this.source.numRows > 0 && !this.source.validity[name as keyof T & string]) {
|
|
579
699
|
throw new Error(`GPUDataFrame nullable column "${name}" requires an explicit validity mask`);
|
|
580
700
|
}
|
|
581
|
-
const column = {
|
|
701
|
+
const column = {
|
|
702
|
+
name,
|
|
703
|
+
format: format as GPUExpressionNumericFormat,
|
|
704
|
+
nullable,
|
|
705
|
+
index: this.columns.length
|
|
706
|
+
};
|
|
582
707
|
this.columns.push(column);
|
|
583
708
|
this.columnsByName.set(name, column);
|
|
584
709
|
return column;
|
|
@@ -607,19 +732,8 @@ class GPUQueryExpressionShaderPlanner<T extends GPUTypeMap> {
|
|
|
607
732
|
}
|
|
608
733
|
|
|
609
734
|
/** Converts a closed scalar format to the corresponding native WGSL scalar type. @internal */
|
|
610
|
-
export function getGPUQueryShaderType(format: GPUQueryValueFormat):
|
|
611
|
-
|
|
612
|
-
case 'float32':
|
|
613
|
-
return 'f32';
|
|
614
|
-
case 'sint32':
|
|
615
|
-
return 'i32';
|
|
616
|
-
case 'uint32':
|
|
617
|
-
return 'u32';
|
|
618
|
-
case 'boolean':
|
|
619
|
-
return 'bool';
|
|
620
|
-
default:
|
|
621
|
-
throw new Error('GPUDataFrame expression contains an unsupported scalar format');
|
|
622
|
-
}
|
|
735
|
+
export function getGPUQueryShaderType(format: GPUQueryValueFormat): string {
|
|
736
|
+
return format === 'boolean' ? 'bool' : getGPUVectorWGSLLayout(format).shaderType;
|
|
623
737
|
}
|
|
624
738
|
|
|
625
739
|
/** Maps only known discriminants to WGSL operators without accepting application shader text. */
|