@luma.gl/graph 10.0.0-alpha.11 → 10.0.0-alpha.12
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/dist.dev.js +658 -292
- package/dist/dist.min.js +110 -92
- package/dist/experimental/index.cjs.map +1 -1
- package/dist/experimental/simulation/index.cjs.map +1 -1
- package/dist/gpu-core/compiled-gpu-graph.cjs +15 -0
- package/dist/gpu-core/compiled-gpu-graph.d.ts +1 -0
- package/dist/gpu-core/compiled-gpu-graph.d.ts.map +1 -1
- package/dist/gpu-core/compiled-gpu-graph.js +15 -0
- package/dist/gpu-core/compiled-gpu-graph.js.map +1 -1
- package/dist/gpu-core/gpu-command-graph.cjs +9 -0
- package/dist/gpu-core/gpu-command-graph.d.ts +2 -0
- package/dist/gpu-core/gpu-command-graph.d.ts.map +1 -1
- package/dist/gpu-core/gpu-command-graph.js +9 -0
- package/dist/gpu-core/gpu-command-graph.js.map +1 -1
- package/dist/gpu-core/gpu-expression-plan.cjs +4 -0
- package/dist/gpu-core/gpu-expression-plan.d.ts.map +1 -1
- package/dist/gpu-core/gpu-expression-plan.js +5 -0
- package/dist/gpu-core/gpu-expression-plan.js.map +1 -1
- package/dist/gpu-core/gpu-shader-pass-kernel.cjs +267 -0
- package/dist/gpu-core/gpu-shader-pass-kernel.d.ts +29 -0
- package/dist/gpu-core/gpu-shader-pass-kernel.d.ts.map +1 -0
- package/dist/gpu-core/gpu-shader-pass-kernel.js +260 -0
- package/dist/gpu-core/gpu-shader-pass-kernel.js.map +1 -0
- package/dist/gpu-core/gpu-shader-pass-operation.cjs +85 -0
- package/dist/gpu-core/gpu-shader-pass-operation.d.ts +32 -0
- package/dist/gpu-core/gpu-shader-pass-operation.d.ts.map +1 -0
- package/dist/gpu-core/gpu-shader-pass-operation.js +74 -0
- package/dist/gpu-core/gpu-shader-pass-operation.js.map +1 -0
- package/dist/gpu-core/index.cjs +3 -0
- package/dist/gpu-core/index.cjs.map +3 -3
- package/dist/gpu-core/index.d.ts +2 -0
- package/dist/gpu-core/index.d.ts.map +1 -1
- package/dist/gpu-core/index.js +1 -0
- package/dist/gpu-core/index.js.map +1 -1
- package/dist/gpu-dggs/benchmarks.cjs.map +1 -1
- package/dist/gpu-graph/index.cjs.map +3 -3
- package/dist/gpu-graph-algorithms/benchmarks.cjs.map +1 -1
- package/dist/gpu-physics/index.cjs.map +1 -1
- package/dist/gpu-project/graph.cjs.map +3 -3
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.cjs +53 -5
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts +3 -1
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts.map +1 -1
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js +58 -5
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js.map +1 -1
- package/dist/gpu-simple-graph/index.cjs.map +3 -3
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/gpu-core/compiled-gpu-graph.ts +18 -0
- package/src/gpu-core/gpu-command-graph.ts +10 -0
- package/src/gpu-core/gpu-expression-plan.ts +6 -0
- package/src/gpu-core/gpu-shader-pass-kernel.ts +307 -0
- package/src/gpu-core/gpu-shader-pass-operation.ts +103 -0
- package/src/gpu-core/index.ts +2 -0
- package/src/gpu-simple-graph/compiled-gpu-expression-graph.ts +59 -5
- package/src/index.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export type { GPUGraphScalarDescriptor, GPUGraphVectorDescriptor, GPUGraphValueD
|
|
|
24
24
|
export type { GPUGraphExecutionBindings } from "./gpu-core/gpu-expression-plan.js";
|
|
25
25
|
export type { GPUOperationOutputDeclarations, GPUOperationContractContext } from "./gpu-core/gpu-operation-contract.js";
|
|
26
26
|
export { GPUUploadOperation, GPUCopyOperation } from "./gpu-core/gpu-transfer-operation.js";
|
|
27
|
+
export { GPUShaderPassOperation } from "./gpu-core/gpu-shader-pass-operation.js";
|
|
28
|
+
export type { GPUShaderPassOperationProps } from "./gpu-core/gpu-shader-pass-operation.js";
|
|
27
29
|
export type { GPUUploadOperationProps, GPUCopyOperationProps } from "./gpu-core/gpu-transfer-operation.js";
|
|
28
30
|
export { GPUCompactionOperation } from "./gpu-core/gpu-compaction-operation.js";
|
|
29
31
|
export type { GPUCompactionOperationProps } from "./gpu-core/gpu-compaction-operation.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,+BAA+B,EAC/B,iBAAiB,EACjB,aAAa,EACb,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,QAAQ,EACR,cAAc,EACd,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,0BAA0B,EAC1B,KAAK,0BAA0B,EAC/B,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,gCAAgC,EACrC,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,KAAK,4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AC1F,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EACnB,0CAAuC;AAExC,YAAY,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,uBAAuB,EACxB,6CAA0C;AAC3C,YAAY,EAAC,YAAY,EAAC,oCAAiC;AAE3D,OAAO,EAAC,QAAQ,EAAC,sCAAmC;AACpD,YAAY,EACV,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EAClB,sCAAmC;AACpC,YAAY,EAAC,yBAAyB,EAAC,0CAAuC;AAC9E,YAAY,EACV,8BAA8B,EAC9B,2BAA2B,EAC5B,6CAA0C;AAE3C,OAAO,EAAC,kBAAkB,EAAE,gBAAgB,EAAC,6CAA0C;AACvF,OAAO,EAAC,sBAAsB,EAAC,gDAA6C;AAC5E,YAAY,EAAC,2BAA2B,EAAC,gDAA6C;AACtF,YAAY,EACV,uBAAuB,EACvB,qBAAqB,EACtB,6CAA0C;AAC3C,OAAO,EAAC,sBAAsB,EAAC,+CAA4C;AAC3E,YAAY,EAAC,2BAA2B,EAAC,+CAA4C;AAErF,YAAY,EAAC,yBAAyB,EAAE,qBAAqB,EAAC,sCAAmC;AACjG,YAAY,EACV,sBAAsB,EACtB,cAAc,EACd,eAAe,EAChB,uCAAoC;AAErC,OAAO,EAAC,eAAe,EAAC,wCAAqC;AAC7D,YAAY,EACV,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,YAAY,EACb,wCAAqC"}
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export { GPUExpressionOperation } from "./gpu-core/gpu-expression-operation.js";
|
|
|
14
14
|
export { CompiledGPUGraph, PreparedGPUGraphExecution } from "./gpu-core/compiled-gpu-graph.js";
|
|
15
15
|
export { gpuGraph } from "./gpu-core/gpu-graph-value.js";
|
|
16
16
|
export { GPUUploadOperation, GPUCopyOperation } from "./gpu-core/gpu-transfer-operation.js";
|
|
17
|
+
export { GPUShaderPassOperation } from "./gpu-core/gpu-shader-pass-operation.js";
|
|
17
18
|
export { GPUCompactionOperation } from "./gpu-core/gpu-compaction-operation.js";
|
|
18
19
|
export { GPUCPUOperation } from "./gpu-core/gpu-cpu-operation.js";
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,+BAA+B,EAC/B,iBAAiB,EACjB,aAAa,EACb,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,QAAQ,EACR,cAAc,EACd,cAAc,EACd,eAAe,EACf,mBAAmB,EAInB,gBAAgB,EAUhB,0BAA0B,EAE1B,gBAAgB,EAqDjB,6BAA0B;AAC3B,OAAO,EACL,iCAAiC,EASjC,wBAAwB,EACzB,kDAA+C;AAChD,OAAO,EAGL,wCAAwC,EACzC,0DAAuD;AACxD,OAAO,EAaL,wBAAwB,EACzB,kDAA+C;AAchD,OAAO,EAAC,cAAc,EAAC,uDAAoD;AAU3E,OAAO,EAAC,aAAa,EAAC,qDAAkD;AACxE,OAAO,EAAC,eAAe,EAAC,+CAA4C;AAMpE,OAAO,EAAC,MAAM,EAAC,sCAAmC;AAClD,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAO/D,OAAO,EAAC,sBAAsB,EAAC,+CAA4C;AAK3E,OAAO,EAAC,gBAAgB,EAAE,yBAAyB,EAAC,yCAAsC;AAe1F,OAAO,EAAC,QAAQ,EAAC,sCAAmC;AAapD,OAAO,EAAC,kBAAkB,EAAE,gBAAgB,EAAC,6CAA0C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,+BAA+B,EAC/B,iBAAiB,EACjB,aAAa,EACb,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,QAAQ,EACR,cAAc,EACd,cAAc,EACd,eAAe,EACf,mBAAmB,EAInB,gBAAgB,EAUhB,0BAA0B,EAE1B,gBAAgB,EAqDjB,6BAA0B;AAC3B,OAAO,EACL,iCAAiC,EASjC,wBAAwB,EACzB,kDAA+C;AAChD,OAAO,EAGL,wCAAwC,EACzC,0DAAuD;AACxD,OAAO,EAaL,wBAAwB,EACzB,kDAA+C;AAchD,OAAO,EAAC,cAAc,EAAC,uDAAoD;AAU3E,OAAO,EAAC,aAAa,EAAC,qDAAkD;AACxE,OAAO,EAAC,eAAe,EAAC,+CAA4C;AAMpE,OAAO,EAAC,MAAM,EAAC,sCAAmC;AAClD,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAO/D,OAAO,EAAC,sBAAsB,EAAC,+CAA4C;AAK3E,OAAO,EAAC,gBAAgB,EAAE,yBAAyB,EAAC,yCAAsC;AAe1F,OAAO,EAAC,QAAQ,EAAC,sCAAmC;AAapD,OAAO,EAAC,kBAAkB,EAAE,gBAAgB,EAAC,6CAA0C;AACvF,OAAO,EAAC,sBAAsB,EAAC,gDAA6C;AAM5E,OAAO,EAAC,sBAAsB,EAAC,+CAA4C;AAU3E,OAAO,EAAC,eAAe,EAAC,wCAAqC"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "10.0.0-alpha.
|
|
6
|
+
"version": "10.0.0-alpha.12",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
@@ -240,8 +240,8 @@
|
|
|
240
240
|
}
|
|
241
241
|
},
|
|
242
242
|
"peerDependencies": {
|
|
243
|
-
"@luma.gl/core": "~10.0.0-alpha.
|
|
244
|
-
"@luma.gl/shaders": "~10.0.0-alpha.
|
|
243
|
+
"@luma.gl/core": "~10.0.0-alpha.12",
|
|
244
|
+
"@luma.gl/shaders": "~10.0.0-alpha.12",
|
|
245
245
|
"apache-arrow": ">=17.0.0"
|
|
246
246
|
},
|
|
247
247
|
"peerDependenciesMeta": {
|
|
@@ -250,10 +250,10 @@
|
|
|
250
250
|
}
|
|
251
251
|
},
|
|
252
252
|
"dependencies": {
|
|
253
|
-
"@math.gl/arrow": "~5.0.0-beta.
|
|
254
|
-
"@math.gl/core": "~5.0.0-beta.
|
|
255
|
-
"@math.gl/geospatial": "~5.0.0-beta.
|
|
253
|
+
"@math.gl/arrow": "~5.0.0-beta.6",
|
|
254
|
+
"@math.gl/core": "~5.0.0-beta.6",
|
|
255
|
+
"@math.gl/geospatial": "~5.0.0-beta.6",
|
|
256
256
|
"probe.gl": "^5.0.0"
|
|
257
257
|
},
|
|
258
|
-
"gitHead": "
|
|
258
|
+
"gitHead": "7a2a8a50666ead2337dac60f378dcd920587310e"
|
|
259
259
|
}
|
|
@@ -23,6 +23,8 @@ import {
|
|
|
23
23
|
type GPUGraphRunOptions
|
|
24
24
|
} from './gpu-expression-plan';
|
|
25
25
|
import {GPUExpressionKernel} from './gpu-expression-kernel';
|
|
26
|
+
import {GPUShaderPassOperation} from './gpu-shader-pass-operation';
|
|
27
|
+
import {GPUShaderPassKernel} from './gpu-shader-pass-kernel';
|
|
26
28
|
import {GPUCPUOperation} from './gpu-cpu-operation';
|
|
27
29
|
import {GPUCPUExecution} from './gpu-cpu-execution';
|
|
28
30
|
|
|
@@ -32,6 +34,7 @@ export class CompiledGPUGraph<Outputs extends GPUGraphOutputs = Record<string, G
|
|
|
32
34
|
private readonly stageLowerings: readonly GPUOperationLowering[];
|
|
33
35
|
private readonly compiler: GPUGraphCompiler;
|
|
34
36
|
private readonly kernels = new Map<GPUExpressionOperation, GPUExpressionKernel>();
|
|
37
|
+
private readonly shaderPasses = new Map<GPUShaderPassOperation, GPUShaderPassKernel>();
|
|
35
38
|
private destroyed = false;
|
|
36
39
|
private runningCPU = false;
|
|
37
40
|
private cpuExecution?: GPUCPUExecution;
|
|
@@ -49,6 +52,11 @@ export class CompiledGPUGraph<Outputs extends GPUGraphOutputs = Record<string, G
|
|
|
49
52
|
this.stageLowerings = lowerings ?? options.lowerings ?? [];
|
|
50
53
|
this.compiler = new GPUGraphCompiler(device, [
|
|
51
54
|
...(lowerings ?? options.lowerings ?? []),
|
|
55
|
+
{
|
|
56
|
+
type: 'shader-pass',
|
|
57
|
+
lower: (operation: GPUShaderPassOperation, context) =>
|
|
58
|
+
this.shaderPasses.get(operation)!.lower(context)
|
|
59
|
+
},
|
|
52
60
|
{
|
|
53
61
|
type: 'expression',
|
|
54
62
|
lower: (operation: GPUExpressionOperation, context) =>
|
|
@@ -70,6 +78,12 @@ export class CompiledGPUGraph<Outputs extends GPUGraphOutputs = Record<string, G
|
|
|
70
78
|
try {
|
|
71
79
|
for (const plan of this.program.expressions)
|
|
72
80
|
this.kernels.set(plan.operation, new GPUExpressionKernel(device, this.program, plan));
|
|
81
|
+
for (const operation of this.program.operations)
|
|
82
|
+
if (operation instanceof GPUShaderPassOperation)
|
|
83
|
+
this.shaderPasses.set(
|
|
84
|
+
operation,
|
|
85
|
+
new GPUShaderPassKernel(device, operation, this.program)
|
|
86
|
+
);
|
|
73
87
|
} catch (error) {
|
|
74
88
|
this.destroy();
|
|
75
89
|
throw error;
|
|
@@ -140,6 +154,8 @@ export class CompiledGPUGraph<Outputs extends GPUGraphOutputs = Record<string, G
|
|
|
140
154
|
const invocation = this.program.prepare(this.device, bindings, options, true);
|
|
141
155
|
let executable: CompiledGPUCommandGraph | undefined;
|
|
142
156
|
try {
|
|
157
|
+
for (const kernel of this.shaderPasses.values())
|
|
158
|
+
kernel.validateTextures(invocation.textures!.values);
|
|
143
159
|
const resolved = new GPUGraph();
|
|
144
160
|
for (const scalar of this.program.scalars) resolved.scalar(scalar.id, scalar.format);
|
|
145
161
|
const vectors: Record<string, GPUVector> = Object.create(null);
|
|
@@ -233,6 +249,8 @@ export class CompiledGPUGraph<Outputs extends GPUGraphOutputs = Record<string, G
|
|
|
233
249
|
// CPU callbacks may still be awaiting input readback or producing output arrays.
|
|
234
250
|
assert(!this.runningCPU);
|
|
235
251
|
this.cpuExecution?.destroy();
|
|
252
|
+
for (const kernel of this.shaderPasses.values()) kernel.destroy();
|
|
253
|
+
this.shaderPasses.clear();
|
|
236
254
|
for (const kernel of this.kernels.values()) kernel.destroy();
|
|
237
255
|
this.kernels.clear();
|
|
238
256
|
this.destroyed = true;
|
|
@@ -738,6 +738,16 @@ export class GPUCommandGraphBuilder<Parameters = void> {
|
|
|
738
738
|
return this.addBuffer(new GraphBufferHandle(this, descriptor, true));
|
|
739
739
|
}
|
|
740
740
|
|
|
741
|
+
/** Choose a compiler-owned resource name without treating diagnostic labels as unique. @internal */
|
|
742
|
+
getUniqueResourceId(label: string): string {
|
|
743
|
+
let id = label;
|
|
744
|
+
let suffix = 1;
|
|
745
|
+
while (this.buffers.has(id) || this.textures.has(id) || this.externalTextures.has(id)) {
|
|
746
|
+
id = `${label}-${suffix++}`;
|
|
747
|
+
}
|
|
748
|
+
return id;
|
|
749
|
+
}
|
|
750
|
+
|
|
741
751
|
/**
|
|
742
752
|
* Creates one typed range over a graph buffer.
|
|
743
753
|
*
|
|
@@ -6,6 +6,7 @@ import {Buffer, Texture, TextureView, type Device} from '@luma.gl/core';
|
|
|
6
6
|
import {CPUVector, GPUData, GPUVector, getGPUVectorFormatInfo} from '@luma.gl/graph/gpu-data';
|
|
7
7
|
import type {GPUGraph} from './gpu-graph';
|
|
8
8
|
import {GPUCopyOperation} from './gpu-transfer-operation';
|
|
9
|
+
import {GPUShaderPassOperation} from './gpu-shader-pass-operation';
|
|
9
10
|
import {validateTextureCopy} from './gpu-texture-copy';
|
|
10
11
|
import {
|
|
11
12
|
GPUTextureInvocation,
|
|
@@ -89,6 +90,11 @@ export class GPUExpressionProgram {
|
|
|
89
90
|
operation.operations.forEach(flatten);
|
|
90
91
|
else {
|
|
91
92
|
if (operation instanceof GPUCompositeOperation) {
|
|
93
|
+
const containsShaderPass = (child: GPUGraphOperation): boolean =>
|
|
94
|
+
child instanceof GPUShaderPassOperation ||
|
|
95
|
+
(child instanceof GPUCompositeOperation && child.operations.some(containsShaderPass));
|
|
96
|
+
if (operation.operations.some(containsShaderPass))
|
|
97
|
+
throw new Error('Shader-pass operations inside control flow are not supported');
|
|
92
98
|
const containsExpression = (child: GPUGraphOperation): boolean =>
|
|
93
99
|
child instanceof GPUExpressionOperation ||
|
|
94
100
|
(child instanceof GPUCompositeOperation && child.operations.some(containsExpression));
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
assert,
|
|
7
|
+
Buffer,
|
|
8
|
+
type Binding,
|
|
9
|
+
type CommandEncoder,
|
|
10
|
+
type Device,
|
|
11
|
+
type RenderPass,
|
|
12
|
+
type Sampler,
|
|
13
|
+
type VertexArray
|
|
14
|
+
} from '@luma.gl/core';
|
|
15
|
+
import {GPUVector} from '@luma.gl/graph/gpu-data';
|
|
16
|
+
import {RenderKernel} from '../execution/compute/render-kernel';
|
|
17
|
+
import type {GPUShaderPassOperation} from './gpu-shader-pass-operation';
|
|
18
|
+
import type {GPUExpressionProgram} from './gpu-expression-plan';
|
|
19
|
+
import type {GPUOperationLoweringContext} from './gpu-graph-lowering';
|
|
20
|
+
import {getGPUScalarWGSLType} from './gpu-scalar';
|
|
21
|
+
import {getTextureBindingInfo, type GPUGraphTextureBinding} from './gpu-texture-plan';
|
|
22
|
+
|
|
23
|
+
const VERTEX_SOURCE = `
|
|
24
|
+
struct GraphShaderPassVertex {
|
|
25
|
+
@builtin(position) position: vec4<f32>,
|
|
26
|
+
@location(0) textureCoordinates: vec2<f32>
|
|
27
|
+
};
|
|
28
|
+
@vertex fn vertexMain(@builtin(vertex_index) index: u32) -> GraphShaderPassVertex {
|
|
29
|
+
let position = vec2<f32>(f32((index << 1u) & 2u), f32(index & 2u));
|
|
30
|
+
var result: GraphShaderPassVertex;
|
|
31
|
+
result.position = vec4<f32>(position * 2.0 - 1.0, 0.0, 1.0);
|
|
32
|
+
result.textureCoordinates = vec2<f32>(position.x, 1.0 - position.y);
|
|
33
|
+
return result;
|
|
34
|
+
}`;
|
|
35
|
+
|
|
36
|
+
/** One immutable pipeline; resources and uniforms are supplied independently for each draw. @internal */
|
|
37
|
+
export class GPUShaderPassKernel {
|
|
38
|
+
private kernel!: RenderKernel;
|
|
39
|
+
private vertexArray!: VertexArray;
|
|
40
|
+
private readonly samplers: Record<string, Sampler> = Object.create(null);
|
|
41
|
+
private readonly parameterFormats: readonly ('float32' | 'uint32' | 'sint32')[];
|
|
42
|
+
private readonly parameterByteLength: number;
|
|
43
|
+
|
|
44
|
+
constructor(
|
|
45
|
+
readonly device: Device,
|
|
46
|
+
readonly operation: GPUShaderPassOperation,
|
|
47
|
+
program: Pick<GPUExpressionProgram, 'textures' | 'scalars'>
|
|
48
|
+
) {
|
|
49
|
+
assert(device.type === 'webgpu');
|
|
50
|
+
this.parameterFormats = Object.values(operation.parameters).map(name => {
|
|
51
|
+
const scalar = program.scalars.find(value => value.id === name);
|
|
52
|
+
assert(scalar);
|
|
53
|
+
return scalar.format;
|
|
54
|
+
});
|
|
55
|
+
this.parameterByteLength = Math.ceil(this.parameterFormats.length / 4) * 16;
|
|
56
|
+
// This first shader-pass contract samples filterable float color and writes float color.
|
|
57
|
+
for (const name of Object.values(operation.inputs)) {
|
|
58
|
+
const input = program.textures.find(texture => texture.id === name)!;
|
|
59
|
+
const info = device.getTextureFormatInfo(input.format);
|
|
60
|
+
assert(
|
|
61
|
+
!info.integer &&
|
|
62
|
+
info.attachment !== 'depth' &&
|
|
63
|
+
info.attachment !== 'depth-stencil' &&
|
|
64
|
+
device.getTextureFormatCapabilities(input.format).filter
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
const outputInfo = device.getTextureFormatInfo(operation.outputDescriptor.format);
|
|
68
|
+
assert(
|
|
69
|
+
!outputInfo.integer &&
|
|
70
|
+
device.getTextureFormatCapabilities(operation.outputDescriptor.format).render
|
|
71
|
+
);
|
|
72
|
+
const shaderBindings: import('@luma.gl/core').ShaderLayout['bindings'] = [
|
|
73
|
+
...Object.keys(operation.inputs).map((name, location) => ({
|
|
74
|
+
name,
|
|
75
|
+
location,
|
|
76
|
+
group: 0,
|
|
77
|
+
type: 'texture' as const,
|
|
78
|
+
viewDimension: '2d' as const,
|
|
79
|
+
sampleType: 'float' as const
|
|
80
|
+
})),
|
|
81
|
+
...Object.keys(operation.samplers).map((name, index) => ({
|
|
82
|
+
name,
|
|
83
|
+
location: Object.keys(operation.inputs).length + index,
|
|
84
|
+
group: 0,
|
|
85
|
+
type: 'sampler' as const
|
|
86
|
+
}))
|
|
87
|
+
];
|
|
88
|
+
let binding = 0;
|
|
89
|
+
const declarations = [
|
|
90
|
+
...Object.keys(operation.inputs).map(
|
|
91
|
+
name => `@group(0) @binding(${binding++}) var ${name}: texture_2d<f32>;`
|
|
92
|
+
),
|
|
93
|
+
...Object.keys(operation.samplers).map(
|
|
94
|
+
name => `@group(0) @binding(${binding++}) var ${name}: sampler;`
|
|
95
|
+
)
|
|
96
|
+
];
|
|
97
|
+
if (this.parameterFormats.length) {
|
|
98
|
+
shaderBindings.push({name: 'parameters', location: binding, group: 0, type: 'uniform'});
|
|
99
|
+
declarations.push(
|
|
100
|
+
`struct GraphShaderPassParameters {${Object.keys(operation.parameters)
|
|
101
|
+
.map((name, index) => `${name}: ${getGPUScalarWGSLType(this.parameterFormats[index])}`)
|
|
102
|
+
.join(
|
|
103
|
+
','
|
|
104
|
+
)}};\n@group(0) @binding(${binding}) var<uniform> parameters: GraphShaderPassParameters;`
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
this.kernel = new RenderKernel(device, {
|
|
109
|
+
id: operation.id,
|
|
110
|
+
vertexSource: VERTEX_SOURCE,
|
|
111
|
+
fragmentSource: `${declarations.join('\n')}\n${operation.fragmentSource}\n
|
|
112
|
+
@fragment fn fragmentMain(@location(0) textureCoordinates: vec2<f32>) -> @location(0) vec4<f32> {
|
|
113
|
+
return shade(textureCoordinates);
|
|
114
|
+
}`,
|
|
115
|
+
vertexEntryPoint: 'vertexMain',
|
|
116
|
+
fragmentEntryPoint: 'fragmentMain',
|
|
117
|
+
topology: 'triangle-list',
|
|
118
|
+
shaderLayout: {attributes: [], bindings: shaderBindings},
|
|
119
|
+
colorAttachmentFormats: [operation.outputDescriptor.format],
|
|
120
|
+
parameters: {depthWriteEnabled: false}
|
|
121
|
+
});
|
|
122
|
+
this.vertexArray = device.createVertexArray({
|
|
123
|
+
shaderLayout: this.kernel.pipeline.shaderLayout,
|
|
124
|
+
bufferLayout: []
|
|
125
|
+
});
|
|
126
|
+
for (const [name, props] of Object.entries(operation.samplers))
|
|
127
|
+
this.samplers[name] = device.createSampler(props);
|
|
128
|
+
} catch (error) {
|
|
129
|
+
this.destroy();
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Validate selected view geometry before either executor records commands. */
|
|
135
|
+
validateTextures(textures: ReadonlyMap<string, GPUGraphTextureBinding>): void {
|
|
136
|
+
for (const name of [...Object.values(this.operation.inputs), this.operation.output]) {
|
|
137
|
+
const binding = textures.get(name);
|
|
138
|
+
assert(binding);
|
|
139
|
+
const info = getTextureBindingInfo(binding);
|
|
140
|
+
assert(
|
|
141
|
+
info.texture.device === this.device &&
|
|
142
|
+
info.dimension === '2d' &&
|
|
143
|
+
info.depth === 1 &&
|
|
144
|
+
info.samples === 1
|
|
145
|
+
);
|
|
146
|
+
if (name === this.operation.output) assert(info.mipLevels === 1);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Full graph lowers to ordinary resource-tracked copy and render nodes. */
|
|
151
|
+
lower<Parameters>(context: GPUOperationLoweringContext<Parameters>): void {
|
|
152
|
+
const operation = this.operation;
|
|
153
|
+
const inputs = Object.fromEntries(
|
|
154
|
+
Object.entries(operation.inputs).map(([name, value]) => [
|
|
155
|
+
name,
|
|
156
|
+
context.resolveTextureView(value)
|
|
157
|
+
])
|
|
158
|
+
);
|
|
159
|
+
const output = context.resolveTextureView(operation.output);
|
|
160
|
+
const parameters = this.parameterFormats.length
|
|
161
|
+
? context.graph.createTransientBuffer({
|
|
162
|
+
id: context.graph.getUniqueResourceId(`${operation.id}-parameters`),
|
|
163
|
+
byteLength: this.parameterByteLength,
|
|
164
|
+
usage: Buffer.UNIFORM | Buffer.COPY_DST
|
|
165
|
+
})
|
|
166
|
+
: undefined;
|
|
167
|
+
if (parameters) {
|
|
168
|
+
const sources = Object.values(operation.parameters).map(
|
|
169
|
+
name => context.resolveScalar(name).view
|
|
170
|
+
);
|
|
171
|
+
context.graph.addCopyPass({
|
|
172
|
+
id: `${operation.id}-parameters`,
|
|
173
|
+
resources: [
|
|
174
|
+
...sources.map(buffer => ({buffer, usage: 'copy-source' as const})),
|
|
175
|
+
{buffer: parameters, usage: 'copy-destination'}
|
|
176
|
+
],
|
|
177
|
+
compile: () => ({
|
|
178
|
+
encode: ({commandEncoder, getBuffer}) => {
|
|
179
|
+
sources.forEach((source, index) =>
|
|
180
|
+
commandEncoder.copyBufferToBuffer({
|
|
181
|
+
sourceBuffer: getBuffer(source),
|
|
182
|
+
sourceOffset: source.byteOffset,
|
|
183
|
+
destinationBuffer: getBuffer(parameters),
|
|
184
|
+
destinationOffset: index * 4,
|
|
185
|
+
size: 4
|
|
186
|
+
})
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
context.graph.addRenderPass({
|
|
193
|
+
id: operation.id,
|
|
194
|
+
resources: [
|
|
195
|
+
...Object.values(inputs).map(texture => ({texture, usage: 'sampled' as const})),
|
|
196
|
+
...(parameters ? [{buffer: parameters, usage: 'uniform' as const}] : [])
|
|
197
|
+
],
|
|
198
|
+
attachments: {colorAttachments: [output]},
|
|
199
|
+
compile: () => ({
|
|
200
|
+
getRenderPassProps: () => ({clearColor: [0, 0, 0, 0], clearDepth: false}),
|
|
201
|
+
encode: ({renderPass, getTextureView, getBuffer}) =>
|
|
202
|
+
this.draw(
|
|
203
|
+
renderPass,
|
|
204
|
+
Object.fromEntries(
|
|
205
|
+
Object.entries(inputs).map(([name, view]) => [name, getTextureView(view)])
|
|
206
|
+
),
|
|
207
|
+
parameters ? getBuffer(parameters) : undefined
|
|
208
|
+
)
|
|
209
|
+
})
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** SimpleGraph owns only per-invocation framebuffer/uniform wrappers, never bound textures. */
|
|
214
|
+
prepare(
|
|
215
|
+
textures: ReadonlyMap<string, GPUGraphTextureBinding>,
|
|
216
|
+
values: ReadonlyMap<string, GPUVector | number>
|
|
217
|
+
) {
|
|
218
|
+
this.validateTextures(textures);
|
|
219
|
+
const inputs = Object.fromEntries(
|
|
220
|
+
Object.entries(this.operation.inputs).map(([name, value]) => [name, textures.get(value)!])
|
|
221
|
+
);
|
|
222
|
+
const output = textures.get(this.operation.output)!;
|
|
223
|
+
const info = getTextureBindingInfo(output);
|
|
224
|
+
const data = new Uint8Array(this.parameterByteLength);
|
|
225
|
+
const view = new DataView(data.buffer);
|
|
226
|
+
const parameterValues = Object.values(this.operation.parameters).map((name, index) => {
|
|
227
|
+
const value = values.get(name);
|
|
228
|
+
assert(value !== undefined);
|
|
229
|
+
if (typeof value === 'number') {
|
|
230
|
+
switch (this.parameterFormats[index]) {
|
|
231
|
+
case 'float32':
|
|
232
|
+
view.setFloat32(index * 4, value, true);
|
|
233
|
+
break;
|
|
234
|
+
case 'sint32':
|
|
235
|
+
view.setInt32(index * 4, value, true);
|
|
236
|
+
break;
|
|
237
|
+
case 'uint32':
|
|
238
|
+
view.setUint32(index * 4, value, true);
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
} else assert(value.length === 1 && value.data.length === 1);
|
|
242
|
+
return value;
|
|
243
|
+
});
|
|
244
|
+
const parameters = data.byteLength
|
|
245
|
+
? this.device.createBuffer({data, usage: Buffer.UNIFORM | Buffer.COPY_DST})
|
|
246
|
+
: undefined;
|
|
247
|
+
let framebuffer;
|
|
248
|
+
try {
|
|
249
|
+
framebuffer = this.device.createFramebuffer({
|
|
250
|
+
width: info.width,
|
|
251
|
+
height: info.height,
|
|
252
|
+
colorAttachments: [output]
|
|
253
|
+
});
|
|
254
|
+
} catch (error) {
|
|
255
|
+
parameters?.destroy();
|
|
256
|
+
throw error;
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
encode: (commandEncoder: CommandEncoder) => {
|
|
260
|
+
this.validateTextures(textures);
|
|
261
|
+
if (parameters)
|
|
262
|
+
parameterValues.forEach((value, index) => {
|
|
263
|
+
if (!(value instanceof GPUVector)) return;
|
|
264
|
+
const chunk = value.data[0];
|
|
265
|
+
const buffer = chunk.buffer instanceof Buffer ? chunk.buffer : chunk.buffer.buffer;
|
|
266
|
+
commandEncoder.copyBufferToBuffer({
|
|
267
|
+
sourceBuffer: buffer,
|
|
268
|
+
sourceOffset: chunk.byteOffset,
|
|
269
|
+
destinationBuffer: parameters,
|
|
270
|
+
destinationOffset: index * 4,
|
|
271
|
+
size: 4
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
const pass = commandEncoder.beginRenderPass({
|
|
275
|
+
framebuffer,
|
|
276
|
+
clearColor: [0, 0, 0, 0],
|
|
277
|
+
clearDepth: false
|
|
278
|
+
});
|
|
279
|
+
try {
|
|
280
|
+
this.draw(pass, inputs, parameters);
|
|
281
|
+
} finally {
|
|
282
|
+
pass.end();
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
destroy: () => {
|
|
286
|
+
framebuffer.destroy();
|
|
287
|
+
parameters?.destroy();
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
destroy(): void {
|
|
293
|
+
for (const sampler of Object.values(this.samplers)) sampler.destroy();
|
|
294
|
+
this.vertexArray?.destroy();
|
|
295
|
+
this.kernel?.destroy();
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
private draw(
|
|
299
|
+
renderPass: RenderPass,
|
|
300
|
+
inputs: Record<string, GPUGraphTextureBinding>,
|
|
301
|
+
parameters?: Buffer
|
|
302
|
+
): void {
|
|
303
|
+
const bindings: Record<string, Binding> = {...inputs, ...this.samplers};
|
|
304
|
+
if (parameters) bindings['parameters'] = parameters;
|
|
305
|
+
this.kernel.draw(renderPass, {vertexArray: this.vertexArray, vertexCount: 3, bindings});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {assert, type SamplerProps, type TextureFormatColor} from '@luma.gl/core';
|
|
6
|
+
import {gpuGraph, type GPUGraphTextureDescriptor} from './gpu-graph-value';
|
|
7
|
+
import type {GPUOperation} from './gpu-operation';
|
|
8
|
+
import type {GPUOperationContract} from './gpu-operation-contract';
|
|
9
|
+
|
|
10
|
+
export type GPUShaderPassOperationProps = {
|
|
11
|
+
id?: string;
|
|
12
|
+
/** WGSL defining fn shade(textureCoordinates: vec2<f32>) -> vec4<f32>. */
|
|
13
|
+
fragmentSource: string;
|
|
14
|
+
/** Shader texture binding names mapped to logical graph texture names. */
|
|
15
|
+
inputs: Readonly<Record<string, string>>;
|
|
16
|
+
/** Explicit, immutable color sampler descriptions, keyed by shader binding name. */
|
|
17
|
+
samplers?: Readonly<Record<string, SamplerProps>>;
|
|
18
|
+
/** Fields of the generated parameters uniform, mapped to graph scalar names. */
|
|
19
|
+
parameters?: Readonly<Record<string, string>>;
|
|
20
|
+
output: string;
|
|
21
|
+
/** Single-sampled 2D color result with an explicit fixed or inherited extent. */
|
|
22
|
+
outputDescriptor: GPUGraphTextureDescriptor<TextureFormatColor>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** One fullscreen WGSL draw, shared by GPUGraph and WebGPU SimpleGraph. */
|
|
26
|
+
export class GPUShaderPassOperation implements GPUOperation {
|
|
27
|
+
readonly type = 'shader-pass';
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly fragmentSource: string;
|
|
30
|
+
readonly inputs: Readonly<Record<string, string>>;
|
|
31
|
+
readonly samplers: Readonly<Record<string, Readonly<SamplerProps>>>;
|
|
32
|
+
readonly parameters: Readonly<Record<string, string>>;
|
|
33
|
+
readonly output: string;
|
|
34
|
+
readonly outputDescriptor: GPUGraphTextureDescriptor<TextureFormatColor>;
|
|
35
|
+
|
|
36
|
+
constructor(props: GPUShaderPassOperationProps) {
|
|
37
|
+
this.id = props.id ?? `${props.output}-shader-pass`;
|
|
38
|
+
this.fragmentSource = props.fragmentSource;
|
|
39
|
+
this.inputs = Object.freeze({...props.inputs});
|
|
40
|
+
this.parameters = Object.freeze({...props.parameters});
|
|
41
|
+
this.samplers = Object.freeze(
|
|
42
|
+
Object.fromEntries(
|
|
43
|
+
Object.entries(props.samplers ?? {}).map(([name, sampler]) => [
|
|
44
|
+
name,
|
|
45
|
+
Object.freeze({...sampler})
|
|
46
|
+
])
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
this.output = props.output;
|
|
50
|
+
const descriptor = props.outputDescriptor;
|
|
51
|
+
// This operation writes one complete 2D color attachment, without mip generation or MSAA.
|
|
52
|
+
assert(
|
|
53
|
+
descriptor.extent &&
|
|
54
|
+
(descriptor.dimension ?? '2d') === '2d' &&
|
|
55
|
+
(descriptor.mipLevels ?? 1) === 1 &&
|
|
56
|
+
(descriptor.samples ?? 1) === 1
|
|
57
|
+
);
|
|
58
|
+
this.outputDescriptor = gpuGraph.texture({
|
|
59
|
+
...descriptor,
|
|
60
|
+
dimension: '2d',
|
|
61
|
+
mipLevels: 1,
|
|
62
|
+
samples: 1
|
|
63
|
+
});
|
|
64
|
+
const bindings = [...Object.keys(this.inputs), ...Object.keys(this.samplers)];
|
|
65
|
+
// Binding names are WGSL identifiers; reserve the generated uniform and entry-point names.
|
|
66
|
+
assert(new Set(bindings).size === bindings.length);
|
|
67
|
+
for (const name of [...bindings, ...Object.keys(this.parameters)])
|
|
68
|
+
assert(
|
|
69
|
+
/^[A-Za-z][A-Za-z0-9_]*$/.test(name) &&
|
|
70
|
+
!['parameters', 'shade', 'vertexMain', 'fragmentMain'].includes(name) &&
|
|
71
|
+
!name.startsWith('GraphShaderPass')
|
|
72
|
+
);
|
|
73
|
+
for (const sampler of Object.values(this.samplers))
|
|
74
|
+
assert((sampler.type ?? 'color-sampler') === 'color-sampler');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
get contract(): GPUOperationContract {
|
|
78
|
+
return {
|
|
79
|
+
values: [
|
|
80
|
+
...Object.values(this.inputs).map(value => ({
|
|
81
|
+
value,
|
|
82
|
+
access: 'read' as const,
|
|
83
|
+
textureUsage: 'sampled' as const
|
|
84
|
+
})),
|
|
85
|
+
...Object.values(this.parameters).map(value => ({value, access: 'read' as const})),
|
|
86
|
+
{value: this.output, access: 'write', textureUsage: 'render-attachment'}
|
|
87
|
+
],
|
|
88
|
+
outputs: ({getValue}) => {
|
|
89
|
+
for (const name of Object.values(this.inputs)) {
|
|
90
|
+
const input = getValue(name);
|
|
91
|
+
// Texture views may select one layer of an array, but the logical input is 2D.
|
|
92
|
+
assert(
|
|
93
|
+
input.type === 'texture' &&
|
|
94
|
+
(input.dimension ?? '2d') === '2d' &&
|
|
95
|
+
(input.samples ?? 1) === 1
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
for (const name of Object.values(this.parameters)) assert(getValue(name).type === 'scalar');
|
|
99
|
+
return {[this.output]: this.outputDescriptor};
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
package/src/gpu-core/index.ts
CHANGED
|
@@ -686,6 +686,8 @@ export type {
|
|
|
686
686
|
} from './gpu-operation-contract';
|
|
687
687
|
|
|
688
688
|
export {GPUUploadOperation, GPUCopyOperation} from './gpu-transfer-operation';
|
|
689
|
+
export {GPUShaderPassOperation} from './gpu-shader-pass-operation';
|
|
690
|
+
export type {GPUShaderPassOperationProps} from './gpu-shader-pass-operation';
|
|
689
691
|
export type {GPUUploadOperationProps, GPUCopyOperationProps} from './gpu-transfer-operation';
|
|
690
692
|
export {GPUCompactionOperation} from './gpu-compaction-operation';
|
|
691
693
|
export type {GPUCompactionOperationProps} from './gpu-compaction-operation';
|