@luma.gl/webgpu 9.1.0-alpha.14 → 9.1.0-alpha.16
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/get-vertex-buffer-layout.js +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.d.ts +4 -4
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js +4 -4
- package/dist/adapter/resources/webgpu-render-pass.js +3 -3
- package/dist/adapter/resources/webgpu-shader.d.ts +1 -0
- package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-shader.js +3 -0
- package/dist/adapter/webgpu-adapter.d.ts.map +1 -1
- package/dist/adapter/webgpu-adapter.js +2 -6
- package/dist/adapter/webgpu-device.d.ts +1 -1
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +6 -10
- package/dist/dist.dev.js +14 -17
- package/dist/dist.min.js +1 -1
- package/dist/index.cjs +14 -17
- package/dist/index.cjs.map +3 -3
- package/package.json +3 -3
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +1 -1
- package/src/adapter/resources/webgpu-command-encoder.ts +8 -8
- package/src/adapter/resources/webgpu-render-pass.ts +3 -3
- package/src/adapter/resources/webgpu-shader.ts +4 -0
- package/src/adapter/webgpu-adapter.ts +2 -7
- package/src/adapter/webgpu-device.ts +9 -12
|
@@ -122,7 +122,7 @@ export function getBufferSlots(shaderLayout, bufferLayout) {
|
|
|
122
122
|
* @throws if name has already been referenced
|
|
123
123
|
*/
|
|
124
124
|
function findAttributeLayout(shaderLayout, name, attributeNames) {
|
|
125
|
-
const attribute = shaderLayout.attributes.find(
|
|
125
|
+
const attribute = shaderLayout.attributes.find(attribute_ => attribute_.name === name);
|
|
126
126
|
if (!attribute) {
|
|
127
127
|
log.warn(`Unknown attribute ${name}`)();
|
|
128
128
|
return null;
|
|
@@ -11,18 +11,18 @@ export declare class WebGPUCommandEncoder extends CommandEncoder {
|
|
|
11
11
|
id?: string;
|
|
12
12
|
}): GPUCommandBuffer;
|
|
13
13
|
copyBufferToBuffer(options: {
|
|
14
|
-
|
|
14
|
+
sourceBuffer: Buffer;
|
|
15
15
|
sourceOffset?: number;
|
|
16
|
-
|
|
16
|
+
destinationBuffer: Buffer;
|
|
17
17
|
destinationOffset?: number;
|
|
18
18
|
size?: number;
|
|
19
19
|
}): void;
|
|
20
20
|
copyBufferToTexture(options: {
|
|
21
|
-
|
|
21
|
+
sourceBuffer: Buffer;
|
|
22
22
|
offset?: number;
|
|
23
23
|
bytesPerRow: number;
|
|
24
24
|
rowsPerImage: number;
|
|
25
|
-
|
|
25
|
+
destinationTexture: Texture;
|
|
26
26
|
mipLevel?: number;
|
|
27
27
|
aspect?: 'all' | 'stencil-only' | 'depth-only';
|
|
28
28
|
origin?: number[] | [number, number, number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AACnF,OAAO,KAAK,EAAC,2BAA2B,EAAE,0BAA0B,EAAC,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAC,YAAY,EAAC,4BAAyB;AAG9C,OAAO,EAAC,cAAc,EAAC,8BAA2B;AAElD,qBAAa,oBAAqB,SAAQ,cAAc;IACtD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;gBAEvB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,mBAAmB;IAYnD,OAAO,IAAI,IAAI;IAExB,MAAM,CAAC,OAAO,CAAC,EAAE;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,gBAAg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E,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7C,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;KAC9C,GAAG,IAAI;IAyBR,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,IAAI;IAW9D,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI;IAWvD,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIxC,aAAa,IAAI,IAAI;IAIrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAI5C,eAAe,CACtB,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,GACA,IAAI;CAWR"}
|
|
@@ -23,13 +23,13 @@ export class WebGPUCommandEncoder extends CommandEncoder {
|
|
|
23
23
|
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
24
24
|
// beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
|
|
25
25
|
copyBufferToBuffer(options) {
|
|
26
|
-
const webgpuSourceBuffer = options.
|
|
27
|
-
const WebGPUDestinationBuffer = options.
|
|
26
|
+
const webgpuSourceBuffer = options.sourceBuffer;
|
|
27
|
+
const WebGPUDestinationBuffer = options.destinationBuffer;
|
|
28
28
|
this.handle.copyBufferToBuffer(webgpuSourceBuffer.handle, options.sourceOffset ?? 0, WebGPUDestinationBuffer.handle, options.destinationOffset ?? 0, options.size ?? 0);
|
|
29
29
|
}
|
|
30
30
|
copyBufferToTexture(options) {
|
|
31
|
-
const webgpuSourceBuffer = options.
|
|
32
|
-
const WebGPUDestinationTexture = options.
|
|
31
|
+
const webgpuSourceBuffer = options.sourceBuffer;
|
|
32
|
+
const WebGPUDestinationTexture = options.destinationTexture;
|
|
33
33
|
this.handle.copyBufferToTexture({
|
|
34
34
|
buffer: webgpuSourceBuffer.handle,
|
|
35
35
|
offset: options.offset ?? 0,
|
|
@@ -17,10 +17,10 @@ export class WebGPURenderPass extends RenderPass {
|
|
|
17
17
|
renderPassDescriptor.occlusionQuerySet = webgpuQuerySet.handle;
|
|
18
18
|
}
|
|
19
19
|
if (device.features.has('timestamp-query')) {
|
|
20
|
-
const
|
|
21
|
-
renderPassDescriptor.timestampWrites =
|
|
20
|
+
const webgpuTSQuerySet = props.timestampQuerySet;
|
|
21
|
+
renderPassDescriptor.timestampWrites = webgpuTSQuerySet
|
|
22
22
|
? {
|
|
23
|
-
querySet:
|
|
23
|
+
querySet: webgpuTSQuerySet.handle,
|
|
24
24
|
beginningOfPassWriteIndex: props.beginTimestampIndex,
|
|
25
25
|
endOfPassWriteIndex: props.endTimestampIndex
|
|
26
26
|
}
|
|
@@ -8,6 +8,7 @@ export declare class WebGPUShader extends Shader {
|
|
|
8
8
|
readonly device: WebGPUDevice;
|
|
9
9
|
readonly handle: GPUShaderModule;
|
|
10
10
|
constructor(device: WebGPUDevice, props: ShaderProps);
|
|
11
|
+
get asyncCompilationStatus(): Promise<any>;
|
|
11
12
|
_checkCompilationError(errorScope: Promise<GPUError | null>): Promise<void>;
|
|
12
13
|
destroy(): void;
|
|
13
14
|
/** Returns compilation info for this shader */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-shader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,eAAe,CAAC;AAChE,OAAO,EAAC,MAAM,EAAM,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AAEnD;;GAEG;AACH,qBAAa,YAAa,SAAQ,MAAM;IACtC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;gBAErB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW;
|
|
1
|
+
{"version":3,"file":"webgpu-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-shader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,eAAe,CAAC;AAChE,OAAO,EAAC,MAAM,EAAM,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AAEnD;;GAEG;AACH,qBAAa,YAAa,SAAQ,MAAM;IACtC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;gBAErB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW;IAYpD,IAAI,sBAAsB,IAAI,OAAO,CAAC,GAAG,CAAC,CAEzC;IAEK,sBAAsB,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAcxE,OAAO,IAAI,IAAI;IAOxB,+CAA+C;IACzC,kBAAkB,IAAI,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;IAO/D,SAAS,CAAC,YAAY,IAAI,eAAe;CAU1C"}
|
|
@@ -16,6 +16,9 @@ export class WebGPUShader extends Shader {
|
|
|
16
16
|
this.handle.label = this.props.id;
|
|
17
17
|
this._checkCompilationError(this.device.handle.popErrorScope());
|
|
18
18
|
}
|
|
19
|
+
get asyncCompilationStatus() {
|
|
20
|
+
return this.getCompilationInfo().then(() => this.compilationStatus);
|
|
21
|
+
}
|
|
19
22
|
async _checkCompilationError(errorScope) {
|
|
20
23
|
const error = (await errorScope);
|
|
21
24
|
if (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"webgpu-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAE,WAAW,EAAM,MAAM,eAAe,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAI7C,qBAAa,aAAc,SAAQ,OAAO;IACxC,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,YAAkC;;IAQ/C,mCAAmC;IACnC,WAAW,IAAI,OAAO;IAIhB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IA0DjD,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC;CAGvD;AAED,eAAO,MAAM,aAAa,eAAsB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { Adapter,
|
|
4
|
+
import { Adapter, log } from '@luma.gl/core';
|
|
5
5
|
import { WebGPUDevice } from "./webgpu-device.js";
|
|
6
6
|
// / <reference types="@webgpu/types" />
|
|
7
7
|
export class WebGPUAdapter extends Adapter {
|
|
@@ -32,7 +32,7 @@ export class WebGPUAdapter extends Adapter {
|
|
|
32
32
|
log.probe(2, 'Adapter available', adapterInfo)();
|
|
33
33
|
const requiredFeatures = [];
|
|
34
34
|
const requiredLimits = {};
|
|
35
|
-
if (props.
|
|
35
|
+
if (props._requestMaxLimits) {
|
|
36
36
|
// Require all features
|
|
37
37
|
requiredFeatures.push(...Array.from(adapter.features));
|
|
38
38
|
// Require all limits
|
|
@@ -51,10 +51,6 @@ export class WebGPUAdapter extends Adapter {
|
|
|
51
51
|
requiredLimits
|
|
52
52
|
});
|
|
53
53
|
log.probe(1, 'GPUDevice available')();
|
|
54
|
-
if (typeof props.canvas === 'string') {
|
|
55
|
-
await CanvasContext.pageLoaded;
|
|
56
|
-
log.probe(1, 'DOM is loaded')();
|
|
57
|
-
}
|
|
58
54
|
const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo);
|
|
59
55
|
log.probe(1, 'Device created. For more info, set chrome://flags/#enable-webgpu-developer-features')();
|
|
60
56
|
log.table(1, device.info)();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DeviceInfo, DeviceLimits, CanvasContextProps, BufferProps, SamplerProps, ShaderProps, Texture, TextureProps, TextureFormat, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipelineProps, RenderPassProps, ComputePassProps, VertexArrayProps, TransformFeedback, TransformFeedbackProps, QuerySet, QuerySetProps, DeviceProps } from '@luma.gl/core';
|
|
2
2
|
import { Device, DeviceFeatures } from '@luma.gl/core';
|
|
3
3
|
import { WebGPUBuffer } from "./resources/webgpu-buffer.js";
|
|
4
4
|
import { WebGPUTexture } from "./resources/webgpu-texture.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-device.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"webgpu-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-device.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EAEZ,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,OAAO,EACP,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAEhB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,QAAQ,EACR,aAAa,EACb,WAAW,EACZ,MAAM,eAAe,CAAC;AACvB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AAO,EAAE;QAClC,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,KAAK,GAAG,cAAc,GAAG,YAAY,CAAC;QAC/C,UAAU,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;QACnC,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAE7B,MAAM,EAAE,WAAW,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,eAAe,CAAC;QAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QAEjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI;CAyCT"}
|
|
@@ -55,14 +55,10 @@ export class WebGPUDevice extends Device {
|
|
|
55
55
|
resolve({ reason: 'destroyed', message: lostInfo.message });
|
|
56
56
|
});
|
|
57
57
|
// Note: WebGPU devices can be created without a canvas, for compute shader purposes
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
width: props.width,
|
|
63
|
-
container: props.container
|
|
64
|
-
});
|
|
65
|
-
// }
|
|
58
|
+
if (props.createCanvasContext) {
|
|
59
|
+
const canvasContextProps = props.createCanvasContext === true ? {} : props.createCanvasContext;
|
|
60
|
+
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);
|
|
61
|
+
}
|
|
66
62
|
}
|
|
67
63
|
// TODO
|
|
68
64
|
// Load the glslang module now so that it is available synchronously when compiling shaders
|
|
@@ -88,7 +84,7 @@ export class WebGPUDevice extends Device {
|
|
|
88
84
|
return this._isLost;
|
|
89
85
|
}
|
|
90
86
|
createBuffer(props) {
|
|
91
|
-
const newProps = this.
|
|
87
|
+
const newProps = this._normalizeBufferProps(props);
|
|
92
88
|
return new WebGPUBuffer(this, newProps);
|
|
93
89
|
}
|
|
94
90
|
createTexture(props) {
|
|
@@ -199,7 +195,7 @@ export class WebGPUDevice extends Device {
|
|
|
199
195
|
for (const feature of WEBGPU_ALWAYS_FEATURES) {
|
|
200
196
|
features.add(feature);
|
|
201
197
|
}
|
|
202
|
-
return new DeviceFeatures(Array.from(features), this.props.
|
|
198
|
+
return new DeviceFeatures(Array.from(features), this.props._disabledFeatures);
|
|
203
199
|
}
|
|
204
200
|
copyExternalImageToTexture(options) {
|
|
205
201
|
const { source, sourceX = 0, sourceY = 0, texture, mipLevel = 0, aspect = 'all', colorSpace = 'display-p3', premultipliedAlpha = false,
|
package/dist/dist.dev.js
CHANGED
|
@@ -445,6 +445,9 @@ var __exports__ = (() => {
|
|
|
445
445
|
this.handle.label = this.props.id;
|
|
446
446
|
this._checkCompilationError(this.device.handle.popErrorScope());
|
|
447
447
|
}
|
|
448
|
+
get asyncCompilationStatus() {
|
|
449
|
+
return this.getCompilationInfo().then(() => this.compilationStatus);
|
|
450
|
+
}
|
|
448
451
|
async _checkCompilationError(errorScope) {
|
|
449
452
|
const error = await errorScope;
|
|
450
453
|
if (error) {
|
|
@@ -790,7 +793,7 @@ var __exports__ = (() => {
|
|
|
790
793
|
return vertexBufferLayouts;
|
|
791
794
|
}
|
|
792
795
|
function findAttributeLayout(shaderLayout, name, attributeNames) {
|
|
793
|
-
const attribute = shaderLayout.attributes.find((
|
|
796
|
+
const attribute = shaderLayout.attributes.find((attribute_) => attribute_.name === name);
|
|
794
797
|
if (!attribute) {
|
|
795
798
|
import_core8.log.warn(`Unknown attribute ${name}`)();
|
|
796
799
|
return null;
|
|
@@ -978,9 +981,9 @@ var __exports__ = (() => {
|
|
|
978
981
|
renderPassDescriptor.occlusionQuerySet = webgpuQuerySet.handle;
|
|
979
982
|
}
|
|
980
983
|
if (device.features.has("timestamp-query")) {
|
|
981
|
-
const
|
|
982
|
-
renderPassDescriptor.timestampWrites =
|
|
983
|
-
querySet:
|
|
984
|
+
const webgpuTSQuerySet = props.timestampQuerySet;
|
|
985
|
+
renderPassDescriptor.timestampWrites = webgpuTSQuerySet ? {
|
|
986
|
+
querySet: webgpuTSQuerySet.handle,
|
|
984
987
|
beginningOfPassWriteIndex: props.beginTimestampIndex,
|
|
985
988
|
endOfPassWriteIndex: props.endTimestampIndex
|
|
986
989
|
} : void 0;
|
|
@@ -1449,12 +1452,10 @@ var __exports__ = (() => {
|
|
|
1449
1452
|
this._isLost = true;
|
|
1450
1453
|
resolve({ reason: "destroyed", message: lostInfo.message });
|
|
1451
1454
|
});
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
container: props.container
|
|
1457
|
-
});
|
|
1455
|
+
if (props.createCanvasContext) {
|
|
1456
|
+
const canvasContextProps = props.createCanvasContext === true ? {} : props.createCanvasContext;
|
|
1457
|
+
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);
|
|
1458
|
+
}
|
|
1458
1459
|
}
|
|
1459
1460
|
// TODO
|
|
1460
1461
|
// Load the glslang module now so that it is available synchronously when compiling shaders
|
|
@@ -1478,7 +1479,7 @@ var __exports__ = (() => {
|
|
|
1478
1479
|
return this._isLost;
|
|
1479
1480
|
}
|
|
1480
1481
|
createBuffer(props) {
|
|
1481
|
-
const newProps = this.
|
|
1482
|
+
const newProps = this._normalizeBufferProps(props);
|
|
1482
1483
|
return new WebGPUBuffer(this, newProps);
|
|
1483
1484
|
}
|
|
1484
1485
|
createTexture(props) {
|
|
@@ -1581,7 +1582,7 @@ var __exports__ = (() => {
|
|
|
1581
1582
|
for (const feature of WEBGPU_ALWAYS_FEATURES) {
|
|
1582
1583
|
features.add(feature);
|
|
1583
1584
|
}
|
|
1584
|
-
return new import_core17.DeviceFeatures(Array.from(features), this.props.
|
|
1585
|
+
return new import_core17.DeviceFeatures(Array.from(features), this.props._disabledFeatures);
|
|
1585
1586
|
}
|
|
1586
1587
|
copyExternalImageToTexture(options) {
|
|
1587
1588
|
const {
|
|
@@ -1653,7 +1654,7 @@ var __exports__ = (() => {
|
|
|
1653
1654
|
import_core18.log.probe(2, "Adapter available", adapterInfo)();
|
|
1654
1655
|
const requiredFeatures = [];
|
|
1655
1656
|
const requiredLimits = {};
|
|
1656
|
-
if (props.
|
|
1657
|
+
if (props._requestMaxLimits) {
|
|
1657
1658
|
requiredFeatures.push(...Array.from(adapter.features));
|
|
1658
1659
|
const limits = Object.keys(adapter.limits).filter(
|
|
1659
1660
|
(key) => !["minSubgroupSize", "maxSubgroupSize"].includes(key)
|
|
@@ -1671,10 +1672,6 @@ var __exports__ = (() => {
|
|
|
1671
1672
|
requiredLimits
|
|
1672
1673
|
});
|
|
1673
1674
|
import_core18.log.probe(1, "GPUDevice available")();
|
|
1674
|
-
if (typeof props.canvas === "string") {
|
|
1675
|
-
await import_core18.CanvasContext.pageLoaded;
|
|
1676
|
-
import_core18.log.probe(1, "DOM is loaded")();
|
|
1677
|
-
}
|
|
1678
1675
|
const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo);
|
|
1679
1676
|
import_core18.log.probe(
|
|
1680
1677
|
1,
|
package/dist/dist.min.js
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['luma'] = factory();
|
|
6
6
|
else root['luma'] = factory();})(globalThis, function () {
|
|
7
|
-
var __exports__=(()=>{var we=Object.create;var R=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Se=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var Pe=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ee=(n,e)=>{for(var t in e)R(n,t,{get:e[t],enumerable:!0})},I=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ve(e))!Ce.call(n,i)&&i!==t&&R(n,i,{get:()=>e[i],enumerable:!(r=ye(e,i))||r.enumerable});return n},O=(n,e,t)=>(I(n,e,"default"),t&&I(t,e,"default")),h=(n,e,t)=>(t=n!=null?we(Se(n)):{},I(e||!n||!n.__esModule?R(t,"default",{value:n,enumerable:!0}):t,n)),Be=n=>I(R({},"__esModule",{value:!0}),n);var o=Pe((Fe,te)=>{te.exports=globalThis.luma});var D={};Ee(D,{WebGPUBuffer:()=>b,WebGPUDevice:()=>y,WebGPUSampler:()=>p,WebGPUShader:()=>C,WebGPUTexture:()=>S,webgpuAdapter:()=>fe});O(D,h(o(),1));var c=h(o(),1);var X=h(o(),1);var F=h(o(),1);function Ae(n){return n.byteLength||n.data?.byteLength||0}var b=class extends F.Buffer{device;handle;byteLength;constructor(e,t){super(e,t),this.device=e,this.byteLength=Ae(t);let r=Boolean(t.data),i=Math.ceil(this.byteLength/4)*4;this.handle=this.props.handle||this.device.handle.createBuffer({size:i,usage:this.props.usage||GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:this.props.mappedAtCreation||r,label:this.props.id}),t.data&&this._writeMapped(t.data),r&&!t.mappedAtCreation&&this.handle.unmap()}destroy(){this.handle?.destroy(),this.handle=null}write(e,t=0){this.device.handle.queue.writeBuffer(this.handle,t,e.buffer,e.byteOffset,e.byteLength)}async readAsync(e=0,t=this.byteLength){let r=new b(this.device,{usage:F.Buffer.MAP_READ|F.Buffer.COPY_DST,byteLength:t}),i=this.device.handle.createCommandEncoder();i.copyBufferToBuffer(this.handle,e,r.handle,0,t),this.device.handle.queue.submit([i.finish()]),await r.handle.mapAsync(GPUMapMode.READ,e,t);let s=r.handle.getMappedRange().slice(0);return r.handle.unmap(),r.destroy(),new Uint8Array(s)}_writeMapped(e){let t=this.handle.getMappedRange();new e.constructor(t).set(e)}mapAsync(e,t=0,r){return this.handle.mapAsync(e,t,r)}getMappedRange(e=0,t){return this.handle.getMappedRange(e,t)}unmap(){this.handle.unmap()}};var x=h(o(),1);function v(n){if(n.includes("webgl"))throw new Error("webgl-only format");return n}var re=h(o(),1),p=class extends re.Sampler{device;handle;constructor(e,t){super(e,t),this.device=e;let r={...this.props};r.type!=="comparison-sampler"&&delete r.compare,this.handle=this.handle||this.device.handle.createSampler(r),this.handle.label=this.props.id}destroy(){this.handle=null}};var ne=h(o(),1),G=class extends ne.TextureView{device;handle;texture;constructor(e,t){super(e,t),this.device=e,this.texture=t.texture,this.handle=this.handle||this.texture.handle.createView({format:t.format||this.texture.format,dimension:t.dimension||this.texture.dimension,aspect:t.aspect,baseMipLevel:t.baseMipLevel,mipLevelCount:t.mipLevelCount,baseArrayLayer:t.baseArrayLayer,arrayLayerCount:t.arrayLayerCount}),this.handle.label=this.props.id}destroy(){this.handle=null}};var Te={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},S=class extends x.Texture{device;handle;height=1;width=1;sampler;view;constructor(e,t){t=x.Texture._fixProps(t),super(e,t),this.device=e,this.initialize(t)}destroy(){this.handle?.destroy(),this.handle=null}createView(e){return new G(this.device,{...e,texture:this})}initialize(e){this.handle=this.props.handle||this.createHandle(),this.handle.label||=this.id,this.props.data&&(x.Texture.isExternalImage(this.props.data)?this.copyExternalImage({image:this.props.data}):this.setData({data:this.props.data})),this.width=this.handle.width,this.height=this.handle.height,this.sampler=e.sampler instanceof p?e.sampler:new p(this.device,e.sampler||{}),this.view=new G(this.device,{...this.props,texture:this})}createHandle(){let e=this.props.width||this.props.data?.width||1,t=this.props.height||this.props.data?.height||1;return this.device.handle.createTexture({label:this.id,size:{width:e,height:t,depthOrArrayLayers:this.depth},usage:this.props.usage||x.Texture.TEXTURE|x.Texture.COPY_DST,dimension:Te[this.dimension],format:v(this.format),mipLevelCount:this.mipLevels,sampleCount:this.props.samples})}createGPUTextureView(){return this.handle.createView({label:this.id})}setSampler(e){return this.sampler=e instanceof p?e:new p(this.device,e),this}setTexture1DData(e){throw new Error("not implemented")}setTexture2DData(e,t,r){throw new Error("not implemented")}setTexture3DData(e,t,r){throw new Error("not implemented")}setTextureCubeData(e,t){throw new Error("not implemented")}setTextureArrayData(e){throw new Error("not implemented")}setTextureCubeArrayData(e){throw new Error("not implemented")}setData(e){if(ArrayBuffer.isView(e.data)){let t=new Uint8ClampedArray(e.data.buffer),r=new ImageData(t,this.width,this.height);return this.copyExternalImage({image:r})}throw new Error("Texture.setData: Use CommandEncoder to upload data to texture in WebGPU")}copyExternalImage(e){let t=x.Texture.getExternalImageSize(e.image),r={...x.Texture.defaultCopyExternalImageOptions,...t,...e},{image:i,sourceX:s,sourceY:a,width:l,height:u,depth:d,mipLevel:g,x:m,y:T,z:J,aspect:ge,colorSpace:be,premultipliedAlpha:xe}=r;return this.device.handle.queue.copyExternalImageToTexture({source:i,origin:[s,a]},{texture:this.handle,origin:[m,T,J],mipLevel:g,aspect:ge,colorSpace:be,premultipliedAlpha:xe},[l,u,d]),{width:l,height:u}}};var ie=h(o(),1);var M=class extends ie.ExternalTexture{device;handle;sampler;constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.handle.importExternalTexture({source:t.source,colorSpace:t.colorSpace}),this.sampler=null}destroy(){this.handle=null}setSampler(e){return this.sampler=e instanceof p?e:new p(this.device,e),this}};var W=h(o(),1),C=class extends W.Shader{device;handle;constructor(e,t){super(e,t),this.device=e,this.device.handle.pushErrorScope("validation"),this.handle=this.props.handle||this.createHandle(),this.handle.label=this.props.id,this._checkCompilationError(this.device.handle.popErrorScope())}async _checkCompilationError(e){let t=await e;if(t){this.debugShader();let r=await this.getCompilationInfo();throw W.log.error(`Shader compilation error: ${t.message}`,r)(),new Error(`Shader compilation error: ${t.message}`)}}destroy(){this.handle=null}async getCompilationInfo(){return(await this.handle.getCompilationInfo()).messages}createHandle(){let{source:e}=this.props,t=e.includes("#version");if(this.props.language==="glsl"||t)throw new Error("GLSL shaders are not supported in WebGPU");return this.device.handle.createShaderModule({code:e})}};var E=h(o(),1);function f(n){return n.depthStencil=n.depthStencil||{format:"depth24plus",stencilFront:{},stencilBack:{},depthWriteEnabled:!1,depthCompare:"less-equal"},n.depthStencil}function U(n){return f(n).stencilFront}function k(n){return f(n).stencilBack}var Ge={cullMode:(n,e,t)=>{t.primitive=t.primitive||{},t.primitive.cullMode=e},frontFace:(n,e,t)=>{t.primitive=t.primitive||{},t.primitive.frontFace=e},depthWriteEnabled:(n,e,t)=>{let r=f(t);r.depthWriteEnabled=e},depthCompare:(n,e,t)=>{let r=f(t);r.depthCompare=e},depthFormat:(n,e,t)=>{let r=f(t);r.format=e},depthBias:(n,e,t)=>{let r=f(t);r.depthBias=e},depthBiasSlopeScale:(n,e,t)=>{let r=f(t);r.depthBiasSlopeScale=e},depthBiasClamp:(n,e,t)=>{let r=f(t);r.depthBiasClamp=e},stencilReadMask:(n,e,t)=>{let r=f(t);r.stencilReadMask=e},stencilWriteMask:(n,e,t)=>{let r=f(t);r.stencilWriteMask=e},stencilCompare:(n,e,t)=>{let r=U(t),i=k(t);r.compare=e,i.compare=e},stencilPassOperation:(n,e,t)=>{let r=U(t),i=k(t);r.passOp=e,i.passOp=e},stencilFailOperation:(n,e,t)=>{let r=U(t),i=k(t);r.failOp=e,i.failOp=e},stencilDepthFailOperation:(n,e,t)=>{let r=U(t),i=k(t);r.depthFailOp=e,i.depthFailOp=e},sampleCount:(n,e,t)=>{t.multisample=t.multisample||{},t.multisample.count=e},sampleMask:(n,e,t)=>{t.multisample=t.multisample||{},t.multisample.mask=e},sampleAlphaToCoverageEnabled:(n,e,t)=>{t.multisample=t.multisample||{},t.multisample.alphaToCoverageEnabled=e},colorMask:(n,e,t)=>{let r=se(t);r[0].writeMask=e},blendColorOperation:(n,e,t)=>{se(t)}},Le={primitive:{cullMode:"back",topology:"triangle-list"},vertex:{module:void 0,entryPoint:"main"},fragment:{module:void 0,entryPoint:"main",targets:[]},layout:"auto"};function ae(n,e={}){Object.assign(n,{...Le,...n}),_e(n,e)}function _e(n,e){for(let[t,r]of Object.entries(e)){let i=Ge[t];if(!i)throw new Error(`Illegal parameter ${t}`);i(t,r,n)}}function se(n){if(n.fragment.targets=n.fragment?.targets||[],!Array.isArray(n.fragment?.targets))throw new Error("colorstate");return n.fragment?.targets?.length===0&&n.fragment.targets?.push({}),n.fragment?.targets}var w=h(o(),1);function V(n,e,t,r){let i=Ie(r,t);return n.createBindGroup({layout:e,entries:i})}function De(n,e){let t=n.bindings.find(r=>r.name===e||`${r.name}uniforms`===e.toLocaleLowerCase());return t||w.log.warn(`Binding ${e} not set: Not found in shader layout.`)(),t||null}function Ie(n,e){let t=[];for(let[r,i]of Object.entries(n)){let s=De(e,r);s&&t.push(Re(i,s.location))}return t}function Re(n,e){if(n instanceof w.Buffer)return{binding:e,resource:{buffer:n.handle}};if(n instanceof w.Sampler)return{binding:e,resource:n.handle};if(n instanceof w.Texture)return{binding:e,resource:n.handle.createView({label:"bind-group-auto-created"})};throw new Error("invalid binding")}var P=h(o(),1);function Z(n){if(n.endsWith("-webgl"))throw new Error(`WebGPU does not support vertex format ${n}`);return n}function he(n,e){let t=[],r=new Set;for(let i of e){let s=[],a="vertex",l=0,u=i.format;if(i.attributes)for(let d of i.attributes){let g=d.attribute,m=oe(n,g,r),T=m?.location;a=m?.stepMode||(m?.name.startsWith("instance")?"instance":"vertex"),s.push({format:Z(d.format||i.format),offset:d.byteOffset,shaderLocation:T}),l+=(0,P.decodeVertexFormat)(u).byteLength}else{let d=oe(n,i.name,r);if(!d)continue;l=(0,P.decodeVertexFormat)(u).byteLength,a=d.stepMode||(d.name.startsWith("instance")?"instance":"vertex"),s.push({format:Z(u),offset:0,shaderLocation:d.location})}t.push({arrayStride:i.byteStride||l,stepMode:a,attributes:s})}for(let i of n.attributes)r.has(i.name)||t.push({arrayStride:(0,P.decodeVertexFormat)("float32x3").byteLength,stepMode:i.stepMode||(i.name.startsWith("instance")?"instance":"vertex"),attributes:[{format:Z("float32x3"),offset:0,shaderLocation:i.location}]});return t}function oe(n,e,t){let r=n.attributes.find(i=>i.name===e);if(!r)return P.log.warn(`Unknown attribute ${e}`)(),null;if(t.has(e))throw new Error(`Duplicate attribute ${e}`);return t.add(e),r}var q=class extends E.RenderPipeline{device;handle;vs;fs=null;_bindings;_bindGroupLayout=null;_bindGroup=null;constructor(e,t){if(super(e,t),this.device=e,this.handle=this.props.handle,!this.handle){let r=this._getRenderPipelineDescriptor();E.log.groupCollapsed(1,`new WebGPURenderPipeline(${this.id})`)(),E.log.probe(1,JSON.stringify(r,null,2))(),E.log.groupEnd(1)(),this.handle=this.device.handle.createRenderPipeline(r)}this.handle.label=this.props.id,this.vs=t.vs,this.fs=t.fs,this._bindings={...this.props.bindings}}destroy(){this.handle=null}setBindings(e){Object.assign(this._bindings,e)}draw(e){let t=e.renderPass;t.handle.setPipeline(this.handle);let r=this._getBindGroup();return r&&t.handle.setBindGroup(0,r),e.vertexArray.bindBeforeRender(e.renderPass),e.indexCount?t.handle.drawIndexed(e.indexCount,e.instanceCount,e.firstIndex,e.baseVertex,e.firstInstance):t.handle.draw(e.vertexCount||0,e.instanceCount||1,e.firstInstance),e.vertexArray.unbindAfterRender(e.renderPass),!0}_getBindGroup(){return this.shaderLayout.bindings.length===0?null:(this._bindGroupLayout=this._bindGroupLayout||this.handle.getBindGroupLayout(0),this._bindGroup=this._bindGroup||V(this.device.handle,this._bindGroupLayout,this.shaderLayout,this._bindings),this._bindGroup)}_getRenderPipelineDescriptor(){let e={module:this.props.vs.handle,entryPoint:this.props.vertexEntryPoint||"main",buffers:he(this.shaderLayout,this.props.bufferLayout)},t={module:this.props.fs.handle,entryPoint:this.props.fragmentEntryPoint||"main",targets:[{format:v(this.device.getCanvasContext().format)}]},r={vertex:e,fragment:t,primitive:{topology:this.props.topology},layout:"auto"};return ae(r,this.props.parameters),r}};var de=h(o(),1),B=class extends de.Framebuffer{device;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t),this.device=e,this.autoCreateAttachmentTextures()}updateAttachments(){}};var le=h(o(),1);var $=class extends le.ComputePipeline{device;handle;_bindGroupLayout=null;_bindGroup=null;_bindings={};constructor(e,t){super(e,t),this.device=e;let r=this.props.shader;this.handle=this.props.handle||this.device.handle.createComputePipeline({label:this.props.id,compute:{module:r.handle,entryPoint:this.props.entryPoint,constants:this.props.constants},layout:"auto"})}setBindings(e){Object.assign(this._bindings,e)}_getBindGroup(){return this._bindGroupLayout=this._bindGroupLayout||this.handle.getBindGroupLayout(0),this._bindGroup=this._bindGroup||V(this.device.handle,this._bindGroupLayout,this.shaderLayout,this._bindings),this._bindGroup}};var A=h(o(),1),z=class extends A.RenderPass{device;handle;pipeline=null;constructor(e,t={}){super(e,t),this.device=e;let r=t.framebuffer||e.getCanvasContext().getCurrentFramebuffer(),i=this.getRenderPassDescriptor(r),s=t.timestampQuerySet;if(s&&(i.occlusionQuerySet=s.handle),e.features.has("timestamp-query")){let a=t.timestampQuerySet;i.timestampWrites=a?{querySet:a.handle,beginningOfPassWriteIndex:t.beginTimestampIndex,endOfPassWriteIndex:t.endTimestampIndex}:void 0}if(!e.commandEncoder)throw new Error("commandEncoder not available");this.handle=this.props.handle||e.commandEncoder.beginRenderPass(i),this.handle.label=this.props.id,A.log.groupCollapsed(3,`new WebGPURenderPass(${this.id})`)(),A.log.probe(3,JSON.stringify(i,null,2))(),A.log.groupEnd(3)()}destroy(){}end(){this.handle.end()}setPipeline(e){this.pipeline=e,this.handle.setPipeline(this.pipeline.handle)}setBindings(e){this.pipeline?.setBindings(e);let t=this.pipeline?._getBindGroup();t&&this.handle.setBindGroup(0,t)}setIndexBuffer(e,t,r=0,i){this.handle.setIndexBuffer(e.handle,t,r,i)}setVertexBuffer(e,t,r=0){this.handle.setVertexBuffer(e,t.handle,r)}draw(e){e.indexCount?this.handle.drawIndexed(e.indexCount,e.instanceCount,e.firstIndex,e.baseVertex,e.firstInstance):this.handle.draw(e.vertexCount||0,e.instanceCount||1,e.firstIndex,e.firstInstance)}drawIndirect(){}setParameters(e){let{blendConstant:t,stencilReference:r,scissorRect:i,viewport:s}=e;t&&this.handle.setBlendConstant(t),r&&this.handle.setStencilReference(r),i&&this.handle.setScissorRect(i[0],i[1],i[2],i[3]),s&&this.handle.setViewport(s[0],s[1],s[2],s[3],s[4],s[5])}pushDebugGroup(e){this.handle.pushDebugGroup(e)}popDebugGroup(){this.handle.popDebugGroup()}insertDebugMarker(e){this.handle.insertDebugMarker(e)}beginOcclusionQuery(e){this.handle.beginOcclusionQuery(e)}endOcclusionQuery(){this.handle.endOcclusionQuery()}getRenderPassDescriptor(e){let t={colorAttachments:[]};if(t.colorAttachments=e.colorAttachments.map(r=>({loadOp:this.props.clearColor!==!1?"clear":"load",colorClearValue:this.props.clearColor||[0,0,0,0],storeOp:this.props.discard?"discard":"store",view:r.handle})),e.depthStencilAttachment){t.depthStencilAttachment={view:e.depthStencilAttachment.handle};let{depthStencilAttachment:r}=t;this.props.depthReadOnly&&(r.depthReadOnly=!0),r.depthClearValue=this.props.clearDepth||0,!0&&(r.depthLoadOp=this.props.clearDepth!==!1?"clear":"load",r.depthStoreOp="store"),!1&&(r.stencilLoadOp=this.props.clearStencil!==!1?"clear":"load",r.stencilStoreOp="store")}return t}};var pe=h(o(),1),Q=class extends pe.ComputePass{device;handle;_webgpuPipeline=null;constructor(e,t){super(e,t),this.device=e;let r;if(e.features.has("timestamp-query")){let i=t.timestampQuerySet;i&&(r={querySet:i.handle,beginningOfPassWriteIndex:t.beginTimestampIndex,endOfPassWriteIndex:t.endTimestampIndex})}this.handle=this.props.handle||e.commandEncoder?.beginComputePass({label:this.props.id,timestampWrites:r})}destroy(){}end(){this.handle.end()}setPipeline(e){let t=e;this.handle.setPipeline(t.handle),this._webgpuPipeline=t,this.setBindings([])}setBindings(e){let t=this._webgpuPipeline._getBindGroup();this.handle.setBindGroup(0,t)}dispatch(e,t,r){this.handle.dispatchWorkgroups(e,t,r)}dispatchIndirect(e,t=0){let r=e;this.handle.dispatchWorkgroupsIndirect(r.handle,t)}pushDebugGroup(e){this.handle.pushDebugGroup(e)}popDebugGroup(){this.handle.popDebugGroup()}insertDebugMarker(e){this.handle.insertDebugMarker(e)}};var L=h(o(),1);var ot=globalThis.document||{},ht=globalThis.process||{},dt=globalThis.console,ue=globalThis.navigator||{};function N(n){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=n||e;return Boolean(t&&t.indexOf("Electron")>=0)}function ce(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||N()}function K(n){return!n&&!ce()?"Node":N(n)?"Electron":(n||ue.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var j=class extends L.VertexArray{get[Symbol.toStringTag](){return"WebGPUVertexArray"}device;handle;constructor(e,t){super(e,t),this.device=e}destroy(){}setIndexBuffer(e){this.indexBuffer=e}setBuffer(e,t){this.attributes[e]=t}bindBeforeRender(e,t,r){let i=e,s=this.indexBuffer;s?.handle&&(L.log.warn("setting index buffer",s?.handle,s?.indexType)(),i.handle.setIndexBuffer(s?.handle,s?.indexType));for(let a=0;a<this.maxVertexAttributes;a++){let l=this.attributes[a];l?.handle&&(L.log.warn(`setting vertex buffer ${a}`,l?.handle)(),i.handle.setVertexBuffer(a,l?.handle))}}unbindAfterRender(e){}static isConstantAttributeZeroSupported(e){return K()==="Chrome"}};var Y=h(o(),1);var _=class extends Y.CanvasContext{device;gpuCanvasContext;format=navigator.gpu.getPreferredCanvasFormat();depthStencilFormat="depth24plus";depthStencilAttachment=null;constructor(e,t,r){super(r),this.device=e,this.width=-1,this.height=-1,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this.gpuCanvasContext=this.canvas.getContext("webgpu"),this.format="bgra8unorm"}destroy(){this.gpuCanvasContext.unconfigure()}getCurrentFramebuffer(){this.update();let e=this.getCurrentTexture();return this.width=e.width,this.height=e.height,this._createDepthStencilAttachment(),new B(this.device,{colorAttachments:[e],depthStencilAttachment:this.depthStencilAttachment})}update(){let[e,t]=this.getPixelSize();(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.depthStencilAttachment&&(this.depthStencilAttachment.destroy(),this.depthStencilAttachment=null),this.gpuCanvasContext.configure({device:this.device.handle,format:v(this.format),colorSpace:this.props.colorSpace,alphaMode:this.props.alphaMode}),Y.log.log(1,`Resized to ${this.width}x${this.height}px`)())}resize(e){if(this.update(),!!this.device.handle&&this.canvas){let t=this.getDevicePixelRatio(e?.useDevicePixels);this.setDevicePixelRatio(t,e);return}}getCurrentTexture(){return this.device.createTexture({id:`${this.id}#color-texture`,handle:this.gpuCanvasContext.getCurrentTexture(),format:this.format})}_createDepthStencilAttachment(){return this.depthStencilAttachment||(this.depthStencilAttachment=this.device.createTexture({id:`${this.id}#depth-stencil-texture`,format:this.depthStencilFormat,width:this.width,height:this.height,usage:GPUTextureUsage.RENDER_ATTACHMENT})),this.depthStencilAttachment}};var me=h(o(),1),H=class extends me.QuerySet{device;handle;constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.handle.createQuerySet({type:this.props.type,count:this.props.count}),this.handle.label=this.props.id}destroy(){this.handle?.destroy(),this.handle=null}};var y=class extends X.Device{type="webgpu";handle;adapter;adapterInfo;features;info;limits;lost;canvasContext=null;_isLost=!1;commandEncoder=null;renderPass=null;constructor(e,t,r,i){super({...e,id:e.id||"webgpu-device"}),this.handle=t,this.adapter=r,this.adapterInfo=i,this.info=this._getInfo(),this.features=this._getFeatures(),this.limits=this.handle.limits,t.addEventListener("uncapturederror",s=>{let a=s instanceof GPUUncapturedErrorEvent?s.error.message:"Unknown error";this.error(new Error(a))}),this.lost=new Promise(async s=>{let a=await this.handle.lost;this._isLost=!0,s({reason:"destroyed",message:a.message})}),this.canvasContext=new _(this,this.adapter,{canvas:e.canvas,height:e.height,width:e.width,container:e.container})}destroy(){this.handle.destroy()}isTextureFormatSupported(e){return!e.includes("webgl")}isTextureFormatFilterable(e){return this.isTextureFormatSupported(e)&&!e.startsWith("depth")&&!e.startsWith("stencil")}isTextureFormatRenderable(e){return this.isTextureFormatSupported(e)}get isLost(){return this._isLost}createBuffer(e){let t=this._getBufferProps(e);return new b(this,t)}createTexture(e){return new S(this,e)}createExternalTexture(e){return new M(this,e)}createShader(e){return new C(this,e)}createSampler(e){return new p(this,e)}createRenderPipeline(e){return new q(this,e)}createFramebuffer(e){return new B(this,e)}createComputePipeline(e){return new $(this,e)}createVertexArray(e){return new j(this,e)}beginRenderPass(e){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new z(this,e)}beginComputePass(e){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Q(this,e)}createTransformFeedback(e){throw new Error("Transform feedback not supported in WebGPU")}createQuerySet(e){return new H(this,e)}createCanvasContext(e){return new _(this,this.adapter,e)}submit(){let e=this.commandEncoder?.finish();e&&this.handle.queue.submit([e]),this.commandEncoder=null}_getInfo(){let[e,t]=(this.adapterInfo.driver||"").split(" Version "),r=this.adapterInfo.vendor||this.adapter.__brand||"unknown",i=e||"",s=t||"",a=r==="apple"?"apple":"unknown",l=this.adapterInfo.architecture||"unknown",u=this.adapterInfo.backend||"unknown",d=(this.adapterInfo.type||"").split(" ")[0].toLowerCase()||"unknown";return{type:"webgpu",vendor:r,renderer:i,version:s,gpu:a,gpuType:d,gpuBackend:u,gpuArchitecture:l,shadingLanguage:"wgsl",shadingLanguageVersion:100}}_getFeatures(){let e=new Set(this.handle.features);e.has("depth-clamping")&&(e.delete("depth-clamping"),e.add("depth-clip-control")),e.has("texture-compression-bc")&&e.add("texture-compression-bc5-webgl");let t=["timer-query-webgl","compilation-status-async-webgl","float32-renderable-webgl","float16-renderable-webgl","norm16-renderable-webgl","texture-filterable-anisotropic-webgl","shader-noperspective-interpolation-webgl"];for(let r of t)e.add(r);return new X.DeviceFeatures(Array.from(e),this.props.disabledFeatures)}copyExternalImageToTexture(e){let{source:t,sourceX:r=0,sourceY:i=0,texture:s,mipLevel:a=0,aspect:l="all",colorSpace:u="display-p3",premultipliedAlpha:d=!1,width:g=s.width,height:m=s.height,depth:T=1}=e,J=s;this.handle?.queue.copyExternalImageToTexture({source:t,origin:[r,i]},{texture:J.handle,origin:[0,0,0],mipLevel:a,aspect:l,colorSpace:u,premultipliedAlpha:d},[g,m,T])}};var ee=class extends c.Adapter{type="webgpu";constructor(){super(),y.adapter=this}isSupported(){return Boolean(typeof navigator<"u"&&navigator.gpu)}async create(e){if(!navigator.gpu)throw new Error("WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu");c.log.groupCollapsed(1,"WebGPUDevice created")();let t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(!t)throw new Error("Failed to request WebGPU adapter");let r=await t.requestAdapterInfo();c.log.probe(2,"Adapter available",r)();let i=[],s={};if(e.requestMaxLimits){i.push(...Array.from(t.features));let u=Object.keys(t.limits).filter(d=>!["minSubgroupSize","maxSubgroupSize"].includes(d));for(let d of u){let g=d,m=t.limits[g];typeof m=="number"&&(s[g]=m)}}let a=await t.requestDevice({requiredFeatures:i,requiredLimits:s});c.log.probe(1,"GPUDevice available")(),typeof e.canvas=="string"&&(await c.CanvasContext.pageLoaded,c.log.probe(1,"DOM is loaded")());let l=new y(e,a,t,r);return c.log.probe(1,"Device created. For more info, set chrome://flags/#enable-webgpu-developer-features")(),c.log.table(1,l.info)(),c.log.groupEnd(1)(),l}async attach(e){throw new Error("WebGPUAdapter.attach() not implemented")}},fe=new ee;return Be(D);})();
|
|
7
|
+
var __exports__=(()=>{var we=Object.create;var R=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Se=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var Pe=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ee=(n,e)=>{for(var t in e)R(n,t,{get:e[t],enumerable:!0})},I=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ve(e))!Ce.call(n,i)&&i!==t&&R(n,i,{get:()=>e[i],enumerable:!(r=ye(e,i))||r.enumerable});return n},F=(n,e,t)=>(I(n,e,"default"),t&&I(t,e,"default")),h=(n,e,t)=>(t=n!=null?we(Se(n)):{},I(e||!n||!n.__esModule?R(t,"default",{value:n,enumerable:!0}):t,n)),Be=n=>I(R({},"__esModule",{value:!0}),n);var o=Pe((Oe,te)=>{te.exports=globalThis.luma});var D={};Ee(D,{WebGPUBuffer:()=>b,WebGPUDevice:()=>y,WebGPUSampler:()=>p,WebGPUShader:()=>C,WebGPUTexture:()=>S,webgpuAdapter:()=>fe});F(D,h(o(),1));var f=h(o(),1);var X=h(o(),1);var O=h(o(),1);function Ae(n){return n.byteLength||n.data?.byteLength||0}var b=class extends O.Buffer{device;handle;byteLength;constructor(e,t){super(e,t),this.device=e,this.byteLength=Ae(t);let r=Boolean(t.data),i=Math.ceil(this.byteLength/4)*4;this.handle=this.props.handle||this.device.handle.createBuffer({size:i,usage:this.props.usage||GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:this.props.mappedAtCreation||r,label:this.props.id}),t.data&&this._writeMapped(t.data),r&&!t.mappedAtCreation&&this.handle.unmap()}destroy(){this.handle?.destroy(),this.handle=null}write(e,t=0){this.device.handle.queue.writeBuffer(this.handle,t,e.buffer,e.byteOffset,e.byteLength)}async readAsync(e=0,t=this.byteLength){let r=new b(this.device,{usage:O.Buffer.MAP_READ|O.Buffer.COPY_DST,byteLength:t}),i=this.device.handle.createCommandEncoder();i.copyBufferToBuffer(this.handle,e,r.handle,0,t),this.device.handle.queue.submit([i.finish()]),await r.handle.mapAsync(GPUMapMode.READ,e,t);let s=r.handle.getMappedRange().slice(0);return r.handle.unmap(),r.destroy(),new Uint8Array(s)}_writeMapped(e){let t=this.handle.getMappedRange();new e.constructor(t).set(e)}mapAsync(e,t=0,r){return this.handle.mapAsync(e,t,r)}getMappedRange(e=0,t){return this.handle.getMappedRange(e,t)}unmap(){this.handle.unmap()}};var x=h(o(),1);function v(n){if(n.includes("webgl"))throw new Error("webgl-only format");return n}var re=h(o(),1),p=class extends re.Sampler{device;handle;constructor(e,t){super(e,t),this.device=e;let r={...this.props};r.type!=="comparison-sampler"&&delete r.compare,this.handle=this.handle||this.device.handle.createSampler(r),this.handle.label=this.props.id}destroy(){this.handle=null}};var ne=h(o(),1),G=class extends ne.TextureView{device;handle;texture;constructor(e,t){super(e,t),this.device=e,this.texture=t.texture,this.handle=this.handle||this.texture.handle.createView({format:t.format||this.texture.format,dimension:t.dimension||this.texture.dimension,aspect:t.aspect,baseMipLevel:t.baseMipLevel,mipLevelCount:t.mipLevelCount,baseArrayLayer:t.baseArrayLayer,arrayLayerCount:t.arrayLayerCount}),this.handle.label=this.props.id}destroy(){this.handle=null}};var Te={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},S=class extends x.Texture{device;handle;height=1;width=1;sampler;view;constructor(e,t){t=x.Texture._fixProps(t),super(e,t),this.device=e,this.initialize(t)}destroy(){this.handle?.destroy(),this.handle=null}createView(e){return new G(this.device,{...e,texture:this})}initialize(e){this.handle=this.props.handle||this.createHandle(),this.handle.label||=this.id,this.props.data&&(x.Texture.isExternalImage(this.props.data)?this.copyExternalImage({image:this.props.data}):this.setData({data:this.props.data})),this.width=this.handle.width,this.height=this.handle.height,this.sampler=e.sampler instanceof p?e.sampler:new p(this.device,e.sampler||{}),this.view=new G(this.device,{...this.props,texture:this})}createHandle(){let e=this.props.width||this.props.data?.width||1,t=this.props.height||this.props.data?.height||1;return this.device.handle.createTexture({label:this.id,size:{width:e,height:t,depthOrArrayLayers:this.depth},usage:this.props.usage||x.Texture.TEXTURE|x.Texture.COPY_DST,dimension:Te[this.dimension],format:v(this.format),mipLevelCount:this.mipLevels,sampleCount:this.props.samples})}createGPUTextureView(){return this.handle.createView({label:this.id})}setSampler(e){return this.sampler=e instanceof p?e:new p(this.device,e),this}setTexture1DData(e){throw new Error("not implemented")}setTexture2DData(e,t,r){throw new Error("not implemented")}setTexture3DData(e,t,r){throw new Error("not implemented")}setTextureCubeData(e,t){throw new Error("not implemented")}setTextureArrayData(e){throw new Error("not implemented")}setTextureCubeArrayData(e){throw new Error("not implemented")}setData(e){if(ArrayBuffer.isView(e.data)){let t=new Uint8ClampedArray(e.data.buffer),r=new ImageData(t,this.width,this.height);return this.copyExternalImage({image:r})}throw new Error("Texture.setData: Use CommandEncoder to upload data to texture in WebGPU")}copyExternalImage(e){let t=x.Texture.getExternalImageSize(e.image),r={...x.Texture.defaultCopyExternalImageOptions,...t,...e},{image:i,sourceX:s,sourceY:a,width:l,height:u,depth:d,mipLevel:g,x:c,y:T,z:J,aspect:ge,colorSpace:be,premultipliedAlpha:xe}=r;return this.device.handle.queue.copyExternalImageToTexture({source:i,origin:[s,a]},{texture:this.handle,origin:[c,T,J],mipLevel:g,aspect:ge,colorSpace:be,premultipliedAlpha:xe},[l,u,d]),{width:l,height:u}}};var ie=h(o(),1);var W=class extends ie.ExternalTexture{device;handle;sampler;constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.handle.importExternalTexture({source:t.source,colorSpace:t.colorSpace}),this.sampler=null}destroy(){this.handle=null}setSampler(e){return this.sampler=e instanceof p?e:new p(this.device,e),this}};var M=h(o(),1),C=class extends M.Shader{device;handle;constructor(e,t){super(e,t),this.device=e,this.device.handle.pushErrorScope("validation"),this.handle=this.props.handle||this.createHandle(),this.handle.label=this.props.id,this._checkCompilationError(this.device.handle.popErrorScope())}get asyncCompilationStatus(){return this.getCompilationInfo().then(()=>this.compilationStatus)}async _checkCompilationError(e){let t=await e;if(t){this.debugShader();let r=await this.getCompilationInfo();throw M.log.error(`Shader compilation error: ${t.message}`,r)(),new Error(`Shader compilation error: ${t.message}`)}}destroy(){this.handle=null}async getCompilationInfo(){return(await this.handle.getCompilationInfo()).messages}createHandle(){let{source:e}=this.props,t=e.includes("#version");if(this.props.language==="glsl"||t)throw new Error("GLSL shaders are not supported in WebGPU");return this.device.handle.createShaderModule({code:e})}};var E=h(o(),1);function m(n){return n.depthStencil=n.depthStencil||{format:"depth24plus",stencilFront:{},stencilBack:{},depthWriteEnabled:!1,depthCompare:"less-equal"},n.depthStencil}function U(n){return m(n).stencilFront}function k(n){return m(n).stencilBack}var Ge={cullMode:(n,e,t)=>{t.primitive=t.primitive||{},t.primitive.cullMode=e},frontFace:(n,e,t)=>{t.primitive=t.primitive||{},t.primitive.frontFace=e},depthWriteEnabled:(n,e,t)=>{let r=m(t);r.depthWriteEnabled=e},depthCompare:(n,e,t)=>{let r=m(t);r.depthCompare=e},depthFormat:(n,e,t)=>{let r=m(t);r.format=e},depthBias:(n,e,t)=>{let r=m(t);r.depthBias=e},depthBiasSlopeScale:(n,e,t)=>{let r=m(t);r.depthBiasSlopeScale=e},depthBiasClamp:(n,e,t)=>{let r=m(t);r.depthBiasClamp=e},stencilReadMask:(n,e,t)=>{let r=m(t);r.stencilReadMask=e},stencilWriteMask:(n,e,t)=>{let r=m(t);r.stencilWriteMask=e},stencilCompare:(n,e,t)=>{let r=U(t),i=k(t);r.compare=e,i.compare=e},stencilPassOperation:(n,e,t)=>{let r=U(t),i=k(t);r.passOp=e,i.passOp=e},stencilFailOperation:(n,e,t)=>{let r=U(t),i=k(t);r.failOp=e,i.failOp=e},stencilDepthFailOperation:(n,e,t)=>{let r=U(t),i=k(t);r.depthFailOp=e,i.depthFailOp=e},sampleCount:(n,e,t)=>{t.multisample=t.multisample||{},t.multisample.count=e},sampleMask:(n,e,t)=>{t.multisample=t.multisample||{},t.multisample.mask=e},sampleAlphaToCoverageEnabled:(n,e,t)=>{t.multisample=t.multisample||{},t.multisample.alphaToCoverageEnabled=e},colorMask:(n,e,t)=>{let r=se(t);r[0].writeMask=e},blendColorOperation:(n,e,t)=>{se(t)}},Le={primitive:{cullMode:"back",topology:"triangle-list"},vertex:{module:void 0,entryPoint:"main"},fragment:{module:void 0,entryPoint:"main",targets:[]},layout:"auto"};function ae(n,e={}){Object.assign(n,{...Le,...n}),_e(n,e)}function _e(n,e){for(let[t,r]of Object.entries(e)){let i=Ge[t];if(!i)throw new Error(`Illegal parameter ${t}`);i(t,r,n)}}function se(n){if(n.fragment.targets=n.fragment?.targets||[],!Array.isArray(n.fragment?.targets))throw new Error("colorstate");return n.fragment?.targets?.length===0&&n.fragment.targets?.push({}),n.fragment?.targets}var w=h(o(),1);function V(n,e,t,r){let i=Ie(r,t);return n.createBindGroup({layout:e,entries:i})}function De(n,e){let t=n.bindings.find(r=>r.name===e||`${r.name}uniforms`===e.toLocaleLowerCase());return t||w.log.warn(`Binding ${e} not set: Not found in shader layout.`)(),t||null}function Ie(n,e){let t=[];for(let[r,i]of Object.entries(n)){let s=De(e,r);s&&t.push(Re(i,s.location))}return t}function Re(n,e){if(n instanceof w.Buffer)return{binding:e,resource:{buffer:n.handle}};if(n instanceof w.Sampler)return{binding:e,resource:n.handle};if(n instanceof w.Texture)return{binding:e,resource:n.handle.createView({label:"bind-group-auto-created"})};throw new Error("invalid binding")}var P=h(o(),1);function Z(n){if(n.endsWith("-webgl"))throw new Error(`WebGPU does not support vertex format ${n}`);return n}function he(n,e){let t=[],r=new Set;for(let i of e){let s=[],a="vertex",l=0,u=i.format;if(i.attributes)for(let d of i.attributes){let g=d.attribute,c=oe(n,g,r),T=c?.location;a=c?.stepMode||(c?.name.startsWith("instance")?"instance":"vertex"),s.push({format:Z(d.format||i.format),offset:d.byteOffset,shaderLocation:T}),l+=(0,P.decodeVertexFormat)(u).byteLength}else{let d=oe(n,i.name,r);if(!d)continue;l=(0,P.decodeVertexFormat)(u).byteLength,a=d.stepMode||(d.name.startsWith("instance")?"instance":"vertex"),s.push({format:Z(u),offset:0,shaderLocation:d.location})}t.push({arrayStride:i.byteStride||l,stepMode:a,attributes:s})}for(let i of n.attributes)r.has(i.name)||t.push({arrayStride:(0,P.decodeVertexFormat)("float32x3").byteLength,stepMode:i.stepMode||(i.name.startsWith("instance")?"instance":"vertex"),attributes:[{format:Z("float32x3"),offset:0,shaderLocation:i.location}]});return t}function oe(n,e,t){let r=n.attributes.find(i=>i.name===e);if(!r)return P.log.warn(`Unknown attribute ${e}`)(),null;if(t.has(e))throw new Error(`Duplicate attribute ${e}`);return t.add(e),r}var q=class extends E.RenderPipeline{device;handle;vs;fs=null;_bindings;_bindGroupLayout=null;_bindGroup=null;constructor(e,t){if(super(e,t),this.device=e,this.handle=this.props.handle,!this.handle){let r=this._getRenderPipelineDescriptor();E.log.groupCollapsed(1,`new WebGPURenderPipeline(${this.id})`)(),E.log.probe(1,JSON.stringify(r,null,2))(),E.log.groupEnd(1)(),this.handle=this.device.handle.createRenderPipeline(r)}this.handle.label=this.props.id,this.vs=t.vs,this.fs=t.fs,this._bindings={...this.props.bindings}}destroy(){this.handle=null}setBindings(e){Object.assign(this._bindings,e)}draw(e){let t=e.renderPass;t.handle.setPipeline(this.handle);let r=this._getBindGroup();return r&&t.handle.setBindGroup(0,r),e.vertexArray.bindBeforeRender(e.renderPass),e.indexCount?t.handle.drawIndexed(e.indexCount,e.instanceCount,e.firstIndex,e.baseVertex,e.firstInstance):t.handle.draw(e.vertexCount||0,e.instanceCount||1,e.firstInstance),e.vertexArray.unbindAfterRender(e.renderPass),!0}_getBindGroup(){return this.shaderLayout.bindings.length===0?null:(this._bindGroupLayout=this._bindGroupLayout||this.handle.getBindGroupLayout(0),this._bindGroup=this._bindGroup||V(this.device.handle,this._bindGroupLayout,this.shaderLayout,this._bindings),this._bindGroup)}_getRenderPipelineDescriptor(){let e={module:this.props.vs.handle,entryPoint:this.props.vertexEntryPoint||"main",buffers:he(this.shaderLayout,this.props.bufferLayout)},t={module:this.props.fs.handle,entryPoint:this.props.fragmentEntryPoint||"main",targets:[{format:v(this.device.getCanvasContext().format)}]},r={vertex:e,fragment:t,primitive:{topology:this.props.topology},layout:"auto"};return ae(r,this.props.parameters),r}};var de=h(o(),1),B=class extends de.Framebuffer{device;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t),this.device=e,this.autoCreateAttachmentTextures()}updateAttachments(){}};var le=h(o(),1);var z=class extends le.ComputePipeline{device;handle;_bindGroupLayout=null;_bindGroup=null;_bindings={};constructor(e,t){super(e,t),this.device=e;let r=this.props.shader;this.handle=this.props.handle||this.device.handle.createComputePipeline({label:this.props.id,compute:{module:r.handle,entryPoint:this.props.entryPoint,constants:this.props.constants},layout:"auto"})}setBindings(e){Object.assign(this._bindings,e)}_getBindGroup(){return this._bindGroupLayout=this._bindGroupLayout||this.handle.getBindGroupLayout(0),this._bindGroup=this._bindGroup||V(this.device.handle,this._bindGroupLayout,this.shaderLayout,this._bindings),this._bindGroup}};var A=h(o(),1),$=class extends A.RenderPass{device;handle;pipeline=null;constructor(e,t={}){super(e,t),this.device=e;let r=t.framebuffer||e.getCanvasContext().getCurrentFramebuffer(),i=this.getRenderPassDescriptor(r),s=t.timestampQuerySet;if(s&&(i.occlusionQuerySet=s.handle),e.features.has("timestamp-query")){let a=t.timestampQuerySet;i.timestampWrites=a?{querySet:a.handle,beginningOfPassWriteIndex:t.beginTimestampIndex,endOfPassWriteIndex:t.endTimestampIndex}:void 0}if(!e.commandEncoder)throw new Error("commandEncoder not available");this.handle=this.props.handle||e.commandEncoder.beginRenderPass(i),this.handle.label=this.props.id,A.log.groupCollapsed(3,`new WebGPURenderPass(${this.id})`)(),A.log.probe(3,JSON.stringify(i,null,2))(),A.log.groupEnd(3)()}destroy(){}end(){this.handle.end()}setPipeline(e){this.pipeline=e,this.handle.setPipeline(this.pipeline.handle)}setBindings(e){this.pipeline?.setBindings(e);let t=this.pipeline?._getBindGroup();t&&this.handle.setBindGroup(0,t)}setIndexBuffer(e,t,r=0,i){this.handle.setIndexBuffer(e.handle,t,r,i)}setVertexBuffer(e,t,r=0){this.handle.setVertexBuffer(e,t.handle,r)}draw(e){e.indexCount?this.handle.drawIndexed(e.indexCount,e.instanceCount,e.firstIndex,e.baseVertex,e.firstInstance):this.handle.draw(e.vertexCount||0,e.instanceCount||1,e.firstIndex,e.firstInstance)}drawIndirect(){}setParameters(e){let{blendConstant:t,stencilReference:r,scissorRect:i,viewport:s}=e;t&&this.handle.setBlendConstant(t),r&&this.handle.setStencilReference(r),i&&this.handle.setScissorRect(i[0],i[1],i[2],i[3]),s&&this.handle.setViewport(s[0],s[1],s[2],s[3],s[4],s[5])}pushDebugGroup(e){this.handle.pushDebugGroup(e)}popDebugGroup(){this.handle.popDebugGroup()}insertDebugMarker(e){this.handle.insertDebugMarker(e)}beginOcclusionQuery(e){this.handle.beginOcclusionQuery(e)}endOcclusionQuery(){this.handle.endOcclusionQuery()}getRenderPassDescriptor(e){let t={colorAttachments:[]};if(t.colorAttachments=e.colorAttachments.map(r=>({loadOp:this.props.clearColor!==!1?"clear":"load",colorClearValue:this.props.clearColor||[0,0,0,0],storeOp:this.props.discard?"discard":"store",view:r.handle})),e.depthStencilAttachment){t.depthStencilAttachment={view:e.depthStencilAttachment.handle};let{depthStencilAttachment:r}=t;this.props.depthReadOnly&&(r.depthReadOnly=!0),r.depthClearValue=this.props.clearDepth||0,!0&&(r.depthLoadOp=this.props.clearDepth!==!1?"clear":"load",r.depthStoreOp="store"),!1&&(r.stencilLoadOp=this.props.clearStencil!==!1?"clear":"load",r.stencilStoreOp="store")}return t}};var pe=h(o(),1),Q=class extends pe.ComputePass{device;handle;_webgpuPipeline=null;constructor(e,t){super(e,t),this.device=e;let r;if(e.features.has("timestamp-query")){let i=t.timestampQuerySet;i&&(r={querySet:i.handle,beginningOfPassWriteIndex:t.beginTimestampIndex,endOfPassWriteIndex:t.endTimestampIndex})}this.handle=this.props.handle||e.commandEncoder?.beginComputePass({label:this.props.id,timestampWrites:r})}destroy(){}end(){this.handle.end()}setPipeline(e){let t=e;this.handle.setPipeline(t.handle),this._webgpuPipeline=t,this.setBindings([])}setBindings(e){let t=this._webgpuPipeline._getBindGroup();this.handle.setBindGroup(0,t)}dispatch(e,t,r){this.handle.dispatchWorkgroups(e,t,r)}dispatchIndirect(e,t=0){let r=e;this.handle.dispatchWorkgroupsIndirect(r.handle,t)}pushDebugGroup(e){this.handle.pushDebugGroup(e)}popDebugGroup(){this.handle.popDebugGroup()}insertDebugMarker(e){this.handle.insertDebugMarker(e)}};var L=h(o(),1);var ot=globalThis.document||{},ht=globalThis.process||{},dt=globalThis.console,ue=globalThis.navigator||{};function N(n){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=n||e;return Boolean(t&&t.indexOf("Electron")>=0)}function ce(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||N()}function K(n){return!n&&!ce()?"Node":N(n)?"Electron":(n||ue.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var j=class extends L.VertexArray{get[Symbol.toStringTag](){return"WebGPUVertexArray"}device;handle;constructor(e,t){super(e,t),this.device=e}destroy(){}setIndexBuffer(e){this.indexBuffer=e}setBuffer(e,t){this.attributes[e]=t}bindBeforeRender(e,t,r){let i=e,s=this.indexBuffer;s?.handle&&(L.log.warn("setting index buffer",s?.handle,s?.indexType)(),i.handle.setIndexBuffer(s?.handle,s?.indexType));for(let a=0;a<this.maxVertexAttributes;a++){let l=this.attributes[a];l?.handle&&(L.log.warn(`setting vertex buffer ${a}`,l?.handle)(),i.handle.setVertexBuffer(a,l?.handle))}}unbindAfterRender(e){}static isConstantAttributeZeroSupported(e){return K()==="Chrome"}};var Y=h(o(),1);var _=class extends Y.CanvasContext{device;gpuCanvasContext;format=navigator.gpu.getPreferredCanvasFormat();depthStencilFormat="depth24plus";depthStencilAttachment=null;constructor(e,t,r){super(r),this.device=e,this.width=-1,this.height=-1,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this.gpuCanvasContext=this.canvas.getContext("webgpu"),this.format="bgra8unorm"}destroy(){this.gpuCanvasContext.unconfigure()}getCurrentFramebuffer(){this.update();let e=this.getCurrentTexture();return this.width=e.width,this.height=e.height,this._createDepthStencilAttachment(),new B(this.device,{colorAttachments:[e],depthStencilAttachment:this.depthStencilAttachment})}update(){let[e,t]=this.getPixelSize();(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.depthStencilAttachment&&(this.depthStencilAttachment.destroy(),this.depthStencilAttachment=null),this.gpuCanvasContext.configure({device:this.device.handle,format:v(this.format),colorSpace:this.props.colorSpace,alphaMode:this.props.alphaMode}),Y.log.log(1,`Resized to ${this.width}x${this.height}px`)())}resize(e){if(this.update(),!!this.device.handle&&this.canvas){let t=this.getDevicePixelRatio(e?.useDevicePixels);this.setDevicePixelRatio(t,e);return}}getCurrentTexture(){return this.device.createTexture({id:`${this.id}#color-texture`,handle:this.gpuCanvasContext.getCurrentTexture(),format:this.format})}_createDepthStencilAttachment(){return this.depthStencilAttachment||(this.depthStencilAttachment=this.device.createTexture({id:`${this.id}#depth-stencil-texture`,format:this.depthStencilFormat,width:this.width,height:this.height,usage:GPUTextureUsage.RENDER_ATTACHMENT})),this.depthStencilAttachment}};var me=h(o(),1),H=class extends me.QuerySet{device;handle;constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.handle.createQuerySet({type:this.props.type,count:this.props.count}),this.handle.label=this.props.id}destroy(){this.handle?.destroy(),this.handle=null}};var y=class extends X.Device{type="webgpu";handle;adapter;adapterInfo;features;info;limits;lost;canvasContext=null;_isLost=!1;commandEncoder=null;renderPass=null;constructor(e,t,r,i){if(super({...e,id:e.id||"webgpu-device"}),this.handle=t,this.adapter=r,this.adapterInfo=i,this.info=this._getInfo(),this.features=this._getFeatures(),this.limits=this.handle.limits,t.addEventListener("uncapturederror",s=>{let a=s instanceof GPUUncapturedErrorEvent?s.error.message:"Unknown error";this.error(new Error(a))}),this.lost=new Promise(async s=>{let a=await this.handle.lost;this._isLost=!0,s({reason:"destroyed",message:a.message})}),e.createCanvasContext){let s=e.createCanvasContext===!0?{}:e.createCanvasContext;this.canvasContext=new _(this,this.adapter,s)}}destroy(){this.handle.destroy()}isTextureFormatSupported(e){return!e.includes("webgl")}isTextureFormatFilterable(e){return this.isTextureFormatSupported(e)&&!e.startsWith("depth")&&!e.startsWith("stencil")}isTextureFormatRenderable(e){return this.isTextureFormatSupported(e)}get isLost(){return this._isLost}createBuffer(e){let t=this._normalizeBufferProps(e);return new b(this,t)}createTexture(e){return new S(this,e)}createExternalTexture(e){return new W(this,e)}createShader(e){return new C(this,e)}createSampler(e){return new p(this,e)}createRenderPipeline(e){return new q(this,e)}createFramebuffer(e){return new B(this,e)}createComputePipeline(e){return new z(this,e)}createVertexArray(e){return new j(this,e)}beginRenderPass(e){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new $(this,e)}beginComputePass(e){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Q(this,e)}createTransformFeedback(e){throw new Error("Transform feedback not supported in WebGPU")}createQuerySet(e){return new H(this,e)}createCanvasContext(e){return new _(this,this.adapter,e)}submit(){let e=this.commandEncoder?.finish();e&&this.handle.queue.submit([e]),this.commandEncoder=null}_getInfo(){let[e,t]=(this.adapterInfo.driver||"").split(" Version "),r=this.adapterInfo.vendor||this.adapter.__brand||"unknown",i=e||"",s=t||"",a=r==="apple"?"apple":"unknown",l=this.adapterInfo.architecture||"unknown",u=this.adapterInfo.backend||"unknown",d=(this.adapterInfo.type||"").split(" ")[0].toLowerCase()||"unknown";return{type:"webgpu",vendor:r,renderer:i,version:s,gpu:a,gpuType:d,gpuBackend:u,gpuArchitecture:l,shadingLanguage:"wgsl",shadingLanguageVersion:100}}_getFeatures(){let e=new Set(this.handle.features);e.has("depth-clamping")&&(e.delete("depth-clamping"),e.add("depth-clip-control")),e.has("texture-compression-bc")&&e.add("texture-compression-bc5-webgl");let t=["timer-query-webgl","compilation-status-async-webgl","float32-renderable-webgl","float16-renderable-webgl","norm16-renderable-webgl","texture-filterable-anisotropic-webgl","shader-noperspective-interpolation-webgl"];for(let r of t)e.add(r);return new X.DeviceFeatures(Array.from(e),this.props._disabledFeatures)}copyExternalImageToTexture(e){let{source:t,sourceX:r=0,sourceY:i=0,texture:s,mipLevel:a=0,aspect:l="all",colorSpace:u="display-p3",premultipliedAlpha:d=!1,width:g=s.width,height:c=s.height,depth:T=1}=e,J=s;this.handle?.queue.copyExternalImageToTexture({source:t,origin:[r,i]},{texture:J.handle,origin:[0,0,0],mipLevel:a,aspect:l,colorSpace:u,premultipliedAlpha:d},[g,c,T])}};var ee=class extends f.Adapter{type="webgpu";constructor(){super(),y.adapter=this}isSupported(){return Boolean(typeof navigator<"u"&&navigator.gpu)}async create(e){if(!navigator.gpu)throw new Error("WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu");f.log.groupCollapsed(1,"WebGPUDevice created")();let t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(!t)throw new Error("Failed to request WebGPU adapter");let r=await t.requestAdapterInfo();f.log.probe(2,"Adapter available",r)();let i=[],s={};if(e._requestMaxLimits){i.push(...Array.from(t.features));let u=Object.keys(t.limits).filter(d=>!["minSubgroupSize","maxSubgroupSize"].includes(d));for(let d of u){let g=d,c=t.limits[g];typeof c=="number"&&(s[g]=c)}}let a=await t.requestDevice({requiredFeatures:i,requiredLimits:s});f.log.probe(1,"GPUDevice available")();let l=new y(e,a,t,r);return f.log.probe(1,"Device created. For more info, set chrome://flags/#enable-webgpu-developer-features")(),f.log.table(1,l.info)(),f.log.groupEnd(1)(),l}async attach(e){throw new Error("WebGPUAdapter.attach() not implemented")}},fe=new ee;return Be(D);})();
|
|
8
8
|
return __exports__;
|
|
9
9
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -334,6 +334,9 @@ var WebGPUShader = class extends import_core6.Shader {
|
|
|
334
334
|
this.handle.label = this.props.id;
|
|
335
335
|
this._checkCompilationError(this.device.handle.popErrorScope());
|
|
336
336
|
}
|
|
337
|
+
get asyncCompilationStatus() {
|
|
338
|
+
return this.getCompilationInfo().then(() => this.compilationStatus);
|
|
339
|
+
}
|
|
337
340
|
async _checkCompilationError(errorScope) {
|
|
338
341
|
const error = await errorScope;
|
|
339
342
|
if (error) {
|
|
@@ -678,7 +681,7 @@ function getVertexBufferLayout(shaderLayout, bufferLayout) {
|
|
|
678
681
|
return vertexBufferLayouts;
|
|
679
682
|
}
|
|
680
683
|
function findAttributeLayout(shaderLayout, name, attributeNames) {
|
|
681
|
-
const attribute = shaderLayout.attributes.find((
|
|
684
|
+
const attribute = shaderLayout.attributes.find((attribute_) => attribute_.name === name);
|
|
682
685
|
if (!attribute) {
|
|
683
686
|
import_core8.log.warn(`Unknown attribute ${name}`)();
|
|
684
687
|
return null;
|
|
@@ -860,9 +863,9 @@ var WebGPURenderPass = class extends import_core12.RenderPass {
|
|
|
860
863
|
renderPassDescriptor.occlusionQuerySet = webgpuQuerySet.handle;
|
|
861
864
|
}
|
|
862
865
|
if (device.features.has("timestamp-query")) {
|
|
863
|
-
const
|
|
864
|
-
renderPassDescriptor.timestampWrites =
|
|
865
|
-
querySet:
|
|
866
|
+
const webgpuTSQuerySet = props.timestampQuerySet;
|
|
867
|
+
renderPassDescriptor.timestampWrites = webgpuTSQuerySet ? {
|
|
868
|
+
querySet: webgpuTSQuerySet.handle,
|
|
866
869
|
beginningOfPassWriteIndex: props.beginTimestampIndex,
|
|
867
870
|
endOfPassWriteIndex: props.endTimestampIndex
|
|
868
871
|
} : void 0;
|
|
@@ -1263,12 +1266,10 @@ var WebGPUDevice = class extends import_core17.Device {
|
|
|
1263
1266
|
this._isLost = true;
|
|
1264
1267
|
resolve({ reason: "destroyed", message: lostInfo.message });
|
|
1265
1268
|
});
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
container: props.container
|
|
1271
|
-
});
|
|
1269
|
+
if (props.createCanvasContext) {
|
|
1270
|
+
const canvasContextProps = props.createCanvasContext === true ? {} : props.createCanvasContext;
|
|
1271
|
+
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);
|
|
1272
|
+
}
|
|
1272
1273
|
}
|
|
1273
1274
|
// TODO
|
|
1274
1275
|
// Load the glslang module now so that it is available synchronously when compiling shaders
|
|
@@ -1292,7 +1293,7 @@ var WebGPUDevice = class extends import_core17.Device {
|
|
|
1292
1293
|
return this._isLost;
|
|
1293
1294
|
}
|
|
1294
1295
|
createBuffer(props) {
|
|
1295
|
-
const newProps = this.
|
|
1296
|
+
const newProps = this._normalizeBufferProps(props);
|
|
1296
1297
|
return new WebGPUBuffer(this, newProps);
|
|
1297
1298
|
}
|
|
1298
1299
|
createTexture(props) {
|
|
@@ -1396,7 +1397,7 @@ var WebGPUDevice = class extends import_core17.Device {
|
|
|
1396
1397
|
for (const feature of WEBGPU_ALWAYS_FEATURES) {
|
|
1397
1398
|
features.add(feature);
|
|
1398
1399
|
}
|
|
1399
|
-
return new import_core17.DeviceFeatures(Array.from(features), this.props.
|
|
1400
|
+
return new import_core17.DeviceFeatures(Array.from(features), this.props._disabledFeatures);
|
|
1400
1401
|
}
|
|
1401
1402
|
copyExternalImageToTexture(options) {
|
|
1402
1403
|
var _a;
|
|
@@ -1467,7 +1468,7 @@ var WebGPUAdapter = class extends import_core18.Adapter {
|
|
|
1467
1468
|
import_core18.log.probe(2, "Adapter available", adapterInfo)();
|
|
1468
1469
|
const requiredFeatures = [];
|
|
1469
1470
|
const requiredLimits = {};
|
|
1470
|
-
if (props.
|
|
1471
|
+
if (props._requestMaxLimits) {
|
|
1471
1472
|
requiredFeatures.push(...Array.from(adapter.features));
|
|
1472
1473
|
const limits = Object.keys(adapter.limits).filter((key) => !["minSubgroupSize", "maxSubgroupSize"].includes(key));
|
|
1473
1474
|
for (const key of limits) {
|
|
@@ -1483,10 +1484,6 @@ var WebGPUAdapter = class extends import_core18.Adapter {
|
|
|
1483
1484
|
requiredLimits
|
|
1484
1485
|
});
|
|
1485
1486
|
import_core18.log.probe(1, "GPUDevice available")();
|
|
1486
|
-
if (typeof props.canvas === "string") {
|
|
1487
|
-
await import_core18.CanvasContext.pageLoaded;
|
|
1488
|
-
import_core18.log.probe(1, "DOM is loaded")();
|
|
1489
|
-
}
|
|
1490
1487
|
const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo);
|
|
1491
1488
|
import_core18.log.probe(1, "Device created. For more info, set chrome://flags/#enable-webgpu-developer-features")();
|
|
1492
1489
|
import_core18.log.table(1, device.info)();
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.js", "adapter/webgpu-adapter.js", "adapter/webgpu-device.js", "adapter/resources/webgpu-buffer.js", "adapter/resources/webgpu-texture.js", "adapter/helpers/convert-texture-format.js", "adapter/resources/webgpu-sampler.js", "adapter/resources/webgpu-texture-view.js", "adapter/resources/webgpu-external-texture.js", "adapter/resources/webgpu-shader.js", "adapter/resources/webgpu-render-pipeline.js", "adapter/helpers/webgpu-parameters.js", "adapter/helpers/get-bind-group.js", "adapter/helpers/get-vertex-buffer-layout.js", "adapter/resources/webgpu-framebuffer.js", "adapter/resources/webgpu-compute-pipeline.js", "adapter/resources/webgpu-render-pass.js", "adapter/resources/webgpu-compute-pass.js", "adapter/resources/webgpu-vertex-array.js", "adapter/webgpu-canvas-context.js", "adapter/resources/webgpu-query-set.js"],
|
|
4
|
-
"sourcesContent": ["// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { webgpuAdapter } from \"./adapter/webgpu-adapter.js\";\n// WEBGPU CLASSES (typically not accessed directly)\nexport { WebGPUDevice } from \"./adapter/webgpu-device.js\";\nexport { WebGPUBuffer } from \"./adapter/resources/webgpu-buffer.js\";\nexport { WebGPUTexture } from \"./adapter/resources/webgpu-texture.js\";\nexport { WebGPUSampler } from \"./adapter/resources/webgpu-sampler.js\";\nexport { WebGPUShader } from \"./adapter/resources/webgpu-shader.js\";\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Adapter, CanvasContext, log } from '@luma.gl/core';\nimport { WebGPUDevice } from \"./webgpu-device.js\";\n// / <reference types=\"@webgpu/types\" />\nexport class WebGPUAdapter extends Adapter {\n /** type of device's created by this adapter */\n type = 'webgpu';\n constructor() {\n super();\n // @ts-ignore For backwards compatibility luma.registerDevices\n WebGPUDevice.adapter = this;\n }\n /** Check if WebGPU is available */\n isSupported() {\n return Boolean(typeof navigator !== 'undefined' && navigator.gpu);\n }\n async create(props) {\n if (!navigator.gpu) {\n throw new Error('WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu');\n }\n log.groupCollapsed(1, 'WebGPUDevice created')();\n const adapter = await navigator.gpu.requestAdapter({\n powerPreference: 'high-performance'\n // forceSoftware: false\n });\n if (!adapter) {\n throw new Error('Failed to request WebGPU adapter');\n }\n const adapterInfo = await adapter.requestAdapterInfo();\n log.probe(2, 'Adapter available', adapterInfo)();\n const requiredFeatures = [];\n const requiredLimits = {};\n if (props.requestMaxLimits) {\n // Require all features\n requiredFeatures.push(...Array.from(adapter.features));\n // Require all limits\n // Filter out chrome specific keys (avoid crash)\n const limits = Object.keys(adapter.limits).filter(key => !['minSubgroupSize', 'maxSubgroupSize'].includes(key));\n for (const key of limits) {\n const limit = key;\n const value = adapter.limits[limit];\n if (typeof value === 'number') {\n requiredLimits[limit] = value;\n }\n }\n }\n const gpuDevice = await adapter.requestDevice({\n requiredFeatures,\n requiredLimits\n });\n log.probe(1, 'GPUDevice available')();\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n log.probe(1, 'DOM is loaded')();\n }\n const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo);\n log.probe(1, 'Device created. For more info, set chrome://flags/#enable-webgpu-developer-features')();\n log.table(1, device.info)();\n log.groupEnd(1)();\n return device;\n }\n async attach(handle) {\n throw new Error('WebGPUAdapter.attach() not implemented');\n }\n}\nexport const webgpuAdapter = new WebGPUAdapter();\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Device, DeviceFeatures } from '@luma.gl/core';\nimport { WebGPUBuffer } from \"./resources/webgpu-buffer.js\";\nimport { WebGPUTexture } from \"./resources/webgpu-texture.js\";\nimport { WebGPUExternalTexture } from \"./resources/webgpu-external-texture.js\";\nimport { WebGPUSampler } from \"./resources/webgpu-sampler.js\";\nimport { WebGPUShader } from \"./resources/webgpu-shader.js\";\nimport { WebGPURenderPipeline } from \"./resources/webgpu-render-pipeline.js\";\nimport { WebGPUFramebuffer } from \"./resources/webgpu-framebuffer.js\";\nimport { WebGPUComputePipeline } from \"./resources/webgpu-compute-pipeline.js\";\nimport { WebGPURenderPass } from \"./resources/webgpu-render-pass.js\";\nimport { WebGPUComputePass } from \"./resources/webgpu-compute-pass.js\";\n// import {WebGPUCommandEncoder} from './resources/webgpu-command-encoder';\nimport { WebGPUVertexArray } from \"./resources/webgpu-vertex-array.js\";\nimport { WebGPUCanvasContext } from \"./webgpu-canvas-context.js\";\nimport { WebGPUQuerySet } from \"./resources/webgpu-query-set.js\";\n/** WebGPU Device implementation */\nexport class WebGPUDevice extends Device {\n /** type of this device */\n type = 'webgpu';\n /** The underlying WebGPU device */\n handle;\n /* The underlying WebGPU adapter */\n adapter;\n /* The underlying WebGPU adapter's info */\n adapterInfo;\n features;\n info;\n limits;\n lost;\n canvasContext = null;\n _isLost = false;\n commandEncoder = null;\n renderPass = null;\n constructor(props, device, adapter, adapterInfo) {\n super({ ...props, id: props.id || 'webgpu-device' });\n this.handle = device;\n this.adapter = adapter;\n this.adapterInfo = adapterInfo;\n this.info = this._getInfo();\n this.features = this._getFeatures();\n this.limits = this.handle.limits;\n // Listen for uncaptured WebGPU errors\n device.addEventListener('uncapturederror', (event) => {\n // TODO is this the right way to make sure the error is an Error instance?\n const errorMessage = event instanceof GPUUncapturedErrorEvent ? event.error.message : 'Unknown error';\n this.error(new Error(errorMessage));\n });\n // \"Context\" loss handling\n this.lost = new Promise(async (resolve) => {\n const lostInfo = await this.handle.lost;\n this._isLost = true;\n resolve({ reason: 'destroyed', message: lostInfo.message });\n });\n // Note: WebGPU devices can be created without a canvas, for compute shader purposes\n // if (props.canvas) {\n this.canvasContext = new WebGPUCanvasContext(this, this.adapter, {\n canvas: props.canvas,\n height: props.height,\n width: props.width,\n container: props.container\n });\n // }\n }\n // TODO\n // Load the glslang module now so that it is available synchronously when compiling shaders\n // const {glsl = true} = props;\n // this.glslang = glsl && await loadGlslangModule();\n destroy() {\n this.handle.destroy();\n }\n isTextureFormatSupported(format) {\n return !format.includes('webgl');\n }\n /** @todo implement proper check? */\n isTextureFormatFilterable(format) {\n return (this.isTextureFormatSupported(format) &&\n !format.startsWith('depth') &&\n !format.startsWith('stencil'));\n }\n /** @todo implement proper check? */\n isTextureFormatRenderable(format) {\n return this.isTextureFormatSupported(format);\n }\n get isLost() {\n return this._isLost;\n }\n createBuffer(props) {\n const newProps = this._getBufferProps(props);\n return new WebGPUBuffer(this, newProps);\n }\n createTexture(props) {\n return new WebGPUTexture(this, props);\n }\n createExternalTexture(props) {\n return new WebGPUExternalTexture(this, props);\n }\n createShader(props) {\n return new WebGPUShader(this, props);\n }\n createSampler(props) {\n return new WebGPUSampler(this, props);\n }\n createRenderPipeline(props) {\n return new WebGPURenderPipeline(this, props);\n }\n createFramebuffer(props) {\n return new WebGPUFramebuffer(this, props);\n }\n createComputePipeline(props) {\n return new WebGPUComputePipeline(this, props);\n }\n createVertexArray(props) {\n return new WebGPUVertexArray(this, props);\n }\n // WebGPU specifics\n /**\n * Allows a render pass to begin against a canvas context\n * @todo need to support a \"Framebuffer\" equivalent (aka preconfigured RenderPassDescriptors?).\n */\n beginRenderPass(props) {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPURenderPass(this, props);\n }\n beginComputePass(props) {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPUComputePass(this, props);\n }\n // createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {\n // return new WebGPUCommandEncoder(this, props);\n // }\n createTransformFeedback(props) {\n throw new Error('Transform feedback not supported in WebGPU');\n }\n createQuerySet(props) {\n return new WebGPUQuerySet(this, props);\n }\n createCanvasContext(props) {\n return new WebGPUCanvasContext(this, this.adapter, props);\n }\n submit() {\n // this.renderPass?.end();\n const commandBuffer = this.commandEncoder?.finish();\n if (commandBuffer) {\n this.handle.queue.submit([commandBuffer]);\n }\n this.commandEncoder = null;\n // this.renderPass = null;\n }\n // PRIVATE METHODS\n _getInfo() {\n const [driver, driverVersion] = (this.adapterInfo.driver || '').split(' Version ');\n // See https://developer.chrome.com/blog/new-in-webgpu-120#adapter_information_updates\n const vendor = this.adapterInfo.vendor || this.adapter.__brand || 'unknown';\n const renderer = driver || '';\n const version = driverVersion || '';\n const gpu = vendor === 'apple' ? 'apple' : 'unknown'; // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',\n const gpuArchitecture = this.adapterInfo.architecture || 'unknown';\n const gpuBackend = this.adapterInfo.backend || 'unknown';\n const gpuType = (this.adapterInfo.type || '').split(' ')[0].toLowerCase() || 'unknown';\n return {\n type: 'webgpu',\n vendor,\n renderer,\n version,\n gpu,\n gpuType,\n gpuBackend,\n gpuArchitecture,\n shadingLanguage: 'wgsl',\n shadingLanguageVersion: 100\n };\n }\n _getFeatures() {\n // Initialize with actual WebGPU Features (note that unknown features may not be in DeviceFeature type)\n const features = new Set(this.handle.features);\n // Fixups for pre-standard names: https://github.com/webgpu-native/webgpu-headers/issues/133\n // @ts-expect-error Chrome Canary v99\n if (features.has('depth-clamping')) {\n // @ts-expect-error Chrome Canary v99\n features.delete('depth-clamping');\n features.add('depth-clip-control');\n }\n // Some subsets of WebGPU extensions correspond to WebGL extensions\n if (features.has('texture-compression-bc')) {\n features.add('texture-compression-bc5-webgl');\n }\n const WEBGPU_ALWAYS_FEATURES = [\n 'timer-query-webgl',\n 'compilation-status-async-webgl',\n 'float32-renderable-webgl',\n 'float16-renderable-webgl',\n 'norm16-renderable-webgl',\n 'texture-filterable-anisotropic-webgl',\n 'shader-noperspective-interpolation-webgl'\n ];\n for (const feature of WEBGPU_ALWAYS_FEATURES) {\n features.add(feature);\n }\n return new DeviceFeatures(Array.from(features), this.props.disabledFeatures);\n }\n copyExternalImageToTexture(options) {\n const { source, sourceX = 0, sourceY = 0, texture, mipLevel = 0, aspect = 'all', colorSpace = 'display-p3', premultipliedAlpha = false, \n // destinationX,\n // destinationY,\n // desitnationZ,\n width = texture.width, height = texture.height, depth = 1 } = options;\n const webGpuTexture = texture;\n this.handle?.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n }, \n // destination: GPUImageCopyTextureTagged\n {\n texture: webGpuTexture.handle,\n origin: [0, 0, 0], // [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n }, \n // copySize: GPUExtent3D\n [width, height, depth]);\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Buffer } from '@luma.gl/core';\nfunction getByteLength(props) {\n return props.byteLength || props.data?.byteLength || 0;\n}\nexport class WebGPUBuffer extends Buffer {\n device;\n handle;\n byteLength;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.byteLength = getByteLength(props);\n const mapBuffer = Boolean(props.data);\n // WebGPU buffers must be aligned to 4 bytes\n const size = Math.ceil(this.byteLength / 4) * 4;\n this.handle =\n this.props.handle ||\n this.device.handle.createBuffer({\n size,\n // usage defaults to vertex\n usage: this.props.usage || GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,\n mappedAtCreation: this.props.mappedAtCreation || mapBuffer,\n label: this.props.id\n });\n if (props.data) {\n this._writeMapped(props.data);\n // this.handle.writeAsync({data: props.data, map: false, unmap: false});\n }\n if (mapBuffer && !props.mappedAtCreation) {\n this.handle.unmap();\n }\n }\n destroy() {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n // WebGPU provides multiple ways to write a buffer...\n write(data, byteOffset = 0) {\n this.device.handle.queue.writeBuffer(this.handle, byteOffset, data.buffer, data.byteOffset, data.byteLength);\n }\n async readAsync(byteOffset = 0, byteLength = this.byteLength) {\n // We need MAP_READ flag, but only COPY_DST buffers can have MAP_READ flag, so we need to create a temp buffer\n const tempBuffer = new WebGPUBuffer(this.device, {\n usage: Buffer.MAP_READ | Buffer.COPY_DST,\n byteLength\n });\n // Now do a GPU-side copy into the temp buffer we can actually read.\n // TODO - we are spinning up an independent command queue here, what does this mean\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);\n this.device.handle.queue.submit([commandEncoder.finish()]);\n // Map the temp buffer and read the data.\n await tempBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);\n const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);\n tempBuffer.handle.unmap();\n tempBuffer.destroy();\n return new Uint8Array(arrayBuffer);\n }\n _writeMapped(typedArray) {\n const arrayBuffer = this.handle.getMappedRange();\n // @ts-expect-error\n new typedArray.constructor(arrayBuffer).set(typedArray);\n }\n // WEBGPU API\n mapAsync(mode, offset = 0, size) {\n return this.handle.mapAsync(mode, offset, size);\n }\n getMappedRange(offset = 0, size) {\n return this.handle.getMappedRange(offset, size);\n }\n unmap() {\n this.handle.unmap();\n }\n}\n/*\n// Convenience API\n /** Read data from the buffer *\n async readAsync(options: {\n byteOffset?: number,\n byteLength?: number,\n map?: boolean,\n unmap?: boolean\n }): Promise<ArrayBuffer> {\n if (options.map ?? true) {\n await this.mapAsync(Buffer.MAP_READ, options.byteOffset, options.byteLength);\n }\n const arrayBuffer = this.getMappedRange(options.byteOffset, options.byteLength);\n if (options.unmap ?? true) {\n this.unmap();\n }\n return arrayBuffer;\n }\n\n /** Write data to the buffer *\n async writeAsync(options: {\n data: ArrayBuffer,\n byteOffset?: number,\n byteLength?: number,\n map?: boolean,\n unmap?: boolean\n }): Promise<void> {\n if (options.map ?? true) {\n await this.mapAsync(Buffer.MAP_WRITE, options.byteOffset, options.byteLength);\n }\n const arrayBuffer = this.getMappedRange(options.byteOffset, options.byteLength);\n const destArray = new Uint8Array(arrayBuffer);\n const srcArray = new Uint8Array(options.data);\n destArray.set(srcArray);\n if (options.unmap ?? true) {\n this.unmap();\n }\n }\n */\n// Mapped API (WebGPU)\n/** Maps the memory so that it can be read *\n // abstract mapAsync(mode, byteOffset, byteLength): Promise<void>\n\n /** Get the mapped range of data for reading or writing *\n // abstract getMappedRange(byteOffset, byteLength): ArrayBuffer;\n\n /** unmap makes the contents of the buffer available to the GPU again *\n // abstract unmap(): void;\n*/\n", "import { Texture } from '@luma.gl/core';\nimport { getWebGPUTextureFormat } from \"../helpers/convert-texture-format.js\";\nimport { WebGPUSampler } from \"./webgpu-sampler.js\";\nimport { WebGPUTextureView } from \"./webgpu-texture-view.js\";\nconst BASE_DIMENSIONS = {\n '1d': '1d',\n '2d': '2d',\n '2d-array': '2d',\n cube: '2d',\n 'cube-array': '2d',\n '3d': '3d'\n};\nexport class WebGPUTexture extends Texture {\n device;\n handle;\n height = 1;\n width = 1;\n sampler;\n view;\n // static async createFromImageURL(src, usage = 0) {\n // const img = document.createElement('img');\n // img.src = src;\n // await img.decode();\n // return WebGPUTexture(img, usage);\n // }\n constructor(device, props) {\n props = Texture._fixProps(props);\n super(device, props);\n this.device = device;\n this.initialize(props);\n }\n destroy() {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n createView(props) {\n return new WebGPUTextureView(this.device, { ...props, texture: this });\n }\n initialize(props) {\n // @ts-expect-error\n this.handle = this.props.handle || this.createHandle();\n this.handle.label ||= this.id;\n if (this.props.data) {\n if (Texture.isExternalImage(this.props.data)) {\n this.copyExternalImage({ image: this.props.data });\n }\n else {\n this.setData({ data: this.props.data });\n }\n }\n this.width = this.handle.width;\n this.height = this.handle.height;\n // Why not just read all properties directly from the texture\n // this.depthOrArrayLayers = this.handle.depthOrArrayLayers;\n // this.mipLevelCount = this.handle.mipLevelCount;\n // this.sampleCount = this.handle.sampleCount;\n // this.dimension = this.handle.dimension;\n // this.format = this.handle.format;\n // this.usage = this.handle.usage;\n // Create a default sampler. This mimics the WebGL1 API where sampler props are stored on the texture\n // this.setSampler(props.sampler);\n this.sampler =\n props.sampler instanceof WebGPUSampler\n ? props.sampler\n : new WebGPUSampler(this.device, props.sampler || {});\n // TODO - To support texture arrays we need to create custom views...\n // But we are not ready to expose TextureViews to the public API.\n // @ts-expect-error\n this.view = new WebGPUTextureView(this.device, { ...this.props, texture: this });\n // format: this.props.format,\n // dimension: this.props.dimension,\n // aspect = \"all\";\n // baseMipLevel: 0;\n // mipLevelCount;\n // baseArrayLayer = 0;\n // arrayLayerCount;\n }\n createHandle() {\n // Deduce size from data - TODO this is a hack\n // @ts-expect-error\n const width = this.props.width || this.props.data?.width || 1;\n // @ts-expect-error\n const height = this.props.height || this.props.data?.height || 1;\n return this.device.handle.createTexture({\n label: this.id,\n size: {\n width,\n height,\n depthOrArrayLayers: this.depth\n },\n usage: this.props.usage || Texture.TEXTURE | Texture.COPY_DST,\n dimension: BASE_DIMENSIONS[this.dimension],\n format: getWebGPUTextureFormat(this.format),\n mipLevelCount: this.mipLevels,\n sampleCount: this.props.samples\n });\n }\n /** @deprecated - intention is to use the createView public API */\n createGPUTextureView() {\n return this.handle.createView({ label: this.id });\n }\n /**\n * Set default sampler\n * Accept a sampler instance or set of props;\n */\n setSampler(sampler) {\n this.sampler =\n sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n setTexture1DData(data) {\n throw new Error('not implemented');\n }\n setTexture2DData(lodData, depth, target) {\n throw new Error('not implemented');\n }\n setTexture3DData(lodData, depth, target) {\n throw new Error('not implemented');\n }\n setTextureCubeData(data, depth) {\n throw new Error('not implemented');\n }\n setTextureArrayData(data) {\n throw new Error('not implemented');\n }\n setTextureCubeArrayData(data) {\n throw new Error('not implemented');\n }\n setData(options) {\n if (ArrayBuffer.isView(options.data)) {\n const clampedArray = new Uint8ClampedArray(options.data.buffer);\n // TODO - pass through src data color space as ImageData Options?\n const image = new ImageData(clampedArray, this.width, this.height);\n return this.copyExternalImage({ image });\n }\n throw new Error('Texture.setData: Use CommandEncoder to upload data to texture in WebGPU');\n }\n copyExternalImage(options) {\n const size = Texture.getExternalImageSize(options.image);\n const opts = { ...Texture.defaultCopyExternalImageOptions, ...size, ...options };\n const { image, sourceX, sourceY, width, height, depth, mipLevel, x, y, z, aspect, colorSpace, premultipliedAlpha } = opts;\n // TODO - max out width\n this.device.handle.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source: image,\n origin: [sourceX, sourceY]\n }, \n // destination: GPUImageCopyTextureTagged\n {\n texture: this.handle,\n origin: [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n }, \n // copySize: GPUExtent3D\n [width, height, depth]);\n return { width, height };\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/** Ensure a texture format is WebGPU compatible */\nexport function getWebGPUTextureFormat(format) {\n if (format.includes('webgl')) {\n throw new Error('webgl-only format');\n }\n return format;\n}\n", "// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\nimport { Sampler } from '@luma.gl/core';\n/**\n *\n */\nexport class WebGPUSampler extends Sampler {\n device;\n handle;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n // Prepare sampler props\n const samplerProps = { ...this.props };\n if (samplerProps.type !== 'comparison-sampler') {\n delete samplerProps.compare;\n }\n this.handle = this.handle || this.device.handle.createSampler(samplerProps);\n this.handle.label = this.props.id;\n }\n destroy() {\n // GPUSampler does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { TextureView } from '@luma.gl/core';\n/**\n *\n */\nexport class WebGPUTextureView extends TextureView {\n device;\n handle;\n texture;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.texture = props.texture;\n this.handle =\n this.handle ||\n this.texture.handle.createView({\n format: (props.format || this.texture.format),\n dimension: props.dimension || this.texture.dimension,\n aspect: props.aspect,\n baseMipLevel: props.baseMipLevel,\n mipLevelCount: props.mipLevelCount, // GPUIntegerCoordinate;\n baseArrayLayer: props.baseArrayLayer, // GPUIntegerCoordinate;\n arrayLayerCount: props.arrayLayerCount // GPUIntegerCoordinate;\n });\n this.handle.label = this.props.id;\n }\n destroy() {\n // GPUTextureView does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ExternalTexture } from '@luma.gl/core';\nimport { WebGPUSampler } from \"./webgpu-sampler.js\";\n/**\n * Cheap, temporary texture view for videos\n * Only valid within same callback, destroyed automatically as a microtask.\n */\nexport class WebGPUExternalTexture extends ExternalTexture {\n device;\n handle;\n sampler;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.handle =\n this.props.handle ||\n this.device.handle.importExternalTexture({\n source: props.source,\n colorSpace: props.colorSpace\n });\n // @ts-expect-error\n this.sampler = null;\n }\n destroy() {\n // External textures are destroyed automatically,\n // as a microtask, instead of manually or upon garbage collection like other resources.\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n /** Set default sampler */\n setSampler(sampler) {\n // We can accept a sampler instance or set of props;\n this.sampler =\n sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Shader, log } from '@luma.gl/core';\n/**\n * Immutable shader\n */\nexport class WebGPUShader extends Shader {\n device;\n handle;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.device.handle.pushErrorScope('validation');\n this.handle = this.props.handle || this.createHandle();\n this.handle.label = this.props.id;\n this._checkCompilationError(this.device.handle.popErrorScope());\n }\n async _checkCompilationError(errorScope) {\n const error = (await errorScope);\n if (error) {\n // The `Shader` base class will determine if debug window should be opened based on props\n this.debugShader();\n const shaderLog = await this.getCompilationInfo();\n log.error(`Shader compilation error: ${error.message}`, shaderLog)();\n // Note: Even though this error is asynchronous and thrown after the constructor completes,\n // it will result in a useful stack trace leading back to the constructor\n throw new Error(`Shader compilation error: ${error.message}`);\n }\n }\n destroy() {\n // Note: WebGPU does not offer a method to destroy shaders\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n /** Returns compilation info for this shader */\n async getCompilationInfo() {\n const compilationInfo = await this.handle.getCompilationInfo();\n return compilationInfo.messages;\n }\n // PRIVATE METHODS\n createHandle() {\n const { source } = this.props;\n const isGLSL = source.includes('#version');\n if (this.props.language === 'glsl' || isGLSL) {\n throw new Error('GLSL shaders are not supported in WebGPU');\n }\n return this.device.handle.createShaderModule({ code: source });\n }\n}\n", "// luma.gl MIT license\nimport { RenderPipeline, log } from '@luma.gl/core';\nimport { applyParametersToRenderPipelineDescriptor } from \"../helpers/webgpu-parameters.js\";\nimport { getWebGPUTextureFormat } from \"../helpers/convert-texture-format.js\";\nimport { getBindGroup } from \"../helpers/get-bind-group.js\";\nimport { getVertexBufferLayout } from \"../helpers/get-vertex-buffer-layout.js\";\n// RENDER PIPELINE\n/** Creates a new render pipeline when parameters change */\nexport class WebGPURenderPipeline extends RenderPipeline {\n device;\n handle;\n vs;\n fs = null;\n /** For internal use to create BindGroups */\n _bindings;\n _bindGroupLayout = null;\n _bindGroup = null;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle;\n if (!this.handle) {\n const descriptor = this._getRenderPipelineDescriptor();\n log.groupCollapsed(1, `new WebGPURenderPipeline(${this.id})`)();\n log.probe(1, JSON.stringify(descriptor, null, 2))();\n log.groupEnd(1)();\n this.handle = this.device.handle.createRenderPipeline(descriptor);\n }\n this.handle.label = this.props.id;\n this.vs = props.vs;\n this.fs = props.fs;\n this._bindings = { ...this.props.bindings };\n }\n destroy() {\n // WebGPURenderPipeline has no destroy method.\n // @ts-expect-error\n this.handle = null;\n }\n /**\n * @todo Use renderpass.setBindings() ?\n * @todo Do we want to expose BindGroups in the API and remove this?\n */\n setBindings(bindings) {\n Object.assign(this._bindings, bindings);\n }\n /** @todo - should this be moved to renderpass? */\n draw(options) {\n const webgpuRenderPass = options.renderPass;\n // Set pipeline\n webgpuRenderPass.handle.setPipeline(this.handle);\n // Set bindings (uniform buffers, textures etc)\n const bindGroup = this._getBindGroup();\n if (bindGroup) {\n webgpuRenderPass.handle.setBindGroup(0, bindGroup);\n }\n // Set attributes\n // Note: Rebinds constant attributes before each draw call\n options.vertexArray.bindBeforeRender(options.renderPass);\n // Draw\n if (options.indexCount) {\n webgpuRenderPass.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);\n }\n else {\n webgpuRenderPass.handle.draw(options.vertexCount || 0, options.instanceCount || 1, // If 0, nothing will be drawn\n options.firstInstance);\n }\n // Note: Rebinds constant attributes before each draw call\n options.vertexArray.unbindAfterRender(options.renderPass);\n return true;\n }\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n if (this.shaderLayout.bindings.length === 0) {\n return null;\n }\n // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group\n this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);\n // Set up the bindings\n // TODO what if bindings change? We need to rebuild the bind group!\n this._bindGroup =\n this._bindGroup ||\n getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);\n return this._bindGroup;\n }\n /**\n * Populate the complex WebGPU GPURenderPipelineDescriptor\n */\n _getRenderPipelineDescriptor() {\n // Set up the vertex stage\n const vertex = {\n module: this.props.vs.handle,\n entryPoint: this.props.vertexEntryPoint || 'main',\n buffers: getVertexBufferLayout(this.shaderLayout, this.props.bufferLayout)\n };\n // Set up the fragment stage\n const fragment = {\n module: this.props.fs.handle,\n entryPoint: this.props.fragmentEntryPoint || 'main',\n targets: [\n {\n // TODO exclamation mark hack!\n format: getWebGPUTextureFormat(this.device.getCanvasContext().format)\n }\n ]\n };\n // Create a partially populated descriptor\n const descriptor = {\n vertex,\n fragment,\n primitive: {\n topology: this.props.topology\n },\n layout: 'auto'\n };\n // Set parameters on the descriptor\n applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);\n return descriptor;\n }\n}\n/**\n_setAttributeBuffers(webgpuRenderPass: WebGPURenderPass) {\n if (this._indexBuffer) {\n webgpuRenderPass.handle.setIndexBuffer(this._indexBuffer.handle, this._indexBuffer.props.indexType);\n }\n\n const buffers = this._getBuffers();\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = cast<WebGPUBuffer>(buffers[i]);\n if (!buffer) {\n const attribute = this.shaderLayout.attributes.find(\n (attribute) => attribute.location === i\n );\n throw new Error(\n `No buffer provided for attribute '${attribute?.name || ''}' in Model '${this.props.id}'`\n );\n }\n webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);\n }\n\n // TODO - HANDLE buffer maps\n /*\n for (const [bufferName, attributeMapping] of Object.entries(this.props.bufferLayout)) {\n const buffer = cast<WebGPUBuffer>(this.props.attributes[bufferName]);\n if (!buffer) {\n log.warn(`Missing buffer for buffer map ${bufferName}`)();\n continue;\n }\n\n if ('location' in attributeMapping) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(layout.location, buffer.handle);\n } else {\n for (const [bufferName, mapping] of Object.entries(attributeMapping)) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(field.location, buffer.handle);\n }\n }\n }\n *\n}\n*/\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nfunction addDepthStencil(descriptor) {\n descriptor.depthStencil = descriptor.depthStencil || {\n // required, set something\n format: 'depth24plus',\n stencilFront: {},\n stencilBack: {},\n // TODO can this cause trouble? Should we set to WebGPU defaults? Are there defaults?\n depthWriteEnabled: false,\n depthCompare: 'less-equal'\n };\n return descriptor.depthStencil;\n}\nfunction addDepthStencilFront(descriptor) {\n const depthStencil = addDepthStencil(descriptor);\n // @ts-ignore\n return depthStencil.stencilFront;\n}\nfunction addDepthStencilBack(descriptor) {\n const depthStencil = addDepthStencil(descriptor);\n // @ts-ignore\n return depthStencil.stencilBack;\n}\n/**\n * Supports for luma.gl's flat parameter space\n * Populates the corresponding sub-objects in a GPURenderPipelineDescriptor\n */\n// @ts-expect-error\nexport const PARAMETER_TABLE = {\n // RASTERIZATION PARAMETERS\n cullMode: (parameter, value, descriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.cullMode = value;\n },\n frontFace: (parameter, value, descriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.frontFace = value;\n },\n // DEPTH\n depthWriteEnabled: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthWriteEnabled = value;\n },\n depthCompare: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthCompare = value;\n },\n depthFormat: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.format = value;\n },\n depthBias: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBias = value;\n },\n depthBiasSlopeScale: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasSlopeScale = value;\n },\n depthBiasClamp: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasClamp = value;\n },\n // STENCIL\n stencilReadMask: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilReadMask = value;\n },\n stencilWriteMask: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilWriteMask = value;\n },\n stencilCompare: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.compare = value;\n stencilBack.compare = value;\n },\n stencilPassOperation: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.passOp = value;\n stencilBack.passOp = value;\n },\n stencilFailOperation: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.failOp = value;\n stencilBack.failOp = value;\n },\n stencilDepthFailOperation: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.depthFailOp = value;\n stencilBack.depthFailOp = value;\n },\n // MULTISAMPLE\n sampleCount: (parameter, value, descriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.count = value;\n },\n sampleMask: (parameter, value, descriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.mask = value;\n },\n sampleAlphaToCoverageEnabled: (parameter, value, descriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.alphaToCoverageEnabled = value;\n },\n // COLOR\n colorMask: (parameter, value, descriptor) => {\n const targets = addColorState(descriptor);\n targets[0].writeMask = value;\n },\n blendColorOperation: (parameter, value, descriptor) => {\n addColorState(descriptor);\n // const targets = addColorState(descriptor);\n // const target = targets[0];\n // const blend: GPUBlendState = target.blend || {color: {alpha: 0}};\n // blend.color = blend.color || {};\n // target.blend.color.operation = value;\n }\n /*\n blendColorSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.srcTarget = value;\n },\n \n blendColorDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.dstTarget = value;\n },\n \n blendAlphaOperation: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.operation = value;\n },\n \n blendAlphaSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.srcTarget = value;\n },\n \n blendAlphaDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.dstTarget = value;\n },\n */\n};\nconst DEFAULT_PIPELINE_DESCRIPTOR = {\n // depthStencil: {\n // stencilFront: {},\n // stencilBack: {},\n // // depthWriteEnabled: true,\n // // depthCompare: 'less',\n // // format: 'depth24plus-stencil8',\n // },\n primitive: {\n cullMode: 'back',\n topology: 'triangle-list'\n },\n vertex: {\n module: undefined,\n entryPoint: 'main'\n },\n fragment: {\n module: undefined,\n entryPoint: 'main',\n targets: [\n // { format: props.color0Format || 'bgra8unorm' }\n ]\n },\n layout: 'auto'\n};\nexport function applyParametersToRenderPipelineDescriptor(pipelineDescriptor, parameters = {}) {\n // Apply defaults\n Object.assign(pipelineDescriptor, { ...DEFAULT_PIPELINE_DESCRIPTOR, ...pipelineDescriptor });\n setParameters(pipelineDescriptor, parameters);\n}\n// Apply any supplied parameters\nfunction setParameters(pipelineDescriptor, parameters) {\n for (const [key, value] of Object.entries(parameters)) {\n const setterFunction = PARAMETER_TABLE[key];\n if (!setterFunction) {\n throw new Error(`Illegal parameter ${key}`);\n }\n setterFunction(key, value, pipelineDescriptor);\n }\n}\nfunction addColorState(descriptor) {\n // @ts-ignore\n descriptor.fragment.targets = descriptor.fragment?.targets || [];\n if (!Array.isArray(descriptor.fragment?.targets)) {\n throw new Error('colorstate');\n }\n if (descriptor.fragment?.targets?.length === 0) {\n descriptor.fragment.targets?.push({});\n }\n return descriptor.fragment?.targets;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Buffer, Sampler, Texture, log } from '@luma.gl/core';\n/**\n * Create a WebGPU \"bind group layout\" from an array of luma.gl bindings\n * @note bind groups can be automatically generated by WebGPU.\n */\nexport function makeBindGroupLayout(device, layout, bindings) {\n throw new Error('not implemented');\n // return device.createBindGroupLayout({\n // layout,\n // entries: getBindGroupEntries(bindings)\n // })\n}\n/**\n * Create a WebGPU \"bind group\" from an array of luma.gl bindings\n */\nexport function getBindGroup(device, bindGroupLayout, shaderLayout, bindings) {\n const entries = getBindGroupEntries(bindings, shaderLayout);\n return device.createBindGroup({\n layout: bindGroupLayout,\n entries\n });\n}\nexport function getShaderLayoutBinding(shaderLayout, bindingName) {\n const bindingLayout = shaderLayout.bindings.find(binding => binding.name === bindingName || `${binding.name}uniforms` === bindingName.toLocaleLowerCase());\n if (!bindingLayout) {\n log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();\n }\n return bindingLayout || null;\n}\n/**\n * @param bindings\n * @returns\n */\nfunction getBindGroupEntries(bindings, shaderLayout) {\n const entries = [];\n for (const [bindingName, value] of Object.entries(bindings)) {\n const bindingLayout = getShaderLayoutBinding(shaderLayout, bindingName);\n if (bindingLayout) {\n entries.push(getBindGroupEntry(value, bindingLayout.location));\n }\n }\n return entries;\n}\nfunction getBindGroupEntry(binding, index) {\n if (binding instanceof Buffer) {\n return {\n binding: index,\n resource: {\n buffer: binding.handle\n }\n };\n }\n if (binding instanceof Sampler) {\n return {\n binding: index,\n resource: binding.handle\n };\n }\n else if (binding instanceof Texture) {\n return {\n binding: index,\n resource: binding.handle.createView({ label: 'bind-group-auto-created' })\n };\n }\n throw new Error('invalid binding');\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { log, decodeVertexFormat } from '@luma.gl/core';\n// import {getAttributeInfosFromLayouts} from '@luma.gl/core';\n/** Throw error on any WebGL-only vertex formats */\nfunction getWebGPUVertexFormat(format) {\n if (format.endsWith('-webgl')) {\n throw new Error(`WebGPU does not support vertex format ${format}`);\n }\n return format;\n}\n/**\n * Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.\n * Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array\n * @param layout\n * @param bufferLayout The buffer map is optional\n * @returns WebGPU layout intended for a GPURenderPassDescriptor.\n */\nexport function getVertexBufferLayout(shaderLayout, bufferLayout) {\n const vertexBufferLayouts = [];\n const usedAttributes = new Set();\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // Build vertex attributes for one buffer\n const vertexAttributes = [];\n // TODO verify that all stepModes for one buffer are the same\n let stepMode = 'vertex';\n let byteStride = 0;\n // @ts-ignore\n const format = mapping.format;\n // interleaved mapping {..., attributes: [{...}, ...]}\n if (mapping.attributes) {\n // const arrayStride = mapping.byteStride; TODO\n for (const attributeMapping of mapping.attributes) {\n const attributeName = attributeMapping.attribute;\n const attributeLayout = findAttributeLayout(shaderLayout, attributeName, usedAttributes);\n // @ts-ignore\n const location = attributeLayout?.location;\n stepMode =\n attributeLayout?.stepMode ||\n (attributeLayout?.name.startsWith('instance') ? 'instance' : 'vertex');\n vertexAttributes.push({\n format: getWebGPUVertexFormat(attributeMapping.format || mapping.format),\n offset: attributeMapping.byteOffset,\n shaderLocation: location\n });\n byteStride += decodeVertexFormat(format).byteLength;\n }\n // non-interleaved mapping (just set offset and stride)\n }\n else {\n const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);\n if (!attributeLayout) {\n continue; // eslint-disable-line no-continue\n }\n byteStride = decodeVertexFormat(format).byteLength;\n stepMode =\n attributeLayout.stepMode ||\n (attributeLayout.name.startsWith('instance') ? 'instance' : 'vertex');\n vertexAttributes.push({\n format: getWebGPUVertexFormat(format),\n // We only support 0 offset for non-interleaved buffer layouts\n offset: 0,\n shaderLocation: attributeLayout.location\n });\n }\n // Store all the attribute bindings for one buffer\n vertexBufferLayouts.push({\n arrayStride: mapping.byteStride || byteStride,\n stepMode,\n attributes: vertexAttributes\n });\n }\n // Add any non-mapped attributes - TODO - avoid hardcoded types\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n vertexBufferLayouts.push({\n arrayStride: decodeVertexFormat('float32x3').byteLength,\n stepMode: attribute.stepMode || (attribute.name.startsWith('instance') ? 'instance' : 'vertex'),\n attributes: [\n {\n format: getWebGPUVertexFormat('float32x3'),\n offset: 0,\n shaderLocation: attribute.location\n }\n ]\n });\n }\n }\n return vertexBufferLayouts;\n}\nexport function getBufferSlots(shaderLayout, bufferLayout) {\n const usedAttributes = new Set();\n let bufferSlot = 0;\n const bufferSlots = {};\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n for (const interleaved of mapping.attributes || []) {\n usedAttributes.add(interleaved.attribute);\n }\n // non-interleaved mapping (just set offset and stride)\n }\n else {\n usedAttributes.add(mapping.name);\n }\n bufferSlots[mapping.name] = bufferSlot++;\n }\n // Add any non-mapped attributes\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n bufferSlots[attribute.name] = bufferSlot++;\n }\n }\n return bufferSlots;\n}\n/**\n * Looks up an attribute in the ShaderLayout.\n * @throws if name is not in ShaderLayout\n * @throws if name has already been referenced\n */\nfunction findAttributeLayout(shaderLayout, name, attributeNames) {\n const attribute = shaderLayout.attributes.find(attribute => attribute.name === name);\n if (!attribute) {\n log.warn(`Unknown attribute ${name}`)();\n return null;\n }\n if (attributeNames.has(name)) {\n throw new Error(`Duplicate attribute ${name}`);\n }\n attributeNames.add(name);\n return attribute;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Framebuffer } from '@luma.gl/core';\n/**\n * Create new textures with correct size for all attachments.\n * @note resize() destroys existing textures (if size has changed).\n */\nexport class WebGPUFramebuffer extends Framebuffer {\n device;\n colorAttachments = [];\n depthStencilAttachment = null;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n }\n updateAttachments() {\n // WebGPU framebuffers are JS only objects, nothing to update\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ComputePipeline } from '@luma.gl/core';\nimport { getBindGroup } from \"../helpers/get-bind-group.js\";\n// COMPUTE PIPELINE\n/** Creates a new compute pipeline when parameters change */\nexport class WebGPUComputePipeline extends ComputePipeline {\n device;\n handle;\n /** For internal use to create BindGroups */\n _bindGroupLayout = null;\n _bindGroup = null;\n /** For internal use to create BindGroups */\n _bindings = {};\n constructor(device, props) {\n super(device, props);\n this.device = device;\n const webgpuShader = this.props.shader;\n this.handle =\n this.props.handle ||\n this.device.handle.createComputePipeline({\n label: this.props.id,\n compute: {\n module: webgpuShader.handle,\n entryPoint: this.props.entryPoint,\n constants: this.props.constants\n },\n layout: 'auto'\n });\n }\n /**\n * @todo Use renderpass.setBindings() ?\n * @todo Do we want to expose BindGroups in the API and remove this?\n */\n setBindings(bindings) {\n Object.assign(this._bindings, bindings);\n }\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group\n this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);\n // Set up the bindings\n this._bindGroup =\n this._bindGroup ||\n getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);\n return this._bindGroup;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { RenderPass, log } from '@luma.gl/core';\nexport class WebGPURenderPass extends RenderPass {\n device;\n handle;\n /** Active pipeline */\n pipeline = null;\n constructor(device, props = {}) {\n super(device, props);\n this.device = device;\n const framebuffer = props.framebuffer || device.getCanvasContext().getCurrentFramebuffer();\n const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);\n const webgpuQuerySet = props.timestampQuerySet;\n if (webgpuQuerySet) {\n renderPassDescriptor.occlusionQuerySet = webgpuQuerySet.handle;\n }\n if (device.features.has('timestamp-query')) {\n const webgpuQuerySet = props.timestampQuerySet;\n renderPassDescriptor.timestampWrites = webgpuQuerySet\n ? {\n querySet: webgpuQuerySet.handle,\n beginningOfPassWriteIndex: props.beginTimestampIndex,\n endOfPassWriteIndex: props.endTimestampIndex\n }\n : undefined;\n }\n if (!device.commandEncoder) {\n throw new Error('commandEncoder not available');\n }\n this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);\n this.handle.label = this.props.id;\n log.groupCollapsed(3, `new WebGPURenderPass(${this.id})`)();\n log.probe(3, JSON.stringify(renderPassDescriptor, null, 2))();\n log.groupEnd(3)();\n }\n destroy() { }\n end() {\n this.handle.end();\n }\n setPipeline(pipeline) {\n this.pipeline = pipeline;\n this.handle.setPipeline(this.pipeline.handle);\n }\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings) {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n setIndexBuffer(buffer, indexFormat, offset = 0, size) {\n this.handle.setIndexBuffer(buffer.handle, indexFormat, offset, size);\n }\n setVertexBuffer(slot, buffer, offset = 0) {\n this.handle.setVertexBuffer(slot, buffer.handle, offset);\n }\n draw(options) {\n if (options.indexCount) {\n this.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);\n }\n else {\n this.handle.draw(options.vertexCount || 0, options.instanceCount || 1, options.firstIndex, options.firstInstance);\n }\n }\n drawIndirect() {\n // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n }\n setParameters(parameters) {\n const { blendConstant, stencilReference, scissorRect, viewport } = parameters;\n if (blendConstant) {\n this.handle.setBlendConstant(blendConstant);\n }\n if (stencilReference) {\n this.handle.setStencilReference(stencilReference);\n }\n if (scissorRect) {\n this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);\n }\n // TODO - explain how 3 dimensions vs 2 in WebGL works.\n if (viewport) {\n this.handle.setViewport(viewport[0], viewport[1], viewport[2], viewport[3], viewport[4], viewport[5]);\n }\n }\n pushDebugGroup(groupLabel) {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup() {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel) {\n this.handle.insertDebugMarker(markerLabel);\n }\n beginOcclusionQuery(queryIndex) {\n this.handle.beginOcclusionQuery(queryIndex);\n }\n endOcclusionQuery() {\n this.handle.endOcclusionQuery();\n }\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n // INTERNAL\n /**\n * Partial render pass descriptor. Used by WebGPURenderPass.\n * @returns attachments fields of a renderpass descriptor.\n */\n getRenderPassDescriptor(framebuffer) {\n const renderPassDescriptor = {\n colorAttachments: []\n };\n renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({\n // clear values\n loadOp: this.props.clearColor !== false ? 'clear' : 'load',\n colorClearValue: this.props.clearColor || [0, 0, 0, 0],\n storeOp: this.props.discard ? 'discard' : 'store',\n // ...colorAttachment,\n view: colorAttachment.handle\n }));\n if (framebuffer.depthStencilAttachment) {\n renderPassDescriptor.depthStencilAttachment = {\n view: framebuffer.depthStencilAttachment.handle\n };\n const { depthStencilAttachment } = renderPassDescriptor;\n // DEPTH\n if (this.props.depthReadOnly) {\n depthStencilAttachment.depthReadOnly = true;\n }\n depthStencilAttachment.depthClearValue = this.props.clearDepth || 0;\n // WebGPU only wants us to set these parameters if the texture format actually has a depth aspect\n const hasDepthAspect = true;\n if (hasDepthAspect) {\n depthStencilAttachment.depthLoadOp = this.props.clearDepth !== false ? 'clear' : 'load';\n depthStencilAttachment.depthStoreOp = 'store'; // TODO - support 'discard'?\n }\n // WebGPU only wants us to set these parameters if the texture format actually has a stencil aspect\n const hasStencilAspect = false;\n if (hasStencilAspect) {\n depthStencilAttachment.stencilLoadOp = this.props.clearStencil !== false ? 'clear' : 'load';\n depthStencilAttachment.stencilStoreOp = 'store'; // TODO - support 'discard'?\n }\n }\n return renderPassDescriptor;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ComputePass } from '@luma.gl/core';\nexport class WebGPUComputePass extends ComputePass {\n device;\n handle;\n _webgpuPipeline = null;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n // Set up queries\n let timestampWrites;\n if (device.features.has('timestamp-query')) {\n const webgpuQuerySet = props.timestampQuerySet;\n if (webgpuQuerySet) {\n timestampWrites = {\n querySet: webgpuQuerySet.handle,\n beginningOfPassWriteIndex: props.beginTimestampIndex,\n endOfPassWriteIndex: props.endTimestampIndex\n };\n }\n }\n this.handle =\n this.props.handle ||\n device.commandEncoder?.beginComputePass({\n label: this.props.id,\n timestampWrites\n });\n }\n /** @note no WebGPU destroy method, just gc */\n destroy() { }\n end() {\n this.handle.end();\n }\n setPipeline(pipeline) {\n const wgpuPipeline = pipeline;\n this.handle.setPipeline(wgpuPipeline.handle);\n this._webgpuPipeline = wgpuPipeline;\n this.setBindings([]);\n }\n /**\n * Sets an array of bindings (uniform buffers, samplers, textures, ...)\n * TODO - still some API confusion - does this method go here or on the pipeline?\n */\n setBindings(bindings) {\n // @ts-expect-error\n const bindGroup = this._webgpuPipeline._getBindGroup();\n this.handle.setBindGroup(0, bindGroup);\n }\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param x X dimension of the grid of work groups to dispatch.\n * @param y Y dimension of the grid of work groups to dispatch.\n * @param z Z dimension of the grid of work groups to dispatch.\n */\n dispatch(x, y, z) {\n this.handle.dispatchWorkgroups(x, y, z);\n }\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n *\n * 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()\n * @param indirectBuffer\n * @param indirectOffset offset in buffer to the beginning of the dispatch data.\n */\n dispatchIndirect(indirectBuffer, indirectByteOffset = 0) {\n const webgpuBuffer = indirectBuffer;\n this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectByteOffset);\n }\n pushDebugGroup(groupLabel) {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup() {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel) {\n this.handle.insertDebugMarker(markerLabel);\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { VertexArray, log } from '@luma.gl/core';\nimport { getBrowser } from '@probe.gl/env';\n/** VertexArrayObject wrapper */\nexport class WebGPUVertexArray extends VertexArray {\n get [Symbol.toStringTag]() {\n return 'WebGPUVertexArray';\n }\n device;\n /** Vertex Array is a helper class under WebGPU */\n handle;\n // Create a VertexArray\n constructor(device, props) {\n super(device, props);\n this.device = device;\n }\n destroy() { }\n /**\n * Set an elements buffer, for indexed rendering.\n * Must be a Buffer bound to buffer with usage bit Buffer.INDEX set.\n */\n setIndexBuffer(buffer) {\n // assert(!elementBuffer || elementBuffer.glTarget === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n this.indexBuffer = buffer;\n }\n /** Set a bufferSlot in vertex attributes array to a buffer, enables the bufferSlot, sets divisor */\n setBuffer(bufferSlot, buffer) {\n // Sanity check target\n // if (buffer.glUsage === GL.ELEMENT_ARRAY_BUFFER) {\n // throw new Error('Use setIndexBuffer');\n // }\n this.attributes[bufferSlot] = buffer;\n }\n bindBeforeRender(renderPass, firstIndex, indexCount) {\n const webgpuRenderPass = renderPass;\n const webgpuIndexBuffer = this.indexBuffer;\n if (webgpuIndexBuffer?.handle) {\n // Note we can't unset an index buffer\n log.warn('setting index buffer', webgpuIndexBuffer?.handle, webgpuIndexBuffer?.indexType)();\n webgpuRenderPass.handle.setIndexBuffer(webgpuIndexBuffer?.handle, \n // @ts-expect-error TODO - we must enforce type\n webgpuIndexBuffer?.indexType);\n }\n for (let location = 0; location < this.maxVertexAttributes; location++) {\n const webgpuBuffer = this.attributes[location];\n if (webgpuBuffer?.handle) {\n log.warn(`setting vertex buffer ${location}`, webgpuBuffer?.handle)();\n webgpuRenderPass.handle.setVertexBuffer(location, webgpuBuffer?.handle);\n }\n }\n // TODO - emit warnings/errors/throw if constants have been set on this vertex array\n }\n unbindAfterRender(renderPass) {\n // On WebGPU we don't need to unbind.\n // In fact we can't easily do it. setIndexBuffer/setVertexBuffer don't accept null.\n // Unbinding presumably happens automatically when the render pass is ended.\n }\n // DEPRECATED METHODS\n /**\n * @deprecated is this even an issue for WebGPU?\n * Attribute 0 can not be disable on most desktop OpenGL based browsers\n */\n static isConstantAttributeZeroSupported(device) {\n return getBrowser() === 'Chrome';\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { CanvasContext, log } from '@luma.gl/core';\nimport { getWebGPUTextureFormat } from \"./helpers/convert-texture-format.js\";\nimport { WebGPUFramebuffer } from \"./resources/webgpu-framebuffer.js\";\n/**\n * Holds a WebGPU Canvas Context\n * The primary job of the CanvasContext is to generate textures for rendering into the current canvas\n * It also manages canvas sizing calculations and resizing.\n */\nexport class WebGPUCanvasContext extends CanvasContext {\n device;\n gpuCanvasContext;\n /** Format of returned textures: \"bgra8unorm\", \"rgba8unorm\", \"rgba16float\". */\n format = navigator.gpu.getPreferredCanvasFormat();\n /** Default stencil format for depth textures */\n depthStencilFormat = 'depth24plus';\n depthStencilAttachment = null;\n constructor(device, adapter, props) {\n super(props);\n this.device = device;\n // TODO - hack to trigger resize?\n this.width = -1;\n this.height = -1;\n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n // @ts-ignore TODO - we don't handle OffscreenRenderingContext.\n this.gpuCanvasContext = this.canvas.getContext('webgpu');\n // TODO this has been replaced\n // this.format = this.gpuCanvasContext.getPreferredFormat(adapter);\n this.format = 'bgra8unorm';\n }\n /** Destroy any textures produced while configured and remove the context configuration. */\n destroy() {\n this.gpuCanvasContext.unconfigure();\n }\n /** Update framebuffer with properly resized \"swap chain\" texture views */\n getCurrentFramebuffer() {\n // Ensure the canvas context size is updated\n this.update();\n // Wrap the current canvas context texture in a luma.gl texture\n // const currentColorAttachment = this.device.createTexture({\n // id: 'default-render-target',\n // handle: this.gpuCanvasContext.getCurrentTexture(),\n // format: this.format,\n // width: this.width,\n // height: this.height\n // });\n // Wrap the current canvas context texture in a luma.gl texture\n const currentColorAttachment = this.getCurrentTexture();\n this.width = currentColorAttachment.width;\n this.height = currentColorAttachment.height;\n // Resize the depth stencil attachment\n this._createDepthStencilAttachment();\n return new WebGPUFramebuffer(this.device, {\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: this.depthStencilAttachment\n });\n }\n /** Resizes and updates render targets if necessary */\n update() {\n const [width, height] = this.getPixelSize();\n const sizeChanged = width !== this.width || height !== this.height;\n if (sizeChanged) {\n this.width = width;\n this.height = height;\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n // Reconfigure the canvas size.\n // https://www.w3.org/TR/webgpu/#canvas-configuration\n this.gpuCanvasContext.configure({\n device: this.device.handle,\n format: getWebGPUTextureFormat(this.format),\n // Can be used to define e.g. -srgb views\n // viewFormats: [...]\n colorSpace: this.props.colorSpace,\n alphaMode: this.props.alphaMode\n });\n log.log(1, `Resized to ${this.width}x${this.height}px`)();\n }\n }\n resize(options) {\n this.update();\n if (!this.device.handle)\n return;\n // Resize browser context .\n if (this.canvas) {\n const devicePixelRatio = this.getDevicePixelRatio(options?.useDevicePixels);\n this.setDevicePixelRatio(devicePixelRatio, options);\n return;\n }\n }\n /** Wrap the current canvas context texture in a luma.gl texture */\n getCurrentTexture() {\n return this.device.createTexture({\n id: `${this.id}#color-texture`,\n handle: this.gpuCanvasContext.getCurrentTexture(),\n format: this.format\n });\n }\n /** We build render targets on demand (i.e. not when size changes but when about to render) */\n _createDepthStencilAttachment() {\n if (!this.depthStencilAttachment) {\n this.depthStencilAttachment = this.device.createTexture({\n id: `${this.id}#depth-stencil-texture`,\n format: this.depthStencilFormat,\n width: this.width,\n height: this.height,\n usage: GPUTextureUsage.RENDER_ATTACHMENT\n });\n }\n return this.depthStencilAttachment;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { QuerySet } from '@luma.gl/core';\n/**\n * Immutable\n */\nexport class WebGPUQuerySet extends QuerySet {\n device;\n handle;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.handle =\n this.props.handle ||\n this.device.handle.createQuerySet({\n type: this.props.type,\n count: this.props.count\n });\n this.handle.label = this.props.id;\n }\n destroy() {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,IAAAA,gBAA4C;;;ACA5C,IAAAC,gBAAuC;;;ACAvC,kBAAuB;AACvB,SAAS,cAAc,OAAO;AAJ9B;AAKI,SAAO,MAAM,gBAAc,WAAM,SAAN,mBAAY,eAAc;AACzD;AACO,IAAM,eAAN,cAA2B,mBAAO;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,QAAQ,OAAO;AACvB,UAAM,QAAQ,KAAK;AACnB,SAAK,SAAS;AACd,SAAK,aAAa,cAAc,KAAK;AACrC,UAAM,YAAY,QAAQ,MAAM,IAAI;AAEpC,UAAM,OAAO,KAAK,KAAK,KAAK,aAAa,CAAC,IAAI;AAC9C,SAAK,SACD,KAAK,MAAM,UACP,KAAK,OAAO,OAAO,aAAa;AAAA,MAC5B;AAAA;AAAA,MAEA,OAAO,KAAK,MAAM,SAAS,eAAe,SAAS,eAAe;AA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A,QAC5B;AAAA,MACJ;AAAA,IACJ;AACA,UAAM,YAAY,MAAM,QAAQ,cAAc;AAAA,MAC1C;AAAA,MACA;AAAA,IACJ,CAAC;AACD,sBAAI,MAAM,GAAG,qBAAqB,EAAE;AACpC,QAAI,OAAO,MAAM,WAAW,UAAU;AAClC,YAAM,4BAAc;AACpB,wBAAI,MAAM,GAAG,eAAe,EAAE;AAAA,IAClC;AACA,UAAM,SAAS,IAAI,aAAa,OAAO,WAAW,SAAS,WAAW;AACtE,sBAAI,MAAM,GAAG,qFAAqF,EAAE;AACpG,sBAAI,MAAM,GAAG,OAAO,IAAI,EAAE;AAC1B,sBAAI,SAAS,CAAC,EAAE;AAChB,WAAO;AAAA,EACX;AAAA,EACA,MAAM,OAAO,QAAQ;AACjB,UAAM,IAAI,MAAM,wCAAwC;AAAA,EAC5D;AACJ;AACO,IAAM,gBAAgB,IAAI,cAAc;",
|
|
6
|
-
"names": ["import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "
|
|
4
|
+
"sourcesContent": ["// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { webgpuAdapter } from \"./adapter/webgpu-adapter.js\";\n// WEBGPU CLASSES (typically not accessed directly)\nexport { WebGPUDevice } from \"./adapter/webgpu-device.js\";\nexport { WebGPUBuffer } from \"./adapter/resources/webgpu-buffer.js\";\nexport { WebGPUTexture } from \"./adapter/resources/webgpu-texture.js\";\nexport { WebGPUSampler } from \"./adapter/resources/webgpu-sampler.js\";\nexport { WebGPUShader } from \"./adapter/resources/webgpu-shader.js\";\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Adapter, log } from '@luma.gl/core';\nimport { WebGPUDevice } from \"./webgpu-device.js\";\n// / <reference types=\"@webgpu/types\" />\nexport class WebGPUAdapter extends Adapter {\n /** type of device's created by this adapter */\n type = 'webgpu';\n constructor() {\n super();\n // @ts-ignore For backwards compatibility luma.registerDevices\n WebGPUDevice.adapter = this;\n }\n /** Check if WebGPU is available */\n isSupported() {\n return Boolean(typeof navigator !== 'undefined' && navigator.gpu);\n }\n async create(props) {\n if (!navigator.gpu) {\n throw new Error('WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu');\n }\n log.groupCollapsed(1, 'WebGPUDevice created')();\n const adapter = await navigator.gpu.requestAdapter({\n powerPreference: 'high-performance'\n // forceSoftware: false\n });\n if (!adapter) {\n throw new Error('Failed to request WebGPU adapter');\n }\n const adapterInfo = await adapter.requestAdapterInfo();\n log.probe(2, 'Adapter available', adapterInfo)();\n const requiredFeatures = [];\n const requiredLimits = {};\n if (props._requestMaxLimits) {\n // Require all features\n requiredFeatures.push(...Array.from(adapter.features));\n // Require all limits\n // Filter out chrome specific keys (avoid crash)\n const limits = Object.keys(adapter.limits).filter(key => !['minSubgroupSize', 'maxSubgroupSize'].includes(key));\n for (const key of limits) {\n const limit = key;\n const value = adapter.limits[limit];\n if (typeof value === 'number') {\n requiredLimits[limit] = value;\n }\n }\n }\n const gpuDevice = await adapter.requestDevice({\n requiredFeatures,\n requiredLimits\n });\n log.probe(1, 'GPUDevice available')();\n const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo);\n log.probe(1, 'Device created. For more info, set chrome://flags/#enable-webgpu-developer-features')();\n log.table(1, device.info)();\n log.groupEnd(1)();\n return device;\n }\n async attach(handle) {\n throw new Error('WebGPUAdapter.attach() not implemented');\n }\n}\nexport const webgpuAdapter = new WebGPUAdapter();\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Device, DeviceFeatures } from '@luma.gl/core';\nimport { WebGPUBuffer } from \"./resources/webgpu-buffer.js\";\nimport { WebGPUTexture } from \"./resources/webgpu-texture.js\";\nimport { WebGPUExternalTexture } from \"./resources/webgpu-external-texture.js\";\nimport { WebGPUSampler } from \"./resources/webgpu-sampler.js\";\nimport { WebGPUShader } from \"./resources/webgpu-shader.js\";\nimport { WebGPURenderPipeline } from \"./resources/webgpu-render-pipeline.js\";\nimport { WebGPUFramebuffer } from \"./resources/webgpu-framebuffer.js\";\nimport { WebGPUComputePipeline } from \"./resources/webgpu-compute-pipeline.js\";\nimport { WebGPURenderPass } from \"./resources/webgpu-render-pass.js\";\nimport { WebGPUComputePass } from \"./resources/webgpu-compute-pass.js\";\n// import {WebGPUCommandEncoder} from './resources/webgpu-command-encoder';\nimport { WebGPUVertexArray } from \"./resources/webgpu-vertex-array.js\";\nimport { WebGPUCanvasContext } from \"./webgpu-canvas-context.js\";\nimport { WebGPUQuerySet } from \"./resources/webgpu-query-set.js\";\n/** WebGPU Device implementation */\nexport class WebGPUDevice extends Device {\n /** type of this device */\n type = 'webgpu';\n /** The underlying WebGPU device */\n handle;\n /* The underlying WebGPU adapter */\n adapter;\n /* The underlying WebGPU adapter's info */\n adapterInfo;\n features;\n info;\n limits;\n lost;\n canvasContext = null;\n _isLost = false;\n commandEncoder = null;\n renderPass = null;\n constructor(props, device, adapter, adapterInfo) {\n super({ ...props, id: props.id || 'webgpu-device' });\n this.handle = device;\n this.adapter = adapter;\n this.adapterInfo = adapterInfo;\n this.info = this._getInfo();\n this.features = this._getFeatures();\n this.limits = this.handle.limits;\n // Listen for uncaptured WebGPU errors\n device.addEventListener('uncapturederror', (event) => {\n // TODO is this the right way to make sure the error is an Error instance?\n const errorMessage = event instanceof GPUUncapturedErrorEvent ? event.error.message : 'Unknown error';\n this.error(new Error(errorMessage));\n });\n // \"Context\" loss handling\n this.lost = new Promise(async (resolve) => {\n const lostInfo = await this.handle.lost;\n this._isLost = true;\n resolve({ reason: 'destroyed', message: lostInfo.message });\n });\n // Note: WebGPU devices can be created without a canvas, for compute shader purposes\n if (props.createCanvasContext) {\n const canvasContextProps = props.createCanvasContext === true ? {} : props.createCanvasContext;\n this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);\n }\n }\n // TODO\n // Load the glslang module now so that it is available synchronously when compiling shaders\n // const {glsl = true} = props;\n // this.glslang = glsl && await loadGlslangModule();\n destroy() {\n this.handle.destroy();\n }\n isTextureFormatSupported(format) {\n return !format.includes('webgl');\n }\n /** @todo implement proper check? */\n isTextureFormatFilterable(format) {\n return (this.isTextureFormatSupported(format) &&\n !format.startsWith('depth') &&\n !format.startsWith('stencil'));\n }\n /** @todo implement proper check? */\n isTextureFormatRenderable(format) {\n return this.isTextureFormatSupported(format);\n }\n get isLost() {\n return this._isLost;\n }\n createBuffer(props) {\n const newProps = this._normalizeBufferProps(props);\n return new WebGPUBuffer(this, newProps);\n }\n createTexture(props) {\n return new WebGPUTexture(this, props);\n }\n createExternalTexture(props) {\n return new WebGPUExternalTexture(this, props);\n }\n createShader(props) {\n return new WebGPUShader(this, props);\n }\n createSampler(props) {\n return new WebGPUSampler(this, props);\n }\n createRenderPipeline(props) {\n return new WebGPURenderPipeline(this, props);\n }\n createFramebuffer(props) {\n return new WebGPUFramebuffer(this, props);\n }\n createComputePipeline(props) {\n return new WebGPUComputePipeline(this, props);\n }\n createVertexArray(props) {\n return new WebGPUVertexArray(this, props);\n }\n // WebGPU specifics\n /**\n * Allows a render pass to begin against a canvas context\n * @todo need to support a \"Framebuffer\" equivalent (aka preconfigured RenderPassDescriptors?).\n */\n beginRenderPass(props) {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPURenderPass(this, props);\n }\n beginComputePass(props) {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPUComputePass(this, props);\n }\n // createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {\n // return new WebGPUCommandEncoder(this, props);\n // }\n createTransformFeedback(props) {\n throw new Error('Transform feedback not supported in WebGPU');\n }\n createQuerySet(props) {\n return new WebGPUQuerySet(this, props);\n }\n createCanvasContext(props) {\n return new WebGPUCanvasContext(this, this.adapter, props);\n }\n submit() {\n // this.renderPass?.end();\n const commandBuffer = this.commandEncoder?.finish();\n if (commandBuffer) {\n this.handle.queue.submit([commandBuffer]);\n }\n this.commandEncoder = null;\n // this.renderPass = null;\n }\n // PRIVATE METHODS\n _getInfo() {\n const [driver, driverVersion] = (this.adapterInfo.driver || '').split(' Version ');\n // See https://developer.chrome.com/blog/new-in-webgpu-120#adapter_information_updates\n const vendor = this.adapterInfo.vendor || this.adapter.__brand || 'unknown';\n const renderer = driver || '';\n const version = driverVersion || '';\n const gpu = vendor === 'apple' ? 'apple' : 'unknown'; // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',\n const gpuArchitecture = this.adapterInfo.architecture || 'unknown';\n const gpuBackend = this.adapterInfo.backend || 'unknown';\n const gpuType = (this.adapterInfo.type || '').split(' ')[0].toLowerCase() || 'unknown';\n return {\n type: 'webgpu',\n vendor,\n renderer,\n version,\n gpu,\n gpuType,\n gpuBackend,\n gpuArchitecture,\n shadingLanguage: 'wgsl',\n shadingLanguageVersion: 100\n };\n }\n _getFeatures() {\n // Initialize with actual WebGPU Features (note that unknown features may not be in DeviceFeature type)\n const features = new Set(this.handle.features);\n // Fixups for pre-standard names: https://github.com/webgpu-native/webgpu-headers/issues/133\n // @ts-expect-error Chrome Canary v99\n if (features.has('depth-clamping')) {\n // @ts-expect-error Chrome Canary v99\n features.delete('depth-clamping');\n features.add('depth-clip-control');\n }\n // Some subsets of WebGPU extensions correspond to WebGL extensions\n if (features.has('texture-compression-bc')) {\n features.add('texture-compression-bc5-webgl');\n }\n const WEBGPU_ALWAYS_FEATURES = [\n 'timer-query-webgl',\n 'compilation-status-async-webgl',\n 'float32-renderable-webgl',\n 'float16-renderable-webgl',\n 'norm16-renderable-webgl',\n 'texture-filterable-anisotropic-webgl',\n 'shader-noperspective-interpolation-webgl'\n ];\n for (const feature of WEBGPU_ALWAYS_FEATURES) {\n features.add(feature);\n }\n return new DeviceFeatures(Array.from(features), this.props._disabledFeatures);\n }\n copyExternalImageToTexture(options) {\n const { source, sourceX = 0, sourceY = 0, texture, mipLevel = 0, aspect = 'all', colorSpace = 'display-p3', premultipliedAlpha = false, \n // destinationX,\n // destinationY,\n // desitnationZ,\n width = texture.width, height = texture.height, depth = 1 } = options;\n const webGpuTexture = texture;\n this.handle?.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n }, \n // destination: GPUImageCopyTextureTagged\n {\n texture: webGpuTexture.handle,\n origin: [0, 0, 0], // [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n }, \n // copySize: GPUExtent3D\n [width, height, depth]);\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Buffer } from '@luma.gl/core';\nfunction getByteLength(props) {\n return props.byteLength || props.data?.byteLength || 0;\n}\nexport class WebGPUBuffer extends Buffer {\n device;\n handle;\n byteLength;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.byteLength = getByteLength(props);\n const mapBuffer = Boolean(props.data);\n // WebGPU buffers must be aligned to 4 bytes\n const size = Math.ceil(this.byteLength / 4) * 4;\n this.handle =\n this.props.handle ||\n this.device.handle.createBuffer({\n size,\n // usage defaults to vertex\n usage: this.props.usage || GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,\n mappedAtCreation: this.props.mappedAtCreation || mapBuffer,\n label: this.props.id\n });\n if (props.data) {\n this._writeMapped(props.data);\n // this.handle.writeAsync({data: props.data, map: false, unmap: false});\n }\n if (mapBuffer && !props.mappedAtCreation) {\n this.handle.unmap();\n }\n }\n destroy() {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n // WebGPU provides multiple ways to write a buffer...\n write(data, byteOffset = 0) {\n this.device.handle.queue.writeBuffer(this.handle, byteOffset, data.buffer, data.byteOffset, data.byteLength);\n }\n async readAsync(byteOffset = 0, byteLength = this.byteLength) {\n // We need MAP_READ flag, but only COPY_DST buffers can have MAP_READ flag, so we need to create a temp buffer\n const tempBuffer = new WebGPUBuffer(this.device, {\n usage: Buffer.MAP_READ | Buffer.COPY_DST,\n byteLength\n });\n // Now do a GPU-side copy into the temp buffer we can actually read.\n // TODO - we are spinning up an independent command queue here, what does this mean\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);\n this.device.handle.queue.submit([commandEncoder.finish()]);\n // Map the temp buffer and read the data.\n await tempBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);\n const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);\n tempBuffer.handle.unmap();\n tempBuffer.destroy();\n return new Uint8Array(arrayBuffer);\n }\n _writeMapped(typedArray) {\n const arrayBuffer = this.handle.getMappedRange();\n // @ts-expect-error\n new typedArray.constructor(arrayBuffer).set(typedArray);\n }\n // WEBGPU API\n mapAsync(mode, offset = 0, size) {\n return this.handle.mapAsync(mode, offset, size);\n }\n getMappedRange(offset = 0, size) {\n return this.handle.getMappedRange(offset, size);\n }\n unmap() {\n this.handle.unmap();\n }\n}\n/*\n// Convenience API\n /** Read data from the buffer *\n async readAsync(options: {\n byteOffset?: number,\n byteLength?: number,\n map?: boolean,\n unmap?: boolean\n }): Promise<ArrayBuffer> {\n if (options.map ?? true) {\n await this.mapAsync(Buffer.MAP_READ, options.byteOffset, options.byteLength);\n }\n const arrayBuffer = this.getMappedRange(options.byteOffset, options.byteLength);\n if (options.unmap ?? true) {\n this.unmap();\n }\n return arrayBuffer;\n }\n\n /** Write data to the buffer *\n async writeAsync(options: {\n data: ArrayBuffer,\n byteOffset?: number,\n byteLength?: number,\n map?: boolean,\n unmap?: boolean\n }): Promise<void> {\n if (options.map ?? true) {\n await this.mapAsync(Buffer.MAP_WRITE, options.byteOffset, options.byteLength);\n }\n const arrayBuffer = this.getMappedRange(options.byteOffset, options.byteLength);\n const destArray = new Uint8Array(arrayBuffer);\n const srcArray = new Uint8Array(options.data);\n destArray.set(srcArray);\n if (options.unmap ?? true) {\n this.unmap();\n }\n }\n */\n// Mapped API (WebGPU)\n/** Maps the memory so that it can be read *\n // abstract mapAsync(mode, byteOffset, byteLength): Promise<void>\n\n /** Get the mapped range of data for reading or writing *\n // abstract getMappedRange(byteOffset, byteLength): ArrayBuffer;\n\n /** unmap makes the contents of the buffer available to the GPU again *\n // abstract unmap(): void;\n*/\n", "import { Texture } from '@luma.gl/core';\nimport { getWebGPUTextureFormat } from \"../helpers/convert-texture-format.js\";\nimport { WebGPUSampler } from \"./webgpu-sampler.js\";\nimport { WebGPUTextureView } from \"./webgpu-texture-view.js\";\nconst BASE_DIMENSIONS = {\n '1d': '1d',\n '2d': '2d',\n '2d-array': '2d',\n cube: '2d',\n 'cube-array': '2d',\n '3d': '3d'\n};\nexport class WebGPUTexture extends Texture {\n device;\n handle;\n height = 1;\n width = 1;\n sampler;\n view;\n // static async createFromImageURL(src, usage = 0) {\n // const img = document.createElement('img');\n // img.src = src;\n // await img.decode();\n // return WebGPUTexture(img, usage);\n // }\n constructor(device, props) {\n props = Texture._fixProps(props);\n super(device, props);\n this.device = device;\n this.initialize(props);\n }\n destroy() {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n createView(props) {\n return new WebGPUTextureView(this.device, { ...props, texture: this });\n }\n initialize(props) {\n // @ts-expect-error\n this.handle = this.props.handle || this.createHandle();\n this.handle.label ||= this.id;\n if (this.props.data) {\n if (Texture.isExternalImage(this.props.data)) {\n this.copyExternalImage({ image: this.props.data });\n }\n else {\n this.setData({ data: this.props.data });\n }\n }\n this.width = this.handle.width;\n this.height = this.handle.height;\n // Why not just read all properties directly from the texture\n // this.depthOrArrayLayers = this.handle.depthOrArrayLayers;\n // this.mipLevelCount = this.handle.mipLevelCount;\n // this.sampleCount = this.handle.sampleCount;\n // this.dimension = this.handle.dimension;\n // this.format = this.handle.format;\n // this.usage = this.handle.usage;\n // Create a default sampler. This mimics the WebGL1 API where sampler props are stored on the texture\n // this.setSampler(props.sampler);\n this.sampler =\n props.sampler instanceof WebGPUSampler\n ? props.sampler\n : new WebGPUSampler(this.device, props.sampler || {});\n // TODO - To support texture arrays we need to create custom views...\n // But we are not ready to expose TextureViews to the public API.\n // @ts-expect-error\n this.view = new WebGPUTextureView(this.device, { ...this.props, texture: this });\n // format: this.props.format,\n // dimension: this.props.dimension,\n // aspect = \"all\";\n // baseMipLevel: 0;\n // mipLevelCount;\n // baseArrayLayer = 0;\n // arrayLayerCount;\n }\n createHandle() {\n // Deduce size from data - TODO this is a hack\n // @ts-expect-error\n const width = this.props.width || this.props.data?.width || 1;\n // @ts-expect-error\n const height = this.props.height || this.props.data?.height || 1;\n return this.device.handle.createTexture({\n label: this.id,\n size: {\n width,\n height,\n depthOrArrayLayers: this.depth\n },\n usage: this.props.usage || Texture.TEXTURE | Texture.COPY_DST,\n dimension: BASE_DIMENSIONS[this.dimension],\n format: getWebGPUTextureFormat(this.format),\n mipLevelCount: this.mipLevels,\n sampleCount: this.props.samples\n });\n }\n /** @deprecated - intention is to use the createView public API */\n createGPUTextureView() {\n return this.handle.createView({ label: this.id });\n }\n /**\n * Set default sampler\n * Accept a sampler instance or set of props;\n */\n setSampler(sampler) {\n this.sampler =\n sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n setTexture1DData(data) {\n throw new Error('not implemented');\n }\n setTexture2DData(lodData, depth, target) {\n throw new Error('not implemented');\n }\n setTexture3DData(lodData, depth, target) {\n throw new Error('not implemented');\n }\n setTextureCubeData(data, depth) {\n throw new Error('not implemented');\n }\n setTextureArrayData(data) {\n throw new Error('not implemented');\n }\n setTextureCubeArrayData(data) {\n throw new Error('not implemented');\n }\n setData(options) {\n if (ArrayBuffer.isView(options.data)) {\n const clampedArray = new Uint8ClampedArray(options.data.buffer);\n // TODO - pass through src data color space as ImageData Options?\n const image = new ImageData(clampedArray, this.width, this.height);\n return this.copyExternalImage({ image });\n }\n throw new Error('Texture.setData: Use CommandEncoder to upload data to texture in WebGPU');\n }\n copyExternalImage(options) {\n const size = Texture.getExternalImageSize(options.image);\n const opts = { ...Texture.defaultCopyExternalImageOptions, ...size, ...options };\n const { image, sourceX, sourceY, width, height, depth, mipLevel, x, y, z, aspect, colorSpace, premultipliedAlpha } = opts;\n // TODO - max out width\n this.device.handle.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source: image,\n origin: [sourceX, sourceY]\n }, \n // destination: GPUImageCopyTextureTagged\n {\n texture: this.handle,\n origin: [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n }, \n // copySize: GPUExtent3D\n [width, height, depth]);\n return { width, height };\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/** Ensure a texture format is WebGPU compatible */\nexport function getWebGPUTextureFormat(format) {\n if (format.includes('webgl')) {\n throw new Error('webgl-only format');\n }\n return format;\n}\n", "// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\nimport { Sampler } from '@luma.gl/core';\n/**\n *\n */\nexport class WebGPUSampler extends Sampler {\n device;\n handle;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n // Prepare sampler props\n const samplerProps = { ...this.props };\n if (samplerProps.type !== 'comparison-sampler') {\n delete samplerProps.compare;\n }\n this.handle = this.handle || this.device.handle.createSampler(samplerProps);\n this.handle.label = this.props.id;\n }\n destroy() {\n // GPUSampler does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { TextureView } from '@luma.gl/core';\n/**\n *\n */\nexport class WebGPUTextureView extends TextureView {\n device;\n handle;\n texture;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.texture = props.texture;\n this.handle =\n this.handle ||\n this.texture.handle.createView({\n format: (props.format || this.texture.format),\n dimension: props.dimension || this.texture.dimension,\n aspect: props.aspect,\n baseMipLevel: props.baseMipLevel,\n mipLevelCount: props.mipLevelCount, // GPUIntegerCoordinate;\n baseArrayLayer: props.baseArrayLayer, // GPUIntegerCoordinate;\n arrayLayerCount: props.arrayLayerCount // GPUIntegerCoordinate;\n });\n this.handle.label = this.props.id;\n }\n destroy() {\n // GPUTextureView does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ExternalTexture } from '@luma.gl/core';\nimport { WebGPUSampler } from \"./webgpu-sampler.js\";\n/**\n * Cheap, temporary texture view for videos\n * Only valid within same callback, destroyed automatically as a microtask.\n */\nexport class WebGPUExternalTexture extends ExternalTexture {\n device;\n handle;\n sampler;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.handle =\n this.props.handle ||\n this.device.handle.importExternalTexture({\n source: props.source,\n colorSpace: props.colorSpace\n });\n // @ts-expect-error\n this.sampler = null;\n }\n destroy() {\n // External textures are destroyed automatically,\n // as a microtask, instead of manually or upon garbage collection like other resources.\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n /** Set default sampler */\n setSampler(sampler) {\n // We can accept a sampler instance or set of props;\n this.sampler =\n sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Shader, log } from '@luma.gl/core';\n/**\n * Immutable shader\n */\nexport class WebGPUShader extends Shader {\n device;\n handle;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.device.handle.pushErrorScope('validation');\n this.handle = this.props.handle || this.createHandle();\n this.handle.label = this.props.id;\n this._checkCompilationError(this.device.handle.popErrorScope());\n }\n get asyncCompilationStatus() {\n return this.getCompilationInfo().then(() => this.compilationStatus);\n }\n async _checkCompilationError(errorScope) {\n const error = (await errorScope);\n if (error) {\n // The `Shader` base class will determine if debug window should be opened based on props\n this.debugShader();\n const shaderLog = await this.getCompilationInfo();\n log.error(`Shader compilation error: ${error.message}`, shaderLog)();\n // Note: Even though this error is asynchronous and thrown after the constructor completes,\n // it will result in a useful stack trace leading back to the constructor\n throw new Error(`Shader compilation error: ${error.message}`);\n }\n }\n destroy() {\n // Note: WebGPU does not offer a method to destroy shaders\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n /** Returns compilation info for this shader */\n async getCompilationInfo() {\n const compilationInfo = await this.handle.getCompilationInfo();\n return compilationInfo.messages;\n }\n // PRIVATE METHODS\n createHandle() {\n const { source } = this.props;\n const isGLSL = source.includes('#version');\n if (this.props.language === 'glsl' || isGLSL) {\n throw new Error('GLSL shaders are not supported in WebGPU');\n }\n return this.device.handle.createShaderModule({ code: source });\n }\n}\n", "// luma.gl MIT license\nimport { RenderPipeline, log } from '@luma.gl/core';\nimport { applyParametersToRenderPipelineDescriptor } from \"../helpers/webgpu-parameters.js\";\nimport { getWebGPUTextureFormat } from \"../helpers/convert-texture-format.js\";\nimport { getBindGroup } from \"../helpers/get-bind-group.js\";\nimport { getVertexBufferLayout } from \"../helpers/get-vertex-buffer-layout.js\";\n// RENDER PIPELINE\n/** Creates a new render pipeline when parameters change */\nexport class WebGPURenderPipeline extends RenderPipeline {\n device;\n handle;\n vs;\n fs = null;\n /** For internal use to create BindGroups */\n _bindings;\n _bindGroupLayout = null;\n _bindGroup = null;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle;\n if (!this.handle) {\n const descriptor = this._getRenderPipelineDescriptor();\n log.groupCollapsed(1, `new WebGPURenderPipeline(${this.id})`)();\n log.probe(1, JSON.stringify(descriptor, null, 2))();\n log.groupEnd(1)();\n this.handle = this.device.handle.createRenderPipeline(descriptor);\n }\n this.handle.label = this.props.id;\n this.vs = props.vs;\n this.fs = props.fs;\n this._bindings = { ...this.props.bindings };\n }\n destroy() {\n // WebGPURenderPipeline has no destroy method.\n // @ts-expect-error\n this.handle = null;\n }\n /**\n * @todo Use renderpass.setBindings() ?\n * @todo Do we want to expose BindGroups in the API and remove this?\n */\n setBindings(bindings) {\n Object.assign(this._bindings, bindings);\n }\n /** @todo - should this be moved to renderpass? */\n draw(options) {\n const webgpuRenderPass = options.renderPass;\n // Set pipeline\n webgpuRenderPass.handle.setPipeline(this.handle);\n // Set bindings (uniform buffers, textures etc)\n const bindGroup = this._getBindGroup();\n if (bindGroup) {\n webgpuRenderPass.handle.setBindGroup(0, bindGroup);\n }\n // Set attributes\n // Note: Rebinds constant attributes before each draw call\n options.vertexArray.bindBeforeRender(options.renderPass);\n // Draw\n if (options.indexCount) {\n webgpuRenderPass.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);\n }\n else {\n webgpuRenderPass.handle.draw(options.vertexCount || 0, options.instanceCount || 1, // If 0, nothing will be drawn\n options.firstInstance);\n }\n // Note: Rebinds constant attributes before each draw call\n options.vertexArray.unbindAfterRender(options.renderPass);\n return true;\n }\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n if (this.shaderLayout.bindings.length === 0) {\n return null;\n }\n // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group\n this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);\n // Set up the bindings\n // TODO what if bindings change? We need to rebuild the bind group!\n this._bindGroup =\n this._bindGroup ||\n getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);\n return this._bindGroup;\n }\n /**\n * Populate the complex WebGPU GPURenderPipelineDescriptor\n */\n _getRenderPipelineDescriptor() {\n // Set up the vertex stage\n const vertex = {\n module: this.props.vs.handle,\n entryPoint: this.props.vertexEntryPoint || 'main',\n buffers: getVertexBufferLayout(this.shaderLayout, this.props.bufferLayout)\n };\n // Set up the fragment stage\n const fragment = {\n module: this.props.fs.handle,\n entryPoint: this.props.fragmentEntryPoint || 'main',\n targets: [\n {\n // TODO exclamation mark hack!\n format: getWebGPUTextureFormat(this.device.getCanvasContext().format)\n }\n ]\n };\n // Create a partially populated descriptor\n const descriptor = {\n vertex,\n fragment,\n primitive: {\n topology: this.props.topology\n },\n layout: 'auto'\n };\n // Set parameters on the descriptor\n applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);\n return descriptor;\n }\n}\n/**\n_setAttributeBuffers(webgpuRenderPass: WebGPURenderPass) {\n if (this._indexBuffer) {\n webgpuRenderPass.handle.setIndexBuffer(this._indexBuffer.handle, this._indexBuffer.props.indexType);\n }\n\n const buffers = this._getBuffers();\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = cast<WebGPUBuffer>(buffers[i]);\n if (!buffer) {\n const attribute = this.shaderLayout.attributes.find(\n (attribute) => attribute.location === i\n );\n throw new Error(\n `No buffer provided for attribute '${attribute?.name || ''}' in Model '${this.props.id}'`\n );\n }\n webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);\n }\n\n // TODO - HANDLE buffer maps\n /*\n for (const [bufferName, attributeMapping] of Object.entries(this.props.bufferLayout)) {\n const buffer = cast<WebGPUBuffer>(this.props.attributes[bufferName]);\n if (!buffer) {\n log.warn(`Missing buffer for buffer map ${bufferName}`)();\n continue;\n }\n\n if ('location' in attributeMapping) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(layout.location, buffer.handle);\n } else {\n for (const [bufferName, mapping] of Object.entries(attributeMapping)) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(field.location, buffer.handle);\n }\n }\n }\n *\n}\n*/\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nfunction addDepthStencil(descriptor) {\n descriptor.depthStencil = descriptor.depthStencil || {\n // required, set something\n format: 'depth24plus',\n stencilFront: {},\n stencilBack: {},\n // TODO can this cause trouble? Should we set to WebGPU defaults? Are there defaults?\n depthWriteEnabled: false,\n depthCompare: 'less-equal'\n };\n return descriptor.depthStencil;\n}\nfunction addDepthStencilFront(descriptor) {\n const depthStencil = addDepthStencil(descriptor);\n // @ts-ignore\n return depthStencil.stencilFront;\n}\nfunction addDepthStencilBack(descriptor) {\n const depthStencil = addDepthStencil(descriptor);\n // @ts-ignore\n return depthStencil.stencilBack;\n}\n/**\n * Supports for luma.gl's flat parameter space\n * Populates the corresponding sub-objects in a GPURenderPipelineDescriptor\n */\n// @ts-expect-error\nexport const PARAMETER_TABLE = {\n // RASTERIZATION PARAMETERS\n cullMode: (parameter, value, descriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.cullMode = value;\n },\n frontFace: (parameter, value, descriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.frontFace = value;\n },\n // DEPTH\n depthWriteEnabled: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthWriteEnabled = value;\n },\n depthCompare: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthCompare = value;\n },\n depthFormat: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.format = value;\n },\n depthBias: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBias = value;\n },\n depthBiasSlopeScale: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasSlopeScale = value;\n },\n depthBiasClamp: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasClamp = value;\n },\n // STENCIL\n stencilReadMask: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilReadMask = value;\n },\n stencilWriteMask: (parameter, value, descriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilWriteMask = value;\n },\n stencilCompare: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.compare = value;\n stencilBack.compare = value;\n },\n stencilPassOperation: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.passOp = value;\n stencilBack.passOp = value;\n },\n stencilFailOperation: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.failOp = value;\n stencilBack.failOp = value;\n },\n stencilDepthFailOperation: (parameter, value, descriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.depthFailOp = value;\n stencilBack.depthFailOp = value;\n },\n // MULTISAMPLE\n sampleCount: (parameter, value, descriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.count = value;\n },\n sampleMask: (parameter, value, descriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.mask = value;\n },\n sampleAlphaToCoverageEnabled: (parameter, value, descriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.alphaToCoverageEnabled = value;\n },\n // COLOR\n colorMask: (parameter, value, descriptor) => {\n const targets = addColorState(descriptor);\n targets[0].writeMask = value;\n },\n blendColorOperation: (parameter, value, descriptor) => {\n addColorState(descriptor);\n // const targets = addColorState(descriptor);\n // const target = targets[0];\n // const blend: GPUBlendState = target.blend || {color: {alpha: 0}};\n // blend.color = blend.color || {};\n // target.blend.color.operation = value;\n }\n /*\n blendColorSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.srcTarget = value;\n },\n \n blendColorDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.dstTarget = value;\n },\n \n blendAlphaOperation: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.operation = value;\n },\n \n blendAlphaSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.srcTarget = value;\n },\n \n blendAlphaDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.dstTarget = value;\n },\n */\n};\nconst DEFAULT_PIPELINE_DESCRIPTOR = {\n // depthStencil: {\n // stencilFront: {},\n // stencilBack: {},\n // // depthWriteEnabled: true,\n // // depthCompare: 'less',\n // // format: 'depth24plus-stencil8',\n // },\n primitive: {\n cullMode: 'back',\n topology: 'triangle-list'\n },\n vertex: {\n module: undefined,\n entryPoint: 'main'\n },\n fragment: {\n module: undefined,\n entryPoint: 'main',\n targets: [\n // { format: props.color0Format || 'bgra8unorm' }\n ]\n },\n layout: 'auto'\n};\nexport function applyParametersToRenderPipelineDescriptor(pipelineDescriptor, parameters = {}) {\n // Apply defaults\n Object.assign(pipelineDescriptor, { ...DEFAULT_PIPELINE_DESCRIPTOR, ...pipelineDescriptor });\n setParameters(pipelineDescriptor, parameters);\n}\n// Apply any supplied parameters\nfunction setParameters(pipelineDescriptor, parameters) {\n for (const [key, value] of Object.entries(parameters)) {\n const setterFunction = PARAMETER_TABLE[key];\n if (!setterFunction) {\n throw new Error(`Illegal parameter ${key}`);\n }\n setterFunction(key, value, pipelineDescriptor);\n }\n}\nfunction addColorState(descriptor) {\n // @ts-ignore\n descriptor.fragment.targets = descriptor.fragment?.targets || [];\n if (!Array.isArray(descriptor.fragment?.targets)) {\n throw new Error('colorstate');\n }\n if (descriptor.fragment?.targets?.length === 0) {\n descriptor.fragment.targets?.push({});\n }\n return descriptor.fragment?.targets;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Buffer, Sampler, Texture, log } from '@luma.gl/core';\n/**\n * Create a WebGPU \"bind group layout\" from an array of luma.gl bindings\n * @note bind groups can be automatically generated by WebGPU.\n */\nexport function makeBindGroupLayout(device, layout, bindings) {\n throw new Error('not implemented');\n // return device.createBindGroupLayout({\n // layout,\n // entries: getBindGroupEntries(bindings)\n // })\n}\n/**\n * Create a WebGPU \"bind group\" from an array of luma.gl bindings\n */\nexport function getBindGroup(device, bindGroupLayout, shaderLayout, bindings) {\n const entries = getBindGroupEntries(bindings, shaderLayout);\n return device.createBindGroup({\n layout: bindGroupLayout,\n entries\n });\n}\nexport function getShaderLayoutBinding(shaderLayout, bindingName) {\n const bindingLayout = shaderLayout.bindings.find(binding => binding.name === bindingName || `${binding.name}uniforms` === bindingName.toLocaleLowerCase());\n if (!bindingLayout) {\n log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();\n }\n return bindingLayout || null;\n}\n/**\n * @param bindings\n * @returns\n */\nfunction getBindGroupEntries(bindings, shaderLayout) {\n const entries = [];\n for (const [bindingName, value] of Object.entries(bindings)) {\n const bindingLayout = getShaderLayoutBinding(shaderLayout, bindingName);\n if (bindingLayout) {\n entries.push(getBindGroupEntry(value, bindingLayout.location));\n }\n }\n return entries;\n}\nfunction getBindGroupEntry(binding, index) {\n if (binding instanceof Buffer) {\n return {\n binding: index,\n resource: {\n buffer: binding.handle\n }\n };\n }\n if (binding instanceof Sampler) {\n return {\n binding: index,\n resource: binding.handle\n };\n }\n else if (binding instanceof Texture) {\n return {\n binding: index,\n resource: binding.handle.createView({ label: 'bind-group-auto-created' })\n };\n }\n throw new Error('invalid binding');\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { log, decodeVertexFormat } from '@luma.gl/core';\n// import {getAttributeInfosFromLayouts} from '@luma.gl/core';\n/** Throw error on any WebGL-only vertex formats */\nfunction getWebGPUVertexFormat(format) {\n if (format.endsWith('-webgl')) {\n throw new Error(`WebGPU does not support vertex format ${format}`);\n }\n return format;\n}\n/**\n * Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.\n * Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array\n * @param layout\n * @param bufferLayout The buffer map is optional\n * @returns WebGPU layout intended for a GPURenderPassDescriptor.\n */\nexport function getVertexBufferLayout(shaderLayout, bufferLayout) {\n const vertexBufferLayouts = [];\n const usedAttributes = new Set();\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // Build vertex attributes for one buffer\n const vertexAttributes = [];\n // TODO verify that all stepModes for one buffer are the same\n let stepMode = 'vertex';\n let byteStride = 0;\n // @ts-ignore\n const format = mapping.format;\n // interleaved mapping {..., attributes: [{...}, ...]}\n if (mapping.attributes) {\n // const arrayStride = mapping.byteStride; TODO\n for (const attributeMapping of mapping.attributes) {\n const attributeName = attributeMapping.attribute;\n const attributeLayout = findAttributeLayout(shaderLayout, attributeName, usedAttributes);\n // @ts-ignore\n const location = attributeLayout?.location;\n stepMode =\n attributeLayout?.stepMode ||\n (attributeLayout?.name.startsWith('instance') ? 'instance' : 'vertex');\n vertexAttributes.push({\n format: getWebGPUVertexFormat(attributeMapping.format || mapping.format),\n offset: attributeMapping.byteOffset,\n shaderLocation: location\n });\n byteStride += decodeVertexFormat(format).byteLength;\n }\n // non-interleaved mapping (just set offset and stride)\n }\n else {\n const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);\n if (!attributeLayout) {\n continue; // eslint-disable-line no-continue\n }\n byteStride = decodeVertexFormat(format).byteLength;\n stepMode =\n attributeLayout.stepMode ||\n (attributeLayout.name.startsWith('instance') ? 'instance' : 'vertex');\n vertexAttributes.push({\n format: getWebGPUVertexFormat(format),\n // We only support 0 offset for non-interleaved buffer layouts\n offset: 0,\n shaderLocation: attributeLayout.location\n });\n }\n // Store all the attribute bindings for one buffer\n vertexBufferLayouts.push({\n arrayStride: mapping.byteStride || byteStride,\n stepMode,\n attributes: vertexAttributes\n });\n }\n // Add any non-mapped attributes - TODO - avoid hardcoded types\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n vertexBufferLayouts.push({\n arrayStride: decodeVertexFormat('float32x3').byteLength,\n stepMode: attribute.stepMode || (attribute.name.startsWith('instance') ? 'instance' : 'vertex'),\n attributes: [\n {\n format: getWebGPUVertexFormat('float32x3'),\n offset: 0,\n shaderLocation: attribute.location\n }\n ]\n });\n }\n }\n return vertexBufferLayouts;\n}\nexport function getBufferSlots(shaderLayout, bufferLayout) {\n const usedAttributes = new Set();\n let bufferSlot = 0;\n const bufferSlots = {};\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n for (const interleaved of mapping.attributes || []) {\n usedAttributes.add(interleaved.attribute);\n }\n // non-interleaved mapping (just set offset and stride)\n }\n else {\n usedAttributes.add(mapping.name);\n }\n bufferSlots[mapping.name] = bufferSlot++;\n }\n // Add any non-mapped attributes\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n bufferSlots[attribute.name] = bufferSlot++;\n }\n }\n return bufferSlots;\n}\n/**\n * Looks up an attribute in the ShaderLayout.\n * @throws if name is not in ShaderLayout\n * @throws if name has already been referenced\n */\nfunction findAttributeLayout(shaderLayout, name, attributeNames) {\n const attribute = shaderLayout.attributes.find(attribute_ => attribute_.name === name);\n if (!attribute) {\n log.warn(`Unknown attribute ${name}`)();\n return null;\n }\n if (attributeNames.has(name)) {\n throw new Error(`Duplicate attribute ${name}`);\n }\n attributeNames.add(name);\n return attribute;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Framebuffer } from '@luma.gl/core';\n/**\n * Create new textures with correct size for all attachments.\n * @note resize() destroys existing textures (if size has changed).\n */\nexport class WebGPUFramebuffer extends Framebuffer {\n device;\n colorAttachments = [];\n depthStencilAttachment = null;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n }\n updateAttachments() {\n // WebGPU framebuffers are JS only objects, nothing to update\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ComputePipeline } from '@luma.gl/core';\nimport { getBindGroup } from \"../helpers/get-bind-group.js\";\n// COMPUTE PIPELINE\n/** Creates a new compute pipeline when parameters change */\nexport class WebGPUComputePipeline extends ComputePipeline {\n device;\n handle;\n /** For internal use to create BindGroups */\n _bindGroupLayout = null;\n _bindGroup = null;\n /** For internal use to create BindGroups */\n _bindings = {};\n constructor(device, props) {\n super(device, props);\n this.device = device;\n const webgpuShader = this.props.shader;\n this.handle =\n this.props.handle ||\n this.device.handle.createComputePipeline({\n label: this.props.id,\n compute: {\n module: webgpuShader.handle,\n entryPoint: this.props.entryPoint,\n constants: this.props.constants\n },\n layout: 'auto'\n });\n }\n /**\n * @todo Use renderpass.setBindings() ?\n * @todo Do we want to expose BindGroups in the API and remove this?\n */\n setBindings(bindings) {\n Object.assign(this._bindings, bindings);\n }\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group\n this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);\n // Set up the bindings\n this._bindGroup =\n this._bindGroup ||\n getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);\n return this._bindGroup;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { RenderPass, log } from '@luma.gl/core';\nexport class WebGPURenderPass extends RenderPass {\n device;\n handle;\n /** Active pipeline */\n pipeline = null;\n constructor(device, props = {}) {\n super(device, props);\n this.device = device;\n const framebuffer = props.framebuffer || device.getCanvasContext().getCurrentFramebuffer();\n const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);\n const webgpuQuerySet = props.timestampQuerySet;\n if (webgpuQuerySet) {\n renderPassDescriptor.occlusionQuerySet = webgpuQuerySet.handle;\n }\n if (device.features.has('timestamp-query')) {\n const webgpuTSQuerySet = props.timestampQuerySet;\n renderPassDescriptor.timestampWrites = webgpuTSQuerySet\n ? {\n querySet: webgpuTSQuerySet.handle,\n beginningOfPassWriteIndex: props.beginTimestampIndex,\n endOfPassWriteIndex: props.endTimestampIndex\n }\n : undefined;\n }\n if (!device.commandEncoder) {\n throw new Error('commandEncoder not available');\n }\n this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);\n this.handle.label = this.props.id;\n log.groupCollapsed(3, `new WebGPURenderPass(${this.id})`)();\n log.probe(3, JSON.stringify(renderPassDescriptor, null, 2))();\n log.groupEnd(3)();\n }\n destroy() { }\n end() {\n this.handle.end();\n }\n setPipeline(pipeline) {\n this.pipeline = pipeline;\n this.handle.setPipeline(this.pipeline.handle);\n }\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings) {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n setIndexBuffer(buffer, indexFormat, offset = 0, size) {\n this.handle.setIndexBuffer(buffer.handle, indexFormat, offset, size);\n }\n setVertexBuffer(slot, buffer, offset = 0) {\n this.handle.setVertexBuffer(slot, buffer.handle, offset);\n }\n draw(options) {\n if (options.indexCount) {\n this.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);\n }\n else {\n this.handle.draw(options.vertexCount || 0, options.instanceCount || 1, options.firstIndex, options.firstInstance);\n }\n }\n drawIndirect() {\n // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n }\n setParameters(parameters) {\n const { blendConstant, stencilReference, scissorRect, viewport } = parameters;\n if (blendConstant) {\n this.handle.setBlendConstant(blendConstant);\n }\n if (stencilReference) {\n this.handle.setStencilReference(stencilReference);\n }\n if (scissorRect) {\n this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);\n }\n // TODO - explain how 3 dimensions vs 2 in WebGL works.\n if (viewport) {\n this.handle.setViewport(viewport[0], viewport[1], viewport[2], viewport[3], viewport[4], viewport[5]);\n }\n }\n pushDebugGroup(groupLabel) {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup() {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel) {\n this.handle.insertDebugMarker(markerLabel);\n }\n beginOcclusionQuery(queryIndex) {\n this.handle.beginOcclusionQuery(queryIndex);\n }\n endOcclusionQuery() {\n this.handle.endOcclusionQuery();\n }\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n // INTERNAL\n /**\n * Partial render pass descriptor. Used by WebGPURenderPass.\n * @returns attachments fields of a renderpass descriptor.\n */\n getRenderPassDescriptor(framebuffer) {\n const renderPassDescriptor = {\n colorAttachments: []\n };\n renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({\n // clear values\n loadOp: this.props.clearColor !== false ? 'clear' : 'load',\n colorClearValue: this.props.clearColor || [0, 0, 0, 0],\n storeOp: this.props.discard ? 'discard' : 'store',\n // ...colorAttachment,\n view: colorAttachment.handle\n }));\n if (framebuffer.depthStencilAttachment) {\n renderPassDescriptor.depthStencilAttachment = {\n view: framebuffer.depthStencilAttachment.handle\n };\n const { depthStencilAttachment } = renderPassDescriptor;\n // DEPTH\n if (this.props.depthReadOnly) {\n depthStencilAttachment.depthReadOnly = true;\n }\n depthStencilAttachment.depthClearValue = this.props.clearDepth || 0;\n // WebGPU only wants us to set these parameters if the texture format actually has a depth aspect\n const hasDepthAspect = true;\n if (hasDepthAspect) {\n depthStencilAttachment.depthLoadOp = this.props.clearDepth !== false ? 'clear' : 'load';\n depthStencilAttachment.depthStoreOp = 'store'; // TODO - support 'discard'?\n }\n // WebGPU only wants us to set these parameters if the texture format actually has a stencil aspect\n const hasStencilAspect = false;\n if (hasStencilAspect) {\n depthStencilAttachment.stencilLoadOp = this.props.clearStencil !== false ? 'clear' : 'load';\n depthStencilAttachment.stencilStoreOp = 'store'; // TODO - support 'discard'?\n }\n }\n return renderPassDescriptor;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ComputePass } from '@luma.gl/core';\nexport class WebGPUComputePass extends ComputePass {\n device;\n handle;\n _webgpuPipeline = null;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n // Set up queries\n let timestampWrites;\n if (device.features.has('timestamp-query')) {\n const webgpuQuerySet = props.timestampQuerySet;\n if (webgpuQuerySet) {\n timestampWrites = {\n querySet: webgpuQuerySet.handle,\n beginningOfPassWriteIndex: props.beginTimestampIndex,\n endOfPassWriteIndex: props.endTimestampIndex\n };\n }\n }\n this.handle =\n this.props.handle ||\n device.commandEncoder?.beginComputePass({\n label: this.props.id,\n timestampWrites\n });\n }\n /** @note no WebGPU destroy method, just gc */\n destroy() { }\n end() {\n this.handle.end();\n }\n setPipeline(pipeline) {\n const wgpuPipeline = pipeline;\n this.handle.setPipeline(wgpuPipeline.handle);\n this._webgpuPipeline = wgpuPipeline;\n this.setBindings([]);\n }\n /**\n * Sets an array of bindings (uniform buffers, samplers, textures, ...)\n * TODO - still some API confusion - does this method go here or on the pipeline?\n */\n setBindings(bindings) {\n // @ts-expect-error\n const bindGroup = this._webgpuPipeline._getBindGroup();\n this.handle.setBindGroup(0, bindGroup);\n }\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param x X dimension of the grid of work groups to dispatch.\n * @param y Y dimension of the grid of work groups to dispatch.\n * @param z Z dimension of the grid of work groups to dispatch.\n */\n dispatch(x, y, z) {\n this.handle.dispatchWorkgroups(x, y, z);\n }\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n *\n * 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()\n * @param indirectBuffer\n * @param indirectOffset offset in buffer to the beginning of the dispatch data.\n */\n dispatchIndirect(indirectBuffer, indirectByteOffset = 0) {\n const webgpuBuffer = indirectBuffer;\n this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectByteOffset);\n }\n pushDebugGroup(groupLabel) {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup() {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel) {\n this.handle.insertDebugMarker(markerLabel);\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { VertexArray, log } from '@luma.gl/core';\nimport { getBrowser } from '@probe.gl/env';\n/** VertexArrayObject wrapper */\nexport class WebGPUVertexArray extends VertexArray {\n get [Symbol.toStringTag]() {\n return 'WebGPUVertexArray';\n }\n device;\n /** Vertex Array is a helper class under WebGPU */\n handle;\n // Create a VertexArray\n constructor(device, props) {\n super(device, props);\n this.device = device;\n }\n destroy() { }\n /**\n * Set an elements buffer, for indexed rendering.\n * Must be a Buffer bound to buffer with usage bit Buffer.INDEX set.\n */\n setIndexBuffer(buffer) {\n // assert(!elementBuffer || elementBuffer.glTarget === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n this.indexBuffer = buffer;\n }\n /** Set a bufferSlot in vertex attributes array to a buffer, enables the bufferSlot, sets divisor */\n setBuffer(bufferSlot, buffer) {\n // Sanity check target\n // if (buffer.glUsage === GL.ELEMENT_ARRAY_BUFFER) {\n // throw new Error('Use setIndexBuffer');\n // }\n this.attributes[bufferSlot] = buffer;\n }\n bindBeforeRender(renderPass, firstIndex, indexCount) {\n const webgpuRenderPass = renderPass;\n const webgpuIndexBuffer = this.indexBuffer;\n if (webgpuIndexBuffer?.handle) {\n // Note we can't unset an index buffer\n log.warn('setting index buffer', webgpuIndexBuffer?.handle, webgpuIndexBuffer?.indexType)();\n webgpuRenderPass.handle.setIndexBuffer(webgpuIndexBuffer?.handle, \n // @ts-expect-error TODO - we must enforce type\n webgpuIndexBuffer?.indexType);\n }\n for (let location = 0; location < this.maxVertexAttributes; location++) {\n const webgpuBuffer = this.attributes[location];\n if (webgpuBuffer?.handle) {\n log.warn(`setting vertex buffer ${location}`, webgpuBuffer?.handle)();\n webgpuRenderPass.handle.setVertexBuffer(location, webgpuBuffer?.handle);\n }\n }\n // TODO - emit warnings/errors/throw if constants have been set on this vertex array\n }\n unbindAfterRender(renderPass) {\n // On WebGPU we don't need to unbind.\n // In fact we can't easily do it. setIndexBuffer/setVertexBuffer don't accept null.\n // Unbinding presumably happens automatically when the render pass is ended.\n }\n // DEPRECATED METHODS\n /**\n * @deprecated is this even an issue for WebGPU?\n * Attribute 0 can not be disable on most desktop OpenGL based browsers\n */\n static isConstantAttributeZeroSupported(device) {\n return getBrowser() === 'Chrome';\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { CanvasContext, log } from '@luma.gl/core';\nimport { getWebGPUTextureFormat } from \"./helpers/convert-texture-format.js\";\nimport { WebGPUFramebuffer } from \"./resources/webgpu-framebuffer.js\";\n/**\n * Holds a WebGPU Canvas Context\n * The primary job of the CanvasContext is to generate textures for rendering into the current canvas\n * It also manages canvas sizing calculations and resizing.\n */\nexport class WebGPUCanvasContext extends CanvasContext {\n device;\n gpuCanvasContext;\n /** Format of returned textures: \"bgra8unorm\", \"rgba8unorm\", \"rgba16float\". */\n format = navigator.gpu.getPreferredCanvasFormat();\n /** Default stencil format for depth textures */\n depthStencilFormat = 'depth24plus';\n depthStencilAttachment = null;\n constructor(device, adapter, props) {\n super(props);\n this.device = device;\n // TODO - hack to trigger resize?\n this.width = -1;\n this.height = -1;\n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n // @ts-ignore TODO - we don't handle OffscreenRenderingContext.\n this.gpuCanvasContext = this.canvas.getContext('webgpu');\n // TODO this has been replaced\n // this.format = this.gpuCanvasContext.getPreferredFormat(adapter);\n this.format = 'bgra8unorm';\n }\n /** Destroy any textures produced while configured and remove the context configuration. */\n destroy() {\n this.gpuCanvasContext.unconfigure();\n }\n /** Update framebuffer with properly resized \"swap chain\" texture views */\n getCurrentFramebuffer() {\n // Ensure the canvas context size is updated\n this.update();\n // Wrap the current canvas context texture in a luma.gl texture\n // const currentColorAttachment = this.device.createTexture({\n // id: 'default-render-target',\n // handle: this.gpuCanvasContext.getCurrentTexture(),\n // format: this.format,\n // width: this.width,\n // height: this.height\n // });\n // Wrap the current canvas context texture in a luma.gl texture\n const currentColorAttachment = this.getCurrentTexture();\n this.width = currentColorAttachment.width;\n this.height = currentColorAttachment.height;\n // Resize the depth stencil attachment\n this._createDepthStencilAttachment();\n return new WebGPUFramebuffer(this.device, {\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: this.depthStencilAttachment\n });\n }\n /** Resizes and updates render targets if necessary */\n update() {\n const [width, height] = this.getPixelSize();\n const sizeChanged = width !== this.width || height !== this.height;\n if (sizeChanged) {\n this.width = width;\n this.height = height;\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n // Reconfigure the canvas size.\n // https://www.w3.org/TR/webgpu/#canvas-configuration\n this.gpuCanvasContext.configure({\n device: this.device.handle,\n format: getWebGPUTextureFormat(this.format),\n // Can be used to define e.g. -srgb views\n // viewFormats: [...]\n colorSpace: this.props.colorSpace,\n alphaMode: this.props.alphaMode\n });\n log.log(1, `Resized to ${this.width}x${this.height}px`)();\n }\n }\n resize(options) {\n this.update();\n if (!this.device.handle)\n return;\n // Resize browser context .\n if (this.canvas) {\n const devicePixelRatio = this.getDevicePixelRatio(options?.useDevicePixels);\n this.setDevicePixelRatio(devicePixelRatio, options);\n return;\n }\n }\n /** Wrap the current canvas context texture in a luma.gl texture */\n getCurrentTexture() {\n return this.device.createTexture({\n id: `${this.id}#color-texture`,\n handle: this.gpuCanvasContext.getCurrentTexture(),\n format: this.format\n });\n }\n /** We build render targets on demand (i.e. not when size changes but when about to render) */\n _createDepthStencilAttachment() {\n if (!this.depthStencilAttachment) {\n this.depthStencilAttachment = this.device.createTexture({\n id: `${this.id}#depth-stencil-texture`,\n format: this.depthStencilFormat,\n width: this.width,\n height: this.height,\n usage: GPUTextureUsage.RENDER_ATTACHMENT\n });\n }\n return this.depthStencilAttachment;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { QuerySet } from '@luma.gl/core';\n/**\n * Immutable\n */\nexport class WebGPUQuerySet extends QuerySet {\n device;\n handle;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.handle =\n this.props.handle ||\n this.device.handle.createQuerySet({\n type: this.props.type,\n count: this.props.count\n });\n this.handle.label = this.props.id;\n }\n destroy() {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,IAAAA,gBAA6B;;;ACA7B,IAAAC,gBAAuC;;;ACAvC,kBAAuB;AACvB,SAAS,cAAc,OAAO;AAJ9B;AAKI,SAAO,MAAM,gBAAc,WAAM,SAAN,mBAAY,eAAc;AACzD;AACO,IAAM,eAAN,cAA2B,mBAAO;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,QAAQ,OAAO;AACvB,UAAM,QAAQ,KAAK;AACnB,SAAK,SAAS;AACd,SAAK,aAAa,cAAc,KAAK;AACrC,UAAM,YAAY,QAAQ,MAAM,IAAI;AAEpC,UAAM,OAAO,KAAK,KAAK,KAAK,aAAa,CAAC,IAAI;AAC9C,SAAK,SACD,KAAK,MAAM,UACP,KAAK,OAAO,OAAO,aAAa;AAAA,MAC5B;AAAA;AAAA,MAEA,OAAO,KAAK,MAAM,SAAS,eAAe,SAAS,eAAe;AAAA,MAClE,kBAAkB,KAAK,MAAM,oBAAoB;AAAA,MACjD,OAAO,KAAK,MAAM;AAA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AI;AAAA,QAC5B;AAAA,MACJ;AAAA,IACJ;AACA,UAAM,YAAY,MAAM,QAAQ,cAAc;AAAA,MAC1C;AAAA,MACA;AAAA,IACJ,CAAC;AACD,sBAAI,MAAM,GAAG,qBAAqB,EAAE;AACpC,UAAM,SAAS,IAAI,aAAa,OAAO,WAAW,SAAS,WAAW;AACtE,sBAAI,MAAM,GAAG,qFAAqF,EAAE;AACpG,sBAAI,MAAM,GAAG,OAAO,IAAI,EAAE;AAC1B,sBAAI,SAAS,CAAC,EAAE;AAChB,WAAO;AAAA,EACX;AAAA,EACA,MAAM,OAAO,QAAQ;AACjB,UAAM,IAAI,MAAM,wCAAwC;AAAA,EAC5D;AACJ;AACO,IAAM,gBAAgB,IAAI,cAAc;",
|
|
6
|
+
"names": ["import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgpu",
|
|
3
|
-
"version": "9.1.0-alpha.
|
|
3
|
+
"version": "9.1.0-alpha.16",
|
|
4
4
|
"description": "WebGPU adapter for the luma.gl core API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@luma.gl/core": "9.1.0-alpha.
|
|
40
|
+
"@luma.gl/core": "9.1.0-alpha.14"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@probe.gl/env": "^4.0.8",
|
|
44
44
|
"@webgpu/types": "^0.1.34"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "39eec40d12c826548b636c057fdb8572adfe611f"
|
|
47
47
|
}
|
|
@@ -150,7 +150,7 @@ function findAttributeLayout(
|
|
|
150
150
|
name: string,
|
|
151
151
|
attributeNames: Set<string>
|
|
152
152
|
): AttributeDeclaration | null {
|
|
153
|
-
const attribute = shaderLayout.attributes.find(
|
|
153
|
+
const attribute = shaderLayout.attributes.find(attribute_ => attribute_.name === name);
|
|
154
154
|
if (!attribute) {
|
|
155
155
|
log.warn(`Unknown attribute ${name}`)();
|
|
156
156
|
return null;
|
|
@@ -36,14 +36,14 @@ export class WebGPUCommandEncoder extends CommandEncoder {
|
|
|
36
36
|
|
|
37
37
|
copyBufferToBuffer(options: // CopyBufferToBufferOptions
|
|
38
38
|
{
|
|
39
|
-
|
|
39
|
+
sourceBuffer: Buffer;
|
|
40
40
|
sourceOffset?: number;
|
|
41
|
-
|
|
41
|
+
destinationBuffer: Buffer;
|
|
42
42
|
destinationOffset?: number;
|
|
43
43
|
size?: number;
|
|
44
44
|
}): void {
|
|
45
|
-
const webgpuSourceBuffer = options.
|
|
46
|
-
const WebGPUDestinationBuffer = options.
|
|
45
|
+
const webgpuSourceBuffer = options.sourceBuffer as WebGPUBuffer;
|
|
46
|
+
const WebGPUDestinationBuffer = options.destinationBuffer as WebGPUBuffer;
|
|
47
47
|
this.handle.copyBufferToBuffer(
|
|
48
48
|
webgpuSourceBuffer.handle,
|
|
49
49
|
options.sourceOffset ?? 0,
|
|
@@ -55,20 +55,20 @@ export class WebGPUCommandEncoder extends CommandEncoder {
|
|
|
55
55
|
|
|
56
56
|
copyBufferToTexture(options: // CopyBufferToTextureOptions
|
|
57
57
|
{
|
|
58
|
-
|
|
58
|
+
sourceBuffer: Buffer;
|
|
59
59
|
offset?: number;
|
|
60
60
|
bytesPerRow: number;
|
|
61
61
|
rowsPerImage: number;
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
destinationTexture: Texture;
|
|
64
64
|
mipLevel?: number;
|
|
65
65
|
aspect?: 'all' | 'stencil-only' | 'depth-only';
|
|
66
66
|
|
|
67
67
|
origin?: number[] | [number, number, number];
|
|
68
68
|
extent?: number[] | [number, number, number];
|
|
69
69
|
}): void {
|
|
70
|
-
const webgpuSourceBuffer = options.
|
|
71
|
-
const WebGPUDestinationTexture = options.
|
|
70
|
+
const webgpuSourceBuffer = options.sourceBuffer as WebGPUBuffer;
|
|
71
|
+
const WebGPUDestinationTexture = options.destinationTexture as WebGPUTexture;
|
|
72
72
|
this.handle.copyBufferToTexture(
|
|
73
73
|
{
|
|
74
74
|
buffer: webgpuSourceBuffer.handle,
|
|
@@ -32,10 +32,10 @@ export class WebGPURenderPass extends RenderPass {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
if (device.features.has('timestamp-query')) {
|
|
35
|
-
const
|
|
36
|
-
renderPassDescriptor.timestampWrites =
|
|
35
|
+
const webgpuTSQuerySet = props.timestampQuerySet as WebGPUQuerySet;
|
|
36
|
+
renderPassDescriptor.timestampWrites = webgpuTSQuerySet
|
|
37
37
|
? ({
|
|
38
|
-
querySet:
|
|
38
|
+
querySet: webgpuTSQuerySet.handle,
|
|
39
39
|
beginningOfPassWriteIndex: props.beginTimestampIndex,
|
|
40
40
|
endOfPassWriteIndex: props.endTimestampIndex
|
|
41
41
|
} as GPUComputePassTimestampWrites)
|
|
@@ -25,6 +25,10 @@ export class WebGPUShader extends Shader {
|
|
|
25
25
|
this._checkCompilationError(this.device.handle.popErrorScope());
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
get asyncCompilationStatus(): Promise<any> {
|
|
29
|
+
return this.getCompilationInfo().then(() => this.compilationStatus);
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
async _checkCompilationError(errorScope: Promise<GPUError | null>): Promise<void> {
|
|
29
33
|
const error = (await errorScope) as GPUValidationError;
|
|
30
34
|
if (error) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {Adapter, DeviceProps,
|
|
5
|
+
import {Adapter, DeviceProps, log} from '@luma.gl/core';
|
|
6
6
|
import {WebGPUDevice} from './webgpu-device';
|
|
7
7
|
|
|
8
8
|
// / <reference types="@webgpu/types" />
|
|
@@ -44,7 +44,7 @@ export class WebGPUAdapter extends Adapter {
|
|
|
44
44
|
const requiredFeatures: GPUFeatureName[] = [];
|
|
45
45
|
const requiredLimits: Record<string, number> = {};
|
|
46
46
|
|
|
47
|
-
if (props.
|
|
47
|
+
if (props._requestMaxLimits) {
|
|
48
48
|
// Require all features
|
|
49
49
|
requiredFeatures.push(...(Array.from(adapter.features) as GPUFeatureName[]));
|
|
50
50
|
|
|
@@ -69,11 +69,6 @@ export class WebGPUAdapter extends Adapter {
|
|
|
69
69
|
|
|
70
70
|
log.probe(1, 'GPUDevice available')();
|
|
71
71
|
|
|
72
|
-
if (typeof props.canvas === 'string') {
|
|
73
|
-
await CanvasContext.pageLoaded;
|
|
74
|
-
log.probe(1, 'DOM is loaded')();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
72
|
const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo);
|
|
78
73
|
|
|
79
74
|
log.probe(
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
// / <reference types="@webgpu/types" />
|
|
7
7
|
|
|
8
8
|
import type {
|
|
9
|
-
DeviceProps,
|
|
10
9
|
DeviceInfo,
|
|
11
10
|
DeviceLimits,
|
|
12
11
|
DeviceFeature,
|
|
@@ -28,7 +27,8 @@ import type {
|
|
|
28
27
|
TransformFeedback,
|
|
29
28
|
TransformFeedbackProps,
|
|
30
29
|
QuerySet,
|
|
31
|
-
QuerySetProps
|
|
30
|
+
QuerySetProps,
|
|
31
|
+
DeviceProps
|
|
32
32
|
} from '@luma.gl/core';
|
|
33
33
|
import {Device, DeviceFeatures} from '@luma.gl/core';
|
|
34
34
|
import {WebGPUBuffer} from './resources/webgpu-buffer';
|
|
@@ -101,14 +101,11 @@ export class WebGPUDevice extends Device {
|
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
// Note: WebGPU devices can be created without a canvas, for compute shader purposes
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
container: props.container
|
|
110
|
-
});
|
|
111
|
-
// }
|
|
104
|
+
if (props.createCanvasContext) {
|
|
105
|
+
const canvasContextProps =
|
|
106
|
+
props.createCanvasContext === true ? {} : props.createCanvasContext;
|
|
107
|
+
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);
|
|
108
|
+
}
|
|
112
109
|
}
|
|
113
110
|
|
|
114
111
|
// TODO
|
|
@@ -143,7 +140,7 @@ export class WebGPUDevice extends Device {
|
|
|
143
140
|
}
|
|
144
141
|
|
|
145
142
|
createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer {
|
|
146
|
-
const newProps = this.
|
|
143
|
+
const newProps = this._normalizeBufferProps(props);
|
|
147
144
|
return new WebGPUBuffer(this, newProps);
|
|
148
145
|
}
|
|
149
146
|
|
|
@@ -280,7 +277,7 @@ export class WebGPUDevice extends Device {
|
|
|
280
277
|
features.add(feature);
|
|
281
278
|
}
|
|
282
279
|
|
|
283
|
-
return new DeviceFeatures(Array.from(features), this.props.
|
|
280
|
+
return new DeviceFeatures(Array.from(features), this.props._disabledFeatures);
|
|
284
281
|
}
|
|
285
282
|
|
|
286
283
|
copyExternalImageToTexture(options: {
|