@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.
Files changed (60) hide show
  1. package/dist/dist.dev.js +658 -292
  2. package/dist/dist.min.js +110 -92
  3. package/dist/experimental/index.cjs.map +1 -1
  4. package/dist/experimental/simulation/index.cjs.map +1 -1
  5. package/dist/gpu-core/compiled-gpu-graph.cjs +15 -0
  6. package/dist/gpu-core/compiled-gpu-graph.d.ts +1 -0
  7. package/dist/gpu-core/compiled-gpu-graph.d.ts.map +1 -1
  8. package/dist/gpu-core/compiled-gpu-graph.js +15 -0
  9. package/dist/gpu-core/compiled-gpu-graph.js.map +1 -1
  10. package/dist/gpu-core/gpu-command-graph.cjs +9 -0
  11. package/dist/gpu-core/gpu-command-graph.d.ts +2 -0
  12. package/dist/gpu-core/gpu-command-graph.d.ts.map +1 -1
  13. package/dist/gpu-core/gpu-command-graph.js +9 -0
  14. package/dist/gpu-core/gpu-command-graph.js.map +1 -1
  15. package/dist/gpu-core/gpu-expression-plan.cjs +4 -0
  16. package/dist/gpu-core/gpu-expression-plan.d.ts.map +1 -1
  17. package/dist/gpu-core/gpu-expression-plan.js +5 -0
  18. package/dist/gpu-core/gpu-expression-plan.js.map +1 -1
  19. package/dist/gpu-core/gpu-shader-pass-kernel.cjs +267 -0
  20. package/dist/gpu-core/gpu-shader-pass-kernel.d.ts +29 -0
  21. package/dist/gpu-core/gpu-shader-pass-kernel.d.ts.map +1 -0
  22. package/dist/gpu-core/gpu-shader-pass-kernel.js +260 -0
  23. package/dist/gpu-core/gpu-shader-pass-kernel.js.map +1 -0
  24. package/dist/gpu-core/gpu-shader-pass-operation.cjs +85 -0
  25. package/dist/gpu-core/gpu-shader-pass-operation.d.ts +32 -0
  26. package/dist/gpu-core/gpu-shader-pass-operation.d.ts.map +1 -0
  27. package/dist/gpu-core/gpu-shader-pass-operation.js +74 -0
  28. package/dist/gpu-core/gpu-shader-pass-operation.js.map +1 -0
  29. package/dist/gpu-core/index.cjs +3 -0
  30. package/dist/gpu-core/index.cjs.map +3 -3
  31. package/dist/gpu-core/index.d.ts +2 -0
  32. package/dist/gpu-core/index.d.ts.map +1 -1
  33. package/dist/gpu-core/index.js +1 -0
  34. package/dist/gpu-core/index.js.map +1 -1
  35. package/dist/gpu-dggs/benchmarks.cjs.map +1 -1
  36. package/dist/gpu-graph/index.cjs.map +3 -3
  37. package/dist/gpu-graph-algorithms/benchmarks.cjs.map +1 -1
  38. package/dist/gpu-physics/index.cjs.map +1 -1
  39. package/dist/gpu-project/graph.cjs.map +3 -3
  40. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.cjs +53 -5
  41. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts +3 -1
  42. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts.map +1 -1
  43. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js +58 -5
  44. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js.map +1 -1
  45. package/dist/gpu-simple-graph/index.cjs.map +3 -3
  46. package/dist/index.cjs +3 -0
  47. package/dist/index.cjs.map +3 -3
  48. package/dist/index.d.ts +2 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +1 -0
  51. package/dist/index.js.map +1 -1
  52. package/package.json +7 -7
  53. package/src/gpu-core/compiled-gpu-graph.ts +18 -0
  54. package/src/gpu-core/gpu-command-graph.ts +10 -0
  55. package/src/gpu-core/gpu-expression-plan.ts +6 -0
  56. package/src/gpu-core/gpu-shader-pass-kernel.ts +307 -0
  57. package/src/gpu-core/gpu-shader-pass-operation.ts +103 -0
  58. package/src/gpu-core/index.ts +2 -0
  59. package/src/gpu-simple-graph/compiled-gpu-expression-graph.ts +59 -5
  60. package/src/index.ts +2 -0
@@ -0,0 +1,260 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { assert, Buffer } from '@luma.gl/core';
5
+ import { GPUVector } from '@luma.gl/graph/gpu-data';
6
+ import { RenderKernel } from "../execution/compute/render-kernel.js";
7
+ import { getGPUScalarWGSLType } from "./gpu-scalar.js";
8
+ import { getTextureBindingInfo } from "./gpu-texture-plan.js";
9
+ const VERTEX_SOURCE = `
10
+ struct GraphShaderPassVertex {
11
+ @builtin(position) position: vec4<f32>,
12
+ @location(0) textureCoordinates: vec2<f32>
13
+ };
14
+ @vertex fn vertexMain(@builtin(vertex_index) index: u32) -> GraphShaderPassVertex {
15
+ let position = vec2<f32>(f32((index << 1u) & 2u), f32(index & 2u));
16
+ var result: GraphShaderPassVertex;
17
+ result.position = vec4<f32>(position * 2.0 - 1.0, 0.0, 1.0);
18
+ result.textureCoordinates = vec2<f32>(position.x, 1.0 - position.y);
19
+ return result;
20
+ }`;
21
+ /** One immutable pipeline; resources and uniforms are supplied independently for each draw. @internal */
22
+ export class GPUShaderPassKernel {
23
+ device;
24
+ operation;
25
+ kernel;
26
+ vertexArray;
27
+ samplers = Object.create(null);
28
+ parameterFormats;
29
+ parameterByteLength;
30
+ constructor(device, operation, program) {
31
+ this.device = device;
32
+ this.operation = operation;
33
+ assert(device.type === 'webgpu');
34
+ this.parameterFormats = Object.values(operation.parameters).map(name => {
35
+ const scalar = program.scalars.find(value => value.id === name);
36
+ assert(scalar);
37
+ return scalar.format;
38
+ });
39
+ this.parameterByteLength = Math.ceil(this.parameterFormats.length / 4) * 16;
40
+ // This first shader-pass contract samples filterable float color and writes float color.
41
+ for (const name of Object.values(operation.inputs)) {
42
+ const input = program.textures.find(texture => texture.id === name);
43
+ const info = device.getTextureFormatInfo(input.format);
44
+ assert(!info.integer &&
45
+ info.attachment !== 'depth' &&
46
+ info.attachment !== 'depth-stencil' &&
47
+ device.getTextureFormatCapabilities(input.format).filter);
48
+ }
49
+ const outputInfo = device.getTextureFormatInfo(operation.outputDescriptor.format);
50
+ assert(!outputInfo.integer &&
51
+ device.getTextureFormatCapabilities(operation.outputDescriptor.format).render);
52
+ const shaderBindings = [
53
+ ...Object.keys(operation.inputs).map((name, location) => ({
54
+ name,
55
+ location,
56
+ group: 0,
57
+ type: 'texture',
58
+ viewDimension: '2d',
59
+ sampleType: 'float'
60
+ })),
61
+ ...Object.keys(operation.samplers).map((name, index) => ({
62
+ name,
63
+ location: Object.keys(operation.inputs).length + index,
64
+ group: 0,
65
+ type: 'sampler'
66
+ }))
67
+ ];
68
+ let binding = 0;
69
+ const declarations = [
70
+ ...Object.keys(operation.inputs).map(name => `@group(0) @binding(${binding++}) var ${name}: texture_2d<f32>;`),
71
+ ...Object.keys(operation.samplers).map(name => `@group(0) @binding(${binding++}) var ${name}: sampler;`)
72
+ ];
73
+ if (this.parameterFormats.length) {
74
+ shaderBindings.push({ name: 'parameters', location: binding, group: 0, type: 'uniform' });
75
+ declarations.push(`struct GraphShaderPassParameters {${Object.keys(operation.parameters)
76
+ .map((name, index) => `${name}: ${getGPUScalarWGSLType(this.parameterFormats[index])}`)
77
+ .join(',')}};\n@group(0) @binding(${binding}) var<uniform> parameters: GraphShaderPassParameters;`);
78
+ }
79
+ try {
80
+ this.kernel = new RenderKernel(device, {
81
+ id: operation.id,
82
+ vertexSource: VERTEX_SOURCE,
83
+ fragmentSource: `${declarations.join('\n')}\n${operation.fragmentSource}\n
84
+ @fragment fn fragmentMain(@location(0) textureCoordinates: vec2<f32>) -> @location(0) vec4<f32> {
85
+ return shade(textureCoordinates);
86
+ }`,
87
+ vertexEntryPoint: 'vertexMain',
88
+ fragmentEntryPoint: 'fragmentMain',
89
+ topology: 'triangle-list',
90
+ shaderLayout: { attributes: [], bindings: shaderBindings },
91
+ colorAttachmentFormats: [operation.outputDescriptor.format],
92
+ parameters: { depthWriteEnabled: false }
93
+ });
94
+ this.vertexArray = device.createVertexArray({
95
+ shaderLayout: this.kernel.pipeline.shaderLayout,
96
+ bufferLayout: []
97
+ });
98
+ for (const [name, props] of Object.entries(operation.samplers))
99
+ this.samplers[name] = device.createSampler(props);
100
+ }
101
+ catch (error) {
102
+ this.destroy();
103
+ throw error;
104
+ }
105
+ }
106
+ /** Validate selected view geometry before either executor records commands. */
107
+ validateTextures(textures) {
108
+ for (const name of [...Object.values(this.operation.inputs), this.operation.output]) {
109
+ const binding = textures.get(name);
110
+ assert(binding);
111
+ const info = getTextureBindingInfo(binding);
112
+ assert(info.texture.device === this.device &&
113
+ info.dimension === '2d' &&
114
+ info.depth === 1 &&
115
+ info.samples === 1);
116
+ if (name === this.operation.output)
117
+ assert(info.mipLevels === 1);
118
+ }
119
+ }
120
+ /** Full graph lowers to ordinary resource-tracked copy and render nodes. */
121
+ lower(context) {
122
+ const operation = this.operation;
123
+ const inputs = Object.fromEntries(Object.entries(operation.inputs).map(([name, value]) => [
124
+ name,
125
+ context.resolveTextureView(value)
126
+ ]));
127
+ const output = context.resolveTextureView(operation.output);
128
+ const parameters = this.parameterFormats.length
129
+ ? context.graph.createTransientBuffer({
130
+ id: context.graph.getUniqueResourceId(`${operation.id}-parameters`),
131
+ byteLength: this.parameterByteLength,
132
+ usage: Buffer.UNIFORM | Buffer.COPY_DST
133
+ })
134
+ : undefined;
135
+ if (parameters) {
136
+ const sources = Object.values(operation.parameters).map(name => context.resolveScalar(name).view);
137
+ context.graph.addCopyPass({
138
+ id: `${operation.id}-parameters`,
139
+ resources: [
140
+ ...sources.map(buffer => ({ buffer, usage: 'copy-source' })),
141
+ { buffer: parameters, usage: 'copy-destination' }
142
+ ],
143
+ compile: () => ({
144
+ encode: ({ commandEncoder, getBuffer }) => {
145
+ sources.forEach((source, index) => commandEncoder.copyBufferToBuffer({
146
+ sourceBuffer: getBuffer(source),
147
+ sourceOffset: source.byteOffset,
148
+ destinationBuffer: getBuffer(parameters),
149
+ destinationOffset: index * 4,
150
+ size: 4
151
+ }));
152
+ }
153
+ })
154
+ });
155
+ }
156
+ context.graph.addRenderPass({
157
+ id: operation.id,
158
+ resources: [
159
+ ...Object.values(inputs).map(texture => ({ texture, usage: 'sampled' })),
160
+ ...(parameters ? [{ buffer: parameters, usage: 'uniform' }] : [])
161
+ ],
162
+ attachments: { colorAttachments: [output] },
163
+ compile: () => ({
164
+ getRenderPassProps: () => ({ clearColor: [0, 0, 0, 0], clearDepth: false }),
165
+ encode: ({ renderPass, getTextureView, getBuffer }) => this.draw(renderPass, Object.fromEntries(Object.entries(inputs).map(([name, view]) => [name, getTextureView(view)])), parameters ? getBuffer(parameters) : undefined)
166
+ })
167
+ });
168
+ }
169
+ /** SimpleGraph owns only per-invocation framebuffer/uniform wrappers, never bound textures. */
170
+ prepare(textures, values) {
171
+ this.validateTextures(textures);
172
+ const inputs = Object.fromEntries(Object.entries(this.operation.inputs).map(([name, value]) => [name, textures.get(value)]));
173
+ const output = textures.get(this.operation.output);
174
+ const info = getTextureBindingInfo(output);
175
+ const data = new Uint8Array(this.parameterByteLength);
176
+ const view = new DataView(data.buffer);
177
+ const parameterValues = Object.values(this.operation.parameters).map((name, index) => {
178
+ const value = values.get(name);
179
+ assert(value !== undefined);
180
+ if (typeof value === 'number') {
181
+ switch (this.parameterFormats[index]) {
182
+ case 'float32':
183
+ view.setFloat32(index * 4, value, true);
184
+ break;
185
+ case 'sint32':
186
+ view.setInt32(index * 4, value, true);
187
+ break;
188
+ case 'uint32':
189
+ view.setUint32(index * 4, value, true);
190
+ break;
191
+ }
192
+ }
193
+ else
194
+ assert(value.length === 1 && value.data.length === 1);
195
+ return value;
196
+ });
197
+ const parameters = data.byteLength
198
+ ? this.device.createBuffer({ data, usage: Buffer.UNIFORM | Buffer.COPY_DST })
199
+ : undefined;
200
+ let framebuffer;
201
+ try {
202
+ framebuffer = this.device.createFramebuffer({
203
+ width: info.width,
204
+ height: info.height,
205
+ colorAttachments: [output]
206
+ });
207
+ }
208
+ catch (error) {
209
+ parameters?.destroy();
210
+ throw error;
211
+ }
212
+ return {
213
+ encode: (commandEncoder) => {
214
+ this.validateTextures(textures);
215
+ if (parameters)
216
+ parameterValues.forEach((value, index) => {
217
+ if (!(value instanceof GPUVector))
218
+ return;
219
+ const chunk = value.data[0];
220
+ const buffer = chunk.buffer instanceof Buffer ? chunk.buffer : chunk.buffer.buffer;
221
+ commandEncoder.copyBufferToBuffer({
222
+ sourceBuffer: buffer,
223
+ sourceOffset: chunk.byteOffset,
224
+ destinationBuffer: parameters,
225
+ destinationOffset: index * 4,
226
+ size: 4
227
+ });
228
+ });
229
+ const pass = commandEncoder.beginRenderPass({
230
+ framebuffer,
231
+ clearColor: [0, 0, 0, 0],
232
+ clearDepth: false
233
+ });
234
+ try {
235
+ this.draw(pass, inputs, parameters);
236
+ }
237
+ finally {
238
+ pass.end();
239
+ }
240
+ },
241
+ destroy: () => {
242
+ framebuffer.destroy();
243
+ parameters?.destroy();
244
+ }
245
+ };
246
+ }
247
+ destroy() {
248
+ for (const sampler of Object.values(this.samplers))
249
+ sampler.destroy();
250
+ this.vertexArray?.destroy();
251
+ this.kernel?.destroy();
252
+ }
253
+ draw(renderPass, inputs, parameters) {
254
+ const bindings = { ...inputs, ...this.samplers };
255
+ if (parameters)
256
+ bindings['parameters'] = parameters;
257
+ this.kernel.draw(renderPass, { vertexArray: this.vertexArray, vertexCount: 3, bindings });
258
+ }
259
+ }
260
+ //# sourceMappingURL=gpu-shader-pass-kernel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpu-shader-pass-kernel.js","sourceRoot":"","sources":["../../src/gpu-core/gpu-shader-pass-kernel.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EACL,MAAM,EACN,MAAM,EAOP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAC,YAAY,EAAC,8CAA2C;AAIhE,OAAO,EAAC,oBAAoB,EAAC,wBAAqB;AAClD,OAAO,EAAC,qBAAqB,EAA8B,8BAA2B;AAEtF,MAAM,aAAa,GAAG;;;;;;;;;;;EAWpB,CAAC;AA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EAAE,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;IACzB,CAAC;IAEO,IAAI,CACV,UAAsB,EACtB,MAA8C,EAC9C,UAAmB;QAEnB,MAAM,QAAQ,GAA4B,EAAC,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAC,CAAC;QACxE,IAAI,UAAU;YAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,UAAU,CAAC;QACpD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,EAAC,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,CAAC,EAAE,QAAQ,EAAC,CAAC,CAAC;IAC1F,CAAC;CACF"}
@@ -0,0 +1,85 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var gpu_shader_pass_operation_exports = {};
19
+ __export(gpu_shader_pass_operation_exports, {
20
+ GPUShaderPassOperation: () => GPUShaderPassOperation
21
+ });
22
+ module.exports = __toCommonJS(gpu_shader_pass_operation_exports);
23
+ var import_core = require("@luma.gl/core");
24
+ var import_gpu_graph_value = require("./gpu-graph-value.cjs");
25
+ class GPUShaderPassOperation {
26
+ type = "shader-pass";
27
+ id;
28
+ fragmentSource;
29
+ inputs;
30
+ samplers;
31
+ parameters;
32
+ output;
33
+ outputDescriptor;
34
+ constructor(props) {
35
+ this.id = props.id ?? `${props.output}-shader-pass`;
36
+ this.fragmentSource = props.fragmentSource;
37
+ this.inputs = Object.freeze({ ...props.inputs });
38
+ this.parameters = Object.freeze({ ...props.parameters });
39
+ this.samplers = Object.freeze(Object.fromEntries(Object.entries(props.samplers ?? {}).map(([name, sampler]) => [
40
+ name,
41
+ Object.freeze({ ...sampler })
42
+ ])));
43
+ this.output = props.output;
44
+ const descriptor = props.outputDescriptor;
45
+ (0, import_core.assert)(descriptor.extent && (descriptor.dimension ?? "2d") === "2d" && (descriptor.mipLevels ?? 1) === 1 && (descriptor.samples ?? 1) === 1);
46
+ this.outputDescriptor = import_gpu_graph_value.gpuGraph.texture({
47
+ ...descriptor,
48
+ dimension: "2d",
49
+ mipLevels: 1,
50
+ samples: 1
51
+ });
52
+ const bindings = [...Object.keys(this.inputs), ...Object.keys(this.samplers)];
53
+ (0, import_core.assert)(new Set(bindings).size === bindings.length);
54
+ for (const name of [...bindings, ...Object.keys(this.parameters)])
55
+ (0, import_core.assert)(/^[A-Za-z][A-Za-z0-9_]*$/.test(name) && !["parameters", "shade", "vertexMain", "fragmentMain"].includes(name) && !name.startsWith("GraphShaderPass"));
56
+ for (const sampler of Object.values(this.samplers))
57
+ (0, import_core.assert)((sampler.type ?? "color-sampler") === "color-sampler");
58
+ }
59
+ get contract() {
60
+ return {
61
+ values: [
62
+ ...Object.values(this.inputs).map((value) => ({
63
+ value,
64
+ access: "read",
65
+ textureUsage: "sampled"
66
+ })),
67
+ ...Object.values(this.parameters).map((value) => ({ value, access: "read" })),
68
+ { value: this.output, access: "write", textureUsage: "render-attachment" }
69
+ ],
70
+ outputs: ({ getValue }) => {
71
+ for (const name of Object.values(this.inputs)) {
72
+ const input = getValue(name);
73
+ (0, import_core.assert)(input.type === "texture" && (input.dimension ?? "2d") === "2d" && (input.samples ?? 1) === 1);
74
+ }
75
+ for (const name of Object.values(this.parameters))
76
+ (0, import_core.assert)(getValue(name).type === "scalar");
77
+ return { [this.output]: this.outputDescriptor };
78
+ }
79
+ };
80
+ }
81
+ }
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ GPUShaderPassOperation
85
+ });
@@ -0,0 +1,32 @@
1
+ import { type SamplerProps, type TextureFormatColor } from '@luma.gl/core';
2
+ import { type GPUGraphTextureDescriptor } from "./gpu-graph-value.js";
3
+ import type { GPUOperation } from "./gpu-operation.js";
4
+ import type { GPUOperationContract } from "./gpu-operation-contract.js";
5
+ export type GPUShaderPassOperationProps = {
6
+ id?: string;
7
+ /** WGSL defining fn shade(textureCoordinates: vec2<f32>) -> vec4<f32>. */
8
+ fragmentSource: string;
9
+ /** Shader texture binding names mapped to logical graph texture names. */
10
+ inputs: Readonly<Record<string, string>>;
11
+ /** Explicit, immutable color sampler descriptions, keyed by shader binding name. */
12
+ samplers?: Readonly<Record<string, SamplerProps>>;
13
+ /** Fields of the generated parameters uniform, mapped to graph scalar names. */
14
+ parameters?: Readonly<Record<string, string>>;
15
+ output: string;
16
+ /** Single-sampled 2D color result with an explicit fixed or inherited extent. */
17
+ outputDescriptor: GPUGraphTextureDescriptor<TextureFormatColor>;
18
+ };
19
+ /** One fullscreen WGSL draw, shared by GPUGraph and WebGPU SimpleGraph. */
20
+ export declare class GPUShaderPassOperation implements GPUOperation {
21
+ readonly type = "shader-pass";
22
+ readonly id: string;
23
+ readonly fragmentSource: string;
24
+ readonly inputs: Readonly<Record<string, string>>;
25
+ readonly samplers: Readonly<Record<string, Readonly<SamplerProps>>>;
26
+ readonly parameters: Readonly<Record<string, string>>;
27
+ readonly output: string;
28
+ readonly outputDescriptor: GPUGraphTextureDescriptor<TextureFormatColor>;
29
+ constructor(props: GPUShaderPassOperationProps);
30
+ get contract(): GPUOperationContract;
31
+ }
32
+ //# sourceMappingURL=gpu-shader-pass-operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"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QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,gBAAgB,EAAE,yBAAyB,CAAC,kBAAkB,CAAC,CAAC;gBAE7D,KAAK,EAAE,2BAA2B;IAyC9C,IAAI,QAAQ,IAAI,oBAAoB,CAyBnC;CACF"}
@@ -0,0 +1,74 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { assert } from '@luma.gl/core';
5
+ import { gpuGraph } from "./gpu-graph-value.js";
6
+ /** One fullscreen WGSL draw, shared by GPUGraph and WebGPU SimpleGraph. */
7
+ export class GPUShaderPassOperation {
8
+ type = 'shader-pass';
9
+ id;
10
+ fragmentSource;
11
+ inputs;
12
+ samplers;
13
+ parameters;
14
+ output;
15
+ outputDescriptor;
16
+ constructor(props) {
17
+ this.id = props.id ?? `${props.output}-shader-pass`;
18
+ this.fragmentSource = props.fragmentSource;
19
+ this.inputs = Object.freeze({ ...props.inputs });
20
+ this.parameters = Object.freeze({ ...props.parameters });
21
+ this.samplers = Object.freeze(Object.fromEntries(Object.entries(props.samplers ?? {}).map(([name, sampler]) => [
22
+ name,
23
+ Object.freeze({ ...sampler })
24
+ ])));
25
+ this.output = props.output;
26
+ const descriptor = props.outputDescriptor;
27
+ // This operation writes one complete 2D color attachment, without mip generation or MSAA.
28
+ assert(descriptor.extent &&
29
+ (descriptor.dimension ?? '2d') === '2d' &&
30
+ (descriptor.mipLevels ?? 1) === 1 &&
31
+ (descriptor.samples ?? 1) === 1);
32
+ this.outputDescriptor = gpuGraph.texture({
33
+ ...descriptor,
34
+ dimension: '2d',
35
+ mipLevels: 1,
36
+ samples: 1
37
+ });
38
+ const bindings = [...Object.keys(this.inputs), ...Object.keys(this.samplers)];
39
+ // Binding names are WGSL identifiers; reserve the generated uniform and entry-point names.
40
+ assert(new Set(bindings).size === bindings.length);
41
+ for (const name of [...bindings, ...Object.keys(this.parameters)])
42
+ assert(/^[A-Za-z][A-Za-z0-9_]*$/.test(name) &&
43
+ !['parameters', 'shade', 'vertexMain', 'fragmentMain'].includes(name) &&
44
+ !name.startsWith('GraphShaderPass'));
45
+ for (const sampler of Object.values(this.samplers))
46
+ assert((sampler.type ?? 'color-sampler') === 'color-sampler');
47
+ }
48
+ get contract() {
49
+ return {
50
+ values: [
51
+ ...Object.values(this.inputs).map(value => ({
52
+ value,
53
+ access: 'read',
54
+ textureUsage: 'sampled'
55
+ })),
56
+ ...Object.values(this.parameters).map(value => ({ value, access: 'read' })),
57
+ { value: this.output, access: 'write', textureUsage: 'render-attachment' }
58
+ ],
59
+ outputs: ({ getValue }) => {
60
+ for (const name of Object.values(this.inputs)) {
61
+ const input = getValue(name);
62
+ // Texture views may select one layer of an array, but the logical input is 2D.
63
+ assert(input.type === 'texture' &&
64
+ (input.dimension ?? '2d') === '2d' &&
65
+ (input.samples ?? 1) === 1);
66
+ }
67
+ for (const name of Object.values(this.parameters))
68
+ assert(getValue(name).type === 'scalar');
69
+ return { [this.output]: this.outputDescriptor };
70
+ }
71
+ };
72
+ }
73
+ }
74
+ //# sourceMappingURL=gpu-shader-pass-operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpu-shader-pass-operation.js","sourceRoot":"","sources":["../../src/gpu-core/gpu-shader-pass-operation.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,MAAM,EAA6C,MAAM,eAAe,CAAC;AACjF,OAAO,EAAC,QAAQ,EAAiC,6BAA0B;AAmB3E,2EAA2E;AAC3E,MAAM,OAAO,sBAAsB;IACxB,IAAI,GAAG,aAAa,CAAC;IACrB,EAAE,CAAS;IACX,cAAc,CAAS;IACvB,MAAM,CAAmC;IACzC,QAAQ,CAAmD;IAC3D,UAAU,CAAmC;IAC7C,MAAM,CAAS;IACf,gBAAgB,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,YAAY,EAAE,mBAAmB,EAAC;aACzE;YACD,OAAO,EAAE,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAE;gBACtB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC9C,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;oBAC7B,+EAA+E;oBAC/E,MAAM,CACJ,KAAK,CAAC,IAAI,KAAK,SAAS;wBACtB,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,KAAK,IAAI;wBAClC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,KAAK,CAAC,CAC7B,CAAC;gBACJ,CAAC;gBACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;oBAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;gBAC5F,OAAO,EAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAC,CAAC;YAChD,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -100,6 +100,7 @@ __export(gpu_core_exports, {
100
100
  GPUSegmentedBVH: () => import_gpu_segmented_bvh.GPUSegmentedBVH,
101
101
  GPUSegmentedLayout: () => import_gpu_segmented_layout.GPUSegmentedLayout,
102
102
  GPUSegmentedSort: () => import_gpu_segmented_sort.GPUSegmentedSort,
103
+ GPUShaderPassOperation: () => import_gpu_shader_pass_operation.GPUShaderPassOperation,
103
104
  GPUSort: () => import_gpu_sort.GPUSort,
104
105
  GPUTextSelection: () => import_gpu_text_selection.GPUTextSelection,
105
106
  GPUTextureHistory: () => import_gpu_texture_history.GPUTextureHistory,
@@ -289,6 +290,7 @@ var import_gpu_expression_operation = require("./gpu-expression-operation.cjs");
289
290
  var import_compiled_gpu_graph = require("./compiled-gpu-graph.cjs");
290
291
  var import_gpu_graph_value2 = require("./gpu-graph-value.cjs");
291
292
  var import_gpu_transfer_operation = require("./gpu-transfer-operation.cjs");
293
+ var import_gpu_shader_pass_operation = require("./gpu-shader-pass-operation.cjs");
292
294
  var import_gpu_compaction_operation = require("./gpu-compaction-operation.cjs");
293
295
  var import_gpu_cpu_operation = require("./gpu-cpu-operation.cjs");
294
296
  // Annotate the CommonJS export names for ESM import in node:
@@ -376,6 +378,7 @@ var import_gpu_cpu_operation = require("./gpu-cpu-operation.cjs");
376
378
  GPUSegmentedBVH,
377
379
  GPUSegmentedLayout,
378
380
  GPUSegmentedSort,
381
+ GPUShaderPassOperation,
379
382
  GPUSort,
380
383
  GPUTextSelection,
381
384
  GPUTextureHistory,