@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
|
@@ -33,6 +33,104 @@ export type GPURigidBodyQueryResult = {
|
|
|
33
33
|
complete: boolean;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
/** One batched ray, or a sphere sweep when radius is supplied. Filters share the batch selection. */
|
|
37
|
+
export type GPURigidBodyBatchCast = Omit<GPURigidBodyRayQuery, 'colliderIndices'> & {
|
|
38
|
+
/** Nonnegative sweep radius. Omit for a ray. */
|
|
39
|
+
radius?: number;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** Optional collider selection shared by every command in a cast batch. */
|
|
43
|
+
export type GPURigidBodyBatchCastOptions = Pick<GPURigidBodyQueryFilter, 'colliderIndices'> & {
|
|
44
|
+
/** Override the world's default. Indexed casts require queryBatchIndex. */
|
|
45
|
+
strategy?: 'scan' | 'indexed';
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Input command stride in bytes, matching the WGSL Query structure. */
|
|
49
|
+
export const RIGID_BODY_CAST_COMMAND_BYTES = 48;
|
|
50
|
+
|
|
51
|
+
/** One result header and one nearest-hit record per command, measured in bytes. */
|
|
52
|
+
export const RIGID_BODY_BATCH_RESULT_BYTES = 64;
|
|
53
|
+
|
|
54
|
+
/** Encode a batch without duplicating the collider selection per command. */
|
|
55
|
+
export function packRigidBodyBatchCasts(
|
|
56
|
+
commands: readonly GPURigidBodyBatchCast[],
|
|
57
|
+
bodyCount: number,
|
|
58
|
+
selectedCount: number,
|
|
59
|
+
indexedCount = 0
|
|
60
|
+
): Uint8Array {
|
|
61
|
+
/** Shared typed views for the command floats and integer flags. */
|
|
62
|
+
const data = new ArrayBuffer(commands.length * RIGID_BODY_CAST_COMMAND_BYTES);
|
|
63
|
+
/** Position, direction, segment length and sweep radius. */
|
|
64
|
+
const floats = new Float32Array(data);
|
|
65
|
+
/** Query kind and optional excluded body. */
|
|
66
|
+
const words = new Uint32Array(data);
|
|
67
|
+
for (const [index, command] of commands.entries()) {
|
|
68
|
+
/** Resolve the per-command segment and optional exclusion before packing. */
|
|
69
|
+
const {origin, direction, maximumDistance, radius, excludeBody} = command;
|
|
70
|
+
/** Normalize directions once on the CPU, retaining distance in world units. */
|
|
71
|
+
const length = Math.hypot(...direction);
|
|
72
|
+
if (
|
|
73
|
+
'colliderIndices' in command ||
|
|
74
|
+
origin.length !== 3 ||
|
|
75
|
+
!origin.every(value => Number.isFinite(Math.fround(value))) ||
|
|
76
|
+
direction.length !== 3 ||
|
|
77
|
+
!Number.isFinite(length) ||
|
|
78
|
+
length === 0 ||
|
|
79
|
+
!Number.isFinite(Math.fround(maximumDistance)) ||
|
|
80
|
+
maximumDistance < 0 ||
|
|
81
|
+
(radius !== undefined && (!Number.isFinite(Math.fround(radius)) || radius < 0)) ||
|
|
82
|
+
(excludeBody !== undefined &&
|
|
83
|
+
(!Number.isInteger(excludeBody) || excludeBody < 0 || excludeBody >= bodyCount))
|
|
84
|
+
)
|
|
85
|
+
throw new Error('Invalid batched collision cast');
|
|
86
|
+
/** Each row is independently aligned to one Query. */
|
|
87
|
+
const offset = (index * RIGID_BODY_CAST_COMMAND_BYTES) / 4;
|
|
88
|
+
floats.set(
|
|
89
|
+
[...origin, radius ?? 0, ...direction.map(value => value / length), maximumDistance],
|
|
90
|
+
offset
|
|
91
|
+
);
|
|
92
|
+
words.set(
|
|
93
|
+
[radius === undefined ? 0 : 2, indexedCount, excludeBody ?? 0xffffffff, selectedCount],
|
|
94
|
+
offset + 8
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return new Uint8Array(data);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Read one nearest hit, using the same layout for scalar and batched query results. */
|
|
101
|
+
export function decodeRigidBodyQueryHit(
|
|
102
|
+
words: Uint32Array,
|
|
103
|
+
floats: Float32Array,
|
|
104
|
+
offset: number
|
|
105
|
+
): GPURigidBodyQueryHit {
|
|
106
|
+
return {
|
|
107
|
+
body: words[offset],
|
|
108
|
+
collider: words[offset + 1],
|
|
109
|
+
point: [floats[offset + 4], floats[offset + 5], floats[offset + 6]],
|
|
110
|
+
distance: floats[offset + 7],
|
|
111
|
+
normal: [floats[offset + 8], floats[offset + 9], floats[offset + 10]]
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Decode ordered results from one compact GPU readback. */
|
|
116
|
+
export function decodeRigidBodyBatchCasts(bytes: Uint8Array): GPURigidBodyQueryResult[] {
|
|
117
|
+
/** Header and identifier words for every command. */
|
|
118
|
+
const words = new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
|
|
119
|
+
/** Nearest hit geometry for each result row. */
|
|
120
|
+
const floats = new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
|
|
121
|
+
return Array.from({length: bytes.byteLength / RIGID_BODY_BATCH_RESULT_BYTES}, (_, index) => {
|
|
122
|
+
/** A four-word header precedes the nearest-hit record. */
|
|
123
|
+
const offset = (index * RIGID_BODY_BATCH_RESULT_BYTES) / 4;
|
|
124
|
+
return {
|
|
125
|
+
hits: words[offset] ? [decodeRigidBodyQueryHit(words, floats, offset + 4)] : [],
|
|
126
|
+
totalHits: words[offset + 1],
|
|
127
|
+
truncated: false,
|
|
128
|
+
complete: words[offset + 2] === 0
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Shared collider intersection code for scalar queries and batched casts. */
|
|
36
134
|
export const RIGID_BODY_QUERY_SHADER = /* wgsl */ `
|
|
37
135
|
struct Query { origin:vec4f, direction:vec4f, settings:vec4u }
|
|
38
136
|
struct QueryHit { identifiers:vec4u, point:vec4f, normal:vec4f }
|
|
@@ -40,21 +138,18 @@ struct QueryOutput { count:u32, total:u32, reserved:vec2u, hits:array<QueryHit>
|
|
|
40
138
|
@group(0) @binding(12) var<uniform> query:Query;
|
|
41
139
|
@group(0) @binding(13) var<storage,read> querySelection:array<u32>;
|
|
42
140
|
@group(0) @binding(14) var<storage,read_write> queryOutput:QueryOutput;
|
|
43
|
-
|
|
44
|
-
let collider=invocation.x;if(collider>=COLLIDER_COUNT){return;}
|
|
45
|
-
queryOutput.hits[collider]=QueryHit();
|
|
46
|
-
if(querySelection[collider]==0u){return;}
|
|
141
|
+
fn queryCollider(collider:u32,request:Query)->QueryHit {
|
|
47
142
|
let shape=bodies.colliders[collider].shape;
|
|
48
|
-
let origin=colliderLocal(collider,
|
|
49
|
-
let direction=colliderLocal(collider,
|
|
143
|
+
let origin=colliderLocal(collider,request.origin.xyz-colliderPosition(collider));
|
|
144
|
+
let direction=colliderLocal(collider,request.direction.xyz);
|
|
50
145
|
var point=origin;var normal=vec3f(0);var distance=0.0;var hit=false;
|
|
51
146
|
var complete=1u;
|
|
52
|
-
if(
|
|
53
|
-
if(
|
|
54
|
-
else{let sweep=sweepSphere(collider,origin,direction,
|
|
55
|
-
}else if(
|
|
56
|
-
if(shape.w==0.0){let lengthFromCenter=length(origin);hit=lengthFromCenter<=shape.x+
|
|
57
|
-
else {point=clamp(origin,-shape.xyz,shape.xyz);let separation=origin-point;let lengthFromSurface=length(separation);hit=lengthFromSurface<=
|
|
147
|
+
if(request.settings.x==2u||shape.w>1.0){
|
|
148
|
+
if(request.settings.x==1u){let surface=closestSurface(collider,origin);hit=surface.distance<=request.origin.w;point=surface.point;normal=select(vec3f(0),(origin-point)/max(length(origin-point),1e-20),surface.distance>0.0);complete=surface.complete;if(shape.w==6.0&&shape.z==0.0&&origin.y<0.0){hit=false;}}
|
|
149
|
+
else{let sweep=sweepSphere(collider,origin,direction,request.direction.w,request.origin.w,false);hit=sweep.hit!=0u;point=sweep.point;normal=sweep.normal;distance=sweep.distance;complete=sweep.complete;}
|
|
150
|
+
}else if(request.settings.x==1u){
|
|
151
|
+
if(shape.w==0.0){let lengthFromCenter=length(origin);hit=lengthFromCenter<=shape.x+request.origin.w;normal=select(vec3f(1,0,0),origin/max(lengthFromCenter,1e-20),lengthFromCenter>1e-20);point=normal*shape.x;}
|
|
152
|
+
else {point=clamp(origin,-shape.xyz,shape.xyz);let separation=origin-point;let lengthFromSurface=length(separation);hit=lengthFromSurface<=request.origin.w;normal=separation/max(lengthFromSurface,1e-20);}
|
|
58
153
|
}else if(shape.w==0.0){
|
|
59
154
|
let projection=dot(origin,direction);
|
|
60
155
|
// Avoid cancellation between large squared distances for distant rays.
|
|
@@ -62,7 +157,7 @@ struct QueryOutput { count:u32, total:u32, reserved:vec2u, hits:array<QueryHit>
|
|
|
62
157
|
if(dot(origin,origin)<=shape.x*shape.x){hit=true;}
|
|
63
158
|
else if(discriminant>=0.0){distance=-projection-sqrt(discriminant);hit=distance>=0.0;point=origin+direction*distance;normal=normalize(point);}
|
|
64
159
|
}else{
|
|
65
|
-
var enter=0.0;var leave=
|
|
160
|
+
var enter=0.0;var leave=request.direction.w;hit=true;
|
|
66
161
|
for(var coordinate=0u;coordinate<3u;coordinate++){
|
|
67
162
|
if(direction[coordinate]==0.0){if(abs(origin[coordinate])>shape[coordinate]){hit=false;}}
|
|
68
163
|
else{
|
|
@@ -74,7 +169,12 @@ struct QueryOutput { count:u32, total:u32, reserved:vec2u, hits:array<QueryHit>
|
|
|
74
169
|
}
|
|
75
170
|
distance=enter;point=origin+direction*distance;hit=hit&&enter<=leave&&leave>=0.0;
|
|
76
171
|
}
|
|
77
|
-
|
|
172
|
+
return QueryHit(vec4u(colliderBody(collider),collider,select(0u,1u,hit&&distance<=request.direction.w),complete),vec4f(colliderPosition(collider)+rotate(colliderRotation(collider),point),distance),vec4f(rotate(colliderRotation(collider),normal),0));
|
|
173
|
+
}
|
|
174
|
+
@compute @workgroup_size(64) fn queryColliders(@builtin(global_invocation_id) invocation:vec3u){
|
|
175
|
+
let collider=invocation.x;if(collider>=COLLIDER_COUNT){return;}
|
|
176
|
+
queryOutput.hits[collider]=QueryHit();
|
|
177
|
+
if(querySelection[collider]!=0u){queryOutput.hits[collider]=queryCollider(collider,query);}
|
|
78
178
|
}
|
|
79
179
|
@compute @workgroup_size(1) fn reduceQueries(){
|
|
80
180
|
queryOutput.count=0u;queryOutput.total=0u;queryOutput.reserved=vec2u(0);var nearest=query.direction.w;
|
|
@@ -88,3 +188,91 @@ struct QueryOutput { count:u32, total:u32, reserved:vec2u, hits:array<QueryHit>
|
|
|
88
188
|
}
|
|
89
189
|
}
|
|
90
190
|
`;
|
|
191
|
+
|
|
192
|
+
/** One workgroup per cast. Scratch is local to the group and scales with lane count. */
|
|
193
|
+
export function getRigidBodyBatchCastShader(leafCapacity = 0): string {
|
|
194
|
+
return /* wgsl */ `
|
|
195
|
+
struct BatchResult {header:vec4u,hit:QueryHit}
|
|
196
|
+
@group(0) @binding(30) var<storage,read> batchCommands:array<Query>;
|
|
197
|
+
@group(0) @binding(31) var<storage,read_write> batchResults:array<BatchResult>;
|
|
198
|
+
var<workgroup> reducedHits:array<QueryHit,64>;
|
|
199
|
+
var<workgroup> reducedCounts:array<vec2u,64>;
|
|
200
|
+
|
|
201
|
+
// Match the scalar reducer: prefer the smaller collider index at equal distance.
|
|
202
|
+
fn closer(first:QueryHit,second:QueryHit)->bool{
|
|
203
|
+
return first.identifiers.z!=0u&&(second.identifiers.z==0u||
|
|
204
|
+
first.point.w<second.point.w||
|
|
205
|
+
(first.point.w==second.point.w&&first.identifiers.y<second.identifiers.y));
|
|
206
|
+
}
|
|
207
|
+
${leafCapacity ? getCastTraversalShader(leafCapacity) : ''}
|
|
208
|
+
fn accumulateCast(
|
|
209
|
+
collider:u32,command:Query,best:ptr<function,QueryHit>,counts:ptr<function,vec2u>
|
|
210
|
+
){
|
|
211
|
+
if(colliderBody(collider)==command.settings.z){return;}
|
|
212
|
+
let candidate=queryCollider(collider,command);
|
|
213
|
+
(*counts)+=vec2u(candidate.identifiers.z,select(0u,1u,candidate.identifiers.w==0u));
|
|
214
|
+
if(closer(candidate,*best)){*best=candidate;}
|
|
215
|
+
}
|
|
216
|
+
@compute @workgroup_size(64) fn castBatch(
|
|
217
|
+
@builtin(workgroup_id) groupIndex:vec3u,
|
|
218
|
+
@builtin(local_invocation_index) lane:u32
|
|
219
|
+
){
|
|
220
|
+
let command=batchCommands[groupIndex.x];
|
|
221
|
+
var best=QueryHit();var counts=vec2u(0);
|
|
222
|
+
${leafCapacity ? 'traverseCastBounds(lane,command,&best,&counts);' : ''}
|
|
223
|
+
for(var work=lane+command.settings.y;work<command.settings.w;work+=64u){
|
|
224
|
+
accumulateCast(querySelection[work],command,&best,&counts);
|
|
225
|
+
}
|
|
226
|
+
reducedHits[lane]=best;reducedCounts[lane]=counts;workgroupBarrier();
|
|
227
|
+
for(var stride=32u;stride>0u;stride/=2u){
|
|
228
|
+
if(lane<stride){
|
|
229
|
+
let neighbor=lane+stride;
|
|
230
|
+
if(closer(reducedHits[neighbor],reducedHits[lane])){reducedHits[lane]=reducedHits[neighbor];}
|
|
231
|
+
reducedCounts[lane]+=reducedCounts[neighbor];
|
|
232
|
+
}
|
|
233
|
+
workgroupBarrier();
|
|
234
|
+
}
|
|
235
|
+
if(lane==0u){
|
|
236
|
+
let hit=reducedHits[0];let counts=reducedCounts[0];
|
|
237
|
+
batchResults[groupIndex.x]=BatchResult(vec4u(hit.identifiers.z,counts.x,counts.y,0u),hit);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
`;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Traverse disjoint implicit subtrees without a private stack or a candidate buffer. */
|
|
244
|
+
function getCastTraversalShader(leafCapacity: number): string {
|
|
245
|
+
return /* wgsl */ `
|
|
246
|
+
@group(0) @binding(26) var<storage,read> nodeMinima:array<f32>;
|
|
247
|
+
@group(0) @binding(27) var<storage,read> nodeMaxima:array<f32>;
|
|
248
|
+
const CAST_LEAVES:u32=${leafCapacity}u;
|
|
249
|
+
const CAST_SUBTREES:u32=min(CAST_LEAVES,8u);
|
|
250
|
+
|
|
251
|
+
fn traverseCastBounds(
|
|
252
|
+
lane:u32,command:Query,best:ptr<function,QueryHit>,counts:ptr<function,vec2u>
|
|
253
|
+
){
|
|
254
|
+
if(lane>=CAST_SUBTREES){return;}
|
|
255
|
+
// One-based heap addresses make sibling and parent navigation arithmetic.
|
|
256
|
+
let root=CAST_SUBTREES+lane;
|
|
257
|
+
var node=root;
|
|
258
|
+
// The world slab and local intersection use different arithmetic orders.
|
|
259
|
+
let directionRoundoff=command.direction.w*vec3f(2e-6);
|
|
260
|
+
let padding=command.origin.w*1.000002+abs(command.origin.xyz)*2e-6+directionRoundoff;
|
|
261
|
+
loop{
|
|
262
|
+
let offset=(node-1u)*3u;
|
|
263
|
+
let lower=vec3f(nodeMinima[offset],nodeMinima[offset+1u],nodeMinima[offset+2u]);
|
|
264
|
+
let upper=vec3f(nodeMaxima[offset],nodeMaxima[offset+1u],nodeMaxima[offset+2u]);
|
|
265
|
+
if(all(lower<=upper)&&intersectsSweepBounds(
|
|
266
|
+
command.origin.xyz,command.direction.xyz,command.direction.w,lower-padding,upper+padding
|
|
267
|
+
)){
|
|
268
|
+
if(node<CAST_LEAVES){node*=2u;continue;}
|
|
269
|
+
let row=node-CAST_LEAVES;
|
|
270
|
+
if(row<command.settings.y){accumulateCast(querySelection[row],command,best,counts);}
|
|
271
|
+
}
|
|
272
|
+
while(node>root&&(node&1u)!=0u){node/=2u;}
|
|
273
|
+
if(node==root){break;}
|
|
274
|
+
node+=1u;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
`;
|
|
278
|
+
}
|
|
@@ -31,7 +31,8 @@ export function getRigidBodyShader(
|
|
|
31
31
|
collisionPartitionSize?: number,
|
|
32
32
|
ensembleBodiesPerInstance?: number,
|
|
33
33
|
blockContacts = false,
|
|
34
|
-
heightFields = false
|
|
34
|
+
heightFields = false,
|
|
35
|
+
ensemblePairsPerInstance?: number
|
|
35
36
|
): string {
|
|
36
37
|
return /* wgsl */ `
|
|
37
38
|
const COMPACT_CONTACTS:bool=${compactContacts};
|
|
@@ -47,7 +48,7 @@ struct Target { position: vec4f, orientation: vec4f }
|
|
|
47
48
|
struct CacheKey { key:atomic<u32>, epoch:u32 }
|
|
48
49
|
struct GeneralConstraint {axes:vec4f,limits:vec4f,control:vec4f,drive:vec4f}
|
|
49
50
|
struct JointState {impulses:array<f32,8>, control:vec4f, limits:vec4f, motor:vec4f, drive:vec4f, spring:vec4f, general:GeneralConstraint}
|
|
50
|
-
struct Targets { entries:array<Target,BODY_COUNT>, dispatch:atomic<u32>, vertical:u32, depth:u32 ${sparse ? `, frame:u32, cacheDropped:atomic<u32>, reserved0:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, reserved1:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, reserved2:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, keys:array<CacheKey,PAIR_CAPACITY>` : ''}${ensembleBodiesPerInstance ? `, instanceHeads:array<atomic<u32>,${count / ensembleBodiesPerInstance}>, instanceFrames:array<u32,${count / ensembleBodiesPerInstance}>, links:array<u32,PAIR_CAPACITY>, journalMarks:array<u32,PAIR_CAPACITY>, journalSlots:array<u32,PAIR_CAPACITY>, journalKeys:array<vec2u,PAIR_CAPACITY>, journalLinks:array<u32,PAIR_CAPACITY>, savedHeads:array<u32,${count / ensembleBodiesPerInstance}>, savedFrames:array<u32,${count / ensembleBodiesPerInstance}>, savedHeader:array<u32,8>, journalManifolds:array<Manifold,PAIR_CAPACITY>` : ''}${jointCount ? `, joints:array<JointState,${jointCount}>` : ''} }
|
|
51
|
+
struct Targets { entries:array<Target,BODY_COUNT>, dispatch:atomic<u32>, vertical:u32, depth:u32 ${sparse ? `, frame:u32, cacheDropped:atomic<u32>, reserved0:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, reserved1:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, reserved2:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, keys:array<CacheKey,PAIR_CAPACITY>` : ''}${ensembleBodiesPerInstance ? `, instanceHeads:array<atomic<u32>,${count / ensembleBodiesPerInstance}>, instanceFrames:array<u32,${count / ensembleBodiesPerInstance}>, links:array<u32,PAIR_CAPACITY>, journalMarks:array<u32,PAIR_CAPACITY>, journalSlots:array<u32,PAIR_CAPACITY>, journalKeys:array<vec2u,PAIR_CAPACITY>, journalLinks:array<u32,PAIR_CAPACITY>, savedHeads:array<u32,${count / ensembleBodiesPerInstance}>, savedFrames:array<u32,${count / ensembleBodiesPerInstance}>, savedHeader:array<u32,8>, journalManifolds:array<Manifold,PAIR_CAPACITY>${ensemblePairsPerInstance ? `, instanceFailures:array<atomic<u32>,${count / ensembleBodiesPerInstance + 1}>` : ''}` : ''}${jointCount ? `, joints:array<JointState,${jointCount}>` : ''} }
|
|
51
52
|
struct Contact { point: vec4f, normal: vec4f, impulse: vec4f, tangent: vec4f, firstAnchor:vec4f, secondAnchor:vec4f }
|
|
52
53
|
struct Manifold { contacts: array<Contact, 4>, count: u32, first:u32, second:u32, previousCount:u32, padding: vec3u, terrainRevision:u32 }
|
|
53
54
|
struct Settings { gravity: vec4f, solver: vec4f, sleep: vec4f, stability: vec4f }
|
|
@@ -63,7 +64,7 @@ struct Settings { gravity: vec4f, solver: vec4f, sleep: vec4f, stability: vec4f
|
|
|
63
64
|
${getEnsembleShader(count, ensembleBodiesPerInstance, collisionPartitionSize, extended)}
|
|
64
65
|
${
|
|
65
66
|
sparse
|
|
66
|
-
? getRigidBodyCacheShader(sparse, Boolean(ensembleBodiesPerInstance))
|
|
67
|
+
? getRigidBodyCacheShader(sparse, Boolean(ensembleBodiesPerInstance), ensemblePairsPerInstance)
|
|
67
68
|
: `
|
|
68
69
|
fn getFirstCollider(pair:u32)->u32{return pair/COLLIDER_COUNT;}
|
|
69
70
|
fn getSecondCollider(pair:u32)->u32{return pair%COLLIDER_COUNT;}
|
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
} from '../gpu-core/gpu-command-graph';
|
|
18
18
|
import type {GPURigidBodyCollider} from './rigid-body-properties';
|
|
19
19
|
import {RIGID_BODY_QUERY_GEOMETRY_SHADER} from './rigid-body-query-geometry';
|
|
20
|
+
import {addRigidBodyEventCompaction} from './rigid-body-event-compaction';
|
|
20
21
|
|
|
21
22
|
export type GPURigidBodyTrigger = {
|
|
22
23
|
/** Union of sensor colliders; one enter/exit state per target body. */
|
|
@@ -237,22 +238,43 @@ struct TriggerRing {sequence:u32,step:u32,saturated:u32,reserved:u32,entries:arr
|
|
|
237
238
|
}
|
|
238
239
|
triggerSamples[index]=vec4u(select(0u,1u,overlapping)|select(0u,2u,crossed)|select(0u,4u,incomplete),selected,0u);
|
|
239
240
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
241
|
+
`;
|
|
242
|
+
/** Geometry sampling and ordered publication compile as separate entry point families. */
|
|
243
|
+
const eventShader =
|
|
244
|
+
shader +
|
|
245
|
+
/* wgsl */ `
|
|
246
|
+
const TRIGGER_ENTER:u32=1u;
|
|
247
|
+
const TRIGGER_EXIT:u32=2u;
|
|
248
|
+
const TRIGGER_SWEPT:u32=4u;
|
|
249
|
+
fn eventCommit()->bool{return triggerStatistics[1]==0u&&triggerStatistics[15]==0u;}
|
|
250
|
+
fn eventClassify(index:u32)->u32{
|
|
251
|
+
let sample=triggerSamples[index];let previous=triggerHistory[index];
|
|
252
|
+
let overlapping=(sample.x&1u)!=0u;let prior=(previous.x&1u)!=0u;
|
|
253
|
+
if(overlapping&&!prior){return TRIGGER_ENTER;}
|
|
254
|
+
if(!overlapping&&prior){return TRIGGER_EXIT;}
|
|
255
|
+
if(!overlapping&&!prior&&(sample.x&2u)!=0u){return TRIGGER_ENTER|TRIGGER_EXIT|TRIGGER_SWEPT;}
|
|
256
|
+
return 0u;
|
|
257
|
+
}
|
|
258
|
+
fn eventCount(flags:u32)->u32{return countOneBits(flags&3u);}
|
|
259
|
+
fn emitTrigger(sequence:u32,step:u32,group:vec4u,pair:vec2u,phase:u32,swept:u32){
|
|
260
|
+
let slot=(sequence-1u)%${capacity}u;
|
|
261
|
+
triggerEvents.entries[slot]=TriggerRecord(vec4u(sequence,step,phase,swept),vec4u(group.x,group.y,pair));
|
|
244
262
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
let
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
263
|
+
fn eventPublish(index:u32,flags:u32,offset:u32,reservation:vec3u){
|
|
264
|
+
let sample=triggerSamples[index];
|
|
265
|
+
let swept=select(0u,1u,(flags&TRIGGER_SWEPT)!=0u);
|
|
266
|
+
if((flags&TRIGGER_ENTER)!=0u){
|
|
267
|
+
let sequence=retainedEventSequence(reservation,offset);
|
|
268
|
+
if(sequence!=0u){emitTrigger(sequence,reservation.z,triggerGroups[index],sample.yz,0u,swept);}
|
|
269
|
+
}
|
|
270
|
+
if((flags&TRIGGER_EXIT)!=0u){
|
|
271
|
+
let sequence=retainedEventSequence(reservation,offset+swept);
|
|
272
|
+
if(sequence!=0u){
|
|
273
|
+
let pair=select(triggerHistory[index].yz,sample.yz,swept!=0u);
|
|
274
|
+
emitTrigger(sequence,reservation.z,triggerGroups[index],pair,1u,swept);
|
|
275
|
+
}
|
|
255
276
|
}
|
|
277
|
+
triggerHistory[index]=sample;
|
|
256
278
|
}
|
|
257
279
|
`;
|
|
258
280
|
const addStage = (entryPoint: string, names: string[], count: number) => {
|
|
@@ -307,6 +329,7 @@ fn emitTrigger(group:vec4u,pair:vec2u,phase:u32,swept:u32){
|
|
|
307
329
|
);
|
|
308
330
|
return {
|
|
309
331
|
events: extras[5].buffer,
|
|
332
|
+
history: extras[4].buffer,
|
|
310
333
|
samples: {buffer: extras[3].buffer, resource: extras[3].resource, count: layout.count},
|
|
311
334
|
sample: () =>
|
|
312
335
|
addStage(
|
|
@@ -324,11 +347,32 @@ fn emitTrigger(group:vec4u,pair:vec2u,phase:u32,swept:u32){
|
|
|
324
347
|
],
|
|
325
348
|
layout.count
|
|
326
349
|
),
|
|
327
|
-
publish: () =>
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
350
|
+
publish: () => {
|
|
351
|
+
/** Select only the storage declarations reached by each compaction stage. */
|
|
352
|
+
const resources = [...extras, statistics].map(({name, resource, location}) => ({
|
|
353
|
+
name,
|
|
354
|
+
resource,
|
|
355
|
+
location,
|
|
356
|
+
readOnly: name === 'triggerGroups' || name === 'triggerStatistics'
|
|
357
|
+
}));
|
|
358
|
+
addRigidBodyEventCompaction(graph, {
|
|
359
|
+
id: `${id}-trigger-events`,
|
|
360
|
+
rowCount: layout.count,
|
|
361
|
+
capacity,
|
|
362
|
+
ring: 'triggerEvents',
|
|
363
|
+
source: eventShader,
|
|
364
|
+
classify: resources.filter(binding =>
|
|
365
|
+
['triggerSamples', 'triggerHistory'].includes(binding.name)
|
|
366
|
+
),
|
|
367
|
+
commit: resources.filter(binding =>
|
|
368
|
+
['triggerEvents', 'triggerStatistics'].includes(binding.name)
|
|
369
|
+
),
|
|
370
|
+
publish: resources.filter(binding =>
|
|
371
|
+
['triggerGroups', 'triggerSamples', 'triggerHistory', 'triggerEvents'].includes(
|
|
372
|
+
binding.name
|
|
373
|
+
)
|
|
374
|
+
)
|
|
375
|
+
});
|
|
376
|
+
}
|
|
333
377
|
};
|
|
334
378
|
}
|
|
@@ -113,6 +113,49 @@ export function getSphereContactShader(mode: 'count' | 'emit', allPairs: boolean
|
|
|
113
113
|
@group(0) @binding(6) var<storage, read> offsets: array<u32>;
|
|
114
114
|
@group(0) @binding(7) var<storage, read_write> contacts: array<vec2u>;
|
|
115
115
|
@group(0) @binding(8) var<storage, read_write> diagnostics: array<atomic<u32>>;
|
|
116
|
+
${
|
|
117
|
+
mode === 'count'
|
|
118
|
+
? `var<workgroup> contactDiagnostics: array<vec4u, 64>;
|
|
119
|
+
|
|
120
|
+
fn addSaturated(counterIndex: u32, amount: u32) {
|
|
121
|
+
var current = atomicLoad(&diagnostics[counterIndex]);
|
|
122
|
+
loop {
|
|
123
|
+
let next = current + min(amount, 0xffffffffu - current);
|
|
124
|
+
let result = atomicCompareExchangeWeak(&diagnostics[counterIndex], current, next);
|
|
125
|
+
if (result.exchanged) { break; }
|
|
126
|
+
current = result.old_value;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
fn countContacts(localIndex: u32, contactCount: u32, candidateCount: u32) {
|
|
131
|
+
contactDiagnostics[localIndex] = vec4u(
|
|
132
|
+
contactCount - min(contactCount, MAXIMUM_CONTACTS),
|
|
133
|
+
candidateCount,
|
|
134
|
+
contactCount,
|
|
135
|
+
select(0u, 2u, MAXIMUM_CANDIDATES > 0u && candidateCount >= MAXIMUM_CANDIDATES)
|
|
136
|
+
);
|
|
137
|
+
workgroupBarrier();
|
|
138
|
+
for (var stride = 32u; stride > 0u; stride >>= 1u) {
|
|
139
|
+
if (localIndex < stride) {
|
|
140
|
+
let first = contactDiagnostics[localIndex];
|
|
141
|
+
let second = contactDiagnostics[localIndex + stride];
|
|
142
|
+
contactDiagnostics[localIndex] = vec4u(
|
|
143
|
+
first.x + second.x, first.y + second.y, max(first.z, second.z), first.w + second.w
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
workgroupBarrier();
|
|
147
|
+
}
|
|
148
|
+
if (localIndex == 0u) {
|
|
149
|
+
let totals = contactDiagnostics[0];
|
|
150
|
+
if (totals.x > 0u) { addSaturated(0u, totals.x); }
|
|
151
|
+
if (totals.y > 0u) { addSaturated(5u, totals.y); }
|
|
152
|
+
if (totals.z > 0u) { atomicMax(&diagnostics[6], totals.z); }
|
|
153
|
+
if (totals.w > 0u) { atomicAdd(&diagnostics[7], totals.w); }
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
`
|
|
157
|
+
: ''
|
|
158
|
+
}
|
|
116
159
|
fn lowerBound(key: u32) -> u32 {
|
|
117
160
|
var first = 0u; var last = BODY_COUNT;
|
|
118
161
|
while (first < last) {
|
|
@@ -122,12 +165,16 @@ fn lowerBound(key: u32) -> u32 {
|
|
|
122
165
|
return first;
|
|
123
166
|
}
|
|
124
167
|
@compute @workgroup_size(64)
|
|
125
|
-
fn main(
|
|
168
|
+
fn main(
|
|
169
|
+
@builtin(global_invocation_id) invocation: vec3u,
|
|
170
|
+
@builtin(local_invocation_index) localIndex: u32
|
|
171
|
+
) {
|
|
126
172
|
let index = invocation.x;
|
|
127
|
-
if (index >= BODY_COUNT) { return; }
|
|
128
|
-
let sphere = positions[index];
|
|
129
173
|
var contactCount = 0u;
|
|
130
174
|
var candidateCount = 0u;
|
|
175
|
+
// Out-of-range lanes supply zero counts and still participate in the reduction.
|
|
176
|
+
var sphere = vec4f(0.0);
|
|
177
|
+
if (index < BODY_COUNT) { sphere = positions[index]; }
|
|
131
178
|
if (isValidSphere(sphere)) {
|
|
132
179
|
let cell = getCell(sphere.xyz);
|
|
133
180
|
${allPairs ? 'let neighborCount = 1u;' : 'let neighborCount = 27u;'}
|
|
@@ -167,24 +214,9 @@ fn main(@builtin(global_invocation_id) invocation: vec3u) {
|
|
|
167
214
|
}
|
|
168
215
|
${
|
|
169
216
|
mode === 'count'
|
|
170
|
-
? `counts[index] = min(contactCount, MAXIMUM_CONTACTS);
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
loop {
|
|
174
|
-
let next = current + min(contactCount - MAXIMUM_CONTACTS, 0xffffffffu - current);
|
|
175
|
-
let result = atomicCompareExchangeWeak(&diagnostics[0], current, next);
|
|
176
|
-
if (result.exchanged) {break;} current = result.old_value;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
var currentCandidates = atomicLoad(&diagnostics[5]);
|
|
180
|
-
loop {
|
|
181
|
-
let next = currentCandidates + min(candidateCount, 0xffffffffu - currentCandidates);
|
|
182
|
-
let result = atomicCompareExchangeWeak(&diagnostics[5], currentCandidates, next);
|
|
183
|
-
if (result.exchanged) {break;} currentCandidates = result.old_value;
|
|
184
|
-
}
|
|
185
|
-
atomicMax(&diagnostics[6], contactCount);
|
|
186
|
-
if(MAXIMUM_CANDIDATES > 0u && candidateCount >= MAXIMUM_CANDIDATES) {atomicAdd(&diagnostics[7], 2u);}`
|
|
187
|
-
: 'atomicAdd(&diagnostics[2], min(contactCount, MAXIMUM_CONTACTS));'
|
|
217
|
+
? `if (index < BODY_COUNT) { counts[index] = min(contactCount, MAXIMUM_CONTACTS); }
|
|
218
|
+
countContacts(localIndex, contactCount, candidateCount);`
|
|
219
|
+
: 'if (contactCount > 0u) { atomicAdd(&diagnostics[2], min(contactCount, MAXIMUM_CONTACTS)); }'
|
|
188
220
|
}
|
|
189
221
|
}
|
|
190
222
|
`;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuProj.
|
|
5
5
|
|
|
6
6
|
import {fp64arithmetic, type ShaderModule} from '@luma.gl/shaders';
|
|
7
|
+
import {nextFloat32} from '../utils/float32';
|
|
7
8
|
import {
|
|
8
9
|
GEOSPATIAL_INTEGER_FP64_ARITHMETIC_MODULE,
|
|
9
10
|
getClassicFP64Defines
|
|
@@ -462,12 +463,3 @@ fn PROGRAM_project(position: ${inputType}, inputValidity: u32) -> PROGRAM_Result
|
|
|
462
463
|
}`;
|
|
463
464
|
return {source, parameters: Uint32Array.from(words)};
|
|
464
465
|
}
|
|
465
|
-
|
|
466
|
-
function nextFloat32(value: number, increase: boolean): number {
|
|
467
|
-
if (value === 0) {
|
|
468
|
-
return increase ? 2 ** -149 : -(2 ** -149);
|
|
469
|
-
}
|
|
470
|
-
const words = new Uint32Array(Float32Array.of(value).buffer);
|
|
471
|
-
words[0] += value > 0 === increase ? 1 : -1;
|
|
472
|
-
return new Float32Array(words.buffer)[0];
|
|
473
|
-
}
|