@luma.gl/webgpu 9.2.6 → 9.3.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/adapter/resources/webgpu-fence.d.ts +13 -0
  2. package/dist/adapter/resources/webgpu-fence.d.ts.map +1 -0
  3. package/dist/adapter/resources/webgpu-fence.js +25 -0
  4. package/dist/adapter/resources/webgpu-fence.js.map +1 -0
  5. package/dist/adapter/resources/webgpu-texture.d.ts +12 -3
  6. package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
  7. package/dist/adapter/resources/webgpu-texture.js +143 -26
  8. package/dist/adapter/resources/webgpu-texture.js.map +1 -1
  9. package/dist/adapter/webgpu-adapter.d.ts.map +1 -1
  10. package/dist/adapter/webgpu-adapter.js +34 -34
  11. package/dist/adapter/webgpu-adapter.js.map +1 -1
  12. package/dist/adapter/webgpu-canvas-context.d.ts +4 -3
  13. package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
  14. package/dist/adapter/webgpu-canvas-context.js +22 -21
  15. package/dist/adapter/webgpu-canvas-context.js.map +1 -1
  16. package/dist/adapter/webgpu-device.d.ts +3 -1
  17. package/dist/adapter/webgpu-device.d.ts.map +1 -1
  18. package/dist/adapter/webgpu-device.js +14 -3
  19. package/dist/adapter/webgpu-device.js.map +1 -1
  20. package/dist/dist.dev.js +6438 -274
  21. package/dist/dist.min.js +10 -6
  22. package/dist/index.cjs +347 -86
  23. package/dist/index.cjs.map +4 -4
  24. package/dist/index.d.ts +2 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +2 -0
  27. package/dist/index.js.map +1 -1
  28. package/dist/wgsl/get-shader-layout-wgsl.d.ts +8 -0
  29. package/dist/wgsl/get-shader-layout-wgsl.d.ts.map +1 -0
  30. package/dist/wgsl/get-shader-layout-wgsl.js +136 -0
  31. package/dist/wgsl/get-shader-layout-wgsl.js.map +1 -0
  32. package/package.json +5 -4
  33. package/src/adapter/resources/webgpu-fence.ts +30 -0
  34. package/src/adapter/resources/webgpu-texture.ts +202 -88
  35. package/src/adapter/webgpu-adapter.ts +40 -42
  36. package/src/adapter/webgpu-canvas-context.ts +25 -23
  37. package/src/adapter/webgpu-device.ts +19 -4
  38. package/src/index.ts +3 -0
  39. package/src/wgsl/get-shader-layout-wgsl.ts +156 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/adapter/resources/webgpu-buffer.ts", "../src/adapter/helpers/convert-texture-format.ts", "../src/adapter/resources/webgpu-sampler.ts", "../src/adapter/resources/webgpu-texture-view.ts", "../src/adapter/resources/webgpu-texture.ts", "../src/adapter/resources/webgpu-external-texture.ts", "../src/adapter/resources/webgpu-shader.ts", "../src/adapter/helpers/webgpu-parameters.ts", "../src/adapter/helpers/get-bind-group.ts", "../src/adapter/helpers/get-vertex-buffer-layout.ts", "../src/adapter/resources/webgpu-render-pipeline.ts", "../src/adapter/resources/webgpu-framebuffer.ts", "../src/adapter/resources/webgpu-compute-pipeline.ts", "../src/adapter/resources/webgpu-vertex-array.ts", "../src/adapter/webgpu-canvas-context.ts", "../src/adapter/resources/webgpu-command-buffer.ts", "../src/adapter/resources/webgpu-render-pass.ts", "../src/adapter/resources/webgpu-compute-pass.ts", "../src/adapter/resources/webgpu-command-encoder.ts", "../src/adapter/resources/webgpu-query-set.ts", "../src/adapter/resources/webgpu-pipeline-layout.ts", "../src/adapter/webgpu-device.ts", "../src/index.ts", "../src/adapter/webgpu-adapter.ts"],
4
- "sourcesContent": ["// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {log, Buffer, type BufferProps, type BufferMapCallback} from '@luma.gl/core';\nimport {type WebGPUDevice} from '../webgpu-device';\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 = props.byteLength || props.data?.byteLength || 0;\n const mappedAtCreation = Boolean(this.props.onMapped || props.data);\n\n // WebGPU buffers must be aligned to 4 bytes\n const size = Math.ceil(this.byteLength / 4) * 4;\n\n this.device.pushErrorScope('out-of-memory');\n this.device.pushErrorScope('validation');\n this.handle =\n this.props.handle ||\n this.device.handle.createBuffer({\n label: this.props.id,\n // usage defaults to vertex\n usage: this.props.usage || GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,\n mappedAtCreation,\n size\n });\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} creation failed ${error.message}`), this)();\n this.device.debug();\n });\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} out of memory: ${error.message}`), this)();\n this.device.debug();\n });\n\n this.device.pushErrorScope('validation');\n if (props.data || props.onMapped) {\n try {\n const arrayBuffer = this.handle.getMappedRange();\n if (props.data) {\n const typedArray = props.data;\n // @ts-expect-error\n new typedArray.constructor(arrayBuffer).set(typedArray);\n } else {\n props.onMapped?.(arrayBuffer, 'mapped');\n }\n } finally {\n this.handle.unmap();\n }\n }\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} creation failed ${error.message}`), this)();\n this.device.debug();\n });\n }\n\n override destroy(): void {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n\n write(data: ArrayBufferLike | ArrayBufferView | SharedArrayBuffer, byteOffset = 0) {\n const arrayBuffer = ArrayBuffer.isView(data) ? data.buffer : data;\n const dataByteOffset = ArrayBuffer.isView(data) ? data.byteOffset : 0;\n\n this.device.pushErrorScope('validation');\n\n // WebGPU provides multiple ways to write a buffer, this is the simplest API\n this.device.handle.queue.writeBuffer(\n this.handle,\n byteOffset,\n arrayBuffer,\n dataByteOffset,\n data.byteLength\n );\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this}.write() ${error.message}`), this)();\n this.device.debug();\n });\n }\n\n async mapAndWriteAsync(\n callback: BufferMapCallback<void>,\n byteOffset: number = 0,\n byteLength: number = this.byteLength - byteOffset\n ): Promise<void> {\n // Unless the application created and supplied a mappable buffer, a staging buffer is needed\n const isMappable = (this.usage & Buffer.MAP_WRITE) !== 0;\n const mappableBuffer: WebGPUBuffer | null = !isMappable\n ? this._getMappableBuffer(Buffer.MAP_WRITE | Buffer.COPY_SRC, 0, this.byteLength)\n : null;\n\n const writeBuffer = mappableBuffer || this;\n\n // const isWritable = this.usage & Buffer.MAP_WRITE;\n // Map the temp buffer and read the data.\n this.device.pushErrorScope('validation');\n try {\n await this.device.handle.queue.onSubmittedWorkDone();\n await writeBuffer.handle.mapAsync(GPUMapMode.WRITE, byteOffset, byteLength);\n const arrayBuffer = writeBuffer.handle.getMappedRange(byteOffset, byteLength);\n // eslint-disable-next-line @typescript-eslint/await-thenable\n await callback(arrayBuffer, 'mapped');\n writeBuffer.handle.unmap();\n if (mappableBuffer) {\n this._copyBuffer(mappableBuffer, byteOffset, byteLength);\n }\n } finally {\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this}.mapAndWriteAsync() ${error.message}`), this)();\n this.device.debug();\n });\n mappableBuffer?.destroy();\n }\n }\n\n async readAsync(\n byteOffset: number = 0,\n byteLength = this.byteLength - byteOffset\n ): Promise<Uint8Array> {\n return this.mapAndReadAsync(\n arrayBuffer => new Uint8Array(arrayBuffer.slice(0)),\n byteOffset,\n byteLength\n );\n }\n\n async mapAndReadAsync<T>(\n callback: BufferMapCallback<T>,\n byteOffset = 0,\n byteLength = this.byteLength - byteOffset\n ): Promise<T> {\n if (byteOffset % 8 !== 0 || byteLength % 4 !== 0) {\n throw new Error('byteOffset must be multiple of 8 and byteLength multiple of 4');\n }\n if (byteOffset + byteLength > this.handle.size) {\n throw new Error('Mapping range exceeds buffer size');\n }\n\n // Unless the application created and supplied a mappable buffer, a staging buffer is needed\n const isMappable = (this.usage & Buffer.MAP_READ) !== 0;\n const mappableBuffer: WebGPUBuffer | null = !isMappable\n ? this._getMappableBuffer(Buffer.MAP_READ | Buffer.COPY_DST, 0, this.byteLength)\n : null;\n\n const readBuffer = mappableBuffer || this;\n\n // Map the temp buffer and read the data.\n this.device.pushErrorScope('validation');\n try {\n await this.device.handle.queue.onSubmittedWorkDone();\n if (mappableBuffer) {\n mappableBuffer._copyBuffer(this);\n }\n await readBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);\n const arrayBuffer = readBuffer.handle.getMappedRange(byteOffset, byteLength);\n // eslint-disable-next-line @typescript-eslint/await-thenable\n const result = await callback(arrayBuffer, 'mapped');\n readBuffer.handle.unmap();\n return result;\n } finally {\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this}.mapAndReadAsync() ${error.message}`), this)();\n this.device.debug();\n });\n mappableBuffer?.destroy();\n }\n }\n\n readSyncWebGL(byteOffset?: number, byteLength?: number): Uint8Array<ArrayBuffer> {\n throw new Error('Not implemented');\n }\n\n // INTERNAL METHODS\n\n /**\n * @todo - A small set of mappable buffers could be cached on the device,\n * however this goes against the goal of keeping core as a thin GPU API layer.\n */\n protected _getMappableBuffer(\n usage: number, // Buffer.MAP_READ | Buffer.MAP_WRITE,\n byteOffset: number,\n byteLength: number\n ): WebGPUBuffer {\n log.warn(`${this} is not readable, creating a temporary Buffer`);\n const readableBuffer = new WebGPUBuffer(this.device, {usage, byteLength});\n\n return readableBuffer;\n }\n\n protected _copyBuffer(\n sourceBuffer: WebGPUBuffer,\n byteOffset: number = 0,\n byteLength: number = this.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 this.device.pushErrorScope('validation');\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToBuffer(\n sourceBuffer.handle,\n byteOffset,\n this.handle,\n byteOffset,\n byteLength\n );\n this.device.handle.queue.submit([commandEncoder.finish()]);\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this}._getReadableBuffer() ${error.message}`), this)();\n this.device.debug();\n });\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {TextureFormat} from '@luma.gl/core';\n\n/** Ensure a texture format is WebGPU compatible */\nexport function getWebGPUTextureFormat(format: TextureFormat): GPUTextureFormat {\n if (format.includes('webgl')) {\n throw new Error('webgl-only format');\n }\n return format as GPUTextureFormat;\n}\n", "// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {Sampler, SamplerProps} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\n\nexport type WebGPUSamplerProps = SamplerProps & {\n handle?: GPUSampler;\n};\n\n/**\n * A WebGPU sampler object\n */\nexport class WebGPUSampler extends Sampler {\n readonly device: WebGPUDevice;\n readonly handle: GPUSampler;\n\n constructor(device: WebGPUDevice, props: WebGPUSamplerProps) {\n super(device, props);\n this.device = device;\n\n // Prepare sampler props. Mostly identical\n const samplerDescriptor: Partial<GPUSamplerDescriptor> = {\n ...this.props,\n mipmapFilter: undefined\n };\n\n // props.compare automatically turns this into a comparison sampler\n if (props.type !== 'comparison-sampler') {\n delete samplerDescriptor.compare;\n }\n\n // disable mipmapFilter if not set\n if (props.mipmapFilter && props.mipmapFilter !== 'none') {\n samplerDescriptor.mipmapFilter = props.mipmapFilter;\n }\n\n this.handle = props.handle || this.device.handle.createSampler(samplerDescriptor);\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {\n // GPUSampler does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {TextureView, TextureViewProps} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport type {WebGPUTexture} from './webgpu-texture';\n\n/*\n // type = sampler\n samplerType?: 'filtering' | 'non-filtering' | 'comparison';\n\n // type = texture\n viewDimension?: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';\n sampleType?: 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint';\n multisampled?: boolean;\n\n // type = storage\n viewDimension?: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';\n access: 'read-only' | 'write-only';\n format: string;\n*/\n\nexport type WebGPUTextureViewProps = TextureViewProps & {\n handle?: GPUTextureView;\n};\n\n/**\n *\n */\nexport class WebGPUTextureView extends TextureView {\n readonly device: WebGPUDevice;\n readonly handle: GPUTextureView;\n readonly texture: WebGPUTexture;\n\n constructor(device: WebGPUDevice, props: WebGPUTextureViewProps & {texture: WebGPUTexture}) {\n super(device, props);\n this.device = device;\n this.texture = props.texture;\n\n this.device.pushErrorScope('validation');\n this.handle =\n // props.handle ||\n this.texture.handle.createView({\n format: (this.props.format || this.texture.format) as GPUTextureFormat,\n dimension: this.props.dimension || this.texture.dimension,\n aspect: this.props.aspect,\n baseMipLevel: this.props.baseMipLevel,\n mipLevelCount: this.props.mipLevelCount,\n baseArrayLayer: this.props.baseArrayLayer,\n arrayLayerCount: this.props.arrayLayerCount\n });\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`TextureView constructor: ${error.message}`), this)();\n this.device.debug();\n });\n\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {\n // GPUTextureView does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "// luma.gl, MIT license\nimport type {\n TextureProps,\n TextureViewProps,\n CopyExternalImageOptions,\n CopyImageDataOptions,\n SamplerProps\n} from '@luma.gl/core';\nimport {Texture, log} from '@luma.gl/core';\n\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUSampler} from './webgpu-sampler';\nimport {WebGPUTextureView} from './webgpu-texture-view';\n\nexport class WebGPUTexture extends Texture {\n readonly device: WebGPUDevice;\n readonly handle: GPUTexture;\n sampler: WebGPUSampler;\n view: WebGPUTextureView;\n\n constructor(device: WebGPUDevice, props: TextureProps) {\n super(device, props);\n this.device = device;\n\n if (this.dimension === 'cube') {\n this.depth = 6;\n }\n\n this.device.pushErrorScope('out-of-memory');\n this.device.pushErrorScope('validation');\n\n this.handle =\n this.props.handle ||\n this.device.handle.createTexture({\n label: this.id,\n size: {\n width: this.width,\n height: this.height,\n depthOrArrayLayers: this.depth\n },\n usage: this.props.usage || Texture.TEXTURE | Texture.COPY_DST,\n dimension: this.baseDimension,\n format: getWebGPUTextureFormat(this.format),\n mipLevelCount: this.mipLevels,\n sampleCount: this.props.samples\n });\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} constructor: ${error.message}`), this)();\n this.device.debug();\n });\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} out of memory: ${error.message}`), this)();\n this.device.debug();\n });\n\n // Update props if external handle was supplied - used mainly by CanvasContext.getDefaultFramebuffer()\n // TODO - Read all properties directly from the supplied handle?\n if (this.props.handle) {\n this.handle.label ||= this.id;\n this.width = this.handle.width;\n this.height = this.handle.height;\n }\n\n this.sampler =\n props.sampler instanceof WebGPUSampler\n ? props.sampler\n : new WebGPUSampler(this.device, (props.sampler as SamplerProps) || {});\n\n this.view = new WebGPUTextureView(this.device, {\n ...this.props,\n texture: this,\n mipLevelCount: this.mipLevels,\n // Note: arrayLayerCount controls the view of array textures, but does not apply to 3d texture depths\n arrayLayerCount: this.dimension !== '3d' ? this.depth : 1\n });\n\n // Set initial data\n // Texture base class strips out the data prop from this.props, so we need to handle it here\n this._initializeData(props.data);\n }\n\n override destroy(): void {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n\n createView(props: TextureViewProps): WebGPUTextureView {\n return new WebGPUTextureView(this.device, {...props, texture: this});\n }\n\n copyImageData(options_: CopyImageDataOptions): void {\n const {width, height, depth} = this;\n const options = this._normalizeCopyImageDataOptions(options_);\n this.device.pushErrorScope('validation');\n this.device.handle.queue.writeTexture(\n // destination: GPUImageCopyTexture\n {\n // texture subresource\n texture: this.handle,\n mipLevel: options.mipLevel,\n aspect: options.aspect,\n // origin to write to\n origin: [options.x, options.y, options.z]\n },\n // data\n options.data,\n // dataLayout: GPUImageDataLayout\n {\n offset: options.byteOffset,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage\n },\n // size: GPUExtent3D - extents of the content to write\n [width, height, depth]\n );\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`copyImageData: ${error.message}`), this)();\n this.device.debug();\n });\n }\n\n copyExternalImage(options_: CopyExternalImageOptions): {width: number; height: number} {\n const options = this._normalizeCopyExternalImageOptions(options_);\n\n this.device.pushErrorScope('validation');\n this.device.handle.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source: options.image,\n origin: [options.sourceX, options.sourceY],\n flipY: options.flipY\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: this.handle,\n origin: [options.x, options.y, 0], // options.depth],\n mipLevel: options.mipLevel,\n aspect: options.aspect,\n colorSpace: options.colorSpace,\n premultipliedAlpha: options.premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [options.width, options.height, 1]\n );\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`copyExternalImage: ${error.message}`), this)();\n this.device.debug();\n });\n\n // TODO - should these be clipped to the texture size minus x,y,z?\n return {width: options.width, height: options.height};\n }\n\n override generateMipmapsWebGL(): void {\n log.warn(`${this}: generateMipmaps not supported in WebGPU`)();\n }\n\n // WebGPU specific\n\n /*\n async readPixels() {\n const readbackBuffer = device.createBuffer({\n usage: Buffer.COPY_DST | Buffer.MAP_READ,\n size: 4 * textureWidth * textureHeight,\n });\n\n // Copy data from the texture to the buffer.\n const encoder = device.createCommandEncoder();\n encoder.copyTextureToBuffer(\n { texture },\n { buffer, rowPitch: textureWidth * 4 },\n [textureWidth, textureHeight],\n );\n device.submit([encoder.finish()]);\n\n // Get the data on the CPU.\n await buffer.mapAndReadAsync(GPUMapMode.READ);\n saveScreenshot(buffer.getMappedRange());\n buffer.unmap();\n }\n\n setImageData(imageData, usage): this {\n let data = null;\n\n const bytesPerRow = Math.ceil((img.width * 4) / 256) * 256;\n if (bytesPerRow == img.width * 4) {\n data = imageData.data;\n } else {\n data = new Uint8Array(bytesPerRow * img.height);\n let imagePixelIndex = 0;\n for (let y = 0; y < img.height; ++y) {\n for (let x = 0; x < img.width; ++x) {\n const i = x * 4 + y * bytesPerRow;\n data[i] = imageData.data[imagePixelIndex];\n data[i + 1] = imageData.data[imagePixelIndex + 1];\n data[i + 2] = imageData.data[imagePixelIndex + 2];\n data[i + 3] = imageData.data[imagePixelIndex + 3];\n imagePixelIndex += 4;\n }\n }\n }\n return this;\n }\n\n setBuffer(textureDataBuffer, {bytesPerRow}): this {\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToTexture(\n {\n buffer: textureDataBuffer,\n bytesPerRow\n },\n {\n texture: this.handle\n },\n {\n width,\n height,\n depth\n }\n );\n\n this.device.handle.defaultQueue.submit([commandEncoder.finish()]);\n return this;\n }\n */\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ExternalTexture, ExternalTextureProps, SamplerProps} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUSampler} from './webgpu-sampler';\n\n/**\n * Cheap, temporary texture view for videos\n * Only valid within same callback, destroyed automatically as a microtask.\n */\nexport class WebGPUExternalTexture extends ExternalTexture {\n readonly device: WebGPUDevice;\n readonly handle: GPUExternalTexture;\n sampler: WebGPUSampler;\n\n constructor(device: WebGPUDevice, props: ExternalTextureProps) {\n super(device, props);\n this.device = device;\n this.handle =\n this.props.handle ||\n this.device.handle.importExternalTexture({\n source: props.source,\n colorSpace: props.colorSpace\n });\n // @ts-expect-error\n this.sampler = null;\n }\n\n override destroy(): void {\n // External textures are destroyed automatically,\n // as a microtask, instead of manually or upon garbage collection like other resources.\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n\n /** Set default sampler */\n setSampler(sampler: WebGPUSampler | SamplerProps): this {\n // We can accept a sampler instance or set of props;\n this.sampler =\n sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {ShaderProps, CompilerMessage} from '@luma.gl/core';\nimport {Shader} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\n\n/**\n * Immutable shader\n */\nexport class WebGPUShader extends Shader {\n readonly device: WebGPUDevice;\n readonly handle: GPUShaderModule;\n\n constructor(device: WebGPUDevice, props: ShaderProps) {\n super(device, props);\n this.device = device;\n\n const isGLSL = props.source.includes('#version');\n if (this.props.language === 'glsl' || isGLSL) {\n throw new Error('GLSL shaders are not supported in WebGPU');\n }\n\n this.device.pushErrorScope('validation');\n this.handle = this.props.handle || this.device.handle.createShaderModule({code: props.source});\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(\n new Error(`${this} creation failed:\\n\"${error.message}\"`),\n this,\n this.props.source\n )();\n this.device.debug();\n });\n\n this.handle.label = this.props.id;\n this._checkCompilationError();\n }\n\n get asyncCompilationStatus(): Promise<any> {\n return this.getCompilationInfo().then(() => this.compilationStatus);\n }\n\n async _checkCompilationError(): Promise<void> {\n const shaderLog = await this.getCompilationInfo();\n const hasErrors = Boolean(shaderLog.find(msg => msg.type === 'error'));\n this.compilationStatus = hasErrors ? 'error' : 'success';\n this.debugShader();\n\n if (this.compilationStatus === 'error') {\n // Note: Even though this error is asynchronous and thrown after the constructor completes,\n // it will result in a useful stack trace leading back to the constructor\n this.device.reportError(new Error(`Shader compilation error`), this, shaderLog)();\n this.device.debug();\n }\n }\n\n override destroy(): void {\n // Note: WebGPU does not offer a method to destroy shaders\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n\n /** Returns compilation info for this shader */\n async getCompilationInfo(): Promise<readonly CompilerMessage[]> {\n const compilationInfo = await this.handle.getCompilationInfo();\n return compilationInfo.messages;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Parameters, log} from '@luma.gl/core';\n\nfunction addDepthStencil(descriptor: GPURenderPipelineDescriptor): GPUDepthStencilState {\n descriptor.depthStencil = descriptor.depthStencil || {\n // required, set something\n format: 'depth24plus',\n stencilFront: {},\n stencilBack: {},\n // TODO can this cause trouble? Should we set to WebGPU defaults? Are there defaults?\n depthWriteEnabled: false,\n depthCompare: 'less-equal'\n };\n return descriptor.depthStencil;\n}\n\nfunction addDepthStencilFront(descriptor: GPURenderPipelineDescriptor): GPUStencilFaceState {\n const depthStencil = addDepthStencil(descriptor);\n // @ts-ignore\n return depthStencil.stencilFront;\n}\n\nfunction addDepthStencilBack(descriptor: GPURenderPipelineDescriptor): GPUStencilFaceState {\n const depthStencil = addDepthStencil(descriptor);\n // @ts-ignore\n return depthStencil.stencilBack;\n}\n\n/**\n * Supports for luma.gl's flat parameter space\n * Populates the corresponding sub-objects in a GPURenderPipelineDescriptor\n */\nexport const PARAMETER_TABLE: Record<keyof Parameters, Function> = {\n // RASTERIZATION PARAMETERS\n\n cullMode: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.cullMode = value;\n },\n\n frontFace: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.frontFace = value;\n },\n\n // DEPTH\n\n depthWriteEnabled: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n if (value) {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthWriteEnabled = value;\n }\n },\n\n depthCompare: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthCompare = value;\n },\n\n depthFormat: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.format = value;\n },\n\n depthBias: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBias = value;\n },\n\n depthBiasSlopeScale: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasSlopeScale = value;\n },\n\n depthBiasClamp: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasClamp = value;\n },\n\n // STENCIL\n\n stencilReadMask: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilReadMask = value;\n },\n\n stencilWriteMask: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilWriteMask = value;\n },\n\n stencilCompare: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.compare = value;\n stencilBack.compare = value;\n },\n\n stencilPassOperation: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.passOp = value;\n stencilBack.passOp = value;\n },\n\n stencilFailOperation: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.failOp = value;\n stencilBack.failOp = value;\n },\n\n stencilDepthFailOperation: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.depthFailOp = value;\n stencilBack.depthFailOp = value;\n },\n\n // MULTISAMPLE\n\n sampleCount: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.count = value;\n },\n\n sampleMask: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.mask = value;\n },\n\n sampleAlphaToCoverageEnabled: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.alphaToCoverageEnabled = value;\n },\n\n // COLOR\n\n colorMask: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const target = addColorState(descriptor, 0);\n target.writeMask = value;\n },\n\n blend: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n if (value) {\n addBlendState(descriptor, 0);\n }\n },\n\n blendColorOperation: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const blend = addBlendState(descriptor, 0);\n blend.color = blend.color || {};\n blend.color.operation = value;\n },\n\n blendColorSrcFactor: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const blend = addBlendState(descriptor, 0);\n blend.color = blend.color || {};\n blend.color.srcFactor = value;\n },\n\n blendColorDstFactor: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const blend = addBlendState(descriptor, 0);\n blend.color.dstFactor = value;\n },\n\n blendAlphaOperation: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const blend = addBlendState(descriptor, 0);\n blend.alpha = blend.alpha || {};\n blend.alpha.operation = value;\n },\n\n blendAlphaSrcFactor: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const blend = addBlendState(descriptor, 0);\n blend.alpha = blend.alpha || {};\n blend.alpha.srcFactor = value;\n },\n\n blendAlphaDstFactor: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const blend = addBlendState(descriptor, 0);\n blend.alpha = blend.alpha || {};\n blend.alpha.dstFactor = value;\n },\n\n unclippedDepth: notSupported,\n provokingVertex: notSupported,\n polygonMode: notSupported,\n polygonOffsetLine: notSupported,\n clipDistance0: notSupported,\n clipDistance1: notSupported,\n clipDistance2: notSupported,\n clipDistance3: notSupported,\n clipDistance4: notSupported,\n clipDistance5: notSupported,\n clipDistance6: notSupported,\n clipDistance7: notSupported\n};\n\nfunction notSupported(\n key: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n): void {\n log.warn(`${key} parameter not supported in WebGPU`)();\n}\n\nconst DEFAULT_PIPELINE_DESCRIPTOR: GPURenderPipelineDescriptor = {\n // depthStencil: {\n // stencilFront: {},\n // stencilBack: {},\n // // depthWriteEnabled: true,\n // // depthCompare: 'less',\n // // format: 'depth24plus-stencil8',\n // },\n\n primitive: {\n cullMode: 'back',\n topology: 'triangle-list'\n },\n\n vertex: {\n module: undefined!,\n entryPoint: 'main'\n },\n\n fragment: {\n module: undefined!,\n entryPoint: 'main',\n targets: [\n // { format: props.color0Format || 'bgra8unorm' }\n ]\n },\n\n layout: 'auto'\n};\n\nexport function applyParametersToRenderPipelineDescriptor(\n pipelineDescriptor: GPURenderPipelineDescriptor,\n parameters: Parameters = {}\n): void {\n // Apply defaults\n Object.assign(pipelineDescriptor, {...DEFAULT_PIPELINE_DESCRIPTOR, ...pipelineDescriptor});\n setParameters(pipelineDescriptor, parameters);\n}\n\n// Apply any supplied parameters\nfunction setParameters(\n pipelineDescriptor: GPURenderPipelineDescriptor,\n parameters: Parameters\n): void {\n for (const [key, value] of Object.entries(parameters)) {\n const setterFunction = PARAMETER_TABLE[key as keyof Parameters];\n if (setterFunction) {\n setterFunction(key, value, pipelineDescriptor);\n } else {\n log.error(`Illegal parameter ${key} in WebGPU`)();\n }\n }\n}\n\n/** @todo - support multiple color targets... */\nfunction addColorState(\n descriptor: GPURenderPipelineDescriptor,\n attachment: number\n): GPUColorTargetState {\n // @ts-ignore\n descriptor.fragment.targets = descriptor.fragment?.targets || ([] as GPUColorTargetState[]);\n if (!Array.isArray(descriptor.fragment?.targets)) {\n log.warn('parameters: no targets array')();\n }\n // @ts-expect-error GPU types as iterator\n if (descriptor.fragment?.targets?.length === 0) {\n // @ts-expect-error GPU types as iterator\n descriptor.fragment.targets?.push({});\n }\n // @ts-expect-error GPU types as iterator\n return descriptor.fragment?.targets?.[0] as GPUColorTargetState;\n}\n\nfunction addBlendState(descriptor: GPURenderPipelineDescriptor, attachment: number): GPUBlendState {\n const target = addColorState(descriptor, attachment);\n target.blend = target.blend || {color: {}, alpha: {}};\n return target.blend;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {ComputeShaderLayout, BindingDeclaration, Binding} from '@luma.gl/core';\nimport {Buffer, Sampler, Texture, log} from '@luma.gl/core';\nimport type {WebGPUBuffer} from '../resources/webgpu-buffer';\nimport type {WebGPUSampler} from '../resources/webgpu-sampler';\nimport type {WebGPUTexture} from '../resources/webgpu-texture';\n\n/**\n * Create a WebGPU \"bind group layout\" from an array of luma.gl bindings\n * @note bind groups can be automatically generated by WebGPU.\n */\nexport function makeBindGroupLayout(\n device: GPUDevice,\n layout: GPUBindGroupLayout,\n bindings: Binding[]\n): GPUBindGroupLayout {\n throw new Error('not implemented');\n // return device.createBindGroupLayout({\n // layout,\n // entries: getBindGroupEntries(bindings)\n // })\n}\n\n/**\n * Create a WebGPU \"bind group\" from an array of luma.gl bindings\n */\nexport function getBindGroup(\n device: GPUDevice,\n bindGroupLayout: GPUBindGroupLayout,\n shaderLayout: ComputeShaderLayout,\n bindings: Record<string, Binding>\n): GPUBindGroup {\n const entries = getBindGroupEntries(bindings, shaderLayout);\n device.pushErrorScope('validation');\n const bindGroup = device.createBindGroup({\n layout: bindGroupLayout,\n entries\n });\n device.popErrorScope().then((error: GPUError | null) => {\n if (error) {\n log.error(`bindGroup creation: ${error.message}`, bindGroup)();\n }\n });\n return bindGroup;\n}\n\nexport function getShaderLayoutBinding(\n shaderLayout: ComputeShaderLayout,\n bindingName: string,\n options?: {ignoreWarnings?: boolean}\n): BindingDeclaration | null {\n const bindingLayout = shaderLayout.bindings.find(\n binding =>\n binding.name === bindingName ||\n `${binding.name.toLocaleLowerCase()}uniforms` === bindingName.toLocaleLowerCase()\n );\n if (!bindingLayout && !options?.ignoreWarnings) {\n log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();\n }\n return bindingLayout || null;\n}\n\n/**\n * @param bindings\n * @returns\n */\nfunction getBindGroupEntries(\n bindings: Record<string, Binding>,\n shaderLayout: ComputeShaderLayout\n): GPUBindGroupEntry[] {\n const entries: GPUBindGroupEntry[] = [];\n\n for (const [bindingName, value] of Object.entries(bindings)) {\n let bindingLayout = getShaderLayoutBinding(shaderLayout, bindingName);\n if (bindingLayout) {\n const entry = getBindGroupEntry(value, bindingLayout.location);\n if (entry) {\n entries.push(entry);\n }\n }\n\n // TODO - hack to automatically bind samplers to supplied texture default samplers\n if (value instanceof Texture) {\n bindingLayout = getShaderLayoutBinding(shaderLayout, `${bindingName}Sampler`, {\n ignoreWarnings: true\n });\n if (bindingLayout) {\n const entry = getBindGroupEntry(value, bindingLayout.location, {sampler: true});\n if (entry) {\n entries.push(entry);\n }\n }\n }\n }\n\n return entries;\n}\n\nfunction getBindGroupEntry(\n binding: Binding,\n index: number,\n options?: {sampler?: boolean}\n): GPUBindGroupEntry | null {\n if (binding instanceof Buffer) {\n return {\n binding: index,\n resource: {\n buffer: (binding as WebGPUBuffer).handle\n }\n };\n }\n if (binding instanceof Sampler) {\n return {\n binding: index,\n resource: (binding as WebGPUSampler).handle\n };\n }\n if (binding instanceof Texture) {\n if (options?.sampler) {\n return {\n binding: index,\n resource: (binding as WebGPUTexture).sampler.handle\n };\n }\n return {\n binding: index,\n resource: (binding as WebGPUTexture).view.handle\n };\n }\n log.warn(`invalid binding ${name}`, binding);\n return null;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {ShaderLayout, BufferLayout, AttributeDeclaration, VertexFormat} from '@luma.gl/core';\nimport {log, getVertexFormatInfo} from '@luma.gl/core';\n// import {getAttributeInfosFromLayouts} from '@luma.gl/core';\n\n/** Throw error on any WebGL-only vertex formats */\nfunction getWebGPUVertexFormat(format: VertexFormat): GPUVertexFormat {\n if (format.endsWith('-webgl')) {\n throw new Error(`WebGPU does not support vertex format ${format}`);\n }\n return format as GPUVertexFormat;\n}\n\n/**\n * Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.\n * Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array\n * @param layout\n * @param bufferLayout The buffer map is optional\n * @returns WebGPU layout intended for a GPURenderPassDescriptor.\n */\nexport function getVertexBufferLayout(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[]\n): GPUVertexBufferLayout[] {\n const vertexBufferLayouts: GPUVertexBufferLayout[] = [];\n const usedAttributes = new Set<string>();\n\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // Build vertex attributes for one buffer\n const vertexAttributes: GPUVertexAttribute[] = [];\n\n // TODO verify that all stepModes for one buffer are the same\n let stepMode: 'vertex' | 'instance' = 'vertex';\n let byteStride = 0;\n // @ts-ignore\n let format: VertexFormat = mapping.format;\n\n // interleaved mapping {..., attributes: [{...}, ...]}\n if (mapping.attributes) {\n // const arrayStride = mapping.byteStride; TODO\n for (const attributeMapping of mapping.attributes) {\n const attributeName = attributeMapping.attribute;\n const attributeLayout = findAttributeLayout(shaderLayout, attributeName, usedAttributes);\n\n // @ts-ignore\n const location: number = attributeLayout?.location;\n format = attributeMapping.format || mapping.format;\n\n stepMode =\n attributeLayout?.stepMode ||\n (attributeLayout?.name.startsWith('instance') ? 'instance' : 'vertex');\n vertexAttributes.push({\n format: getWebGPUVertexFormat(format),\n offset: attributeMapping.byteOffset,\n shaderLocation: location\n });\n\n byteStride += getVertexFormatInfo(format).byteLength;\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);\n if (!attributeLayout) {\n continue; // eslint-disable-line no-continue\n }\n byteStride = getVertexFormatInfo(format).byteLength;\n\n stepMode =\n attributeLayout.stepMode ||\n (attributeLayout.name.startsWith('instance') ? 'instance' : 'vertex');\n vertexAttributes.push({\n format: getWebGPUVertexFormat(format),\n // We only support 0 offset for non-interleaved buffer layouts\n offset: 0,\n shaderLocation: attributeLayout.location\n });\n }\n\n // Store all the attribute bindings for one buffer\n vertexBufferLayouts.push({\n arrayStride: mapping.byteStride || byteStride,\n stepMode,\n attributes: vertexAttributes\n });\n }\n\n // Add any non-mapped attributes - TODO - avoid hardcoded types\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n vertexBufferLayouts.push({\n arrayStride: getVertexFormatInfo('float32x3').byteLength,\n stepMode:\n attribute.stepMode || (attribute.name.startsWith('instance') ? 'instance' : 'vertex'),\n attributes: [\n {\n format: getWebGPUVertexFormat('float32x3'),\n offset: 0,\n shaderLocation: attribute.location\n }\n ]\n });\n }\n }\n\n // it's important that the VertexBufferLayout order matches the\n // @location order of the attribute struct otherwise the buffers\n // will not contain the data the shader expects them to.\n vertexBufferLayouts.sort((a, b) => {\n const minLocationA = Math.min(...Array.from(a.attributes, attr => attr.shaderLocation));\n const minLocationB = Math.min(...Array.from(b.attributes, attr => attr.shaderLocation));\n\n return minLocationA - minLocationB;\n });\n\n return vertexBufferLayouts;\n}\n\nexport function getBufferSlots(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[]\n): Record<string, number> {\n const usedAttributes = new Set<string>();\n let bufferSlot = 0;\n const bufferSlots: Record<string, number> = {};\n\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n for (const interleaved of mapping.attributes || []) {\n usedAttributes.add(interleaved.attribute);\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n usedAttributes.add(mapping.name);\n }\n bufferSlots[mapping.name] = bufferSlot++;\n }\n\n // Add any non-mapped attributes\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n bufferSlots[attribute.name] = bufferSlot++;\n }\n }\n\n return bufferSlots;\n}\n\n/**\n * Looks up an attribute in the ShaderLayout.\n * @throws if name is not in ShaderLayout\n * @throws if name has already been referenced and attributeNames is provided\n */\nfunction findAttributeLayout(\n shaderLayout: ShaderLayout,\n name: string,\n attributeNames?: Set<string>\n): AttributeDeclaration | null {\n const attribute = shaderLayout.attributes.find(attribute_ => attribute_.name === name);\n if (!attribute) {\n log.warn(`Supplied attribute not present in shader layout: ${name}`)();\n return null;\n }\n if (attributeNames) {\n if (attributeNames.has(name)) {\n throw new Error(`Found multiple entries for attribute: ${name}`);\n }\n attributeNames.add(name);\n }\n return attribute;\n}\n", "// luma.gl MIT license\n\nimport type {Binding, RenderPass, VertexArray} from '@luma.gl/core';\nimport {RenderPipeline, RenderPipelineProps, log} from '@luma.gl/core';\nimport {applyParametersToRenderPipelineDescriptor} from '../helpers/webgpu-parameters';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport {getBindGroup} from '../helpers/get-bind-group';\nimport {getVertexBufferLayout} from '../helpers/get-vertex-buffer-layout';\n// import {convertAttributesVertexBufferToLayout} from '../helpers/get-vertex-buffer-layout';\n// import {mapAccessorToWebGPUFormat} from './helpers/accessor-to-format';\n// import type {BufferAccessors} from './webgpu-pipeline';\n\nimport type {WebGPUDevice} from '../webgpu-device';\n// import type {WebGPUBuffer} from './webgpu-buffer';\nimport type {WebGPUShader} from './webgpu-shader';\nimport type {WebGPURenderPass} from './webgpu-render-pass';\n\n// RENDER PIPELINE\n\n/** Creates a new render pipeline when parameters change */\nexport class WebGPURenderPipeline extends RenderPipeline {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPipeline;\n\n readonly vs: WebGPUShader;\n readonly fs: WebGPUShader | null = null;\n\n /** For internal use to create BindGroups */\n private _bindings: Record<string, Binding>;\n private _bindGroupLayout: GPUBindGroupLayout | null = null;\n private _bindGroup: GPUBindGroup | null = null;\n\n override get [Symbol.toStringTag]() {\n return 'WebGPURenderPipeline';\n }\n\n constructor(device: WebGPUDevice, props: RenderPipelineProps) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle as GPURenderPipeline;\n if (!this.handle) {\n const descriptor = this._getRenderPipelineDescriptor();\n log.groupCollapsed(1, `new WebGPURenderPipeline(${this.id})`)();\n log.probe(1, JSON.stringify(descriptor, null, 2))();\n log.groupEnd(1)();\n\n this.device.pushErrorScope('validation');\n this.handle = this.device.handle.createRenderPipeline(descriptor);\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} creation failed:\\n\"${error.message}\"`), this)();\n this.device.debug();\n });\n }\n this.handle.label = this.props.id;\n\n // Note: Often the same shader in WebGPU\n this.vs = props.vs as WebGPUShader;\n this.fs = props.fs as WebGPUShader;\n\n this._bindings = {...this.props.bindings};\n }\n\n override destroy(): void {\n // WebGPURenderPipeline has no destroy method.\n // @ts-expect-error\n this.handle = null;\n }\n\n /**\n * @todo Use renderpass.setBindings() ?\n * @todo Do we want to expose BindGroups in the API and remove this?\n */\n setBindings(bindings: Record<string, Binding>): void {\n // Invalidate the cached bind group if any value has changed\n for (const [name, binding] of Object.entries(bindings)) {\n if (this._bindings[name] !== binding) {\n this._bindGroup = null;\n }\n }\n Object.assign(this._bindings, bindings);\n }\n\n /** @todo - should this be moved to renderpass? */\n draw(options: {\n renderPass: RenderPass;\n vertexArray: VertexArray;\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): boolean {\n const webgpuRenderPass = options.renderPass as WebGPURenderPass;\n\n // Set pipeline\n this.device.pushErrorScope('validation');\n webgpuRenderPass.handle.setPipeline(this.handle);\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} setPipeline failed:\\n\"${error.message}\"`), this)();\n this.device.debug();\n });\n\n // Set bindings (uniform buffers, textures etc)\n const bindGroup = this._getBindGroup();\n if (bindGroup) {\n webgpuRenderPass.handle.setBindGroup(0, bindGroup);\n }\n\n // Set attributes\n // Note: Rebinds constant attributes before each draw call\n options.vertexArray.bindBeforeRender(options.renderPass);\n\n // Draw\n if (options.indexCount) {\n webgpuRenderPass.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n webgpuRenderPass.handle.draw(\n options.vertexCount || 0,\n options.instanceCount || 1, // If 0, nothing will be drawn\n options.firstInstance\n );\n }\n\n // Note: Rebinds constant attributes before each draw call\n options.vertexArray.unbindAfterRender(options.renderPass);\n\n return true;\n }\n\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n if (this.shaderLayout.bindings.length === 0) {\n return null;\n }\n\n // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group\n this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);\n\n // Set up the bindings\n // TODO what if bindings change? We need to rebuild the bind group!\n this._bindGroup =\n this._bindGroup ||\n getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);\n\n return this._bindGroup;\n }\n\n /**\n * Populate the complex WebGPU GPURenderPipelineDescriptor\n */\n protected _getRenderPipelineDescriptor() {\n // Set up the vertex stage\n const vertex: GPUVertexState = {\n module: (this.props.vs as WebGPUShader).handle,\n entryPoint: this.props.vertexEntryPoint || 'main',\n buffers: getVertexBufferLayout(this.shaderLayout, this.props.bufferLayout)\n };\n\n // Populate color targets\n // TODO - at the moment blend and write mask are only set on the first target\n const targets: (GPUColorTargetState | null)[] = [];\n if (this.props.colorAttachmentFormats) {\n for (const format of this.props.colorAttachmentFormats) {\n targets.push(format ? {format: getWebGPUTextureFormat(format)} : null);\n }\n } else {\n targets.push({format: getWebGPUTextureFormat(this.device.preferredColorFormat)});\n }\n\n // Set up the fragment stage\n const fragment: GPUFragmentState = {\n module: (this.props.fs as WebGPUShader).handle,\n entryPoint: this.props.fragmentEntryPoint || 'main',\n targets\n };\n\n const layout = this.device.createPipelineLayout({\n shaderLayout: this.shaderLayout\n });\n\n // Create a partially populated descriptor\n const descriptor: GPURenderPipelineDescriptor = {\n vertex,\n fragment,\n primitive: {\n topology: this.props.topology\n },\n layout: layout.handle\n };\n\n // Set depth format if required, defaulting to the preferred depth format\n const depthFormat = this.props.depthStencilAttachmentFormat || this.device.preferredDepthFormat;\n\n if (this.props.parameters.depthWriteEnabled) {\n descriptor.depthStencil = {\n format: getWebGPUTextureFormat(depthFormat)\n };\n }\n\n // Set parameters on the descriptor\n applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);\n\n return descriptor;\n }\n}\n/**\n_setAttributeBuffers(webgpuRenderPass: WebGPURenderPass) {\n if (this._indexBuffer) {\n webgpuRenderPass.handle.setIndexBuffer(this._indexBuffer.handle, this._indexBuffer.props.indexType);\n }\n\n const buffers = this._getBuffers();\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = cast<WebGPUBuffer>(buffers[i]);\n if (!buffer) {\n const attribute = this.shaderLayout.attributes.find(\n (attribute) => attribute.location === i\n );\n throw new Error(\n `No buffer provided for attribute '${attribute?.name || ''}' in Model '${this.props.id}'`\n );\n }\n webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);\n }\n\n // TODO - HANDLE buffer maps\n /*\n for (const [bufferName, attributeMapping] of Object.entries(this.props.bufferLayout)) {\n const buffer = cast<WebGPUBuffer>(this.props.attributes[bufferName]);\n if (!buffer) {\n log.warn(`Missing buffer for buffer map ${bufferName}`)();\n continue;\n }\n\n if ('location' in attributeMapping) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(layout.location, buffer.handle);\n } else {\n for (const [bufferName, mapping] of Object.entries(attributeMapping)) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(field.location, buffer.handle);\n }\n }\n }\n *\n}\n*/\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {FramebufferProps} from '@luma.gl/core';\nimport {Framebuffer} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUTextureView} from '../resources/webgpu-texture-view';\n\n/**\n * Create new textures with correct size for all attachments.\n * @note resize() destroys existing textures (if size has changed).\n */\nexport class WebGPUFramebuffer extends Framebuffer {\n readonly device: WebGPUDevice;\n readonly handle = null;\n\n readonly colorAttachments: WebGPUTextureView[] = [];\n readonly depthStencilAttachment: WebGPUTextureView | null = null;\n\n constructor(device: WebGPUDevice, props: FramebufferProps) {\n super(device, props);\n this.device = device;\n\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n }\n\n protected updateAttachments(): void {\n // WebGPU framebuffers are JS only objects, nothing to update\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ComputePipeline, ComputePipelineProps, Binding} from '@luma.gl/core';\nimport {getBindGroup} from '../helpers/get-bind-group';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUShader} from './webgpu-shader';\n\n// COMPUTE PIPELINE\n\n/** Creates a new compute pipeline when parameters change */\nexport class WebGPUComputePipeline extends ComputePipeline {\n readonly device: WebGPUDevice;\n readonly handle: GPUComputePipeline;\n\n /** For internal use to create BindGroups */\n private _bindGroupLayout: GPUBindGroupLayout | null = null;\n private _bindGroup: GPUBindGroup | null = null;\n /** For internal use to create BindGroups */\n private _bindings: Record<string, Binding> = {};\n\n constructor(device: WebGPUDevice, props: ComputePipelineProps) {\n super(device, props);\n this.device = device;\n\n const webgpuShader = this.props.shader as WebGPUShader;\n\n this.handle =\n this.props.handle ||\n this.device.handle.createComputePipeline({\n label: this.props.id,\n compute: {\n module: webgpuShader.handle,\n entryPoint: this.props.entryPoint,\n constants: this.props.constants\n },\n layout: 'auto'\n });\n }\n\n /**\n * @todo Use renderpass.setBindings() ?\n * @todo Do we want to expose BindGroups in the API and remove this?\n */\n setBindings(bindings: Record<string, Binding>): void {\n Object.assign(this._bindings, bindings);\n }\n\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group\n this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);\n\n // Set up the bindings\n this._bindGroup =\n this._bindGroup ||\n getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);\n\n return this._bindGroup;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Device, Buffer, VertexArrayProps, RenderPass} from '@luma.gl/core';\nimport {VertexArray, log} from '@luma.gl/core';\nimport {getBrowser} from '@probe.gl/env';\n\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from '../resources/webgpu-buffer';\n\nimport {WebGPURenderPass} from './webgpu-render-pass';\n\n/** VertexArrayObject wrapper */\nexport class WebGPUVertexArray extends VertexArray {\n override get [Symbol.toStringTag](): string {\n return 'WebGPUVertexArray';\n }\n\n readonly device: WebGPUDevice;\n /** Vertex Array is just a helper class under WebGPU */\n readonly handle = null;\n\n // Create a VertexArray\n constructor(device: WebGPUDevice, props: VertexArrayProps) {\n super(device, props);\n this.device = device;\n }\n\n override destroy(): void {}\n\n /**\n * Set an elements buffer, for indexed rendering.\n * Must be a Buffer bound to buffer with usage bit Buffer.INDEX set.\n */\n setIndexBuffer(buffer: Buffer | null): void {\n // assert(!elementBuffer || elementBuffer.glTarget === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n this.indexBuffer = buffer;\n }\n\n /** Set a bufferSlot in vertex attributes array to a buffer, enables the bufferSlot, sets divisor */\n setBuffer(bufferSlot: number, buffer: Buffer): void {\n // Sanity check target\n // if (buffer.glUsage === GL.ELEMENT_ARRAY_BUFFER) {\n // throw new Error('Use setIndexBuffer');\n // }\n\n this.attributes[bufferSlot] = buffer;\n }\n\n override bindBeforeRender(\n renderPass: RenderPass,\n firstIndex?: number,\n indexCount?: number\n ): void {\n const webgpuRenderPass = renderPass as WebGPURenderPass;\n const webgpuIndexBuffer = this.indexBuffer as WebGPUBuffer;\n if (webgpuIndexBuffer?.handle) {\n // Note we can't unset an index buffer\n log.info(\n 3,\n 'setting index buffer',\n webgpuIndexBuffer?.handle,\n webgpuIndexBuffer?.indexType\n )();\n webgpuRenderPass.handle.setIndexBuffer(\n webgpuIndexBuffer?.handle,\n // @ts-expect-error TODO - we must enforce type\n webgpuIndexBuffer?.indexType\n );\n }\n for (let location = 0; location < this.maxVertexAttributes; location++) {\n const webgpuBuffer = this.attributes[location] as WebGPUBuffer;\n if (webgpuBuffer?.handle) {\n log.info(3, `setting vertex buffer ${location}`, webgpuBuffer?.handle)();\n webgpuRenderPass.handle.setVertexBuffer(location, webgpuBuffer?.handle);\n }\n }\n // TODO - emit warnings/errors/throw if constants have been set on this vertex array\n }\n\n override unbindAfterRender(renderPass: RenderPass): void {\n // On WebGPU we don't need to unbind.\n // In fact we can't easily do it. setIndexBuffer/setVertexBuffer don't accept null.\n // Unbinding presumably happens automatically when the render pass is ended.\n }\n\n // DEPRECATED METHODS\n\n /**\n * @deprecated is this even an issue for WebGPU?\n * Attribute 0 can not be disable on most desktop OpenGL based browsers\n */\n static isConstantAttributeZeroSupported(device: Device): boolean {\n return getBrowser() === 'Chrome';\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport type {TextureFormatDepthStencil, CanvasContextProps} from '@luma.gl/core';\nimport {CanvasContext, Texture, log} from '@luma.gl/core';\nimport {WebGPUDevice} from './webgpu-device';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\nimport {WebGPUTexture} from './resources/webgpu-texture';\n\n/**\n * Holds a WebGPU Canvas Context\n * The primary job of the CanvasContext is to generate textures for rendering into the current canvas\n * It also manages canvas sizing calculations and resizing.\n */\nexport class WebGPUCanvasContext extends CanvasContext {\n readonly device: WebGPUDevice;\n readonly handle: GPUCanvasContext;\n\n private depthStencilAttachment: WebGPUTexture | null = null;\n\n get [Symbol.toStringTag](): string {\n return 'WebGPUCanvasContext';\n }\n\n constructor(device: WebGPUDevice, adapter: GPUAdapter, props: CanvasContextProps) {\n super(props);\n\n const context = this.canvas.getContext('webgpu');\n if (!context) {\n throw new Error(`${this}: Failed to create WebGPU canvas context`);\n }\n this.device = device;\n this.handle = context;\n\n // Base class constructor cannot access derived methods/fields, so we need to call these functions in the subclass constructor\n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n this._updateDevice();\n }\n\n /** Destroy any textures produced while configured and remove the context configuration. */\n override destroy(): void {\n this.handle.unconfigure();\n super.destroy();\n }\n\n /** Update framebuffer with properly resized \"swap chain\" texture views */\n getCurrentFramebuffer(\n options: {depthStencilFormat?: TextureFormatDepthStencil | false} = {\n depthStencilFormat: 'depth24plus'\n }\n ): WebGPUFramebuffer {\n // Wrap the current canvas context texture in a luma.gl texture\n const currentColorAttachment = this.getCurrentTexture();\n // TODO - temporary debug code\n if (\n currentColorAttachment.width !== this.drawingBufferWidth ||\n currentColorAttachment.height !== this.drawingBufferHeight\n ) {\n const [oldWidth, oldHeight] = this.getDrawingBufferSize();\n this.drawingBufferWidth = currentColorAttachment.width;\n this.drawingBufferHeight = currentColorAttachment.height;\n log.log(\n 1,\n `${this}: Resized to compensate for initial canvas size mismatch ${oldWidth}x${oldHeight} => ${this.drawingBufferWidth}x${this.drawingBufferHeight}px`\n )();\n }\n\n // Resize the depth stencil attachment\n if (options?.depthStencilFormat) {\n this._createDepthStencilAttachment(options?.depthStencilFormat);\n }\n\n return new WebGPUFramebuffer(this.device, {\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: this.depthStencilAttachment\n });\n }\n\n // IMPLEMENTATION OF ABSTRACT METHODS\n\n _updateDevice(): void {\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n\n // Reconfigure the canvas size.\n // https://www.w3.org/TR/webgpu/#canvas-configuration\n this.handle.configure({\n device: this.device.handle,\n format: this.device.preferredColorFormat,\n // Can be used to define e.g. -srgb views\n // viewFormats: [...]\n colorSpace: this.props.colorSpace,\n alphaMode: this.props.alphaMode\n });\n }\n\n /** Wrap the current canvas context texture in a luma.gl texture */\n getCurrentTexture(): WebGPUTexture {\n const handle = this.handle.getCurrentTexture();\n return this.device.createTexture({\n id: `${this.id}#color-texture`,\n handle,\n format: this.device.preferredColorFormat,\n width: handle.width,\n height: handle.height\n });\n }\n\n /** We build render targets on demand (i.e. not when size changes but when about to render) */\n _createDepthStencilAttachment(depthStencilFormat: TextureFormatDepthStencil): WebGPUTexture {\n if (!this.depthStencilAttachment) {\n this.depthStencilAttachment = this.device.createTexture({\n id: `${this.id}#depth-stencil-texture`,\n usage: Texture.RENDER_ATTACHMENT,\n format: depthStencilFormat,\n width: this.drawingBufferWidth,\n height: this.drawingBufferHeight\n });\n }\n return this.depthStencilAttachment;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {CommandBufferProps} from '@luma.gl/core';\nimport {CommandBuffer} from '@luma.gl/core';\n\nimport {WebGPUDevice} from '../webgpu-device';\nimport type {WebGPUCommandEncoder} from './webgpu-command-encoder';\n\nexport class WebGPUCommandBuffer extends CommandBuffer {\n readonly device: WebGPUDevice;\n readonly handle: GPUCommandBuffer;\n\n constructor(commandEncoder: WebGPUCommandEncoder, props: CommandBufferProps) {\n super(commandEncoder.device, {});\n this.device = commandEncoder.device;\n this.handle =\n this.props.handle ||\n commandEncoder.handle.finish({\n label: props?.id || 'unnamed-command-buffer'\n });\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {TypedArray, NumberArray4} from '@math.gl/types';\nimport type {RenderPassProps, RenderPassParameters, Binding} from '@luma.gl/core';\nimport {Buffer, RenderPass, RenderPipeline, log} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\n// import {WebGPUCommandEncoder} from './webgpu-command-encoder';\nimport {WebGPURenderPipeline} from './webgpu-render-pipeline';\nimport {WebGPUQuerySet} from './webgpu-query-set';\nimport {WebGPUFramebuffer} from './webgpu-framebuffer';\n\nexport class WebGPURenderPass extends RenderPass {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPassEncoder;\n\n /** Active pipeline */\n pipeline: WebGPURenderPipeline | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPassProps = {}) {\n super(device, props);\n this.device = device;\n const framebuffer =\n (props.framebuffer as WebGPUFramebuffer) || device.getCanvasContext().getCurrentFramebuffer();\n\n const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);\n\n const webgpuQuerySet = props.timestampQuerySet as WebGPUQuerySet;\n if (webgpuQuerySet) {\n renderPassDescriptor.occlusionQuerySet = webgpuQuerySet.handle;\n }\n\n if (device.features.has('timestamp-query')) {\n const webgpuTSQuerySet = props.timestampQuerySet as WebGPUQuerySet;\n renderPassDescriptor.timestampWrites = webgpuTSQuerySet\n ? ({\n querySet: webgpuTSQuerySet.handle,\n beginningOfPassWriteIndex: props.beginTimestampIndex,\n endOfPassWriteIndex: props.endTimestampIndex\n } as GPUComputePassTimestampWrites)\n : undefined;\n }\n\n if (!device.commandEncoder) {\n throw new Error('commandEncoder not available');\n }\n\n this.device.pushErrorScope('validation');\n this.handle =\n this.props.handle || device.commandEncoder.handle.beginRenderPass(renderPassDescriptor);\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} creation failed:\\n\"${error.message}\"`), this)();\n this.device.debug();\n });\n this.handle.label = this.props.id;\n log.groupCollapsed(3, `new WebGPURenderPass(${this.id})`)();\n log.probe(3, JSON.stringify(renderPassDescriptor, null, 2))();\n log.groupEnd(3)();\n }\n\n override destroy(): void {}\n\n end(): void {\n this.handle.end();\n }\n\n setPipeline(pipeline: RenderPipeline): void {\n this.pipeline = pipeline as WebGPURenderPipeline;\n this.device.pushErrorScope('validation');\n this.handle.setPipeline(this.pipeline.handle);\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} setPipeline failed:\\n\"${error.message}\"`), this)();\n this.device.debug();\n });\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Record<string, Binding>): void {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n\n setIndexBuffer(\n buffer: Buffer,\n indexFormat: GPUIndexFormat,\n offset: number = 0,\n size?: number\n ): void {\n this.handle.setIndexBuffer((buffer as WebGPUBuffer).handle, indexFormat, offset, size);\n }\n\n setVertexBuffer(slot: number, buffer: Buffer, offset: number = 0): void {\n this.handle.setVertexBuffer(slot, (buffer as WebGPUBuffer).handle, offset);\n }\n\n draw(options: {\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n if (options.indexCount) {\n this.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n this.handle.draw(\n options.vertexCount || 0,\n options.instanceCount || 1,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n drawIndirect(): void {\n // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n }\n\n setParameters(parameters: RenderPassParameters): void {\n const {blendConstant, stencilReference, scissorRect, viewport} = parameters;\n if (blendConstant) {\n this.handle.setBlendConstant(blendConstant);\n }\n if (stencilReference) {\n this.handle.setStencilReference(stencilReference);\n }\n if (scissorRect) {\n this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);\n }\n // TODO - explain how 3 dimensions vs 2 in WebGL works.\n if (viewport) {\n this.handle.setViewport(\n viewport[0],\n viewport[1],\n viewport[2],\n viewport[3],\n viewport[4] ?? 0,\n viewport[5] ?? 1\n );\n }\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n beginOcclusionQuery(queryIndex: number): void {\n this.handle.beginOcclusionQuery(queryIndex);\n }\n endOcclusionQuery(): void {\n this.handle.endOcclusionQuery();\n }\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n\n // INTERNAL\n\n /**\n * Partial render pass descriptor. Used by WebGPURenderPass.\n * @returns attachments fields of a renderpass descriptor.\n */\n protected getRenderPassDescriptor(framebuffer: WebGPUFramebuffer): GPURenderPassDescriptor {\n const renderPassDescriptor: GPURenderPassDescriptor = {\n colorAttachments: []\n };\n\n renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(\n (colorAttachment, index) => ({\n // clear values\n loadOp: this.props.clearColor !== false ? 'clear' : 'load',\n clearValue: convertColor(\n this.props.clearColors?.[index] || this.props.clearColor || RenderPass.defaultClearColor\n ),\n storeOp: this.props.discard ? 'discard' : 'store',\n // ...colorAttachment,\n view: colorAttachment.handle\n })\n );\n\n if (framebuffer.depthStencilAttachment) {\n renderPassDescriptor.depthStencilAttachment = {\n view: framebuffer.depthStencilAttachment.handle\n };\n const {depthStencilAttachment} = renderPassDescriptor;\n\n // DEPTH\n if (this.props.depthReadOnly) {\n depthStencilAttachment.depthReadOnly = true;\n }\n if (this.props.clearDepth !== false) {\n depthStencilAttachment.depthClearValue = this.props.clearDepth;\n }\n // STENCIL\n // if (this.props.clearStencil !== false) {\n // depthStencilAttachment.stencilClearValue = this.props.clearStencil;\n // }\n\n // WebGPU only wants us to set these parameters if the texture format actually has a depth aspect\n const hasDepthAspect = true;\n if (hasDepthAspect) {\n depthStencilAttachment.depthLoadOp = this.props.clearDepth !== false ? 'clear' : 'load';\n depthStencilAttachment.depthStoreOp = 'store'; // TODO - support 'discard'?\n }\n\n // WebGPU only wants us to set these parameters if the texture format actually has a stencil aspect\n const hasStencilAspect = false;\n if (hasStencilAspect) {\n depthStencilAttachment.stencilLoadOp = this.props.clearStencil !== false ? 'clear' : 'load';\n depthStencilAttachment.stencilStoreOp = 'store'; // TODO - support 'discard'?\n }\n }\n\n return renderPassDescriptor;\n }\n}\n\nfunction convertColor(color: TypedArray | NumberArray4): GPUColor {\n return {r: color[0], g: color[1], b: color[2], a: color[3]};\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {WebGPUComputePipeline} from './webgpu-compute-pipeline';\nimport {WebGPUQuerySet} from './webgpu-query-set';\n\nexport class WebGPUComputePass extends ComputePass {\n readonly device: WebGPUDevice;\n readonly handle: GPUComputePassEncoder;\n\n _webgpuPipeline: WebGPUComputePipeline | null = null;\n\n constructor(device: WebGPUDevice, props: ComputePassProps) {\n super(device, props);\n this.device = device;\n\n // Set up queries\n let timestampWrites: GPUComputePassTimestampWrites | undefined;\n if (device.features.has('timestamp-query')) {\n const webgpuQuerySet = props.timestampQuerySet as WebGPUQuerySet;\n if (webgpuQuerySet) {\n timestampWrites = {\n querySet: webgpuQuerySet.handle,\n beginningOfPassWriteIndex: props.beginTimestampIndex,\n endOfPassWriteIndex: props.endTimestampIndex\n };\n }\n }\n\n this.handle =\n this.props.handle ||\n device.commandEncoder.handle.beginComputePass({\n label: this.props.id,\n timestampWrites\n });\n }\n\n /** @note no WebGPU destroy method, just gc */\n override destroy(): void {}\n\n end(): void {\n this.handle.end();\n }\n\n setPipeline(pipeline: ComputePipeline): void {\n const wgpuPipeline = pipeline as WebGPUComputePipeline;\n this.handle.setPipeline(wgpuPipeline.handle);\n this._webgpuPipeline = wgpuPipeline;\n this.setBindings([]);\n }\n\n /**\n * Sets an array of bindings (uniform buffers, samplers, textures, ...)\n * TODO - still some API confusion - does this method go here or on the pipeline?\n */\n setBindings(bindings: Binding[]): void {\n // @ts-expect-error\n const bindGroup = this._webgpuPipeline._getBindGroup();\n this.handle.setBindGroup(0, bindGroup);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param x X dimension of the grid of work groups to dispatch.\n * @param y Y dimension of the grid of work groups to dispatch.\n * @param z Z dimension of the grid of work groups to dispatch.\n */\n dispatch(x: number, y?: number, z?: number): void {\n this.handle.dispatchWorkgroups(x, y, z);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n *\n * Buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()\n * @param indirectBuffer\n * @param indirectOffset offset in buffer to the beginning of the dispatch data.\n */\n dispatchIndirect(indirectBuffer: Buffer, indirectByteOffset: number = 0): void {\n const webgpuBuffer = indirectBuffer as WebGPUBuffer;\n this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectByteOffset);\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {\n RenderPassProps,\n ComputePassProps,\n CopyTextureToTextureOptions,\n CopyTextureToBufferOptions\n} from '@luma.gl/core';\nimport {CommandEncoder, CommandEncoderProps, Buffer, Texture} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUCommandBuffer} from './webgpu-command-buffer';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {WebGPURenderPass} from './webgpu-render-pass';\nimport {WebGPUComputePass} from './webgpu-compute-pass';\nimport {WebGPUTexture} from './webgpu-texture';\nimport {WebGPUQuerySet} from './webgpu-query-set';\n\nexport class WebGPUCommandEncoder extends CommandEncoder {\n readonly device: WebGPUDevice;\n readonly handle: GPUCommandEncoder;\n\n constructor(device: WebGPUDevice, props: CommandEncoderProps = {}) {\n super(device, props);\n this.device = device;\n this.handle =\n props.handle ||\n this.device.handle.createCommandEncoder({\n label: this.props.id\n // TODO was this removed in standard?\n // measureExecutionTime: this.props.measureExecutionTime\n });\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\n\n finish(props?: CommandEncoderProps): WebGPUCommandBuffer {\n this.device.pushErrorScope('validation');\n const commandBuffer = new WebGPUCommandBuffer(this, {\n id: props?.id || 'unnamed-command-buffer'\n });\n this.device.popErrorScope((error: GPUError) => {\n const message = `${this} command encoding: ${error.message}. Maybe add depthWriteEnabled to your Model?`;\n this.device.reportError(new Error(message), this)();\n this.device.debug();\n });\n return commandBuffer;\n }\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 return new WebGPURenderPass(this.device, props);\n }\n\n beginComputePass(props: ComputePassProps): WebGPUComputePass {\n return new WebGPUComputePass(this.device, props);\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n\n copyBufferToBuffer(options: // CopyBufferToBufferOptions\n {\n sourceBuffer: Buffer;\n sourceOffset?: number;\n destinationBuffer: Buffer;\n destinationOffset?: number;\n size?: number;\n }): void {\n const webgpuSourceBuffer = options.sourceBuffer as WebGPUBuffer;\n const WebGPUDestinationBuffer = options.destinationBuffer as WebGPUBuffer;\n this.handle.copyBufferToBuffer(\n webgpuSourceBuffer.handle,\n options.sourceOffset ?? 0,\n WebGPUDestinationBuffer.handle,\n options.destinationOffset ?? 0,\n options.size ?? 0\n );\n }\n\n copyBufferToTexture(options: // CopyBufferToTextureOptions\n {\n sourceBuffer: Buffer;\n offset?: number;\n bytesPerRow: number;\n rowsPerImage: number;\n\n destinationTexture: Texture;\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n\n origin?: number[] | [number, number, number];\n extent?: number[] | [number, number, number];\n }): void {\n const webgpuSourceBuffer = options.sourceBuffer as WebGPUBuffer;\n const WebGPUDestinationTexture = options.destinationTexture as WebGPUTexture;\n this.handle.copyBufferToTexture(\n {\n buffer: webgpuSourceBuffer.handle,\n offset: options.offset ?? 0,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage\n },\n {\n texture: WebGPUDestinationTexture.handle,\n mipLevel: options.mipLevel ?? 0,\n origin: options.origin ?? {}\n // aspect: options.aspect\n },\n {\n // @ts-ignore\n width: options.extent?.[0],\n height: options.extent?.[1],\n depthOrArrayLayers: options.extent?.[2]\n }\n );\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n // this.handle.copyTextureToBuffer(\n // // source\n // {},\n // // destination\n // {},\n // // copySize\n // {}\n // );\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n // this.handle.copyTextureToTexture(\n // // source\n // {},\n // // destination\n // {},\n // // copySize\n // {}\n // );\n }\n\n override pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n\n override popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n\n override insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n override resolveQuerySet(\n querySet: WebGPUQuerySet,\n destination: Buffer,\n options?: {\n firstQuery?: number;\n queryCount?: number;\n destinationOffset?: number;\n }\n ): void {\n const webgpuQuerySet = querySet;\n const webgpuBuffer = destination as WebGPUBuffer;\n this.handle.resolveQuerySet(\n webgpuQuerySet.handle,\n options?.firstQuery || 0,\n options?.queryCount || querySet.props.count - (options?.firstQuery || 0),\n webgpuBuffer.handle,\n options?.destinationOffset || 0\n );\n }\n}\n\n/*\n // setDataFromTypedArray(data): this {\n // const textureDataBuffer = this.device.handle.createBuffer({\n // size: data.byteLength,\n // usage: Buffer.COPY_DST | Buffer.COPY_SRC,\n // mappedAtCreation: true\n // });\n // new Uint8Array(textureDataBuffer.getMappedRange()).set(data);\n // textureDataBuffer.unmap();\n\n // this.setBuffer(textureDataBuffer);\n\n // textureDataBuffer.destroy();\n // return this;\n // }\n\n */\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {QuerySet, QuerySetProps} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\n\nexport type QuerySetProps2 = {\n type: 'occlusion' | 'timestamp';\n count: number;\n};\n\n/**\n * Immutable\n */\nexport class WebGPUQuerySet extends QuerySet {\n readonly device: WebGPUDevice;\n readonly handle: GPUQuerySet;\n\n constructor(device: WebGPUDevice, props: QuerySetProps) {\n super(device, props);\n this.device = device;\n this.handle =\n this.props.handle ||\n this.device.handle.createQuerySet({\n type: this.props.type,\n count: this.props.count\n });\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {\n log,\n PipelineLayout,\n PipelineLayoutProps,\n StorageBufferBindingLayout,\n StorageTextureBindingLayout\n} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\n\nexport class WebGPUPipelineLayout extends PipelineLayout {\n readonly device: WebGPUDevice;\n readonly handle: GPUPipelineLayout;\n\n constructor(device: WebGPUDevice, props: PipelineLayoutProps) {\n super(device, props);\n\n this.device = device;\n\n const bindGroupEntries = this.mapShaderLayoutToBindGroupEntries();\n\n this.handle = this.device.handle.createPipelineLayout({\n label: props?.id ?? 'unnamed-pipeline-layout',\n bindGroupLayouts: [\n // TODO (kaapp): We can cache these to re-use them across\n // layers, particularly if using a separate group for injected\n // bindings (e.g. project/lighting)\n this.device.handle.createBindGroupLayout({\n label: 'bind-group-layout',\n entries: bindGroupEntries\n })\n ]\n });\n }\n\n override destroy(): void {\n // WebGPUPipelineLayout has no destroy method.\n // @ts-expect-error\n this.handle = null;\n }\n\n protected mapShaderLayoutToBindGroupEntries(): GPUBindGroupLayoutEntry[] {\n // Set up the pipeline layout\n // TODO (kaapp): This only supports the first group, but so does the rest of the code\n const bindGroupEntries: GPUBindGroupLayoutEntry[] = [];\n\n for (let i = 0; i < this.props.shaderLayout.bindings.length; i++) {\n const binding = this.props.shaderLayout.bindings[i];\n const bindingTypeInfo: Omit<GPUBindGroupLayoutEntry, 'binding' | 'visibility'> = {};\n\n switch (binding.type) {\n case 'uniform': {\n bindingTypeInfo.buffer = {\n type: 'uniform',\n hasDynamicOffset: binding.hasDynamicOffset,\n minBindingSize: binding.minBindingSize\n };\n break;\n }\n\n case 'read-only-storage': {\n bindingTypeInfo.buffer = {\n type: 'read-only-storage',\n hasDynamicOffset: binding.hasDynamicOffset,\n minBindingSize: binding.minBindingSize\n };\n break;\n }\n\n case 'sampler': {\n bindingTypeInfo.sampler = {\n type: binding.samplerType\n };\n break;\n }\n\n case 'storage': {\n if (isStorageTextureBindingLayout(binding)) {\n bindingTypeInfo.storageTexture = {\n // TODO (kaapp): Not all formats in the binding layout are supported\n // by WebGPU, but at least it will provide a clear error for now.\n format: binding.format as GPUTextureFormat,\n access: binding.access,\n viewDimension: binding.viewDimension\n };\n } else {\n bindingTypeInfo.buffer = {\n type: 'storage',\n hasDynamicOffset: binding.hasDynamicOffset,\n minBindingSize: binding.minBindingSize\n };\n }\n break;\n }\n\n case 'texture': {\n bindingTypeInfo.texture = {\n multisampled: binding.multisampled,\n sampleType: binding.sampleType,\n viewDimension: binding.viewDimension\n };\n break;\n }\n\n default: {\n log.warn('unhandled binding type when creating pipeline descriptor')();\n }\n }\n\n const VISIBILITY_ALL =\n GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE;\n\n bindGroupEntries.push({\n binding: binding.location,\n visibility: binding.visibility || VISIBILITY_ALL,\n ...bindingTypeInfo\n });\n }\n\n return bindGroupEntries;\n }\n}\n\nconst isStorageTextureBindingLayout = (\n maybe: StorageBufferBindingLayout | StorageTextureBindingLayout\n): maybe is StorageTextureBindingLayout => {\n return (maybe as StorageTextureBindingLayout).format !== undefined;\n};\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport type {\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n DeviceTextureFormatCapabilities,\n VertexFormat,\n CanvasContextProps,\n BufferProps,\n SamplerProps,\n ShaderProps,\n TextureProps,\n ExternalTextureProps,\n FramebufferProps,\n RenderPipelineProps,\n ComputePipelineProps,\n VertexArrayProps,\n TransformFeedback,\n TransformFeedbackProps,\n QuerySet,\n QuerySetProps,\n DeviceProps,\n CommandEncoderProps,\n PipelineLayoutProps,\n} from '@luma.gl/core';\nimport {Device, DeviceFeatures} 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 {WebGPUVertexArray} from './resources/webgpu-vertex-array';\n\nimport {WebGPUCanvasContext} from './webgpu-canvas-context';\nimport {WebGPUCommandEncoder} from './resources/webgpu-command-encoder';\nimport {WebGPUCommandBuffer} from './resources/webgpu-command-buffer';\nimport {WebGPUQuerySet} from './resources/webgpu-query-set';\nimport {WebGPUPipelineLayout} from './resources/webgpu-pipeline-layout';\n\n/** WebGPU Device implementation */\nexport class WebGPUDevice extends Device {\n /** The underlying WebGPU device */\n readonly handle: GPUDevice;\n /* The underlying WebGPU adapter */\n readonly adapter: GPUAdapter;\n /* The underlying WebGPU adapter's info */\n readonly adapterInfo: GPUAdapterInfo;\n\n /** type of this device */\n readonly type = 'webgpu';\n\n readonly preferredColorFormat = navigator.gpu.getPreferredCanvasFormat() as\n | 'rgba8unorm'\n | 'bgra8unorm';\n readonly preferredDepthFormat = 'depth24plus';\n\n readonly features: DeviceFeatures;\n readonly info: DeviceInfo;\n readonly limits: DeviceLimits;\n\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n override canvasContext: WebGPUCanvasContext | null = null;\n\n private _isLost: boolean = false;\n commandEncoder: WebGPUCommandEncoder;\n\n override get [Symbol.toStringTag](): string {\n return 'WebGPUDevice';\n }\n\n override toString(): string {\n return `WebGPUDevice(${this.id})`;\n }\n\n constructor(\n props: DeviceProps,\n device: GPUDevice,\n adapter: GPUAdapter,\n adapterInfo: GPUAdapterInfo\n ) {\n super({...props, id: props.id || 'webgpu-device'});\n this.handle = device;\n this.adapter = adapter;\n this.adapterInfo = adapterInfo;\n\n this.info = this._getInfo();\n this.features = this._getFeatures();\n this.limits = this.handle.limits;\n\n // Listen for uncaptured WebGPU errors\n device.addEventListener('uncapturederror', (event: Event) => {\n event.preventDefault();\n // TODO is this the right way to make sure the error is an Error instance?\n const errorMessage =\n event instanceof GPUUncapturedErrorEvent ? event.error.message : 'Unknown WebGPU error';\n this.reportError(new Error(errorMessage), this)();\n this.debug();\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 const canvasContextProps = Device._getCanvasContextProps(props);\n if (canvasContextProps) {\n this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);\n }\n\n this.commandEncoder = this.createCommandEncoder({});\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 isLost(): boolean {\n return this._isLost;\n }\n\n override isVertexFormatSupported(format: VertexFormat): boolean {\n const info = this.getVertexFormatInfo(format);\n return !info.webglOnly;\n }\n\n getTextureByteAlignment(): number {\n return 1;\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer {\n const newProps = this._normalizeBufferProps(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 return new WebGPUFramebuffer(this, props);\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 override createCommandEncoder(props?: CommandEncoderProps): WebGPUCommandEncoder {\n return new WebGPUCommandEncoder(this, props);\n }\n\n // WebGPU specifics\n\n createTransformFeedback(props: TransformFeedbackProps): TransformFeedback {\n throw new Error('Transform feedback not supported in WebGPU');\n }\n\n override createQuerySet(props: QuerySetProps): QuerySet {\n return new WebGPUQuerySet(this, props);\n }\n\n createCanvasContext(props: CanvasContextProps): WebGPUCanvasContext {\n return new WebGPUCanvasContext(this, this.adapter, props);\n }\n\n createPipelineLayout(props: PipelineLayoutProps): WebGPUPipelineLayout {\n return new WebGPUPipelineLayout(this, props);\n }\n\n submit(commandBuffer?: WebGPUCommandBuffer): void {\n if (!commandBuffer) {\n commandBuffer = this.commandEncoder.finish();\n this.commandEncoder.destroy();\n this.commandEncoder = this.createCommandEncoder({id: `${this.id}-default-encoder`});\n }\n\n this.pushErrorScope('validation');\n this.handle.queue.submit([commandBuffer.handle]);\n this.popErrorScope((error: GPUError) => {\n this.reportError(new Error(`${this} command submission: ${error.message}`), this)();\n this.debug();\n });\n }\n\n // WebGPU specific\n\n pushErrorScope(scope: 'validation' | 'out-of-memory'): void {\n this.handle.pushErrorScope(scope);\n }\n\n popErrorScope(handler: (error: GPUError) => void): void {\n this.handle.popErrorScope().then((error: GPUError | null) => {\n if (error) {\n handler(error);\n }\n });\n }\n\n // PRIVATE METHODS\n\n protected _getInfo(): DeviceInfo {\n const [driver, driverVersion] = ((this.adapterInfo as any).driver || '').split(' Version ');\n\n // See https://developer.chrome.com/blog/new-in-webgpu-120#adapter_information_updates\n const vendor = this.adapterInfo.vendor || this.adapter.__brand || 'unknown';\n const renderer = driver || '';\n const version = driverVersion || '';\n\n const gpu = vendor === 'apple' ? 'apple' : 'unknown'; // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',\n const gpuArchitecture = this.adapterInfo.architecture || 'unknown';\n const gpuBackend = (this.adapterInfo as any).backend || 'unknown';\n const gpuType = ((this.adapterInfo as any).type || '').split(' ')[0].toLowerCase() || 'unknown';\n\n return {\n type: 'webgpu',\n vendor,\n renderer,\n version,\n gpu,\n gpuType,\n gpuBackend,\n gpuArchitecture,\n shadingLanguage: 'wgsl',\n shadingLanguageVersion: 100\n };\n }\n\n protected _getFeatures(): DeviceFeatures {\n // Initialize with actual WebGPU Features (note that unknown features may not be in DeviceFeature type)\n const features = new Set<DeviceFeature>(this.handle.features as Set<DeviceFeature>);\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 // Some subsets of WebGPU extensions correspond to WebGL extensions\n if (features.has('texture-compression-bc')) {\n features.add('texture-compression-bc5-webgl');\n }\n\n const WEBGPU_ALWAYS_FEATURES: DeviceFeature[] = [\n 'timer-query-webgl',\n 'compilation-status-async-webgl',\n 'float32-renderable-webgl',\n 'float16-renderable-webgl',\n 'norm16-renderable-webgl',\n 'texture-filterable-anisotropic-webgl',\n 'shader-noperspective-interpolation-webgl'\n ];\n\n for (const feature of WEBGPU_ALWAYS_FEATURES) {\n features.add(feature);\n }\n\n return new DeviceFeatures(Array.from(features), this.props._disabledFeatures);\n }\n\n override _getDeviceSpecificTextureFormatCapabilities(\n capabilities: DeviceTextureFormatCapabilities\n ): DeviceTextureFormatCapabilities {\n const {format} = capabilities;\n if (format.includes('webgl')) {\n return {format, create: false, render: false, filter: false, blend: false, store: false};\n }\n return capabilities;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// WEBGPU ADAPTER\nexport type {WebGPUAdapter} from './adapter/webgpu-adapter';\nexport {webgpuAdapter} from './adapter/webgpu-adapter';\n\n// WEBGPU CLASSES (typically not accessed directly)\nexport {WebGPUDevice} from './adapter/webgpu-device';\nexport {WebGPUBuffer} from './adapter/resources/webgpu-buffer';\nexport {WebGPUTexture} from './adapter/resources/webgpu-texture';\nexport {WebGPUSampler} from './adapter/resources/webgpu-sampler';\nexport {WebGPUShader} from './adapter/resources/webgpu-shader';\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport {Adapter, DeviceProps, log} from '@luma.gl/core';\nimport type {WebGPUDevice} from './webgpu-device';\n\nexport class WebGPUAdapter extends Adapter {\n /** type of device's created by this adapter */\n readonly type: WebGPUDevice['type'] = 'webgpu';\n\n isSupported(): boolean {\n // Check if WebGPU is available\n return Boolean(typeof navigator !== 'undefined' && navigator.gpu);\n }\n\n isDeviceHandle(handle: unknown): boolean {\n if (typeof GPUDevice !== 'undefined' && handle instanceof GPUDevice) {\n return true;\n }\n\n // TODO - WebGPU does not yet seem to have a stable in-browser API, so we \"sniff\" for members instead\n if ((handle as any)?.queue) {\n return true;\n }\n\n return false;\n }\n\n async create(props: DeviceProps): Promise<WebGPUDevice> {\n if (!navigator.gpu) {\n throw new Error('WebGPU not available. Recent Chrome browsers should work.');\n }\n\n log.groupCollapsed(1, 'WebGPUDevice created')();\n try {\n const adapter = await navigator.gpu.requestAdapter({\n powerPreference: 'high-performance'\n // forceSoftware: false\n });\n\n if (!adapter) {\n throw new Error('Failed to request WebGPU adapter');\n }\n\n // Note: adapter.requestAdapterInfo() has been replaced with adapter.info. Fall back in case adapter.info is not available\n const adapterInfo =\n adapter.info ||\n // @ts-ignore\n (await adapter.requestAdapterInfo?.());\n log.probe(2, 'Adapter available', adapterInfo)();\n\n const requiredFeatures: GPUFeatureName[] = [];\n const requiredLimits: Record<string, number> = {};\n\n if (props._requestMaxLimits) {\n // Require all features\n requiredFeatures.push(...(Array.from(adapter.features) as GPUFeatureName[]));\n\n // Require all limits\n // Filter out chrome specific keys (avoid crash)\n const limits = Object.keys(adapter.limits).filter(\n key => !['minSubgroupSize', 'maxSubgroupSize'].includes(key)\n );\n for (const key of limits) {\n const limit = key as keyof GPUSupportedLimits;\n const value = adapter.limits[limit];\n if (typeof value === 'number') {\n requiredLimits[limit] = value;\n }\n }\n }\n\n const gpuDevice = await adapter.requestDevice({\n requiredFeatures,\n requiredLimits\n });\n\n log.probe(1, 'GPUDevice available')();\n\n const {WebGPUDevice} = await import('./webgpu-device');\n\n const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo);\n\n log.probe(\n 1,\n 'Device created. For more info, set chrome://flags/#enable-webgpu-developer-features'\n )();\n log.table(1, device.info)();\n\n return device;\n } finally {\n log.groupEnd(1)();\n }\n }\n\n async attach(handle: GPUDevice): Promise<WebGPUDevice> {\n throw new Error('WebGPUAdapter.attach() not implemented');\n }\n}\n\nexport const webgpuAdapter = new WebGPUAdapter();\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAIA,aAGa;AAPb;;;AAIA,kBAAoE;AAG9D,IAAO,eAAP,cAA4B,mBAAM;MAC7B;MACA;MACA;MAET,YAAY,QAAsB,OAAkB;AAZtD;AAaI,cAAM,QAAQ,KAAK;AACnB,aAAK,SAAS;AAEd,aAAK,aAAa,MAAM,gBAAc,WAAM,SAAN,mBAAY,eAAc;AAChE,cAAM,mBAAmB,QAAQ,KAAK,MAAM,YAAY,MAAM,IAAI;AAGlE,cAAM,OAAO,KAAK,KAAK,KAAK,aAAa,CAAC,IAAI;AAE9C,aAAK,OAAO,eAAe,eAAe;AAC1C,aAAK,OAAO,eAAe,YAAY;AACvC,aAAK,SACH,KAAK,MAAM,UACX,KAAK,OAAO,OAAO,aAAa;UAC9B,OAAO,KAAK,MAAM;;UAElB,OAAO,KAAK,MAAM,SAAS,eAAe,SAAS,eAAe;UAClE;UACA;SACD;AACH,aAAK,OAAO,cAAc,CAAC,UAAmB;AAC5C,eAAK,OAAO,YAAY,IAAI,MAAM,GAAG,wBAAwB,MAAM,SAAS,GAAG,IAAI,EAAC;AACpF,eAAK,OAAO,MAAK;QACnB,CAAC;AACD,aAAK,OAAO,cAAc,CAAC,UAAmB;AAC5C,eAAK,O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AAC,CAAC,mBAAmB,iBAAiB,EAAE,SAAS,GAAG,CAAC;AAE9D,mBAAW,OAAO,QAAQ;AACxB,gBAAM,QAAQ;AACd,gBAAM,QAAQ,QAAQ,OAAO,KAAK;AAClC,cAAI,OAAO,UAAU,UAAU;AAC7B,2BAAe,KAAK,IAAI;UAC1B;QACF;MACF;AAEA,YAAM,YAAY,MAAM,QAAQ,cAAc;QAC5C;QACA;OACD;AAED,wBAAI,MAAM,GAAG,qBAAqB,EAAC;AAEnC,YAAM,EAAC,cAAAC,cAAY,IAAI,MAAM;AAE7B,YAAM,SAAS,IAAIA,cAAa,OAAO,WAAW,SAAS,WAAW;AAEtE,wBAAI,MACF,GACA,qFAAqF,EACtF;AACD,wBAAI,MAAM,GAAG,OAAO,IAAI,EAAC;AAEzB,aAAO;IACT;AACE,wBAAI,SAAS,CAAC,EAAC;IACjB;EACF;EAEA,MAAM,OAAO,QAAiB;AAC5B,UAAM,IAAI,MAAM,wCAAwC;EAC1D;;AAGK,IAAM,gBAAgB,IAAI,cAAa;;;AD/F9C;AACA;AACA;AACA;AACA;",
6
- "names": ["import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "name", "import_core", "import_core", "name", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "WebGPUDevice"]
3
+ "sources": ["../src/adapter/resources/webgpu-buffer.ts", "../src/adapter/helpers/convert-texture-format.ts", "../src/adapter/resources/webgpu-sampler.ts", "../src/adapter/resources/webgpu-texture-view.ts", "../src/adapter/resources/webgpu-texture.ts", "../src/adapter/resources/webgpu-external-texture.ts", "../src/adapter/resources/webgpu-shader.ts", "../src/adapter/helpers/webgpu-parameters.ts", "../src/adapter/helpers/get-bind-group.ts", "../src/adapter/helpers/get-vertex-buffer-layout.ts", "../src/adapter/resources/webgpu-render-pipeline.ts", "../src/adapter/resources/webgpu-framebuffer.ts", "../src/adapter/resources/webgpu-compute-pipeline.ts", "../src/adapter/resources/webgpu-vertex-array.ts", "../src/adapter/webgpu-canvas-context.ts", "../src/adapter/resources/webgpu-command-buffer.ts", "../src/adapter/resources/webgpu-render-pass.ts", "../src/adapter/resources/webgpu-compute-pass.ts", "../src/adapter/resources/webgpu-command-encoder.ts", "../src/adapter/resources/webgpu-query-set.ts", "../src/adapter/resources/webgpu-pipeline-layout.ts", "../src/adapter/resources/webgpu-fence.ts", "../src/wgsl/get-shader-layout-wgsl.ts", "../src/adapter/webgpu-device.ts", "../src/index.ts", "../src/adapter/webgpu-adapter.ts"],
4
+ "sourcesContent": ["// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {log, Buffer, type BufferProps, type BufferMapCallback} from '@luma.gl/core';\nimport {type WebGPUDevice} from '../webgpu-device';\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 = props.byteLength || props.data?.byteLength || 0;\n const mappedAtCreation = Boolean(this.props.onMapped || props.data);\n\n // WebGPU buffers must be aligned to 4 bytes\n const size = Math.ceil(this.byteLength / 4) * 4;\n\n this.device.pushErrorScope('out-of-memory');\n this.device.pushErrorScope('validation');\n this.handle =\n this.props.handle ||\n this.device.handle.createBuffer({\n label: this.props.id,\n // usage defaults to vertex\n usage: this.props.usage || GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,\n mappedAtCreation,\n size\n });\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} creation failed ${error.message}`), this)();\n this.device.debug();\n });\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} out of memory: ${error.message}`), this)();\n this.device.debug();\n });\n\n this.device.pushErrorScope('validation');\n if (props.data || props.onMapped) {\n try {\n const arrayBuffer = this.handle.getMappedRange();\n if (props.data) {\n const typedArray = props.data;\n // @ts-expect-error\n new typedArray.constructor(arrayBuffer).set(typedArray);\n } else {\n props.onMapped?.(arrayBuffer, 'mapped');\n }\n } finally {\n this.handle.unmap();\n }\n }\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} creation failed ${error.message}`), this)();\n this.device.debug();\n });\n }\n\n override destroy(): void {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n\n write(data: ArrayBufferLike | ArrayBufferView | SharedArrayBuffer, byteOffset = 0) {\n const arrayBuffer = ArrayBuffer.isView(data) ? data.buffer : data;\n const dataByteOffset = ArrayBuffer.isView(data) ? data.byteOffset : 0;\n\n this.device.pushErrorScope('validation');\n\n // WebGPU provides multiple ways to write a buffer, this is the simplest API\n this.device.handle.queue.writeBuffer(\n this.handle,\n byteOffset,\n arrayBuffer,\n dataByteOffset,\n data.byteLength\n );\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this}.write() ${error.message}`), this)();\n this.device.debug();\n });\n }\n\n async mapAndWriteAsync(\n callback: BufferMapCallback<void>,\n byteOffset: number = 0,\n byteLength: number = this.byteLength - byteOffset\n ): Promise<void> {\n // Unless the application created and supplied a mappable buffer, a staging buffer is needed\n const isMappable = (this.usage & Buffer.MAP_WRITE) !== 0;\n const mappableBuffer: WebGPUBuffer | null = !isMappable\n ? this._getMappableBuffer(Buffer.MAP_WRITE | Buffer.COPY_SRC, 0, this.byteLength)\n : null;\n\n const writeBuffer = mappableBuffer || this;\n\n // const isWritable = this.usage & Buffer.MAP_WRITE;\n // Map the temp buffer and read the data.\n this.device.pushErrorScope('validation');\n try {\n await this.device.handle.queue.onSubmittedWorkDone();\n await writeBuffer.handle.mapAsync(GPUMapMode.WRITE, byteOffset, byteLength);\n const arrayBuffer = writeBuffer.handle.getMappedRange(byteOffset, byteLength);\n // eslint-disable-next-line @typescript-eslint/await-thenable\n await callback(arrayBuffer, 'mapped');\n writeBuffer.handle.unmap();\n if (mappableBuffer) {\n this._copyBuffer(mappableBuffer, byteOffset, byteLength);\n }\n } finally {\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this}.mapAndWriteAsync() ${error.message}`), this)();\n this.device.debug();\n });\n mappableBuffer?.destroy();\n }\n }\n\n async readAsync(\n byteOffset: number = 0,\n byteLength = this.byteLength - byteOffset\n ): Promise<Uint8Array> {\n return this.mapAndReadAsync(\n arrayBuffer => new Uint8Array(arrayBuffer.slice(0)),\n byteOffset,\n byteLength\n );\n }\n\n async mapAndReadAsync<T>(\n callback: BufferMapCallback<T>,\n byteOffset = 0,\n byteLength = this.byteLength - byteOffset\n ): Promise<T> {\n if (byteOffset % 8 !== 0 || byteLength % 4 !== 0) {\n throw new Error('byteOffset must be multiple of 8 and byteLength multiple of 4');\n }\n if (byteOffset + byteLength > this.handle.size) {\n throw new Error('Mapping range exceeds buffer size');\n }\n\n // Unless the application created and supplied a mappable buffer, a staging buffer is needed\n const isMappable = (this.usage & Buffer.MAP_READ) !== 0;\n const mappableBuffer: WebGPUBuffer | null = !isMappable\n ? this._getMappableBuffer(Buffer.MAP_READ | Buffer.COPY_DST, 0, this.byteLength)\n : null;\n\n const readBuffer = mappableBuffer || this;\n\n // Map the temp buffer and read the data.\n this.device.pushErrorScope('validation');\n try {\n await this.device.handle.queue.onSubmittedWorkDone();\n if (mappableBuffer) {\n mappableBuffer._copyBuffer(this);\n }\n await readBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);\n const arrayBuffer = readBuffer.handle.getMappedRange(byteOffset, byteLength);\n // eslint-disable-next-line @typescript-eslint/await-thenable\n const result = await callback(arrayBuffer, 'mapped');\n readBuffer.handle.unmap();\n return result;\n } finally {\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this}.mapAndReadAsync() ${error.message}`), this)();\n this.device.debug();\n });\n mappableBuffer?.destroy();\n }\n }\n\n readSyncWebGL(byteOffset?: number, byteLength?: number): Uint8Array<ArrayBuffer> {\n throw new Error('Not implemented');\n }\n\n // INTERNAL METHODS\n\n /**\n * @todo - A small set of mappable buffers could be cached on the device,\n * however this goes against the goal of keeping core as a thin GPU API layer.\n */\n protected _getMappableBuffer(\n usage: number, // Buffer.MAP_READ | Buffer.MAP_WRITE,\n byteOffset: number,\n byteLength: number\n ): WebGPUBuffer {\n log.warn(`${this} is not readable, creating a temporary Buffer`);\n const readableBuffer = new WebGPUBuffer(this.device, {usage, byteLength});\n\n return readableBuffer;\n }\n\n protected _copyBuffer(\n sourceBuffer: WebGPUBuffer,\n byteOffset: number = 0,\n byteLength: number = this.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 this.device.pushErrorScope('validation');\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToBuffer(\n sourceBuffer.handle,\n byteOffset,\n this.handle,\n byteOffset,\n byteLength\n );\n this.device.handle.queue.submit([commandEncoder.finish()]);\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this}._getReadableBuffer() ${error.message}`), this)();\n this.device.debug();\n });\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {TextureFormat} from '@luma.gl/core';\n\n/** Ensure a texture format is WebGPU compatible */\nexport function getWebGPUTextureFormat(format: TextureFormat): GPUTextureFormat {\n if (format.includes('webgl')) {\n throw new Error('webgl-only format');\n }\n return format as GPUTextureFormat;\n}\n", "// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {Sampler, SamplerProps} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\n\nexport type WebGPUSamplerProps = SamplerProps & {\n handle?: GPUSampler;\n};\n\n/**\n * A WebGPU sampler object\n */\nexport class WebGPUSampler extends Sampler {\n readonly device: WebGPUDevice;\n readonly handle: GPUSampler;\n\n constructor(device: WebGPUDevice, props: WebGPUSamplerProps) {\n super(device, props);\n this.device = device;\n\n // Prepare sampler props. Mostly identical\n const samplerDescriptor: Partial<GPUSamplerDescriptor> = {\n ...this.props,\n mipmapFilter: undefined\n };\n\n // props.compare automatically turns this into a comparison sampler\n if (props.type !== 'comparison-sampler') {\n delete samplerDescriptor.compare;\n }\n\n // disable mipmapFilter if not set\n if (props.mipmapFilter && props.mipmapFilter !== 'none') {\n samplerDescriptor.mipmapFilter = props.mipmapFilter;\n }\n\n this.handle = props.handle || this.device.handle.createSampler(samplerDescriptor);\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {\n // GPUSampler does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {TextureView, TextureViewProps} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport type {WebGPUTexture} from './webgpu-texture';\n\n/*\n // type = sampler\n samplerType?: 'filtering' | 'non-filtering' | 'comparison';\n\n // type = texture\n viewDimension?: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';\n sampleType?: 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint';\n multisampled?: boolean;\n\n // type = storage\n viewDimension?: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';\n access: 'read-only' | 'write-only';\n format: string;\n*/\n\nexport type WebGPUTextureViewProps = TextureViewProps & {\n handle?: GPUTextureView;\n};\n\n/**\n *\n */\nexport class WebGPUTextureView extends TextureView {\n readonly device: WebGPUDevice;\n readonly handle: GPUTextureView;\n readonly texture: WebGPUTexture;\n\n constructor(device: WebGPUDevice, props: WebGPUTextureViewProps & {texture: WebGPUTexture}) {\n super(device, props);\n this.device = device;\n this.texture = props.texture;\n\n this.device.pushErrorScope('validation');\n this.handle =\n // props.handle ||\n this.texture.handle.createView({\n format: (this.props.format || this.texture.format) as GPUTextureFormat,\n dimension: this.props.dimension || this.texture.dimension,\n aspect: this.props.aspect,\n baseMipLevel: this.props.baseMipLevel,\n mipLevelCount: this.props.mipLevelCount,\n baseArrayLayer: this.props.baseArrayLayer,\n arrayLayerCount: this.props.arrayLayerCount\n });\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`TextureView constructor: ${error.message}`), this)();\n this.device.debug();\n });\n\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {\n // GPUTextureView does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "// luma.gl, MIT license\nimport {\n type TextureProps,\n type TextureViewProps,\n type CopyExternalImageOptions,\n type CopyImageDataOptions,\n type TextureReadOptions,\n type TextureWriteOptions,\n type SamplerProps,\n Buffer,\n Texture,\n log,\n textureFormatDecoder\n} from '@luma.gl/core';\n\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUSampler} from './webgpu-sampler';\nimport {WebGPUTextureView} from './webgpu-texture-view';\n\n/** WebGPU implementation of the luma.gl core Texture resource */\nexport class WebGPUTexture extends Texture {\n readonly device: WebGPUDevice;\n readonly handle: GPUTexture;\n sampler: WebGPUSampler;\n view: WebGPUTextureView;\n\n constructor(device: WebGPUDevice, props: TextureProps) {\n super(device, props, {byteAlignment: 256}); // WebGPU requires row width to be a multiple of 256 bytes\n this.device = device;\n\n this.device.pushErrorScope('out-of-memory');\n this.device.pushErrorScope('validation');\n\n this.handle =\n this.props.handle ||\n this.device.handle.createTexture({\n label: this.id,\n size: {\n width: this.width,\n height: this.height,\n depthOrArrayLayers: this.depth\n },\n usage: this.props.usage || Texture.TEXTURE | Texture.COPY_DST,\n dimension: this.baseDimension,\n format: getWebGPUTextureFormat(this.format),\n mipLevelCount: this.mipLevels,\n sampleCount: this.props.samples\n });\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} constructor: ${error.message}`), this)();\n this.device.debug();\n });\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} out of memory: ${error.message}`), this)();\n this.device.debug();\n });\n\n // Update props if external handle was supplied - used mainly by CanvasContext.getDefaultFramebuffer()\n // TODO - Read all properties directly from the supplied handle?\n if (this.props.handle) {\n this.handle.label ||= this.id;\n // @ts-expect-error readonly\n this.width = this.handle.width;\n // @ts-expect-error readonly\n this.height = this.handle.height;\n }\n\n this.sampler =\n props.sampler instanceof WebGPUSampler\n ? props.sampler\n : new WebGPUSampler(this.device, (props.sampler as SamplerProps) || {});\n\n this.view = new WebGPUTextureView(this.device, {\n ...this.props,\n texture: this,\n mipLevelCount: this.mipLevels,\n // Note: arrayLayerCount controls the view of array textures, but does not apply to 3d texture depths\n arrayLayerCount: this.dimension !== '3d' ? this.depth : 1\n });\n\n // Set initial data\n // Texture base class strips out the data prop from this.props, so we need to handle it here\n this._initializeData(props.data);\n }\n\n override destroy(): void {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n\n createView(props: TextureViewProps): WebGPUTextureView {\n return new WebGPUTextureView(this.device, {...props, texture: this});\n }\n\n copyExternalImage(options_: CopyExternalImageOptions): {width: number; height: number} {\n const options = this._normalizeCopyExternalImageOptions(options_);\n\n this.device.pushErrorScope('validation');\n this.device.handle.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source: options.image,\n origin: [options.sourceX, options.sourceY],\n flipY: false // options.flipY\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: this.handle,\n origin: [options.x, options.y, options.z],\n mipLevel: options.mipLevel,\n aspect: options.aspect,\n colorSpace: options.colorSpace,\n premultipliedAlpha: options.premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [options.width, options.height, options.depth] // depth is always 1 for 2D textures\n );\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`copyExternalImage: ${error.message}`), this)();\n this.device.debug();\n });\n\n // TODO - should these be clipped to the texture size minus x,y,z?\n return {width: options.width, height: options.height};\n }\n\n copyImageData(options_: CopyImageDataOptions): void {\n const {width, height, depth} = this;\n const options = this._normalizeCopyImageDataOptions(options_);\n this.device.pushErrorScope('validation');\n\n this.device.handle.queue.writeTexture(\n // destination: GPUImageCopyTexture\n {\n // texture subresource\n texture: this.handle,\n mipLevel: options.mipLevel,\n aspect: options.aspect,\n // origin to write to\n origin: [options.x, options.y, options.z]\n },\n // data\n options.data,\n // dataLayout: GPUImageDataLayout\n {\n offset: options.byteOffset,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage\n },\n // size: GPUExtent3D - extents of the content to write\n [width, height, depth]\n );\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`copyImageData: ${error.message}`), this)();\n this.device.debug();\n });\n }\n\n override generateMipmapsWebGL(): void {\n log.warn(`${this}: generateMipmaps not supported in WebGPU`)();\n }\n\n getImageDataLayout(options: TextureReadOptions): {\n byteLength: number;\n bytesPerRow: number;\n rowsPerImage: number;\n } {\n return {\n byteLength: 0,\n bytesPerRow: 0,\n rowsPerImage: 0\n };\n }\n\n override readBuffer(options: TextureReadOptions = {}, buffer?: Buffer): Buffer {\n const {\n x = 0,\n y = 0,\n z = 0,\n width = this.width,\n height = this.height,\n depthOrArrayLayers = this.depth,\n mipLevel = 0,\n aspect = 'all'\n } = options;\n\n const layout = this.computeMemoryLayout(options);\n\n const {bytesPerRow, rowsPerImage, byteLength} = layout;\n\n // Create a GPUBuffer to hold the copied pixel data.\n const readBuffer =\n buffer ||\n this.device.createBuffer({\n byteLength,\n usage: Buffer.COPY_DST | Buffer.MAP_READ\n });\n const gpuReadBuffer = readBuffer.handle as GPUBuffer;\n\n // Record commands to copy from the texture to the buffer.\n const gpuDevice = this.device.handle;\n\n this.device.pushErrorScope('validation');\n const commandEncoder = gpuDevice.createCommandEncoder();\n commandEncoder.copyTextureToBuffer(\n // source\n {\n texture: this.handle,\n origin: {x, y, z},\n // origin: [options.x, options.y, 0], // options.depth],\n mipLevel,\n aspect\n // colorSpace: options.colorSpace,\n // premultipliedAlpha: options.premultipliedAlpha\n },\n // destination\n {\n buffer: gpuReadBuffer,\n offset: 0,\n bytesPerRow,\n rowsPerImage\n },\n // copy size\n {\n width,\n height,\n depthOrArrayLayers\n }\n );\n\n // Submit the command.\n const commandBuffer = commandEncoder.finish();\n this.device.handle.queue.submit([commandBuffer]);\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} readBuffer: ${error.message}`), this)();\n this.device.debug();\n });\n\n return readBuffer;\n }\n\n override async readDataAsync(options: TextureReadOptions = {}): Promise<ArrayBuffer> {\n const buffer = this.readBuffer(options);\n const data = await buffer.readAsync();\n buffer.destroy();\n return data.buffer as ArrayBuffer;\n }\n\n override writeBuffer(buffer: Buffer, options: TextureWriteOptions = {}) {\n const {\n x = 0,\n y = 0,\n z = 0,\n width = this.width,\n height = this.height,\n depthOrArrayLayers = this.depth,\n mipLevel = 0,\n aspect = 'all'\n } = options;\n\n const layout = this.computeMemoryLayout(options);\n\n // Get the data on the CPU.\n // await buffer.mapAndReadAsync();\n\n const {bytesPerRow, rowsPerImage} = layout;\n\n const gpuDevice = this.device.handle;\n\n this.device.pushErrorScope('validation');\n const commandEncoder = gpuDevice.createCommandEncoder();\n commandEncoder.copyBufferToTexture(\n {\n buffer: buffer.handle as GPUBuffer,\n offset: 0,\n bytesPerRow,\n rowsPerImage\n },\n {\n texture: this.handle,\n origin: {x, y, z},\n mipLevel,\n aspect\n },\n {width, height, depthOrArrayLayers}\n );\n const commandBuffer = commandEncoder.finish();\n this.device.handle.queue.submit([commandBuffer]);\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} writeBuffer: ${error.message}`), this)();\n this.device.debug();\n });\n }\n\n override writeData(data: ArrayBuffer | ArrayBufferView, options: TextureWriteOptions = {}): void {\n const device = this.device;\n\n const {\n x = 0,\n y = 0,\n z = 0,\n width = this.width,\n height = this.height,\n depthOrArrayLayers = this.depth,\n mipLevel = 0,\n aspect = 'all'\n } = options;\n\n const layout = textureFormatDecoder.computeMemoryLayout({\n format: this.format,\n width: this.width,\n height: this.height,\n depth: this.depth,\n byteAlignment: this.byteAlignment\n });\n\n const {bytesPerRow, rowsPerImage} = layout;\n\n this.device.pushErrorScope('validation');\n device.handle.queue.writeTexture(\n {\n texture: this.handle,\n mipLevel,\n aspect,\n origin: {x, y, z}\n },\n data,\n {\n offset: 0,\n bytesPerRow,\n rowsPerImage\n },\n {width, height, depthOrArrayLayers}\n );\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} writeData: ${error.message}`), this)();\n this.device.debug();\n });\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ExternalTexture, ExternalTextureProps, SamplerProps} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUSampler} from './webgpu-sampler';\n\n/**\n * Cheap, temporary texture view for videos\n * Only valid within same callback, destroyed automatically as a microtask.\n */\nexport class WebGPUExternalTexture extends ExternalTexture {\n readonly device: WebGPUDevice;\n readonly handle: GPUExternalTexture;\n sampler: WebGPUSampler;\n\n constructor(device: WebGPUDevice, props: ExternalTextureProps) {\n super(device, props);\n this.device = device;\n this.handle =\n this.props.handle ||\n this.device.handle.importExternalTexture({\n source: props.source,\n colorSpace: props.colorSpace\n });\n // @ts-expect-error\n this.sampler = null;\n }\n\n override destroy(): void {\n // External textures are destroyed automatically,\n // as a microtask, instead of manually or upon garbage collection like other resources.\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n\n /** Set default sampler */\n setSampler(sampler: WebGPUSampler | SamplerProps): this {\n // We can accept a sampler instance or set of props;\n this.sampler =\n sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {ShaderProps, CompilerMessage} from '@luma.gl/core';\nimport {Shader} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\n\n/**\n * Immutable shader\n */\nexport class WebGPUShader extends Shader {\n readonly device: WebGPUDevice;\n readonly handle: GPUShaderModule;\n\n constructor(device: WebGPUDevice, props: ShaderProps) {\n super(device, props);\n this.device = device;\n\n const isGLSL = props.source.includes('#version');\n if (this.props.language === 'glsl' || isGLSL) {\n throw new Error('GLSL shaders are not supported in WebGPU');\n }\n\n this.device.pushErrorScope('validation');\n this.handle = this.props.handle || this.device.handle.createShaderModule({code: props.source});\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(\n new Error(`${this} creation failed:\\n\"${error.message}\"`),\n this,\n this.props.source\n )();\n this.device.debug();\n });\n\n this.handle.label = this.props.id;\n this._checkCompilationError();\n }\n\n get asyncCompilationStatus(): Promise<any> {\n return this.getCompilationInfo().then(() => this.compilationStatus);\n }\n\n async _checkCompilationError(): Promise<void> {\n const shaderLog = await this.getCompilationInfo();\n const hasErrors = Boolean(shaderLog.find(msg => msg.type === 'error'));\n this.compilationStatus = hasErrors ? 'error' : 'success';\n this.debugShader();\n\n if (this.compilationStatus === 'error') {\n // Note: Even though this error is asynchronous and thrown after the constructor completes,\n // it will result in a useful stack trace leading back to the constructor\n this.device.reportError(new Error(`Shader compilation error`), this, shaderLog)();\n this.device.debug();\n }\n }\n\n override destroy(): void {\n // Note: WebGPU does not offer a method to destroy shaders\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n\n /** Returns compilation info for this shader */\n async getCompilationInfo(): Promise<readonly CompilerMessage[]> {\n const compilationInfo = await this.handle.getCompilationInfo();\n return compilationInfo.messages;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Parameters, log} from '@luma.gl/core';\n\nfunction addDepthStencil(descriptor: GPURenderPipelineDescriptor): GPUDepthStencilState {\n descriptor.depthStencil = descriptor.depthStencil || {\n // required, set something\n format: 'depth24plus',\n stencilFront: {},\n stencilBack: {},\n // TODO can this cause trouble? Should we set to WebGPU defaults? Are there defaults?\n depthWriteEnabled: false,\n depthCompare: 'less-equal'\n };\n return descriptor.depthStencil;\n}\n\nfunction addDepthStencilFront(descriptor: GPURenderPipelineDescriptor): GPUStencilFaceState {\n const depthStencil = addDepthStencil(descriptor);\n // @ts-ignore\n return depthStencil.stencilFront;\n}\n\nfunction addDepthStencilBack(descriptor: GPURenderPipelineDescriptor): GPUStencilFaceState {\n const depthStencil = addDepthStencil(descriptor);\n // @ts-ignore\n return depthStencil.stencilBack;\n}\n\n/**\n * Supports for luma.gl's flat parameter space\n * Populates the corresponding sub-objects in a GPURenderPipelineDescriptor\n */\nexport const PARAMETER_TABLE: Record<keyof Parameters, Function> = {\n // RASTERIZATION PARAMETERS\n\n cullMode: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.cullMode = value;\n },\n\n frontFace: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.frontFace = value;\n },\n\n // DEPTH\n\n depthWriteEnabled: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n if (value) {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthWriteEnabled = value;\n }\n },\n\n depthCompare: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthCompare = value;\n },\n\n depthFormat: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.format = value;\n },\n\n depthBias: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBias = value;\n },\n\n depthBiasSlopeScale: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasSlopeScale = value;\n },\n\n depthBiasClamp: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasClamp = value;\n },\n\n // STENCIL\n\n stencilReadMask: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilReadMask = value;\n },\n\n stencilWriteMask: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilWriteMask = value;\n },\n\n stencilCompare: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.compare = value;\n stencilBack.compare = value;\n },\n\n stencilPassOperation: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.passOp = value;\n stencilBack.passOp = value;\n },\n\n stencilFailOperation: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.failOp = value;\n stencilBack.failOp = value;\n },\n\n stencilDepthFailOperation: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const stencilFront = addDepthStencilFront(descriptor);\n const stencilBack = addDepthStencilBack(descriptor);\n stencilFront.depthFailOp = value;\n stencilBack.depthFailOp = value;\n },\n\n // MULTISAMPLE\n\n sampleCount: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.count = value;\n },\n\n sampleMask: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.mask = value;\n },\n\n sampleAlphaToCoverageEnabled: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.alphaToCoverageEnabled = value;\n },\n\n // COLOR\n\n colorMask: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const target = addColorState(descriptor, 0);\n target.writeMask = value;\n },\n\n blend: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n if (value) {\n addBlendState(descriptor, 0);\n }\n },\n\n blendColorOperation: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const blend = addBlendState(descriptor, 0);\n blend.color = blend.color || {};\n blend.color.operation = value;\n },\n\n blendColorSrcFactor: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const blend = addBlendState(descriptor, 0);\n blend.color = blend.color || {};\n blend.color.srcFactor = value;\n },\n\n blendColorDstFactor: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const blend = addBlendState(descriptor, 0);\n blend.color.dstFactor = value;\n },\n\n blendAlphaOperation: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const blend = addBlendState(descriptor, 0);\n blend.alpha = blend.alpha || {};\n blend.alpha.operation = value;\n },\n\n blendAlphaSrcFactor: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const blend = addBlendState(descriptor, 0);\n blend.alpha = blend.alpha || {};\n blend.alpha.srcFactor = value;\n },\n\n blendAlphaDstFactor: (\n _: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n ) => {\n const blend = addBlendState(descriptor, 0);\n blend.alpha = blend.alpha || {};\n blend.alpha.dstFactor = value;\n },\n\n unclippedDepth: notSupported,\n provokingVertex: notSupported,\n polygonMode: notSupported,\n polygonOffsetLine: notSupported,\n clipDistance0: notSupported,\n clipDistance1: notSupported,\n clipDistance2: notSupported,\n clipDistance3: notSupported,\n clipDistance4: notSupported,\n clipDistance5: notSupported,\n clipDistance6: notSupported,\n clipDistance7: notSupported\n};\n\nfunction notSupported(\n key: keyof Parameters,\n value: any,\n descriptor: GPURenderPipelineDescriptor\n): void {\n log.warn(`${key} parameter not supported in WebGPU`)();\n}\n\nconst DEFAULT_PIPELINE_DESCRIPTOR: GPURenderPipelineDescriptor = {\n // depthStencil: {\n // stencilFront: {},\n // stencilBack: {},\n // // depthWriteEnabled: true,\n // // depthCompare: 'less',\n // // format: 'depth24plus-stencil8',\n // },\n\n primitive: {\n cullMode: 'back',\n topology: 'triangle-list'\n },\n\n vertex: {\n module: undefined!,\n entryPoint: 'main'\n },\n\n fragment: {\n module: undefined!,\n entryPoint: 'main',\n targets: [\n // { format: props.color0Format || 'bgra8unorm' }\n ]\n },\n\n layout: 'auto'\n};\n\nexport function applyParametersToRenderPipelineDescriptor(\n pipelineDescriptor: GPURenderPipelineDescriptor,\n parameters: Parameters = {}\n): void {\n // Apply defaults\n Object.assign(pipelineDescriptor, {...DEFAULT_PIPELINE_DESCRIPTOR, ...pipelineDescriptor});\n setParameters(pipelineDescriptor, parameters);\n}\n\n// Apply any supplied parameters\nfunction setParameters(\n pipelineDescriptor: GPURenderPipelineDescriptor,\n parameters: Parameters\n): void {\n for (const [key, value] of Object.entries(parameters)) {\n const setterFunction = PARAMETER_TABLE[key as keyof Parameters];\n if (setterFunction) {\n setterFunction(key, value, pipelineDescriptor);\n } else {\n log.error(`Illegal parameter ${key} in WebGPU`)();\n }\n }\n}\n\n/** @todo - support multiple color targets... */\nfunction addColorState(\n descriptor: GPURenderPipelineDescriptor,\n attachment: number\n): GPUColorTargetState {\n // @ts-ignore\n descriptor.fragment.targets = descriptor.fragment?.targets || ([] as GPUColorTargetState[]);\n if (!Array.isArray(descriptor.fragment?.targets)) {\n log.warn('parameters: no targets array')();\n }\n // @ts-expect-error GPU types as iterator\n if (descriptor.fragment?.targets?.length === 0) {\n // @ts-expect-error GPU types as iterator\n descriptor.fragment.targets?.push({});\n }\n // @ts-expect-error GPU types as iterator\n return descriptor.fragment?.targets?.[0] as GPUColorTargetState;\n}\n\nfunction addBlendState(descriptor: GPURenderPipelineDescriptor, attachment: number): GPUBlendState {\n const target = addColorState(descriptor, attachment);\n target.blend = target.blend || {color: {}, alpha: {}};\n return target.blend;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {ComputeShaderLayout, BindingDeclaration, Binding} from '@luma.gl/core';\nimport {Buffer, Sampler, Texture, log} from '@luma.gl/core';\nimport type {WebGPUBuffer} from '../resources/webgpu-buffer';\nimport type {WebGPUSampler} from '../resources/webgpu-sampler';\nimport type {WebGPUTexture} from '../resources/webgpu-texture';\n\n/**\n * Create a WebGPU \"bind group layout\" from an array of luma.gl bindings\n * @note bind groups can be automatically generated by WebGPU.\n */\nexport function makeBindGroupLayout(\n device: GPUDevice,\n layout: GPUBindGroupLayout,\n bindings: Binding[]\n): GPUBindGroupLayout {\n throw new Error('not implemented');\n // return device.createBindGroupLayout({\n // layout,\n // entries: getBindGroupEntries(bindings)\n // })\n}\n\n/**\n * Create a WebGPU \"bind group\" from an array of luma.gl bindings\n */\nexport function getBindGroup(\n device: GPUDevice,\n bindGroupLayout: GPUBindGroupLayout,\n shaderLayout: ComputeShaderLayout,\n bindings: Record<string, Binding>\n): GPUBindGroup {\n const entries = getBindGroupEntries(bindings, shaderLayout);\n device.pushErrorScope('validation');\n const bindGroup = device.createBindGroup({\n layout: bindGroupLayout,\n entries\n });\n device.popErrorScope().then((error: GPUError | null) => {\n if (error) {\n log.error(`bindGroup creation: ${error.message}`, bindGroup)();\n }\n });\n return bindGroup;\n}\n\nexport function getShaderLayoutBinding(\n shaderLayout: ComputeShaderLayout,\n bindingName: string,\n options?: {ignoreWarnings?: boolean}\n): BindingDeclaration | null {\n const bindingLayout = shaderLayout.bindings.find(\n binding =>\n binding.name === bindingName ||\n `${binding.name.toLocaleLowerCase()}uniforms` === bindingName.toLocaleLowerCase()\n );\n if (!bindingLayout && !options?.ignoreWarnings) {\n log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();\n }\n return bindingLayout || null;\n}\n\n/**\n * @param bindings\n * @returns\n */\nfunction getBindGroupEntries(\n bindings: Record<string, Binding>,\n shaderLayout: ComputeShaderLayout\n): GPUBindGroupEntry[] {\n const entries: GPUBindGroupEntry[] = [];\n\n for (const [bindingName, value] of Object.entries(bindings)) {\n let bindingLayout = getShaderLayoutBinding(shaderLayout, bindingName);\n if (bindingLayout) {\n const entry = getBindGroupEntry(value, bindingLayout.location);\n if (entry) {\n entries.push(entry);\n }\n }\n\n // TODO - hack to automatically bind samplers to supplied texture default samplers\n if (value instanceof Texture) {\n bindingLayout = getShaderLayoutBinding(shaderLayout, `${bindingName}Sampler`, {\n ignoreWarnings: true\n });\n if (bindingLayout) {\n const entry = getBindGroupEntry(value, bindingLayout.location, {sampler: true});\n if (entry) {\n entries.push(entry);\n }\n }\n }\n }\n\n return entries;\n}\n\nfunction getBindGroupEntry(\n binding: Binding,\n index: number,\n options?: {sampler?: boolean}\n): GPUBindGroupEntry | null {\n if (binding instanceof Buffer) {\n return {\n binding: index,\n resource: {\n buffer: (binding as WebGPUBuffer).handle\n }\n };\n }\n if (binding instanceof Sampler) {\n return {\n binding: index,\n resource: (binding as WebGPUSampler).handle\n };\n }\n if (binding instanceof Texture) {\n if (options?.sampler) {\n return {\n binding: index,\n resource: (binding as WebGPUTexture).sampler.handle\n };\n }\n return {\n binding: index,\n resource: (binding as WebGPUTexture).view.handle\n };\n }\n log.warn(`invalid binding ${name}`, binding);\n return null;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {ShaderLayout, BufferLayout, AttributeDeclaration, VertexFormat} from '@luma.gl/core';\nimport {log, getVertexFormatInfo} from '@luma.gl/core';\n// import {getAttributeInfosFromLayouts} from '@luma.gl/core';\n\n/** Throw error on any WebGL-only vertex formats */\nfunction getWebGPUVertexFormat(format: VertexFormat): GPUVertexFormat {\n if (format.endsWith('-webgl')) {\n throw new Error(`WebGPU does not support vertex format ${format}`);\n }\n return format as GPUVertexFormat;\n}\n\n/**\n * Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.\n * Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array\n * @param layout\n * @param bufferLayout The buffer map is optional\n * @returns WebGPU layout intended for a GPURenderPassDescriptor.\n */\nexport function getVertexBufferLayout(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[]\n): GPUVertexBufferLayout[] {\n const vertexBufferLayouts: GPUVertexBufferLayout[] = [];\n const usedAttributes = new Set<string>();\n\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // Build vertex attributes for one buffer\n const vertexAttributes: GPUVertexAttribute[] = [];\n\n // TODO verify that all stepModes for one buffer are the same\n let stepMode: 'vertex' | 'instance' = 'vertex';\n let byteStride = 0;\n // @ts-ignore\n let format: VertexFormat = mapping.format;\n\n // interleaved mapping {..., attributes: [{...}, ...]}\n if (mapping.attributes) {\n // const arrayStride = mapping.byteStride; TODO\n for (const attributeMapping of mapping.attributes) {\n const attributeName = attributeMapping.attribute;\n const attributeLayout = findAttributeLayout(shaderLayout, attributeName, usedAttributes);\n\n // @ts-ignore\n const location: number = attributeLayout?.location;\n format = attributeMapping.format || mapping.format;\n\n stepMode =\n attributeLayout?.stepMode ||\n (attributeLayout?.name.startsWith('instance') ? 'instance' : 'vertex');\n vertexAttributes.push({\n format: getWebGPUVertexFormat(format),\n offset: attributeMapping.byteOffset,\n shaderLocation: location\n });\n\n byteStride += getVertexFormatInfo(format).byteLength;\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);\n if (!attributeLayout) {\n continue; // eslint-disable-line no-continue\n }\n byteStride = getVertexFormatInfo(format).byteLength;\n\n stepMode =\n attributeLayout.stepMode ||\n (attributeLayout.name.startsWith('instance') ? 'instance' : 'vertex');\n vertexAttributes.push({\n format: getWebGPUVertexFormat(format),\n // We only support 0 offset for non-interleaved buffer layouts\n offset: 0,\n shaderLocation: attributeLayout.location\n });\n }\n\n // Store all the attribute bindings for one buffer\n vertexBufferLayouts.push({\n arrayStride: mapping.byteStride || byteStride,\n stepMode,\n attributes: vertexAttributes\n });\n }\n\n // Add any non-mapped attributes - TODO - avoid hardcoded types\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n vertexBufferLayouts.push({\n arrayStride: getVertexFormatInfo('float32x3').byteLength,\n stepMode:\n attribute.stepMode || (attribute.name.startsWith('instance') ? 'instance' : 'vertex'),\n attributes: [\n {\n format: getWebGPUVertexFormat('float32x3'),\n offset: 0,\n shaderLocation: attribute.location\n }\n ]\n });\n }\n }\n\n // it's important that the VertexBufferLayout order matches the\n // @location order of the attribute struct otherwise the buffers\n // will not contain the data the shader expects them to.\n vertexBufferLayouts.sort((a, b) => {\n const minLocationA = Math.min(...Array.from(a.attributes, attr => attr.shaderLocation));\n const minLocationB = Math.min(...Array.from(b.attributes, attr => attr.shaderLocation));\n\n return minLocationA - minLocationB;\n });\n\n return vertexBufferLayouts;\n}\n\nexport function getBufferSlots(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[]\n): Record<string, number> {\n const usedAttributes = new Set<string>();\n let bufferSlot = 0;\n const bufferSlots: Record<string, number> = {};\n\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n for (const interleaved of mapping.attributes || []) {\n usedAttributes.add(interleaved.attribute);\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n usedAttributes.add(mapping.name);\n }\n bufferSlots[mapping.name] = bufferSlot++;\n }\n\n // Add any non-mapped attributes\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n bufferSlots[attribute.name] = bufferSlot++;\n }\n }\n\n return bufferSlots;\n}\n\n/**\n * Looks up an attribute in the ShaderLayout.\n * @throws if name is not in ShaderLayout\n * @throws if name has already been referenced and attributeNames is provided\n */\nfunction findAttributeLayout(\n shaderLayout: ShaderLayout,\n name: string,\n attributeNames?: Set<string>\n): AttributeDeclaration | null {\n const attribute = shaderLayout.attributes.find(attribute_ => attribute_.name === name);\n if (!attribute) {\n log.warn(`Supplied attribute not present in shader layout: ${name}`)();\n return null;\n }\n if (attributeNames) {\n if (attributeNames.has(name)) {\n throw new Error(`Found multiple entries for attribute: ${name}`);\n }\n attributeNames.add(name);\n }\n return attribute;\n}\n", "// luma.gl MIT license\n\nimport type {Binding, RenderPass, VertexArray} from '@luma.gl/core';\nimport {RenderPipeline, RenderPipelineProps, log} from '@luma.gl/core';\nimport {applyParametersToRenderPipelineDescriptor} from '../helpers/webgpu-parameters';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport {getBindGroup} from '../helpers/get-bind-group';\nimport {getVertexBufferLayout} from '../helpers/get-vertex-buffer-layout';\n// import {convertAttributesVertexBufferToLayout} from '../helpers/get-vertex-buffer-layout';\n// import {mapAccessorToWebGPUFormat} from './helpers/accessor-to-format';\n// import type {BufferAccessors} from './webgpu-pipeline';\n\nimport type {WebGPUDevice} from '../webgpu-device';\n// import type {WebGPUBuffer} from './webgpu-buffer';\nimport type {WebGPUShader} from './webgpu-shader';\nimport type {WebGPURenderPass} from './webgpu-render-pass';\n\n// RENDER PIPELINE\n\n/** Creates a new render pipeline when parameters change */\nexport class WebGPURenderPipeline extends RenderPipeline {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPipeline;\n\n readonly vs: WebGPUShader;\n readonly fs: WebGPUShader | null = null;\n\n /** For internal use to create BindGroups */\n private _bindings: Record<string, Binding>;\n private _bindGroupLayout: GPUBindGroupLayout | null = null;\n private _bindGroup: GPUBindGroup | null = null;\n\n override get [Symbol.toStringTag]() {\n return 'WebGPURenderPipeline';\n }\n\n constructor(device: WebGPUDevice, props: RenderPipelineProps) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle as GPURenderPipeline;\n if (!this.handle) {\n const descriptor = this._getRenderPipelineDescriptor();\n log.groupCollapsed(1, `new WebGPURenderPipeline(${this.id})`)();\n log.probe(1, JSON.stringify(descriptor, null, 2))();\n log.groupEnd(1)();\n\n this.device.pushErrorScope('validation');\n this.handle = this.device.handle.createRenderPipeline(descriptor);\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} creation failed:\\n\"${error.message}\"`), this)();\n this.device.debug();\n });\n }\n this.handle.label = this.props.id;\n\n // Note: Often the same shader in WebGPU\n this.vs = props.vs as WebGPUShader;\n this.fs = props.fs as WebGPUShader;\n\n this._bindings = {...this.props.bindings};\n }\n\n override destroy(): void {\n // WebGPURenderPipeline has no destroy method.\n // @ts-expect-error\n this.handle = null;\n }\n\n /**\n * @todo Use renderpass.setBindings() ?\n * @todo Do we want to expose BindGroups in the API and remove this?\n */\n setBindings(bindings: Record<string, Binding>): void {\n // Invalidate the cached bind group if any value has changed\n for (const [name, binding] of Object.entries(bindings)) {\n if (this._bindings[name] !== binding) {\n this._bindGroup = null;\n }\n }\n Object.assign(this._bindings, bindings);\n }\n\n /** @todo - should this be moved to renderpass? */\n draw(options: {\n renderPass: RenderPass;\n vertexArray: VertexArray;\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): boolean {\n const webgpuRenderPass = options.renderPass as WebGPURenderPass;\n\n // Set pipeline\n this.device.pushErrorScope('validation');\n webgpuRenderPass.handle.setPipeline(this.handle);\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} setPipeline failed:\\n\"${error.message}\"`), this)();\n this.device.debug();\n });\n\n // Set bindings (uniform buffers, textures etc)\n const bindGroup = this._getBindGroup();\n if (bindGroup) {\n webgpuRenderPass.handle.setBindGroup(0, bindGroup);\n }\n\n // Set attributes\n // Note: Rebinds constant attributes before each draw call\n options.vertexArray.bindBeforeRender(options.renderPass);\n\n // Draw\n if (options.indexCount) {\n webgpuRenderPass.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n webgpuRenderPass.handle.draw(\n options.vertexCount || 0,\n options.instanceCount || 1, // If 0, nothing will be drawn\n options.firstInstance\n );\n }\n\n // Note: Rebinds constant attributes before each draw call\n options.vertexArray.unbindAfterRender(options.renderPass);\n\n return true;\n }\n\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n if (this.shaderLayout.bindings.length === 0) {\n return null;\n }\n\n // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group\n this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);\n\n // Set up the bindings\n // TODO what if bindings change? We need to rebuild the bind group!\n this._bindGroup =\n this._bindGroup ||\n getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);\n\n return this._bindGroup;\n }\n\n /**\n * Populate the complex WebGPU GPURenderPipelineDescriptor\n */\n protected _getRenderPipelineDescriptor() {\n // Set up the vertex stage\n const vertex: GPUVertexState = {\n module: (this.props.vs as WebGPUShader).handle,\n entryPoint: this.props.vertexEntryPoint || 'main',\n buffers: getVertexBufferLayout(this.shaderLayout, this.props.bufferLayout)\n };\n\n // Populate color targets\n // TODO - at the moment blend and write mask are only set on the first target\n const targets: (GPUColorTargetState | null)[] = [];\n if (this.props.colorAttachmentFormats) {\n for (const format of this.props.colorAttachmentFormats) {\n targets.push(format ? {format: getWebGPUTextureFormat(format)} : null);\n }\n } else {\n targets.push({format: getWebGPUTextureFormat(this.device.preferredColorFormat)});\n }\n\n // Set up the fragment stage\n const fragment: GPUFragmentState = {\n module: (this.props.fs as WebGPUShader).handle,\n entryPoint: this.props.fragmentEntryPoint || 'main',\n targets\n };\n\n const layout = this.device.createPipelineLayout({\n shaderLayout: this.shaderLayout\n });\n\n // Create a partially populated descriptor\n const descriptor: GPURenderPipelineDescriptor = {\n vertex,\n fragment,\n primitive: {\n topology: this.props.topology\n },\n layout: layout.handle\n };\n\n // Set depth format if required, defaulting to the preferred depth format\n const depthFormat = this.props.depthStencilAttachmentFormat || this.device.preferredDepthFormat;\n\n if (this.props.parameters.depthWriteEnabled) {\n descriptor.depthStencil = {\n format: getWebGPUTextureFormat(depthFormat)\n };\n }\n\n // Set parameters on the descriptor\n applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);\n\n return descriptor;\n }\n}\n/**\n_setAttributeBuffers(webgpuRenderPass: WebGPURenderPass) {\n if (this._indexBuffer) {\n webgpuRenderPass.handle.setIndexBuffer(this._indexBuffer.handle, this._indexBuffer.props.indexType);\n }\n\n const buffers = this._getBuffers();\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = cast<WebGPUBuffer>(buffers[i]);\n if (!buffer) {\n const attribute = this.shaderLayout.attributes.find(\n (attribute) => attribute.location === i\n );\n throw new Error(\n `No buffer provided for attribute '${attribute?.name || ''}' in Model '${this.props.id}'`\n );\n }\n webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);\n }\n\n // TODO - HANDLE buffer maps\n /*\n for (const [bufferName, attributeMapping] of Object.entries(this.props.bufferLayout)) {\n const buffer = cast<WebGPUBuffer>(this.props.attributes[bufferName]);\n if (!buffer) {\n log.warn(`Missing buffer for buffer map ${bufferName}`)();\n continue;\n }\n\n if ('location' in attributeMapping) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(layout.location, buffer.handle);\n } else {\n for (const [bufferName, mapping] of Object.entries(attributeMapping)) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(field.location, buffer.handle);\n }\n }\n }\n *\n}\n*/\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {FramebufferProps} from '@luma.gl/core';\nimport {Framebuffer} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUTextureView} from '../resources/webgpu-texture-view';\n\n/**\n * Create new textures with correct size for all attachments.\n * @note resize() destroys existing textures (if size has changed).\n */\nexport class WebGPUFramebuffer extends Framebuffer {\n readonly device: WebGPUDevice;\n readonly handle = null;\n\n readonly colorAttachments: WebGPUTextureView[] = [];\n readonly depthStencilAttachment: WebGPUTextureView | null = null;\n\n constructor(device: WebGPUDevice, props: FramebufferProps) {\n super(device, props);\n this.device = device;\n\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n }\n\n protected updateAttachments(): void {\n // WebGPU framebuffers are JS only objects, nothing to update\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ComputePipeline, ComputePipelineProps, Binding} from '@luma.gl/core';\nimport {getBindGroup} from '../helpers/get-bind-group';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUShader} from './webgpu-shader';\n\n// COMPUTE PIPELINE\n\n/** Creates a new compute pipeline when parameters change */\nexport class WebGPUComputePipeline extends ComputePipeline {\n readonly device: WebGPUDevice;\n readonly handle: GPUComputePipeline;\n\n /** For internal use to create BindGroups */\n private _bindGroupLayout: GPUBindGroupLayout | null = null;\n private _bindGroup: GPUBindGroup | null = null;\n /** For internal use to create BindGroups */\n private _bindings: Record<string, Binding> = {};\n\n constructor(device: WebGPUDevice, props: ComputePipelineProps) {\n super(device, props);\n this.device = device;\n\n const webgpuShader = this.props.shader as WebGPUShader;\n\n this.handle =\n this.props.handle ||\n this.device.handle.createComputePipeline({\n label: this.props.id,\n compute: {\n module: webgpuShader.handle,\n entryPoint: this.props.entryPoint,\n constants: this.props.constants\n },\n layout: 'auto'\n });\n }\n\n /**\n * @todo Use renderpass.setBindings() ?\n * @todo Do we want to expose BindGroups in the API and remove this?\n */\n setBindings(bindings: Record<string, Binding>): void {\n Object.assign(this._bindings, bindings);\n }\n\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group\n this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);\n\n // Set up the bindings\n this._bindGroup =\n this._bindGroup ||\n getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);\n\n return this._bindGroup;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Device, Buffer, VertexArrayProps, RenderPass} from '@luma.gl/core';\nimport {VertexArray, log} from '@luma.gl/core';\nimport {getBrowser} from '@probe.gl/env';\n\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from '../resources/webgpu-buffer';\n\nimport {WebGPURenderPass} from './webgpu-render-pass';\n\n/** VertexArrayObject wrapper */\nexport class WebGPUVertexArray extends VertexArray {\n override get [Symbol.toStringTag](): string {\n return 'WebGPUVertexArray';\n }\n\n readonly device: WebGPUDevice;\n /** Vertex Array is just a helper class under WebGPU */\n readonly handle = null;\n\n // Create a VertexArray\n constructor(device: WebGPUDevice, props: VertexArrayProps) {\n super(device, props);\n this.device = device;\n }\n\n override destroy(): void {}\n\n /**\n * Set an elements buffer, for indexed rendering.\n * Must be a Buffer bound to buffer with usage bit Buffer.INDEX set.\n */\n setIndexBuffer(buffer: Buffer | null): void {\n // assert(!elementBuffer || elementBuffer.glTarget === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n this.indexBuffer = buffer;\n }\n\n /** Set a bufferSlot in vertex attributes array to a buffer, enables the bufferSlot, sets divisor */\n setBuffer(bufferSlot: number, buffer: Buffer): void {\n // Sanity check target\n // if (buffer.glUsage === GL.ELEMENT_ARRAY_BUFFER) {\n // throw new Error('Use setIndexBuffer');\n // }\n\n this.attributes[bufferSlot] = buffer;\n }\n\n override bindBeforeRender(\n renderPass: RenderPass,\n firstIndex?: number,\n indexCount?: number\n ): void {\n const webgpuRenderPass = renderPass as WebGPURenderPass;\n const webgpuIndexBuffer = this.indexBuffer as WebGPUBuffer;\n if (webgpuIndexBuffer?.handle) {\n // Note we can't unset an index buffer\n log.info(\n 3,\n 'setting index buffer',\n webgpuIndexBuffer?.handle,\n webgpuIndexBuffer?.indexType\n )();\n webgpuRenderPass.handle.setIndexBuffer(\n webgpuIndexBuffer?.handle,\n // @ts-expect-error TODO - we must enforce type\n webgpuIndexBuffer?.indexType\n );\n }\n for (let location = 0; location < this.maxVertexAttributes; location++) {\n const webgpuBuffer = this.attributes[location] as WebGPUBuffer;\n if (webgpuBuffer?.handle) {\n log.info(3, `setting vertex buffer ${location}`, webgpuBuffer?.handle)();\n webgpuRenderPass.handle.setVertexBuffer(location, webgpuBuffer?.handle);\n }\n }\n // TODO - emit warnings/errors/throw if constants have been set on this vertex array\n }\n\n override unbindAfterRender(renderPass: RenderPass): void {\n // On WebGPU we don't need to unbind.\n // In fact we can't easily do it. setIndexBuffer/setVertexBuffer don't accept null.\n // Unbinding presumably happens automatically when the render pass is ended.\n }\n\n // DEPRECATED METHODS\n\n /**\n * @deprecated is this even an issue for WebGPU?\n * Attribute 0 can not be disable on most desktop OpenGL based browsers\n */\n static isConstantAttributeZeroSupported(device: Device): boolean {\n return getBrowser() === 'Chrome';\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport type {TextureFormatDepthStencil, CanvasContextProps} from '@luma.gl/core';\nimport {CanvasContext, Texture, log} from '@luma.gl/core';\nimport {WebGPUDevice} from './webgpu-device';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\nimport {WebGPUTexture} from './resources/webgpu-texture';\n\n/**\n * Holds a WebGPU Canvas Context\n * The primary job of the CanvasContext is to generate textures for rendering into the current canvas\n * It also manages canvas sizing calculations and resizing.\n */\nexport class WebGPUCanvasContext extends CanvasContext {\n readonly device: WebGPUDevice;\n readonly handle: GPUCanvasContext;\n\n private depthStencilAttachment: WebGPUTexture | null = null;\n\n get [Symbol.toStringTag](): string {\n return 'WebGPUCanvasContext';\n }\n\n constructor(device: WebGPUDevice, adapter: GPUAdapter, props: CanvasContextProps) {\n super(props);\n\n const context = this.canvas.getContext('webgpu');\n if (!context) {\n throw new Error(`${this}: Failed to create WebGPU canvas context`);\n }\n this.device = device;\n this.handle = context;\n\n // Base class constructor cannot access derived methods/fields, so we need to call these functions in the subclass constructor\n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n this._configureDevice();\n }\n\n /** Destroy any textures produced while configured and remove the context configuration. */\n override destroy(): void {\n this.handle.unconfigure();\n super.destroy();\n }\n\n // IMPLEMENTATION OF ABSTRACT METHODS\n\n /** @see https://www.w3.org/TR/webgpu/#canvas-configuration */\n _configureDevice(): void {\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n\n // Reconfigure the canvas size.\n this.handle.configure({\n device: this.device.handle,\n format: this.device.preferredColorFormat,\n // Can be used to define e.g. -srgb views\n // viewFormats: [...]\n colorSpace: this.props.colorSpace,\n alphaMode: this.props.alphaMode\n });\n }\n\n /** Update framebuffer with properly resized \"swap chain\" texture views */\n _getCurrentFramebuffer(\n options: {depthStencilFormat?: TextureFormatDepthStencil | false} = {\n depthStencilFormat: 'depth24plus'\n }\n ): WebGPUFramebuffer {\n // Wrap the current canvas context texture in a luma.gl texture\n const currentColorAttachment = this._getCurrentTexture();\n // TODO - temporary debug code\n if (\n currentColorAttachment.width !== this.drawingBufferWidth ||\n currentColorAttachment.height !== this.drawingBufferHeight\n ) {\n const [oldWidth, oldHeight] = this.getDrawingBufferSize();\n this.drawingBufferWidth = currentColorAttachment.width;\n this.drawingBufferHeight = currentColorAttachment.height;\n log.log(\n 1,\n `${this}: Resized to compensate for initial canvas size mismatch ${oldWidth}x${oldHeight} => ${this.drawingBufferWidth}x${this.drawingBufferHeight}px`\n )();\n }\n\n // Resize the depth stencil attachment\n if (options?.depthStencilFormat) {\n this._createDepthStencilAttachment(options?.depthStencilFormat);\n }\n\n return new WebGPUFramebuffer(this.device, {\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: this.depthStencilAttachment\n });\n }\n\n // PRIMARY METHODS\n\n /** Wrap the current canvas context texture in a luma.gl texture */\n _getCurrentTexture(): WebGPUTexture {\n const handle = this.handle.getCurrentTexture();\n return this.device.createTexture({\n id: `${this.id}#color-texture`,\n handle,\n format: this.device.preferredColorFormat,\n width: handle.width,\n height: handle.height\n });\n }\n\n /** We build render targets on demand (i.e. not when size changes but when about to render) */\n _createDepthStencilAttachment(depthStencilFormat: TextureFormatDepthStencil): WebGPUTexture {\n if (!this.depthStencilAttachment) {\n this.depthStencilAttachment = this.device.createTexture({\n id: `${this.id}#depth-stencil-texture`,\n usage: Texture.RENDER_ATTACHMENT,\n format: depthStencilFormat,\n width: this.drawingBufferWidth,\n height: this.drawingBufferHeight\n });\n }\n return this.depthStencilAttachment;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {CommandBufferProps} from '@luma.gl/core';\nimport {CommandBuffer} from '@luma.gl/core';\n\nimport {WebGPUDevice} from '../webgpu-device';\nimport type {WebGPUCommandEncoder} from './webgpu-command-encoder';\n\nexport class WebGPUCommandBuffer extends CommandBuffer {\n readonly device: WebGPUDevice;\n readonly handle: GPUCommandBuffer;\n\n constructor(commandEncoder: WebGPUCommandEncoder, props: CommandBufferProps) {\n super(commandEncoder.device, {});\n this.device = commandEncoder.device;\n this.handle =\n this.props.handle ||\n commandEncoder.handle.finish({\n label: props?.id || 'unnamed-command-buffer'\n });\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {TypedArray, NumberArray4} from '@math.gl/types';\nimport type {RenderPassProps, RenderPassParameters, Binding} from '@luma.gl/core';\nimport {Buffer, RenderPass, RenderPipeline, log} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\n// import {WebGPUCommandEncoder} from './webgpu-command-encoder';\nimport {WebGPURenderPipeline} from './webgpu-render-pipeline';\nimport {WebGPUQuerySet} from './webgpu-query-set';\nimport {WebGPUFramebuffer} from './webgpu-framebuffer';\n\nexport class WebGPURenderPass extends RenderPass {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPassEncoder;\n\n /** Active pipeline */\n pipeline: WebGPURenderPipeline | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPassProps = {}) {\n super(device, props);\n this.device = device;\n const framebuffer =\n (props.framebuffer as WebGPUFramebuffer) || device.getCanvasContext().getCurrentFramebuffer();\n\n const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);\n\n const webgpuQuerySet = props.timestampQuerySet as WebGPUQuerySet;\n if (webgpuQuerySet) {\n renderPassDescriptor.occlusionQuerySet = webgpuQuerySet.handle;\n }\n\n if (device.features.has('timestamp-query')) {\n const webgpuTSQuerySet = props.timestampQuerySet as WebGPUQuerySet;\n renderPassDescriptor.timestampWrites = webgpuTSQuerySet\n ? ({\n querySet: webgpuTSQuerySet.handle,\n beginningOfPassWriteIndex: props.beginTimestampIndex,\n endOfPassWriteIndex: props.endTimestampIndex\n } as GPUComputePassTimestampWrites)\n : undefined;\n }\n\n if (!device.commandEncoder) {\n throw new Error('commandEncoder not available');\n }\n\n this.device.pushErrorScope('validation');\n this.handle =\n this.props.handle || device.commandEncoder.handle.beginRenderPass(renderPassDescriptor);\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} creation failed:\\n\"${error.message}\"`), this)();\n this.device.debug();\n });\n this.handle.label = this.props.id;\n log.groupCollapsed(3, `new WebGPURenderPass(${this.id})`)();\n log.probe(3, JSON.stringify(renderPassDescriptor, null, 2))();\n log.groupEnd(3)();\n }\n\n override destroy(): void {}\n\n end(): void {\n this.handle.end();\n }\n\n setPipeline(pipeline: RenderPipeline): void {\n this.pipeline = pipeline as WebGPURenderPipeline;\n this.device.pushErrorScope('validation');\n this.handle.setPipeline(this.pipeline.handle);\n this.device.popErrorScope((error: GPUError) => {\n this.device.reportError(new Error(`${this} setPipeline failed:\\n\"${error.message}\"`), this)();\n this.device.debug();\n });\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Record<string, Binding>): void {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n\n setIndexBuffer(\n buffer: Buffer,\n indexFormat: GPUIndexFormat,\n offset: number = 0,\n size?: number\n ): void {\n this.handle.setIndexBuffer((buffer as WebGPUBuffer).handle, indexFormat, offset, size);\n }\n\n setVertexBuffer(slot: number, buffer: Buffer, offset: number = 0): void {\n this.handle.setVertexBuffer(slot, (buffer as WebGPUBuffer).handle, offset);\n }\n\n draw(options: {\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n if (options.indexCount) {\n this.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n this.handle.draw(\n options.vertexCount || 0,\n options.instanceCount || 1,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n drawIndirect(): void {\n // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n }\n\n setParameters(parameters: RenderPassParameters): void {\n const {blendConstant, stencilReference, scissorRect, viewport} = parameters;\n if (blendConstant) {\n this.handle.setBlendConstant(blendConstant);\n }\n if (stencilReference) {\n this.handle.setStencilReference(stencilReference);\n }\n if (scissorRect) {\n this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);\n }\n // TODO - explain how 3 dimensions vs 2 in WebGL works.\n if (viewport) {\n this.handle.setViewport(\n viewport[0],\n viewport[1],\n viewport[2],\n viewport[3],\n viewport[4] ?? 0,\n viewport[5] ?? 1\n );\n }\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n beginOcclusionQuery(queryIndex: number): void {\n this.handle.beginOcclusionQuery(queryIndex);\n }\n endOcclusionQuery(): void {\n this.handle.endOcclusionQuery();\n }\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n\n // INTERNAL\n\n /**\n * Partial render pass descriptor. Used by WebGPURenderPass.\n * @returns attachments fields of a renderpass descriptor.\n */\n protected getRenderPassDescriptor(framebuffer: WebGPUFramebuffer): GPURenderPassDescriptor {\n const renderPassDescriptor: GPURenderPassDescriptor = {\n colorAttachments: []\n };\n\n renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(\n (colorAttachment, index) => ({\n // clear values\n loadOp: this.props.clearColor !== false ? 'clear' : 'load',\n clearValue: convertColor(\n this.props.clearColors?.[index] || this.props.clearColor || RenderPass.defaultClearColor\n ),\n storeOp: this.props.discard ? 'discard' : 'store',\n // ...colorAttachment,\n view: colorAttachment.handle\n })\n );\n\n if (framebuffer.depthStencilAttachment) {\n renderPassDescriptor.depthStencilAttachment = {\n view: framebuffer.depthStencilAttachment.handle\n };\n const {depthStencilAttachment} = renderPassDescriptor;\n\n // DEPTH\n if (this.props.depthReadOnly) {\n depthStencilAttachment.depthReadOnly = true;\n }\n if (this.props.clearDepth !== false) {\n depthStencilAttachment.depthClearValue = this.props.clearDepth;\n }\n // STENCIL\n // if (this.props.clearStencil !== false) {\n // depthStencilAttachment.stencilClearValue = this.props.clearStencil;\n // }\n\n // WebGPU only wants us to set these parameters if the texture format actually has a depth aspect\n const hasDepthAspect = true;\n if (hasDepthAspect) {\n depthStencilAttachment.depthLoadOp = this.props.clearDepth !== false ? 'clear' : 'load';\n depthStencilAttachment.depthStoreOp = 'store'; // TODO - support 'discard'?\n }\n\n // WebGPU only wants us to set these parameters if the texture format actually has a stencil aspect\n const hasStencilAspect = false;\n if (hasStencilAspect) {\n depthStencilAttachment.stencilLoadOp = this.props.clearStencil !== false ? 'clear' : 'load';\n depthStencilAttachment.stencilStoreOp = 'store'; // TODO - support 'discard'?\n }\n }\n\n return renderPassDescriptor;\n }\n}\n\nfunction convertColor(color: TypedArray | NumberArray4): GPUColor {\n return {r: color[0], g: color[1], b: color[2], a: color[3]};\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {WebGPUComputePipeline} from './webgpu-compute-pipeline';\nimport {WebGPUQuerySet} from './webgpu-query-set';\n\nexport class WebGPUComputePass extends ComputePass {\n readonly device: WebGPUDevice;\n readonly handle: GPUComputePassEncoder;\n\n _webgpuPipeline: WebGPUComputePipeline | null = null;\n\n constructor(device: WebGPUDevice, props: ComputePassProps) {\n super(device, props);\n this.device = device;\n\n // Set up queries\n let timestampWrites: GPUComputePassTimestampWrites | undefined;\n if (device.features.has('timestamp-query')) {\n const webgpuQuerySet = props.timestampQuerySet as WebGPUQuerySet;\n if (webgpuQuerySet) {\n timestampWrites = {\n querySet: webgpuQuerySet.handle,\n beginningOfPassWriteIndex: props.beginTimestampIndex,\n endOfPassWriteIndex: props.endTimestampIndex\n };\n }\n }\n\n this.handle =\n this.props.handle ||\n device.commandEncoder.handle.beginComputePass({\n label: this.props.id,\n timestampWrites\n });\n }\n\n /** @note no WebGPU destroy method, just gc */\n override destroy(): void {}\n\n end(): void {\n this.handle.end();\n }\n\n setPipeline(pipeline: ComputePipeline): void {\n const wgpuPipeline = pipeline as WebGPUComputePipeline;\n this.handle.setPipeline(wgpuPipeline.handle);\n this._webgpuPipeline = wgpuPipeline;\n this.setBindings([]);\n }\n\n /**\n * Sets an array of bindings (uniform buffers, samplers, textures, ...)\n * TODO - still some API confusion - does this method go here or on the pipeline?\n */\n setBindings(bindings: Binding[]): void {\n // @ts-expect-error\n const bindGroup = this._webgpuPipeline._getBindGroup();\n this.handle.setBindGroup(0, bindGroup);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param x X dimension of the grid of work groups to dispatch.\n * @param y Y dimension of the grid of work groups to dispatch.\n * @param z Z dimension of the grid of work groups to dispatch.\n */\n dispatch(x: number, y?: number, z?: number): void {\n this.handle.dispatchWorkgroups(x, y, z);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n *\n * Buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()\n * @param indirectBuffer\n * @param indirectOffset offset in buffer to the beginning of the dispatch data.\n */\n dispatchIndirect(indirectBuffer: Buffer, indirectByteOffset: number = 0): void {\n const webgpuBuffer = indirectBuffer as WebGPUBuffer;\n this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectByteOffset);\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {\n RenderPassProps,\n ComputePassProps,\n CopyTextureToTextureOptions,\n CopyTextureToBufferOptions\n} from '@luma.gl/core';\nimport {CommandEncoder, CommandEncoderProps, Buffer, Texture} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUCommandBuffer} from './webgpu-command-buffer';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {WebGPURenderPass} from './webgpu-render-pass';\nimport {WebGPUComputePass} from './webgpu-compute-pass';\nimport {WebGPUTexture} from './webgpu-texture';\nimport {WebGPUQuerySet} from './webgpu-query-set';\n\nexport class WebGPUCommandEncoder extends CommandEncoder {\n readonly device: WebGPUDevice;\n readonly handle: GPUCommandEncoder;\n\n constructor(device: WebGPUDevice, props: CommandEncoderProps = {}) {\n super(device, props);\n this.device = device;\n this.handle =\n props.handle ||\n this.device.handle.createCommandEncoder({\n label: this.props.id\n // TODO was this removed in standard?\n // measureExecutionTime: this.props.measureExecutionTime\n });\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\n\n finish(props?: CommandEncoderProps): WebGPUCommandBuffer {\n this.device.pushErrorScope('validation');\n const commandBuffer = new WebGPUCommandBuffer(this, {\n id: props?.id || 'unnamed-command-buffer'\n });\n this.device.popErrorScope((error: GPUError) => {\n const message = `${this} command encoding: ${error.message}. Maybe add depthWriteEnabled to your Model?`;\n this.device.reportError(new Error(message), this)();\n this.device.debug();\n });\n return commandBuffer;\n }\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 return new WebGPURenderPass(this.device, props);\n }\n\n beginComputePass(props: ComputePassProps): WebGPUComputePass {\n return new WebGPUComputePass(this.device, props);\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n\n copyBufferToBuffer(options: // CopyBufferToBufferOptions\n {\n sourceBuffer: Buffer;\n sourceOffset?: number;\n destinationBuffer: Buffer;\n destinationOffset?: number;\n size?: number;\n }): void {\n const webgpuSourceBuffer = options.sourceBuffer as WebGPUBuffer;\n const WebGPUDestinationBuffer = options.destinationBuffer as WebGPUBuffer;\n this.handle.copyBufferToBuffer(\n webgpuSourceBuffer.handle,\n options.sourceOffset ?? 0,\n WebGPUDestinationBuffer.handle,\n options.destinationOffset ?? 0,\n options.size ?? 0\n );\n }\n\n copyBufferToTexture(options: // CopyBufferToTextureOptions\n {\n sourceBuffer: Buffer;\n offset?: number;\n bytesPerRow: number;\n rowsPerImage: number;\n\n destinationTexture: Texture;\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n\n origin?: number[] | [number, number, number];\n extent?: number[] | [number, number, number];\n }): void {\n const webgpuSourceBuffer = options.sourceBuffer as WebGPUBuffer;\n const WebGPUDestinationTexture = options.destinationTexture as WebGPUTexture;\n this.handle.copyBufferToTexture(\n {\n buffer: webgpuSourceBuffer.handle,\n offset: options.offset ?? 0,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage\n },\n {\n texture: WebGPUDestinationTexture.handle,\n mipLevel: options.mipLevel ?? 0,\n origin: options.origin ?? {}\n // aspect: options.aspect\n },\n {\n // @ts-ignore\n width: options.extent?.[0],\n height: options.extent?.[1],\n depthOrArrayLayers: options.extent?.[2]\n }\n );\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n // this.handle.copyTextureToBuffer(\n // // source\n // {},\n // // destination\n // {},\n // // copySize\n // {}\n // );\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n // this.handle.copyTextureToTexture(\n // // source\n // {},\n // // destination\n // {},\n // // copySize\n // {}\n // );\n }\n\n override pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n\n override popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n\n override insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n override resolveQuerySet(\n querySet: WebGPUQuerySet,\n destination: Buffer,\n options?: {\n firstQuery?: number;\n queryCount?: number;\n destinationOffset?: number;\n }\n ): void {\n const webgpuQuerySet = querySet;\n const webgpuBuffer = destination as WebGPUBuffer;\n this.handle.resolveQuerySet(\n webgpuQuerySet.handle,\n options?.firstQuery || 0,\n options?.queryCount || querySet.props.count - (options?.firstQuery || 0),\n webgpuBuffer.handle,\n options?.destinationOffset || 0\n );\n }\n}\n\n/*\n // setDataFromTypedArray(data): this {\n // const textureDataBuffer = this.device.handle.createBuffer({\n // size: data.byteLength,\n // usage: Buffer.COPY_DST | Buffer.COPY_SRC,\n // mappedAtCreation: true\n // });\n // new Uint8Array(textureDataBuffer.getMappedRange()).set(data);\n // textureDataBuffer.unmap();\n\n // this.setBuffer(textureDataBuffer);\n\n // textureDataBuffer.destroy();\n // return this;\n // }\n\n */\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {QuerySet, QuerySetProps} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\n\nexport type QuerySetProps2 = {\n type: 'occlusion' | 'timestamp';\n count: number;\n};\n\n/**\n * Immutable\n */\nexport class WebGPUQuerySet extends QuerySet {\n readonly device: WebGPUDevice;\n readonly handle: GPUQuerySet;\n\n constructor(device: WebGPUDevice, props: QuerySetProps) {\n super(device, props);\n this.device = device;\n this.handle =\n this.props.handle ||\n this.device.handle.createQuerySet({\n type: this.props.type,\n count: this.props.count\n });\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {\n this.handle?.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {\n log,\n PipelineLayout,\n PipelineLayoutProps,\n StorageBufferBindingLayout,\n StorageTextureBindingLayout\n} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\n\nexport class WebGPUPipelineLayout extends PipelineLayout {\n readonly device: WebGPUDevice;\n readonly handle: GPUPipelineLayout;\n\n constructor(device: WebGPUDevice, props: PipelineLayoutProps) {\n super(device, props);\n\n this.device = device;\n\n const bindGroupEntries = this.mapShaderLayoutToBindGroupEntries();\n\n this.handle = this.device.handle.createPipelineLayout({\n label: props?.id ?? 'unnamed-pipeline-layout',\n bindGroupLayouts: [\n // TODO (kaapp): We can cache these to re-use them across\n // layers, particularly if using a separate group for injected\n // bindings (e.g. project/lighting)\n this.device.handle.createBindGroupLayout({\n label: 'bind-group-layout',\n entries: bindGroupEntries\n })\n ]\n });\n }\n\n override destroy(): void {\n // WebGPUPipelineLayout has no destroy method.\n // @ts-expect-error\n this.handle = null;\n }\n\n protected mapShaderLayoutToBindGroupEntries(): GPUBindGroupLayoutEntry[] {\n // Set up the pipeline layout\n // TODO (kaapp): This only supports the first group, but so does the rest of the code\n const bindGroupEntries: GPUBindGroupLayoutEntry[] = [];\n\n for (let i = 0; i < this.props.shaderLayout.bindings.length; i++) {\n const binding = this.props.shaderLayout.bindings[i];\n const bindingTypeInfo: Omit<GPUBindGroupLayoutEntry, 'binding' | 'visibility'> = {};\n\n switch (binding.type) {\n case 'uniform': {\n bindingTypeInfo.buffer = {\n type: 'uniform',\n hasDynamicOffset: binding.hasDynamicOffset,\n minBindingSize: binding.minBindingSize\n };\n break;\n }\n\n case 'read-only-storage': {\n bindingTypeInfo.buffer = {\n type: 'read-only-storage',\n hasDynamicOffset: binding.hasDynamicOffset,\n minBindingSize: binding.minBindingSize\n };\n break;\n }\n\n case 'sampler': {\n bindingTypeInfo.sampler = {\n type: binding.samplerType\n };\n break;\n }\n\n case 'storage': {\n if (isStorageTextureBindingLayout(binding)) {\n bindingTypeInfo.storageTexture = {\n // TODO (kaapp): Not all formats in the binding layout are supported\n // by WebGPU, but at least it will provide a clear error for now.\n format: binding.format as GPUTextureFormat,\n access: binding.access,\n viewDimension: binding.viewDimension\n };\n } else {\n bindingTypeInfo.buffer = {\n type: 'storage',\n hasDynamicOffset: binding.hasDynamicOffset,\n minBindingSize: binding.minBindingSize\n };\n }\n break;\n }\n\n case 'texture': {\n bindingTypeInfo.texture = {\n multisampled: binding.multisampled,\n sampleType: binding.sampleType,\n viewDimension: binding.viewDimension\n };\n break;\n }\n\n default: {\n log.warn('unhandled binding type when creating pipeline descriptor')();\n }\n }\n\n const VISIBILITY_ALL =\n GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE;\n\n bindGroupEntries.push({\n binding: binding.location,\n visibility: binding.visibility || VISIBILITY_ALL,\n ...bindingTypeInfo\n });\n }\n\n return bindGroupEntries;\n }\n}\n\nconst isStorageTextureBindingLayout = (\n maybe: StorageBufferBindingLayout | StorageTextureBindingLayout\n): maybe is StorageTextureBindingLayout => {\n return (maybe as StorageTextureBindingLayout).format !== undefined;\n};\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Fence, type FenceProps} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\n\n/** WebGPU fence implemented by waiting for submitted work */\nexport class WebGPUFence extends Fence {\n readonly device: WebGPUDevice;\n readonly handle: null = null;\n readonly signaled: Promise<void>;\n private _signaled = false;\n\n constructor(device: WebGPUDevice, props: FenceProps = {}) {\n super(device, {});\n this.device = device;\n this.signaled = device.handle.queue.onSubmittedWorkDone().then(() => {\n this._signaled = true;\n });\n }\n\n isSignaled(): boolean {\n return this._signaled;\n }\n\n override destroy(): void {\n // Nothing to release for WebGPU fence\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {AttributeShaderType, ShaderLayout, TextureBindingLayout, log} from '@luma.gl/core';\nimport {TypeInfo, VariableInfo, WgslReflect, ResourceType} from 'wgsl_reflect';\n\n/**\n * Parse a ShaderLayout from WGSL shader source code.\n * @param source WGSL source code (can contain both @vertex and @fragment entry points)\n * @returns\n */\nexport function getShaderLayoutFromWGSL(source: string): ShaderLayout {\n const shaderLayout: ShaderLayout = {attributes: [], bindings: []};\n\n let parsedWGSL: WgslReflect;\n try {\n parsedWGSL = parseWGSL(source);\n } catch (error: any) {\n log.error(error.message)();\n return shaderLayout;\n }\n\n for (const uniform of parsedWGSL.uniforms) {\n const members = [];\n // @ts-expect-error\n for (const attribute of uniform.type?.members || []) {\n members.push({\n name: attribute.name,\n type: getType(attribute.type)\n });\n }\n\n shaderLayout.bindings.push({\n type: 'uniform',\n name: uniform.name,\n group: uniform.group,\n location: uniform.binding,\n // @ts-expect-error TODO - unused for now but needs fixing\n members\n });\n }\n\n for (const texture of parsedWGSL.textures) {\n const bindingDeclaration: TextureBindingLayout = {\n type: 'texture',\n name: texture.name,\n group: texture.group,\n location: texture.binding,\n ...getTextureBindingFromReflect(texture)\n };\n\n shaderLayout.bindings.push(bindingDeclaration);\n }\n\n for (const sampler of parsedWGSL.samplers) {\n shaderLayout.bindings.push({\n type: 'sampler',\n name: sampler.name,\n group: sampler.group,\n location: sampler.binding\n });\n }\n\n const vertex = parsedWGSL.entry.vertex[0]; // \"main\"\n\n // Vertex shader inputs\n const attributeCount = vertex?.inputs.length || 0; // inputs to \"main\"\n for (let i = 0; i < attributeCount; i++) {\n const wgslAttribute = vertex.inputs[i];\n\n // locationType can be \"builtin\"\n if (wgslAttribute.locationType === 'location') {\n const type = getType(wgslAttribute.type);\n\n shaderLayout.attributes.push({\n name: wgslAttribute.name,\n location: Number(wgslAttribute.location),\n type\n });\n }\n }\n return shaderLayout;\n}\n\n/** Get a valid shader attribute type string from a wgsl-reflect type */\nfunction getType(type: TypeInfo | null): AttributeShaderType {\n // @ts-expect-error WgslReflect type checks needed\n return type?.format ? `${type.name}<${type.format.name}>` : type.name;\n}\n\nfunction parseWGSL(source: string): WgslReflect {\n try {\n return new WgslReflect(source);\n } catch (error: any) {\n if (error instanceof Error) {\n throw error;\n }\n let message = 'WGSL parse error';\n if (typeof error === 'object' && error?.message) {\n message += `: ${error.message} `;\n }\n if (typeof error === 'object' && error?.token) {\n message += error.token.line || '';\n }\n throw new Error(message, {cause: error});\n }\n}\n\nfunction getTextureBindingFromReflect(\n v: VariableInfo, // VariableInfo for a texture\n opts?: {format?: GPUTextureFormat} // optional: if you know the runtime format\n): {\n viewDimension: GPUTextureViewDimension;\n /** @note sampleType float vs unfilterable-float cannot be determined without checking texture format and features */\n sampleType: GPUTextureSampleType;\n multisampled: boolean;\n} {\n if (v.resourceType !== ResourceType.Texture) {\n throw new Error('Not a texture binding');\n }\n\n const typeName = v.type.name; // e.g. \"texture_2d\", \"texture_cube_array\", \"texture_multisampled_2d\"\n // @ts-expect-error v.type.format is not always defined\n const component = v.type.format?.name as 'f32' | 'i32' | 'u32' | undefined;\n\n // viewDimension\n const viewDimension: GPUTextureViewDimension = typeName.includes('cube_array')\n ? 'cube-array'\n : typeName.includes('cube')\n ? 'cube'\n : typeName.includes('2d_array')\n ? '2d-array'\n : typeName.includes('3d')\n ? '3d'\n : typeName.includes('1d')\n ? '1d'\n : '2d';\n\n // multisampled\n const multisampled = typeName === 'texture_multisampled_2d';\n\n // sampleType\n let sampleType: GPUTextureSampleType;\n if (typeName.startsWith('texture_depth')) {\n sampleType = 'depth';\n } else if (component === 'i32') {\n sampleType = 'sint';\n } else if (component === 'u32') {\n sampleType = 'uint';\n } else {\n sampleType = 'float'; // default to float\n }\n\n return {viewDimension, sampleType, multisampled};\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport type {\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n DeviceTextureFormatCapabilities,\n VertexFormat,\n CanvasContextProps,\n BufferProps,\n SamplerProps,\n ShaderProps,\n TextureProps,\n ExternalTextureProps,\n FramebufferProps,\n RenderPipelineProps,\n ComputePipelineProps,\n VertexArrayProps,\n TransformFeedback,\n TransformFeedbackProps,\n QuerySet,\n QuerySetProps,\n DeviceProps,\n CommandEncoderProps,\n PipelineLayoutProps,\n} from '@luma.gl/core';\nimport {Device, DeviceFeatures} 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 {WebGPUVertexArray} from './resources/webgpu-vertex-array';\n\nimport {WebGPUCanvasContext} from './webgpu-canvas-context';\nimport {WebGPUCommandEncoder} from './resources/webgpu-command-encoder';\nimport {WebGPUCommandBuffer} from './resources/webgpu-command-buffer';\nimport {WebGPUQuerySet} from './resources/webgpu-query-set';\nimport {WebGPUPipelineLayout} from './resources/webgpu-pipeline-layout';\nimport {WebGPUFence} from './resources/webgpu-fence';\n\nimport {getShaderLayoutFromWGSL} from '../wgsl/get-shader-layout-wgsl';\n\n/** WebGPU Device implementation */\nexport class WebGPUDevice extends Device {\n /** The underlying WebGPU device */\n readonly handle: GPUDevice;\n /* The underlying WebGPU adapter */\n readonly adapter: GPUAdapter;\n /* The underlying WebGPU adapter's info */\n readonly adapterInfo: GPUAdapterInfo;\n\n /** type of this device */\n readonly type = 'webgpu';\n\n readonly preferredColorFormat = navigator.gpu.getPreferredCanvasFormat() as\n | 'rgba8unorm'\n | 'bgra8unorm';\n readonly preferredDepthFormat = 'depth24plus';\n\n readonly features: DeviceFeatures;\n readonly info: DeviceInfo;\n readonly limits: DeviceLimits;\n\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n override canvasContext: WebGPUCanvasContext | null = null;\n\n private _isLost: boolean = false;\n commandEncoder: WebGPUCommandEncoder;\n\n override get [Symbol.toStringTag](): string {\n return 'WebGPUDevice';\n }\n\n override toString(): string {\n return `WebGPUDevice(${this.id})`;\n }\n\n constructor(\n props: DeviceProps,\n device: GPUDevice,\n adapter: GPUAdapter,\n adapterInfo: GPUAdapterInfo\n ) {\n super({...props, id: props.id || 'webgpu-device'});\n this.handle = device;\n this.adapter = adapter;\n this.adapterInfo = adapterInfo;\n\n this.info = this._getInfo();\n this.features = this._getFeatures();\n this.limits = this.handle.limits;\n\n // Listen for uncaptured WebGPU errors\n device.addEventListener('uncapturederror', (event: Event) => {\n event.preventDefault();\n // TODO is this the right way to make sure the error is an Error instance?\n const errorMessage =\n event instanceof GPUUncapturedErrorEvent ? event.error.message : 'Unknown WebGPU error';\n this.reportError(new Error(errorMessage), this)();\n this.debug();\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 const canvasContextProps = Device._getCanvasContextProps(props);\n if (canvasContextProps) {\n this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);\n }\n\n this.commandEncoder = this.createCommandEncoder({});\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 isLost(): boolean {\n return this._isLost;\n }\n\n getShaderLayout(source: string) {\n return getShaderLayoutFromWGSL(source);\n }\n\n override isVertexFormatSupported(format: VertexFormat): boolean {\n const info = this.getVertexFormatInfo(format);\n return !info.webglOnly;\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer {\n const newProps = this._normalizeBufferProps(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 return new WebGPUFramebuffer(this, props);\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 override createCommandEncoder(props?: CommandEncoderProps): WebGPUCommandEncoder {\n return new WebGPUCommandEncoder(this, props);\n }\n\n // WebGPU specifics\n\n createTransformFeedback(props: TransformFeedbackProps): TransformFeedback {\n throw new Error('Transform feedback not supported in WebGPU');\n }\n\n override createQuerySet(props: QuerySetProps): QuerySet {\n return new WebGPUQuerySet(this, props);\n }\n\n override createFence(): WebGPUFence {\n return new WebGPUFence(this);\n }\n\n createCanvasContext(props: CanvasContextProps): WebGPUCanvasContext {\n return new WebGPUCanvasContext(this, this.adapter, props);\n }\n\n createPipelineLayout(props: PipelineLayoutProps): WebGPUPipelineLayout {\n return new WebGPUPipelineLayout(this, props);\n }\n\n submit(commandBuffer?: WebGPUCommandBuffer): void {\n if (!commandBuffer) {\n commandBuffer = this.commandEncoder.finish();\n this.commandEncoder.destroy();\n this.commandEncoder = this.createCommandEncoder({id: `${this.id}-default-encoder`});\n }\n\n this.pushErrorScope('validation');\n this.handle.queue.submit([commandBuffer.handle]);\n this.popErrorScope((error: GPUError) => {\n this.reportError(new Error(`${this} command submission: ${error.message}`), this)();\n this.debug();\n });\n }\n\n // WebGPU specific\n\n pushErrorScope(scope: 'validation' | 'out-of-memory'): void {\n this.handle.pushErrorScope(scope);\n }\n\n popErrorScope(handler: (error: GPUError) => void): void {\n this.handle.popErrorScope().then((error: GPUError | null) => {\n if (error) {\n handler(error);\n }\n });\n }\n\n // PRIVATE METHODS\n\n protected _getInfo(): DeviceInfo {\n const [driver, driverVersion] = ((this.adapterInfo as any).driver || '').split(' Version ');\n\n // See https://developer.chrome.com/blog/new-in-webgpu-120#adapter_information_updates\n const vendor = this.adapterInfo.vendor || this.adapter.__brand || 'unknown';\n const renderer = driver || '';\n const version = driverVersion || '';\n\n const gpu = vendor === 'apple' ? 'apple' : 'unknown'; // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',\n const gpuArchitecture = this.adapterInfo.architecture || 'unknown';\n const gpuBackend = (this.adapterInfo as any).backend || 'unknown';\n const gpuType = ((this.adapterInfo as any).type || '').split(' ')[0].toLowerCase() || 'unknown';\n\n return {\n type: 'webgpu',\n vendor,\n renderer,\n version,\n gpu,\n gpuType,\n gpuBackend,\n gpuArchitecture,\n shadingLanguage: 'wgsl',\n shadingLanguageVersion: 100\n };\n }\n\n protected _getFeatures(): DeviceFeatures {\n // Initialize with actual WebGPU Features (note that unknown features may not be in DeviceFeature type)\n const features = new Set<DeviceFeature>(this.handle.features as Set<DeviceFeature>);\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 // Some subsets of WebGPU extensions correspond to WebGL extensions\n if (features.has('texture-compression-bc')) {\n features.add('texture-compression-bc5-webgl');\n }\n\n if (this.handle.features.has('chromium-experimental-norm16-texture-formats')) {\n features.add('norm16-renderable-webgl');\n }\n\n if (this.handle.features.has('chromium-experimental-snorm16-texture-formats')) {\n features.add('snorm16-renderable-webgl');\n }\n\n const WEBGPU_ALWAYS_FEATURES: DeviceFeature[] = [\n 'timer-query-webgl',\n 'compilation-status-async-webgl',\n 'float32-renderable-webgl',\n 'float16-renderable-webgl',\n 'norm16-renderable-webgl',\n 'texture-filterable-anisotropic-webgl',\n 'shader-noperspective-interpolation-webgl'\n ];\n\n for (const feature of WEBGPU_ALWAYS_FEATURES) {\n features.add(feature);\n }\n\n return new DeviceFeatures(Array.from(features), this.props._disabledFeatures);\n }\n\n override _getDeviceSpecificTextureFormatCapabilities(\n capabilities: DeviceTextureFormatCapabilities\n ): DeviceTextureFormatCapabilities {\n const {format} = capabilities;\n if (format.includes('webgl')) {\n return {format, create: false, render: false, filter: false, blend: false, store: false};\n }\n return capabilities;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// WEBGPU ADAPTER\nexport type {WebGPUAdapter} from './adapter/webgpu-adapter';\nexport {webgpuAdapter} from './adapter/webgpu-adapter';\n\n// WEBGPU CLASSES (typically not accessed directly)\nexport {WebGPUDevice} from './adapter/webgpu-device';\nexport {WebGPUBuffer} from './adapter/resources/webgpu-buffer';\nexport {WebGPUTexture} from './adapter/resources/webgpu-texture';\nexport {WebGPUSampler} from './adapter/resources/webgpu-sampler';\nexport {WebGPUShader} from './adapter/resources/webgpu-shader';\nexport {WebGPUFence} from './adapter/resources/webgpu-fence';\n\nexport {getShaderLayoutFromWGSL} from './wgsl/get-shader-layout-wgsl';\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport {Adapter, DeviceProps, log} from '@luma.gl/core';\nimport type {WebGPUDevice} from './webgpu-device';\n\nexport class WebGPUAdapter extends Adapter {\n /** type of device's created by this adapter */\n readonly type: WebGPUDevice['type'] = 'webgpu';\n\n isSupported(): boolean {\n // Check if WebGPU is available\n return Boolean(typeof navigator !== 'undefined' && navigator.gpu);\n }\n\n isDeviceHandle(handle: unknown): boolean {\n if (typeof GPUDevice !== 'undefined' && handle instanceof GPUDevice) {\n return true;\n }\n\n // TODO - WebGPU does not yet seem to have a stable in-browser API, so we \"sniff\" for members instead\n if ((handle as any)?.queue) {\n return true;\n }\n\n return false;\n }\n\n async create(props: DeviceProps): Promise<WebGPUDevice> {\n if (!navigator.gpu) {\n throw new Error('WebGPU not available. Recent Chrome browsers should work.');\n }\n\n const adapter = await navigator.gpu.requestAdapter({\n powerPreference: 'high-performance'\n // forceSoftware: false\n });\n\n if (!adapter) {\n throw new Error('Failed to request WebGPU adapter');\n }\n\n // Note: adapter.requestAdapterInfo() has been replaced with adapter.info. Fall back in case adapter.info is not available\n const adapterInfo =\n adapter.info ||\n // @ts-ignore\n (await adapter.requestAdapterInfo?.());\n // log.probe(2, 'Adapter available', adapterInfo)();\n\n const requiredFeatures: GPUFeatureName[] = [];\n const requiredLimits: Record<string, number> = {};\n\n if (props._requestMaxLimits) {\n // Require all features\n requiredFeatures.push(...(Array.from(adapter.features) as GPUFeatureName[]));\n\n // Require all limits\n // Filter out chrome specific keys (avoid crash)\n const limits = Object.keys(adapter.limits).filter(\n key => !['minSubgroupSize', 'maxSubgroupSize'].includes(key)\n );\n for (const key of limits) {\n const limit = key as keyof GPUSupportedLimits;\n const value = adapter.limits[limit];\n if (typeof value === 'number') {\n requiredLimits[limit] = value;\n }\n }\n }\n\n const gpuDevice = await adapter.requestDevice({\n requiredFeatures,\n requiredLimits\n });\n\n // log.probe(1, 'GPUDevice available')();\n\n const {WebGPUDevice} = await import('./webgpu-device');\n\n log.groupCollapsed(1, 'WebGPUDevice created')();\n try {\n const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo);\n log.probe(\n 1,\n 'Device created. For more info, set chrome://flags/#enable-webgpu-developer-features'\n )();\n log.table(1, device.info)();\n return device;\n } finally {\n log.groupEnd(1)();\n }\n }\n\n async attach(handle: GPUDevice): Promise<WebGPUDevice> {\n throw new Error('WebGPUAdapter.attach() not implemented');\n }\n}\n\nexport const webgpuAdapter = new WebGPUAdapter();\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAIA,aAGa;AAPb;;;AAIA,kBAAoE;AAG9D,IAAO,eAAP,cAA4B,mBAAM;MAC7B;MACA;MACA;MAET,YAAY,QAAsB,OAAkB;AAZtD;AAaI,cAAM,QAAQ,KAAK;AACnB,aAAK,SAAS;AAEd,aAAK,aAAa,MAAM,gBAAc,WAAM,SAAN,mBAAY,eAAc;AAChE,cAAM,mBAAmB,QAAQ,KAAK,MAAM,YAAY,MAAM,IAAI;AAGlE,cAAM,OAAO,KAAK,KAAK,KAAK,aAAa,CAAC,IAAI;AAE9C,aAAK,OAAO,eAAe,eAAe;AAC1C,aAAK,OAAO,eAAe,YAAY;AAC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WAAW,SAAS,WAAW;AACtE,wBAAI,MACF,GACA,qFAAqF,EACtF;AACD,wBAAI,MAAM,GAAG,OAAO,IAAI,EAAC;AACzB,aAAO;IACT;AACE,wBAAI,SAAS,CAAC,EAAC;IACjB;EACF;EAEA,MAAM,OAAO,QAAiB;AAC5B,UAAM,IAAI,MAAM,wCAAwC;EAC1D;;AAGK,IAAM,gBAAgB,IAAI,cAAa;;;AD7F9C;AACA;AACA;AACA;AACA;AACA;AAEA;",
6
+ "names": ["import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "name", "import_core", "import_core", "name", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "WebGPUDevice"]
7
7
  }