@luma.gl/graph 10.0.0-alpha.13 → 10.0.0-alpha.14
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/arrow-colors.cjs +99 -18
- package/dist/arrow/arrow-colors.d.ts +27 -10
- package/dist/arrow/arrow-colors.d.ts.map +1 -1
- package/dist/arrow/arrow-colors.js +107 -24
- package/dist/arrow/arrow-colors.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-vector-adapters.cjs +2 -0
- package/dist/arrow/gpu/arrow-gpu-vector-adapters.d.ts +1 -0
- package/dist/arrow/gpu/arrow-gpu-vector-adapters.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-vector-adapters.js +1 -1
- package/dist/arrow/gpu/arrow-gpu-vector-adapters.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.cjs +32 -3
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts +6 -1
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.js +37 -3
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.js.map +1 -1
- package/dist/arrow/index.cjs.map +3 -3
- package/dist/dist.dev.js +19 -4
- package/dist/dist.min.js +38 -38
- package/dist/gpu-core/gpu-expression-operation.cjs +1 -1
- package/dist/gpu-core/gpu-expression-operation.d.ts +1 -1
- package/dist/gpu-core/gpu-expression-operation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-expression-operation.js +1 -1
- package/dist/gpu-core/gpu-expression-operation.js.map +1 -1
- package/dist/gpu-data/color-conversion.cjs +105 -0
- package/dist/gpu-data/color-conversion.d.ts +30 -0
- package/dist/gpu-data/color-conversion.d.ts.map +1 -0
- package/dist/gpu-data/color-conversion.js +109 -0
- package/dist/gpu-data/color-conversion.js.map +1 -0
- package/dist/gpu-data/index.cjs +7 -2
- package/dist/gpu-data/index.cjs.map +3 -3
- package/dist/gpu-data/index.d.ts +2 -0
- package/dist/gpu-data/index.d.ts.map +1 -1
- package/dist/gpu-data/index.js +1 -0
- package/dist/gpu-data/index.js.map +1 -1
- package/dist/gpu-project/graph.cjs.map +3 -3
- package/dist/gpu-simple-graph/index.cjs.map +3 -3
- package/dist/gpu-simple-graph/index.d.ts +1 -1
- package/dist/gpu-simple-graph/index.d.ts.map +1 -1
- package/dist/gpu-simple-graph/index.js.map +1 -1
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.cjs +2 -0
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js +3 -0
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js.map +1 -1
- package/dist/gpu-simple-graph/operations/convert-colors.cjs +6 -6
- package/dist/gpu-simple-graph/operations/convert-colors.d.ts +5 -1
- package/dist/gpu-simple-graph/operations/convert-colors.d.ts.map +1 -1
- package/dist/gpu-simple-graph/operations/convert-colors.js +12 -7
- package/dist/gpu-simple-graph/operations/convert-colors.js.map +1 -1
- package/dist/gpu-simple-graph/operations/cpu/convert-colors.cjs +16 -33
- package/dist/gpu-simple-graph/operations/cpu/convert-colors.d.ts.map +1 -1
- package/dist/gpu-simple-graph/operations/cpu/convert-colors.js +22 -35
- package/dist/gpu-simple-graph/operations/cpu/convert-colors.js.map +1 -1
- package/dist/gpu-simple-graph/operations/cpu/index.cjs.map +3 -3
- package/dist/gpu-simple-graph/operations/webgl/index.cjs.map +3 -3
- package/dist/gpu-simple-graph/operations/webgpu/convert-colors.cjs +31 -13
- package/dist/gpu-simple-graph/operations/webgpu/convert-colors.d.ts.map +1 -1
- package/dist/gpu-simple-graph/operations/webgpu/convert-colors.js +42 -13
- package/dist/gpu-simple-graph/operations/webgpu/convert-colors.js.map +1 -1
- package/dist/gpu-simple-graph/operations/webgpu/index.cjs.map +1 -1
- package/dist/gpu-sql/gpu-sql.cjs +1 -1
- package/dist/gpu-sql/gpu-sql.js +1 -1
- package/dist/gpu-sql/gpu-sql.js.map +1 -1
- package/dist/gpu-sql/index.cjs.map +1 -1
- package/package.json +8 -7
- package/src/arrow/arrow-colors.ts +194 -33
- package/src/arrow/gpu/arrow-gpu-vector-adapters.ts +3 -1
- package/src/arrow/gpu/arrow-gpu-vector-conversion.ts +46 -4
- package/src/gpu-core/gpu-expression-operation.ts +1 -1
- package/src/gpu-data/color-conversion.ts +158 -0
- package/src/gpu-data/index.ts +3 -0
- package/src/gpu-simple-graph/index.ts +1 -0
- package/src/gpu-simple-graph/operation/gpu-data-evaluator.ts +2 -0
- package/src/gpu-simple-graph/operations/convert-colors.ts +22 -7
- package/src/gpu-simple-graph/operations/cpu/convert-colors.ts +31 -48
- package/src/gpu-simple-graph/operations/webgpu/convert-colors.ts +47 -13
- package/src/gpu-sql/gpu-sql.ts +2 -2
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type GPUDataEvaluatorInput
|
|
9
9
|
} from '../operation/gpu-data-evaluator';
|
|
10
10
|
import {Operation} from '../operation/operation';
|
|
11
|
+
import type {ColorOutputFormat} from '../../gpu-data/color-conversion';
|
|
11
12
|
|
|
12
13
|
export type ColorInputFormat =
|
|
13
14
|
| 'uint8x3'
|
|
@@ -17,13 +18,17 @@ export type ColorInputFormat =
|
|
|
17
18
|
| 'float32x3'
|
|
18
19
|
| 'float32x4';
|
|
19
20
|
|
|
21
|
+
export type {ColorOutputFormat} from '../../gpu-data/color-conversion';
|
|
22
|
+
|
|
20
23
|
export type ConvertColorsProps = {
|
|
24
|
+
format?: ColorOutputFormat;
|
|
21
25
|
inputFormat?: ColorInputFormat;
|
|
22
26
|
};
|
|
23
27
|
|
|
24
28
|
export type ConvertColorsInputs = {
|
|
25
29
|
source: GPUDataEvaluator;
|
|
26
30
|
inputFormat: ColorInputFormat;
|
|
31
|
+
outputFormat: ColorOutputFormat;
|
|
27
32
|
};
|
|
28
33
|
|
|
29
34
|
class ConvertColorsOperation extends Operation<ConvertColorsInputs> {
|
|
@@ -31,15 +36,24 @@ class ConvertColorsOperation extends Operation<ConvertColorsInputs> {
|
|
|
31
36
|
|
|
32
37
|
output: GPUDataEvaluator;
|
|
33
38
|
|
|
34
|
-
constructor(
|
|
35
|
-
|
|
39
|
+
constructor(
|
|
40
|
+
source: GPUDataEvaluator,
|
|
41
|
+
inputFormat: ColorInputFormat,
|
|
42
|
+
outputFormat: ColorOutputFormat
|
|
43
|
+
) {
|
|
44
|
+
super({source, inputFormat, outputFormat});
|
|
36
45
|
|
|
37
46
|
this.output = new GPUDataEvaluator({
|
|
38
47
|
id: `convertColors(${source})`,
|
|
39
|
-
type:
|
|
48
|
+
type:
|
|
49
|
+
outputFormat === 'unorm8x4'
|
|
50
|
+
? 'uint8'
|
|
51
|
+
: outputFormat === 'float16x4'
|
|
52
|
+
? 'float16'
|
|
53
|
+
: 'float32',
|
|
40
54
|
size: 4,
|
|
41
|
-
normalized:
|
|
42
|
-
format:
|
|
55
|
+
normalized: outputFormat === 'unorm8x4',
|
|
56
|
+
format: outputFormat,
|
|
43
57
|
length: source.length,
|
|
44
58
|
source: this
|
|
45
59
|
});
|
|
@@ -50,14 +64,15 @@ class ConvertColorsOperation extends Operation<ConvertColorsInputs> {
|
|
|
50
64
|
}
|
|
51
65
|
}
|
|
52
66
|
|
|
53
|
-
/** Converts one fixed-width
|
|
67
|
+
/** Converts one fixed-width color range to RGBA8, binary16 or binary32 RGBA storage. */
|
|
54
68
|
export function convertColorData(
|
|
55
69
|
source: GPUDataEvaluatorInput,
|
|
56
70
|
props: ConvertColorsProps = {}
|
|
57
71
|
): GPUDataEvaluator {
|
|
58
72
|
const sourceEvaluator = getGPUDataEvaluator(source);
|
|
59
73
|
const inputFormat = props.inputFormat ?? getColorInputFormat(sourceEvaluator);
|
|
60
|
-
return new ConvertColorsOperation(sourceEvaluator, inputFormat)
|
|
74
|
+
return new ConvertColorsOperation(sourceEvaluator, inputFormat, props.format ?? 'unorm8x4')
|
|
75
|
+
.output;
|
|
61
76
|
}
|
|
62
77
|
|
|
63
78
|
function getColorInputFormat(source: GPUDataEvaluator): ColorInputFormat {
|
|
@@ -2,55 +2,38 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import {CPUData} from '../../../gpu-data/cpu-data';
|
|
6
|
+
import {convertCPUColorData} from '../../../gpu-data/color-conversion';
|
|
7
7
|
import type {OperationHandler} from '../../operation/operation';
|
|
8
8
|
import type {ConvertColorsInputs} from '../convert-colors';
|
|
9
9
|
|
|
10
|
-
export const convertColors: OperationHandler<ConvertColorsInputs> = async ({
|
|
11
|
-
inputs
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
10
|
+
export const convertColors: OperationHandler<ConvertColorsInputs> = async ({inputs, target}) => {
|
|
11
|
+
const {source, inputFormat, outputFormat} = inputs;
|
|
12
|
+
const values = await source.ensureCPUValue();
|
|
13
|
+
const format =
|
|
14
|
+
source.format ??
|
|
15
|
+
(inputFormat === 'uint8x3'
|
|
16
|
+
? 'uint8x3-webgl'
|
|
17
|
+
: inputFormat === 'float16x3'
|
|
18
|
+
? 'uint16x3-webgl'
|
|
19
|
+
: inputFormat);
|
|
20
|
+
const converted = convertCPUColorData(
|
|
21
|
+
new CPUData({
|
|
22
|
+
buffer: values,
|
|
23
|
+
format,
|
|
24
|
+
length: source.length,
|
|
25
|
+
byteOffset: source.offset,
|
|
26
|
+
byteStride: source.stride
|
|
27
|
+
}),
|
|
28
|
+
outputFormat,
|
|
29
|
+
inputFormat
|
|
30
|
+
);
|
|
31
|
+
const bytes = new Uint8Array(
|
|
32
|
+
converted.buffer,
|
|
33
|
+
converted.byteOffset,
|
|
34
|
+
converted.length * converted.byteStride
|
|
35
|
+
);
|
|
36
|
+
target.write(bytes);
|
|
37
|
+
// Let the evaluator decode the target in its own Float16Array/Uint16Array representation.
|
|
38
|
+
return {success: true};
|
|
35
39
|
};
|
|
36
|
-
|
|
37
|
-
function convertColorChannel(values: TypedArray, index: number, inputFormat: string): number {
|
|
38
|
-
if (inputFormat.startsWith('uint8')) {
|
|
39
|
-
return values[index];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const value = inputFormat.startsWith('float16') ? getFloat16Value(values, index) : values[index];
|
|
43
|
-
return Math.round(Math.min(Math.max(value, 0), 1) * 255);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function getFloat16Value(values: TypedArray, index: number): number {
|
|
47
|
-
const Float16ArrayConstructor = getNativeFloat16ArrayConstructor();
|
|
48
|
-
if (Float16ArrayConstructor && values.constructor === Float16ArrayConstructor) {
|
|
49
|
-
return values[index];
|
|
50
|
-
}
|
|
51
|
-
return fromHalfFloat(values[index]);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function getNativeFloat16ArrayConstructor(): unknown {
|
|
55
|
-
return (globalThis as typeof globalThis & {Float16Array?: unknown}).Float16Array;
|
|
56
|
-
}
|
|
@@ -13,11 +13,19 @@ const COMPUTATION_RUNS = 'Computation Runs';
|
|
|
13
13
|
export const convertColors: OperationHandler<ConvertColorsInputs> = async ({
|
|
14
14
|
inputs,
|
|
15
15
|
output,
|
|
16
|
-
target
|
|
16
|
+
target,
|
|
17
|
+
scope
|
|
17
18
|
}) => {
|
|
18
19
|
const {source, inputFormat} = inputs;
|
|
20
|
+
if (output.length === 0) return {success: true};
|
|
19
21
|
const kernel = new Kernel(target.device, {
|
|
20
|
-
source: getConvertColorsWGSL(
|
|
22
|
+
source: getConvertColorsWGSL(
|
|
23
|
+
inputFormat,
|
|
24
|
+
source.offset,
|
|
25
|
+
source.stride,
|
|
26
|
+
output.length,
|
|
27
|
+
inputs.outputFormat
|
|
28
|
+
),
|
|
21
29
|
shaderLayout: {
|
|
22
30
|
bindings: [
|
|
23
31
|
{name: 'source', type: 'storage' as const, group: 0, location: 0},
|
|
@@ -31,23 +39,38 @@ export const convertColors: OperationHandler<ConvertColorsInputs> = async ({
|
|
|
31
39
|
result: target
|
|
32
40
|
};
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
if (scope) scope.retain(() => kernel.destroy());
|
|
43
|
+
try {
|
|
44
|
+
const computePass = scope
|
|
45
|
+
? scope.commandEncoder.beginComputePass({})
|
|
46
|
+
: target.device.beginComputePass({});
|
|
47
|
+
try {
|
|
48
|
+
target.device.statsManager
|
|
49
|
+
.getStats(GPGPU_OPERATION_STATS)
|
|
50
|
+
.get(COMPUTATION_RUNS)
|
|
51
|
+
.incrementCount();
|
|
52
|
+
kernel.dispatch(computePass, {
|
|
53
|
+
bindings: kernelBindings,
|
|
54
|
+
x: Math.ceil(output.length / WORKGROUP_SIZE)
|
|
55
|
+
});
|
|
56
|
+
} finally {
|
|
57
|
+
computePass.end();
|
|
58
|
+
}
|
|
59
|
+
if (!scope) target.device.submit();
|
|
60
|
+
} finally {
|
|
61
|
+
if (!scope) kernel.destroy();
|
|
62
|
+
}
|
|
63
|
+
|
|
43
64
|
return {success: true};
|
|
44
65
|
};
|
|
66
|
+
convertColors.supportsEvaluationScope = true;
|
|
45
67
|
|
|
46
68
|
function getConvertColorsWGSL(
|
|
47
69
|
inputFormat: ConvertColorsInputs['inputFormat'],
|
|
48
70
|
byteOffset: number,
|
|
49
71
|
byteStride: number,
|
|
50
|
-
length: number
|
|
72
|
+
length: number,
|
|
73
|
+
outputFormat: ConvertColorsInputs['outputFormat']
|
|
51
74
|
): string {
|
|
52
75
|
return /* wgsl */ `\
|
|
53
76
|
@group(0) @binding(0) var<storage, read> source: array<u32>;
|
|
@@ -90,7 +113,18 @@ ${getReadColorWGSL(inputFormat)}
|
|
|
90
113
|
return;
|
|
91
114
|
}
|
|
92
115
|
|
|
93
|
-
|
|
116
|
+
let color = readColor(rowIndex);
|
|
117
|
+
${
|
|
118
|
+
outputFormat === 'unorm8x4'
|
|
119
|
+
? ' result[rowIndex] = pack4x8unorm(color);'
|
|
120
|
+
: outputFormat === 'float16x4'
|
|
121
|
+
? ` result[rowIndex * 2u] = pack2x16float(color.xy);
|
|
122
|
+
result[rowIndex * 2u + 1u] = pack2x16float(color.zw);`
|
|
123
|
+
: ` result[rowIndex * 4u] = bitcast<u32>(color.x);
|
|
124
|
+
result[rowIndex * 4u + 1u] = bitcast<u32>(color.y);
|
|
125
|
+
result[rowIndex * 4u + 2u] = bitcast<u32>(color.z);
|
|
126
|
+
result[rowIndex * 4u + 3u] = bitcast<u32>(color.w);`
|
|
127
|
+
}
|
|
94
128
|
}
|
|
95
129
|
`;
|
|
96
130
|
}
|
package/src/gpu-sql/gpu-sql.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
// SPDX-FileComment: Independently implemented for WebGPU; inspired by relational SQL semantics.
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
6
|
+
import {parseSQLExpression} from '@math.gl/expressions/sql';
|
|
7
|
+
import type {Expression} from '@math.gl/expressions';
|
|
8
8
|
import type {GPUCommandGraph} from '@luma.gl/graph/gpu-core';
|
|
9
9
|
import {GPUDataFrame} from '../gpu-dataframe/gpu-data-frame';
|
|
10
10
|
import {GPUDataFrameQuery} from '../gpu-dataframe/gpu-data-frame-query';
|