@luma.gl/graph 10.0.0-alpha.11 → 10.0.0-alpha.13

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 (131) hide show
  1. package/LICENSE +4 -4
  2. package/THIRD-PARTY-NOTICES.md +19 -0
  3. package/dist/arrow/gpu/arrow-gpu-vector-adapters.cjs +6 -6
  4. package/dist/arrow/gpu/arrow-gpu-vector-adapters.d.ts.map +1 -1
  5. package/dist/arrow/gpu/arrow-gpu-vector-adapters.js +16 -6
  6. package/dist/arrow/gpu/arrow-gpu-vector-adapters.js.map +1 -1
  7. package/dist/arrow/gpu/arrow-gpu-vector-conversion.cjs +3 -2
  8. package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts.map +1 -1
  9. package/dist/arrow/gpu/arrow-gpu-vector-conversion.js +3 -2
  10. package/dist/arrow/gpu/arrow-gpu-vector-conversion.js.map +1 -1
  11. package/dist/arrow/index.cjs.map +2 -2
  12. package/dist/arrow/internal.cjs.map +2 -2
  13. package/dist/dist.dev.js +2148 -454
  14. package/dist/dist.min.js +437 -123
  15. package/dist/experimental/index.cjs.map +1 -1
  16. package/dist/experimental/simulation/index.cjs.map +1 -1
  17. package/dist/gpu-core/compiled-gpu-graph.cjs +15 -0
  18. package/dist/gpu-core/compiled-gpu-graph.d.ts +1 -0
  19. package/dist/gpu-core/compiled-gpu-graph.d.ts.map +1 -1
  20. package/dist/gpu-core/compiled-gpu-graph.js +15 -0
  21. package/dist/gpu-core/compiled-gpu-graph.js.map +1 -1
  22. package/dist/gpu-core/gpu-command-graph.cjs +9 -0
  23. package/dist/gpu-core/gpu-command-graph.d.ts +2 -0
  24. package/dist/gpu-core/gpu-command-graph.d.ts.map +1 -1
  25. package/dist/gpu-core/gpu-command-graph.js +9 -0
  26. package/dist/gpu-core/gpu-command-graph.js.map +1 -1
  27. package/dist/gpu-core/gpu-expression-plan.cjs +4 -0
  28. package/dist/gpu-core/gpu-expression-plan.d.ts.map +1 -1
  29. package/dist/gpu-core/gpu-expression-plan.js +5 -0
  30. package/dist/gpu-core/gpu-expression-plan.js.map +1 -1
  31. package/dist/gpu-core/gpu-graph-compiler.cjs +48 -0
  32. package/dist/gpu-core/gpu-graph-compiler.d.ts +1 -0
  33. package/dist/gpu-core/gpu-graph-compiler.d.ts.map +1 -1
  34. package/dist/gpu-core/gpu-graph-compiler.js +50 -0
  35. package/dist/gpu-core/gpu-graph-compiler.js.map +1 -1
  36. package/dist/gpu-core/gpu-group-aggregation.cjs +7 -15
  37. package/dist/gpu-core/gpu-group-aggregation.d.ts.map +1 -1
  38. package/dist/gpu-core/gpu-group-aggregation.js +7 -18
  39. package/dist/gpu-core/gpu-group-aggregation.js.map +1 -1
  40. package/dist/gpu-core/gpu-reduction.cjs +6 -14
  41. package/dist/gpu-core/gpu-reduction.d.ts.map +1 -1
  42. package/dist/gpu-core/gpu-reduction.js +6 -15
  43. package/dist/gpu-core/gpu-reduction.js.map +1 -1
  44. package/dist/gpu-core/gpu-semantic-aggregation-operation.cjs +112 -0
  45. package/dist/gpu-core/gpu-semantic-aggregation-operation.d.ts +71 -0
  46. package/dist/gpu-core/gpu-semantic-aggregation-operation.d.ts.map +1 -0
  47. package/dist/gpu-core/gpu-semantic-aggregation-operation.js +92 -0
  48. package/dist/gpu-core/gpu-semantic-aggregation-operation.js.map +1 -0
  49. package/dist/gpu-core/gpu-shader-pass-kernel.cjs +267 -0
  50. package/dist/gpu-core/gpu-shader-pass-kernel.d.ts +29 -0
  51. package/dist/gpu-core/gpu-shader-pass-kernel.d.ts.map +1 -0
  52. package/dist/gpu-core/gpu-shader-pass-kernel.js +260 -0
  53. package/dist/gpu-core/gpu-shader-pass-kernel.js.map +1 -0
  54. package/dist/gpu-core/gpu-shader-pass-operation.cjs +85 -0
  55. package/dist/gpu-core/gpu-shader-pass-operation.d.ts +32 -0
  56. package/dist/gpu-core/gpu-shader-pass-operation.d.ts.map +1 -0
  57. package/dist/gpu-core/gpu-shader-pass-operation.js +74 -0
  58. package/dist/gpu-core/gpu-shader-pass-operation.js.map +1 -0
  59. package/dist/gpu-core/index.cjs +8 -0
  60. package/dist/gpu-core/index.cjs.map +3 -3
  61. package/dist/gpu-core/index.d.ts +4 -0
  62. package/dist/gpu-core/index.d.ts.map +1 -1
  63. package/dist/gpu-core/index.js +2 -0
  64. package/dist/gpu-core/index.js.map +1 -1
  65. package/dist/gpu-data/cpu-gpu-vector-transfer.cjs +7 -2
  66. package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts.map +1 -1
  67. package/dist/gpu-data/cpu-gpu-vector-transfer.js +9 -6
  68. package/dist/gpu-data/cpu-gpu-vector-transfer.js.map +1 -1
  69. package/dist/gpu-data/gpu-data-buffer-props.cjs +41 -0
  70. package/dist/gpu-data/gpu-data-buffer-props.d.ts +5 -0
  71. package/dist/gpu-data/gpu-data-buffer-props.d.ts.map +1 -0
  72. package/dist/gpu-data/gpu-data-buffer-props.js +19 -0
  73. package/dist/gpu-data/gpu-data-buffer-props.js.map +1 -0
  74. package/dist/gpu-data/index.cjs.map +3 -3
  75. package/dist/gpu-dggs/benchmarks.cjs.map +1 -1
  76. package/dist/gpu-graph/index.cjs +5 -0
  77. package/dist/gpu-graph/index.cjs.map +3 -3
  78. package/dist/gpu-graph/index.d.ts +2 -0
  79. package/dist/gpu-graph/index.d.ts.map +1 -1
  80. package/dist/gpu-graph/index.js +1 -0
  81. package/dist/gpu-graph/index.js.map +1 -1
  82. package/dist/gpu-graph-algorithms/benchmarks.cjs.map +1 -1
  83. package/dist/gpu-graph-algorithms/index.cjs.map +1 -1
  84. package/dist/gpu-physics/index.cjs.map +1 -1
  85. package/dist/gpu-project/benchmarks.cjs.map +2 -2
  86. package/dist/gpu-project/crs.cjs.map +2 -2
  87. package/dist/gpu-project/graph.cjs.map +3 -3
  88. package/dist/gpu-project/index.cjs.map +2 -2
  89. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.cjs +53 -5
  90. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts +3 -1
  91. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts.map +1 -1
  92. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js +58 -5
  93. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js.map +1 -1
  94. package/dist/gpu-simple-graph/index.cjs.map +3 -3
  95. package/dist/gpu-sql/gpu-sql.cjs +112 -100
  96. package/dist/gpu-sql/gpu-sql.d.ts +1 -1
  97. package/dist/gpu-sql/gpu-sql.d.ts.map +1 -1
  98. package/dist/gpu-sql/gpu-sql.js +120 -102
  99. package/dist/gpu-sql/gpu-sql.js.map +1 -1
  100. package/dist/gpu-sql/index.cjs.map +2 -2
  101. package/dist/gpu-tables/index.cjs.map +2 -2
  102. package/dist/gpu-tables/table/gpu-table.cjs +2 -2
  103. package/dist/gpu-tables/table/gpu-table.d.ts.map +1 -1
  104. package/dist/gpu-tables/table/gpu-table.js +2 -2
  105. package/dist/gpu-tables/table/gpu-table.js.map +1 -1
  106. package/dist/index.cjs +8 -0
  107. package/dist/index.cjs.map +3 -3
  108. package/dist/index.d.ts +4 -0
  109. package/dist/index.d.ts.map +1 -1
  110. package/dist/index.js +2 -0
  111. package/dist/index.js.map +1 -1
  112. package/package.json +10 -8
  113. package/src/arrow/gpu/arrow-gpu-vector-adapters.ts +17 -6
  114. package/src/arrow/gpu/arrow-gpu-vector-conversion.ts +3 -2
  115. package/src/gpu-core/compiled-gpu-graph.ts +18 -0
  116. package/src/gpu-core/gpu-command-graph.ts +10 -0
  117. package/src/gpu-core/gpu-expression-plan.ts +6 -0
  118. package/src/gpu-core/gpu-graph-compiler.ts +61 -0
  119. package/src/gpu-core/gpu-group-aggregation.ts +38 -50
  120. package/src/gpu-core/gpu-reduction.ts +32 -42
  121. package/src/gpu-core/gpu-semantic-aggregation-operation.ts +150 -0
  122. package/src/gpu-core/gpu-shader-pass-kernel.ts +307 -0
  123. package/src/gpu-core/gpu-shader-pass-operation.ts +103 -0
  124. package/src/gpu-core/index.ts +8 -0
  125. package/src/gpu-data/cpu-gpu-vector-transfer.ts +10 -7
  126. package/src/gpu-data/gpu-data-buffer-props.ts +25 -0
  127. package/src/gpu-graph/index.ts +9 -0
  128. package/src/gpu-simple-graph/compiled-gpu-expression-graph.ts +59 -5
  129. package/src/gpu-sql/gpu-sql.ts +130 -103
  130. package/src/gpu-tables/table/gpu-table.ts +2 -1
  131. package/src/index.ts +11 -0
@@ -0,0 +1,267 @@
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_kernel_exports = {};
19
+ __export(gpu_shader_pass_kernel_exports, {
20
+ GPUShaderPassKernel: () => GPUShaderPassKernel
21
+ });
22
+ module.exports = __toCommonJS(gpu_shader_pass_kernel_exports);
23
+ var import_core = require("@luma.gl/core");
24
+ var import_gpu_data = require("@luma.gl/graph/gpu-data");
25
+ var import_render_kernel = require("../execution/compute/render-kernel.cjs");
26
+ var import_gpu_scalar = require("./gpu-scalar.cjs");
27
+ var import_gpu_texture_plan = require("./gpu-texture-plan.cjs");
28
+ const VERTEX_SOURCE = `
29
+ struct GraphShaderPassVertex {
30
+ @builtin(position) position: vec4<f32>,
31
+ @location(0) textureCoordinates: vec2<f32>
32
+ };
33
+ @vertex fn vertexMain(@builtin(vertex_index) index: u32) -> GraphShaderPassVertex {
34
+ let position = vec2<f32>(f32((index << 1u) & 2u), f32(index & 2u));
35
+ var result: GraphShaderPassVertex;
36
+ result.position = vec4<f32>(position * 2.0 - 1.0, 0.0, 1.0);
37
+ result.textureCoordinates = vec2<f32>(position.x, 1.0 - position.y);
38
+ return result;
39
+ }`;
40
+ class GPUShaderPassKernel {
41
+ device;
42
+ operation;
43
+ kernel;
44
+ vertexArray;
45
+ samplers = /* @__PURE__ */ Object.create(null);
46
+ parameterFormats;
47
+ parameterByteLength;
48
+ constructor(device, operation, program) {
49
+ this.device = device;
50
+ this.operation = operation;
51
+ (0, import_core.assert)(device.type === "webgpu");
52
+ this.parameterFormats = Object.values(operation.parameters).map((name) => {
53
+ const scalar = program.scalars.find((value) => value.id === name);
54
+ (0, import_core.assert)(scalar);
55
+ return scalar.format;
56
+ });
57
+ this.parameterByteLength = Math.ceil(this.parameterFormats.length / 4) * 16;
58
+ for (const name of Object.values(operation.inputs)) {
59
+ const input = program.textures.find((texture) => texture.id === name);
60
+ const info = device.getTextureFormatInfo(input.format);
61
+ (0, import_core.assert)(!info.integer && info.attachment !== "depth" && info.attachment !== "depth-stencil" && device.getTextureFormatCapabilities(input.format).filter);
62
+ }
63
+ const outputInfo = device.getTextureFormatInfo(operation.outputDescriptor.format);
64
+ (0, import_core.assert)(!outputInfo.integer && device.getTextureFormatCapabilities(operation.outputDescriptor.format).render);
65
+ const shaderBindings = [
66
+ ...Object.keys(operation.inputs).map((name, location) => ({
67
+ name,
68
+ location,
69
+ group: 0,
70
+ type: "texture",
71
+ viewDimension: "2d",
72
+ sampleType: "float"
73
+ })),
74
+ ...Object.keys(operation.samplers).map((name, index) => ({
75
+ name,
76
+ location: Object.keys(operation.inputs).length + index,
77
+ group: 0,
78
+ type: "sampler"
79
+ }))
80
+ ];
81
+ let binding = 0;
82
+ const declarations = [
83
+ ...Object.keys(operation.inputs).map((name) => `@group(0) @binding(${binding++}) var ${name}: texture_2d<f32>;`),
84
+ ...Object.keys(operation.samplers).map((name) => `@group(0) @binding(${binding++}) var ${name}: sampler;`)
85
+ ];
86
+ if (this.parameterFormats.length) {
87
+ shaderBindings.push({ name: "parameters", location: binding, group: 0, type: "uniform" });
88
+ declarations.push(`struct GraphShaderPassParameters {${Object.keys(operation.parameters).map((name, index) => `${name}: ${(0, import_gpu_scalar.getGPUScalarWGSLType)(this.parameterFormats[index])}`).join(",")}};
89
+ @group(0) @binding(${binding}) var<uniform> parameters: GraphShaderPassParameters;`);
90
+ }
91
+ try {
92
+ this.kernel = new import_render_kernel.RenderKernel(device, {
93
+ id: operation.id,
94
+ vertexSource: VERTEX_SOURCE,
95
+ fragmentSource: `${declarations.join("\n")}
96
+ ${operation.fragmentSource}
97
+
98
+ @fragment fn fragmentMain(@location(0) textureCoordinates: vec2<f32>) -> @location(0) vec4<f32> {
99
+ return shade(textureCoordinates);
100
+ }`,
101
+ vertexEntryPoint: "vertexMain",
102
+ fragmentEntryPoint: "fragmentMain",
103
+ topology: "triangle-list",
104
+ shaderLayout: { attributes: [], bindings: shaderBindings },
105
+ colorAttachmentFormats: [operation.outputDescriptor.format],
106
+ parameters: { depthWriteEnabled: false }
107
+ });
108
+ this.vertexArray = device.createVertexArray({
109
+ shaderLayout: this.kernel.pipeline.shaderLayout,
110
+ bufferLayout: []
111
+ });
112
+ for (const [name, props] of Object.entries(operation.samplers))
113
+ this.samplers[name] = device.createSampler(props);
114
+ } catch (error) {
115
+ this.destroy();
116
+ throw error;
117
+ }
118
+ }
119
+ /** Validate selected view geometry before either executor records commands. */
120
+ validateTextures(textures) {
121
+ for (const name of [...Object.values(this.operation.inputs), this.operation.output]) {
122
+ const binding = textures.get(name);
123
+ (0, import_core.assert)(binding);
124
+ const info = (0, import_gpu_texture_plan.getTextureBindingInfo)(binding);
125
+ (0, import_core.assert)(info.texture.device === this.device && info.dimension === "2d" && info.depth === 1 && info.samples === 1);
126
+ if (name === this.operation.output)
127
+ (0, import_core.assert)(info.mipLevels === 1);
128
+ }
129
+ }
130
+ /** Full graph lowers to ordinary resource-tracked copy and render nodes. */
131
+ lower(context) {
132
+ const operation = this.operation;
133
+ const inputs = Object.fromEntries(Object.entries(operation.inputs).map(([name, value]) => [
134
+ name,
135
+ context.resolveTextureView(value)
136
+ ]));
137
+ const output = context.resolveTextureView(operation.output);
138
+ const parameters = this.parameterFormats.length ? context.graph.createTransientBuffer({
139
+ id: context.graph.getUniqueResourceId(`${operation.id}-parameters`),
140
+ byteLength: this.parameterByteLength,
141
+ usage: import_core.Buffer.UNIFORM | import_core.Buffer.COPY_DST
142
+ }) : void 0;
143
+ if (parameters) {
144
+ const sources = Object.values(operation.parameters).map((name) => context.resolveScalar(name).view);
145
+ context.graph.addCopyPass({
146
+ id: `${operation.id}-parameters`,
147
+ resources: [
148
+ ...sources.map((buffer) => ({ buffer, usage: "copy-source" })),
149
+ { buffer: parameters, usage: "copy-destination" }
150
+ ],
151
+ compile: () => ({
152
+ encode: ({ commandEncoder, getBuffer }) => {
153
+ sources.forEach((source, index) => commandEncoder.copyBufferToBuffer({
154
+ sourceBuffer: getBuffer(source),
155
+ sourceOffset: source.byteOffset,
156
+ destinationBuffer: getBuffer(parameters),
157
+ destinationOffset: index * 4,
158
+ size: 4
159
+ }));
160
+ }
161
+ })
162
+ });
163
+ }
164
+ context.graph.addRenderPass({
165
+ id: operation.id,
166
+ resources: [
167
+ ...Object.values(inputs).map((texture) => ({ texture, usage: "sampled" })),
168
+ ...parameters ? [{ buffer: parameters, usage: "uniform" }] : []
169
+ ],
170
+ attachments: { colorAttachments: [output] },
171
+ compile: () => ({
172
+ getRenderPassProps: () => ({ clearColor: [0, 0, 0, 0], clearDepth: false }),
173
+ encode: ({ renderPass, getTextureView, getBuffer }) => this.draw(renderPass, Object.fromEntries(Object.entries(inputs).map(([name, view]) => [name, getTextureView(view)])), parameters ? getBuffer(parameters) : void 0)
174
+ })
175
+ });
176
+ }
177
+ /** SimpleGraph owns only per-invocation framebuffer/uniform wrappers, never bound textures. */
178
+ prepare(textures, values) {
179
+ this.validateTextures(textures);
180
+ const inputs = Object.fromEntries(Object.entries(this.operation.inputs).map(([name, value]) => [name, textures.get(value)]));
181
+ const output = textures.get(this.operation.output);
182
+ const info = (0, import_gpu_texture_plan.getTextureBindingInfo)(output);
183
+ const data = new Uint8Array(this.parameterByteLength);
184
+ const view = new DataView(data.buffer);
185
+ const parameterValues = Object.values(this.operation.parameters).map((name, index) => {
186
+ const value = values.get(name);
187
+ (0, import_core.assert)(value !== void 0);
188
+ if (typeof value === "number") {
189
+ switch (this.parameterFormats[index]) {
190
+ case "float32":
191
+ view.setFloat32(index * 4, value, true);
192
+ break;
193
+ case "sint32":
194
+ view.setInt32(index * 4, value, true);
195
+ break;
196
+ case "uint32":
197
+ view.setUint32(index * 4, value, true);
198
+ break;
199
+ }
200
+ } else
201
+ (0, import_core.assert)(value.length === 1 && value.data.length === 1);
202
+ return value;
203
+ });
204
+ const parameters = data.byteLength ? this.device.createBuffer({ data, usage: import_core.Buffer.UNIFORM | import_core.Buffer.COPY_DST }) : void 0;
205
+ let framebuffer;
206
+ try {
207
+ framebuffer = this.device.createFramebuffer({
208
+ width: info.width,
209
+ height: info.height,
210
+ colorAttachments: [output]
211
+ });
212
+ } catch (error) {
213
+ parameters == null ? void 0 : parameters.destroy();
214
+ throw error;
215
+ }
216
+ return {
217
+ encode: (commandEncoder) => {
218
+ this.validateTextures(textures);
219
+ if (parameters)
220
+ parameterValues.forEach((value, index) => {
221
+ if (!(value instanceof import_gpu_data.GPUVector))
222
+ return;
223
+ const chunk = value.data[0];
224
+ const buffer = chunk.buffer instanceof import_core.Buffer ? chunk.buffer : chunk.buffer.buffer;
225
+ commandEncoder.copyBufferToBuffer({
226
+ sourceBuffer: buffer,
227
+ sourceOffset: chunk.byteOffset,
228
+ destinationBuffer: parameters,
229
+ destinationOffset: index * 4,
230
+ size: 4
231
+ });
232
+ });
233
+ const pass = commandEncoder.beginRenderPass({
234
+ framebuffer,
235
+ clearColor: [0, 0, 0, 0],
236
+ clearDepth: false
237
+ });
238
+ try {
239
+ this.draw(pass, inputs, parameters);
240
+ } finally {
241
+ pass.end();
242
+ }
243
+ },
244
+ destroy: () => {
245
+ framebuffer.destroy();
246
+ parameters == null ? void 0 : parameters.destroy();
247
+ }
248
+ };
249
+ }
250
+ destroy() {
251
+ var _a, _b;
252
+ for (const sampler of Object.values(this.samplers))
253
+ sampler.destroy();
254
+ (_a = this.vertexArray) == null ? void 0 : _a.destroy();
255
+ (_b = this.kernel) == null ? void 0 : _b.destroy();
256
+ }
257
+ draw(renderPass, inputs, parameters) {
258
+ const bindings = { ...inputs, ...this.samplers };
259
+ if (parameters)
260
+ bindings["parameters"] = parameters;
261
+ this.kernel.draw(renderPass, { vertexArray: this.vertexArray, vertexCount: 3, bindings });
262
+ }
263
+ }
264
+ // Annotate the CommonJS export names for ESM import in node:
265
+ 0 && (module.exports = {
266
+ GPUShaderPassKernel
267
+ });
@@ -0,0 +1,29 @@
1
+ import { type CommandEncoder, type Device } from '@luma.gl/core';
2
+ import { GPUVector } from '@luma.gl/graph/gpu-data';
3
+ import type { GPUShaderPassOperation } from "./gpu-shader-pass-operation.js";
4
+ import type { GPUExpressionProgram } from "./gpu-expression-plan.js";
5
+ import type { GPUOperationLoweringContext } from "./gpu-graph-lowering.js";
6
+ import { type GPUGraphTextureBinding } from "./gpu-texture-plan.js";
7
+ /** One immutable pipeline; resources and uniforms are supplied independently for each draw. @internal */
8
+ export declare class GPUShaderPassKernel {
9
+ readonly device: Device;
10
+ readonly operation: GPUShaderPassOperation;
11
+ private kernel;
12
+ private vertexArray;
13
+ private readonly samplers;
14
+ private readonly parameterFormats;
15
+ private readonly parameterByteLength;
16
+ constructor(device: Device, operation: GPUShaderPassOperation, program: Pick<GPUExpressionProgram, 'textures' | 'scalars'>);
17
+ /** Validate selected view geometry before either executor records commands. */
18
+ validateTextures(textures: ReadonlyMap<string, GPUGraphTextureBinding>): void;
19
+ /** Full graph lowers to ordinary resource-tracked copy and render nodes. */
20
+ lower<Parameters>(context: GPUOperationLoweringContext<Parameters>): void;
21
+ /** SimpleGraph owns only per-invocation framebuffer/uniform wrappers, never bound textures. */
22
+ prepare(textures: ReadonlyMap<string, GPUGraphTextureBinding>, values: ReadonlyMap<string, GPUVector | number>): {
23
+ encode: (commandEncoder: CommandEncoder) => void;
24
+ destroy: () => void;
25
+ };
26
+ destroy(): void;
27
+ private draw;
28
+ }
29
+ //# sourceMappingURL=gpu-shader-pass-kernel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpu-shader-pass-kernel.d.ts","sourceRoot":"","sources":["../../src/gpu-core/gpu-shader-pass-kernel.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,MAAM,EAIZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAElD,OAAO,KAAK,EAAC,sBAAsB,EAAC,uCAAoC;AACxE,OAAO,KAAK,EAAC,oBAAoB,EAAC,iCAA8B;AAChE,OAAO,KAAK,EAAC,2BAA2B,EAAC,gCAA6B;AAEtE,OAAO,EAAwB,KAAK,sBAAsB,EAAC,8BAA2B;AAetF,yGAAyG;AACzG,qBAAa,mBAAmB;IAQ5B,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,SAAS,EAAE,sBAAsB;IAR5C,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,WAAW,CAAe;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgD;IACzE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA+C;IAChF,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;gBAGlC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,sBAAsB,EAC1C,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,UAAU,GAAG,SAAS,CAAC;IAuF7D,+EAA+E;IAC/E,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,GAAG,IAAI;IAe7E,4EAA4E;IAC5E,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,2BAA2B,CAAC,UAAU,CAAC,GAAG,IAAI;IA8DzE,+FAA+F;IAC/F,OAAO,CACL,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,EACrD,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC;iCA2CpB,cAAc;;;IAiC3C,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,IAAI;CASb"}
@@ -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;AAEH,yGAAyG;AACzG,MAAM,OAAO,mBAAmB;IAQnB;IACA;IARH,MAAM,CAAgB;IACtB,WAAW,CAAe;IACjB,QAAQ,GAA4B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxD,gBAAgB,CAA+C;IAC/D,mBAAmB,CAAS;IAE7C,YACW,MAAc,EACd,SAAiC,EAC1C,OAA2D;QAFlD,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAwB;QAG1C,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACrE,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC;YAChE,MAAM,CAAC,MAAM,CAAC,CAAC;YACf,OAAO,MAAM,CAAC,MAAM,CAAC;QACvB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,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KAAK;iBAClB,CAAC,CAAC;gBACH,IAAI,CAAC;oBACH,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;gBACtC,CAAC;wBAAS,CAAC;oBACT,IAAI,CAAC,GAAG,EAAE,CAAC;gBACb,CAAC;YACH,CAAC;YACD,OAAO,EAAE,GAAG,EAAE;gBACZ,WAAW,CAAC,OAAO,EAAE,CAAC;gBACtB,UAAU,EAAE,OAAO,EAAE,CAAC;YACxB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;YAAE,OAAO,CAAC,OAAO,EAAE,CAAC;QACtE,IAAI,CAAC,WAAW,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
+ });