@luma.gl/webgpu 9.0.0-beta.5 → 9.0.0-beta.7
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/adapter/helpers/accessor-to-format.js +4 -1
- package/dist/adapter/helpers/convert-texture-format.d.ts.map +1 -1
- package/dist/adapter/helpers/convert-texture-format.js +3 -0
- package/dist/adapter/helpers/get-bind-group.d.ts +3 -3
- package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
- package/dist/adapter/helpers/get-bind-group.js +3 -0
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +9 -2
- package/dist/adapter/helpers/webgpu-parameters.d.ts.map +1 -1
- package/dist/adapter/helpers/webgpu-parameters.js +3 -0
- package/dist/adapter/resources/webgpu-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.js +19 -10
- package/dist/adapter/resources/webgpu-command-encoder.d.ts +7 -1
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js +8 -0
- package/dist/adapter/resources/webgpu-compute-pass.d.ts +15 -9
- package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js +39 -17
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +14 -4
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js +37 -15
- package/dist/adapter/resources/webgpu-external-texture.d.ts +2 -2
- package/dist/adapter/resources/webgpu-external-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-external-texture.js +14 -7
- package/dist/adapter/resources/webgpu-framebuffer.d.ts +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.js +3 -0
- package/dist/adapter/resources/webgpu-query-set.d.ts +17 -0
- package/dist/adapter/resources/webgpu-query-set.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-query-set.js +27 -0
- package/dist/adapter/resources/webgpu-render-pass.d.ts +4 -2
- package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js +27 -9
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts +52 -5
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js +76 -66
- package/dist/adapter/resources/webgpu-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.js +3 -0
- package/dist/adapter/resources/webgpu-shader.d.ts +2 -5
- package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-shader.js +10 -20
- package/dist/adapter/resources/webgpu-texture-view.d.ts +20 -0
- package/dist/adapter/resources/webgpu-texture-view.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-texture-view.js +35 -0
- package/dist/adapter/resources/webgpu-texture.d.ts +8 -8
- package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-texture.js +25 -22
- package/dist/adapter/resources/webgpu-vertex-array.d.ts +7 -9
- package/dist/adapter/resources/webgpu-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-vertex-array.js +11 -13
- package/dist/adapter/webgpu-canvas-context.d.ts +3 -3
- package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgpu-canvas-context.js +8 -5
- package/dist/adapter/webgpu-device.d.ts +26 -28
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +81 -74
- package/dist/dist.dev.js +339 -305
- package/dist/index.cjs +313 -250
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist.min.js +1 -1
- package/package.json +2 -2
- package/src/adapter/helpers/accessor-to-format.ts +5 -1
- package/src/adapter/helpers/convert-texture-format.ts +4 -1
- package/src/adapter/helpers/get-bind-group.ts +12 -6
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +12 -4
- package/src/adapter/helpers/webgpu-parameters.ts +79 -15
- package/src/adapter/resources/webgpu-buffer.ts +24 -11
- package/src/adapter/resources/webgpu-command-encoder.ts +24 -9
- package/src/adapter/resources/webgpu-compute-pass.ts +45 -22
- package/src/adapter/resources/webgpu-compute-pipeline.ts +48 -16
- package/src/adapter/resources/webgpu-external-texture.ts +14 -6
- package/src/adapter/resources/webgpu-framebuffer.ts +4 -0
- package/src/adapter/resources/webgpu-query-set.ts +37 -0
- package/src/adapter/resources/webgpu-render-pass.ts +37 -14
- package/src/adapter/resources/webgpu-render-pipeline.ts +75 -115
- package/src/adapter/resources/webgpu-sampler.ts +4 -1
- package/src/adapter/resources/webgpu-shader.ts +11 -25
- package/src/adapter/resources/webgpu-texture-view.ts +46 -0
- package/src/adapter/resources/webgpu-texture.ts +33 -28
- package/src/adapter/resources/webgpu-vertex-array.ts +25 -20
- package/src/adapter/webgpu-canvas-context.ts +10 -5
- package/src/adapter/webgpu-device.ts +99 -76
- package/src/index.ts +2 -1
- package/dist/adapter/helpers/generate-mipmaps.d.ts +0 -10
- package/dist/adapter/helpers/generate-mipmaps.d.ts.map +0 -1
- package/dist/adapter/helpers/generate-mipmaps.js +0 -94
- package/dist/adapter/resources/webgpu-query.d.ts +0 -1
- package/dist/adapter/resources/webgpu-query.d.ts.map +0 -1
- package/dist/adapter/resources/webgpu-query.js +0 -43
- package/dist/adapter/webgpu-types.d.ts +0 -1
- package/dist/adapter/webgpu-types.d.ts.map +0 -1
- package/dist/adapter/webgpu-types.js +0 -0
- package/dist/glsl/glsllang.d.ts +0 -3
- package/dist/glsl/glsllang.d.ts.map +0 -1
- package/dist/glsl/glsllang.js +0 -12
- package/src/adapter/helpers/generate-mipmaps.ts +0 -107
- package/src/adapter/resources/webgpu-query.ts +0 -43
- package/src/adapter/webgpu-types.ts +0 -0
- package/src/glsl/glsllang.ts +0 -14
package/dist/index.cjs
CHANGED
|
@@ -33,7 +33,7 @@ __export(dist_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(dist_exports);
|
|
34
34
|
|
|
35
35
|
// dist/adapter/webgpu-device.js
|
|
36
|
-
var
|
|
36
|
+
var import_core17 = require("@luma.gl/core");
|
|
37
37
|
|
|
38
38
|
// dist/adapter/resources/webgpu-buffer.js
|
|
39
39
|
var import_core = require("@luma.gl/core");
|
|
@@ -66,14 +66,19 @@ var WebGPUBuffer = class extends import_core.Buffer {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
destroy() {
|
|
69
|
-
|
|
69
|
+
var _a;
|
|
70
|
+
(_a = this.handle) == null ? void 0 : _a.destroy();
|
|
71
|
+
this.handle = null;
|
|
70
72
|
}
|
|
71
73
|
// WebGPU provides multiple ways to write a buffer...
|
|
72
74
|
write(data, byteOffset = 0) {
|
|
73
75
|
this.device.handle.queue.writeBuffer(this.handle, byteOffset, data.buffer, data.byteOffset, data.byteLength);
|
|
74
76
|
}
|
|
75
77
|
async readAsync(byteOffset = 0, byteLength = this.byteLength) {
|
|
76
|
-
const tempBuffer = new WebGPUBuffer(this.device, {
|
|
78
|
+
const tempBuffer = new WebGPUBuffer(this.device, {
|
|
79
|
+
usage: import_core.Buffer.MAP_READ | import_core.Buffer.COPY_DST,
|
|
80
|
+
byteLength
|
|
81
|
+
});
|
|
77
82
|
const commandEncoder = this.device.handle.createCommandEncoder();
|
|
78
83
|
commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);
|
|
79
84
|
this.device.handle.queue.submit([commandEncoder.finish()]);
|
|
@@ -100,7 +105,7 @@ var WebGPUBuffer = class extends import_core.Buffer {
|
|
|
100
105
|
};
|
|
101
106
|
|
|
102
107
|
// dist/adapter/resources/webgpu-texture.js
|
|
103
|
-
var
|
|
108
|
+
var import_core4 = require("@luma.gl/core");
|
|
104
109
|
|
|
105
110
|
// dist/adapter/helpers/convert-texture-format.js
|
|
106
111
|
function getWebGPUTextureFormat(format) {
|
|
@@ -126,6 +131,36 @@ var WebGPUSampler = class extends import_core2.Sampler {
|
|
|
126
131
|
this.handle.label = this.props.id;
|
|
127
132
|
}
|
|
128
133
|
destroy() {
|
|
134
|
+
this.handle = null;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// dist/adapter/resources/webgpu-texture-view.js
|
|
139
|
+
var import_core3 = require("@luma.gl/core");
|
|
140
|
+
var WebGPUTextureView = class extends import_core3.TextureView {
|
|
141
|
+
device;
|
|
142
|
+
handle;
|
|
143
|
+
texture;
|
|
144
|
+
constructor(device, props) {
|
|
145
|
+
super(device, props);
|
|
146
|
+
this.device = device;
|
|
147
|
+
this.texture = props.texture;
|
|
148
|
+
this.handle = this.handle || this.texture.handle.createView({
|
|
149
|
+
format: props.format || this.texture.format,
|
|
150
|
+
dimension: props.dimension || this.texture.dimension,
|
|
151
|
+
aspect: props.aspect,
|
|
152
|
+
baseMipLevel: props.baseMipLevel,
|
|
153
|
+
mipLevelCount: props.mipLevelCount,
|
|
154
|
+
// GPUIntegerCoordinate;
|
|
155
|
+
baseArrayLayer: props.baseArrayLayer,
|
|
156
|
+
// GPUIntegerCoordinate;
|
|
157
|
+
arrayLayerCount: props.arrayLayerCount
|
|
158
|
+
// GPUIntegerCoordinate;
|
|
159
|
+
});
|
|
160
|
+
this.handle.label = this.props.id;
|
|
161
|
+
}
|
|
162
|
+
destroy() {
|
|
163
|
+
this.handle = null;
|
|
129
164
|
}
|
|
130
165
|
};
|
|
131
166
|
|
|
@@ -134,17 +169,17 @@ var BASE_DIMENSIONS = {
|
|
|
134
169
|
"1d": "1d",
|
|
135
170
|
"2d": "2d",
|
|
136
171
|
"2d-array": "2d",
|
|
137
|
-
|
|
172
|
+
cube: "2d",
|
|
138
173
|
"cube-array": "2d",
|
|
139
174
|
"3d": "3d"
|
|
140
175
|
};
|
|
141
|
-
var WebGPUTexture = class extends
|
|
176
|
+
var WebGPUTexture = class extends import_core4.Texture {
|
|
142
177
|
device;
|
|
143
178
|
handle;
|
|
144
|
-
view;
|
|
145
|
-
sampler;
|
|
146
179
|
height = 1;
|
|
147
180
|
width = 1;
|
|
181
|
+
sampler;
|
|
182
|
+
view;
|
|
148
183
|
// static async createFromImageURL(src, usage = 0) {
|
|
149
184
|
// const img = document.createElement('img');
|
|
150
185
|
// img.src = src;
|
|
@@ -163,6 +198,14 @@ var WebGPUTexture = class extends import_core3.Texture {
|
|
|
163
198
|
}
|
|
164
199
|
this.initialize(props);
|
|
165
200
|
}
|
|
201
|
+
destroy() {
|
|
202
|
+
var _a;
|
|
203
|
+
(_a = this.handle) == null ? void 0 : _a.destroy();
|
|
204
|
+
this.handle = null;
|
|
205
|
+
}
|
|
206
|
+
createView(props) {
|
|
207
|
+
return new WebGPUTextureView(this.device, { ...props, texture: this });
|
|
208
|
+
}
|
|
166
209
|
initialize(props) {
|
|
167
210
|
this.handle = this.props.handle || this.createHandle();
|
|
168
211
|
this.handle.label ||= this.id;
|
|
@@ -172,7 +215,7 @@ var WebGPUTexture = class extends import_core3.Texture {
|
|
|
172
215
|
this.width = this.handle.width;
|
|
173
216
|
this.height = this.handle.height;
|
|
174
217
|
this.sampler = props.sampler instanceof WebGPUSampler ? props.sampler : new WebGPUSampler(this.device, props.sampler);
|
|
175
|
-
this.view = this.
|
|
218
|
+
this.view = new WebGPUTextureView(this.device, { ...this.props, texture: this });
|
|
176
219
|
}
|
|
177
220
|
createHandle() {
|
|
178
221
|
var _a, _b;
|
|
@@ -192,9 +235,6 @@ var WebGPUTexture = class extends import_core3.Texture {
|
|
|
192
235
|
sampleCount: this.props.samples
|
|
193
236
|
});
|
|
194
237
|
}
|
|
195
|
-
destroy() {
|
|
196
|
-
this.handle.destroy();
|
|
197
|
-
}
|
|
198
238
|
/**
|
|
199
239
|
* Set default sampler
|
|
200
240
|
* Accept a sampler instance or set of props;
|
|
@@ -225,24 +265,15 @@ var WebGPUTexture = class extends import_core3.Texture {
|
|
|
225
265
|
premultipliedAlpha
|
|
226
266
|
},
|
|
227
267
|
// copySize: GPUExtent3D
|
|
228
|
-
[
|
|
229
|
-
width,
|
|
230
|
-
height,
|
|
231
|
-
depth
|
|
232
|
-
]
|
|
268
|
+
[width, height, depth]
|
|
233
269
|
);
|
|
234
270
|
return { width, height };
|
|
235
271
|
}
|
|
236
|
-
// WebGPU specific
|
|
237
|
-
/** TODO - intention is to expose TextureViews in the public API */
|
|
238
|
-
createView() {
|
|
239
|
-
return this.handle.createView({ label: this.id });
|
|
240
|
-
}
|
|
241
272
|
};
|
|
242
273
|
|
|
243
274
|
// dist/adapter/resources/webgpu-external-texture.js
|
|
244
|
-
var
|
|
245
|
-
var WebGPUExternalTexture = class extends
|
|
275
|
+
var import_core5 = require("@luma.gl/core");
|
|
276
|
+
var WebGPUExternalTexture = class extends import_core5.ExternalTexture {
|
|
246
277
|
device;
|
|
247
278
|
handle;
|
|
248
279
|
sampler;
|
|
@@ -256,6 +287,7 @@ var WebGPUExternalTexture = class extends import_core4.ExternalTexture {
|
|
|
256
287
|
this.sampler = null;
|
|
257
288
|
}
|
|
258
289
|
destroy() {
|
|
290
|
+
this.handle = null;
|
|
259
291
|
}
|
|
260
292
|
/** Set default sampler */
|
|
261
293
|
setSampler(sampler) {
|
|
@@ -265,8 +297,8 @@ var WebGPUExternalTexture = class extends import_core4.ExternalTexture {
|
|
|
265
297
|
};
|
|
266
298
|
|
|
267
299
|
// dist/adapter/resources/webgpu-shader.js
|
|
268
|
-
var
|
|
269
|
-
var WebGPUShader = class extends
|
|
300
|
+
var import_core6 = require("@luma.gl/core");
|
|
301
|
+
var WebGPUShader = class extends import_core6.Shader {
|
|
270
302
|
device;
|
|
271
303
|
handle;
|
|
272
304
|
constructor(device, props) {
|
|
@@ -282,11 +314,12 @@ var WebGPUShader = class extends import_core5.Shader {
|
|
|
282
314
|
if (error) {
|
|
283
315
|
this.debugShader();
|
|
284
316
|
const shaderLog = await this.getCompilationInfo();
|
|
285
|
-
|
|
317
|
+
import_core6.log.error(`Shader compilation error: ${error.message}`, shaderLog)();
|
|
286
318
|
throw new Error(`Shader compilation error: ${error.message}`);
|
|
287
319
|
}
|
|
288
320
|
}
|
|
289
321
|
destroy() {
|
|
322
|
+
this.handle = null;
|
|
290
323
|
}
|
|
291
324
|
/** Returns compilation info for this shader */
|
|
292
325
|
async getCompilationInfo() {
|
|
@@ -295,28 +328,17 @@ var WebGPUShader = class extends import_core5.Shader {
|
|
|
295
328
|
}
|
|
296
329
|
// PRIVATE METHODS
|
|
297
330
|
createHandle() {
|
|
298
|
-
const { source
|
|
299
|
-
|
|
300
|
-
if (language === "
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
switch (language) {
|
|
304
|
-
case "wgsl":
|
|
305
|
-
return this.device.handle.createShaderModule({ code: source });
|
|
306
|
-
case "glsl":
|
|
307
|
-
return this.device.handle.createShaderModule({
|
|
308
|
-
code: source,
|
|
309
|
-
// @ts-expect-error
|
|
310
|
-
transform: (glsl) => this.device.glslang.compileGLSL(glsl, stage)
|
|
311
|
-
});
|
|
312
|
-
default:
|
|
313
|
-
throw new Error(language);
|
|
331
|
+
const { source } = this.props;
|
|
332
|
+
const isGLSL = source.includes("#version");
|
|
333
|
+
if (this.props.language === "glsl" || isGLSL) {
|
|
334
|
+
throw new Error("GLSL shaders are not supported in WebGPU");
|
|
314
335
|
}
|
|
336
|
+
return this.device.handle.createShaderModule({ code: source });
|
|
315
337
|
}
|
|
316
338
|
};
|
|
317
339
|
|
|
318
340
|
// dist/adapter/resources/webgpu-render-pipeline.js
|
|
319
|
-
var
|
|
341
|
+
var import_core9 = require("@luma.gl/core");
|
|
320
342
|
|
|
321
343
|
// dist/adapter/helpers/webgpu-parameters.js
|
|
322
344
|
function addDepthStencil(descriptor) {
|
|
@@ -504,7 +526,7 @@ function addColorState(descriptor) {
|
|
|
504
526
|
}
|
|
505
527
|
|
|
506
528
|
// dist/adapter/helpers/get-bind-group.js
|
|
507
|
-
var
|
|
529
|
+
var import_core7 = require("@luma.gl/core");
|
|
508
530
|
function getBindGroup(device, bindGroupLayout, shaderLayout, bindings) {
|
|
509
531
|
const entries = getBindGroupEntries(bindings, shaderLayout);
|
|
510
532
|
return device.createBindGroup({
|
|
@@ -515,7 +537,7 @@ function getBindGroup(device, bindGroupLayout, shaderLayout, bindings) {
|
|
|
515
537
|
function getShaderLayoutBinding(shaderLayout, bindingName) {
|
|
516
538
|
const bindingLayout = shaderLayout.bindings.find((binding) => binding.name === bindingName || `${binding.name}uniforms` === bindingName.toLocaleLowerCase());
|
|
517
539
|
if (!bindingLayout) {
|
|
518
|
-
|
|
540
|
+
import_core7.log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();
|
|
519
541
|
}
|
|
520
542
|
return bindingLayout;
|
|
521
543
|
}
|
|
@@ -530,30 +552,30 @@ function getBindGroupEntries(bindings, shaderLayout) {
|
|
|
530
552
|
return entries;
|
|
531
553
|
}
|
|
532
554
|
function getBindGroupEntry(binding, index) {
|
|
533
|
-
if (binding instanceof
|
|
555
|
+
if (binding instanceof import_core7.Buffer) {
|
|
534
556
|
return {
|
|
535
557
|
binding: index,
|
|
536
558
|
resource: {
|
|
537
|
-
buffer: (0,
|
|
559
|
+
buffer: (0, import_core7.cast)(binding).handle
|
|
538
560
|
}
|
|
539
561
|
};
|
|
540
562
|
}
|
|
541
|
-
if (binding instanceof
|
|
563
|
+
if (binding instanceof import_core7.Sampler) {
|
|
542
564
|
return {
|
|
543
565
|
binding: index,
|
|
544
|
-
resource: (0,
|
|
566
|
+
resource: (0, import_core7.cast)(binding).handle
|
|
545
567
|
};
|
|
546
|
-
} else if (binding instanceof
|
|
568
|
+
} else if (binding instanceof import_core7.Texture) {
|
|
547
569
|
return {
|
|
548
570
|
binding: index,
|
|
549
|
-
resource: (0,
|
|
571
|
+
resource: (0, import_core7.cast)(binding).handle.createView({ label: "bind-group-auto-created" })
|
|
550
572
|
};
|
|
551
573
|
}
|
|
552
574
|
throw new Error("invalid binding");
|
|
553
575
|
}
|
|
554
576
|
|
|
555
577
|
// dist/adapter/helpers/get-vertex-buffer-layout.js
|
|
556
|
-
var
|
|
578
|
+
var import_core8 = require("@luma.gl/core");
|
|
557
579
|
function getWebGPUVertexFormat(format) {
|
|
558
580
|
if (format.endsWith("-webgl")) {
|
|
559
581
|
throw new Error(`WebGPU does not support vertex format ${format}`);
|
|
@@ -577,14 +599,14 @@ function getVertexBufferLayout(shaderLayout, bufferLayout) {
|
|
|
577
599
|
offset: attributeMapping.byteOffset,
|
|
578
600
|
shaderLocation: attributeLayout.location
|
|
579
601
|
});
|
|
580
|
-
byteStride += (0,
|
|
602
|
+
byteStride += (0, import_core8.decodeVertexFormat)(mapping.format).byteLength;
|
|
581
603
|
}
|
|
582
604
|
} else {
|
|
583
605
|
const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);
|
|
584
606
|
if (!attributeLayout) {
|
|
585
607
|
continue;
|
|
586
608
|
}
|
|
587
|
-
byteStride = (0,
|
|
609
|
+
byteStride = (0, import_core8.decodeVertexFormat)(mapping.format).byteLength;
|
|
588
610
|
stepMode = attributeLayout.stepMode || (attributeLayout.name.startsWith("instance") ? "instance" : "vertex");
|
|
589
611
|
vertexAttributes.push({
|
|
590
612
|
format: getWebGPUVertexFormat(mapping.format),
|
|
@@ -602,7 +624,7 @@ function getVertexBufferLayout(shaderLayout, bufferLayout) {
|
|
|
602
624
|
for (const attribute of shaderLayout.attributes) {
|
|
603
625
|
if (!usedAttributes.has(attribute.name)) {
|
|
604
626
|
vertexBufferLayouts.push({
|
|
605
|
-
arrayStride: (0,
|
|
627
|
+
arrayStride: (0, import_core8.decodeVertexFormat)("float32x3").byteLength,
|
|
606
628
|
stepMode: attribute.stepMode || (attribute.name.startsWith("instance") ? "instance" : "vertex"),
|
|
607
629
|
attributes: [
|
|
608
630
|
{
|
|
@@ -619,7 +641,7 @@ function getVertexBufferLayout(shaderLayout, bufferLayout) {
|
|
|
619
641
|
function findAttributeLayout(shaderLayout, name, attributeNames) {
|
|
620
642
|
const attribute = shaderLayout.attributes.find((attribute2) => attribute2.name === name);
|
|
621
643
|
if (!attribute) {
|
|
622
|
-
|
|
644
|
+
import_core8.log.warn(`Unknown attribute ${name}`)();
|
|
623
645
|
return null;
|
|
624
646
|
}
|
|
625
647
|
if (attributeNames.has(name)) {
|
|
@@ -630,16 +652,13 @@ function findAttributeLayout(shaderLayout, name, attributeNames) {
|
|
|
630
652
|
}
|
|
631
653
|
|
|
632
654
|
// dist/adapter/resources/webgpu-render-pipeline.js
|
|
633
|
-
var WebGPURenderPipeline = class extends
|
|
655
|
+
var WebGPURenderPipeline = class extends import_core9.RenderPipeline {
|
|
634
656
|
device;
|
|
635
657
|
handle;
|
|
636
658
|
vs;
|
|
637
659
|
fs = null;
|
|
638
|
-
// private _bufferSlots: Record<string, number>;
|
|
639
|
-
// private _buffers: Buffer[];
|
|
640
|
-
// private _firstIndex: number;
|
|
641
|
-
// private _lastIndex: number;
|
|
642
660
|
/** For internal use to create BindGroups */
|
|
661
|
+
_bindings;
|
|
643
662
|
_bindGroupLayout = null;
|
|
644
663
|
_bindGroup = null;
|
|
645
664
|
constructor(device, props) {
|
|
@@ -648,53 +667,29 @@ var WebGPURenderPipeline = class extends import_core8.RenderPipeline {
|
|
|
648
667
|
this.handle = this.props.handle;
|
|
649
668
|
if (!this.handle) {
|
|
650
669
|
const descriptor = this._getRenderPipelineDescriptor();
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
670
|
+
import_core9.log.groupCollapsed(1, `new WebGPURenderPipeline(${this.id})`)();
|
|
671
|
+
import_core9.log.probe(1, JSON.stringify(descriptor, null, 2))();
|
|
672
|
+
import_core9.log.groupEnd(1)();
|
|
654
673
|
this.handle = this.device.handle.createRenderPipeline(descriptor);
|
|
655
674
|
}
|
|
656
675
|
this.handle.label = this.props.id;
|
|
657
|
-
this.vs = (0,
|
|
658
|
-
this.fs = (0,
|
|
676
|
+
this.vs = (0, import_core9.cast)(props.vs);
|
|
677
|
+
this.fs = (0, import_core9.cast)(props.fs);
|
|
678
|
+
this._bindings = { ...this.props.bindings };
|
|
659
679
|
}
|
|
660
680
|
destroy() {
|
|
681
|
+
this.handle = null;
|
|
661
682
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
setAttributes(attributes: Record<string, Buffer>): void {
|
|
667
|
-
for (const [name, buffer] of Object.entries(attributes)) {
|
|
668
|
-
const bufferIndex = this._bufferSlots[name];
|
|
669
|
-
if (bufferIndex >= 0) {
|
|
670
|
-
this._buffers[bufferIndex] = buffer;
|
|
671
|
-
} else {
|
|
672
|
-
throw new Error(
|
|
673
|
-
`Setting attribute '${name}' not listed in shader layout for program ${this.id}`
|
|
674
|
-
);
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
// for (let i = 0; i < this._bufferSlots.length; ++i) {
|
|
678
|
-
// const bufferName = this._bufferSlots[i];
|
|
679
|
-
// if (attributes[bufferName]) {
|
|
680
|
-
// this.handle
|
|
681
|
-
// }
|
|
682
|
-
// }
|
|
683
|
-
}
|
|
684
|
-
*/
|
|
685
|
-
// setConstantAttributes(attributes: Record<string, TypedArray>): void {
|
|
686
|
-
// throw new Error('not implemented');
|
|
687
|
-
// }
|
|
683
|
+
/**
|
|
684
|
+
* @todo Use renderpass.setBindings() ?
|
|
685
|
+
* @todo Do we want to expose BindGroups in the API and remove this?
|
|
686
|
+
*/
|
|
688
687
|
setBindings(bindings) {
|
|
689
|
-
Object.assign(this.
|
|
690
|
-
}
|
|
691
|
-
setUniforms(uniforms) {
|
|
692
|
-
if (!(0, import_core8.isObjectEmpty)(uniforms)) {
|
|
693
|
-
throw new Error("WebGPU does not support uniforms");
|
|
694
|
-
}
|
|
688
|
+
Object.assign(this._bindings, bindings);
|
|
695
689
|
}
|
|
690
|
+
/** @todo - should this be moved to renderpass? */
|
|
696
691
|
draw(options) {
|
|
697
|
-
const webgpuRenderPass =
|
|
692
|
+
const webgpuRenderPass = options.renderPass;
|
|
698
693
|
webgpuRenderPass.handle.setPipeline(this.handle);
|
|
699
694
|
const bindGroup = this._getBindGroup();
|
|
700
695
|
if (bindGroup) {
|
|
@@ -712,14 +707,15 @@ var WebGPURenderPipeline = class extends import_core8.RenderPipeline {
|
|
|
712
707
|
);
|
|
713
708
|
}
|
|
714
709
|
options.vertexArray.unbindAfterRender(options.renderPass);
|
|
710
|
+
return true;
|
|
715
711
|
}
|
|
716
|
-
// _getBuffers() {
|
|
717
|
-
// return this._buffers;
|
|
718
|
-
// }
|
|
719
712
|
/** Return a bind group created by setBindings */
|
|
720
713
|
_getBindGroup() {
|
|
714
|
+
if (this.props.shaderLayout.bindings.length === 0) {
|
|
715
|
+
return null;
|
|
716
|
+
}
|
|
721
717
|
this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);
|
|
722
|
-
this._bindGroup = this._bindGroup || getBindGroup(this.device.handle, this._bindGroupLayout, this.props.shaderLayout, this.
|
|
718
|
+
this._bindGroup = this._bindGroup || getBindGroup(this.device.handle, this._bindGroupLayout, this.props.shaderLayout, this._bindings);
|
|
723
719
|
return this._bindGroup;
|
|
724
720
|
}
|
|
725
721
|
/**
|
|
@@ -728,23 +724,20 @@ var WebGPURenderPipeline = class extends import_core8.RenderPipeline {
|
|
|
728
724
|
_getRenderPipelineDescriptor() {
|
|
729
725
|
var _a, _b;
|
|
730
726
|
const vertex = {
|
|
731
|
-
module: (0,
|
|
732
|
-
entryPoint: this.props.
|
|
727
|
+
module: (0, import_core9.cast)(this.props.vs).handle,
|
|
728
|
+
entryPoint: this.props.vertexEntryPoint || "main",
|
|
733
729
|
buffers: getVertexBufferLayout(this.props.shaderLayout, this.props.bufferLayout)
|
|
734
730
|
};
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
]
|
|
746
|
-
};
|
|
747
|
-
}
|
|
731
|
+
const fragment = {
|
|
732
|
+
module: (0, import_core9.cast)(this.props.fs).handle,
|
|
733
|
+
entryPoint: this.props.fragmentEntryPoint || "main",
|
|
734
|
+
targets: [
|
|
735
|
+
{
|
|
736
|
+
// TODO exclamation mark hack!
|
|
737
|
+
format: getWebGPUTextureFormat((_b = (_a = this.device) == null ? void 0 : _a.canvasContext) == null ? void 0 : _b.format)
|
|
738
|
+
}
|
|
739
|
+
]
|
|
740
|
+
};
|
|
748
741
|
switch (this.props.topology) {
|
|
749
742
|
case "triangle-fan-webgl":
|
|
750
743
|
case "line-loop-webgl":
|
|
@@ -764,34 +757,59 @@ var WebGPURenderPipeline = class extends import_core8.RenderPipeline {
|
|
|
764
757
|
}
|
|
765
758
|
};
|
|
766
759
|
|
|
760
|
+
// dist/adapter/resources/webgpu-framebuffer.js
|
|
761
|
+
var import_core10 = require("@luma.gl/core");
|
|
762
|
+
var WebGPUFramebuffer = class extends import_core10.Framebuffer {
|
|
763
|
+
device;
|
|
764
|
+
constructor(device, props) {
|
|
765
|
+
super(device, props);
|
|
766
|
+
this.device = device;
|
|
767
|
+
this.autoCreateAttachmentTextures();
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
|
|
767
771
|
// dist/adapter/resources/webgpu-compute-pipeline.js
|
|
768
|
-
var
|
|
769
|
-
var WebGPUComputePipeline = class extends
|
|
772
|
+
var import_core11 = require("@luma.gl/core");
|
|
773
|
+
var WebGPUComputePipeline = class extends import_core11.ComputePipeline {
|
|
770
774
|
device;
|
|
771
775
|
handle;
|
|
776
|
+
/** For internal use to create BindGroups */
|
|
777
|
+
_bindGroupLayout = null;
|
|
778
|
+
_bindGroup = null;
|
|
779
|
+
/** For internal use to create BindGroups */
|
|
780
|
+
_bindings = {};
|
|
772
781
|
constructor(device, props) {
|
|
773
782
|
super(device, props);
|
|
774
783
|
this.device = device;
|
|
775
|
-
const webgpuShader = this.props.
|
|
784
|
+
const webgpuShader = this.props.shader;
|
|
776
785
|
this.handle = this.props.handle || this.device.handle.createComputePipeline({
|
|
777
786
|
label: this.props.id,
|
|
778
787
|
compute: {
|
|
779
788
|
module: webgpuShader.handle,
|
|
780
|
-
entryPoint: this.props.
|
|
781
|
-
|
|
789
|
+
entryPoint: this.props.entryPoint,
|
|
790
|
+
constants: this.props.constants
|
|
782
791
|
},
|
|
783
792
|
layout: "auto"
|
|
784
793
|
});
|
|
785
794
|
}
|
|
786
|
-
/**
|
|
787
|
-
|
|
788
|
-
|
|
795
|
+
/**
|
|
796
|
+
* @todo Use renderpass.setBindings() ?
|
|
797
|
+
* @todo Do we want to expose BindGroups in the API and remove this?
|
|
798
|
+
*/
|
|
799
|
+
setBindings(bindings) {
|
|
800
|
+
Object.assign(this._bindings, bindings);
|
|
801
|
+
}
|
|
802
|
+
/** Return a bind group created by setBindings */
|
|
803
|
+
_getBindGroup() {
|
|
804
|
+
this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);
|
|
805
|
+
this._bindGroup = this._bindGroup || getBindGroup(this.device.handle, this._bindGroupLayout, this.props.shaderLayout, this._bindings);
|
|
806
|
+
return this._bindGroup;
|
|
789
807
|
}
|
|
790
808
|
};
|
|
791
809
|
|
|
792
810
|
// dist/adapter/resources/webgpu-render-pass.js
|
|
793
|
-
var
|
|
794
|
-
var WebGPURenderPass = class extends
|
|
811
|
+
var import_core12 = require("@luma.gl/core");
|
|
812
|
+
var WebGPURenderPass = class extends import_core12.RenderPass {
|
|
795
813
|
device;
|
|
796
814
|
handle;
|
|
797
815
|
/** Active pipeline */
|
|
@@ -801,11 +819,23 @@ var WebGPURenderPass = class extends import_core10.RenderPass {
|
|
|
801
819
|
this.device = device;
|
|
802
820
|
const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();
|
|
803
821
|
const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
822
|
+
const webgpuQuerySet = props.timestampQuerySet;
|
|
823
|
+
if (webgpuQuerySet) {
|
|
824
|
+
renderPassDescriptor.occlusionQuerySet = webgpuQuerySet.handle;
|
|
825
|
+
}
|
|
826
|
+
if (device.features.has("timestamp-query")) {
|
|
827
|
+
const webgpuQuerySet2 = props.timestampQuerySet;
|
|
828
|
+
renderPassDescriptor.timestampWrites = webgpuQuerySet2 ? {
|
|
829
|
+
querySet: webgpuQuerySet2.handle,
|
|
830
|
+
beginningOfPassWriteIndex: props.beginTimestampIndex,
|
|
831
|
+
endOfPassWriteIndex: props.endTimestampIndex
|
|
832
|
+
} : void 0;
|
|
833
|
+
}
|
|
807
834
|
this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);
|
|
808
835
|
this.handle.label = this.props.id;
|
|
836
|
+
import_core12.log.groupCollapsed(3, `new WebGPURenderPass(${this.id})`)();
|
|
837
|
+
import_core12.log.probe(3, JSON.stringify(renderPassDescriptor, null, 2))();
|
|
838
|
+
import_core12.log.groupEnd(3)();
|
|
809
839
|
}
|
|
810
840
|
destroy() {
|
|
811
841
|
}
|
|
@@ -813,7 +843,7 @@ var WebGPURenderPass = class extends import_core10.RenderPass {
|
|
|
813
843
|
this.handle.end();
|
|
814
844
|
}
|
|
815
845
|
setPipeline(pipeline) {
|
|
816
|
-
this.pipeline = (0,
|
|
846
|
+
this.pipeline = (0, import_core12.cast)(pipeline);
|
|
817
847
|
this.handle.setPipeline(this.pipeline.handle);
|
|
818
848
|
}
|
|
819
849
|
/** Sets an array of bindings (uniform buffers, samplers, textures, ...) */
|
|
@@ -826,10 +856,10 @@ var WebGPURenderPass = class extends import_core10.RenderPass {
|
|
|
826
856
|
}
|
|
827
857
|
}
|
|
828
858
|
setIndexBuffer(buffer, indexFormat, offset = 0, size) {
|
|
829
|
-
this.handle.setIndexBuffer((0,
|
|
859
|
+
this.handle.setIndexBuffer((0, import_core12.cast)(buffer).handle, indexFormat, offset, size);
|
|
830
860
|
}
|
|
831
861
|
setVertexBuffer(slot, buffer, offset = 0) {
|
|
832
|
-
this.handle.setVertexBuffer(slot, (0,
|
|
862
|
+
this.handle.setVertexBuffer(slot, (0, import_core12.cast)(buffer).handle, offset);
|
|
833
863
|
}
|
|
834
864
|
draw(options) {
|
|
835
865
|
if (options.indexCount) {
|
|
@@ -864,11 +894,12 @@ var WebGPURenderPass = class extends import_core10.RenderPass {
|
|
|
864
894
|
insertDebugMarker(markerLabel) {
|
|
865
895
|
this.handle.insertDebugMarker(markerLabel);
|
|
866
896
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
897
|
+
beginOcclusionQuery(queryIndex) {
|
|
898
|
+
this.handle.beginOcclusionQuery(queryIndex);
|
|
899
|
+
}
|
|
900
|
+
endOcclusionQuery() {
|
|
901
|
+
this.handle.endOcclusionQuery();
|
|
902
|
+
}
|
|
872
903
|
// executeBundles(bundles: Iterable<GPURenderBundle>): void;
|
|
873
904
|
// INTERNAL
|
|
874
905
|
/**
|
|
@@ -885,11 +916,11 @@ var WebGPURenderPass = class extends import_core10.RenderPass {
|
|
|
885
916
|
colorClearValue: this.props.clearColor || [0, 0, 0, 0],
|
|
886
917
|
storeOp: this.props.discard ? "discard" : "store",
|
|
887
918
|
// ...colorAttachment,
|
|
888
|
-
view: colorAttachment.
|
|
919
|
+
view: colorAttachment.handle
|
|
889
920
|
}));
|
|
890
921
|
if (framebuffer.depthStencilAttachment) {
|
|
891
922
|
renderPassDescriptor.depthStencilAttachment = {
|
|
892
|
-
view: framebuffer.depthStencilAttachment.
|
|
923
|
+
view: framebuffer.depthStencilAttachment.handle
|
|
893
924
|
};
|
|
894
925
|
const { depthStencilAttachment } = renderPassDescriptor;
|
|
895
926
|
if (this.props.depthReadOnly) {
|
|
@@ -912,18 +943,29 @@ var WebGPURenderPass = class extends import_core10.RenderPass {
|
|
|
912
943
|
};
|
|
913
944
|
|
|
914
945
|
// dist/adapter/resources/webgpu-compute-pass.js
|
|
915
|
-
var
|
|
916
|
-
var WebGPUComputePass = class extends
|
|
946
|
+
var import_core13 = require("@luma.gl/core");
|
|
947
|
+
var WebGPUComputePass = class extends import_core13.ComputePass {
|
|
917
948
|
device;
|
|
918
949
|
handle;
|
|
919
|
-
|
|
950
|
+
_webgpuPipeline = null;
|
|
920
951
|
constructor(device, props) {
|
|
921
952
|
var _a;
|
|
922
953
|
super(device, props);
|
|
923
954
|
this.device = device;
|
|
955
|
+
let timestampWrites;
|
|
956
|
+
if (device.features.has("timestamp-query")) {
|
|
957
|
+
const webgpuQuerySet = props.timestampQuerySet;
|
|
958
|
+
if (webgpuQuerySet) {
|
|
959
|
+
timestampWrites = {
|
|
960
|
+
querySet: webgpuQuerySet.handle,
|
|
961
|
+
beginningOfPassWriteIndex: props.beginTimestampIndex,
|
|
962
|
+
endOfPassWriteIndex: props.endTimestampIndex
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
}
|
|
924
966
|
this.handle = this.props.handle || ((_a = device.commandEncoder) == null ? void 0 : _a.beginComputePass({
|
|
925
|
-
label: this.props.id
|
|
926
|
-
|
|
967
|
+
label: this.props.id,
|
|
968
|
+
timestampWrites
|
|
927
969
|
}));
|
|
928
970
|
}
|
|
929
971
|
/** @note no WebGPU destroy method, just gc */
|
|
@@ -935,29 +977,36 @@ var WebGPUComputePass = class extends import_core11.ComputePass {
|
|
|
935
977
|
setPipeline(pipeline) {
|
|
936
978
|
const wgpuPipeline = pipeline;
|
|
937
979
|
this.handle.setPipeline(wgpuPipeline.handle);
|
|
938
|
-
this.
|
|
980
|
+
this._webgpuPipeline = wgpuPipeline;
|
|
981
|
+
this.setBindings([]);
|
|
939
982
|
}
|
|
940
|
-
/**
|
|
983
|
+
/**
|
|
984
|
+
* Sets an array of bindings (uniform buffers, samplers, textures, ...)
|
|
985
|
+
* TODO - still some API confusion - does this method go here or on the pipeline?
|
|
986
|
+
*/
|
|
941
987
|
setBindings(bindings) {
|
|
942
|
-
|
|
988
|
+
const bindGroup = this._webgpuPipeline._getBindGroup();
|
|
989
|
+
this.handle.setBindGroup(0, bindGroup);
|
|
943
990
|
}
|
|
944
991
|
/**
|
|
945
992
|
* Dispatch work to be performed with the current ComputePipeline.
|
|
946
|
-
* @param x X dimension of the grid of
|
|
947
|
-
* @param y Y dimension of the grid of
|
|
948
|
-
* @param z Z dimension of the grid of
|
|
993
|
+
* @param x X dimension of the grid of work groups to dispatch.
|
|
994
|
+
* @param y Y dimension of the grid of work groups to dispatch.
|
|
995
|
+
* @param z Z dimension of the grid of work groups to dispatch.
|
|
949
996
|
*/
|
|
950
997
|
dispatch(x, y, z) {
|
|
951
998
|
this.handle.dispatchWorkgroups(x, y, z);
|
|
952
999
|
}
|
|
953
1000
|
/**
|
|
954
1001
|
* Dispatch work to be performed with the current ComputePipeline.
|
|
955
|
-
*
|
|
956
|
-
*
|
|
1002
|
+
*
|
|
1003
|
+
* Buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()
|
|
1004
|
+
* @param indirectBuffer
|
|
1005
|
+
* @param indirectOffset offset in buffer to the beginning of the dispatch data.
|
|
957
1006
|
*/
|
|
958
|
-
dispatchIndirect(indirectBuffer,
|
|
1007
|
+
dispatchIndirect(indirectBuffer, indirectByteOffset = 0) {
|
|
959
1008
|
const webgpuBuffer = indirectBuffer;
|
|
960
|
-
this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle,
|
|
1009
|
+
this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectByteOffset);
|
|
961
1010
|
}
|
|
962
1011
|
pushDebugGroup(groupLabel) {
|
|
963
1012
|
this.handle.pushDebugGroup(groupLabel);
|
|
@@ -971,22 +1020,15 @@ var WebGPUComputePass = class extends import_core11.ComputePass {
|
|
|
971
1020
|
};
|
|
972
1021
|
|
|
973
1022
|
// dist/adapter/resources/webgpu-vertex-array.js
|
|
974
|
-
var
|
|
1023
|
+
var import_core14 = require("@luma.gl/core");
|
|
975
1024
|
var import_env = require("@probe.gl/env");
|
|
976
|
-
var WebGPUVertexArray = class extends
|
|
1025
|
+
var WebGPUVertexArray = class extends import_core14.VertexArray {
|
|
977
1026
|
get [Symbol.toStringTag]() {
|
|
978
1027
|
return "WebGPUVertexArray";
|
|
979
1028
|
}
|
|
980
1029
|
device;
|
|
981
1030
|
/** Vertex Array is a helper class under WebGPU */
|
|
982
1031
|
handle;
|
|
983
|
-
/**
|
|
984
|
-
* Attribute 0 can not be disable on most desktop OpenGL based browsers
|
|
985
|
-
* TODO is this even an issue for WebGPU?
|
|
986
|
-
*/
|
|
987
|
-
static isConstantAttributeZeroSupported(device) {
|
|
988
|
-
return (0, import_env.getBrowser)() === "Chrome";
|
|
989
|
-
}
|
|
990
1032
|
// Create a VertexArray
|
|
991
1033
|
constructor(device, props) {
|
|
992
1034
|
super(device, props);
|
|
@@ -1005,49 +1047,39 @@ var WebGPUVertexArray = class extends import_core12.VertexArray {
|
|
|
1005
1047
|
setBuffer(bufferSlot, buffer) {
|
|
1006
1048
|
this.attributes[bufferSlot] = buffer;
|
|
1007
1049
|
}
|
|
1008
|
-
/** Set a location in vertex attributes array to a constant value, disables the location */
|
|
1009
|
-
setConstant(location, value) {
|
|
1010
|
-
import_core12.log.warn(`${this.id} constant attributes not supported on WebGPU`);
|
|
1011
|
-
}
|
|
1012
1050
|
bindBeforeRender(renderPass, firstIndex, indexCount) {
|
|
1013
1051
|
const webgpuRenderPass = renderPass;
|
|
1014
1052
|
const webgpuIndexBuffer = this.indexBuffer;
|
|
1015
1053
|
if (webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.handle) {
|
|
1016
|
-
|
|
1054
|
+
import_core14.log.warn("setting index buffer", webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.handle, webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.indexType)();
|
|
1017
1055
|
webgpuRenderPass.handle.setIndexBuffer(webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.handle, webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.indexType);
|
|
1018
1056
|
}
|
|
1019
1057
|
for (let location = 0; location < this.maxVertexAttributes; location++) {
|
|
1020
1058
|
const webgpuBuffer = this.attributes[location];
|
|
1021
1059
|
if (webgpuBuffer == null ? void 0 : webgpuBuffer.handle) {
|
|
1022
|
-
|
|
1060
|
+
import_core14.log.warn(`setting vertex buffer ${location}`, webgpuBuffer == null ? void 0 : webgpuBuffer.handle)();
|
|
1023
1061
|
webgpuRenderPass.handle.setVertexBuffer(location, webgpuBuffer == null ? void 0 : webgpuBuffer.handle);
|
|
1024
1062
|
}
|
|
1025
1063
|
}
|
|
1026
1064
|
}
|
|
1027
1065
|
unbindAfterRender(renderPass) {
|
|
1028
1066
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
var WebGPUFramebuffer = class extends import_core13.Framebuffer {
|
|
1037
|
-
device;
|
|
1038
|
-
constructor(device, props) {
|
|
1039
|
-
super(device, props);
|
|
1040
|
-
this.device = device;
|
|
1041
|
-
this.autoCreateAttachmentTextures();
|
|
1067
|
+
// DEPRECATED METHODS
|
|
1068
|
+
/**
|
|
1069
|
+
* @deprecated is this even an issue for WebGPU?
|
|
1070
|
+
* Attribute 0 can not be disable on most desktop OpenGL based browsers
|
|
1071
|
+
*/
|
|
1072
|
+
static isConstantAttributeZeroSupported(device) {
|
|
1073
|
+
return (0, import_env.getBrowser)() === "Chrome";
|
|
1042
1074
|
}
|
|
1043
1075
|
};
|
|
1044
1076
|
|
|
1045
1077
|
// dist/adapter/webgpu-canvas-context.js
|
|
1046
|
-
var
|
|
1078
|
+
var import_core15 = require("@luma.gl/core");
|
|
1079
|
+
var WebGPUCanvasContext = class extends import_core15.CanvasContext {
|
|
1047
1080
|
device;
|
|
1048
1081
|
gpuCanvasContext;
|
|
1049
1082
|
/** Format of returned textures: "bgra8unorm", "rgba8unorm", "rgba16float". */
|
|
1050
|
-
// @ts-ignore - TODO - fix this
|
|
1051
1083
|
format = navigator.gpu.getPreferredCanvasFormat();
|
|
1052
1084
|
/** Default stencil format for depth textures */
|
|
1053
1085
|
depthStencilFormat = "depth24plus";
|
|
@@ -1096,7 +1128,7 @@ var WebGPUCanvasContext = class extends import_core14.CanvasContext {
|
|
|
1096
1128
|
colorSpace: this.props.colorSpace,
|
|
1097
1129
|
alphaMode: this.props.alphaMode
|
|
1098
1130
|
});
|
|
1099
|
-
|
|
1131
|
+
import_core15.log.log(1, `Resized to ${this.width}x${this.height}px`)();
|
|
1100
1132
|
}
|
|
1101
1133
|
}
|
|
1102
1134
|
resize(options) {
|
|
@@ -1106,7 +1138,8 @@ var WebGPUCanvasContext = class extends import_core14.CanvasContext {
|
|
|
1106
1138
|
getCurrentTexture() {
|
|
1107
1139
|
return this.device._createTexture({
|
|
1108
1140
|
id: `${this.id}#color-texture`,
|
|
1109
|
-
handle: this.gpuCanvasContext.getCurrentTexture()
|
|
1141
|
+
handle: this.gpuCanvasContext.getCurrentTexture(),
|
|
1142
|
+
format: this.format
|
|
1110
1143
|
});
|
|
1111
1144
|
}
|
|
1112
1145
|
/** We build render targets on demand (i.e. not when size changes but when about to render) */
|
|
@@ -1124,16 +1157,45 @@ var WebGPUCanvasContext = class extends import_core14.CanvasContext {
|
|
|
1124
1157
|
}
|
|
1125
1158
|
};
|
|
1126
1159
|
|
|
1160
|
+
// dist/adapter/resources/webgpu-query-set.js
|
|
1161
|
+
var import_core16 = require("@luma.gl/core");
|
|
1162
|
+
var WebGPUQuerySet = class extends import_core16.QuerySet {
|
|
1163
|
+
device;
|
|
1164
|
+
handle;
|
|
1165
|
+
constructor(device, props) {
|
|
1166
|
+
super(device, props);
|
|
1167
|
+
this.device = device;
|
|
1168
|
+
this.handle = this.props.handle || this.device.handle.createQuerySet({
|
|
1169
|
+
type: this.props.type,
|
|
1170
|
+
count: this.props.count
|
|
1171
|
+
});
|
|
1172
|
+
this.handle.label = this.props.id;
|
|
1173
|
+
}
|
|
1174
|
+
destroy() {
|
|
1175
|
+
var _a;
|
|
1176
|
+
(_a = this.handle) == null ? void 0 : _a.destroy();
|
|
1177
|
+
this.handle = null;
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
|
|
1127
1181
|
// dist/adapter/webgpu-device.js
|
|
1128
|
-
var _WebGPUDevice = class extends
|
|
1182
|
+
var _WebGPUDevice = class extends import_core17.Device {
|
|
1183
|
+
/** type of this device */
|
|
1184
|
+
type = "webgpu";
|
|
1185
|
+
/** The underlying WebGPU device */
|
|
1129
1186
|
handle;
|
|
1187
|
+
/* The underlying WebGPU adapter */
|
|
1130
1188
|
adapter;
|
|
1189
|
+
/* The underlying WebGPU adapter's info */
|
|
1190
|
+
adapterInfo;
|
|
1191
|
+
features;
|
|
1192
|
+
info;
|
|
1193
|
+
limits;
|
|
1131
1194
|
lost;
|
|
1132
1195
|
canvasContext = null;
|
|
1196
|
+
_isLost = false;
|
|
1133
1197
|
commandEncoder = null;
|
|
1134
1198
|
renderPass = null;
|
|
1135
|
-
_info;
|
|
1136
|
-
_isLost = false;
|
|
1137
1199
|
/** Check if WebGPU is available */
|
|
1138
1200
|
static isSupported() {
|
|
1139
1201
|
return Boolean(typeof navigator !== "undefined" && navigator.gpu);
|
|
@@ -1142,7 +1204,7 @@ var _WebGPUDevice = class extends import_core15.Device {
|
|
|
1142
1204
|
if (!navigator.gpu) {
|
|
1143
1205
|
throw new Error("WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu");
|
|
1144
1206
|
}
|
|
1145
|
-
|
|
1207
|
+
import_core17.log.groupCollapsed(1, "WebGPUDevice created")();
|
|
1146
1208
|
const adapter = await navigator.gpu.requestAdapter({
|
|
1147
1209
|
powerPreference: "high-performance"
|
|
1148
1210
|
// forceSoftware: false
|
|
@@ -1151,47 +1213,40 @@ var _WebGPUDevice = class extends import_core15.Device {
|
|
|
1151
1213
|
throw new Error("Failed to request WebGPU adapter");
|
|
1152
1214
|
}
|
|
1153
1215
|
const adapterInfo = await adapter.requestAdapterInfo();
|
|
1154
|
-
|
|
1216
|
+
import_core17.log.probe(2, "Adapter available", adapterInfo)();
|
|
1217
|
+
const requiredFeatures = [];
|
|
1218
|
+
const requiredLimits = {};
|
|
1219
|
+
if (props.requestMaxLimits) {
|
|
1220
|
+
requiredFeatures.push(...Array.from(adapter.features));
|
|
1221
|
+
for (const key in adapter.limits) {
|
|
1222
|
+
requiredLimits[key] = adapter.limits[key];
|
|
1223
|
+
}
|
|
1224
|
+
delete requiredLimits.minSubgroupSize;
|
|
1225
|
+
delete requiredLimits.maxSubgroupSize;
|
|
1226
|
+
}
|
|
1155
1227
|
const gpuDevice = await adapter.requestDevice({
|
|
1156
|
-
requiredFeatures
|
|
1157
|
-
|
|
1158
|
-
// requiredLimits: adapter.limits
|
|
1228
|
+
requiredFeatures,
|
|
1229
|
+
requiredLimits
|
|
1159
1230
|
});
|
|
1160
|
-
|
|
1231
|
+
import_core17.log.probe(1, "GPUDevice available")();
|
|
1161
1232
|
if (typeof props.canvas === "string") {
|
|
1162
|
-
await
|
|
1163
|
-
|
|
1233
|
+
await import_core17.CanvasContext.pageLoaded;
|
|
1234
|
+
import_core17.log.probe(1, "DOM is loaded")();
|
|
1164
1235
|
}
|
|
1165
1236
|
const device = new _WebGPUDevice(gpuDevice, adapter, adapterInfo, props);
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1237
|
+
import_core17.log.probe(1, "Device created. For more info, set chrome://flags/#enable-webgpu-developer-features")();
|
|
1238
|
+
import_core17.log.table(1, device.info)();
|
|
1239
|
+
import_core17.log.groupEnd(1)();
|
|
1169
1240
|
return device;
|
|
1170
1241
|
}
|
|
1171
1242
|
constructor(device, adapter, adapterInfo, props) {
|
|
1172
|
-
super({ ...props, id: props.id || (0,
|
|
1243
|
+
super({ ...props, id: props.id || (0, import_core17.uid)("webgpu-device") });
|
|
1173
1244
|
this.handle = device;
|
|
1174
1245
|
this.adapter = adapter;
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
const gpu = vendor === "apple" ? "apple" : "unknown";
|
|
1180
|
-
const gpuArchitecture = adapterInfo.architecture || "unknown";
|
|
1181
|
-
const gpuBackend = adapterInfo.backend || "unknown";
|
|
1182
|
-
const gpuType = (adapterInfo.type || "").split(" ")[0].toLowerCase() || "unknown";
|
|
1183
|
-
this._info = {
|
|
1184
|
-
type: "webgpu",
|
|
1185
|
-
vendor,
|
|
1186
|
-
renderer,
|
|
1187
|
-
version,
|
|
1188
|
-
gpu,
|
|
1189
|
-
gpuType,
|
|
1190
|
-
gpuBackend,
|
|
1191
|
-
gpuArchitecture,
|
|
1192
|
-
shadingLanguage: "wgsl",
|
|
1193
|
-
shadingLanguageVersion: 100
|
|
1194
|
-
};
|
|
1246
|
+
this.adapterInfo = adapterInfo;
|
|
1247
|
+
this.info = this._getInfo();
|
|
1248
|
+
this.features = this._getFeatures();
|
|
1249
|
+
this.limits = this.handle.limits;
|
|
1195
1250
|
this.lost = new Promise(async (resolve) => {
|
|
1196
1251
|
const lostInfo = await this.handle.lost;
|
|
1197
1252
|
this._isLost = true;
|
|
@@ -1203,7 +1258,6 @@ var _WebGPUDevice = class extends import_core15.Device {
|
|
|
1203
1258
|
width: props.width,
|
|
1204
1259
|
container: props.container
|
|
1205
1260
|
});
|
|
1206
|
-
this.features = this._getFeatures();
|
|
1207
1261
|
}
|
|
1208
1262
|
// TODO
|
|
1209
1263
|
// Load the glslang module now so that it is available synchronously when compiling shaders
|
|
@@ -1212,19 +1266,12 @@ var _WebGPUDevice = class extends import_core15.Device {
|
|
|
1212
1266
|
destroy() {
|
|
1213
1267
|
this.handle.destroy();
|
|
1214
1268
|
}
|
|
1215
|
-
get info() {
|
|
1216
|
-
return this._info;
|
|
1217
|
-
}
|
|
1218
|
-
features;
|
|
1219
|
-
get limits() {
|
|
1220
|
-
return this.handle.limits;
|
|
1221
|
-
}
|
|
1222
1269
|
isTextureFormatSupported(format) {
|
|
1223
1270
|
return !format.includes("webgl");
|
|
1224
1271
|
}
|
|
1225
1272
|
/** @todo implement proper check? */
|
|
1226
1273
|
isTextureFormatFilterable(format) {
|
|
1227
|
-
return this.isTextureFormatSupported(format);
|
|
1274
|
+
return this.isTextureFormatSupported(format) && !format.startsWith("depth") && !format.startsWith("stencil");
|
|
1228
1275
|
}
|
|
1229
1276
|
/** @todo implement proper check? */
|
|
1230
1277
|
isTextureFormatRenderable(format) {
|
|
@@ -1253,7 +1300,7 @@ var _WebGPUDevice = class extends import_core15.Device {
|
|
|
1253
1300
|
return new WebGPURenderPipeline(this, props);
|
|
1254
1301
|
}
|
|
1255
1302
|
createFramebuffer(props) {
|
|
1256
|
-
|
|
1303
|
+
return new WebGPUFramebuffer(this, props);
|
|
1257
1304
|
}
|
|
1258
1305
|
createComputePipeline(props) {
|
|
1259
1306
|
return new WebGPUComputePipeline(this, props);
|
|
@@ -1280,18 +1327,12 @@ var _WebGPUDevice = class extends import_core15.Device {
|
|
|
1280
1327
|
createTransformFeedback(props) {
|
|
1281
1328
|
throw new Error("Transform feedback not supported in WebGPU");
|
|
1282
1329
|
}
|
|
1330
|
+
createQuerySet(props) {
|
|
1331
|
+
return new WebGPUQuerySet(this, props);
|
|
1332
|
+
}
|
|
1283
1333
|
createCanvasContext(props) {
|
|
1284
1334
|
return new WebGPUCanvasContext(this, this.adapter, props);
|
|
1285
1335
|
}
|
|
1286
|
-
/**
|
|
1287
|
-
* Gets default renderpass encoder.
|
|
1288
|
-
* Creates a new encoder against default canvasContext if not already created
|
|
1289
|
-
* @note Called internally by Model.
|
|
1290
|
-
* @deprecated Create explicit pass with device.beginRenderPass
|
|
1291
|
-
*/
|
|
1292
|
-
getDefaultRenderPass() {
|
|
1293
|
-
throw new Error("a");
|
|
1294
|
-
}
|
|
1295
1336
|
submit() {
|
|
1296
1337
|
var _a;
|
|
1297
1338
|
const commandBuffer = (_a = this.commandEncoder) == null ? void 0 : _a.finish();
|
|
@@ -1300,6 +1341,29 @@ var _WebGPUDevice = class extends import_core15.Device {
|
|
|
1300
1341
|
}
|
|
1301
1342
|
this.commandEncoder = null;
|
|
1302
1343
|
}
|
|
1344
|
+
// PRIVATE METHODS
|
|
1345
|
+
_getInfo() {
|
|
1346
|
+
const [driver, driverVersion] = (this.adapterInfo.driver || "").split(" Version ");
|
|
1347
|
+
const vendor = this.adapterInfo.vendor || this.adapter.__brand || "unknown";
|
|
1348
|
+
const renderer = driver || "";
|
|
1349
|
+
const version = driverVersion || "";
|
|
1350
|
+
const gpu = vendor === "apple" ? "apple" : "unknown";
|
|
1351
|
+
const gpuArchitecture = this.adapterInfo.architecture || "unknown";
|
|
1352
|
+
const gpuBackend = this.adapterInfo.backend || "unknown";
|
|
1353
|
+
const gpuType = (this.adapterInfo.type || "").split(" ")[0].toLowerCase() || "unknown";
|
|
1354
|
+
return {
|
|
1355
|
+
type: "webgpu",
|
|
1356
|
+
vendor,
|
|
1357
|
+
renderer,
|
|
1358
|
+
version,
|
|
1359
|
+
gpu,
|
|
1360
|
+
gpuType,
|
|
1361
|
+
gpuBackend,
|
|
1362
|
+
gpuArchitecture,
|
|
1363
|
+
shadingLanguage: "wgsl",
|
|
1364
|
+
shadingLanguageVersion: 100
|
|
1365
|
+
};
|
|
1366
|
+
}
|
|
1303
1367
|
_getFeatures() {
|
|
1304
1368
|
const features = new Set(this.handle.features);
|
|
1305
1369
|
if (features.has("depth-clamping")) {
|
|
@@ -1310,19 +1374,18 @@ var _WebGPUDevice = class extends import_core15.Device {
|
|
|
1310
1374
|
features.add("texture-compression-bc5-webgl");
|
|
1311
1375
|
}
|
|
1312
1376
|
const WEBGPU_ALWAYS_FEATURES = [
|
|
1313
|
-
"webgpu",
|
|
1314
|
-
"wgsl",
|
|
1315
1377
|
"timer-query-webgl",
|
|
1316
|
-
"
|
|
1317
|
-
"float16-filterable-linear-webgl",
|
|
1318
|
-
"texture-filterable-anisotropic-webgl",
|
|
1378
|
+
"compilation-status-async-webgl",
|
|
1319
1379
|
"float32-renderable-webgl",
|
|
1320
|
-
"float16-renderable-webgl"
|
|
1380
|
+
"float16-renderable-webgl",
|
|
1381
|
+
"norm16-renderable-webgl",
|
|
1382
|
+
"texture-filterable-anisotropic-webgl",
|
|
1383
|
+
"shader-noperspective-interpolation-webgl"
|
|
1321
1384
|
];
|
|
1322
1385
|
for (const feature of WEBGPU_ALWAYS_FEATURES) {
|
|
1323
1386
|
features.add(feature);
|
|
1324
1387
|
}
|
|
1325
|
-
return features;
|
|
1388
|
+
return new import_core17.DeviceFeatures(Array.from(features), this.props.disabledFeatures);
|
|
1326
1389
|
}
|
|
1327
1390
|
copyExternalImageToTexture(options) {
|
|
1328
1391
|
var _a;
|