@luma.gl/webgpu 9.0.0-alpha.45 → 9.0.0-alpha.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/helpers/accessor-to-format.js.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.js +1 -1
- package/dist/adapter/resources/webgpu-buffer.js.map +1 -1
- package/dist/adapter/webgpu-device.d.ts +2 -1
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +7 -1
- package/dist/adapter/webgpu-device.js.map +1 -1
- package/dist/dist.dev.js +18 -10
- package/dist/index.cjs +11 -7
- package/dist.min.js +2 -2
- package/package.json +3 -3
- package/src/adapter/helpers/accessor-to-format.ts +0 -1
- package/src/adapter/resources/webgpu-buffer.ts +2 -2
- package/src/adapter/webgpu-device.ts +17 -10
- package/LICENSE +0 -34
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessor-to-format.js","names":[],"sources":["../../../src/adapter/helpers/accessor-to-format.ts"],"sourcesContent":["/*\nimport {assert} from '@luma.gl/core';\
|
|
1
|
+
{"version":3,"file":"accessor-to-format.js","names":[],"sources":["../../../src/adapter/helpers/accessor-to-format.ts"],"sourcesContent":["/*\nimport {assert} from '@luma.gl/core';\n\ntype Accessor = Record<string, any>;\n\nconst FORMAT_TO_ACCESSOR: Record<GPUVertexFormat, Accessor> = {\n uchar2: {type: 'uchar', size: 2},\n uchar4: {type: 'uchar', size: 4},\n char2: {type: 'char', size: 2},\n char4: {type: 'char', size: 4},\n uchar2norm: {type: 'uchar', size: 2, normalized: true},\n uchar4norm: {type: 'uchar', size: 4, normalized: true},\n char2norm: {type: 'char', size: 2, normalized: true},\n char4norm: {type: 'char', size: 4, normalized: true},\n ushort2: {type: 'ushort', size: 2},\n ushort4: {type: 'ushort', size: 4},\n short2: {type: 'short', size: 2},\n short4: {type: 'short', size: 4},\n ushort2norm: {type: 'ushort', size: 2, normalized: true},\n ushort4norm: {type: 'ushort', size: 4, normalized: true},\n short2norm: {type: 'short', size: 1, normalized: true},\n short4norm: {type: 'short', size: 1, normalized: true},\n half2: {type: 'half', size: 2},\n half4: {type: 'half', size: 4},\n float: {type: 'float', size: 1},\n float2: {type: 'float', size: 2},\n float3: {type: 'float', size: 3},\n float4: {type: 'float', size: 4},\n uint: {type: 'uint', size: 1, integer: true},\n uint2: {type: 'uint', size: 2, integer: true},\n uint3: {type: 'uint', size: 3, integer: true},\n uint4: {type: 'uint', size: 4, integer: true},\n int: {type: 'int', size: 1, integer: true},\n int2: {type: 'int', size: 2, integer: true},\n int3: {type: 'int', size: 3, integer: true},\n int4: {type: 'int', size: 4, integer: true}\n};\n\n/**\n * Convert from WebGPU attribute format strings to accessor {type, size, normalized, integer}\n * @param {*} format\n *\nexport function mapWebGPUFormatToAccessor(format) {\n const accessorDefinition = FORMAT_TO_ACCESSOR[format];\n assert(accessorDefinition, 'invalid attribute format');\n return Object.freeze(accessorDefinition);\n}\n\n/**\n * Convert from accessor {type, size, normalized, integer} to WebGPU attribute format strings\n * @param {*} format\n *\nexport function mapAccessorToWebGPUFormat(accessor) {\n const {type = GL.FLOAT, size = 1, normalized = false, integer = false} = accessor;\n assert(size >=1 && size <=4);\n // `norm` suffix (uchar4norm)\n const norm = normalized ? 'norm' : '';\n // size 1 is ommitted in format names (float vs float2)\n const count = size === 1 ? '' : size;\n switch (type) {\n case GL.UNSIGNED_BYTE:\n switch (size) {\n case 2:\n case 4:\n return `uchar${count}${norm}`;\n }\n case GL.BYTE:\n switch (size) {\n case 2:\n case 4:\n return `char${count}${norm}`;\n }\n case GL.UNSIGNED_SHORT:\n switch (size) {\n case 2:\n case 4:\n return `ushort${count}${norm}`;\n }\n case GL.SHORT:\n switch (size) {\n case 2:\n case 4:\n return `short${count}${norm}`;\n }\n case GL.HALF_FLOAT:\n switch (size) {\n case 2:\n case 4:\n return `half${count}`;\n }\n case GL.FLOAT:\n return `float${count}`;\n case GL.UNSIGNED_INT:\n return `uint${count}`;\n case GL.INT:\n return `int${count}`;\n }\n throw new Error('illegal accessor');\n}\n*/"],"mappings":""}
|
|
@@ -8,7 +8,7 @@ export declare class WebGPUBuffer extends Buffer {
|
|
|
8
8
|
constructor(device: WebGPUDevice, props: BufferProps);
|
|
9
9
|
destroy(): void;
|
|
10
10
|
write(data: ArrayBufferView, byteOffset?: number): void;
|
|
11
|
-
readAsync(byteOffset?: number, byteLength?: number): Promise<
|
|
11
|
+
readAsync(byteOffset?: number, byteLength?: number): Promise<Uint8Array>;
|
|
12
12
|
_writeMapped<TypedArray>(typedArray: TypedArray): void;
|
|
13
13
|
mapAsync(mode: number, offset?: number, size?: number): Promise<void>;
|
|
14
14
|
getMappedRange(offset?: number, size?: number): ArrayBuffer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAMnD,qBAAa,YAAa,SAAQ,MAAM;IACtC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW;IA4B3C,OAAO,IAAI,IAAI;IAKf,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,SAAI;IAUrC,SAAS,CAAC,UAAU,GAAE,MAAU,EAAE,UAAU,GAAE,MAAwB,GAAG,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"webgpu-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAMnD,qBAAa,YAAa,SAAQ,MAAM;IACtC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW;IA4B3C,OAAO,IAAI,IAAI;IAKf,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,SAAI;IAUrC,SAAS,CAAC,UAAU,GAAE,MAAU,EAAE,UAAU,GAAE,MAAwB,GAAG,OAAO,CAAC,UAAU,CAAC;IAmB3G,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAQtD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxE,cAAc,CAAC,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW;IAI9D,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -47,7 +47,7 @@ export class WebGPUBuffer extends Buffer {
|
|
|
47
47
|
const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);
|
|
48
48
|
tempBuffer.handle.unmap();
|
|
49
49
|
tempBuffer.destroy();
|
|
50
|
-
return arrayBuffer;
|
|
50
|
+
return new Uint8Array(arrayBuffer);
|
|
51
51
|
}
|
|
52
52
|
_writeMapped(typedArray) {
|
|
53
53
|
const arrayBuffer = this.handle.getMappedRange();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-buffer.js","names":["Buffer","getByteLength","props","_props$data","byteLength","data","WebGPUBuffer","constructor","device","handle","mapBuffer","Boolean","size","Math","ceil","createBuffer","usage","GPUBufferUsage","VERTEX","COPY_DST","mappedAtCreation","label","id","_writeMapped","unmap","destroy","write","byteOffset","arguments","length","undefined","queue","writeBuffer","buffer","readAsync","tempBuffer","MAP_READ","commandEncoder","createCommandEncoder","copyBufferToBuffer","submit","finish","mapAsync","GPUMapMode","READ","arrayBuffer","getMappedRange","slice","typedArray","set","mode","offset"],"sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"sourcesContent":["// WEBGPU Buffer implementation\nimport {Buffer, BufferProps} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\n\nfunction getByteLength(props: BufferProps): number {\n return props.byteLength || props.data?.byteLength || 0;\n}\n\nexport class WebGPUBuffer extends Buffer {\n readonly device: WebGPUDevice;\n readonly handle: GPUBuffer;\n readonly byteLength: number;\n\n constructor(device: WebGPUDevice, props: BufferProps) {\n super(device, props);\n this.device = device;\n\n this.byteLength = getByteLength(props);\n const mapBuffer = Boolean(props.data);\n\n // WebGPU buffers must be aligned to 4 bytes\n const size = Math.ceil(this.byteLength / 4) * 4;\n\n this.handle = this.props.handle || 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\n if (props.data) {\n this._writeMapped(props.data);\n // this.handle.writeAsync({data: props.data, map: false, unmap: false});\n }\n\n if (mapBuffer && !props.mappedAtCreation) {\n this.handle.unmap();\n }\n }\n\n override destroy(): void {\n this.handle.destroy();\n }\n\n // WebGPU provides multiple ways to write a buffer...\n override write(data: ArrayBufferView, byteOffset = 0) {\n this.device.handle.queue.writeBuffer(\n this.handle,\n byteOffset,\n data.buffer,\n data.byteOffset,\n data.byteLength\n );\n }\n\n override async readAsync(byteOffset: number = 0, byteLength: number = this.byteLength): Promise<
|
|
1
|
+
{"version":3,"file":"webgpu-buffer.js","names":["Buffer","getByteLength","props","_props$data","byteLength","data","WebGPUBuffer","constructor","device","handle","mapBuffer","Boolean","size","Math","ceil","createBuffer","usage","GPUBufferUsage","VERTEX","COPY_DST","mappedAtCreation","label","id","_writeMapped","unmap","destroy","write","byteOffset","arguments","length","undefined","queue","writeBuffer","buffer","readAsync","tempBuffer","MAP_READ","commandEncoder","createCommandEncoder","copyBufferToBuffer","submit","finish","mapAsync","GPUMapMode","READ","arrayBuffer","getMappedRange","slice","Uint8Array","typedArray","set","mode","offset"],"sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"sourcesContent":["// WEBGPU Buffer implementation\nimport {Buffer, BufferProps} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\n\nfunction getByteLength(props: BufferProps): number {\n return props.byteLength || props.data?.byteLength || 0;\n}\n\nexport class WebGPUBuffer extends Buffer {\n readonly device: WebGPUDevice;\n readonly handle: GPUBuffer;\n readonly byteLength: number;\n\n constructor(device: WebGPUDevice, props: BufferProps) {\n super(device, props);\n this.device = device;\n\n this.byteLength = getByteLength(props);\n const mapBuffer = Boolean(props.data);\n\n // WebGPU buffers must be aligned to 4 bytes\n const size = Math.ceil(this.byteLength / 4) * 4;\n\n this.handle = this.props.handle || 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\n if (props.data) {\n this._writeMapped(props.data);\n // this.handle.writeAsync({data: props.data, map: false, unmap: false});\n }\n\n if (mapBuffer && !props.mappedAtCreation) {\n this.handle.unmap();\n }\n }\n\n override destroy(): void {\n this.handle.destroy();\n }\n\n // WebGPU provides multiple ways to write a buffer...\n override write(data: ArrayBufferView, byteOffset = 0) {\n this.device.handle.queue.writeBuffer(\n this.handle,\n byteOffset,\n data.buffer,\n data.byteOffset,\n data.byteLength\n );\n }\n\n override async readAsync(byteOffset: number = 0, byteLength: number = this.byteLength): Promise<Uint8Array> {\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, {usage: Buffer.MAP_READ | Buffer.COPY_DST, 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\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\n return new Uint8Array(arrayBuffer);\n }\n\n _writeMapped<TypedArray>(typedArray: TypedArray): void {\n const arrayBuffer = this.handle.getMappedRange();\n // @ts-expect-error\n new typedArray.constructor(arrayBuffer).set(typedArray);\n }\n\n // WEBGPU API\n\n mapAsync(mode: number, offset: number = 0, size?: number): Promise<void> {\n return this.handle.mapAsync(mode, offset, size);\n }\n\n getMappedRange(offset: number = 0, size?: number): ArrayBuffer {\n return this.handle.getMappedRange(offset, size);\n }\n\n unmap(): void {\n this.handle.unmap();\n }\n}\n"],"mappings":"AACA,SAAQA,MAAM,QAAoB,eAAe;AAGjD,SAASC,aAAaA,CAACC,KAAkB,EAAU;EAAA,IAAAC,WAAA;EACjD,OAAOD,KAAK,CAACE,UAAU,MAAAD,WAAA,GAAID,KAAK,CAACG,IAAI,cAAAF,WAAA,uBAAVA,WAAA,CAAYC,UAAU,KAAI,CAAC;AACxD;AAEA,OAAO,MAAME,YAAY,SAASN,MAAM,CAAC;EAKvCO,WAAWA,CAACC,MAAoB,EAAEN,KAAkB,EAAE;IACpD,KAAK,CAACM,MAAM,EAAEN,KAAK,CAAC;IAAC,KALdM,MAAM;IAAA,KACNC,MAAM;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AAc,CAAC,CAAC;IAEhD,IAAIG,UAAU,CAAC1C,WAAW,CAACsC,WAAW,CAAC,CAACK,GAAG,CAACD,UAAU,CAAC;EACzD;EAIAP,QAAQA,CAACS,IAAY,EAAoD;IAAA,IAAlDC,MAAc,GAAAxB,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;IAAA,IAAEhB,IAAa,GAAAgB,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IACtD,OAAO,IAAI,CAACrB,MAAM,CAACiC,QAAQ,CAACS,IAAI,EAAEC,MAAM,EAAExC,IAAI,CAAC;EACjD;EAEAkC,cAAcA,CAAA,EAAiD;IAAA,IAAhDM,MAAc,GAAAxB,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;IAAA,IAAEhB,IAAa,GAAAgB,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAC9C,OAAO,IAAI,CAACrB,MAAM,CAACqC,cAAc,CAACM,MAAM,EAAExC,IAAI,CAAC;EACjD;EAEAY,KAAKA,CAAA,EAAS;IACZ,IAAI,CAACf,MAAM,CAACe,KAAK,CAAC,CAAC;EACrB;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="dist" />
|
|
2
|
-
import type { DeviceProps, DeviceInfo, DeviceLimits, DeviceFeature, CanvasContextProps, BufferProps, SamplerProps, ShaderProps, Texture, TextureProps, TextureFormat, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipelineProps, RenderPassProps, ComputePassProps, VertexArrayProps } from '@luma.gl/core';
|
|
2
|
+
import type { DeviceProps, DeviceInfo, DeviceLimits, DeviceFeature, CanvasContextProps, BufferProps, SamplerProps, ShaderProps, Texture, TextureProps, TextureFormat, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipelineProps, RenderPassProps, ComputePassProps, VertexArrayProps, TransformFeedback, TransformFeedbackProps } from '@luma.gl/core';
|
|
3
3
|
import { Device } from '@luma.gl/core';
|
|
4
4
|
import { WebGPUBuffer } from './resources/webgpu-buffer';
|
|
5
5
|
import { WebGPUTexture } from './resources/webgpu-texture';
|
|
@@ -56,6 +56,7 @@ export declare class WebGPUDevice extends Device {
|
|
|
56
56
|
*/
|
|
57
57
|
beginRenderPass(props: RenderPassProps): WebGPURenderPass;
|
|
58
58
|
beginComputePass(props: ComputePassProps): WebGPUComputePass;
|
|
59
|
+
createTransformFeedback(props: TransformFeedbackProps): TransformFeedback;
|
|
59
60
|
createCanvasContext(props: CanvasContextProps): WebGPUCanvasContext;
|
|
60
61
|
/**
|
|
61
62
|
* Gets default renderpass encoder.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-device.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,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,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,MAAM,EAA0B,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,qBAAqB,EAAC,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,C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EAAE,gBAAgB,GAAG,iBAAiB;IAS5D,uBAAuB,CAAC,KAAK,EAAE,sBAAsB,GAAG,iBAAiB;IAIzE,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,mBAAmB;IAInE;;;;;OAKG;IACH,oBAAoB,IAAI,gBAAgB;IAUxC,MAAM,IAAI,IAAI;IAUd,YAAY;IAuDZ,0BAA0B,CAAC,OAAO,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"}
|
|
@@ -80,7 +80,10 @@ export class WebGPUDevice extends Device {
|
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
82
|
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, {
|
|
83
|
-
canvas: props.canvas
|
|
83
|
+
canvas: props.canvas,
|
|
84
|
+
height: props.height,
|
|
85
|
+
width: props.width,
|
|
86
|
+
container: props.container
|
|
84
87
|
});
|
|
85
88
|
this.features = this._getFeatures();
|
|
86
89
|
}
|
|
@@ -141,6 +144,9 @@ export class WebGPUDevice extends Device {
|
|
|
141
144
|
this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();
|
|
142
145
|
return new WebGPUComputePass(this, props);
|
|
143
146
|
}
|
|
147
|
+
createTransformFeedback(props) {
|
|
148
|
+
throw new Error('Transform feedback not supported in WebGPU');
|
|
149
|
+
}
|
|
144
150
|
createCanvasContext(props) {
|
|
145
151
|
return new WebGPUCanvasContext(this, this.adapter, props);
|
|
146
152
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-device.js","names":["Device","CanvasContext","log","uid","WebGPUBuffer","WebGPUTexture","WebGPUExternalTexture","WebGPUSampler","WebGPUShader","WebGPURenderPipeline","WebGPUComputePipeline","WebGPURenderPass","WebGPUComputePass","WebGPUVertexArray","WebGPUCanvasContext","WebGPUDevice","isSupported","Boolean","navigator","gpu","create","props","Error","groupCollapsed","adapter","requestAdapter","powerPreference","adapterInfo","requestAdapterInfo","probe","gpuDevice","requestDevice","requiredFeatures","features","canvas","pageLoaded","device","info","table","groupEnd","constructor","id","handle","lost","canvasContext","commandEncoder","renderPass","_info","_isLost","type","vendor","__brand","renderer","version","shadingLanguages","shadingLanguageVersions","glsl","wgsl","vendorMasked","rendererMasked","Promise","resolve","lostInfo","reason","message","_getFeatures","destroy","limits","isTextureFormatSupported","format","includes","isTextureFormatFilterable","isTextureFormatRenderable","isLost","createBuffer","newProps","_getBufferProps","_createTexture","createExternalTexture","createShader","createSampler","createRenderPipeline","createFramebuffer","createComputePipeline","createVertexArray","beginRenderPass","createCommandEncoder","beginComputePass","createCanvasContext","getDefaultRenderPass","submit","_this$commandEncoder","commandBuffer","finish","queue","Set","has","delete","add","copyExternalImageToTexture","options","_this$handle","source","sourceX","sourceY","texture","mipLevel","aspect","colorSpace","premultipliedAlpha","width","height","depth","webGpuTexture","origin"],"sources":["../../src/adapter/webgpu-device.ts"],"sourcesContent":["// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n BufferProps,\n SamplerProps,\n ShaderProps,\n Texture,\n TextureProps,\n TextureFormat,\n ExternalTextureProps,\n FramebufferProps,\n RenderPipelineProps,\n ComputePipelineProps,\n RenderPassProps,\n ComputePassProps,\n // CommandEncoderProps,\n VertexArrayProps\n} from '@luma.gl/core';\nimport {Device, CanvasContext, log, uid} from '@luma.gl/core';\nimport {WebGPUBuffer} from './resources/webgpu-buffer';\nimport {WebGPUTexture} from './resources/webgpu-texture';\nimport {WebGPUExternalTexture} from './resources/webgpu-external-texture';\nimport {WebGPUSampler} from './resources/webgpu-sampler';\nimport {WebGPUShader} from './resources/webgpu-shader';\nimport {WebGPURenderPipeline} from './resources/webgpu-render-pipeline';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\nimport {WebGPUComputePipeline} from './resources/webgpu-compute-pipeline';\nimport {WebGPURenderPass} from './resources/webgpu-render-pass';\nimport {WebGPUComputePass} from './resources/webgpu-compute-pass';\n// import {WebGPUCommandEncoder} from './resources/webgpu-command-encoder';\nimport {WebGPUVertexArray} from './resources/webgpu-vertex-array';\n\nimport {WebGPUCanvasContext} from './webgpu-canvas-context';\n// import {loadGlslangModule} from '../glsl/glslang';\n\n/** WebGPU Device implementation */\nexport class WebGPUDevice extends Device {\n readonly handle: GPUDevice;\n readonly adapter: GPUAdapter;\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n canvasContext: WebGPUCanvasContext | null = null;\n\n commandEncoder: GPUCommandEncoder | null = null;\n renderPass: WebGPURenderPass | null = null;\n\n private _info: DeviceInfo;\n private _isLost: boolean = false;\n\n static type: string = 'webgpu';\n\n /** Check if WebGPU is available */\n static isSupported(): boolean {\n return Boolean(typeof navigator !== 'undefined' && navigator.gpu);\n }\n\n static async create(props: DeviceProps): Promise<WebGPUDevice> {\n if (!navigator.gpu) {\n throw new Error(\n 'WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu'\n );\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\n const adapterInfo = await adapter.requestAdapterInfo();\n log.probe(1, 'Adapter available', adapterInfo)();\n\n const gpuDevice = await adapter.requestDevice({\n requiredFeatures: adapter.features as ReadonlySet<GPUFeatureName>\n // TODO ensure we obtain best limits\n // requiredLimits: adapter.limits\n });\n log.probe(1, 'GPUDevice available')();\n\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n log.probe(1, 'DOM is loaded')();\n }\n\n const device = new WebGPUDevice(gpuDevice, adapter, props);\n log.probe(1, 'Device created', device.info)();\n log.table(1, device.info)();\n log.groupEnd(1)();\n return device;\n }\n\n constructor(device: GPUDevice, adapter: GPUAdapter, props: DeviceProps) {\n super({...props, id: props.id || uid('webgpu-device')});\n this.handle = device;\n this.adapter = adapter;\n\n this._info = {\n type: 'webgpu',\n vendor: this.adapter.__brand,\n renderer: '',\n version: '',\n gpu: 'unknown', // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',\n shadingLanguages: ['wgsl'],\n shadingLanguageVersions: {\n glsl: '450',\n wgsl: '100'\n },\n vendorMasked: '',\n rendererMasked: ''\n };\n\n // \"Context\" loss handling\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(async (resolve) => {\n const lostInfo = await this.handle.lost;\n this._isLost = true;\n resolve({reason: 'destroyed', message: lostInfo.message});\n });\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, {canvas: props.canvas});\n // }\n\n this.features = this._getFeatures();\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\n destroy(): void {\n this.handle.destroy();\n }\n\n get info(): DeviceInfo {\n return this._info;\n }\n\n features: Set<DeviceFeature>;\n\n get limits(): DeviceLimits {\n return this.handle.limits;\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return !format.includes('webgl');\n }\n\n /** @todo implement proper check? */\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n /** @todo implement proper check? */\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n get isLost(): boolean {\n return this._isLost;\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer {\n const newProps = this._getBufferProps(props);\n return new WebGPUBuffer(this, newProps);\n }\n\n _createTexture(props: TextureProps): WebGPUTexture {\n return new WebGPUTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): WebGPUExternalTexture {\n return new WebGPUExternalTexture(this, props);\n }\n\n createShader(props: ShaderProps): WebGPUShader {\n return new WebGPUShader(this, props);\n }\n\n createSampler(props: SamplerProps): WebGPUSampler {\n return new WebGPUSampler(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WebGPURenderPipeline {\n return new WebGPURenderPipeline(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WebGPUFramebuffer {\n throw new Error('Not implemented');\n }\n\n createComputePipeline(props: ComputePipelineProps): WebGPUComputePipeline {\n return new WebGPUComputePipeline(this, props);\n }\n\n createVertexArray(props: VertexArrayProps): WebGPUVertexArray {\n return new WebGPUVertexArray(this, props);\n }\n\n // WebGPU specifics\n\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: RenderPassProps): WebGPURenderPass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPURenderPass(this, props);\n }\n\n beginComputePass(props: ComputePassProps): WebGPUComputePass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPUComputePass(this, props);\n }\n\n // createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {\n // return new WebGPUCommandEncoder(this, props);\n // }\n\n createCanvasContext(props: CanvasContextProps): WebGPUCanvasContext {\n return new WebGPUCanvasContext(this, this.adapter, props);\n }\n\n /**\n * Gets default renderpass encoder.\n * Creates a new encoder against default canvasContext if not already created\n * @note Called internally by Model.\n * @deprecated Create explicit pass with device.beginRenderPass\n */\n getDefaultRenderPass(): WebGPURenderPass {\n // this.renderPass =\n // this.renderPass ||\n // this.beginRenderPass({\n // framebuffer: this.canvasContext?.getCurrentFramebuffer()\n // });\n // return this.renderPass;\n throw new Error('a');\n }\n\n submit(): void {\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\n _getFeatures() {\n // WebGPU Features\n const features = new Set<DeviceFeature>(this.handle.features as Set<DeviceFeature>);\n\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\n // Add subsets\n if (features.has('texture-compression-bc')) {\n features.add('texture-compression-bc5-webgl');\n }\n\n features.add('webgpu');\n\n features.add('timer-query-webgl');\n\n // WEBGL1 SUPPORT\n features.add('vertex-array-object-webgl1');\n features.add('instanced-rendering-webgl1');\n features.add('multiple-render-targets-webgl1');\n features.add('index-uint32-webgl1');\n features.add('blend-minmax-webgl1');\n features.add('texture-blend-float-webgl1');\n\n // TEXTURES, RENDERBUFFERS\n features.add('texture-formats-srgb-webgl1');\n\n // TEXTURES\n features.add('texture-formats-depth-webgl1');\n features.add('texture-formats-float32-webgl1');\n features.add('texture-formats-float16-webgl1');\n\n features.add('texture-filter-linear-float32-webgl');\n features.add('texture-filter-linear-float16-webgl');\n features.add('texture-filter-anisotropic-webgl');\n\n // FRAMEBUFFERS, TEXTURES AND RENDERBUFFERS\n features.add('texture-renderable-rgba32float-webgl');\n features.add('texture-renderable-float32-webgl');\n features.add('texture-renderable-float16-webgl');\n\n // GLSL extensions\n features.add('glsl-frag-data');\n features.add('glsl-frag-depth');\n features.add('glsl-derivatives');\n features.add('glsl-texture-lod');\n\n return features;\n }\n\n copyExternalImageToTexture(options: {\n texture: Texture;\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'display-p3' | 'srgb';\n premultipliedAlpha?: boolean;\n\n source: ImageBitmap | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas;\n sourceX?: number;\n sourceY?: number;\n\n width?: number;\n height?: number;\n depth?: number;\n }): void {\n const {\n source,\n sourceX = 0,\n sourceY = 0,\n\n texture,\n mipLevel = 0,\n aspect = 'all',\n colorSpace = 'display-p3',\n premultipliedAlpha = false,\n // destinationX,\n // destinationY,\n // desitnationZ,\n\n width = texture.width,\n height = texture.height,\n depth = 1\n } = options;\n\n const webGpuTexture = texture as WebGPUTexture;\n\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 [\n width,\n height,\n depth\n ]\n )\n }\n}\n"],"mappings":"AAwBA,SAAQA,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,QAAO,eAAe;AAAC,SACtDC,YAAY;AAAA,SACZC,aAAa;AAAA,SACbC,qBAAqB;AAAA,SACrBC,aAAa;AAAA,SACbC,YAAY;AAAA,SACZC,oBAAoB;AAAA,SAEpBC,qBAAqB;AAAA,SACrBC,gBAAgB;AAAA,SAChBC,iBAAiB;AAAA,SAEjBC,iBAAiB;AAAA,SAEjBC,mBAAmB;AAI3B,OAAO,MAAMC,YAAY,SAASf,MAAM,CAAC;EAevC,OAAOgB,WAAWA,CAAA,EAAY;IAC5B,OAAOC,OAAO,CAAC,OAAOC,SAAS,KAAK,WAAW,IAAIA,SAAS,CAACC,GAAG,CAAC;EACnE;EA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;MACVC;IACF,CAAC,EAED,CACEC,KAAK,EACLC,MAAM,EACNC,KAAK,CAET,CAAC;EACH;AACF;AAzUajG,YAAY,CAYhBkC,IAAI,GAAW,QAAQ"}
|
|
1
|
+
{"version":3,"file":"webgpu-device.js","names":["Device","CanvasContext","log","uid","WebGPUBuffer","WebGPUTexture","WebGPUExternalTexture","WebGPUSampler","WebGPUShader","WebGPURenderPipeline","WebGPUComputePipeline","WebGPURenderPass","WebGPUComputePass","WebGPUVertexArray","WebGPUCanvasContext","WebGPUDevice","isSupported","Boolean","navigator","gpu","create","props","Error","groupCollapsed","adapter","requestAdapter","powerPreference","adapterInfo","requestAdapterInfo","probe","gpuDevice","requestDevice","requiredFeatures","features","canvas","pageLoaded","device","info","table","groupEnd","constructor","id","handle","lost","canvasContext","commandEncoder","renderPass","_info","_isLost","type","vendor","__brand","renderer","version","shadingLanguages","shadingLanguageVersions","glsl","wgsl","vendorMasked","rendererMasked","Promise","resolve","lostInfo","reason","message","height","width","container","_getFeatures","destroy","limits","isTextureFormatSupported","format","includes","isTextureFormatFilterable","isTextureFormatRenderable","isLost","createBuffer","newProps","_getBufferProps","_createTexture","createExternalTexture","createShader","createSampler","createRenderPipeline","createFramebuffer","createComputePipeline","createVertexArray","beginRenderPass","createCommandEncoder","beginComputePass","createTransformFeedback","createCanvasContext","getDefaultRenderPass","submit","_this$commandEncoder","commandBuffer","finish","queue","Set","has","delete","add","copyExternalImageToTexture","options","_this$handle","source","sourceX","sourceY","texture","mipLevel","aspect","colorSpace","premultipliedAlpha","depth","webGpuTexture","origin"],"sources":["../../src/adapter/webgpu-device.ts"],"sourcesContent":["// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n BufferProps,\n SamplerProps,\n ShaderProps,\n Texture,\n TextureProps,\n TextureFormat,\n ExternalTextureProps,\n FramebufferProps,\n RenderPipelineProps,\n ComputePipelineProps,\n RenderPassProps,\n ComputePassProps,\n // CommandEncoderProps,\n VertexArrayProps,\n TransformFeedback,\n TransformFeedbackProps\n} from '@luma.gl/core';\nimport {Device, CanvasContext, log, uid} from '@luma.gl/core';\nimport {WebGPUBuffer} from './resources/webgpu-buffer';\nimport {WebGPUTexture} from './resources/webgpu-texture';\nimport {WebGPUExternalTexture} from './resources/webgpu-external-texture';\nimport {WebGPUSampler} from './resources/webgpu-sampler';\nimport {WebGPUShader} from './resources/webgpu-shader';\nimport {WebGPURenderPipeline} from './resources/webgpu-render-pipeline';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\nimport {WebGPUComputePipeline} from './resources/webgpu-compute-pipeline';\nimport {WebGPURenderPass} from './resources/webgpu-render-pass';\nimport {WebGPUComputePass} from './resources/webgpu-compute-pass';\n// import {WebGPUCommandEncoder} from './resources/webgpu-command-encoder';\nimport {WebGPUVertexArray} from './resources/webgpu-vertex-array';\n\nimport {WebGPUCanvasContext} from './webgpu-canvas-context';\n// import {loadGlslangModule} from '../glsl/glslang';\n\n/** WebGPU Device implementation */\nexport class WebGPUDevice extends Device {\n readonly handle: GPUDevice;\n readonly adapter: GPUAdapter;\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n canvasContext: WebGPUCanvasContext | null = null;\n\n commandEncoder: GPUCommandEncoder | null = null;\n renderPass: WebGPURenderPass | null = null;\n\n private _info: DeviceInfo;\n private _isLost: boolean = false;\n\n static type: string = 'webgpu';\n\n /** Check if WebGPU is available */\n static isSupported(): boolean {\n return Boolean(typeof navigator !== 'undefined' && navigator.gpu);\n }\n\n static async create(props: DeviceProps): Promise<WebGPUDevice> {\n if (!navigator.gpu) {\n throw new Error(\n 'WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu'\n );\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\n const adapterInfo = await adapter.requestAdapterInfo();\n log.probe(1, 'Adapter available', adapterInfo)();\n\n const gpuDevice = await adapter.requestDevice({\n requiredFeatures: adapter.features as ReadonlySet<GPUFeatureName>\n // TODO ensure we obtain best limits\n // requiredLimits: adapter.limits\n });\n log.probe(1, 'GPUDevice available')();\n\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n log.probe(1, 'DOM is loaded')();\n }\n\n const device = new WebGPUDevice(gpuDevice, adapter, props);\n log.probe(1, 'Device created', device.info)();\n log.table(1, device.info)();\n log.groupEnd(1)();\n return device;\n }\n\n constructor(device: GPUDevice, adapter: GPUAdapter, props: DeviceProps) {\n super({...props, id: props.id || uid('webgpu-device')});\n this.handle = device;\n this.adapter = adapter;\n\n this._info = {\n type: 'webgpu',\n vendor: this.adapter.__brand,\n renderer: '',\n version: '',\n gpu: 'unknown', // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',\n shadingLanguages: ['wgsl'],\n shadingLanguageVersions: {\n glsl: '450',\n wgsl: '100'\n },\n vendorMasked: '',\n rendererMasked: ''\n };\n\n // \"Context\" loss handling\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(async resolve => {\n const lostInfo = await this.handle.lost;\n this._isLost = true;\n resolve({reason: 'destroyed', message: lostInfo.message});\n });\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 this.features = this._getFeatures();\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\n destroy(): void {\n this.handle.destroy();\n }\n\n get info(): DeviceInfo {\n return this._info;\n }\n\n features: Set<DeviceFeature>;\n\n get limits(): DeviceLimits {\n return this.handle.limits;\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return !format.includes('webgl');\n }\n\n /** @todo implement proper check? */\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n /** @todo implement proper check? */\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n get isLost(): boolean {\n return this._isLost;\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer {\n const newProps = this._getBufferProps(props);\n return new WebGPUBuffer(this, newProps);\n }\n\n _createTexture(props: TextureProps): WebGPUTexture {\n return new WebGPUTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): WebGPUExternalTexture {\n return new WebGPUExternalTexture(this, props);\n }\n\n createShader(props: ShaderProps): WebGPUShader {\n return new WebGPUShader(this, props);\n }\n\n createSampler(props: SamplerProps): WebGPUSampler {\n return new WebGPUSampler(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WebGPURenderPipeline {\n return new WebGPURenderPipeline(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WebGPUFramebuffer {\n throw new Error('Not implemented');\n }\n\n createComputePipeline(props: ComputePipelineProps): WebGPUComputePipeline {\n return new WebGPUComputePipeline(this, props);\n }\n\n createVertexArray(props: VertexArrayProps): WebGPUVertexArray {\n return new WebGPUVertexArray(this, props);\n }\n\n // WebGPU specifics\n\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: RenderPassProps): WebGPURenderPass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPURenderPass(this, props);\n }\n\n beginComputePass(props: ComputePassProps): WebGPUComputePass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPUComputePass(this, props);\n }\n\n // createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {\n // return new WebGPUCommandEncoder(this, props);\n // }\n\n createTransformFeedback(props: TransformFeedbackProps): TransformFeedback {\n throw new Error('Transform feedback not supported in WebGPU');\n }\n\n createCanvasContext(props: CanvasContextProps): WebGPUCanvasContext {\n return new WebGPUCanvasContext(this, this.adapter, props);\n }\n\n /**\n * Gets default renderpass encoder.\n * Creates a new encoder against default canvasContext if not already created\n * @note Called internally by Model.\n * @deprecated Create explicit pass with device.beginRenderPass\n */\n getDefaultRenderPass(): WebGPURenderPass {\n // this.renderPass =\n // this.renderPass ||\n // this.beginRenderPass({\n // framebuffer: this.canvasContext?.getCurrentFramebuffer()\n // });\n // return this.renderPass;\n throw new Error('a');\n }\n\n submit(): void {\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\n _getFeatures() {\n // WebGPU Features\n const features = new Set<DeviceFeature>(this.handle.features as Set<DeviceFeature>);\n\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\n // Add subsets\n if (features.has('texture-compression-bc')) {\n features.add('texture-compression-bc5-webgl');\n }\n\n features.add('webgpu');\n\n features.add('timer-query-webgl');\n\n // WEBGL1 SUPPORT\n features.add('vertex-array-object-webgl1');\n features.add('instanced-rendering-webgl1');\n features.add('multiple-render-targets-webgl1');\n features.add('index-uint32-webgl1');\n features.add('blend-minmax-webgl1');\n features.add('texture-blend-float-webgl1');\n\n // TEXTURES, RENDERBUFFERS\n features.add('texture-formats-srgb-webgl1');\n\n // TEXTURES\n features.add('texture-formats-depth-webgl1');\n features.add('texture-formats-float32-webgl1');\n features.add('texture-formats-float16-webgl1');\n\n features.add('texture-filter-linear-float32-webgl');\n features.add('texture-filter-linear-float16-webgl');\n features.add('texture-filter-anisotropic-webgl');\n\n // FRAMEBUFFERS, TEXTURES AND RENDERBUFFERS\n features.add('texture-renderable-rgba32float-webgl');\n features.add('texture-renderable-float32-webgl');\n features.add('texture-renderable-float16-webgl');\n\n // GLSL extensions\n features.add('glsl-frag-data');\n features.add('glsl-frag-depth');\n features.add('glsl-derivatives');\n features.add('glsl-texture-lod');\n\n return features;\n }\n\n copyExternalImageToTexture(options: {\n texture: Texture;\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'display-p3' | 'srgb';\n premultipliedAlpha?: boolean;\n\n source: ImageBitmap | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas;\n sourceX?: number;\n sourceY?: number;\n\n width?: number;\n height?: number;\n depth?: number;\n }): void {\n const {\n source,\n sourceX = 0,\n sourceY = 0,\n\n texture,\n mipLevel = 0,\n aspect = 'all',\n colorSpace = 'display-p3',\n premultipliedAlpha = false,\n // destinationX,\n // destinationY,\n // desitnationZ,\n\n width = texture.width,\n height = texture.height,\n depth = 1\n } = options;\n\n const webGpuTexture = texture as WebGPUTexture;\n\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}\n"],"mappings":"AA0BA,SAAQA,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,QAAO,eAAe;AAAC,SACtDC,YAAY;AAAA,SACZC,aAAa;AAAA,SACbC,qBAAqB;AAAA,SACrBC,aAAa;AAAA,SACbC,YAAY;AAAA,SACZC,oBAAoB;AAAA,SAEpBC,qBAAqB;AAAA,SACrBC,gBAAgB;AAAA,SAChBC,iBAAiB;AAAA,SAEjBC,iBAAiB;AAAA,SAEjBC,mBAAmB;AAI3B,OAAO,MAAMC,YAAY,SAASf,MAAM,CAAC;EAevC,OAA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X,MAAMW,aAAa,GAAGN,OAAwB;IAE9C,CAAAJ,YAAA,OAAI,CAAC/D,MAAM,cAAA+D,YAAA,uBAAXA,YAAA,CAAaP,KAAK,CAACK,0BAA0B,CAE3C;MACEG,MAAM;MACNU,MAAM,EAAE,CAACT,OAAO,EAAEC,OAAO;IAC3B,CAAC,EAED;MACEC,OAAO,EAAEM,aAAa,CAACzE,MAAM;MAC7B0E,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;MACjBN,QAAQ;MACRC,MAAM;MACNC,UAAU;MACVC;IACF,CAAC,EAED,CAAC/C,KAAK,EAAED,MAAM,EAAEiD,KAAK,CACvB,CAAC;EACH;AACF;AA9UanG,YAAY,CAYhBkC,IAAI,GAAW,QAAQ"}
|
package/dist/dist.dev.js
CHANGED
|
@@ -1138,10 +1138,10 @@ var __exports__ = (() => {
|
|
|
1138
1138
|
// Device loss
|
|
1139
1139
|
/** `true` if device is already lost */
|
|
1140
1140
|
/** Promise that resolves when device is lost */
|
|
1141
|
-
/**
|
|
1142
|
-
* Trigger device loss.
|
|
1143
|
-
* @returns `true` if context loss could actually be triggered.
|
|
1144
|
-
* @note primarily intended for testing how application reacts to device loss
|
|
1141
|
+
/**
|
|
1142
|
+
* Trigger device loss.
|
|
1143
|
+
* @returns `true` if context loss could actually be triggered.
|
|
1144
|
+
* @note primarily intended for testing how application reacts to device loss
|
|
1145
1145
|
*/
|
|
1146
1146
|
loseDevice() {
|
|
1147
1147
|
return false;
|
|
@@ -1170,9 +1170,10 @@ var __exports__ = (() => {
|
|
|
1170
1170
|
}
|
|
1171
1171
|
/** Create a temporary texture view of a video source */
|
|
1172
1172
|
/** Create a sampler */
|
|
1173
|
+
/** Create a Framebuffer. Must have at least one attachment. */
|
|
1173
1174
|
/** Create a shader */
|
|
1174
1175
|
/** Create a render pipeline (aka program) */
|
|
1175
|
-
/** Create a compute pipeline (aka program) */
|
|
1176
|
+
/** Create a compute pipeline (aka program). WebGPU only. */
|
|
1176
1177
|
createCommandEncoder(props = {}) {
|
|
1177
1178
|
throw new Error("not implemented");
|
|
1178
1179
|
}
|
|
@@ -1180,7 +1181,8 @@ var __exports__ = (() => {
|
|
|
1180
1181
|
/** Create a RenderPass */
|
|
1181
1182
|
/** Create a ComputePass */
|
|
1182
1183
|
/** Get a renderpass that is set up to render to the primary CanvasContext */
|
|
1183
|
-
|
|
1184
|
+
/** Create a transform feedback (immutable set of output buffer bindings). WebGL 2 only. */
|
|
1185
|
+
// Implementation
|
|
1184
1186
|
_getBufferProps(props) {
|
|
1185
1187
|
if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {
|
|
1186
1188
|
props = {
|
|
@@ -1795,10 +1797,10 @@ var __exports__ = (() => {
|
|
|
1795
1797
|
this.bufferLayout = this.props.bufferLayout || [];
|
|
1796
1798
|
}
|
|
1797
1799
|
/** Set bindings (stored on pipeline and set before each call) */
|
|
1798
|
-
/** Uniforms
|
|
1800
|
+
/** Uniforms
|
|
1799
1801
|
* @deprecated Only supported on WebGL devices.
|
|
1800
1802
|
* @note textures, samplers and uniform buffers should be set via `setBindings()`, these are not considered uniforms.
|
|
1801
|
-
* @note In WebGL uniforms have a performance penalty, they are reset before each call to enable pipeline sharing.
|
|
1803
|
+
* @note In WebGL uniforms have a performance penalty, they are reset before each call to enable pipeline sharing.
|
|
1802
1804
|
*/
|
|
1803
1805
|
/** Draw call */
|
|
1804
1806
|
};
|
|
@@ -2243,7 +2245,7 @@ var __exports__ = (() => {
|
|
|
2243
2245
|
const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);
|
|
2244
2246
|
tempBuffer.handle.unmap();
|
|
2245
2247
|
tempBuffer.destroy();
|
|
2246
|
-
return arrayBuffer;
|
|
2248
|
+
return new Uint8Array(arrayBuffer);
|
|
2247
2249
|
}
|
|
2248
2250
|
_writeMapped(typedArray) {
|
|
2249
2251
|
const arrayBuffer = this.handle.getMappedRange();
|
|
@@ -3413,7 +3415,10 @@ var __exports__ = (() => {
|
|
|
3413
3415
|
});
|
|
3414
3416
|
});
|
|
3415
3417
|
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, {
|
|
3416
|
-
canvas: props.canvas
|
|
3418
|
+
canvas: props.canvas,
|
|
3419
|
+
height: props.height,
|
|
3420
|
+
width: props.width,
|
|
3421
|
+
container: props.container
|
|
3417
3422
|
});
|
|
3418
3423
|
this.features = this._getFeatures();
|
|
3419
3424
|
}
|
|
@@ -3488,6 +3493,9 @@ var __exports__ = (() => {
|
|
|
3488
3493
|
// createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {
|
|
3489
3494
|
// return new WebGPUCommandEncoder(this, props);
|
|
3490
3495
|
// }
|
|
3496
|
+
createTransformFeedback(props) {
|
|
3497
|
+
throw new Error("Transform feedback not supported in WebGPU");
|
|
3498
|
+
}
|
|
3491
3499
|
createCanvasContext(props) {
|
|
3492
3500
|
return new WebGPUCanvasContext(this, this.adapter, props);
|
|
3493
3501
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -117,7 +117,7 @@ var WebGPUBuffer = class extends import_core.Buffer {
|
|
|
117
117
|
const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);
|
|
118
118
|
tempBuffer.handle.unmap();
|
|
119
119
|
tempBuffer.destroy();
|
|
120
|
-
return arrayBuffer;
|
|
120
|
+
return new Uint8Array(arrayBuffer);
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
_writeMapped(typedArray) {
|
|
@@ -1307,7 +1307,12 @@ var _WebGPUDevice = class extends import_core15.Device {
|
|
|
1307
1307
|
this._isLost = true;
|
|
1308
1308
|
resolve({ reason: "destroyed", message: lostInfo.message });
|
|
1309
1309
|
}));
|
|
1310
|
-
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, {
|
|
1310
|
+
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, {
|
|
1311
|
+
canvas: props.canvas,
|
|
1312
|
+
height: props.height,
|
|
1313
|
+
width: props.width,
|
|
1314
|
+
container: props.container
|
|
1315
|
+
});
|
|
1311
1316
|
this.features = this._getFeatures();
|
|
1312
1317
|
}
|
|
1313
1318
|
/** Check if WebGPU is available */
|
|
@@ -1419,6 +1424,9 @@ var _WebGPUDevice = class extends import_core15.Device {
|
|
|
1419
1424
|
// createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {
|
|
1420
1425
|
// return new WebGPUCommandEncoder(this, props);
|
|
1421
1426
|
// }
|
|
1427
|
+
createTransformFeedback(props) {
|
|
1428
|
+
throw new Error("Transform feedback not supported in WebGPU");
|
|
1429
|
+
}
|
|
1422
1430
|
createCanvasContext(props) {
|
|
1423
1431
|
return new WebGPUCanvasContext(this, this.adapter, props);
|
|
1424
1432
|
}
|
|
@@ -1508,11 +1516,7 @@ var _WebGPUDevice = class extends import_core15.Device {
|
|
|
1508
1516
|
premultipliedAlpha
|
|
1509
1517
|
},
|
|
1510
1518
|
// copySize: GPUExtent3D
|
|
1511
|
-
[
|
|
1512
|
-
width,
|
|
1513
|
-
height,
|
|
1514
|
-
depth
|
|
1515
|
-
]
|
|
1519
|
+
[width, height, depth]
|
|
1516
1520
|
);
|
|
1517
1521
|
}
|
|
1518
1522
|
};
|
package/dist.min.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
var __exports__=(()=>{var Vr=Object.create;var Re=Object.defineProperty;var zr=Object.getOwnPropertyDescriptor;var Hr=Object.getOwnPropertyNames;var $r=Object.getPrototypeOf,Yr=Object.prototype.hasOwnProperty;var Qe=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports),Kr=(t,n)=>{for(var e in n)Re(t,e,{get:n[e],enumerable:!0})},mt=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Hr(n))!Yr.call(t,i)&&i!==e&&Re(t,i,{get:()=>n[i],enumerable:!(r=zr(n,i))||r.enumerable});return t};var et=(t,n,e)=>(e=t!=null?Vr($r(t)):{},mt(n||!t||!t.__esModule?Re(e,"default",{value:t,enumerable:!0}):e,t)),qr=t=>mt(Re({},"__esModule",{value:!0}),t);var yt=Qe((si,K)=>{function rt(t){return K.exports=rt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},K.exports.__esModule=!0,K.exports.default=K.exports,rt(t)}K.exports=rt,K.exports.__esModule=!0,K.exports.default=K.exports});var wt=Qe((ui,q)=>{var bt=yt().default;function _t(){"use strict";q.exports=_t=function(){return t},q.exports.__esModule=!0,q.exports.default=q.exports;var t={},n=Object.prototype,e=n.hasOwnProperty,r=Object.defineProperty||function(p,f,l){p[f]=l.value},i=typeof Symbol=="function"?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(p,f,l){return Object.defineProperty(p,f,{value:l,enumerable:!0,configurable:!0,writable:!0}),p[f]}try{u({},"")}catch{u=function(l,y,P){return l[y]=P}}function c(p,f,l,y){var P=f&&f.prototype instanceof O?f:O,S=Object.create(P.prototype),E=new $(y||[]);return r(S,"_invoke",{value:Q(p,l,E)}),S}function v(p,f,l){try{return{type:"normal",arg:p.call(f,l)}}catch(y){return{type:"throw",arg:y}}}t.wrap=c;var h={};function O(){}function w(){}function T(){}var k={};u(k,o,function(){return this});var z=Object.getPrototypeOf,I=z&&z(z(re([])));I&&I!==n&&e.call(I,o)&&(k=I);var M=T.prototype=O.prototype=Object.create(k);function F(p){["next","throw","return"].forEach(function(f){u(p,f,function(l){return this._invoke(f,l)})})}function G(p,f){function l(P,S,E,D){var N=v(p[P],p,S);if(N.type!=="throw"){var ne=N.arg,X=ne.value;return X&&bt(X)=="object"&&e.call(X,"__await")?f.resolve(X.__await).then(function(oe){l("next",oe,E,D)},function(oe){l("throw",oe,E,D)}):f.resolve(X).then(function(oe){ne.value=oe,E(ne)},function(oe){return l("throw",oe,E,D)})}D(N.arg)}var y;r(this,"_invoke",{value:function(S,E){function D(){return new f(function(N,ne){l(S,E,N,ne)})}return y=y?y.then(D,D):D()}})}function Q(p,f,l){var y="suspendedStart";return function(P,S){if(y==="executing")throw new Error("Generator is already running");if(y==="completed"){if(P==="throw")throw S;return{value:void 0,done:!0}}for(l.method=P,l.arg=S;;){var E=l.delegate;if(E){var D=ce(E,l);if(D){if(D===h)continue;return D}}if(l.method==="next")l.sent=l._sent=l.arg;else if(l.method==="throw"){if(y==="suspendedStart")throw y="completed",l.arg;l.dispatchException(l.arg)}else l.method==="return"&&l.abrupt("return",l.arg);y="executing";var N=v(p,f,l);if(N.type==="normal"){if(y=l.done?"completed":"suspendedYield",N.arg===h)continue;return{value:N.arg,done:l.done}}N.type==="throw"&&(y="completed",l.method="throw",l.arg=N.arg)}}}function ce(p,f){var l=f.method,y=p.iterator[l];if(y===void 0)return f.delegate=null,l==="throw"&&p.iterator.return&&(f.method="return",f.arg=void 0,ce(p,f),f.method==="throw")||l!=="return"&&(f.method="throw",f.arg=new TypeError("The iterator does not provide a '"+l+"' method")),h;var P=v(y,p.iterator,f.arg);if(P.type==="throw")return f.method="throw",f.arg=P.arg,f.delegate=null,h;var S=P.arg;return S?S.done?(f[p.resultName]=S.value,f.next=p.nextLoc,f.method!=="return"&&(f.method="next",f.arg=void 0),f.delegate=null,h):S:(f.method="throw",f.arg=new TypeError("iterator result is not an object"),f.delegate=null,h)}function ee(p){var f={tryLoc:p[0]};1 in p&&(f.catchLoc=p[1]),2 in p&&(f.finallyLoc=p[2],f.afterLoc=p[3]),this.tryEntries.push(f)}function te(p){var f=p.completion||{};f.type="normal",delete f.arg,p.completion=f}function $(p){this.tryEntries=[{tryLoc:"root"}],p.forEach(ee,this),this.reset(!0)}function re(p){if(p||p===""){var f=p[o];if(f)return f.call(p);if(typeof p.next=="function")return p;if(!isNaN(p.length)){var l=-1,y=function P(){for(;++l<p.length;)if(e.call(p,l))return P.value=p[l],P.done=!1,P;return P.value=void 0,P.done=!0,P};return y.next=y}}throw new TypeError(bt(p)+" is not iterable")}return w.prototype=T,r(M,"constructor",{value:T,configurable:!0}),r(T,"constructor",{value:w,configurable:!0}),w.displayName=u(T,s,"GeneratorFunction"),t.isGeneratorFunction=function(p){var f=typeof p=="function"&&p.constructor;return!!f&&(f===w||(f.displayName||f.name)==="GeneratorFunction")},t.mark=function(p){return Object.setPrototypeOf?Object.setPrototypeOf(p,T):(p.__proto__=T,u(p,s,"GeneratorFunction")),p.prototype=Object.create(M),p},t.awrap=function(p){return{__await:p}},F(G.prototype),u(G.prototype,a,function(){return this}),t.AsyncIterator=G,t.async=function(p,f,l,y,P){P===void 0&&(P=Promise);var S=new G(c(p,f,l,y),P);return t.isGeneratorFunction(f)?S:S.next().then(function(E){return E.done?E.value:S.next()})},F(M),u(M,s,"Generator"),u(M,o,function(){return this}),u(M,"toString",function(){return"[object Generator]"}),t.keys=function(p){var f=Object(p),l=[];for(var y in f)l.push(y);return l.reverse(),function P(){for(;l.length;){var S=l.pop();if(S in f)return P.value=S,P.done=!1,P}return P.done=!0,P}},t.values=re,$.prototype={constructor:$,reset:function(f){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(te),!f)for(var l in this)l.charAt(0)==="t"&&e.call(this,l)&&!isNaN(+l.slice(1))&&(this[l]=void 0)},stop:function(){this.done=!0;var f=this.tryEntries[0].completion;if(f.type==="throw")throw f.arg;return this.rval},dispatchException:function(f){if(this.done)throw f;var l=this;function y(ne,X){return E.type="throw",E.arg=f,l.next=ne,X&&(l.method="next",l.arg=void 0),!!X}for(var P=this.tryEntries.length-1;P>=0;--P){var S=this.tryEntries[P],E=S.completion;if(S.tryLoc==="root")return y("end");if(S.tryLoc<=this.prev){var D=e.call(S,"catchLoc"),N=e.call(S,"finallyLoc");if(D&&N){if(this.prev<S.catchLoc)return y(S.catchLoc,!0);if(this.prev<S.finallyLoc)return y(S.finallyLoc)}else if(D){if(this.prev<S.catchLoc)return y(S.catchLoc,!0)}else{if(!N)throw new Error("try statement without catch or finally");if(this.prev<S.finallyLoc)return y(S.finallyLoc)}}}},abrupt:function(f,l){for(var y=this.tryEntries.length-1;y>=0;--y){var P=this.tryEntries[y];if(P.tryLoc<=this.prev&&e.call(P,"finallyLoc")&&this.prev<P.finallyLoc){var S=P;break}}S&&(f==="break"||f==="continue")&&S.tryLoc<=l&&l<=S.finallyLoc&&(S=null);var E=S?S.completion:{};return E.type=f,E.arg=l,S?(this.method="next",this.next=S.finallyLoc,h):this.complete(E)},complete:function(f,l){if(f.type==="throw")throw f.arg;return f.type==="break"||f.type==="continue"?this.next=f.arg:f.type==="return"?(this.rval=this.arg=f.arg,this.method="return",this.next="end"):f.type==="normal"&&l&&(this.next=l),h},finish:function(f){for(var l=this.tryEntries.length-1;l>=0;--l){var y=this.tryEntries[l];if(y.finallyLoc===f)return this.complete(y.completion,y.afterLoc),te(y),h}},catch:function(f){for(var l=this.tryEntries.length-1;l>=0;--l){var y=this.tryEntries[l];if(y.tryLoc===f){var P=y.completion;if(P.type==="throw"){var S=P.arg;te(y)}return S}}throw new Error("illegal catch attempt")},delegateYield:function(f,l,y){return this.delegate={iterator:re(f),resultName:l,nextLoc:y},this.method==="next"&&(this.arg=void 0),h}},t}q.exports=_t,q.exports.__esModule=!0,q.exports.default=q.exports});var Ee=Qe((ci,St)=>{var Te=wt()();St.exports=Te;try{regeneratorRuntime=Te}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=Te:Function("r","regeneratorRuntime = r")(Te)}});var ko={};Kr(ko,{WebGPUBuffer:()=>qe,WebGPUDevice:()=>ht,WebGPUSampler:()=>W,WebGPUShader:()=>Je,WebGPUTexture:()=>Xe});function H(t){return H=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},H(t)}function tt(t,n){if(H(t)!=="object"||t===null)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var r=e.call(t,n||"default");if(H(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function be(t){var n=tt(t,"string");return H(n)==="symbol"?n:String(n)}function C(t,n,e){return n=be(n),n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function gt(t,n,e,r,i,o,a){try{var s=t[o](a),u=s.value}catch(c){e(c);return}s.done?n(u):Promise.resolve(u).then(r,i)}function Y(t){return function(){var n=this,e=arguments;return new Promise(function(r,i){var o=t.apply(n,e);function a(u){gt(o,r,i,a,s,"next",u)}function s(u){gt(o,r,i,a,s,"throw",u)}a(void 0)})}}function m(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function vt(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,be(r.key),r)}}function g(t,n,e){return n&&vt(t.prototype,n),e&&vt(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function _e(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function we(t,n){return we=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},we(t,n)}function b(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),n&&we(t,n)}function _(t,n){if(n&&(H(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _e(t)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(t)}var Ce=et(Ee(),1);function Se(t){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let n=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,e=t||n;return!!(e&&e.indexOf("Electron")>=0)}function j(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||Se()}var Xr=globalThis.self||globalThis.window||globalThis.global,fe=globalThis.window||globalThis.self||globalThis.global,Jr=globalThis.document||{},ie=globalThis.process||{},Zr=globalThis.console,Pt=globalThis.navigator||{};var Ae=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",mi=j();var nt=globalThis;function Be(t){if(!t&&!j())return"Node";if(Se(t))return"Electron";let n=t||Pt.userAgent||"";if(n.indexOf("Edge")>-1)return"Edge";let e=n.indexOf("MSIE ")!==-1,r=n.indexOf("Trident/")!==-1;return e||r?"IE":nt.chrome?"Chrome":nt.safari?"Safari":nt.mozInnerScreenX?"Firefox":"Unknown"}function Qr(t){try{let n=window[t],e="__storage_test__";return n.setItem(e,e),n.removeItem(e),n}catch{return null}}var je=class{constructor(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"sessionStorage";this.storage=void 0,this.id=void 0,this.config=void 0,this.storage=Qr(r),this.id=n,this.config=e,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(n){if(Object.assign(this.config,n),this.storage){let e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let n={};if(this.storage){let e=this.storage.getItem(this.id);n=e?JSON.parse(e):{}}return Object.assign(this.config,n),this}};function xt(t){let n;return t<10?n="".concat(t.toFixed(2),"ms"):t<100?n="".concat(t.toFixed(1),"ms"):t<1e3?n="".concat(t.toFixed(0),"ms"):n="".concat((t/1e3).toFixed(2),"s"),n}function Ot(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8,e=Math.max(n-t.length,0);return"".concat(" ".repeat(e)).concat(t)}function Ie(t,n,e){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:600,i=t.src.replace(/\(/g,"%28").replace(/\)/g,"%29");t.width>r&&(e=Math.min(e,r/t.width));let o=t.width*e,a=t.height*e,s=["font-size:1px;","padding:".concat(Math.floor(a/2),"px ").concat(Math.floor(o/2),"px;"),"line-height:".concat(a,"px;"),"background:url(".concat(i,");"),"background-size:".concat(o,"px ").concat(a,"px;"),"color:transparent;"].join("");return["".concat(n," %c+"),s]}var De;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(De||(De={}));var en=10;function Ct(t){return typeof t!="string"?t:(t=t.toUpperCase(),De[t]||De.WHITE)}function Rt(t,n,e){if(!j&&typeof t=="string"){if(n){let r=Ct(n);t="\x1B[".concat(r,"m").concat(t,"\x1B[39m")}if(e){let r=Ct(e);t="\x1B[".concat(r+en,"m").concat(t,"\x1B[49m")}}return t}function Tt(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:["constructor"],e=Object.getPrototypeOf(t),r=Object.getOwnPropertyNames(e),i=t;for(let o of r){let a=i[o];typeof a=="function"&&(n.find(s=>o===s)||(i[o]=a.bind(t)))}}function le(t,n){if(!t)throw new Error(n||"Assertion failed")}function ae(){let t;if(j()&&fe.performance){var n,e;t=fe===null||fe===void 0||(n=fe.performance)===null||n===void 0||(e=n.now)===null||e===void 0?void 0:e.call(n)}else if("hrtime"in ie){var r;let i=ie===null||ie===void 0||(r=ie.hrtime)===null||r===void 0?void 0:r.call(ie);t=i[0]*1e3+i[1]/1e6}else t=Date.now();return t}var pe={debug:j()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},tn={enabled:!0,level:0};function U(){}var Et={},At={once:!0},J=class{constructor(){let{id:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{id:""};this.id=void 0,this.VERSION=Ae,this._startTs=ae(),this._deltaTs=ae(),this._storage=void 0,this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=n,this.userData={},this._storage=new je("__probe-".concat(this.id,"__"),tn),this.timeStamp("".concat(this.id," started")),Tt(this),Object.seal(this)}set level(n){this.setLevel(n)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((ae()-this._startTs).toPrecision(10))}getDelta(){return Number((ae()-this._deltaTs).toPrecision(10))}set priority(n){this.level=n}get priority(){return this.level}getPriority(){return this.level}enable(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return this._storage.setConfiguration({enabled:n}),this}setLevel(n){return this._storage.setConfiguration({level:n}),this}get(n){return this._storage.config[n]}set(n,e){this._storage.setConfiguration({[n]:e})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(n,e){le(n,e)}warn(n){return this._getLogFunction(0,n,pe.warn,arguments,At)}error(n){return this._getLogFunction(0,n,pe.error,arguments)}deprecated(n,e){return this.warn("`".concat(n,"` is deprecated and will be removed in a later version. Use `").concat(e,"` instead"))}removed(n,e){return this.error("`".concat(n,"` has been removed. Use `").concat(e,"` instead"))}probe(n,e){return this._getLogFunction(n,e,pe.log,arguments,{time:!0,once:!0})}log(n,e){return this._getLogFunction(n,e,pe.debug,arguments)}info(n,e){return this._getLogFunction(n,e,console.info,arguments)}once(n,e){return this._getLogFunction(n,e,pe.debug||pe.info,arguments,At)}table(n,e,r){return e?this._getLogFunction(n,e,console.table||U,r&&[r],{tag:an(e)}):U}image(n){let{logLevel:e,priority:r,image:i,message:o="",scale:a=1}=n;return this._shouldLog(e||r)?j()?on({image:i,message:o,scale:a}):nn({image:i,message:o,scale:a}):U}time(n,e){return this._getLogFunction(n,e,console.time?console.time:console.info)}timeEnd(n,e){return this._getLogFunction(n,e,console.timeEnd?console.timeEnd:console.info)}timeStamp(n,e){return this._getLogFunction(n,e,console.timeStamp||U)}group(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{collapsed:!1},i=Bt({logLevel:n,message:e,opts:r}),{collapsed:o}=r;return i.method=(o?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.group(n,e,Object.assign({},r,{collapsed:!0}))}groupEnd(n){return this._getLogFunction(n,"",console.groupEnd||U)}withGroup(n,e,r){this.group(n,e)();try{r()}finally{this.groupEnd(n)()}}trace(){console.trace&&console.trace()}_shouldLog(n){return this.isEnabled()&&this.getLevel()>=jt(n)}_getLogFunction(n,e,r,i,o){if(this._shouldLog(n)){o=Bt({logLevel:n,message:e,args:i,opts:o}),r=r||o.method,le(r),o.total=this.getTotal(),o.delta=this.getDelta(),this._deltaTs=ae();let a=o.tag||o.message;if(o.once&&a)if(!Et[a])Et[a]=ae();else return U;return e=rn(this.id,o.message,o),r.bind(console,e,...o.args)}return U}};J.VERSION=Ae;function jt(t){if(!t)return 0;let n;switch(typeof t){case"number":n=t;break;case"object":n=t.logLevel||t.priority||0;break;default:return 0}return le(Number.isFinite(n)&&n>=0),n}function Bt(t){let{logLevel:n,message:e}=t;t.logLevel=jt(n);let r=t.args?Array.from(t.args):[];for(;r.length&&r.shift()!==e;);switch(typeof n){case"string":case"function":e!==void 0&&r.unshift(e),t.message=n;break;case"object":Object.assign(t,n);break;default:}typeof t.message=="function"&&(t.message=t.message());let i=typeof t.message;return le(i==="string"||i==="object"),Object.assign(t,{args:r},t.opts)}function rn(t,n,e){if(typeof n=="string"){let r=e.time?Ot(xt(e.total)):"";n=e.time?"".concat(t,": ").concat(r," ").concat(n):"".concat(t,": ").concat(n),n=Rt(n,e.color,e.background)}return n}function nn(t){let{image:n,message:e="",scale:r=1}=t;return console.warn("removed"),U}function on(t){let{image:n,message:e="",scale:r=1}=t;if(typeof n=="string"){let o=new Image;return o.onload=()=>{let a=Ie(o,e,r);console.log(...a)},o.src=n,U}let i=n.nodeName||"";if(i.toLowerCase()==="img")return console.log(...Ie(n,e,r)),U;if(i.toLowerCase()==="canvas"){let o=new Image;return o.onload=()=>console.log(...Ie(o,e,r)),o.src=n.toDataURL(),U}return U}function an(t){for(let n in t)for(let e in t[n])return e||"untitled";return"empty"}var $i=new J({id:"@probe.gl/log"});var x=new J({id:"luma.gl"});function Pe(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let n=process.hrtime();t=n[0]*1e3+n[1]/1e6}else t=Date.now();return t}var se=class{constructor(n,e){this.name=void 0,this.type=void 0,this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=n,this.type=e,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(n){return this.sampleSize=n,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(n){return this._count+=n,this._samples++,this._checkSampling(),this}subtractCount(n){return this._count-=n,this._samples++,this._checkSampling(),this}addTime(n){return this._time+=n,this.lastTiming=n,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Pe(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Pe()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var de=class{constructor(n){this.id=void 0,this.stats={},this.id=n.id,this.stats={},this._initializeStats(n.stats),Object.seal(this)}get(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"count";return this._getOrCreate({name:n,type:e})}get size(){return Object.keys(this.stats).length}reset(){for(let n of Object.values(this.stats))n.reset();return this}forEach(n){for(let e of Object.values(this.stats))n(e)}getTable(){let n={};return this.forEach(e=>{n[e.name]={time:e.time||0,count:e.count||0,average:e.getAverageTime()||0,hz:e.getHz()||0}}),n}_initializeStats(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(e=>this._getOrCreate(e))}_getOrCreate(n){let{name:e,type:r}=n,i=this.stats[e];return i||(n instanceof se?i=n:i=new se(e,r),this.stats[e]=i),i}};var sn=function(){function t(){m(this,t),this.stats=new Map}var n=t.prototype;return n.getStats=function(r){return this.get(r)},n.get=function(r){return this.stats.has(r)||this.stats.set(r,new de({id:r})),this.stats.get(r)},g(t)}(),Ge=new sn;function un(){var t=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",n="set luma.log.level=1 (or higher) to trace rendering";if(globalThis.luma&&globalThis.luma.VERSION!==t)throw new Error("luma.gl - multiple VERSIONs detected: ".concat(globalThis.luma.VERSION," vs ").concat(t));return globalThis.luma||(j()&&x.log(1,"luma.gl ".concat(t," - ").concat(n))(),globalThis.luma=globalThis.luma||{VERSION:t,version:t,log:x,stats:Ge}),t}var It=un();var ot={};function ue(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"id";ot[t]=ot[t]||1;var n=ot[t]++;return"".concat(t,"-").concat(n)}function Ne(t){var n=!0;for(var e in t){n=!1;break}return n}function Dt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function cn(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Dt(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Dt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var R=function(){function t(e,r,i){if(m(this,t),this.id=void 0,this.props=void 0,this.userData={},this.device=void 0,this._device=void 0,this.destroyed=!1,this.allocatedBytes=0,this._attachedResources=new Set,!e)throw new Error("no device");this._device=e,this.props=fn(r,i);var o=this.props.id!=="undefined"?this.props.id:ue(this[Symbol.toStringTag]);this.props.id=o,this.id=o,this.userData=this.props.userData||{},this.addStats()}var n=t.prototype;return n.destroy=function(){this.destroyResource()},n.delete=function(){return this.destroy(),this},n.toString=function(){return"".concat(this[Symbol.toStringTag]||this.constructor.name,"(").concat(this.id,")")},n.getProps=function(){return this.props},n.attachResource=function(r){this._attachedResources.add(r)},n.detachResource=function(r){this._attachedResources.delete(r)},n.destroyAttachedResource=function(r){this._attachedResources.delete(r)&&r.destroy()},n.destroyAttachedResources=function(){for(var r=0,i=Object.values(this._attachedResources);r<i.length;r++){var o=i[r];o.destroy()}this._attachedResources=new Set},n.destroyResource=function(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0},n.removeStats=function(){var r=this._device.statsManager.getStats("Resource Counts"),i=this[Symbol.toStringTag];r.get("".concat(i,"s Active")).decrementCount()},n.trackAllocatedMemory=function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this[Symbol.toStringTag],o=this._device.statsManager.getStats("Resource Counts");o.get("GPU Memory").addCount(r),o.get("".concat(i," Memory")).addCount(r),this.allocatedBytes=r},n.trackDeallocatedMemory=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this[Symbol.toStringTag],i=this._device.statsManager.getStats("Resource Counts");i.get("GPU Memory").subtractCount(this.allocatedBytes),i.get("".concat(r," Memory")).subtractCount(this.allocatedBytes),this.allocatedBytes=0},n.addStats=function(){var r=this._device.statsManager.getStats("Resource Counts"),i=this[Symbol.toStringTag];r.get("Resources Created").incrementCount(),r.get("".concat(i,"s Created")).incrementCount(),r.get("".concat(i,"s Active")).incrementCount()},g(t)}();R.defaultProps={id:"undefined",handle:void 0,userData:void 0};function fn(t,n){var e=cn({},n);for(var r in t)t[r]!==void 0&&(e[r]=t[r]);return e}var Nt;function Gt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function it(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Gt(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Gt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function ln(t){var n=pn();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function pn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Nt=Symbol.toStringTag;var A=function(t){b(e,t);var n=ln(e);function e(i,o){var a;m(this,e);var s=it({},o);return(o.usage||0)&e.INDEX&&!o.indexType&&(o.data instanceof Uint32Array?s.indexType="uint32":o.data instanceof Uint16Array&&(s.indexType="uint16")),a=n.call(this,i,s,e.defaultProps),a.usage=void 0,a.indexType=void 0,a.byteLength=void 0,a.usage=o.usage||0,a.indexType=s.indexType,a}var r=e.prototype;return r.write=function(o,a){throw new Error("not implemented")},r.readAsync=function(o,a){throw new Error("not implemented")},r.getData=function(){throw new Error("not implemented")},g(e,[{key:Nt,get:function(){return"Buffer"}}]),e}(R);A.defaultProps=it(it({},R.defaultProps),{},{usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1});A.MAP_READ=1;A.MAP_WRITE=2;A.COPY_SRC=4;A.COPY_DST=8;A.INDEX=16;A.VERTEX=32;A.UNIFORM=64;A.STORAGE=128;A.INDIRECT=256;A.QUERY_RESOLVE=512;var Mt;function Lt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function at(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Lt(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Lt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var dn={id:null,type:"best-available",canvas:null,container:null,webgl2:!0,webgl1:!0,manageState:!0,width:800,height:600,debug:Boolean(x.get("debug")),break:[],gl:null};Mt=Symbol.toStringTag;var Le=function(){function t(e){m(this,t),this.id=void 0,this.statsManager=Ge,this.props=void 0,this.userData={},this._lumaData={},this.info=void 0,this.lost=void 0,this.canvasContext=void 0,this.props=at(at({},dn),e),this.id=this.props.id||ue(this[Symbol.toStringTag].toLowerCase())}var n=t.prototype;return n.loseDevice=function(){return!1},n.getCanvasContext=function(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext},n.createTexture=function(r){return(r instanceof Promise||typeof r=="string")&&(r={data:r}),this._createTexture(r)},n.createCommandEncoder=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};throw new Error("not implemented")},n._getBufferProps=function(r){(r instanceof ArrayBuffer||ArrayBuffer.isView(r))&&(r={data:r});var i=at({},r);return(r.usage||0)&A.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?i.indexType="uint32":r.data instanceof Uint16Array?i.indexType="uint16":x.warn("indices buffer content must be of integer type")()),i},g(t,[{key:Mt,get:function(){return"Device"}}]),t}();Le.VERSION=It;function st(t){if(Array.isArray(t))return t}function ut(t,n){var e=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(e!=null){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(e=e.call(t)).next,n===0){if(Object(e)!==e)return;u=!1}else for(;!(u=(r=o.call(e)).done)&&(s.push(r.value),s.length!==n);u=!0);}catch(v){c=!0,i=v}finally{try{if(!u&&e.return!=null&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}function Me(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function ct(t,n){if(t){if(typeof t=="string")return Me(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return Me(t,n)}}function ft(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
8
8
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function B(t,n){return st(t)||ut(t,n)||ct(t,n)||ft()}function hn(t,n){var e=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=mn(t))||n&&t&&typeof t.length=="number"){e&&(t=e);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
9
9
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,s;return{s:function(){e=e.call(t)},n:function(){var c=e.next();return o=c.done,c},e:function(c){a=!0,s=c},f:function(){try{!o&&e.return!=null&&e.return()}finally{if(a)throw s}}}}function mn(t,n){if(t){if(typeof t=="string")return kt(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return kt(t,n)}}function kt(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function Ft(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Ut(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Ft(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Ft(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var gn=j()&&typeof document<"u",ke=function(){return gn&&document.readyState==="complete"},vn={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},he=function(){function t(e){var r=this;if(m(this,t),this.device=void 0,this.id=void 0,this.props=void 0,this.canvas=void 0,this.htmlCanvas=void 0,this.offscreenCanvas=void 0,this.type=void 0,this.width=1,this.height=1,this.resizeObserver=void 0,this._canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1},this.props=Ut(Ut({},vn),e),e=this.props,!j()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(e.canvas)typeof e.canvas=="string"?this.canvas=_n(e.canvas):this.canvas=e.canvas;else{var i,o,a=wn(e),s=bn(((i=e)===null||i===void 0?void 0:i.container)||null);s.insertBefore(a,s.firstChild),this.canvas=a,(o=e)!==null&&o!==void 0&&o.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(function(u){var c=hn(u),v;try{for(c.s();!(v=c.n()).done;){var h=v.value;h.target===r.canvas&&r.update()}}catch(O){c.e(O)}finally{c.f()}}),this.resizeObserver.observe(this.canvas))}var n=t.prototype;return n.getDevicePixelRatio=function(r){if(typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(r=r===void 0?this.props.useDevicePixels:r,!r||r<=0))return 1;if(r===!0){var i=typeof window<"u"&&window.devicePixelRatio;return i||1}return r},n.getPixelSize=function(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":var r=this.getDevicePixelRatio(),i=this.canvas;return i.parentElement?[i.clientWidth*r,i.clientHeight*r]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}},n.getAspect=function(){var r=this.getPixelSize(),i=B(r,2),o=i[0],a=i[1];return o/a},n.cssToDeviceRatio=function(){try{var r=this.getDrawingBufferSize(),i=B(r,1),o=i[0],a=this._canvasSizeInfo.clientWidth;return a?o/a:1}catch{return 1}},n.cssToDevicePixels=function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,o=this.cssToDeviceRatio(),a=this.getDrawingBufferSize(),s=B(a,2),u=s[0],c=s[1];return Sn(r,o,u,c,i)},n.setDevicePixelRatio=function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.htmlCanvas){var o="width"in i?i.width:this.htmlCanvas.clientWidth,a="height"in i?i.height:this.htmlCanvas.clientHeight;(!o||!a)&&(x.log(1,"Canvas clientWidth/clientHeight is 0")(),r=1,o=this.htmlCanvas.width||1,a=this.htmlCanvas.height||1);var s=this._canvasSizeInfo;if(s.clientWidth!==o||s.clientHeight!==a||s.devicePixelRatio!==r){var u=r,c=Math.floor(o*u),v=Math.floor(a*u);this.htmlCanvas.width=c,this.htmlCanvas.height=v;var h=this.getDrawingBufferSize(),O=B(h,2),w=O[0],T=O[1];(w!==c||T!==v)&&(u=Math.min(w/o,T/a),this.htmlCanvas.width=Math.floor(o*u),this.htmlCanvas.height=Math.floor(a*u),x.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=o,this._canvasSizeInfo.clientHeight=a,this._canvasSizeInfo.devicePixelRatio=r}}},n.getDrawingBufferSize=function(){var r=this.device.gl;if(!r)throw new Error("canvas size");return[r.drawingBufferWidth,r.drawingBufferHeight]},n._setAutoCreatedCanvasId=function(r){var i;((i=this.htmlCanvas)===null||i===void 0?void 0:i.id)==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=r)},g(t,null,[{key:"isPageLoaded",get:function(){return ke()}}]),t}();he.pageLoaded=yn();function yn(){return ke()||typeof window>"u"?Promise.resolve():new Promise(function(t){window.addEventListener("load",function(){return t()})})}function bn(t){if(typeof t=="string"){var n=document.getElementById(t);if(!n&&!ke())throw new Error("Accessing '".concat(t,"' before page was loaded"));if(!n)throw new Error("".concat(t," is not an HTML element"));return n}else if(t)return t;return document.body}function _n(t){var n=document.getElementById(t);if(!n&&!ke())throw new Error("Accessing '".concat(t,"' before page was loaded"));if(!(n instanceof HTMLCanvasElement))throw new Error("'".concat(n,"' is not a canvas element"));return n}function wn(t){var n=t.width,e=t.height,r=document.createElement("canvas");return r.id="lumagl-auto-created-canvas",r.width=n||1,r.height=e||1,r.style.width=Number.isFinite(n)?"".concat(n,"px"):"100%",r.style.height=Number.isFinite(e)?"".concat(e,"px"):"100%",r}function Sn(t,n,e,r,i){var o=t,a=Wt(o[0],n,e),s=Vt(o[1],n,r,i),u=Wt(o[0]+1,n,e),c=u===e-1?u:u-1;u=Vt(o[1]+1,n,r,i);var v;return i?(u=u===0?u:u+1,v=s,s=u):v=u===r-1?u:u-1,{x:a,y:s,width:Math.max(c-a+1,1),height:Math.max(v-s+1,1)}}function Wt(t,n,e){var r=Math.min(Math.round(t*n),e-1);return r}function Vt(t,n,e,r){return r?Math.max(0,e-1-Math.round(t*n)):Math.min(Math.round(t*n),e-1)}var $t;function zt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Ht(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?zt(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):zt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Pn(t){var n=xn();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function xn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}$t=Symbol.toStringTag;var L=function(t){b(e,t);var n=Pn(e);function e(r,i){var o,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.defaultProps;return m(this,e),o=n.call(this,r,i,a),o.dimension=void 0,o.format=void 0,o.width=void 0,o.height=void 0,o.depth=void 0,o.sampler=void 0,o.dimension=o.props.dimension,o.format=o.props.format,o.width=o.props.width,o.height=o.props.height,o.depth=o.props.depth,o}return g(e,[{key:$t,get:function(){return"Texture"}}]),e}(R);L.defaultProps=Ht(Ht({},R.defaultProps),{},{data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,sampler:{},compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0});L.COPY_SRC=1;L.COPY_DST=2;L.TEXTURE_BINDING=4;L.STORAGE_BINDING=8;L.RENDER_ATTACHMENT=16;var qt;function Yt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Kt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Yt(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Yt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function On(t){var n=Cn();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function Cn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}qt=Symbol.toStringTag;var Fe=function(t){b(e,t);var n=On(e);function e(r,i){return m(this,e),n.call(this,r,i,e.defaultProps)}return g(e,[{key:qt,get:function(){return"ExternalTexture"}}]),e}(R);Fe.defaultProps=Kt(Kt({},R.defaultProps),{},{source:null,colorSpace:"srgb"});var Zt;function Xt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Jt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Xt(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Xt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Rn(t){var n=Tn();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function Tn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Zt=Symbol.toStringTag;var Ue=function(t){b(e,t);var n=Rn(e);function e(r,i){var o;return m(this,e),o=n.call(this,r,i,e.defaultProps),o.stage=void 0,o.source=void 0,o.stage=o.props.stage,o.source=o.props.source,o}return g(e,[{key:Zt,get:function(){return"Shader"}}]),e}(R);Ue.defaultProps=Jt(Jt({},R.defaultProps),{},{stage:"vertex",source:"",sourceMap:null,language:"auto",shaderType:0});var tr;function Qt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function er(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Qt(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Qt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function En(t){var n=An();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function An(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}tr=Symbol.toStringTag;var me=function(t){b(e,t);var n=En(e);function e(r,i){return m(this,e),n.call(this,r,i,e.defaultProps)}return g(e,[{key:tr,get:function(){return"Sampler"}}]),e}(R);me.defaultProps=er(er({},R.defaultProps),{},{type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});var nr;function rr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function ge(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?rr(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):rr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Bn(t){var n=jn();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function jn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}nr=Symbol.toStringTag;var We=function(t){b(e,t);var n=Bn(e);function e(i){var o,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return m(this,e),o=n.call(this,i,a,e.defaultProps),o.width=void 0,o.height=void 0,o.colorAttachments=[],o.depthStencilAttachment=null,o.width=o.props.width,o.height=o.props.height,o}var r=e.prototype;return r.resize=function(o){var a=!o;if(o){var s=Array.isArray(o)?o:[o.width,o.height],u=B(s,2),c=u[0],v=u[1];a=a||v!==this.height||c!==this.width,this.width=c,this.height=v}a&&(x.log(2,"Resizing framebuffer ".concat(this.id," to ").concat(this.width,"x").concat(this.height))(),this.resizeAttachments(this.width,this.height))},r.autoCreateAttachmentTextures=function(){var o=this;if(this.colorAttachments=this.props.colorAttachments.map(function(s){if(typeof s=="string"){var u=o.createColorTexture(s);return o.attachResource(u),u}return s}),this.props.depthStencilAttachment)if(typeof this.props.depthStencilAttachment=="string"){var a=this.createDepthStencilTexture(this.props.depthStencilAttachment);this.attachResource(a),this.depthStencilAttachment=a}else this.depthStencilAttachment=this.props.depthStencilAttachment},r.createColorTexture=function(o){return this.device.createTexture({id:"color-attachment",usage:L.RENDER_ATTACHMENT,format:o,width:this.width,height:this.height})},r.createDepthStencilTexture=function(o){return this.device.createTexture({id:"depth-stencil-attachment",usage:L.RENDER_ATTACHMENT,format:o,width:this.width,height:this.height})},r.resizeAttachments=function(o,a){for(var s=0;s<this.colorAttachments.length;++s)if(this.colorAttachments[s]){var u=this.device._createTexture(ge(ge({},this.colorAttachments[s].props),{},{width:o,height:a}));this.destroyAttachedResource(this.colorAttachments[s]),this.colorAttachments[s]=u,this.attachResource(u)}if(this.depthStencilAttachment){var c=this.device._createTexture(ge(ge({},this.depthStencilAttachment.props),{},{width:o,height:a}));this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=c,this.attachResource(c)}},g(e,[{key:nr,get:function(){return"Framebuffer"}}]),e}(R);We.defaultProps=ge(ge({},R.defaultProps),{},{width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var ar;function or(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function ir(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?or(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):or(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function In(t){var n=Dn();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function Dn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}ar=Symbol.toStringTag;var Ve=function(t){b(e,t);var n=In(e);function e(r,i){var o;return m(this,e),o=n.call(this,r,i,e.defaultProps),o.hash="",o.vs=void 0,o.fs=void 0,o.shaderLayout=void 0,o.bufferLayout=void 0,o.shaderLayout=o.props.shaderLayout,o.bufferLayout=o.props.bufferLayout||[],o}return g(e,[{key:ar,get:function(){return"RenderPipeline"}}]),e}(R);Ve.defaultProps=ir(ir({},R.defaultProps),{},{vs:null,vsEntryPoint:"",vsConstants:{},fs:null,fsEntryPoint:"",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},vertexCount:0,instanceCount:0,bindings:{},uniforms:{}});var cr;function sr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function ur(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?sr(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):sr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Gn(t){var n=Nn();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function Nn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}cr=Symbol.toStringTag;var ze=function(t){b(e,t);var n=Gn(e);function e(r,i){var o;return m(this,e),o=n.call(this,r,i,e.defaultProps),o.hash="",o}return g(e,[{key:cr,get:function(){return"ComputePipeline"}}]),e}(R);ze.defaultProps=ur(ur({},R.defaultProps),{},{cs:void 0,csEntryPoint:void 0,csConstants:{},shaderLayout:[]});var pr;function fr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function lr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?fr(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):fr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Ln(t){var n=Mn();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function Mn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}pr=Symbol.toStringTag;var He=function(t){b(e,t);var n=Ln(e);function e(r,i){return m(this,e),n.call(this,r,i,e.defaultProps)}return g(e,[{key:pr,get:function(){return"RenderPass"}}]),e}(R);He.defaultProps=lr(lr({},R.defaultProps),{},{framebuffer:null,parameters:void 0,clearColor:[0,0,0,0],clearDepth:1,clearStencil:0,depthReadOnly:!1,stencilReadOnly:!1,discard:!1});var hr;function dr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function kn(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?dr(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):dr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Fn(t){var n=Un();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function Un(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}hr=Symbol.toStringTag;var $e=function(t){b(e,t);var n=Fn(e);function e(r,i){return m(this,e),n.call(this,r,i,R.defaultProps)}return g(e,[{key:hr,get:function(){return"ComputePass"}}]),e}(R);$e.defaultProps=kn({},R.defaultProps);function mr(t){var n=B(Vn[t],2),e=n[0],r=n[1],i=e==="i32"||e==="u32",o=e!=="u32",a=zn[e]*r,s=Wn(e,r);return{dataType:e,components:r,defaultVertexFormat:s,byteLength:a,integer:i,signed:o}}function Wn(t,n){var e;switch(t){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return n<=2?"float16x2":"float16x4"}return n===1?e:"".concat(e,"x").concat(n)}var Vn={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},zn={f32:4,f16:2,i32:4,u32:4};function vr(t){var n=gr[t],e=Hn(n),r=t.includes("norm"),i=!r&&!t.startsWith("float"),o=t.startsWith("s");return{dataType:gr[t],byteLength:e,integer:i,signed:o,normalized:r}}function Hn(t){var n=$n[t];return n}var gr={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},$n={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};function Z(t){var n;t.endsWith("-webgl")&&(t.replace("-webgl",""),n=!0);var e=t.split("x"),r=B(e,2),i=r[0],o=r[1],a=i,s=o?parseInt(o):1,u=vr(a),c={type:a,components:s,byteLength:u.byteLength*s,integer:u.integer,signed:u.signed,normalized:u.normalized};return n&&(c.webglOnly=!0),c}function xe(t,n){var e=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Yn(t))||n&&t&&typeof t.length=="number"){e&&(t=e);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
10
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,s;return{s:function(){e=e.call(t)},n:function(){var c=e.next();return o=c.done,c},e:function(c){a=!0,s=c},f:function(){try{!o&&e.return!=null&&e.return()}finally{if(a)throw s}}}}function Yn(t,n){if(t){if(typeof t=="string")return yr(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return yr(t,n)}}function yr(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function Ye(t,n){var e={},r=xe(t.attributes),i;try{for(r.s();!(i=r.n()).done;){var o=i.value;e[o.name]=Kn(t,n,o.name)}}catch(a){r.e(a)}finally{r.f()}return e}function br(t,n){for(var e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:16,r=Ye(t,n),i=new Array(e).fill(null),o=0,a=Object.values(r);o<a.length;o++){var s=a[o];i[s.location]=s}return i}function Kn(t,n,e){var r=qn(t,e),i=Xn(n,e);if(!r)return null;var o=mr(r.type),a=i?.vertexFormat||o.defaultVertexFormat,s=Z(a);return{attributeName:i?.attributeName||r.name,bufferName:i?.bufferName||r.name,location:r.location,shaderType:r.type,shaderDataType:o.dataType,shaderComponents:o.components,vertexFormat:a,bufferDataType:s.type,bufferComponents:s.components,normalized:s.normalized,integer:o.integer,stepMode:i?.stepMode||r.stepMode,byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function qn(t,n){var e=t.attributes.find(function(r){return r.name===n});return e||x.warn('shader layout attribute "'.concat(n,'" not present in shader')),e||null}function Xn(t,n){Jn(t);var e=Zn(t,n);return e||(e=Qn(t,n),e)?e:(x.warn('layout for attribute "'.concat(n,'" not present in buffer layout')),null)}function Jn(t){var n=xe(t),e;try{for(n.s();!(e=n.n()).done;){var r=e.value;(r.attributes&&r.format||!r.attributes&&!r.format)&&x.warn("BufferLayout ".concat(name," must have either 'attributes' or 'format' field"))}}catch(i){n.e(i)}finally{n.f()}}function Zn(t,n){var e=xe(t),r;try{for(e.s();!(r=e.n()).done;){var i=r.value;if(i.format&&i.name===n)return{attributeName:i.name,bufferName:n,stepMode:i.stepMode,vertexFormat:i.format,byteOffset:0,byteStride:i.byteStride||0}}}catch(o){e.e(o)}finally{e.f()}return null}function Qn(t,n){var e=xe(t),r;try{for(e.s();!(r=e.n()).done;){var i,o=r.value,a=o.byteStride;if(typeof o.byteStride!="number"){var s=xe(o.attributes||[]),u;try{for(s.s();!(u=s.n()).done;){var c=u.value,v=Z(c.format);a+=v.byteLength}}catch(O){s.e(O)}finally{s.f()}}var h=(i=o.attributes)===null||i===void 0?void 0:i.find(function(O){return O.attribute===n});if(h)return{attributeName:h.attribute,bufferName:o.name,stepMode:o.stepMode,vertexFormat:h.format,byteOffset:h.byteOffset,byteStride:a}}}catch(O){e.e(O)}finally{e.f()}return null}var Sr;function _r(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function wr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?_r(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):_r(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function eo(t){var n=to();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function to(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Sr=Symbol.toStringTag;var Ke=function(t){b(e,t);var n=eo(e);function e(r,i){var o;return m(this,e),o=n.call(this,r,i,e.defaultProps),o.maxVertexAttributes=void 0,o.attributeInfos=void 0,o.indexBuffer=null,o.attributes=void 0,o.maxVertexAttributes=r.limits.maxVertexAttributes,o.attributes=new Array(o.maxVertexAttributes).fill(null),o.attributeInfos=br(i.renderPipeline.shaderLayout,i.renderPipeline.bufferLayout,o.maxVertexAttributes),o}return g(e,[{key:Sr,get:function(){return"VertexArray"}}]),e}(R);Ke.defaultProps=wr(wr({},R.defaultProps),{},{renderPipeline:null});var lt=et(Ee(),1);function ro(t){var n=no();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function no(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function oo(t){var n;return t.byteLength||((n=t.data)===null||n===void 0?void 0:n.byteLength)||0}var qe=function(t){b(e,t);var n=ro(e);function e(i,o){var a;m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.byteLength=void 0,a.device=i,a.byteLength=oo(o);var s=Boolean(o.data),u=Math.ceil(a.byteLength/4)*4;return a.handle=a.props.handle||a.device.handle.createBuffer({size:u,usage:a.props.usage||GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:a.props.mappedAtCreation||s,label:a.props.id}),o.data&&a._writeMapped(o.data),s&&!o.mappedAtCreation&&a.handle.unmap(),a}var r=e.prototype;return r.destroy=function(){this.handle.destroy()},r.write=function(o){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.device.handle.queue.writeBuffer(this.handle,a,o.buffer,o.byteOffset,o.byteLength)},r.readAsync=function(){var i=Y(lt.default.mark(function a(){var s,u,c,v,h,O=arguments;return lt.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return s=O.length>0&&O[0]!==void 0?O[0]:0,u=O.length>1&&O[1]!==void 0?O[1]:this.byteLength,c=new e(this.device,{usage:A.MAP_READ|A.COPY_DST,byteLength:u}),v=this.device.handle.createCommandEncoder(),v.copyBufferToBuffer(this.handle,s,c.handle,0,u),this.device.handle.queue.submit([v.finish()]),T.next=8,c.handle.mapAsync(GPUMapMode.READ,s,u);case 8:return h=c.handle.getMappedRange().slice(0),c.handle.unmap(),c.destroy(),T.abrupt("return",h);case 12:case"end":return T.stop()}},a,this)}));function o(){return i.apply(this,arguments)}return o}(),r._writeMapped=function(o){var a=this.handle.getMappedRange();new o.constructor(a).set(o)},r.mapAsync=function(o){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=arguments.length>2?arguments[2]:void 0;return this.handle.mapAsync(o,a,s)},r.getMappedRange=function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,a=arguments.length>1?arguments[1]:void 0;return this.handle.getMappedRange(o,a)},r.unmap=function(){this.handle.unmap()},g(e)}(A);function ve(t){if(t.includes("webgl"))throw new Error("webgl-only format");return t}function Pr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function io(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Pr(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Pr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function ao(t){var n=so();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function so(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var W=function(t){b(e,t);var n=ao(e);function e(i,o){var a;m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.device=i;var s=io({},a.props);return s.type!=="comparison-sampler"&&delete s.compare,a.handle=a.handle||a.device.handle.createSampler(s),a.handle.label=a.props.id,a}var r=e.prototype;return r.destroy=function(){},g(e)}(me);function uo(t){var n=co();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function co(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var fo={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Xe=function(t){b(e,t);var n=uo(e);function e(i,o){var a;if(m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.view=void 0,a.sampler=void 0,a.height=void 0,a.width=void 0,typeof a.props.format=="number")throw new Error("number format");return a.device=i,a.handle=a.props.handle||a.createHandle(),a.props.data&&a.setData({data:a.props.data}),a.width=a.handle.width,a.height=a.handle.height,a.sampler=o.sampler instanceof W?o.sampler:new W(a.device,o.sampler),a.view=a.handle.createView({}),a}var r=e.prototype;return r.createHandle=function(){var o,a;if(typeof this.props.format=="number")throw new Error("number format");var s=this.props.width||((o=this.props.data)===null||o===void 0?void 0:o.width)||1,u=this.props.height||((a=this.props.data)===null||a===void 0?void 0:a.height)||1;return this.device.handle.createTexture({size:{width:s,height:u,depthOrArrayLayers:this.props.depth},dimension:fo[this.props.dimension],format:ve(this.props.format),usage:this.props.usage,mipLevelCount:this.props.mipLevels,sampleCount:this.props.samples})},r.destroy=function(){this.handle.destroy()},r.setSampler=function(o){return this.sampler=o instanceof W?o:new W(this.device,o),this},r.setData=function(o){return this.setImage({source:o.data})},r.setImage=function(o){var a=o.source,s=o.width,u=s===void 0?o.source.width:s,c=o.height,v=c===void 0?o.source.height:c,h=o.depth,O=h===void 0?1:h,w=o.sourceX,T=w===void 0?0:w,k=o.sourceY,z=k===void 0?0:k,I=o.mipLevel,M=I===void 0?0:I,F=o.x,G=F===void 0?0:F,Q=o.y,ce=Q===void 0?0:Q,ee=o.z,te=ee===void 0?0:ee,$=o.aspect,re=$===void 0?"all":$,p=o.colorSpace,f=p===void 0?"srgb":p,l=o.premultipliedAlpha,y=l===void 0?!1:l;return this.device.handle.queue.copyExternalImageToTexture({source:a,origin:[T,z]},{texture:this.handle,origin:[G,ce,te],mipLevel:M,aspect:re,colorSpace:f,premultipliedAlpha:y},[u,v,O]),{width:u,height:v}},g(e)}(L);function lo(t){var n=po();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function po(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var xr=function(t){b(e,t);var n=lo(e);function e(i,o){var a;return m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.sampler=void 0,a.device=i,a.handle=a.props.handle||a.device.handle.importExternalTexture({source:o.source,colorSpace:o.colorSpace}),a.sampler=null,a}var r=e.prototype;return r.destroy=function(){},r.setSampler=function(o){return this.sampler=o instanceof W?o:new W(this.device,o),this},g(e)}(Fe);var Oe=et(Ee(),1);function ho(t){var n=mo();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function mo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Je=function(t){b(e,t);var n=ho(e);function e(i,o){var a;return m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.device=i,a.device.handle.pushErrorScope("validation"),a.handle=a.props.handle||a.createHandle(),a.handle.label=a.props.id,a._checkCompilationError(a.device.handle.popErrorScope()),a}var r=e.prototype;return r._checkCompilationError=function(){var i=Y(Oe.default.mark(function a(s){var u,c;return Oe.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,s;case 2:if(u=h.sent,!u){h.next=9;break}return h.next=6,this.compilationInfo();case 6:throw c=h.sent,x.error("Shader compilation error: ".concat(u.message),c)(),new Error("Shader compilation error: ".concat(u.message));case 9:case"end":return h.stop()}},a,this)}));function o(a){return i.apply(this,arguments)}return o}(),r.destroy=function(){},r.createHandle=function(){var o=this,a=this.props,s=a.source,u=a.stage,c=this.props.language;switch(c==="auto"&&(c=s.includes("->")?"wgsl":"glsl"),c){case"wgsl":return this.device.handle.createShaderModule({code:s});case"glsl":return this.device.handle.createShaderModule({code:s,transform:function(h){return o.device.glslang.compileGLSL(h,u)}});default:throw new Error(c)}},r.compilationInfo=function(){var i=Y(Oe.default.mark(function a(){var s;return Oe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.handle.getCompilationInfo();case 2:return s=c.sent,c.abrupt("return",s.messages);case 4:case"end":return c.stop()}},a,this)}));function o(){return i.apply(this,arguments)}return o}(),g(e)}(Ue);function Or(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Cr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Or(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Or(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function V(t){return t.depthStencil=t.depthStencil||{format:"depth24plus",stencilFront:{},stencilBack:{},depthWriteEnabled:!1,depthCompare:"less-equal"},t.depthStencil}var go={cullMode:function(n,e,r){r.primitive=r.primitive||{},r.primitive.cullMode=e},frontFace:function(n,e,r){r.primitive=r.primitive||{},r.primitive.frontFace=e},depthWriteEnabled:function(n,e,r){var i=V(r);i.depthWriteEnabled=e},depthCompare:function(n,e,r){var i=V(r);i.depthCompare=e},depthFormat:function(n,e,r){var i=V(r);i.format=e},depthBias:function(n,e,r){var i=V(r);i.depthBias=e},depthBiasSlopeScale:function(n,e,r){var i=V(r);i.depthBiasSlopeScale=e},depthBiasClamp:function(n,e,r){var i=V(r);i.depthBiasClamp=e},stencilReadMask:function(n,e,r){var i=V(r);i.stencilReadMask=e},stencilWriteMask:function(n,e,r){var i=V(r);i.stencilWriteMask=e},stencilCompare:function(n,e,r){var i=V(r);i.stencilFront.compare=e,i.stencilBack.compare=e},stencilPassOperation:function(n,e,r){var i=V(r);i.stencilFront.passOp=e,i.stencilBack.passOp=e},stencilFailOperation:function(n,e,r){var i=V(r);i.stencilFront.failOp=e,i.stencilBack.failOp=e},stencilDepthFailOperation:function(n,e,r){var i=V(r);i.stencilFront.depthFailOp=e,i.stencilBack.depthFailOp=e},sampleCount:function(n,e,r){r.multisample=r.multisample||{},r.multisample.count=e},sampleMask:function(n,e,r){r.multisample=r.multisample||{},r.multisample.mask=e},sampleAlphaToCoverageEnabled:function(n,e,r){r.multisample=r.multisample||{},r.multisample.alphaToCoverageEnabled=e},colorMask:function(n,e,r){var i=Rr(r);i[0].writeMask=e},blendColorOperation:function(n,e,r){Rr(r)}},vo={primitive:{cullMode:"back",topology:"triangle-list"},vertex:{module:void 0,entryPoint:"main"},fragment:{module:void 0,entryPoint:"main",targets:[]},layout:"auto"};function Tr(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Object.assign(t,Cr(Cr({},vo),t)),yo(t,n)}function yo(t,n){for(var e=0,r=Object.entries(n);e<r.length;e++){var i=B(r[e],2),o=i[0],a=i[1],s=go[o];if(!s)throw new Error("Illegal parameter ".concat(o));s(o,a,t)}}function Rr(t){var n,e,r,i;if(t.fragment.targets=((n=t.fragment)===null||n===void 0?void 0:n.targets)||[],!Array.isArray((e=t.fragment)===null||e===void 0?void 0:e.targets))throw new Error("colorstate");if(((r=t.fragment)===null||r===void 0||(r=r.targets)===null||r===void 0?void 0:r.length)===0){var o;(o=t.fragment.targets)===null||o===void 0||o.push({})}return(i=t.fragment)===null||i===void 0?void 0:i.targets}function Er(t,n,e,r){var i=_o(r,e);return t.createBindGroup({layout:n,entries:i})}function bo(t,n){var e=t.bindings.find(function(r){return r.name===n});return e||x.warn("Binding ".concat(n," not set: Not found in shader layout."))(),e}function _o(t,n){for(var e=[],r=0,i=Object.entries(t);r<i.length;r++){var o=B(i[r],2),a=o[0],s=o[1],u=bo(n,a);u&&e.push(wo(s,u.location))}return e}function wo(t,n){if(t instanceof A)return{binding:n,resource:{buffer:t.handle}};if(t instanceof me)return{binding:n,resource:t.handle};if(t instanceof L)return{binding:n,resource:t.handle.createView()};throw new Error("invalid binding")}function ye(t,n){var e=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=So(t))||n&&t&&typeof t.length=="number"){e&&(t=e);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
11
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,s;return{s:function(){e=e.call(t)},n:function(){var c=e.next();return o=c.done,c},e:function(c){a=!0,s=c},f:function(){try{!o&&e.return!=null&&e.return()}finally{if(a)throw s}}}}function So(t,n){if(t){if(typeof t=="string")return Ar(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return Ar(t,n)}}function Ar(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function pt(t){if(t.endsWith("-webgl"))throw new Error("WebGPU does not support vertex format ".concat(t));return t}function jr(t,n){var e=Ye(t,n),r=[],i=new Set,o=ye(n),a;try{for(o.s();!(a=o.n()).done;){var s=a.value,u=[],c="vertex",v=0;if(s.attributes){var h=ye(s.attributes),O;try{for(h.s();!(O=h.n()).done;){var w=O.value,T=w.attribute,k=Br(t,T,i);c=k.stepMode||"vertex",u.push({format:pt(w.format||s.format),offset:w.byteOffset,shaderLocation:k.location}),v+=Z(s.format).byteLength}}catch(G){h.e(G)}finally{h.f()}}else{var z=Br(t,s.name,i);v=Z(s.format).byteLength,c=z.stepMode||"vertex",u.push({format:pt(s.format),offset:0,shaderLocation:z.location})}r.push({arrayStride:s.byteStride||v,stepMode:c||"vertex",attributes:u})}}catch(G){o.e(G)}finally{o.f()}var I=ye(t.attributes),M;try{for(I.s();!(M=I.n()).done;){var F=M.value;i.has(F.name)||r.push({arrayStride:Z("float32x3").byteLength,stepMode:F.stepMode||"vertex",attributes:[{format:pt("float32x3"),offset:0,shaderLocation:F.location}]})}}catch(G){I.e(G)}finally{I.f()}return r}function Ir(t,n){var e=new Set,r=0,i={},o=ye(n),a;try{for(o.s();!(a=o.n()).done;){var s=a.value;if("attributes"in s){var u=ye(s.attributes),c;try{for(u.s();!(c=u.n()).done;){var v=c.value;e.add(v.attribute)}}catch(T){u.e(T)}finally{u.f()}}else e.add(s.name);i[s.name]=r++}}catch(T){o.e(T)}finally{o.f()}var h=ye(t.attributes),O;try{for(h.s();!(O=h.n()).done;){var w=O.value;e.has(w.name)||(i[w.name]=r++)}}catch(T){h.e(T)}finally{h.f()}return i}function Br(t,n,e){var r=t.attributes.find(function(i){return i.name===n});if(!r)throw new Error("Unknown attribute ".concat(n));if(e.has(n))throw new Error("Duplicate attribute ".concat(n));return e.add(n),r}function Po(t){var n=xo();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function xo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Dr=function(t){b(e,t);var n=Po(e);function e(i,o){var a;if(m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.vs=void 0,a.fs=null,a._bufferSlots=void 0,a._buffers=void 0,a._indexBuffer=null,a._bindGroupLayout=null,a._bindGroup=null,a.device=i,a.handle=a.props.handle,!a.handle){var s=a._getRenderPipelineDescriptor();x.groupCollapsed(1,"new WebGPURenderPipeline(".concat(a.id,")"))(),x.probe(1,JSON.stringify(s,null,2))(),x.groupEnd(1)(),a.handle=a.device.handle.createRenderPipeline(s)}return a.handle.label=a.props.id,a.vs=o.vs,a.fs=o.fs,a._bufferSlots=Ir(a.props.shaderLayout,a.props.bufferLayout),a._buffers=new Array(Object.keys(a._bufferSlots).length).fill(null),a}var r=e.prototype;return r.destroy=function(){},r.setIndexBuffer=function(o){this._indexBuffer=o},r.setAttributes=function(o){for(var a=0,s=Object.entries(o);a<s.length;a++){var u=B(s[a],2),c=u[0],v=u[1],h=this._bufferSlots[c];if(h>=0)this._buffers[h]=v;else throw new Error("Setting attribute '".concat(c,"' not listed in shader layout for program ").concat(this.id))}},r.setConstantAttributes=function(o){throw new Error("not implemented")},r.setBindings=function(o){Ne(this.props.bindings)||(Object.assign(this.props.bindings,o),this._bindGroupLayout=this._bindGroupLayout||this.handle.getBindGroupLayout(0),this._bindGroup=Er(this.device.handle,this._bindGroupLayout,this.props.shaderLayout,this.props.bindings))},r.setUniforms=function(o){if(!Ne(o))throw new Error("WebGPU does not support uniforms")},r._getBuffers=function(){return this._buffers},r._getBindGroup=function(){return this._bindGroup},r._getRenderPipelineDescriptor=function(){var o={module:this.props.vs.handle,entryPoint:this.props.vsEntryPoint||"main",buffers:jr(this.props.shaderLayout,this.props.bufferLayout)},a;if(this.props.fs){var s;a={module:this.props.fs.handle,entryPoint:this.props.fsEntryPoint||"main",targets:[{format:ve((s=this.device)===null||s===void 0||(s=s.canvasContext)===null||s===void 0?void 0:s.format)}]}}switch(this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":throw new Error("WebGPU does not support primitive topology ".concat(this.props.topology));default:}var u={vertex:o,fragment:a,primitive:{topology:this.props.topology},layout:"auto"};return Tr(u,this.props.parameters),u},r.draw=function(o){var a=o.renderPass||this.device.getDefaultRenderPass();a.handle.setPipeline(this.handle);var s=this._getBindGroup();s&&a.handle.setBindGroup(0,s),this._setAttributeBuffers(a),o.indexCount?a.handle.drawIndexed(o.indexCount,o.instanceCount,o.firstIndex,o.baseVertex,o.firstInstance):a.handle.draw(o.vertexCount||0,o.instanceCount||1,o.firstInstance)},r._setAttributeBuffers=function(o){var a=this;this._indexBuffer&&o.handle.setIndexBuffer(this._indexBuffer.handle,this._indexBuffer.props.indexType);for(var s=this._getBuffers(),u=function(h){var O=s[h];if(!O){var w=a.props.shaderLayout.attributes.find(function(T){return T.location===h});throw new Error("No buffer provided for attribute '".concat(w?.name||"","' in Model '").concat(a.props.id,"'"))}o.handle.setVertexBuffer(h,O.handle)},c=0;c<s.length;++c)u(c)},g(e)}(Ve);function Oo(t){var n=Co();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function Co(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Gr=function(t){b(e,t);var n=Oo(e);function e(i,o){var a;m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.device=i;var s=a.props.cs.handle;return a.handle=a.props.handle||a.device.handle.createComputePipeline({label:a.props.id,compute:{module:s,entryPoint:a.props.csEntryPoint},layout:"auto"}),a}var r=e.prototype;return r._getBindGroupLayout=function(){return this.handle.getBindGroupLayout(0)},g(e)}(ze);function Ro(t){var n=To();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function To(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Nr=function(t){b(e,t);var n=Ro(e);function e(i){var o,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};m(this,e),o=n.call(this,i,a),o.device=void 0,o.handle=void 0,o.pipeline=null,o.device=i;var s=a.framebuffer||i.canvasContext.getCurrentFramebuffer(),u=o.getRenderPassDescriptor(s);return x.groupCollapsed(1,"new WebGPURenderPass(".concat(o.id,")"))(),x.probe(1,JSON.stringify(u,null,2))(),x.groupEnd(1)(),o.handle=o.props.handle||i.commandEncoder.beginRenderPass(u),o.handle.label=o.props.id,o}var r=e.prototype;return r.destroy=function(){},r.end=function(){this.handle.end()},r.setPipeline=function(o){this.pipeline=o,this.handle.setPipeline(this.pipeline.handle)},r.setBindings=function(o){var a,s;(a=this.pipeline)===null||a===void 0||a.setBindings(o);var u=(s=this.pipeline)===null||s===void 0?void 0:s._getBindGroup();u&&this.handle.setBindGroup(0,u)},r.setIndexBuffer=function(o,a){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,u=arguments.length>3?arguments[3]:void 0;this.handle.setIndexBuffer(o.handle,a,s,u)},r.setVertexBuffer=function(o,a){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;this.handle.setVertexBuffer(o,a.handle,s)},r.draw=function(o){o.indexCount?this.handle.drawIndexed(o.indexCount,o.instanceCount,o.firstIndex,o.baseVertex,o.firstInstance):this.handle.draw(o.vertexCount||0,o.instanceCount||1,o.firstIndex,o.firstInstance)},r.drawIndirect=function(){},r.setParameters=function(o){var a=o.blendConstant,s=o.stencilReference,u=o.scissorRect,c=o.viewport;a&&this.handle.setBlendConstant(a),s&&this.handle.setStencilReference(s),u&&this.handle.setScissorRect(u[0],u[1],u[2],u[3]),c&&this.handle.setViewport(c[0],c[1],c[2],c[3],c[4],c[5])},r.pushDebugGroup=function(o){this.handle.pushDebugGroup(o)},r.popDebugGroup=function(){this.handle.popDebugGroup()},r.insertDebugMarker=function(o){this.handle.insertDebugMarker(o)},r.getRenderPassDescriptor=function(o){var a=this,s={colorAttachments:[]};if(s.colorAttachments=o.colorAttachments.map(function(h){return{loadOp:a.props.clearColor!==!1?"clear":"load",colorClearValue:a.props.clearColor||[0,0,0,0],storeOp:a.props.discard?"discard":"store",view:h.handle.createView()}}),o.depthStencilAttachment){s.depthStencilAttachment={view:o.depthStencilAttachment.handle.createView()};var u=s.depthStencilAttachment;this.props.depthReadOnly&&(u.depthReadOnly=!0),u.depthClearValue=this.props.clearDepth||0;var c=!0;c&&(u.depthLoadOp=this.props.clearDepth!==!1?"clear":"load",u.depthStoreOp="store");var v=!1;v&&(u.stencilLoadOp=this.props.clearStencil!==!1?"clear":"load",u.stencilStoreOp="store")}return s},g(e)}(He);function Eo(t){var n=Ao();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function Ao(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Lr=function(t){b(e,t);var n=Eo(e);function e(i,o){var a,s;return m(this,e),s=n.call(this,i,o),s.device=void 0,s.handle=void 0,s._bindGroupLayout=null,s.device=i,s.handle=s.props.handle||((a=i.commandEncoder)===null||a===void 0?void 0:a.beginComputePass({label:s.props.id})),s}var r=e.prototype;return r.destroy=function(){},r.end=function(){this.handle.end()},r.setPipeline=function(o){var a=o;this.handle.setPipeline(a.handle),this._bindGroupLayout=a._getBindGroupLayout()},r.setBindings=function(o){throw new Error("fix me")},r.dispatch=function(o,a,s){this.handle.dispatchWorkgroups(o,a,s)},r.dispatchIndirect=function(o){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.handle.dispatchWorkgroupsIndirect(o.handle,a)},r.pushDebugGroup=function(o){this.handle.pushDebugGroup(o)},r.popDebugGroup=function(){this.handle.popDebugGroup()},r.insertDebugMarker=function(o){this.handle.insertDebugMarker(o)},g(e)}($e);var Mr;function Bo(t){var n=jo();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function jo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Mr=Symbol.toStringTag;var kr=function(t){b(e,t);var n=Bo(e);e.isConstantAttributeZeroSupported=function(o){return o.info.type==="webgl2"||Be()==="Chrome"};function e(i,o){var a;return m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.device=i,a}var r=e.prototype;return r.destroy=function(){},r.setIndexBuffer=function(o){this.indexBuffer=o},r.setBuffer=function(o,a){this.attributes[o]=a},r.setConstant=function(o,a){x.warn("".concat(this.id," constant attributes not supported on WebGPU"))},r.bindBeforeRender=function(o,a,s){var u=o,c=this.indexBuffer;u.handle.setIndexBuffer(c?.handle,c?.indexType);for(var v=0;v<this.maxVertexAttributes;v++){var h=this.attributes[v];u.handle.setVertexBuffer(v,h.handle)}},r.unbindAfterRender=function(o){},g(e,[{key:Mr,get:function(){return"WebGPUVertexArray"}}]),e}(Ke);function Io(t){var n=Do();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function Do(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Fr=function(t){b(e,t);var n=Io(e);function e(r,i){var o;return m(this,e),o=n.call(this,r,i),o.device=void 0,o.device=r,o.autoCreateAttachmentTextures(),o}return g(e)}(We);function Go(t){var n=No();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function No(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var dt=function(t){b(e,t);var n=Go(e);function e(i,o,a){var s;return m(this,e),s=n.call(this,a),s.device=void 0,s.gpuCanvasContext=void 0,s.format=navigator.gpu.getPreferredCanvasFormat(),s.depthStencilFormat="depth24plus",s.depthStencilAttachment=null,s.device=i,s.width=-1,s.height=-1,s._setAutoCreatedCanvasId("".concat(s.device.id,"-canvas")),s.gpuCanvasContext=s.canvas.getContext("webgpu"),s.format="bgra8unorm",s}var r=e.prototype;return r.destroy=function(){this.gpuCanvasContext.unconfigure()},r.getCurrentTexture=function(){return this.device._createTexture({id:"default-render-target",handle:this.gpuCanvasContext.getCurrentTexture()})},r.getCurrentFramebuffer=function(){this.update();var o=this.getCurrentTexture();return this.width=o.width,this.height=o.height,this._createDepthStencilAttachment(),new Fr(this.device,{colorAttachments:[o],depthStencilAttachment:this.depthStencilAttachment})},r.update=function(){var o=this.getPixelSize(),a=B(o,2),s=a[0],u=a[1],c=s!==this.width||u!==this.height;c&&(this.width=s,this.height=u,this.depthStencilAttachment&&(this.depthStencilAttachment.destroy(),this.depthStencilAttachment=null),this.gpuCanvasContext.configure({device:this.device.handle,format:ve(this.format),colorSpace:this.props.colorSpace,alphaMode:this.props.alphaMode}),x.log(1,"Resized to ".concat(this.width,"x").concat(this.height,"px"))())},r.resize=function(o){this.update()},r._createDepthStencilAttachment=function(){return this.depthStencilAttachment||(this.depthStencilAttachment=this.device.createTexture({id:"depth-stencil-target",format:this.depthStencilFormat,width:this.width,height:this.height,usage:GPUTextureUsage.RENDER_ATTACHMENT})),this.depthStencilAttachment},g(e)}(he);function Ur(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Wr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Ur(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Ur(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Lo(t){var n=Mo();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function Mo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ht=function(t){b(e,t);var n=Lo(e);e.isSupported=function(){return Boolean(typeof navigator<"u"&&navigator.gpu)},e.create=function(){var i=Y(Ce.default.mark(function a(s){var u,c,v,h;return Ce.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(navigator.gpu){w.next=2;break}throw new Error("WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu");case 2:return x.groupCollapsed(1,"WebGPUDevice created")(),w.next=5,navigator.gpu.requestAdapter({powerPreference:"high-performance"});case 5:if(u=w.sent,u){w.next=8;break}throw new Error("Failed to request WebGPU adapter");case 8:return w.next=10,u.requestAdapterInfo();case 10:return c=w.sent,x.probe(1,"Adapter available",c)(),w.next=14,u.requestDevice({requiredFeatures:u.features});case 14:if(v=w.sent,x.probe(1,"GPUDevice available")(),typeof s.canvas!="string"){w.next=20;break}return w.next=19,he.pageLoaded;case 19:x.probe(1,"DOM is loaded")();case 20:return h=new e(v,u,s),x.probe(1,"Device created",h.info)(),x.table(1,h.info)(),x.groupEnd(1)(),w.abrupt("return",h);case 25:case"end":return w.stop()}},a)}));function o(a){return i.apply(this,arguments)}return o}();function e(i,o,a){var s;return m(this,e),s=n.call(this,Wr(Wr({},a),{},{id:a.id||ue("webgpu-device")})),s.handle=void 0,s.adapter=void 0,s.lost=void 0,s.canvasContext=null,s.commandEncoder=null,s.renderPass=null,s._info=void 0,s._isLost=!1,s.features=void 0,s.handle=i,s.adapter=o,s._info={type:"webgpu",vendor:s.adapter.__brand,renderer:"",version:"",gpu:"unknown",shadingLanguages:["wgsl"],shadingLanguageVersions:{glsl:"450",wgsl:"100"},vendorMasked:"",rendererMasked:""},s.lost=new Promise(function(){var u=Y(Ce.default.mark(function c(v){var h;return Ce.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,s.handle.lost;case 2:h=w.sent,s._isLost=!0,v({reason:"destroyed",message:h.message});case 5:case"end":return w.stop()}},c)}));return function(c){return u.apply(this,arguments)}}()),s.canvasContext=new dt(_e(s),s.adapter,{canvas:a.canvas}),s.features=s._getFeatures(),s}var r=e.prototype;return r.destroy=function(){this.handle.destroy()},r.isTextureFormatSupported=function(o){return!o.includes("webgl")},r.isTextureFormatFilterable=function(o){return this.isTextureFormatSupported(o)},r.isTextureFormatRenderable=function(o){return this.isTextureFormatSupported(o)},r.createBuffer=function(o){var a=this._getBufferProps(o);return new qe(this,a)},r._createTexture=function(o){return new Xe(this,o)},r.createExternalTexture=function(o){return new xr(this,o)},r.createShader=function(o){return new Je(this,o)},r.createSampler=function(o){return new W(this,o)},r.createRenderPipeline=function(o){return new Dr(this,o)},r.createFramebuffer=function(o){throw new Error("Not implemented")},r.createComputePipeline=function(o){return new Gr(this,o)},r.createVertexArray=function(o){return new kr(this,o)},r.beginRenderPass=function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Nr(this,o)},r.beginComputePass=function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Lr(this,o)},r.createCanvasContext=function(o){return new dt(this,this.adapter,o)},r.getDefaultRenderPass=function(){throw new Error("a")},r.submit=function(){var o,a=(o=this.commandEncoder)===null||o===void 0?void 0:o.finish();a&&this.handle.queue.submit([a]),this.commandEncoder=null},r._getFeatures=function(){var o=new Set(this.handle.features);return o.has("depth-clamping")&&(o.delete("depth-clamping"),o.add("depth-clip-control")),o.has("texture-compression-bc")&&o.add("texture-compression-bc5-webgl"),o.add("webgpu"),o.add("timer-query-webgl"),o.add("vertex-array-object-webgl1"),o.add("instanced-rendering-webgl1"),o.add("multiple-render-targets-webgl1"),o.add("index-uint32-webgl1"),o.add("blend-minmax-webgl1"),o.add("texture-blend-float-webgl1"),o.add("texture-formats-srgb-webgl1"),o.add("texture-formats-depth-webgl1"),o.add("texture-formats-float32-webgl1"),o.add("texture-formats-float16-webgl1"),o.add("texture-filter-linear-float32-webgl"),o.add("texture-filter-linear-float16-webgl"),o.add("texture-filter-anisotropic-webgl"),o.add("texture-renderable-rgba32float-webgl"),o.add("texture-renderable-float32-webgl"),o.add("texture-renderable-float16-webgl"),o.add("glsl-frag-data"),o.add("glsl-frag-depth"),o.add("glsl-derivatives"),o.add("glsl-texture-lod"),o},r.copyExternalImageToTexture=function(o){var a,s=o.source,u=o.sourceX,c=u===void 0?0:u,v=o.sourceY,h=v===void 0?0:v,O=o.texture,w=o.mipLevel,T=w===void 0?0:w,k=o.aspect,z=k===void 0?"all":k,I=o.colorSpace,M=I===void 0?"display-p3":I,F=o.premultipliedAlpha,G=F===void 0?!1:F,Q=o.width,ce=Q===void 0?O.width:Q,ee=o.height,te=ee===void 0?O.height:ee,$=o.depth,re=$===void 0?1:$,p=O;(a=this.handle)===null||a===void 0||a.queue.copyExternalImageToTexture({source:s,origin:[c,h]},{texture:p.handle,origin:[0,0,0],mipLevel:T,aspect:z,colorSpace:M,premultipliedAlpha:G},[ce,te,re])},g(e,[{key:"info",get:function(){return this._info}},{key:"limits",get:function(){return this.handle.limits}},{key:"isLost",get:function(){return this._isLost}}]),e}(Le);ht.type="webgpu";return qr(ko);})();
|
|
10
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,s;return{s:function(){e=e.call(t)},n:function(){var c=e.next();return o=c.done,c},e:function(c){a=!0,s=c},f:function(){try{!o&&e.return!=null&&e.return()}finally{if(a)throw s}}}}function Yn(t,n){if(t){if(typeof t=="string")return yr(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return yr(t,n)}}function yr(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function Ye(t,n){var e={},r=xe(t.attributes),i;try{for(r.s();!(i=r.n()).done;){var o=i.value;e[o.name]=Kn(t,n,o.name)}}catch(a){r.e(a)}finally{r.f()}return e}function br(t,n){for(var e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:16,r=Ye(t,n),i=new Array(e).fill(null),o=0,a=Object.values(r);o<a.length;o++){var s=a[o];i[s.location]=s}return i}function Kn(t,n,e){var r=qn(t,e),i=Xn(n,e);if(!r)return null;var o=mr(r.type),a=i?.vertexFormat||o.defaultVertexFormat,s=Z(a);return{attributeName:i?.attributeName||r.name,bufferName:i?.bufferName||r.name,location:r.location,shaderType:r.type,shaderDataType:o.dataType,shaderComponents:o.components,vertexFormat:a,bufferDataType:s.type,bufferComponents:s.components,normalized:s.normalized,integer:o.integer,stepMode:i?.stepMode||r.stepMode,byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function qn(t,n){var e=t.attributes.find(function(r){return r.name===n});return e||x.warn('shader layout attribute "'.concat(n,'" not present in shader')),e||null}function Xn(t,n){Jn(t);var e=Zn(t,n);return e||(e=Qn(t,n),e)?e:(x.warn('layout for attribute "'.concat(n,'" not present in buffer layout')),null)}function Jn(t){var n=xe(t),e;try{for(n.s();!(e=n.n()).done;){var r=e.value;(r.attributes&&r.format||!r.attributes&&!r.format)&&x.warn("BufferLayout ".concat(name," must have either 'attributes' or 'format' field"))}}catch(i){n.e(i)}finally{n.f()}}function Zn(t,n){var e=xe(t),r;try{for(e.s();!(r=e.n()).done;){var i=r.value;if(i.format&&i.name===n)return{attributeName:i.name,bufferName:n,stepMode:i.stepMode,vertexFormat:i.format,byteOffset:0,byteStride:i.byteStride||0}}}catch(o){e.e(o)}finally{e.f()}return null}function Qn(t,n){var e=xe(t),r;try{for(e.s();!(r=e.n()).done;){var i,o=r.value,a=o.byteStride;if(typeof o.byteStride!="number"){var s=xe(o.attributes||[]),u;try{for(s.s();!(u=s.n()).done;){var c=u.value,v=Z(c.format);a+=v.byteLength}}catch(O){s.e(O)}finally{s.f()}}var h=(i=o.attributes)===null||i===void 0?void 0:i.find(function(O){return O.attribute===n});if(h)return{attributeName:h.attribute,bufferName:o.name,stepMode:o.stepMode,vertexFormat:h.format,byteOffset:h.byteOffset,byteStride:a}}}catch(O){e.e(O)}finally{e.f()}return null}var Sr;function _r(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function wr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?_r(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):_r(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function eo(t){var n=to();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function to(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Sr=Symbol.toStringTag;var Ke=function(t){b(e,t);var n=eo(e);function e(r,i){var o;return m(this,e),o=n.call(this,r,i,e.defaultProps),o.maxVertexAttributes=void 0,o.attributeInfos=void 0,o.indexBuffer=null,o.attributes=void 0,o.maxVertexAttributes=r.limits.maxVertexAttributes,o.attributes=new Array(o.maxVertexAttributes).fill(null),o.attributeInfos=br(i.renderPipeline.shaderLayout,i.renderPipeline.bufferLayout,o.maxVertexAttributes),o}return g(e,[{key:Sr,get:function(){return"VertexArray"}}]),e}(R);Ke.defaultProps=wr(wr({},R.defaultProps),{},{renderPipeline:null});var lt=et(Ee(),1);function ro(t){var n=no();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function no(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function oo(t){var n;return t.byteLength||((n=t.data)===null||n===void 0?void 0:n.byteLength)||0}var qe=function(t){b(e,t);var n=ro(e);function e(i,o){var a;m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.byteLength=void 0,a.device=i,a.byteLength=oo(o);var s=Boolean(o.data),u=Math.ceil(a.byteLength/4)*4;return a.handle=a.props.handle||a.device.handle.createBuffer({size:u,usage:a.props.usage||GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:a.props.mappedAtCreation||s,label:a.props.id}),o.data&&a._writeMapped(o.data),s&&!o.mappedAtCreation&&a.handle.unmap(),a}var r=e.prototype;return r.destroy=function(){this.handle.destroy()},r.write=function(o){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.device.handle.queue.writeBuffer(this.handle,a,o.buffer,o.byteOffset,o.byteLength)},r.readAsync=function(){var i=Y(lt.default.mark(function a(){var s,u,c,v,h,O=arguments;return lt.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return s=O.length>0&&O[0]!==void 0?O[0]:0,u=O.length>1&&O[1]!==void 0?O[1]:this.byteLength,c=new e(this.device,{usage:A.MAP_READ|A.COPY_DST,byteLength:u}),v=this.device.handle.createCommandEncoder(),v.copyBufferToBuffer(this.handle,s,c.handle,0,u),this.device.handle.queue.submit([v.finish()]),T.next=8,c.handle.mapAsync(GPUMapMode.READ,s,u);case 8:return h=c.handle.getMappedRange().slice(0),c.handle.unmap(),c.destroy(),T.abrupt("return",new Uint8Array(h));case 12:case"end":return T.stop()}},a,this)}));function o(){return i.apply(this,arguments)}return o}(),r._writeMapped=function(o){var a=this.handle.getMappedRange();new o.constructor(a).set(o)},r.mapAsync=function(o){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=arguments.length>2?arguments[2]:void 0;return this.handle.mapAsync(o,a,s)},r.getMappedRange=function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,a=arguments.length>1?arguments[1]:void 0;return this.handle.getMappedRange(o,a)},r.unmap=function(){this.handle.unmap()},g(e)}(A);function ve(t){if(t.includes("webgl"))throw new Error("webgl-only format");return t}function Pr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function io(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Pr(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Pr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function ao(t){var n=so();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function so(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var W=function(t){b(e,t);var n=ao(e);function e(i,o){var a;m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.device=i;var s=io({},a.props);return s.type!=="comparison-sampler"&&delete s.compare,a.handle=a.handle||a.device.handle.createSampler(s),a.handle.label=a.props.id,a}var r=e.prototype;return r.destroy=function(){},g(e)}(me);function uo(t){var n=co();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function co(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var fo={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Xe=function(t){b(e,t);var n=uo(e);function e(i,o){var a;if(m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.view=void 0,a.sampler=void 0,a.height=void 0,a.width=void 0,typeof a.props.format=="number")throw new Error("number format");return a.device=i,a.handle=a.props.handle||a.createHandle(),a.props.data&&a.setData({data:a.props.data}),a.width=a.handle.width,a.height=a.handle.height,a.sampler=o.sampler instanceof W?o.sampler:new W(a.device,o.sampler),a.view=a.handle.createView({}),a}var r=e.prototype;return r.createHandle=function(){var o,a;if(typeof this.props.format=="number")throw new Error("number format");var s=this.props.width||((o=this.props.data)===null||o===void 0?void 0:o.width)||1,u=this.props.height||((a=this.props.data)===null||a===void 0?void 0:a.height)||1;return this.device.handle.createTexture({size:{width:s,height:u,depthOrArrayLayers:this.props.depth},dimension:fo[this.props.dimension],format:ve(this.props.format),usage:this.props.usage,mipLevelCount:this.props.mipLevels,sampleCount:this.props.samples})},r.destroy=function(){this.handle.destroy()},r.setSampler=function(o){return this.sampler=o instanceof W?o:new W(this.device,o),this},r.setData=function(o){return this.setImage({source:o.data})},r.setImage=function(o){var a=o.source,s=o.width,u=s===void 0?o.source.width:s,c=o.height,v=c===void 0?o.source.height:c,h=o.depth,O=h===void 0?1:h,w=o.sourceX,T=w===void 0?0:w,k=o.sourceY,z=k===void 0?0:k,I=o.mipLevel,M=I===void 0?0:I,F=o.x,G=F===void 0?0:F,Q=o.y,ce=Q===void 0?0:Q,ee=o.z,te=ee===void 0?0:ee,$=o.aspect,re=$===void 0?"all":$,p=o.colorSpace,f=p===void 0?"srgb":p,l=o.premultipliedAlpha,y=l===void 0?!1:l;return this.device.handle.queue.copyExternalImageToTexture({source:a,origin:[T,z]},{texture:this.handle,origin:[G,ce,te],mipLevel:M,aspect:re,colorSpace:f,premultipliedAlpha:y},[u,v,O]),{width:u,height:v}},g(e)}(L);function lo(t){var n=po();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function po(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var xr=function(t){b(e,t);var n=lo(e);function e(i,o){var a;return m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.sampler=void 0,a.device=i,a.handle=a.props.handle||a.device.handle.importExternalTexture({source:o.source,colorSpace:o.colorSpace}),a.sampler=null,a}var r=e.prototype;return r.destroy=function(){},r.setSampler=function(o){return this.sampler=o instanceof W?o:new W(this.device,o),this},g(e)}(Fe);var Oe=et(Ee(),1);function ho(t){var n=mo();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function mo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Je=function(t){b(e,t);var n=ho(e);function e(i,o){var a;return m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.device=i,a.device.handle.pushErrorScope("validation"),a.handle=a.props.handle||a.createHandle(),a.handle.label=a.props.id,a._checkCompilationError(a.device.handle.popErrorScope()),a}var r=e.prototype;return r._checkCompilationError=function(){var i=Y(Oe.default.mark(function a(s){var u,c;return Oe.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,s;case 2:if(u=h.sent,!u){h.next=9;break}return h.next=6,this.compilationInfo();case 6:throw c=h.sent,x.error("Shader compilation error: ".concat(u.message),c)(),new Error("Shader compilation error: ".concat(u.message));case 9:case"end":return h.stop()}},a,this)}));function o(a){return i.apply(this,arguments)}return o}(),r.destroy=function(){},r.createHandle=function(){var o=this,a=this.props,s=a.source,u=a.stage,c=this.props.language;switch(c==="auto"&&(c=s.includes("->")?"wgsl":"glsl"),c){case"wgsl":return this.device.handle.createShaderModule({code:s});case"glsl":return this.device.handle.createShaderModule({code:s,transform:function(h){return o.device.glslang.compileGLSL(h,u)}});default:throw new Error(c)}},r.compilationInfo=function(){var i=Y(Oe.default.mark(function a(){var s;return Oe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.handle.getCompilationInfo();case 2:return s=c.sent,c.abrupt("return",s.messages);case 4:case"end":return c.stop()}},a,this)}));function o(){return i.apply(this,arguments)}return o}(),g(e)}(Ue);function Or(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Cr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Or(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Or(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function V(t){return t.depthStencil=t.depthStencil||{format:"depth24plus",stencilFront:{},stencilBack:{},depthWriteEnabled:!1,depthCompare:"less-equal"},t.depthStencil}var go={cullMode:function(n,e,r){r.primitive=r.primitive||{},r.primitive.cullMode=e},frontFace:function(n,e,r){r.primitive=r.primitive||{},r.primitive.frontFace=e},depthWriteEnabled:function(n,e,r){var i=V(r);i.depthWriteEnabled=e},depthCompare:function(n,e,r){var i=V(r);i.depthCompare=e},depthFormat:function(n,e,r){var i=V(r);i.format=e},depthBias:function(n,e,r){var i=V(r);i.depthBias=e},depthBiasSlopeScale:function(n,e,r){var i=V(r);i.depthBiasSlopeScale=e},depthBiasClamp:function(n,e,r){var i=V(r);i.depthBiasClamp=e},stencilReadMask:function(n,e,r){var i=V(r);i.stencilReadMask=e},stencilWriteMask:function(n,e,r){var i=V(r);i.stencilWriteMask=e},stencilCompare:function(n,e,r){var i=V(r);i.stencilFront.compare=e,i.stencilBack.compare=e},stencilPassOperation:function(n,e,r){var i=V(r);i.stencilFront.passOp=e,i.stencilBack.passOp=e},stencilFailOperation:function(n,e,r){var i=V(r);i.stencilFront.failOp=e,i.stencilBack.failOp=e},stencilDepthFailOperation:function(n,e,r){var i=V(r);i.stencilFront.depthFailOp=e,i.stencilBack.depthFailOp=e},sampleCount:function(n,e,r){r.multisample=r.multisample||{},r.multisample.count=e},sampleMask:function(n,e,r){r.multisample=r.multisample||{},r.multisample.mask=e},sampleAlphaToCoverageEnabled:function(n,e,r){r.multisample=r.multisample||{},r.multisample.alphaToCoverageEnabled=e},colorMask:function(n,e,r){var i=Rr(r);i[0].writeMask=e},blendColorOperation:function(n,e,r){Rr(r)}},vo={primitive:{cullMode:"back",topology:"triangle-list"},vertex:{module:void 0,entryPoint:"main"},fragment:{module:void 0,entryPoint:"main",targets:[]},layout:"auto"};function Tr(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Object.assign(t,Cr(Cr({},vo),t)),yo(t,n)}function yo(t,n){for(var e=0,r=Object.entries(n);e<r.length;e++){var i=B(r[e],2),o=i[0],a=i[1],s=go[o];if(!s)throw new Error("Illegal parameter ".concat(o));s(o,a,t)}}function Rr(t){var n,e,r,i;if(t.fragment.targets=((n=t.fragment)===null||n===void 0?void 0:n.targets)||[],!Array.isArray((e=t.fragment)===null||e===void 0?void 0:e.targets))throw new Error("colorstate");if(((r=t.fragment)===null||r===void 0||(r=r.targets)===null||r===void 0?void 0:r.length)===0){var o;(o=t.fragment.targets)===null||o===void 0||o.push({})}return(i=t.fragment)===null||i===void 0?void 0:i.targets}function Er(t,n,e,r){var i=_o(r,e);return t.createBindGroup({layout:n,entries:i})}function bo(t,n){var e=t.bindings.find(function(r){return r.name===n});return e||x.warn("Binding ".concat(n," not set: Not found in shader layout."))(),e}function _o(t,n){for(var e=[],r=0,i=Object.entries(t);r<i.length;r++){var o=B(i[r],2),a=o[0],s=o[1],u=bo(n,a);u&&e.push(wo(s,u.location))}return e}function wo(t,n){if(t instanceof A)return{binding:n,resource:{buffer:t.handle}};if(t instanceof me)return{binding:n,resource:t.handle};if(t instanceof L)return{binding:n,resource:t.handle.createView()};throw new Error("invalid binding")}function ye(t,n){var e=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=So(t))||n&&t&&typeof t.length=="number"){e&&(t=e);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
11
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,s;return{s:function(){e=e.call(t)},n:function(){var c=e.next();return o=c.done,c},e:function(c){a=!0,s=c},f:function(){try{!o&&e.return!=null&&e.return()}finally{if(a)throw s}}}}function So(t,n){if(t){if(typeof t=="string")return Ar(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return Ar(t,n)}}function Ar(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function pt(t){if(t.endsWith("-webgl"))throw new Error("WebGPU does not support vertex format ".concat(t));return t}function jr(t,n){var e=Ye(t,n),r=[],i=new Set,o=ye(n),a;try{for(o.s();!(a=o.n()).done;){var s=a.value,u=[],c="vertex",v=0;if(s.attributes){var h=ye(s.attributes),O;try{for(h.s();!(O=h.n()).done;){var w=O.value,T=w.attribute,k=Br(t,T,i);c=k.stepMode||"vertex",u.push({format:pt(w.format||s.format),offset:w.byteOffset,shaderLocation:k.location}),v+=Z(s.format).byteLength}}catch(G){h.e(G)}finally{h.f()}}else{var z=Br(t,s.name,i);v=Z(s.format).byteLength,c=z.stepMode||"vertex",u.push({format:pt(s.format),offset:0,shaderLocation:z.location})}r.push({arrayStride:s.byteStride||v,stepMode:c||"vertex",attributes:u})}}catch(G){o.e(G)}finally{o.f()}var I=ye(t.attributes),M;try{for(I.s();!(M=I.n()).done;){var F=M.value;i.has(F.name)||r.push({arrayStride:Z("float32x3").byteLength,stepMode:F.stepMode||"vertex",attributes:[{format:pt("float32x3"),offset:0,shaderLocation:F.location}]})}}catch(G){I.e(G)}finally{I.f()}return r}function Ir(t,n){var e=new Set,r=0,i={},o=ye(n),a;try{for(o.s();!(a=o.n()).done;){var s=a.value;if("attributes"in s){var u=ye(s.attributes),c;try{for(u.s();!(c=u.n()).done;){var v=c.value;e.add(v.attribute)}}catch(T){u.e(T)}finally{u.f()}}else e.add(s.name);i[s.name]=r++}}catch(T){o.e(T)}finally{o.f()}var h=ye(t.attributes),O;try{for(h.s();!(O=h.n()).done;){var w=O.value;e.has(w.name)||(i[w.name]=r++)}}catch(T){h.e(T)}finally{h.f()}return i}function Br(t,n,e){var r=t.attributes.find(function(i){return i.name===n});if(!r)throw new Error("Unknown attribute ".concat(n));if(e.has(n))throw new Error("Duplicate attribute ".concat(n));return e.add(n),r}function Po(t){var n=xo();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function xo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Dr=function(t){b(e,t);var n=Po(e);function e(i,o){var a;if(m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.vs=void 0,a.fs=null,a._bufferSlots=void 0,a._buffers=void 0,a._indexBuffer=null,a._bindGroupLayout=null,a._bindGroup=null,a.device=i,a.handle=a.props.handle,!a.handle){var s=a._getRenderPipelineDescriptor();x.groupCollapsed(1,"new WebGPURenderPipeline(".concat(a.id,")"))(),x.probe(1,JSON.stringify(s,null,2))(),x.groupEnd(1)(),a.handle=a.device.handle.createRenderPipeline(s)}return a.handle.label=a.props.id,a.vs=o.vs,a.fs=o.fs,a._bufferSlots=Ir(a.props.shaderLayout,a.props.bufferLayout),a._buffers=new Array(Object.keys(a._bufferSlots).length).fill(null),a}var r=e.prototype;return r.destroy=function(){},r.setIndexBuffer=function(o){this._indexBuffer=o},r.setAttributes=function(o){for(var a=0,s=Object.entries(o);a<s.length;a++){var u=B(s[a],2),c=u[0],v=u[1],h=this._bufferSlots[c];if(h>=0)this._buffers[h]=v;else throw new Error("Setting attribute '".concat(c,"' not listed in shader layout for program ").concat(this.id))}},r.setConstantAttributes=function(o){throw new Error("not implemented")},r.setBindings=function(o){Ne(this.props.bindings)||(Object.assign(this.props.bindings,o),this._bindGroupLayout=this._bindGroupLayout||this.handle.getBindGroupLayout(0),this._bindGroup=Er(this.device.handle,this._bindGroupLayout,this.props.shaderLayout,this.props.bindings))},r.setUniforms=function(o){if(!Ne(o))throw new Error("WebGPU does not support uniforms")},r._getBuffers=function(){return this._buffers},r._getBindGroup=function(){return this._bindGroup},r._getRenderPipelineDescriptor=function(){var o={module:this.props.vs.handle,entryPoint:this.props.vsEntryPoint||"main",buffers:jr(this.props.shaderLayout,this.props.bufferLayout)},a;if(this.props.fs){var s;a={module:this.props.fs.handle,entryPoint:this.props.fsEntryPoint||"main",targets:[{format:ve((s=this.device)===null||s===void 0||(s=s.canvasContext)===null||s===void 0?void 0:s.format)}]}}switch(this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":throw new Error("WebGPU does not support primitive topology ".concat(this.props.topology));default:}var u={vertex:o,fragment:a,primitive:{topology:this.props.topology},layout:"auto"};return Tr(u,this.props.parameters),u},r.draw=function(o){var a=o.renderPass||this.device.getDefaultRenderPass();a.handle.setPipeline(this.handle);var s=this._getBindGroup();s&&a.handle.setBindGroup(0,s),this._setAttributeBuffers(a),o.indexCount?a.handle.drawIndexed(o.indexCount,o.instanceCount,o.firstIndex,o.baseVertex,o.firstInstance):a.handle.draw(o.vertexCount||0,o.instanceCount||1,o.firstInstance)},r._setAttributeBuffers=function(o){var a=this;this._indexBuffer&&o.handle.setIndexBuffer(this._indexBuffer.handle,this._indexBuffer.props.indexType);for(var s=this._getBuffers(),u=function(h){var O=s[h];if(!O){var w=a.props.shaderLayout.attributes.find(function(T){return T.location===h});throw new Error("No buffer provided for attribute '".concat(w?.name||"","' in Model '").concat(a.props.id,"'"))}o.handle.setVertexBuffer(h,O.handle)},c=0;c<s.length;++c)u(c)},g(e)}(Ve);function Oo(t){var n=Co();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function Co(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Gr=function(t){b(e,t);var n=Oo(e);function e(i,o){var a;m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.device=i;var s=a.props.cs.handle;return a.handle=a.props.handle||a.device.handle.createComputePipeline({label:a.props.id,compute:{module:s,entryPoint:a.props.csEntryPoint},layout:"auto"}),a}var r=e.prototype;return r._getBindGroupLayout=function(){return this.handle.getBindGroupLayout(0)},g(e)}(ze);function Ro(t){var n=To();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function To(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Nr=function(t){b(e,t);var n=Ro(e);function e(i){var o,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};m(this,e),o=n.call(this,i,a),o.device=void 0,o.handle=void 0,o.pipeline=null,o.device=i;var s=a.framebuffer||i.canvasContext.getCurrentFramebuffer(),u=o.getRenderPassDescriptor(s);return x.groupCollapsed(1,"new WebGPURenderPass(".concat(o.id,")"))(),x.probe(1,JSON.stringify(u,null,2))(),x.groupEnd(1)(),o.handle=o.props.handle||i.commandEncoder.beginRenderPass(u),o.handle.label=o.props.id,o}var r=e.prototype;return r.destroy=function(){},r.end=function(){this.handle.end()},r.setPipeline=function(o){this.pipeline=o,this.handle.setPipeline(this.pipeline.handle)},r.setBindings=function(o){var a,s;(a=this.pipeline)===null||a===void 0||a.setBindings(o);var u=(s=this.pipeline)===null||s===void 0?void 0:s._getBindGroup();u&&this.handle.setBindGroup(0,u)},r.setIndexBuffer=function(o,a){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,u=arguments.length>3?arguments[3]:void 0;this.handle.setIndexBuffer(o.handle,a,s,u)},r.setVertexBuffer=function(o,a){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;this.handle.setVertexBuffer(o,a.handle,s)},r.draw=function(o){o.indexCount?this.handle.drawIndexed(o.indexCount,o.instanceCount,o.firstIndex,o.baseVertex,o.firstInstance):this.handle.draw(o.vertexCount||0,o.instanceCount||1,o.firstIndex,o.firstInstance)},r.drawIndirect=function(){},r.setParameters=function(o){var a=o.blendConstant,s=o.stencilReference,u=o.scissorRect,c=o.viewport;a&&this.handle.setBlendConstant(a),s&&this.handle.setStencilReference(s),u&&this.handle.setScissorRect(u[0],u[1],u[2],u[3]),c&&this.handle.setViewport(c[0],c[1],c[2],c[3],c[4],c[5])},r.pushDebugGroup=function(o){this.handle.pushDebugGroup(o)},r.popDebugGroup=function(){this.handle.popDebugGroup()},r.insertDebugMarker=function(o){this.handle.insertDebugMarker(o)},r.getRenderPassDescriptor=function(o){var a=this,s={colorAttachments:[]};if(s.colorAttachments=o.colorAttachments.map(function(h){return{loadOp:a.props.clearColor!==!1?"clear":"load",colorClearValue:a.props.clearColor||[0,0,0,0],storeOp:a.props.discard?"discard":"store",view:h.handle.createView()}}),o.depthStencilAttachment){s.depthStencilAttachment={view:o.depthStencilAttachment.handle.createView()};var u=s.depthStencilAttachment;this.props.depthReadOnly&&(u.depthReadOnly=!0),u.depthClearValue=this.props.clearDepth||0;var c=!0;c&&(u.depthLoadOp=this.props.clearDepth!==!1?"clear":"load",u.depthStoreOp="store");var v=!1;v&&(u.stencilLoadOp=this.props.clearStencil!==!1?"clear":"load",u.stencilStoreOp="store")}return s},g(e)}(He);function Eo(t){var n=Ao();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function Ao(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Lr=function(t){b(e,t);var n=Eo(e);function e(i,o){var a,s;return m(this,e),s=n.call(this,i,o),s.device=void 0,s.handle=void 0,s._bindGroupLayout=null,s.device=i,s.handle=s.props.handle||((a=i.commandEncoder)===null||a===void 0?void 0:a.beginComputePass({label:s.props.id})),s}var r=e.prototype;return r.destroy=function(){},r.end=function(){this.handle.end()},r.setPipeline=function(o){var a=o;this.handle.setPipeline(a.handle),this._bindGroupLayout=a._getBindGroupLayout()},r.setBindings=function(o){throw new Error("fix me")},r.dispatch=function(o,a,s){this.handle.dispatchWorkgroups(o,a,s)},r.dispatchIndirect=function(o){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.handle.dispatchWorkgroupsIndirect(o.handle,a)},r.pushDebugGroup=function(o){this.handle.pushDebugGroup(o)},r.popDebugGroup=function(){this.handle.popDebugGroup()},r.insertDebugMarker=function(o){this.handle.insertDebugMarker(o)},g(e)}($e);var Mr;function Bo(t){var n=jo();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function jo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Mr=Symbol.toStringTag;var kr=function(t){b(e,t);var n=Bo(e);e.isConstantAttributeZeroSupported=function(o){return o.info.type==="webgl2"||Be()==="Chrome"};function e(i,o){var a;return m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.device=i,a}var r=e.prototype;return r.destroy=function(){},r.setIndexBuffer=function(o){this.indexBuffer=o},r.setBuffer=function(o,a){this.attributes[o]=a},r.setConstant=function(o,a){x.warn("".concat(this.id," constant attributes not supported on WebGPU"))},r.bindBeforeRender=function(o,a,s){var u=o,c=this.indexBuffer;u.handle.setIndexBuffer(c?.handle,c?.indexType);for(var v=0;v<this.maxVertexAttributes;v++){var h=this.attributes[v];u.handle.setVertexBuffer(v,h.handle)}},r.unbindAfterRender=function(o){},g(e,[{key:Mr,get:function(){return"WebGPUVertexArray"}}]),e}(Ke);function Io(t){var n=Do();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function Do(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Fr=function(t){b(e,t);var n=Io(e);function e(r,i){var o;return m(this,e),o=n.call(this,r,i),o.device=void 0,o.device=r,o.autoCreateAttachmentTextures(),o}return g(e)}(We);function Go(t){var n=No();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function No(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var dt=function(t){b(e,t);var n=Go(e);function e(i,o,a){var s;return m(this,e),s=n.call(this,a),s.device=void 0,s.gpuCanvasContext=void 0,s.format=navigator.gpu.getPreferredCanvasFormat(),s.depthStencilFormat="depth24plus",s.depthStencilAttachment=null,s.device=i,s.width=-1,s.height=-1,s._setAutoCreatedCanvasId("".concat(s.device.id,"-canvas")),s.gpuCanvasContext=s.canvas.getContext("webgpu"),s.format="bgra8unorm",s}var r=e.prototype;return r.destroy=function(){this.gpuCanvasContext.unconfigure()},r.getCurrentTexture=function(){return this.device._createTexture({id:"default-render-target",handle:this.gpuCanvasContext.getCurrentTexture()})},r.getCurrentFramebuffer=function(){this.update();var o=this.getCurrentTexture();return this.width=o.width,this.height=o.height,this._createDepthStencilAttachment(),new Fr(this.device,{colorAttachments:[o],depthStencilAttachment:this.depthStencilAttachment})},r.update=function(){var o=this.getPixelSize(),a=B(o,2),s=a[0],u=a[1],c=s!==this.width||u!==this.height;c&&(this.width=s,this.height=u,this.depthStencilAttachment&&(this.depthStencilAttachment.destroy(),this.depthStencilAttachment=null),this.gpuCanvasContext.configure({device:this.device.handle,format:ve(this.format),colorSpace:this.props.colorSpace,alphaMode:this.props.alphaMode}),x.log(1,"Resized to ".concat(this.width,"x").concat(this.height,"px"))())},r.resize=function(o){this.update()},r._createDepthStencilAttachment=function(){return this.depthStencilAttachment||(this.depthStencilAttachment=this.device.createTexture({id:"depth-stencil-target",format:this.depthStencilFormat,width:this.width,height:this.height,usage:GPUTextureUsage.RENDER_ATTACHMENT})),this.depthStencilAttachment},g(e)}(he);function Ur(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Wr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Ur(Object(e),!0).forEach(function(r){C(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Ur(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Lo(t){var n=Mo();return function(){var r=d(t),i;if(n){var o=d(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return _(this,i)}}function Mo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ht=function(t){b(e,t);var n=Lo(e);e.isSupported=function(){return Boolean(typeof navigator<"u"&&navigator.gpu)},e.create=function(){var i=Y(Ce.default.mark(function a(s){var u,c,v,h;return Ce.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(navigator.gpu){w.next=2;break}throw new Error("WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu");case 2:return x.groupCollapsed(1,"WebGPUDevice created")(),w.next=5,navigator.gpu.requestAdapter({powerPreference:"high-performance"});case 5:if(u=w.sent,u){w.next=8;break}throw new Error("Failed to request WebGPU adapter");case 8:return w.next=10,u.requestAdapterInfo();case 10:return c=w.sent,x.probe(1,"Adapter available",c)(),w.next=14,u.requestDevice({requiredFeatures:u.features});case 14:if(v=w.sent,x.probe(1,"GPUDevice available")(),typeof s.canvas!="string"){w.next=20;break}return w.next=19,he.pageLoaded;case 19:x.probe(1,"DOM is loaded")();case 20:return h=new e(v,u,s),x.probe(1,"Device created",h.info)(),x.table(1,h.info)(),x.groupEnd(1)(),w.abrupt("return",h);case 25:case"end":return w.stop()}},a)}));function o(a){return i.apply(this,arguments)}return o}();function e(i,o,a){var s;return m(this,e),s=n.call(this,Wr(Wr({},a),{},{id:a.id||ue("webgpu-device")})),s.handle=void 0,s.adapter=void 0,s.lost=void 0,s.canvasContext=null,s.commandEncoder=null,s.renderPass=null,s._info=void 0,s._isLost=!1,s.features=void 0,s.handle=i,s.adapter=o,s._info={type:"webgpu",vendor:s.adapter.__brand,renderer:"",version:"",gpu:"unknown",shadingLanguages:["wgsl"],shadingLanguageVersions:{glsl:"450",wgsl:"100"},vendorMasked:"",rendererMasked:""},s.lost=new Promise(function(){var u=Y(Ce.default.mark(function c(v){var h;return Ce.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,s.handle.lost;case 2:h=w.sent,s._isLost=!0,v({reason:"destroyed",message:h.message});case 5:case"end":return w.stop()}},c)}));return function(c){return u.apply(this,arguments)}}()),s.canvasContext=new dt(_e(s),s.adapter,{canvas:a.canvas,height:a.height,width:a.width,container:a.container}),s.features=s._getFeatures(),s}var r=e.prototype;return r.destroy=function(){this.handle.destroy()},r.isTextureFormatSupported=function(o){return!o.includes("webgl")},r.isTextureFormatFilterable=function(o){return this.isTextureFormatSupported(o)},r.isTextureFormatRenderable=function(o){return this.isTextureFormatSupported(o)},r.createBuffer=function(o){var a=this._getBufferProps(o);return new qe(this,a)},r._createTexture=function(o){return new Xe(this,o)},r.createExternalTexture=function(o){return new xr(this,o)},r.createShader=function(o){return new Je(this,o)},r.createSampler=function(o){return new W(this,o)},r.createRenderPipeline=function(o){return new Dr(this,o)},r.createFramebuffer=function(o){throw new Error("Not implemented")},r.createComputePipeline=function(o){return new Gr(this,o)},r.createVertexArray=function(o){return new kr(this,o)},r.beginRenderPass=function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Nr(this,o)},r.beginComputePass=function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Lr(this,o)},r.createTransformFeedback=function(o){throw new Error("Transform feedback not supported in WebGPU")},r.createCanvasContext=function(o){return new dt(this,this.adapter,o)},r.getDefaultRenderPass=function(){throw new Error("a")},r.submit=function(){var o,a=(o=this.commandEncoder)===null||o===void 0?void 0:o.finish();a&&this.handle.queue.submit([a]),this.commandEncoder=null},r._getFeatures=function(){var o=new Set(this.handle.features);return o.has("depth-clamping")&&(o.delete("depth-clamping"),o.add("depth-clip-control")),o.has("texture-compression-bc")&&o.add("texture-compression-bc5-webgl"),o.add("webgpu"),o.add("timer-query-webgl"),o.add("vertex-array-object-webgl1"),o.add("instanced-rendering-webgl1"),o.add("multiple-render-targets-webgl1"),o.add("index-uint32-webgl1"),o.add("blend-minmax-webgl1"),o.add("texture-blend-float-webgl1"),o.add("texture-formats-srgb-webgl1"),o.add("texture-formats-depth-webgl1"),o.add("texture-formats-float32-webgl1"),o.add("texture-formats-float16-webgl1"),o.add("texture-filter-linear-float32-webgl"),o.add("texture-filter-linear-float16-webgl"),o.add("texture-filter-anisotropic-webgl"),o.add("texture-renderable-rgba32float-webgl"),o.add("texture-renderable-float32-webgl"),o.add("texture-renderable-float16-webgl"),o.add("glsl-frag-data"),o.add("glsl-frag-depth"),o.add("glsl-derivatives"),o.add("glsl-texture-lod"),o},r.copyExternalImageToTexture=function(o){var a,s=o.source,u=o.sourceX,c=u===void 0?0:u,v=o.sourceY,h=v===void 0?0:v,O=o.texture,w=o.mipLevel,T=w===void 0?0:w,k=o.aspect,z=k===void 0?"all":k,I=o.colorSpace,M=I===void 0?"display-p3":I,F=o.premultipliedAlpha,G=F===void 0?!1:F,Q=o.width,ce=Q===void 0?O.width:Q,ee=o.height,te=ee===void 0?O.height:ee,$=o.depth,re=$===void 0?1:$,p=O;(a=this.handle)===null||a===void 0||a.queue.copyExternalImageToTexture({source:s,origin:[c,h]},{texture:p.handle,origin:[0,0,0],mipLevel:T,aspect:z,colorSpace:M,premultipliedAlpha:G},[ce,te,re])},g(e,[{key:"info",get:function(){return this._info}},{key:"limits",get:function(){return this.handle.limits}},{key:"isLost",get:function(){return this._isLost}}]),e}(Le);ht.type="webgpu";return qr(ko);})();
|
|
12
12
|
/*! Bundled license information:
|
|
13
13
|
|
|
14
14
|
@babel/runtime/helpers/regeneratorRuntime.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgpu",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.46",
|
|
4
4
|
"description": "WebGPU adapter for the luma.gl API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@babel/runtime": "^7.0.0",
|
|
40
|
-
"@luma.gl/core": "9.0.0-alpha.
|
|
40
|
+
"@luma.gl/core": "9.0.0-alpha.46",
|
|
41
41
|
"@probe.gl/env": "^4.0.2",
|
|
42
42
|
"@webgpu/types": "^0.1.34"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "c1e0602fd739f8d08e6532034a02e8cf658e188a"
|
|
45
45
|
}
|
|
@@ -54,7 +54,7 @@ export class WebGPUBuffer extends Buffer {
|
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
override async readAsync(byteOffset: number = 0, byteLength: number = this.byteLength): Promise<
|
|
57
|
+
override async readAsync(byteOffset: number = 0, byteLength: number = this.byteLength): Promise<Uint8Array> {
|
|
58
58
|
// We need MAP_READ flag, but only COPY_DST buffers can have MAP_READ flag, so we need to create a temp buffer
|
|
59
59
|
const tempBuffer = new WebGPUBuffer(this.device, {usage: Buffer.MAP_READ | Buffer.COPY_DST, byteLength});
|
|
60
60
|
|
|
@@ -70,7 +70,7 @@ export class WebGPUBuffer extends Buffer {
|
|
|
70
70
|
tempBuffer.handle.unmap();
|
|
71
71
|
tempBuffer.destroy();
|
|
72
72
|
|
|
73
|
-
return arrayBuffer;
|
|
73
|
+
return new Uint8Array(arrayBuffer);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
_writeMapped<TypedArray>(typedArray: TypedArray): void {
|
|
@@ -20,7 +20,9 @@ import type {
|
|
|
20
20
|
RenderPassProps,
|
|
21
21
|
ComputePassProps,
|
|
22
22
|
// CommandEncoderProps,
|
|
23
|
-
VertexArrayProps
|
|
23
|
+
VertexArrayProps,
|
|
24
|
+
TransformFeedback,
|
|
25
|
+
TransformFeedbackProps
|
|
24
26
|
} from '@luma.gl/core';
|
|
25
27
|
import {Device, CanvasContext, log, uid} from '@luma.gl/core';
|
|
26
28
|
import {WebGPUBuffer} from './resources/webgpu-buffer';
|
|
@@ -117,7 +119,7 @@ export class WebGPUDevice extends Device {
|
|
|
117
119
|
};
|
|
118
120
|
|
|
119
121
|
// "Context" loss handling
|
|
120
|
-
this.lost = new Promise<{reason: 'destroyed'; message: string}>(async
|
|
122
|
+
this.lost = new Promise<{reason: 'destroyed'; message: string}>(async resolve => {
|
|
121
123
|
const lostInfo = await this.handle.lost;
|
|
122
124
|
this._isLost = true;
|
|
123
125
|
resolve({reason: 'destroyed', message: lostInfo.message});
|
|
@@ -125,7 +127,12 @@ export class WebGPUDevice extends Device {
|
|
|
125
127
|
|
|
126
128
|
// Note: WebGPU devices can be created without a canvas, for compute shader purposes
|
|
127
129
|
// if (props.canvas) {
|
|
128
|
-
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, {
|
|
130
|
+
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, {
|
|
131
|
+
canvas: props.canvas,
|
|
132
|
+
height: props.height,
|
|
133
|
+
width: props.width,
|
|
134
|
+
container: props.container
|
|
135
|
+
});
|
|
129
136
|
// }
|
|
130
137
|
|
|
131
138
|
this.features = this._getFeatures();
|
|
@@ -225,6 +232,10 @@ export class WebGPUDevice extends Device {
|
|
|
225
232
|
// return new WebGPUCommandEncoder(this, props);
|
|
226
233
|
// }
|
|
227
234
|
|
|
235
|
+
createTransformFeedback(props: TransformFeedbackProps): TransformFeedback {
|
|
236
|
+
throw new Error('Transform feedback not supported in WebGPU');
|
|
237
|
+
}
|
|
238
|
+
|
|
228
239
|
createCanvasContext(props: CanvasContextProps): WebGPUCanvasContext {
|
|
229
240
|
return new WebGPUCanvasContext(this, this.adapter, props);
|
|
230
241
|
}
|
|
@@ -317,7 +328,7 @@ export class WebGPUDevice extends Device {
|
|
|
317
328
|
colorSpace?: 'display-p3' | 'srgb';
|
|
318
329
|
premultipliedAlpha?: boolean;
|
|
319
330
|
|
|
320
|
-
source:
|
|
331
|
+
source: ImageBitmap | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas;
|
|
321
332
|
sourceX?: number;
|
|
322
333
|
sourceY?: number;
|
|
323
334
|
|
|
@@ -362,11 +373,7 @@ export class WebGPUDevice extends Device {
|
|
|
362
373
|
premultipliedAlpha
|
|
363
374
|
},
|
|
364
375
|
// copySize: GPUExtent3D
|
|
365
|
-
[
|
|
366
|
-
|
|
367
|
-
height,
|
|
368
|
-
depth
|
|
369
|
-
]
|
|
370
|
-
)
|
|
376
|
+
[width, height, depth]
|
|
377
|
+
);
|
|
371
378
|
}
|
|
372
379
|
}
|
package/LICENSE
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
luma.gl is provided under the MIT license
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 vis.gl contributors
|
|
4
|
-
|
|
5
|
-
This software includes parts initially developed by Uber and open sourced under MIT license.
|
|
6
|
-
Copyright (c) 2015 Uber Technologies, Inc.
|
|
7
|
-
|
|
8
|
-
This software includes parts of PhiloGL (https://github.com/philogb/philogl)
|
|
9
|
-
under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs.
|
|
10
|
-
|
|
11
|
-
This software includes adaptations of some postprocessing code from
|
|
12
|
-
THREE.js (https://github.com/mrdoob/three.js/) under MIT license.
|
|
13
|
-
THREE.js parts Copyright © 2010-2018 three.js authors.
|
|
14
|
-
|
|
15
|
-
Additional attribution given in specific source files.
|
|
16
|
-
|
|
17
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
19
|
-
in the Software without restriction, including without limitation the rights
|
|
20
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
22
|
-
furnished to do so, subject to the following conditions:
|
|
23
|
-
|
|
24
|
-
The above copyright notice and this permission notice shall be included in
|
|
25
|
-
all copies or substantial portions of the Software.
|
|
26
|
-
|
|
27
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
33
|
-
THE SOFTWARE.
|
|
34
|
-
|