@luma.gl/webgpu 9.3.0-alpha.8 → 9.3.0

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/adapter/resources/webgpu-buffer.ts", "../src/adapter/helpers/convert-texture-format.ts", "../src/adapter/resources/webgpu-sampler.ts", "../src/adapter/helpers/cpu-hotspot-profiler.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-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/webgpu-presentation-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/helpers/generate-mipmaps-webgpu.ts", "../src/adapter/helpers/get-bind-group.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\n/**\n * WebGPU implementation of Buffer\n * For byte alignment requirements see:\n * @see https://www.w3.org/TR/webgpu/#dom-gpubuffer-mapasync\n * @see https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/mapAsync\n */\nexport class WebGPUBuffer extends Buffer {\n readonly device: WebGPUDevice;\n readonly handle: GPUBuffer;\n readonly byteLength: number;\n readonly paddedByteLength: 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 this.paddedByteLength = Math.ceil(this.byteLength / 4) * 4;\n const mappedAtCreation = Boolean(this.props.onMapped || props.data);\n\n // WebGPU buffers must be aligned to 4 bytes\n const size = this.paddedByteLength;\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 if (!this.props.handle) {\n this.trackAllocatedMemory(size);\n } else {\n this.trackReferencedMemory(size, 'Buffer');\n }\n }\n\n override destroy(): void {\n if (!this.destroyed && this.handle) {\n this.removeStats();\n if (!this.props.handle) {\n this.trackDeallocatedMemory();\n this.handle.destroy();\n } else {\n this.trackDeallocatedReferencedMemory('Buffer');\n }\n this.destroyed = true;\n // @ts-expect-error readonly\n this.handle = null;\n }\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 const alignedByteLength = Math.ceil(byteLength / 4) * 4;\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.paddedByteLength)\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, alignedByteLength);\n const mappedRange = writeBuffer.handle.getMappedRange(byteOffset, alignedByteLength);\n const arrayBuffer = mappedRange.slice(0, byteLength);\n // eslint-disable-next-line @typescript-eslint/await-thenable\n await callback(arrayBuffer, 'mapped');\n new Uint8Array(mappedRange).set(new Uint8Array(arrayBuffer), 0);\n writeBuffer.handle.unmap();\n if (mappableBuffer) {\n this._copyBuffer(mappableBuffer, byteOffset, alignedByteLength);\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 const requestedEnd = byteOffset + byteLength;\n if (requestedEnd > this.byteLength) {\n throw new Error('Mapping range exceeds buffer size');\n }\n\n let mappedByteOffset = byteOffset;\n let mappedByteLength = byteLength;\n let sliceByteOffset = 0;\n let lifetime: 'mapped' | 'copied' = 'mapped';\n\n // WebGPU mapAsync requires 8-byte offsets and 4-byte lengths.\n if (byteOffset % 8 !== 0 || byteLength % 4 !== 0) {\n mappedByteOffset = Math.floor(byteOffset / 8) * 8;\n const alignedEnd = Math.ceil(requestedEnd / 4) * 4;\n mappedByteLength = alignedEnd - mappedByteOffset;\n sliceByteOffset = byteOffset - mappedByteOffset;\n lifetime = 'copied';\n }\n\n if (mappedByteOffset + mappedByteLength > this.paddedByteLength) {\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.paddedByteLength)\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, mappedByteOffset, mappedByteLength);\n }\n await readBuffer.handle.mapAsync(GPUMapMode.READ, mappedByteOffset, mappedByteLength);\n const arrayBuffer = readBuffer.handle.getMappedRange(mappedByteOffset, mappedByteLength);\n const mappedRange =\n lifetime === 'mapped'\n ? arrayBuffer\n : arrayBuffer.slice(sliceByteOffset, sliceByteOffset + byteLength);\n // eslint-disable-next-line @typescript-eslint/await-thenable\n const result = await callback(mappedRange, lifetime);\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 if (this.destroyed) {\n return;\n }\n\n this.destroyResource();\n // GPUSampler does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "/**\n * Internal WebGPU CPU hotspot profiler helpers.\n *\n * Keep the profiler key and accessors localized here so the adapter-level\n * instrumentation can be reduced or removed without touching every call site.\n */\nexport const CPU_HOTSPOT_PROFILER_MODULE = 'cpu-hotspot-profiler';\nexport const CPU_HOTSPOT_SUBMIT_REASON = 'cpu-hotspot-submit-reason';\n\nexport type CpuHotspotProfiler = {\n enabled?: boolean;\n framebufferAcquireCount?: number;\n framebufferAcquireTimeMs?: number;\n currentTextureAcquireCount?: number;\n currentTextureAcquireTimeMs?: number;\n activeDefaultFramebufferAcquireDepth?: number;\n defaultFramebufferRenderPassCount?: number;\n explicitFramebufferRenderPassCount?: number;\n renderPassSetupCount?: number;\n renderPassSetupTimeMs?: number;\n renderPassDescriptorAssemblyCount?: number;\n renderPassDescriptorAssemblyTimeMs?: number;\n renderPassBeginCount?: number;\n renderPassBeginTimeMs?: number;\n submitCount?: number;\n submitTimeMs?: number;\n queueSubmitCount?: number;\n queueSubmitTimeMs?: number;\n submitResolveKickoffCount?: number;\n submitResolveKickoffTimeMs?: number;\n commandBufferDestroyCount?: number;\n commandBufferDestroyTimeMs?: number;\n defaultSubmitCount?: number;\n defaultSubmitTimeMs?: number;\n queryReadbackSubmitCount?: number;\n queryReadbackSubmitTimeMs?: number;\n errorScopePushCount?: number;\n errorScopePopCount?: number;\n errorScopeTimeMs?: number;\n textureViewReinitializeCount?: number;\n textureViewReinitializeTimeMs?: number;\n};\n\ntype UserDataOwner = {\n userData: Record<string, unknown>;\n};\n\n/** Returns the enabled profiler payload attached to a WebGPU userData owner. */\nexport function getCpuHotspotProfiler(owner: UserDataOwner): CpuHotspotProfiler | null {\n const profiler = owner.userData[CPU_HOTSPOT_PROFILER_MODULE] as CpuHotspotProfiler | undefined;\n return profiler?.enabled ? profiler : null;\n}\n\n/** Returns the optional submit reason tag used to split submit timing buckets. */\nexport function getCpuHotspotSubmitReason(owner: UserDataOwner): string | null {\n return (owner.userData[CPU_HOTSPOT_SUBMIT_REASON] as string | undefined) || null;\n}\n\n/** Updates the optional submit reason tag used by the profiler. */\nexport function setCpuHotspotSubmitReason(\n owner: UserDataOwner,\n submitReason: string | undefined\n): void {\n owner.userData[CPU_HOTSPOT_SUBMIT_REASON] = submitReason;\n}\n\n/** Shared timestamp helper for low-overhead CPU-side instrumentation. */\nexport function getTimestamp(): number {\n return globalThis.performance?.now?.() ?? Date.now();\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';\nimport {getCpuHotspotProfiler, getTimestamp} from '../helpers/cpu-hotspot-profiler';\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 = 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 if (this.destroyed) {\n return;\n }\n\n this.destroyResource();\n // GPUTextureView does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n\n /**\n * Internal-only hook for the cached CanvasContext/PresentationContext swapchain path.\n * Rebuilds the default view when the per-frame canvas texture handle changes, without\n * replacing the long-lived luma.gl wrapper object.\n */\n _reinitialize(texture: WebGPUTexture): void {\n // @ts-expect-error readonly\n this.texture = texture;\n\n const profiler = getCpuHotspotProfiler(this.device);\n this.device.pushErrorScope('validation');\n const createViewStartTime = profiler ? getTimestamp() : 0;\n const handle = 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 if (profiler) {\n profiler.textureViewReinitializeCount = (profiler.textureViewReinitializeCount || 0) + 1;\n profiler.textureViewReinitializeTimeMs =\n (profiler.textureViewReinitializeTimeMs || 0) + (getTimestamp() - createViewStartTime);\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 handle.label = this.props.id;\n // @ts-expect-error readonly\n this.handle = handle;\n }\n}\n", "// luma.gl, MIT license\nimport {\n type TextureProps,\n type TextureViewProps,\n type CopyExternalImageOptions,\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';\nimport {WebGPUBuffer} from './webgpu-buffer';\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 private _allocatedByteLength: number = 0;\n\n constructor(device: WebGPUDevice, props: TextureProps) {\n // WebGPU buffer copies use 256-byte row alignment. queue.writeTexture() can use tightly packed rows.\n super(device, props, {byteAlignment: 256});\n this.device = device;\n\n if (props.sampler instanceof WebGPUSampler) {\n this.sampler = props.sampler;\n } else if (props.sampler === undefined) {\n this.sampler = this.device.getDefaultSampler();\n } else {\n this.sampler = new WebGPUSampler(this.device, (props.sampler as SamplerProps) || {});\n this.attachResource(this.sampler);\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 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.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 this.attachResource(this.view);\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 this._allocatedByteLength = this.getAllocatedByteLength();\n\n if (!this.props.handle) {\n this.trackAllocatedMemory(this._allocatedByteLength, 'Texture');\n } else {\n this.trackReferencedMemory(this._allocatedByteLength, 'Texture');\n }\n }\n\n override destroy(): void {\n if (this.destroyed) {\n return;\n }\n\n if (!this.props.handle && this.handle) {\n this.trackDeallocatedMemory('Texture');\n this.handle.destroy();\n } else if (this.handle) {\n this.trackDeallocatedReferencedMemory('Texture');\n }\n\n this.destroyResource();\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 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(\n options: TextureReadOptions & {byteOffset?: number} = {},\n buffer?: Buffer\n ): Buffer {\n if (!buffer) {\n throw new Error(`${this} readBuffer requires a destination buffer`);\n }\n const {x, y, z, width, height, depthOrArrayLayers, mipLevel, aspect} =\n this._getSupportedColorReadOptions(options);\n const byteOffset = options.byteOffset ?? 0;\n\n const layout = this.computeMemoryLayout({width, height, depthOrArrayLayers, mipLevel});\n\n const {byteLength} = layout;\n\n if (buffer.byteLength < byteOffset + byteLength) {\n throw new Error(\n `${this} readBuffer target is too small (${buffer.byteLength} < ${byteOffset + byteLength})`\n );\n }\n\n const gpuDevice = this.device.handle;\n this.device.pushErrorScope('validation');\n const commandEncoder = gpuDevice.createCommandEncoder();\n this.copyToBuffer(\n commandEncoder,\n {x, y, z, width, height, depthOrArrayLayers, mipLevel, aspect, byteOffset},\n buffer\n );\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} readBuffer: ${error.message}`), this)();\n this.device.debug();\n });\n\n return buffer;\n }\n\n override async readDataAsync(options: TextureReadOptions = {}): Promise<ArrayBuffer> {\n throw new Error(\n `${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`\n );\n }\n\n copyToBuffer(\n commandEncoder: GPUCommandEncoder,\n options: TextureReadOptions & {\n byteOffset?: number;\n bytesPerRow?: number;\n rowsPerImage?: number;\n } = {},\n buffer: Buffer\n ): void {\n const {\n byteOffset = 0,\n bytesPerRow: requestedBytesPerRow,\n rowsPerImage: requestedRowsPerImage,\n ...textureReadOptions\n } = options;\n const {x, y, z, width, height, depthOrArrayLayers, mipLevel, aspect} =\n this._getSupportedColorReadOptions(textureReadOptions);\n const layout = this.computeMemoryLayout({width, height, depthOrArrayLayers, mipLevel});\n const effectiveBytesPerRow = requestedBytesPerRow ?? layout.bytesPerRow;\n const effectiveRowsPerImage = requestedRowsPerImage ?? layout.rowsPerImage;\n const webgpuBuffer = buffer as WebGPUBuffer;\n\n commandEncoder.copyTextureToBuffer(\n {\n texture: this.handle,\n origin: {x, y, z},\n mipLevel,\n aspect\n },\n {\n buffer: webgpuBuffer.handle,\n offset: byteOffset,\n bytesPerRow: effectiveBytesPerRow,\n rowsPerImage: effectiveRowsPerImage\n },\n {\n width,\n height,\n depthOrArrayLayers\n }\n );\n }\n\n override writeBuffer(buffer: Buffer, options_: TextureWriteOptions = {}) {\n const options = this._normalizeTextureWriteOptions(options_);\n const {\n x,\n y,\n z,\n width,\n height,\n depthOrArrayLayers,\n mipLevel,\n aspect,\n byteOffset,\n bytesPerRow,\n rowsPerImage\n } = options;\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: byteOffset,\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(\n data: ArrayBuffer | SharedArrayBuffer | ArrayBufferView,\n options_: TextureWriteOptions = {}\n ): void {\n const device = this.device;\n const options = this._normalizeTextureWriteOptions(options_);\n const {x, y, z, width, height, depthOrArrayLayers, mipLevel, aspect, byteOffset} = options;\n const source = data as GPUAllowSharedBufferSource;\n const formatInfo = this.device.getTextureFormatInfo(this.format);\n // queue.writeTexture() defaults to tightly packed rows, unlike WebGPU buffer copy paths.\n const packedSourceLayout = textureFormatDecoder.computeMemoryLayout({\n format: this.format,\n width,\n height,\n depth: depthOrArrayLayers,\n byteAlignment: 1\n });\n const bytesPerRow = options_.bytesPerRow ?? packedSourceLayout.bytesPerRow;\n const rowsPerImage = options_.rowsPerImage ?? packedSourceLayout.rowsPerImage;\n let copyWidth = width;\n let copyHeight = height;\n\n if (formatInfo.compressed) {\n const blockWidth = formatInfo.blockWidth || 1;\n const blockHeight = formatInfo.blockHeight || 1;\n copyWidth = Math.ceil(width / blockWidth) * blockWidth;\n copyHeight = Math.ceil(height / blockHeight) * blockHeight;\n }\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 source,\n {\n offset: byteOffset,\n bytesPerRow,\n rowsPerImage\n },\n {width: copyWidth, height: copyHeight, 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 /**\n * Internal-only hook for the cached CanvasContext/PresentationContext swapchain path.\n * Rebinds this handle-backed texture wrapper to the current per-frame canvas texture\n * without allocating a new luma.gl Texture or TextureView wrapper.\n */\n _reinitialize(handle: GPUTexture, props?: Partial<TextureProps>): void {\n const nextWidth = props?.width ?? handle.width ?? this.width;\n const nextHeight = props?.height ?? handle.height ?? this.height;\n const nextDepth = props?.depth ?? this.depth;\n const nextFormat = props?.format ?? this.format;\n const allocationMayHaveChanged =\n nextWidth !== this.width ||\n nextHeight !== this.height ||\n nextDepth !== this.depth ||\n nextFormat !== this.format;\n handle.label ||= this.id;\n\n // @ts-expect-error readonly\n this.handle = handle;\n // @ts-expect-error readonly\n this.width = nextWidth;\n // @ts-expect-error readonly\n this.height = nextHeight;\n\n if (props?.depth !== undefined) {\n // @ts-expect-error readonly\n this.depth = nextDepth;\n }\n if (props?.format !== undefined) {\n // @ts-expect-error readonly\n this.format = nextFormat;\n }\n\n this.props.handle = handle;\n if (props?.width !== undefined) {\n this.props.width = props.width;\n }\n if (props?.height !== undefined) {\n this.props.height = props.height;\n }\n if (props?.depth !== undefined) {\n this.props.depth = props.depth;\n }\n if (props?.format !== undefined) {\n this.props.format = props.format;\n }\n\n if (allocationMayHaveChanged) {\n const nextAllocation = this.getAllocatedByteLength();\n if (nextAllocation !== this._allocatedByteLength) {\n this._allocatedByteLength = nextAllocation;\n this.trackReferencedMemory(nextAllocation, 'Texture');\n }\n }\n this.view._reinitialize(this);\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 // `_checkCompilationError()` runs asynchronously after construction, so the shader can be\n // destroyed before we await compilation info. Snapshot the handle and treat a destroyed shader\n // as having no compiler messages instead of dereferencing `null`.\n const handle = this.handle;\n if (!handle) {\n return [];\n }\n let compilationInfo;\n try {\n compilationInfo = await handle.getCompilationInfo();\n } catch (error) {\n if (this.device.shouldIgnoreDroppedInstanceError(error, 'getCompilationInfo')) {\n return [];\n }\n throw error;\n }\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 clearDepth: notSupported,\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 {ShaderLayout, BufferLayout, AttributeDeclaration, VertexFormat} from '@luma.gl/core';\nimport {log, vertexFormatDecoder} 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 options?: {pipelineId?: string}\n): GPUVertexBufferLayout[] {\n const vertexBufferLayouts: GPUVertexBufferLayout[] = [];\n const usedAttributes = new Set<string>();\n const shaderAttributes = shaderLayout.attributes || [];\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(\n shaderLayout,\n attributeName,\n usedAttributes,\n options\n );\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 += vertexFormatDecoder.getVertexFormatInfo(format).byteLength;\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n const attributeLayout = findAttributeLayout(\n shaderLayout,\n mapping.name,\n usedAttributes,\n options\n );\n if (!attributeLayout) {\n continue; // eslint-disable-line no-continue\n }\n byteStride = vertexFormatDecoder.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 shaderAttributes) {\n if (!usedAttributes.has(attribute.name)) {\n vertexBufferLayouts.push({\n arrayStride: vertexFormatDecoder.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 const shaderAttributes = shaderLayout.attributes || [];\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 shaderAttributes) {\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 options?: {pipelineId?: string}\n): AttributeDeclaration | null {\n const attribute = shaderLayout.attributes?.find(attribute_ => attribute_.name === name);\n if (!attribute) {\n const pipelineContext = options?.pipelineId\n ? `RenderPipeline(${options.pipelineId})`\n : 'RenderPipeline';\n log.warn(\n `${pipelineContext}: Ignoring \"${name}\" attribute, since it is not present in shader layout.`\n )();\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 {Bindings, BindingsByGroup, RenderPass, VertexArray} from '@luma.gl/core';\nimport {\n RenderPipeline,\n RenderPipelineProps,\n _getDefaultBindGroupFactory,\n log,\n normalizeBindingsByGroup\n} from '@luma.gl/core';\nimport {applyParametersToRenderPipelineDescriptor} from '../helpers/webgpu-parameters';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport {getVertexBufferLayout} from '../helpers/get-vertex-buffer-layout';\n// import {convertAttributesVertexBufferToLayout} from '../helpers/get-vertex-buffer-layout';\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 readonly descriptor: GPURenderPipelineDescriptor | null;\n\n readonly vs: WebGPUShader;\n readonly fs: WebGPUShader | null = null;\n\n /** Compatibility path for direct pipeline.setBindings() usage */\n private _bindingsByGroup: BindingsByGroup;\n private _bindGroupCacheKeysByGroup: Partial<Record<number, object>> = {};\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.shaderLayout ||= this.device.getShaderLayout((props.vs as WebGPUShader).source) || {\n attributes: [],\n bindings: []\n };\n this.handle = this.props.handle as GPURenderPipeline;\n let descriptor: GPURenderPipelineDescriptor | null = null;\n if (!this.handle) {\n 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.descriptor = descriptor;\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 this._bindingsByGroup =\n props.bindGroups || normalizeBindingsByGroup(this.shaderLayout, props.bindings);\n this._bindGroupCacheKeysByGroup = createBindGroupCacheKeys(this._bindingsByGroup);\n }\n\n override destroy(): void {\n // WebGPURenderPipeline has no destroy method.\n // @ts-expect-error\n this.handle = null;\n }\n\n /**\n * Compatibility shim for code paths that still set bindings on the pipeline.\n * The shared-model path passes bindings per draw and does not rely on this state.\n */\n setBindings(bindings: Bindings | BindingsByGroup): void {\n const nextBindingsByGroup = normalizeBindingsByGroup(this.shaderLayout, bindings);\n for (const [groupKey, groupBindings] of Object.entries(nextBindingsByGroup)) {\n const group = Number(groupKey);\n for (const [name, binding] of Object.entries(groupBindings || {})) {\n const currentGroupBindings = this._bindingsByGroup[group] || {};\n if (currentGroupBindings[name] !== binding) {\n if (\n !this._bindingsByGroup[group] ||\n this._bindingsByGroup[group] === currentGroupBindings\n ) {\n this._bindingsByGroup[group] = {...currentGroupBindings};\n }\n this._bindingsByGroup[group][name] = binding;\n this._bindGroupCacheKeysByGroup[group] = {};\n }\n }\n }\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 bindings?: Bindings;\n bindGroups?: BindingsByGroup;\n _bindGroupCacheKeys?: Partial<Record<number, object>>;\n uniforms?: Record<string, unknown>;\n }): boolean {\n const webgpuRenderPass = options.renderPass as WebGPURenderPass;\n const instanceCount =\n options.instanceCount && options.instanceCount > 0 ? options.instanceCount : 1;\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 hasExplicitBindings = Boolean(options.bindGroups || options.bindings);\n const bindGroups = _getDefaultBindGroupFactory(this.device).getBindGroups(\n this,\n hasExplicitBindings ? options.bindGroups || options.bindings : this._bindingsByGroup,\n hasExplicitBindings ? options._bindGroupCacheKeys : this._bindGroupCacheKeysByGroup\n );\n for (const [group, bindGroup] of Object.entries(bindGroups)) {\n if (bindGroup) {\n webgpuRenderPass.handle.setBindGroup(Number(group), bindGroup as GPUBindGroup);\n }\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 instanceCount,\n options.firstIndex || 0,\n options.baseVertex || 0,\n options.firstInstance || 0\n );\n } else {\n webgpuRenderPass.handle.draw(\n options.vertexCount || 0,\n instanceCount,\n options.firstVertex || 0,\n options.firstInstance || 0\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 _getBindingsByGroupWebGPU(): BindingsByGroup {\n return this._bindingsByGroup;\n }\n\n _getBindGroupCacheKeysWebGPU(): Partial<Record<number, object>> {\n return this._bindGroupCacheKeysByGroup;\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 pipelineId: this.id\n })\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\nfunction createBindGroupCacheKeys(\n bindingsByGroup: BindingsByGroup\n): Partial<Record<number, object>> {\n const bindGroupCacheKeys: Partial<Record<number, object>> = {};\n for (const [groupKey, groupBindings] of Object.entries(bindingsByGroup)) {\n if (groupBindings && Object.keys(groupBindings).length > 0) {\n bindGroupCacheKeys[Number(groupKey)] = {};\n }\n }\n return bindGroupCacheKeys;\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 /**\n * Internal-only hook for the cached CanvasContext/PresentationContext swapchain path.\n * Rebinds the long-lived default framebuffer wrapper to the current per-frame color view\n * and optional depth attachment without allocating a new luma.gl Framebuffer object.\n */\n _reinitialize(\n colorAttachment: WebGPUTextureView,\n depthStencilAttachment: WebGPUTextureView | null\n ): void {\n this.colorAttachments[0] = colorAttachment;\n // @ts-expect-error Internal-only canvas wrapper reuse mutates this otherwise-readonly attachment.\n this.depthStencilAttachment = depthStencilAttachment;\n this.width = colorAttachment.texture.width;\n this.height = colorAttachment.texture.height;\n\n this.props.width = this.width;\n this.props.height = this.height;\n this.props.colorAttachments = [colorAttachment.texture];\n this.props.depthStencilAttachment = depthStencilAttachment?.texture || null;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {\n ComputePipeline,\n ComputePipelineProps,\n Bindings,\n BindingsByGroup,\n _getDefaultBindGroupFactory,\n normalizeBindingsByGroup\n} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUShader} from './webgpu-shader';\n\nconst EMPTY_BIND_GROUPS: BindingsByGroup = {};\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 private _bindingsByGroup: BindingsByGroup;\n private _bindGroupCacheKeysByGroup: Partial<Record<number, object>>;\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 this._bindingsByGroup = EMPTY_BIND_GROUPS;\n this._bindGroupCacheKeysByGroup = {};\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: Bindings | BindingsByGroup): void {\n const nextBindingsByGroup = normalizeBindingsByGroup(this.shaderLayout, bindings);\n for (const [groupKey, groupBindings] of Object.entries(nextBindingsByGroup)) {\n const group = Number(groupKey);\n for (const [name, binding] of Object.entries(groupBindings || {})) {\n const currentGroupBindings = this._bindingsByGroup[group] || {};\n if (currentGroupBindings[name] !== binding) {\n if (\n !this._bindingsByGroup[group] ||\n this._bindingsByGroup[group] === currentGroupBindings\n ) {\n this._bindingsByGroup[group] = {...currentGroupBindings};\n }\n this._bindingsByGroup[group][name] = binding;\n this._bindGroupCacheKeysByGroup[group] = {};\n }\n }\n }\n }\n\n _getBindGroups(\n bindings?: Bindings | BindingsByGroup,\n bindGroupCacheKeys?: Partial<Record<number, object>>\n ): Partial<Record<number, unknown>> {\n const hasExplicitBindings = Boolean(bindings);\n return _getDefaultBindGroupFactory(this.device).getBindGroups(\n this,\n hasExplicitBindings ? bindings : this._bindingsByGroup,\n hasExplicitBindings ? bindGroupCacheKeys : this._bindGroupCacheKeysByGroup\n );\n }\n\n _getBindingsByGroupWebGPU(): BindingsByGroup {\n return this._bindingsByGroup;\n }\n\n _getBindGroupCacheKeysWebGPU(): Partial<Record<number, object>> {\n return this._bindGroupCacheKeysByGroup;\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 'VertexArray';\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';\nimport {getCpuHotspotProfiler, getTimestamp} from './helpers/cpu-hotspot-profiler';\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 colorAttachment: WebGPUTexture | null = null;\n private depthStencilAttachment: WebGPUTexture | null = null;\n private framebuffer: WebGPUFramebuffer | 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 this._startObservers();\n }\n\n /** Destroy any textures produced while configured and remove the context configuration. */\n override destroy(): void {\n if (this.framebuffer) {\n this.framebuffer.destroy();\n this.framebuffer = null;\n }\n if (this.colorAttachment) {\n this.colorAttachment.destroy();\n this.colorAttachment = null;\n }\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\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 this._createDepthStencilAttachment(this.device.preferredDepthFormat);\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 const profiler = getCpuHotspotProfiler(this.device);\n const startTime = profiler ? getTimestamp() : 0;\n if (profiler) {\n profiler.framebufferAcquireCount = (profiler.framebufferAcquireCount || 0) + 1;\n profiler.activeDefaultFramebufferAcquireDepth =\n (profiler.activeDefaultFramebufferAcquireDepth || 0) + 1;\n }\n\n try {\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 this.framebuffer ||= new WebGPUFramebuffer(this.device, {\n id: `${this.id}#framebuffer`,\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: null\n });\n this.framebuffer._reinitialize(\n currentColorAttachment.view,\n options?.depthStencilFormat ? this.depthStencilAttachment?.view || null : null\n );\n return this.framebuffer;\n } finally {\n if (profiler) {\n profiler.activeDefaultFramebufferAcquireDepth =\n (profiler.activeDefaultFramebufferAcquireDepth || 1) - 1;\n profiler.framebufferAcquireTimeMs =\n (profiler.framebufferAcquireTimeMs || 0) + (getTimestamp() - startTime);\n }\n }\n }\n\n // PRIMARY METHODS\n\n /** Wrap the current canvas context texture in a luma.gl texture */\n _getCurrentTexture(): WebGPUTexture {\n const profiler = getCpuHotspotProfiler(this.device);\n const currentTextureStartTime = profiler ? getTimestamp() : 0;\n const handle = this.handle.getCurrentTexture();\n if (profiler) {\n profiler.currentTextureAcquireCount = (profiler.currentTextureAcquireCount || 0) + 1;\n profiler.currentTextureAcquireTimeMs =\n (profiler.currentTextureAcquireTimeMs || 0) + (getTimestamp() - currentTextureStartTime);\n }\n if (!this.colorAttachment) {\n this.colorAttachment = 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 return this.colorAttachment;\n }\n\n this.colorAttachment._reinitialize(handle, {\n handle,\n format: this.device.preferredColorFormat,\n width: handle.width,\n height: handle.height\n });\n return this.colorAttachment;\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 const needsNewDepthStencilAttachment =\n !this.depthStencilAttachment ||\n this.depthStencilAttachment.width !== this.drawingBufferWidth ||\n this.depthStencilAttachment.height !== this.drawingBufferHeight ||\n this.depthStencilAttachment.format !== depthStencilFormat;\n if (needsNewDepthStencilAttachment) {\n this.depthStencilAttachment?.destroy();\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\n// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport type {PresentationContextProps, TextureFormatDepthStencil} from '@luma.gl/core';\nimport {PresentationContext, Texture, log} from '@luma.gl/core';\nimport type {WebGPUDevice} from './webgpu-device';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\nimport {WebGPUTexture} from './resources/webgpu-texture';\nimport {getCpuHotspotProfiler, getTimestamp} from './helpers/cpu-hotspot-profiler';\n\n/**\n * A WebGPU PresentationContext renders directly into its destination canvas.\n */\nexport class WebGPUPresentationContext extends PresentationContext {\n readonly device: WebGPUDevice;\n readonly handle: GPUCanvasContext;\n\n private colorAttachment: WebGPUTexture | null = null;\n private depthStencilAttachment: WebGPUTexture | null = null;\n private framebuffer: WebGPUFramebuffer | null = null;\n\n get [Symbol.toStringTag](): string {\n return 'WebGPUPresentationContext';\n }\n\n constructor(device: WebGPUDevice, props: PresentationContextProps = {}) {\n super(props);\n const contextLabel = `${this[Symbol.toStringTag]}(${this.id})`;\n\n const context = this.canvas.getContext('webgpu');\n if (!context) {\n throw new Error(`${contextLabel}: Failed to create WebGPU presentation context`);\n }\n this.device = device;\n this.handle = context;\n\n this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`);\n this._configureDevice();\n this._startObservers();\n }\n\n override destroy(): void {\n if (this.framebuffer) {\n this.framebuffer.destroy();\n this.framebuffer = null;\n }\n if (this.colorAttachment) {\n this.colorAttachment.destroy();\n this.colorAttachment = null;\n }\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n this.handle.unconfigure();\n super.destroy();\n }\n\n present(): void {\n this.device.submit();\n }\n\n protected override _configureDevice(): void {\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n\n this.handle.configure({\n device: this.device.handle,\n format: this.device.preferredColorFormat,\n colorSpace: this.props.colorSpace,\n alphaMode: this.props.alphaMode\n });\n\n this._createDepthStencilAttachment(this.device.preferredDepthFormat);\n }\n\n protected override _getCurrentFramebuffer(\n options: {depthStencilFormat?: TextureFormatDepthStencil | false} = {\n depthStencilFormat: 'depth24plus'\n }\n ): WebGPUFramebuffer {\n const profiler = getCpuHotspotProfiler(this.device);\n const startTime = profiler ? getTimestamp() : 0;\n if (profiler) {\n profiler.framebufferAcquireCount = (profiler.framebufferAcquireCount || 0) + 1;\n }\n\n try {\n const currentColorAttachment = this._getCurrentTexture();\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[Symbol.toStringTag]}(${this.id}): Resized to compensate for initial canvas size mismatch ${oldWidth}x${oldHeight} => ${this.drawingBufferWidth}x${this.drawingBufferHeight}px`\n )();\n }\n\n if (options?.depthStencilFormat) {\n this._createDepthStencilAttachment(options.depthStencilFormat);\n }\n\n this.framebuffer ||= new WebGPUFramebuffer(this.device, {\n id: `${this.id}#framebuffer`,\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: null\n });\n this.framebuffer._reinitialize(\n currentColorAttachment.view,\n options?.depthStencilFormat ? this.depthStencilAttachment?.view || null : null\n );\n return this.framebuffer;\n } finally {\n if (profiler) {\n profiler.framebufferAcquireTimeMs =\n (profiler.framebufferAcquireTimeMs || 0) + (getTimestamp() - startTime);\n }\n }\n }\n\n private _getCurrentTexture(): WebGPUTexture {\n const profiler = getCpuHotspotProfiler(this.device);\n const currentTextureStartTime = profiler ? getTimestamp() : 0;\n const handle = this.handle.getCurrentTexture();\n if (profiler) {\n profiler.currentTextureAcquireCount = (profiler.currentTextureAcquireCount || 0) + 1;\n profiler.currentTextureAcquireTimeMs =\n (profiler.currentTextureAcquireTimeMs || 0) + (getTimestamp() - currentTextureStartTime);\n }\n if (!this.colorAttachment) {\n this.colorAttachment = 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 return this.colorAttachment;\n }\n\n this.colorAttachment._reinitialize(handle, {\n handle,\n format: this.device.preferredColorFormat,\n width: handle.width,\n height: handle.height\n });\n return this.colorAttachment;\n }\n\n private _createDepthStencilAttachment(\n depthStencilFormat: TextureFormatDepthStencil\n ): WebGPUTexture {\n const needsNewDepthStencilAttachment =\n !this.depthStencilAttachment ||\n this.depthStencilAttachment.width !== this.drawingBufferWidth ||\n this.depthStencilAttachment.height !== this.drawingBufferHeight ||\n this.depthStencilAttachment.format !== depthStencilFormat;\n if (needsNewDepthStencilAttachment) {\n this.depthStencilAttachment?.destroy();\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, props);\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, Bindings, BindingsByGroup} from '@luma.gl/core';\nimport {Buffer, RenderPass, RenderPipeline, _getDefaultBindGroupFactory, 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';\nimport {getCpuHotspotProfiler, getTimestamp} from '../helpers/cpu-hotspot-profiler';\n\nexport class WebGPURenderPass extends RenderPass {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPassEncoder;\n readonly framebuffer: WebGPUFramebuffer;\n\n /** Active pipeline */\n pipeline: WebGPURenderPipeline | null = null;\n\n /** Latest bindings applied to this pass */\n bindings: Bindings | BindingsByGroup = {};\n\n constructor(\n device: WebGPUDevice,\n props: RenderPassProps = {},\n commandEncoder: GPUCommandEncoder = device.commandEncoder.handle\n ) {\n super(device, props);\n this.device = device;\n const {props: renderPassProps} = this;\n this.framebuffer =\n (renderPassProps.framebuffer as WebGPUFramebuffer) ||\n device.getCanvasContext().getCurrentFramebuffer();\n\n const profiler = getCpuHotspotProfiler(this.device);\n if (profiler) {\n const counterName:\n | 'explicitFramebufferRenderPassCount'\n | 'defaultFramebufferRenderPassCount' = renderPassProps.framebuffer\n ? 'explicitFramebufferRenderPassCount'\n : 'defaultFramebufferRenderPassCount';\n profiler[counterName] = (profiler[counterName] || 0) + 1;\n }\n\n const startTime = profiler ? getTimestamp() : 0;\n try {\n const descriptorAssemblyStartTime = profiler ? getTimestamp() : 0;\n const renderPassDescriptor = this.getRenderPassDescriptor(this.framebuffer);\n\n if (renderPassProps.occlusionQuerySet) {\n renderPassDescriptor.occlusionQuerySet = (\n renderPassProps.occlusionQuerySet as WebGPUQuerySet\n ).handle;\n }\n\n if (renderPassProps.timestampQuerySet) {\n const webgpuTSQuerySet = renderPassProps.timestampQuerySet as WebGPUQuerySet;\n webgpuTSQuerySet?._invalidateResults();\n renderPassDescriptor.timestampWrites = webgpuTSQuerySet\n ? ({\n querySet: webgpuTSQuerySet.handle,\n beginningOfPassWriteIndex: renderPassProps.beginTimestampIndex,\n endOfPassWriteIndex: renderPassProps.endTimestampIndex\n } as GPURenderPassTimestampWrites)\n : undefined;\n }\n if (profiler) {\n profiler.renderPassDescriptorAssemblyCount =\n (profiler.renderPassDescriptorAssemblyCount || 0) + 1;\n profiler.renderPassDescriptorAssemblyTimeMs =\n (profiler.renderPassDescriptorAssemblyTimeMs || 0) +\n (getTimestamp() - descriptorAssemblyStartTime);\n }\n\n this.device.pushErrorScope('validation');\n const beginRenderPassStartTime = profiler ? getTimestamp() : 0;\n this.handle = this.props.handle || commandEncoder.beginRenderPass(renderPassDescriptor);\n if (profiler) {\n profiler.renderPassBeginCount = (profiler.renderPassBeginCount || 0) + 1;\n profiler.renderPassBeginTimeMs =\n (profiler.renderPassBeginTimeMs || 0) + (getTimestamp() - beginRenderPassStartTime);\n }\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 } finally {\n if (profiler) {\n profiler.renderPassSetupCount = (profiler.renderPassSetupCount || 0) + 1;\n profiler.renderPassSetupTimeMs =\n (profiler.renderPassSetupTimeMs || 0) + (getTimestamp() - startTime);\n }\n }\n }\n\n override destroy(): void {\n this.destroyResource();\n }\n\n end(): void {\n if (this.destroyed) {\n return;\n }\n this.handle.end();\n this.destroy();\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: Bindings | BindingsByGroup): void {\n this.bindings = bindings;\n const bindGroups =\n (this.pipeline &&\n _getDefaultBindGroupFactory(this.device).getBindGroups(this.pipeline, bindings)) ||\n {};\n for (const [group, bindGroup] of Object.entries(bindGroups)) {\n if (bindGroup) {\n this.handle.setBindGroup(Number(group), bindGroup as GPUBindGroup);\n }\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 {\n ComputePass,\n ComputePassProps,\n ComputePipeline,\n Buffer,\n Bindings,\n BindingsByGroup,\n _getDefaultBindGroupFactory\n} 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(\n device: WebGPUDevice,\n props: ComputePassProps = {},\n commandEncoder: GPUCommandEncoder = device.commandEncoder.handle\n ) {\n super(device, props);\n this.device = device;\n const {props: computePassProps} = this;\n\n // Set up queries\n let timestampWrites: GPUComputePassTimestampWrites | undefined;\n if (computePassProps.timestampQuerySet) {\n const webgpuQuerySet = computePassProps.timestampQuerySet as WebGPUQuerySet;\n if (webgpuQuerySet) {\n webgpuQuerySet._invalidateResults();\n timestampWrites = {\n querySet: webgpuQuerySet.handle,\n beginningOfPassWriteIndex: computePassProps.beginTimestampIndex,\n endOfPassWriteIndex: computePassProps.endTimestampIndex\n };\n }\n }\n\n this.handle =\n this.props.handle ||\n commandEncoder.beginComputePass({\n label: this.props.id,\n timestampWrites\n });\n }\n\n /** @note no WebGPU destroy method, just gc */\n override destroy(): void {\n this.destroyResource();\n }\n\n end(): void {\n if (this.destroyed) {\n return;\n }\n this.handle.end();\n this.destroy();\n }\n\n setPipeline(pipeline: ComputePipeline): void {\n const wgpuPipeline = pipeline as WebGPUComputePipeline;\n this.handle.setPipeline(wgpuPipeline.handle);\n this._webgpuPipeline = wgpuPipeline;\n const bindGroups = _getDefaultBindGroupFactory(this.device).getBindGroups(\n this._webgpuPipeline,\n this._webgpuPipeline._getBindingsByGroupWebGPU(),\n this._webgpuPipeline._getBindGroupCacheKeysWebGPU()\n );\n for (const [group, bindGroup] of Object.entries(bindGroups)) {\n if (bindGroup) {\n this.handle.setBindGroup(Number(group), bindGroup as GPUBindGroup);\n }\n }\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: Bindings | BindingsByGroup): void {\n const bindGroups =\n (this._webgpuPipeline &&\n _getDefaultBindGroupFactory(this.device).getBindGroups(this._webgpuPipeline, bindings)) ||\n {};\n for (const [group, bindGroup] of Object.entries(bindGroups)) {\n if (bindGroup) {\n this.handle.setBindGroup(Number(group), bindGroup as GPUBindGroup);\n }\n }\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 CommandBufferProps,\n RenderPassProps,\n ComputePassProps,\n CopyBufferToTextureOptions,\n CopyTextureToTextureOptions,\n CopyTextureToBufferOptions\n} from '@luma.gl/core';\nimport {CommandEncoder, CommandEncoderProps, Buffer} 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 this.destroyResource();\n }\n\n finish(props?: CommandBufferProps): 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 this.destroy();\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(\n this.device,\n this._applyTimeProfilingToPassProps(props),\n this.handle\n );\n }\n\n beginComputePass(props: ComputePassProps = {}): WebGPUComputePass {\n return new WebGPUComputePass(\n this.device,\n this._applyTimeProfilingToPassProps(props),\n this.handle\n );\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n\n copyBufferToBuffer(options: {\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): void {\n const webgpuSourceBuffer = options.sourceBuffer as WebGPUBuffer;\n const webgpuDestinationTexture = options.destinationTexture as WebGPUTexture;\n const copyOrigin = options.origin ?? [0, 0, 0];\n const copySize = options.size;\n this.handle.copyBufferToTexture(\n {\n buffer: webgpuSourceBuffer.handle,\n offset: options.byteOffset ?? 0,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage\n },\n {\n texture: webgpuDestinationTexture.handle,\n mipLevel: options.mipLevel ?? 0,\n origin: {\n x: copyOrigin[0] ?? 0,\n y: copyOrigin[1] ?? 0,\n z: copyOrigin[2] ?? 0\n },\n aspect: options.aspect\n },\n {\n width: copySize[0],\n height: copySize[1],\n depthOrArrayLayers: copySize[2]\n }\n );\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n const {\n sourceTexture,\n destinationBuffer,\n origin = [0, 0, 0],\n byteOffset = 0,\n width,\n height,\n depthOrArrayLayers,\n mipLevel,\n aspect\n } = options;\n const webgpuSourceTexture = sourceTexture as WebGPUTexture;\n webgpuSourceTexture.copyToBuffer(\n this.handle,\n {\n x: origin[0] ?? 0,\n y: origin[1] ?? 0,\n z: origin[2] ?? 0,\n width,\n height,\n depthOrArrayLayers,\n mipLevel,\n aspect,\n byteOffset,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage\n },\n destinationBuffer\n );\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n const webgpuSourceTexture = options.sourceTexture as WebGPUTexture;\n const webgpuDestinationTexture = options.destinationTexture as WebGPUTexture;\n const sourceRegion = webgpuSourceTexture._normalizeTextureReadOptions({\n x: options.origin?.[0] ?? 0,\n y: options.origin?.[1] ?? 0,\n z: options.origin?.[2] ?? 0,\n width: options.width,\n height: options.height,\n depthOrArrayLayers: options.depthOrArrayLayers,\n mipLevel: options.mipLevel ?? 0,\n aspect: options.aspect ?? 'all'\n });\n\n this.handle.copyTextureToTexture(\n {\n texture: webgpuSourceTexture.handle,\n mipLevel: sourceRegion.mipLevel,\n origin: {\n x: sourceRegion.x,\n y: sourceRegion.y,\n z: sourceRegion.z\n },\n aspect: sourceRegion.aspect\n },\n {\n texture: webgpuDestinationTexture.handle,\n mipLevel: options.destinationMipLevel ?? 0,\n origin: {\n x: options.destinationOrigin?.[0] ?? 0,\n y: options.destinationOrigin?.[1] ?? 0,\n z: options.destinationOrigin?.[2] ?? 0\n },\n aspect: options.destinationAspect ?? sourceRegion.aspect\n },\n {\n width: sourceRegion.width,\n height: sourceRegion.height,\n depthOrArrayLayers: sourceRegion.depthOrArrayLayers\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 writeTimestamp(querySet: WebGPUQuerySet, queryIndex: number): void {\n querySet._invalidateResults();\n const writeTimestamp = (\n this.handle as GPUCommandEncoder & {\n writeTimestamp?: (querySet: GPUQuerySet, queryIndex: number) => void;\n }\n ).writeTimestamp;\n\n if (writeTimestamp) {\n writeTimestamp.call(this.handle, querySet.handle, queryIndex);\n return;\n }\n\n const computePass = this.handle.beginComputePass({\n timestampWrites: {\n querySet: querySet.handle,\n beginningOfPassWriteIndex: queryIndex\n }\n });\n computePass.end();\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 {Buffer, QuerySet, QuerySetProps} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {\n getCpuHotspotSubmitReason,\n setCpuHotspotSubmitReason\n} from '../helpers/cpu-hotspot-profiler';\n\n/**\n * Immutable\n */\nexport class WebGPUQuerySet extends QuerySet {\n readonly device: WebGPUDevice;\n readonly handle: GPUQuerySet;\n\n protected _resolveBuffer: WebGPUBuffer | null = null;\n protected _readBuffer: WebGPUBuffer | null = null;\n protected _cachedResults: bigint[] | null = null;\n protected _readResultsPromise: Promise<bigint[]> | null = null;\n protected _resultsPendingResolution: boolean = false;\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 if (!this.destroyed) {\n this.handle?.destroy();\n this.destroyResource();\n // @ts-expect-error readonly\n this.handle = null;\n }\n }\n\n isResultAvailable(queryIndex?: number): boolean {\n if (!this._cachedResults) {\n return false;\n }\n\n return queryIndex === undefined\n ? true\n : queryIndex >= 0 && queryIndex < this._cachedResults.length;\n }\n\n async readResults(options?: {firstQuery?: number; queryCount?: number}): Promise<bigint[]> {\n const firstQuery = options?.firstQuery || 0;\n const queryCount = options?.queryCount || this.props.count - firstQuery;\n\n if (firstQuery < 0 || queryCount < 0 || firstQuery + queryCount > this.props.count) {\n throw new Error('Query read range is out of bounds');\n }\n\n let needsFreshResults = true;\n while (needsFreshResults) {\n if (!this._readResultsPromise) {\n this._readResultsPromise = this._readAllResults();\n }\n\n const readResultsPromise = this._readResultsPromise;\n const results = await readResultsPromise;\n\n // A later submit may have invalidated the query set while this read was in flight.\n // Retry so each caller observes the freshest resolved results instead of stale data.\n needsFreshResults = this._resultsPendingResolution;\n if (!needsFreshResults) {\n return results.slice(firstQuery, firstQuery + queryCount);\n }\n }\n\n throw new Error('Query read unexpectedly failed to resolve');\n }\n\n async readTimestampDuration(beginIndex: number, endIndex: number): Promise<number> {\n if (this.props.type !== 'timestamp') {\n throw new Error('Timestamp durations require a timestamp QuerySet');\n }\n if (beginIndex < 0 || endIndex <= beginIndex || endIndex >= this.props.count) {\n throw new Error('Timestamp duration range is out of bounds');\n }\n\n const results = await this.readResults({\n firstQuery: beginIndex,\n queryCount: endIndex - beginIndex + 1\n });\n return Number(results[results.length - 1] - results[0]) / 1e6;\n }\n\n /** Marks any cached query results as stale after new writes have been encoded. */\n _invalidateResults(): void {\n this._cachedResults = null;\n this._resultsPendingResolution = true;\n }\n\n protected async _readAllResults(): Promise<bigint[]> {\n this._ensureBuffers();\n\n try {\n // Use a dedicated encoder so async profiling reads cannot flush or replace the\n // device's active frame encoder while application rendering is in flight.\n if (this._resultsPendingResolution) {\n const commandEncoder = this.device.createCommandEncoder({\n id: `${this.id}-read-results`\n });\n commandEncoder.resolveQuerySet(this, this._resolveBuffer!);\n commandEncoder.copyBufferToBuffer({\n sourceBuffer: this._resolveBuffer!,\n destinationBuffer: this._readBuffer!,\n size: this._resolveBuffer!.byteLength\n });\n const commandBuffer = commandEncoder.finish({\n id: `${this.id}-read-results-command-buffer`\n });\n const previousSubmitReason = getCpuHotspotSubmitReason(this.device) || undefined;\n setCpuHotspotSubmitReason(this.device, 'query-readback');\n try {\n this.device.submit(commandBuffer);\n } finally {\n setCpuHotspotSubmitReason(this.device, previousSubmitReason);\n }\n }\n\n const data = await this._readBuffer!.readAsync(0, this._readBuffer!.byteLength);\n const resultView = new BigUint64Array(data.buffer, data.byteOffset, this.props.count);\n this._cachedResults = Array.from(resultView, value => value);\n this._resultsPendingResolution = false;\n return this._cachedResults;\n } finally {\n this._readResultsPromise = null;\n }\n }\n\n protected _ensureBuffers(): void {\n if (this._resolveBuffer && this._readBuffer) {\n return;\n }\n\n const byteLength = this.props.count * 8;\n this._resolveBuffer = this.device.createBuffer({\n id: `${this.id}-resolve-buffer`,\n usage: Buffer.QUERY_RESOLVE | Buffer.COPY_SRC,\n byteLength\n });\n this.attachResource(this._resolveBuffer);\n\n this._readBuffer = this.device.createBuffer({\n id: `${this.id}-read-buffer`,\n usage: Buffer.COPY_DST | Buffer.MAP_READ,\n byteLength\n });\n this.attachResource(this._readBuffer);\n }\n\n _encodeResolveToReadBuffer(\n commandEncoder: {\n resolveQuerySet: (\n querySet: WebGPUQuerySet,\n destination: WebGPUBuffer,\n options?: {firstQuery?: number; queryCount?: number; destinationOffset?: number}\n ) => void;\n copyBufferToBuffer: (options: {\n sourceBuffer: WebGPUBuffer;\n destinationBuffer: WebGPUBuffer;\n sourceOffset?: number;\n destinationOffset?: number;\n size?: number;\n }) => void;\n },\n options?: {firstQuery?: number; queryCount?: number}\n ): boolean {\n if (!this._resultsPendingResolution) {\n return false;\n }\n\n // If a readback is already mapping the shared read buffer, defer to the fallback read path.\n // That path will submit resolve/copy commands once the current read has completed.\n if (this._readResultsPromise) {\n return false;\n }\n\n this._ensureBuffers();\n const firstQuery = options?.firstQuery || 0;\n const queryCount = options?.queryCount || this.props.count - firstQuery;\n const byteLength = queryCount * BigUint64Array.BYTES_PER_ELEMENT;\n const byteOffset = firstQuery * BigUint64Array.BYTES_PER_ELEMENT;\n\n commandEncoder.resolveQuerySet(this, this._resolveBuffer!, {\n firstQuery,\n queryCount,\n destinationOffset: byteOffset\n });\n commandEncoder.copyBufferToBuffer({\n sourceBuffer: this._resolveBuffer!,\n sourceOffset: byteOffset,\n destinationBuffer: this._readBuffer!,\n destinationOffset: byteOffset,\n size: byteLength\n });\n this._resultsPendingResolution = false;\n return true;\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 bindGroupEntriesByGroup = this.mapShaderLayoutToBindGroupEntriesByGroup();\n\n this.handle = this.device.handle.createPipelineLayout({\n label: props?.id ?? 'unnamed-pipeline-layout',\n bindGroupLayouts: bindGroupEntriesByGroup.map((entries, group) =>\n this.device.handle.createBindGroupLayout({\n label: `bind-group-layout-${group}`,\n entries\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 mapShaderLayoutToBindGroupEntriesByGroup(): GPUBindGroupLayoutEntry[][] {\n const maxGroup = this.props.shaderLayout.bindings.reduce(\n (highestGroup, binding) => Math.max(highestGroup, binding.group),\n -1\n );\n const bindGroupEntriesByGroup: GPUBindGroupLayoutEntry[][] = Array.from(\n {length: maxGroup + 1},\n () => []\n );\n\n for (const binding of this.props.shaderLayout.bindings) {\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 bindGroupEntriesByGroup[binding.group].push({\n binding: binding.location,\n visibility: binding.visibility || VISIBILITY_ALL,\n ...bindingTypeInfo\n });\n }\n\n return bindGroupEntriesByGroup;\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\n .onSubmittedWorkDone()\n .then(() => {\n this._signaled = true;\n })\n .catch(error => {\n if (this.device.shouldIgnoreDroppedInstanceError(error)) {\n return;\n }\n throw error;\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 storageBuffer of parsedWGSL.storage) {\n shaderLayout.bindings.push({\n type: storageBuffer.access === 'read' ? 'read-only-storage' : 'storage',\n name: storageBuffer.name,\n group: storageBuffer.group,\n location: storageBuffer.binding\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// Forked from https://github.com/greggman/webgpu-utils under MIT license\n// Copyright (c) 2022 Gregg Tavares\n\nimport type {\n Texture,\n TextureView,\n TextureFormat,\n TextureFormatColor,\n TextureBindingLayout,\n StorageTextureBindingLayout,\n UniformBufferBindingLayout,\n SamplerBindingLayout\n} from '@luma.gl/core';\nimport {Buffer, textureFormatDecoder} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport type {WebGPUComputePass} from '../resources/webgpu-compute-pass';\nimport type {WebGPURenderPass} from '../resources/webgpu-render-pass';\n\ntype RenderTextureViewDimension = '2d' | '2d-array' | 'cube' | 'cube-array';\ntype TextureCapability = 'render' | 'filter' | 'store';\ntype MipmapPath = 'render' | 'compute';\n\nconst RENDER_DIMENSIONS: ReadonlyArray<RenderTextureViewDimension> = [\n '2d',\n '2d-array',\n 'cube',\n 'cube-array'\n];\n\nconst WORKGROUP_SIZE = {\n x: 4,\n y: 4,\n z: 4\n} as const;\n\nconst RENDER_SOURCE_SAMPLER_LAYOUT: SamplerBindingLayout = {\n type: 'sampler',\n name: 'sourceSampler',\n group: 0,\n location: 0\n};\n\nconst COMPUTE_SOURCE_TEXTURE_LAYOUT: TextureBindingLayout = {\n type: 'texture',\n name: 'sourceTexture',\n group: 0,\n location: 0,\n viewDimension: '3d',\n sampleType: 'float'\n};\n\nconst COMPUTE_UNIFORMS_LAYOUT: UniformBufferBindingLayout = {\n type: 'uniform',\n name: 'uniforms',\n group: 0,\n location: 2\n};\n\n/**\n * Generates mip levels from level 0 to the last mip for an existing WebGPU texture.\n */\nexport function generateMipmapsWebGPU(device: WebGPUDevice, texture: Texture): void {\n if (texture.mipLevels <= 1) {\n return;\n }\n\n if (texture.dimension === '3d') {\n generateMipmaps3D(device, texture);\n return;\n }\n\n if (RENDER_DIMENSIONS.includes(texture.dimension as RenderTextureViewDimension)) {\n generateMipmapsRender(device, texture);\n return;\n }\n\n throw new Error(\n `Cannot generate mipmaps for texture dimension \"${texture.dimension}\" with WebGPU.`\n );\n}\n\nfunction generateMipmapsRender(device: WebGPUDevice, texture: Texture): void {\n validateFormatCapabilities(device, texture, ['render', 'filter'], 'render');\n const colorAttachmentFormat = getColorAttachmentFormat(\n texture.format,\n 'render',\n texture.dimension\n );\n\n const viewDimension = texture.dimension as RenderTextureViewDimension;\n const shaderSource = getRenderMipmapWGSL(viewDimension);\n const sampler = device.createSampler({minFilter: 'linear', magFilter: 'linear'});\n const uniformsBuffer = device.createBuffer({\n byteLength: 16,\n usage: Buffer.UNIFORM | Buffer.COPY_DST\n });\n const uniformValues = new Uint32Array(1);\n const sourceTextureLayout: TextureBindingLayout = {\n type: 'texture',\n name: 'sourceTexture',\n group: 0,\n location: 1,\n viewDimension,\n sampleType: 'float'\n };\n const uniformsLayout: UniformBufferBindingLayout = {\n type: 'uniform',\n name: 'uniforms',\n group: 0,\n location: 2\n };\n const renderShaderLayout = {\n attributes: [],\n bindings: [RENDER_SOURCE_SAMPLER_LAYOUT, sourceTextureLayout, uniformsLayout]\n };\n const vertexShader = device.createShader({\n id: 'mipmap-generation-render-vs',\n source: shaderSource,\n language: 'wgsl',\n stage: 'vertex'\n });\n const fragmentShader = device.createShader({\n id: 'mipmap-generation-render-fs',\n source: shaderSource,\n language: 'wgsl',\n stage: 'fragment'\n });\n const renderPipeline = device.createRenderPipeline({\n id: `mipmap-generation-render:${texture.dimension}:${texture.format}`,\n vs: vertexShader,\n fs: fragmentShader,\n shaderLayout: renderShaderLayout,\n colorAttachmentFormats: [colorAttachmentFormat],\n topology: 'triangle-list'\n });\n\n let sourceWidth = texture.width;\n let sourceHeight = texture.height;\n const layerCount = texture.dimension === '2d' ? 1 : texture.depth;\n\n function renderMipmapLayer(\n sourceView: TextureView,\n baseMipLevel: number,\n baseArrayLayer: number,\n destinationWidth: number,\n destinationHeight: number\n ): void {\n uniformValues[0] = baseArrayLayer;\n uniformsBuffer.write(uniformValues);\n\n const destinationView = texture.createView({\n dimension: '2d',\n baseMipLevel,\n mipLevelCount: 1,\n baseArrayLayer,\n arrayLayerCount: 1\n });\n const framebuffer = device.createFramebuffer({\n colorAttachments: [destinationView]\n });\n const renderPass = device.beginRenderPass({\n id: `mipmap-generation:${texture.format}:${baseMipLevel}:${baseArrayLayer}`,\n framebuffer\n }) as WebGPURenderPass;\n\n try {\n renderPass.setPipeline(renderPipeline);\n renderPass.setBindings({\n sourceSampler: sampler,\n sourceTexture: sourceView,\n uniforms: uniformsBuffer\n });\n renderPass.setParameters({\n viewport: [0, 0, destinationWidth, destinationHeight, 0, 1],\n scissorRect: [0, 0, destinationWidth, destinationHeight]\n });\n renderPass.draw({vertexCount: 3});\n renderPass.end();\n device.submit();\n } finally {\n destinationView.destroy();\n framebuffer.destroy();\n }\n }\n\n try {\n for (let baseMipLevel = 1; baseMipLevel < texture.mipLevels; ++baseMipLevel) {\n validateFormatCapabilities(device, texture, ['render', 'filter'], 'render');\n const sourceMipLevel = baseMipLevel - 1;\n const destinationWidth = Math.max(1, sourceWidth >> 1);\n const destinationHeight = Math.max(1, sourceHeight >> 1);\n\n const sourceView = texture.createView({\n dimension: viewDimension,\n baseMipLevel: sourceMipLevel,\n mipLevelCount: 1,\n baseArrayLayer: 0,\n arrayLayerCount: texture.depth\n });\n\n try {\n for (let baseArrayLayer = 0; baseArrayLayer < layerCount; ++baseArrayLayer) {\n renderMipmapLayer(\n sourceView,\n baseMipLevel,\n baseArrayLayer,\n destinationWidth,\n destinationHeight\n );\n }\n } finally {\n sourceView.destroy();\n }\n\n sourceWidth = destinationWidth;\n sourceHeight = destinationHeight;\n }\n } finally {\n renderPipeline.destroy();\n vertexShader.destroy();\n fragmentShader.destroy();\n sampler.destroy();\n uniformsBuffer.destroy();\n }\n}\n\nfunction getColorAttachmentFormat(\n format: TextureFormat,\n path: MipmapPath,\n dimension: string\n): TextureFormatColor {\n if (textureFormatDecoder.isColor(format)) {\n return format;\n }\n\n throw new Error(\n `Cannot run ${path} mipmap generation for ${dimension} texture with format \"${format}\". ` +\n `Only color textures can be used for this operation. ` +\n `Required capabilities: color. ` +\n `Actual capabilities: color=false.`\n );\n}\n\nfunction generateMipmaps3D(device: WebGPUDevice, texture: Texture): void {\n validateFormatCapabilities(device, texture, ['filter', 'store'], 'compute');\n const format = getColorAttachmentFormat(texture.format, 'compute', texture.dimension);\n const shaderSource = get3DComputeMipmapWGSL(format);\n const destinationTextureLayout: StorageTextureBindingLayout = {\n type: 'storage',\n name: 'destinationTexture',\n group: 0,\n location: 1,\n format,\n viewDimension: '3d',\n access: 'write-only'\n };\n const computeShaderLayout = {\n bindings: [COMPUTE_SOURCE_TEXTURE_LAYOUT, destinationTextureLayout, COMPUTE_UNIFORMS_LAYOUT]\n };\n const computeShader = device.createShader({\n id: 'mipmap-generation-compute',\n source: shaderSource,\n language: 'wgsl',\n stage: 'compute'\n });\n const computePipeline = device.createComputePipeline({\n id: `mipmap-generation-compute:${texture.format}`,\n shader: computeShader,\n shaderLayout: computeShaderLayout\n });\n const uniformsBuffer = device.createBuffer({\n byteLength: 32,\n usage: Buffer.UNIFORM | Buffer.COPY_DST\n });\n const uniformValues = new Uint32Array(8);\n\n let sourceWidth = texture.width;\n let sourceHeight = texture.height;\n let sourceDepth = texture.depth;\n\n try {\n for (\n let destinationMipLevel = 1;\n destinationMipLevel < texture.mipLevels;\n ++destinationMipLevel\n ) {\n validateFormatCapabilities(device, texture, ['filter', 'store'], 'compute');\n const destinationWidth = Math.max(1, sourceWidth >> 1);\n const destinationHeight = Math.max(1, sourceHeight >> 1);\n const destinationDepth = Math.max(1, sourceDepth >> 1);\n\n uniformValues[0] = sourceWidth;\n uniformValues[1] = sourceHeight;\n uniformValues[2] = sourceDepth;\n uniformValues[3] = destinationWidth;\n uniformValues[4] = destinationHeight;\n uniformValues[5] = destinationDepth;\n uniformValues[6] = 0;\n uniformsBuffer.write(uniformValues);\n\n const sourceView = texture.createView({\n dimension: '3d',\n baseMipLevel: destinationMipLevel - 1,\n mipLevelCount: 1,\n baseArrayLayer: 0,\n arrayLayerCount: 1\n });\n const destinationView = texture.createView({\n dimension: '3d',\n baseMipLevel: destinationMipLevel,\n mipLevelCount: 1,\n baseArrayLayer: 0,\n arrayLayerCount: 1\n });\n computePipeline.setBindings({\n sourceTexture: sourceView,\n destinationTexture: destinationView,\n uniforms: uniformsBuffer\n });\n\n try {\n const workgroupsX = Math.ceil(destinationWidth / WORKGROUP_SIZE.x);\n const workgroupsY = Math.ceil(destinationHeight / WORKGROUP_SIZE.y);\n const workgroupsZ = Math.ceil(destinationDepth / WORKGROUP_SIZE.z);\n const computePass = device.beginComputePass({}) as WebGPUComputePass;\n\n computePass.setPipeline(computePipeline);\n computePass.dispatch(workgroupsX, workgroupsY, workgroupsZ);\n computePass.end();\n device.submit();\n } finally {\n sourceView.destroy();\n destinationView.destroy();\n }\n\n sourceWidth = destinationWidth;\n sourceHeight = destinationHeight;\n sourceDepth = destinationDepth;\n }\n } finally {\n computePipeline.destroy();\n computeShader.destroy();\n uniformsBuffer.destroy();\n }\n}\n\nfunction validateFormatCapabilities(\n device: WebGPUDevice,\n texture: Texture,\n requiredCapabilities: ReadonlyArray<TextureCapability>,\n path: MipmapPath\n): void {\n const {format, dimension} = texture;\n const capabilities = device.getTextureFormatCapabilities(format);\n const missingCapabilities = requiredCapabilities.filter(capability => !capabilities[capability]);\n\n if (missingCapabilities.length > 0) {\n const required = requiredCapabilities.join(' + ');\n const actual = requiredCapabilities\n .map(capability => `${capability}=${capabilities[capability]}`)\n .join(', ');\n throw new Error(\n `Cannot run ${path} mipmap generation for ${dimension} texture with format \"${format}\". ` +\n `Required capabilities: ${required}. ` +\n `Actual capabilities: ${actual}.`\n );\n }\n}\n\nfunction getSourceTextureType(dimension: RenderTextureViewDimension): string {\n switch (dimension) {\n case '2d':\n return 'texture_2d<f32>';\n case '2d-array':\n return 'texture_2d_array<f32>';\n case 'cube':\n return 'texture_cube<f32>';\n case 'cube-array':\n return 'texture_cube_array<f32>';\n default:\n throw new Error(`Unsupported render dimension \"${dimension}\" for mipmap generation.`);\n }\n}\n\nfunction getRenderMipmapWGSL(dimension: RenderTextureViewDimension): string {\n const sourceSnippet = getRenderMipmapSampleSnippet(dimension);\n\n return `\nstruct MipmapUniforms {\n sourceLayer: u32,\n};\n\nfn _touchUniform(uniforms: MipmapUniforms) {\n let unusedSourceLayer = uniforms.sourceLayer;\n}\n\nconst faceMat = array(\n mat3x3f(\n 0.0, 0.0, -2.0,\n 0.0, -2.0, 0.0,\n 1.0, 1.0, 1.0\n ), // pos-x\n mat3x3f(\n 0.0, 0.0, 2.0,\n 0.0, -2.0, 0.0,\n -1.0, 1.0, -1.0\n ), // neg-x\n mat3x3f(\n 2.0, 0.0, 0.0,\n 0.0, 0.0, 2.0,\n -1.0, 1.0, -1.0\n ), // pos-y\n mat3x3f(\n 2.0, 0.0, 0.0,\n 0.0, 0.0, -2.0,\n -1.0, -1.0, 1.0\n ), // neg-y\n mat3x3f(\n 2.0, 0.0, 0.0,\n 0.0, -2.0, 0.0,\n -1.0, 1.0, 1.0\n ), // pos-z\n mat3x3f(\n -2.0, 0.0, 0.0,\n 0.0, -2.0, 0.0,\n 1.0, 1.0, -1.0\n ) // neg-z\n);\n\nstruct FragmentInputs {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f\n};\n\nstruct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f\n};\n\n@group(0) @binding(0) var sourceSampler: sampler;\n@group(0) @binding(1) var sourceTexture: ${getSourceTextureType(dimension)};\n@group(0) @binding(2) var<uniform> uniforms: MipmapUniforms;\n\n@vertex\nfn vertexMain(\n @builtin(vertex_index) vertexIndex: u32\n) -> VertexOutput {\n const positions = array(\n vec2f(-1.0, -1.0),\n vec2f(-1.0, 3.0),\n vec2f( 3.0, -1.0)\n );\n\n let xy = positions[vertexIndex];\n return VertexOutput(\n vec4f(xy, 0.0, 1.0),\n xy * vec2f(0.5, -0.5) + vec2f(0.5)\n );\n}\n\n@fragment\nfn fragmentMain(fsInput: VertexOutput) -> @location(0) vec4f {\n _touchUniform(uniforms);\n return ${sourceSnippet};\n}\n`;\n}\n\nfunction getRenderMipmapSampleSnippet(dimension: RenderTextureViewDimension): string {\n const layer = 'uniforms.sourceLayer';\n\n switch (dimension) {\n case '2d':\n return 'textureSampleLevel(sourceTexture, sourceSampler, fsInput.texcoord, 0.0)';\n case '2d-array':\n return (\n 'textureSampleLevel(sourceTexture, sourceSampler, fsInput.texcoord, ' +\n `i32(${layer}), 0.0)`\n );\n case 'cube':\n return (\n 'textureSampleLevel(sourceTexture, sourceSampler, ' +\n `faceMat[i32(${layer})] * vec3f(fract(fsInput.texcoord), 1.0), 0.0)`\n );\n case 'cube-array':\n return (\n 'textureSampleLevel(sourceTexture, sourceSampler, ' +\n `faceMat[i32(${layer} % 6u)] * vec3f(fract(fsInput.texcoord), 1.0), ` +\n `i32(${layer} / 6u), 0.0)`\n );\n default:\n throw new Error(`Unsupported render dimension \"${dimension}\" for mipmap generation.`);\n }\n}\n\nfunction get3DComputeMipmapWGSL(format: TextureFormatColor): string {\n return `\nstruct MipmapUniforms {\n sourceWidth: u32,\n sourceHeight: u32,\n sourceDepth: u32,\n destinationWidth: u32,\n destinationHeight: u32,\n destinationDepth: u32,\n padding: u32,\n};\n\n@group(0) @binding(0) var sourceTexture: texture_3d<f32>;\n@group(0) @binding(1) var destinationTexture: texture_storage_3d<${format}, write>;\n@group(0) @binding(2) var<uniform> uniforms: MipmapUniforms;\n\n@compute @workgroup_size(${WORKGROUP_SIZE.x}, ${WORKGROUP_SIZE.y}, ${WORKGROUP_SIZE.z})\nfn main(@builtin(global_invocation_id) id: vec3<u32>) {\n if (\n id.x >= uniforms.destinationWidth ||\n id.y >= uniforms.destinationHeight ||\n id.z >= uniforms.destinationDepth\n ) {\n return;\n }\n\n let sourceBase = id * 2u;\n let sourceX0 = min(sourceBase.x, uniforms.sourceWidth - 1u);\n let sourceY0 = min(sourceBase.y, uniforms.sourceHeight - 1u);\n let sourceZ0 = min(sourceBase.z, uniforms.sourceDepth - 1u);\n\n let sourceX1 = min(sourceBase.x + 1u, uniforms.sourceWidth - 1u);\n let sourceY1 = min(sourceBase.y + 1u, uniforms.sourceHeight - 1u);\n let sourceZ1 = min(sourceBase.z + 1u, uniforms.sourceDepth - 1u);\n\n var sum = textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX0), i32(sourceY0), i32(sourceZ0)),\n 0\n );\n sum += textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX1), i32(sourceY0), i32(sourceZ0)),\n 0\n );\n sum += textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX0), i32(sourceY1), i32(sourceZ0)),\n 0\n );\n sum += textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX1), i32(sourceY1), i32(sourceZ0)),\n 0\n );\n sum += textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX0), i32(sourceY0), i32(sourceZ1)),\n 0\n );\n sum += textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX1), i32(sourceY0), i32(sourceZ1)),\n 0\n );\n sum += textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX0), i32(sourceY1), i32(sourceZ1)),\n 0\n );\n sum += textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX1), i32(sourceY1), i32(sourceZ1)),\n 0\n );\n\n textureStore(\n destinationTexture,\n vec3<i32>(i32(id.x), i32(id.y), i32(id.z)),\n vec4<f32>(sum.xyz / 8.0, sum.w / 8.0)\n );\n}\n`;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Binding, Bindings, ComputeShaderLayout, ShaderLayout} from '@luma.gl/core';\nimport {Buffer, Sampler, Texture, TextureView, getShaderLayoutBinding, log} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport type {WebGPUBuffer} from '../resources/webgpu-buffer';\nimport type {WebGPUSampler} from '../resources/webgpu-sampler';\nimport type {WebGPUTexture} from '../resources/webgpu-texture';\nimport type {WebGPUTextureView} from '../resources/webgpu-texture-view';\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: Bindings\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: WebGPUDevice,\n bindGroupLayout: GPUBindGroupLayout,\n shaderLayout: ShaderLayout | ComputeShaderLayout,\n bindings: Bindings,\n group: number\n): GPUBindGroup | null {\n const entries = getBindGroupEntries(bindings, shaderLayout, group);\n if (entries.length === 0) {\n return null;\n }\n device.pushErrorScope('validation');\n const bindGroup = device.handle.createBindGroup({\n layout: bindGroupLayout,\n entries\n });\n device.popErrorScope((error: GPUError) => {\n log.error(`bindGroup creation: ${error.message}`, bindGroup)();\n });\n return bindGroup;\n}\n\n/**\n * @param bindings\n * @returns\n */\nfunction getBindGroupEntries(\n bindings: Bindings,\n shaderLayout: ShaderLayout | ComputeShaderLayout,\n group: number\n): GPUBindGroupEntry[] {\n const entries: GPUBindGroupEntry[] = [];\n\n for (const [bindingName, value] of Object.entries(bindings)) {\n const exactBindingLayout = shaderLayout.bindings.find(binding => binding.name === bindingName);\n const bindingLayout = exactBindingLayout || getShaderLayoutBinding(shaderLayout, bindingName);\n const isShadowedAlias =\n !exactBindingLayout && bindingLayout ? bindingLayout.name in bindings : false;\n\n // Mirror the WebGL path: when both `foo` and `fooUniforms` exist in the bindings map,\n // prefer the exact shader binding name and ignore the alias entry.\n if (!isShadowedAlias && bindingLayout?.group === group) {\n const entry = bindingLayout\n ? getBindGroupEntry(value, bindingLayout.location, undefined, bindingName)\n : null;\n if (entry) {\n entries.push(entry);\n }\n\n // TODO - hack to automatically bind samplers to supplied texture default samplers\n if (value instanceof Texture) {\n const samplerBindingLayout = getShaderLayoutBinding(shaderLayout, `${bindingName}Sampler`, {\n ignoreWarnings: true\n });\n const samplerEntry = samplerBindingLayout\n ? samplerBindingLayout.group === group\n ? getBindGroupEntry(value, samplerBindingLayout.location, {sampler: true}, bindingName)\n : null\n : null;\n if (samplerEntry) {\n entries.push(samplerEntry);\n }\n }\n }\n }\n\n return entries;\n}\n\nfunction getBindGroupEntry(\n binding: Binding,\n index: number,\n options?: {sampler?: boolean},\n bindingName: string = 'unknown'\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 TextureView) {\n return {\n binding: index,\n resource: (binding as WebGPUTextureView).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 ${bindingName}`, binding);\n return null;\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 Bindings,\n ComputePipeline,\n ComputeShaderLayout,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n DeviceTextureFormatCapabilities,\n VertexFormat,\n CanvasContextProps,\n PresentationContextProps,\n PresentationContext,\n BufferProps,\n SamplerProps,\n ShaderProps,\n TextureProps,\n Texture,\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 RenderPipeline,\n ShaderLayout\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 {WebGPUPresentationContext} from './webgpu-presentation-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';\nimport {generateMipmapsWebGPU} from './helpers/generate-mipmaps-webgpu';\nimport {getBindGroup} from './helpers/get-bind-group';\nimport {\n getCpuHotspotProfiler as getWebGPUCpuHotspotProfiler,\n getCpuHotspotSubmitReason as getWebGPUCpuHotspotSubmitReason,\n getTimestamp\n} from './helpers/cpu-hotspot-profiler';\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 private _defaultSampler: WebGPUSampler | null = null;\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.commandEncoder?.destroy();\n this._defaultSampler?.destroy();\n this._defaultSampler = null;\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 getDefaultSampler(): WebGPUSampler {\n this._defaultSampler ||= new WebGPUSampler(this, {\n id: `${this.id}-default-sampler`\n });\n return this._defaultSampler;\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 createPresentationContext(props?: PresentationContextProps): PresentationContext {\n return new WebGPUPresentationContext(this, props);\n }\n\n createPipelineLayout(props: PipelineLayoutProps): WebGPUPipelineLayout {\n return new WebGPUPipelineLayout(this, props);\n }\n\n override generateMipmapsWebGPU(texture: Texture): void {\n generateMipmapsWebGPU(this, texture);\n }\n\n override _createBindGroupLayoutWebGPU(\n pipeline: RenderPipeline | ComputePipeline,\n group: number\n ): GPUBindGroupLayout {\n return (pipeline as WebGPURenderPipeline | WebGPUComputePipeline).handle.getBindGroupLayout(\n group\n );\n }\n\n override _createBindGroupWebGPU(\n bindGroupLayout: unknown,\n shaderLayout: ShaderLayout | ComputeShaderLayout,\n bindings: Bindings,\n group: number\n ): GPUBindGroup | null {\n if (Object.keys(bindings).length === 0) {\n return this.handle.createBindGroup({\n layout: bindGroupLayout as GPUBindGroupLayout,\n entries: []\n });\n }\n\n return getBindGroup(this, bindGroupLayout as GPUBindGroupLayout, shaderLayout, bindings, group);\n }\n\n submit(commandBuffer?: WebGPUCommandBuffer): void {\n let submittedCommandEncoder: WebGPUCommandEncoder | null = null;\n if (!commandBuffer) {\n ({submittedCommandEncoder, commandBuffer} = this._finalizeDefaultCommandEncoderForSubmit());\n }\n\n const profiler = getWebGPUCpuHotspotProfiler(this);\n const startTime = profiler ? getTimestamp() : 0;\n const submitReason = getWebGPUCpuHotspotSubmitReason(this);\n try {\n this.pushErrorScope('validation');\n const queueSubmitStartTime = profiler ? getTimestamp() : 0;\n this.handle.queue.submit([commandBuffer.handle]);\n if (profiler) {\n profiler.queueSubmitCount = (profiler.queueSubmitCount || 0) + 1;\n profiler.queueSubmitTimeMs =\n (profiler.queueSubmitTimeMs || 0) + (getTimestamp() - queueSubmitStartTime);\n }\n this.popErrorScope((error: GPUError) => {\n this.reportError(new Error(`${this} command submission: ${error.message}`), this)();\n this.debug();\n });\n\n if (submittedCommandEncoder) {\n const submitResolveKickoffStartTime = profiler ? getTimestamp() : 0;\n scheduleMicrotask(() => {\n submittedCommandEncoder\n .resolveTimeProfilingQuerySet()\n .then(() => {\n this.commandEncoder._gpuTimeMs = submittedCommandEncoder._gpuTimeMs;\n })\n .catch(() => {});\n });\n if (profiler) {\n profiler.submitResolveKickoffCount = (profiler.submitResolveKickoffCount || 0) + 1;\n profiler.submitResolveKickoffTimeMs =\n (profiler.submitResolveKickoffTimeMs || 0) +\n (getTimestamp() - submitResolveKickoffStartTime);\n }\n }\n } finally {\n if (profiler) {\n profiler.submitCount = (profiler.submitCount || 0) + 1;\n profiler.submitTimeMs = (profiler.submitTimeMs || 0) + (getTimestamp() - startTime);\n const reasonCountKey =\n submitReason === 'query-readback' ? 'queryReadbackSubmitCount' : 'defaultSubmitCount';\n const reasonTimeKey =\n submitReason === 'query-readback' ? 'queryReadbackSubmitTimeMs' : 'defaultSubmitTimeMs';\n profiler[reasonCountKey] = (profiler[reasonCountKey] || 0) + 1;\n profiler[reasonTimeKey] = (profiler[reasonTimeKey] || 0) + (getTimestamp() - startTime);\n }\n const commandBufferDestroyStartTime = profiler ? getTimestamp() : 0;\n commandBuffer.destroy();\n if (profiler) {\n profiler.commandBufferDestroyCount = (profiler.commandBufferDestroyCount || 0) + 1;\n profiler.commandBufferDestroyTimeMs =\n (profiler.commandBufferDestroyTimeMs || 0) +\n (getTimestamp() - commandBufferDestroyStartTime);\n }\n }\n }\n\n private _finalizeDefaultCommandEncoderForSubmit(): {\n submittedCommandEncoder: WebGPUCommandEncoder;\n commandBuffer: WebGPUCommandBuffer;\n } {\n const submittedCommandEncoder = this.commandEncoder;\n if (\n submittedCommandEncoder.getTimeProfilingSlotCount() > 0 &&\n submittedCommandEncoder.getTimeProfilingQuerySet() instanceof WebGPUQuerySet\n ) {\n const querySet = submittedCommandEncoder.getTimeProfilingQuerySet() as WebGPUQuerySet;\n querySet._encodeResolveToReadBuffer(submittedCommandEncoder, {\n firstQuery: 0,\n queryCount: submittedCommandEncoder.getTimeProfilingSlotCount()\n });\n }\n\n const commandBuffer = submittedCommandEncoder.finish();\n this.commandEncoder.destroy();\n this.commandEncoder = this.createCommandEncoder({\n id: submittedCommandEncoder.props.id,\n timeProfilingQuerySet: submittedCommandEncoder.getTimeProfilingQuerySet()\n });\n\n return {submittedCommandEncoder, commandBuffer};\n }\n\n // WebGPU specific\n\n pushErrorScope(scope: 'validation' | 'out-of-memory'): void {\n if (!this.props.debug) {\n return;\n }\n const profiler = getWebGPUCpuHotspotProfiler(this);\n const startTime = profiler ? getTimestamp() : 0;\n this.handle.pushErrorScope(scope);\n if (profiler) {\n profiler.errorScopePushCount = (profiler.errorScopePushCount || 0) + 1;\n profiler.errorScopeTimeMs = (profiler.errorScopeTimeMs || 0) + (getTimestamp() - startTime);\n }\n }\n\n popErrorScope(handler: (error: GPUError) => void): void {\n if (!this.props.debug) {\n return;\n }\n const profiler = getWebGPUCpuHotspotProfiler(this);\n const startTime = profiler ? getTimestamp() : 0;\n this.handle\n .popErrorScope()\n .then((error: GPUError | null) => {\n if (error) {\n handler(error);\n }\n })\n .catch((error: unknown) => {\n if (this.shouldIgnoreDroppedInstanceError(error, 'popErrorScope')) {\n return;\n }\n\n const errorMessage = error instanceof Error ? error.message : String(error);\n this.reportError(new Error(`${this} popErrorScope failed: ${errorMessage}`), this)();\n this.debug();\n });\n if (profiler) {\n profiler.errorScopePopCount = (profiler.errorScopePopCount || 0) + 1;\n profiler.errorScopeTimeMs = (profiler.errorScopeTimeMs || 0) + (getTimestamp() - startTime);\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 const fallback = Boolean(\n (this.adapterInfo as any).isFallbackAdapter ??\n (this.adapter as any).isFallbackAdapter ??\n false\n );\n const softwareRenderer = /SwiftShader/i.test(\n `${vendor} ${renderer} ${this.adapterInfo.architecture || ''}`\n );\n\n const gpu =\n vendor === 'apple' ? 'apple' : softwareRenderer || fallback ? 'software' : '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 =\n ((this.adapterInfo as any).type || '').split(' ')[0].toLowerCase() ||\n (softwareRenderer || fallback ? 'cpu' : 'unknown');\n\n return {\n type: 'webgpu',\n vendor,\n renderer,\n version,\n gpu,\n gpuType,\n gpuBackend,\n gpuArchitecture,\n fallback,\n shadingLanguage: 'wgsl',\n shadingLanguageVersion: 100\n };\n }\n\n shouldIgnoreDroppedInstanceError(error: unknown, operation?: string): boolean {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return (\n errorMessage.includes('Instance dropped') &&\n (!operation || errorMessage.includes(operation)) &&\n (this._isLost ||\n this.info.gpu === 'software' ||\n this.info.gpuType === 'cpu' ||\n Boolean(this.info.fallback))\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 '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\nfunction scheduleMicrotask(callback: () => void): void {\n if (globalThis.queueMicrotask) {\n globalThis.queueMicrotask(callback);\n return;\n }\n Promise.resolve()\n .then(callback)\n .catch(() => {});\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,aASa;AAbb;;;AAIA,kBAAoE;AAS9D,IAAO,eAAP,cAA4B,mBAAM;MAC7B;MACA;MACA;MACA;MAET,YAAY,QAAsB,OAAkB;A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,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;",
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\n/**\n * WebGPU implementation of Buffer\n * For byte alignment requirements see:\n * @see https://www.w3.org/TR/webgpu/#dom-gpubuffer-mapasync\n * @see https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/mapAsync\n */\nexport class WebGPUBuffer extends Buffer {\n readonly device: WebGPUDevice;\n readonly handle: GPUBuffer;\n readonly byteLength: number;\n readonly paddedByteLength: 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 this.paddedByteLength = Math.ceil(this.byteLength / 4) * 4;\n const mappedAtCreation = Boolean(this.props.onMapped || props.data);\n\n // WebGPU buffers must be aligned to 4 bytes\n const size = this.paddedByteLength;\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 if (!this.props.handle) {\n this.trackAllocatedMemory(size);\n } else {\n this.trackReferencedMemory(size, 'Buffer');\n }\n }\n\n override destroy(): void {\n if (!this.destroyed && this.handle) {\n this.removeStats();\n if (!this.props.handle) {\n this.trackDeallocatedMemory();\n this.handle.destroy();\n } else {\n this.trackDeallocatedReferencedMemory('Buffer');\n }\n this.destroyed = true;\n // @ts-expect-error readonly\n this.handle = null;\n }\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 const alignedByteLength = Math.ceil(byteLength / 4) * 4;\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.paddedByteLength)\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, alignedByteLength);\n const mappedRange = writeBuffer.handle.getMappedRange(byteOffset, alignedByteLength);\n const arrayBuffer = mappedRange.slice(0, byteLength);\n // eslint-disable-next-line @typescript-eslint/await-thenable\n await callback(arrayBuffer, 'mapped');\n new Uint8Array(mappedRange).set(new Uint8Array(arrayBuffer), 0);\n writeBuffer.handle.unmap();\n if (mappableBuffer) {\n this._copyBuffer(mappableBuffer, byteOffset, alignedByteLength);\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 const requestedEnd = byteOffset + byteLength;\n if (requestedEnd > this.byteLength) {\n throw new Error('Mapping range exceeds buffer size');\n }\n\n let mappedByteOffset = byteOffset;\n let mappedByteLength = byteLength;\n let sliceByteOffset = 0;\n let lifetime: 'mapped' | 'copied' = 'mapped';\n\n // WebGPU mapAsync requires 8-byte offsets and 4-byte lengths.\n if (byteOffset % 8 !== 0 || byteLength % 4 !== 0) {\n mappedByteOffset = Math.floor(byteOffset / 8) * 8;\n const alignedEnd = Math.ceil(requestedEnd / 4) * 4;\n mappedByteLength = alignedEnd - mappedByteOffset;\n sliceByteOffset = byteOffset - mappedByteOffset;\n lifetime = 'copied';\n }\n\n if (mappedByteOffset + mappedByteLength > this.paddedByteLength) {\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.paddedByteLength)\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, mappedByteOffset, mappedByteLength);\n }\n await readBuffer.handle.mapAsync(GPUMapMode.READ, mappedByteOffset, mappedByteLength);\n const arrayBuffer = readBuffer.handle.getMappedRange(mappedByteOffset, mappedByteLength);\n const mappedRange =\n lifetime === 'mapped'\n ? arrayBuffer\n : arrayBuffer.slice(sliceByteOffset, sliceByteOffset + byteLength);\n // eslint-disable-next-line @typescript-eslint/await-thenable\n const result = await callback(mappedRange, lifetime);\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 if (this.destroyed) {\n return;\n }\n\n this.destroyResource();\n // GPUSampler does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n}\n", "/**\n * Internal WebGPU CPU hotspot profiler helpers.\n *\n * Keep the profiler key and accessors localized here so the adapter-level\n * instrumentation can be reduced or removed without touching every call site.\n */\nexport const CPU_HOTSPOT_PROFILER_MODULE = 'cpu-hotspot-profiler';\nexport const CPU_HOTSPOT_SUBMIT_REASON = 'cpu-hotspot-submit-reason';\n\nexport type CpuHotspotProfiler = {\n enabled?: boolean;\n framebufferAcquireCount?: number;\n framebufferAcquireTimeMs?: number;\n currentTextureAcquireCount?: number;\n currentTextureAcquireTimeMs?: number;\n activeDefaultFramebufferAcquireDepth?: number;\n defaultFramebufferRenderPassCount?: number;\n explicitFramebufferRenderPassCount?: number;\n renderPassSetupCount?: number;\n renderPassSetupTimeMs?: number;\n renderPassDescriptorAssemblyCount?: number;\n renderPassDescriptorAssemblyTimeMs?: number;\n renderPassBeginCount?: number;\n renderPassBeginTimeMs?: number;\n submitCount?: number;\n submitTimeMs?: number;\n queueSubmitCount?: number;\n queueSubmitTimeMs?: number;\n submitResolveKickoffCount?: number;\n submitResolveKickoffTimeMs?: number;\n commandBufferDestroyCount?: number;\n commandBufferDestroyTimeMs?: number;\n defaultSubmitCount?: number;\n defaultSubmitTimeMs?: number;\n queryReadbackSubmitCount?: number;\n queryReadbackSubmitTimeMs?: number;\n errorScopePushCount?: number;\n errorScopePopCount?: number;\n errorScopeTimeMs?: number;\n textureViewReinitializeCount?: number;\n textureViewReinitializeTimeMs?: number;\n};\n\ntype UserDataOwner = {\n userData: Record<string, unknown>;\n};\n\n/** Returns the enabled profiler payload attached to a WebGPU userData owner. */\nexport function getCpuHotspotProfiler(owner: UserDataOwner): CpuHotspotProfiler | null {\n const profiler = owner.userData[CPU_HOTSPOT_PROFILER_MODULE] as CpuHotspotProfiler | undefined;\n return profiler?.enabled ? profiler : null;\n}\n\n/** Returns the optional submit reason tag used to split submit timing buckets. */\nexport function getCpuHotspotSubmitReason(owner: UserDataOwner): string | null {\n return (owner.userData[CPU_HOTSPOT_SUBMIT_REASON] as string | undefined) || null;\n}\n\n/** Updates the optional submit reason tag used by the profiler. */\nexport function setCpuHotspotSubmitReason(\n owner: UserDataOwner,\n submitReason: string | undefined\n): void {\n owner.userData[CPU_HOTSPOT_SUBMIT_REASON] = submitReason;\n}\n\n/** Shared timestamp helper for low-overhead CPU-side instrumentation. */\nexport function getTimestamp(): number {\n return globalThis.performance?.now?.() ?? Date.now();\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';\nimport {getCpuHotspotProfiler, getTimestamp} from '../helpers/cpu-hotspot-profiler';\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 = 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 if (this.destroyed) {\n return;\n }\n\n this.destroyResource();\n // GPUTextureView does not have a destroy method\n // this.handle.destroy();\n // @ts-expect-error readonly\n this.handle = null;\n }\n\n /**\n * Internal-only hook for the cached CanvasContext/PresentationContext swapchain path.\n * Rebuilds the default view when the per-frame canvas texture handle changes, without\n * replacing the long-lived luma.gl wrapper object.\n */\n _reinitialize(texture: WebGPUTexture): void {\n // @ts-expect-error readonly\n this.texture = texture;\n\n const profiler = getCpuHotspotProfiler(this.device);\n this.device.pushErrorScope('validation');\n const createViewStartTime = profiler ? getTimestamp() : 0;\n const handle = 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 if (profiler) {\n profiler.textureViewReinitializeCount = (profiler.textureViewReinitializeCount || 0) + 1;\n profiler.textureViewReinitializeTimeMs =\n (profiler.textureViewReinitializeTimeMs || 0) + (getTimestamp() - createViewStartTime);\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 handle.label = this.props.id;\n // @ts-expect-error readonly\n this.handle = handle;\n }\n}\n", "// luma.gl, MIT license\nimport {\n type TextureProps,\n type TextureViewProps,\n type CopyExternalImageOptions,\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';\nimport {WebGPUBuffer} from './webgpu-buffer';\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 private _allocatedByteLength: number = 0;\n\n constructor(device: WebGPUDevice, props: TextureProps) {\n // WebGPU buffer copies use 256-byte row alignment. queue.writeTexture() can use tightly packed rows.\n super(device, props, {byteAlignment: 256});\n this.device = device;\n\n if (props.sampler instanceof WebGPUSampler) {\n this.sampler = props.sampler;\n } else if (props.sampler === undefined) {\n this.sampler = this.device.getDefaultSampler();\n } else {\n this.sampler = new WebGPUSampler(this.device, (props.sampler as SamplerProps) || {});\n this.attachResource(this.sampler);\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 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.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 this.attachResource(this.view);\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 this._allocatedByteLength = this.getAllocatedByteLength();\n\n if (!this.props.handle) {\n this.trackAllocatedMemory(this._allocatedByteLength, 'Texture');\n } else {\n this.trackReferencedMemory(this._allocatedByteLength, 'Texture');\n }\n }\n\n override destroy(): void {\n if (this.destroyed) {\n return;\n }\n\n if (!this.props.handle && this.handle) {\n this.trackDeallocatedMemory('Texture');\n this.handle.destroy();\n } else if (this.handle) {\n this.trackDeallocatedReferencedMemory('Texture');\n }\n\n this.destroyResource();\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 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(\n options: TextureReadOptions & {byteOffset?: number} = {},\n buffer?: Buffer\n ): Buffer {\n if (!buffer) {\n throw new Error(`${this} readBuffer requires a destination buffer`);\n }\n const {x, y, z, width, height, depthOrArrayLayers, mipLevel, aspect} =\n this._getSupportedColorReadOptions(options);\n const byteOffset = options.byteOffset ?? 0;\n\n const layout = this.computeMemoryLayout({width, height, depthOrArrayLayers, mipLevel});\n\n const {byteLength} = layout;\n\n if (buffer.byteLength < byteOffset + byteLength) {\n throw new Error(\n `${this} readBuffer target is too small (${buffer.byteLength} < ${byteOffset + byteLength})`\n );\n }\n\n const gpuDevice = this.device.handle;\n this.device.pushErrorScope('validation');\n const commandEncoder = gpuDevice.createCommandEncoder();\n this.copyToBuffer(\n commandEncoder,\n {x, y, z, width, height, depthOrArrayLayers, mipLevel, aspect, byteOffset},\n buffer\n );\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} readBuffer: ${error.message}`), this)();\n this.device.debug();\n });\n\n return buffer;\n }\n\n override async readDataAsync(options: TextureReadOptions = {}): Promise<ArrayBuffer> {\n throw new Error(\n `${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`\n );\n }\n\n copyToBuffer(\n commandEncoder: GPUCommandEncoder,\n options: TextureReadOptions & {\n byteOffset?: number;\n bytesPerRow?: number;\n rowsPerImage?: number;\n } = {},\n buffer: Buffer\n ): void {\n const {\n byteOffset = 0,\n bytesPerRow: requestedBytesPerRow,\n rowsPerImage: requestedRowsPerImage,\n ...textureReadOptions\n } = options;\n const {x, y, z, width, height, depthOrArrayLayers, mipLevel, aspect} =\n this._getSupportedColorReadOptions(textureReadOptions);\n const layout = this.computeMemoryLayout({width, height, depthOrArrayLayers, mipLevel});\n const effectiveBytesPerRow = requestedBytesPerRow ?? layout.bytesPerRow;\n const effectiveRowsPerImage = requestedRowsPerImage ?? layout.rowsPerImage;\n const webgpuBuffer = buffer as WebGPUBuffer;\n\n commandEncoder.copyTextureToBuffer(\n {\n texture: this.handle,\n origin: {x, y, z},\n mipLevel,\n aspect\n },\n {\n buffer: webgpuBuffer.handle,\n offset: byteOffset,\n bytesPerRow: effectiveBytesPerRow,\n rowsPerImage: effectiveRowsPerImage\n },\n {\n width,\n height,\n depthOrArrayLayers\n }\n );\n }\n\n override writeBuffer(buffer: Buffer, options_: TextureWriteOptions = {}) {\n const options = this._normalizeTextureWriteOptions(options_);\n const {\n x,\n y,\n z,\n width,\n height,\n depthOrArrayLayers,\n mipLevel,\n aspect,\n byteOffset,\n bytesPerRow,\n rowsPerImage\n } = options;\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: byteOffset,\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(\n data: ArrayBuffer | SharedArrayBuffer | ArrayBufferView,\n options_: TextureWriteOptions = {}\n ): void {\n const device = this.device;\n const options = this._normalizeTextureWriteOptions(options_);\n const {x, y, z, width, height, depthOrArrayLayers, mipLevel, aspect, byteOffset} = options;\n const source = data as GPUAllowSharedBufferSource;\n const formatInfo = this.device.getTextureFormatInfo(this.format);\n // queue.writeTexture() defaults to tightly packed rows, unlike WebGPU buffer copy paths.\n const packedSourceLayout = textureFormatDecoder.computeMemoryLayout({\n format: this.format,\n width,\n height,\n depth: depthOrArrayLayers,\n byteAlignment: 1\n });\n const bytesPerRow = options_.bytesPerRow ?? packedSourceLayout.bytesPerRow;\n const rowsPerImage = options_.rowsPerImage ?? packedSourceLayout.rowsPerImage;\n let copyWidth = width;\n let copyHeight = height;\n\n if (formatInfo.compressed) {\n const blockWidth = formatInfo.blockWidth || 1;\n const blockHeight = formatInfo.blockHeight || 1;\n copyWidth = Math.ceil(width / blockWidth) * blockWidth;\n copyHeight = Math.ceil(height / blockHeight) * blockHeight;\n }\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 source,\n {\n offset: byteOffset,\n bytesPerRow,\n rowsPerImage\n },\n {width: copyWidth, height: copyHeight, 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 /**\n * Internal-only hook for the cached CanvasContext/PresentationContext swapchain path.\n * Rebinds this handle-backed texture wrapper to the current per-frame canvas texture\n * without allocating a new luma.gl Texture or TextureView wrapper.\n */\n _reinitialize(handle: GPUTexture, props?: Partial<TextureProps>): void {\n const nextWidth = props?.width ?? handle.width ?? this.width;\n const nextHeight = props?.height ?? handle.height ?? this.height;\n const nextDepth = props?.depth ?? this.depth;\n const nextFormat = props?.format ?? this.format;\n const allocationMayHaveChanged =\n nextWidth !== this.width ||\n nextHeight !== this.height ||\n nextDepth !== this.depth ||\n nextFormat !== this.format;\n handle.label ||= this.id;\n\n // @ts-expect-error readonly\n this.handle = handle;\n // @ts-expect-error readonly\n this.width = nextWidth;\n // @ts-expect-error readonly\n this.height = nextHeight;\n\n if (props?.depth !== undefined) {\n // @ts-expect-error readonly\n this.depth = nextDepth;\n }\n if (props?.format !== undefined) {\n // @ts-expect-error readonly\n this.format = nextFormat;\n }\n\n this.props.handle = handle;\n if (props?.width !== undefined) {\n this.props.width = props.width;\n }\n if (props?.height !== undefined) {\n this.props.height = props.height;\n }\n if (props?.depth !== undefined) {\n this.props.depth = props.depth;\n }\n if (props?.format !== undefined) {\n this.props.format = props.format;\n }\n\n if (allocationMayHaveChanged) {\n const nextAllocation = this.getAllocatedByteLength();\n if (nextAllocation !== this._allocatedByteLength) {\n this._allocatedByteLength = nextAllocation;\n this.trackReferencedMemory(nextAllocation, 'Texture');\n }\n }\n this.view._reinitialize(this);\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 // `_checkCompilationError()` runs asynchronously after construction, so the shader can be\n // destroyed before we await compilation info. Snapshot the handle and treat a destroyed shader\n // as having no compiler messages instead of dereferencing `null`.\n const handle = this.handle;\n if (!handle) {\n return [];\n }\n let compilationInfo;\n try {\n compilationInfo = await handle.getCompilationInfo();\n } catch (error) {\n if (this.device.shouldIgnoreDroppedInstanceError(error, 'getCompilationInfo')) {\n return [];\n }\n throw error;\n }\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 clearDepth: notSupported,\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 {ShaderLayout, BufferLayout, AttributeDeclaration, VertexFormat} from '@luma.gl/core';\nimport {log, vertexFormatDecoder} 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 options?: {pipelineId?: string}\n): GPUVertexBufferLayout[] {\n const vertexBufferLayouts: GPUVertexBufferLayout[] = [];\n const usedAttributes = new Set<string>();\n const shaderAttributes = shaderLayout.attributes || [];\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(\n shaderLayout,\n attributeName,\n usedAttributes,\n options\n );\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 += vertexFormatDecoder.getVertexFormatInfo(format).byteLength;\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n const attributeLayout = findAttributeLayout(\n shaderLayout,\n mapping.name,\n usedAttributes,\n options\n );\n if (!attributeLayout) {\n continue; // eslint-disable-line no-continue\n }\n byteStride = vertexFormatDecoder.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 shaderAttributes) {\n if (!usedAttributes.has(attribute.name)) {\n vertexBufferLayouts.push({\n arrayStride: vertexFormatDecoder.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 const shaderAttributes = shaderLayout.attributes || [];\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 shaderAttributes) {\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 options?: {pipelineId?: string}\n): AttributeDeclaration | null {\n const attribute = shaderLayout.attributes?.find(attribute_ => attribute_.name === name);\n if (!attribute) {\n const pipelineContext = options?.pipelineId\n ? `RenderPipeline(${options.pipelineId})`\n : 'RenderPipeline';\n log.warn(\n `${pipelineContext}: Ignoring \"${name}\" attribute, since it is not present in shader layout.`\n )();\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 {Bindings, BindingsByGroup, RenderPass, VertexArray} from '@luma.gl/core';\nimport {\n RenderPipeline,\n RenderPipelineProps,\n _getDefaultBindGroupFactory,\n log,\n normalizeBindingsByGroup\n} from '@luma.gl/core';\nimport {applyParametersToRenderPipelineDescriptor} from '../helpers/webgpu-parameters';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport {getVertexBufferLayout} from '../helpers/get-vertex-buffer-layout';\n// import {convertAttributesVertexBufferToLayout} from '../helpers/get-vertex-buffer-layout';\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 readonly descriptor: GPURenderPipelineDescriptor | null;\n\n readonly vs: WebGPUShader;\n readonly fs: WebGPUShader | null = null;\n\n /** Compatibility path for direct pipeline.setBindings() usage */\n private _bindingsByGroup: BindingsByGroup;\n private _bindGroupCacheKeysByGroup: Partial<Record<number, object>> = {};\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.shaderLayout ||= this.device.getShaderLayout((props.vs as WebGPUShader).source) || {\n attributes: [],\n bindings: []\n };\n this.handle = this.props.handle as GPURenderPipeline;\n let descriptor: GPURenderPipelineDescriptor | null = null;\n if (!this.handle) {\n 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.linkStatus = 'error';\n this.device.reportError(new Error(`${this} creation failed:\\n\"${error.message}\"`), this)();\n this.device.debug();\n });\n }\n this.descriptor = descriptor;\n this.handle.label = this.props.id;\n this.linkStatus = 'success';\n\n // Note: Often the same shader in WebGPU\n this.vs = props.vs as WebGPUShader;\n this.fs = props.fs as WebGPUShader;\n this._bindingsByGroup =\n props.bindGroups || normalizeBindingsByGroup(this.shaderLayout, props.bindings);\n this._bindGroupCacheKeysByGroup = createBindGroupCacheKeys(this._bindingsByGroup);\n }\n\n override destroy(): void {\n // WebGPURenderPipeline has no destroy method.\n // @ts-expect-error\n this.handle = null;\n }\n\n /**\n * Compatibility shim for code paths that still set bindings on the pipeline.\n * The shared-model path passes bindings per draw and does not rely on this state.\n */\n setBindings(bindings: Bindings | BindingsByGroup): void {\n const nextBindingsByGroup = normalizeBindingsByGroup(this.shaderLayout, bindings);\n for (const [groupKey, groupBindings] of Object.entries(nextBindingsByGroup)) {\n const group = Number(groupKey);\n for (const [name, binding] of Object.entries(groupBindings || {})) {\n const currentGroupBindings = this._bindingsByGroup[group] || {};\n if (currentGroupBindings[name] !== binding) {\n if (\n !this._bindingsByGroup[group] ||\n this._bindingsByGroup[group] === currentGroupBindings\n ) {\n this._bindingsByGroup[group] = {...currentGroupBindings};\n }\n this._bindingsByGroup[group][name] = binding;\n this._bindGroupCacheKeysByGroup[group] = {};\n }\n }\n }\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 bindings?: Bindings;\n bindGroups?: BindingsByGroup;\n _bindGroupCacheKeys?: Partial<Record<number, object>>;\n uniforms?: Record<string, unknown>;\n }): boolean {\n if (this.isErrored) {\n log.info(2, `RenderPipeline:${this.id}.draw() aborted - pipeline initialization failed`)();\n return false;\n }\n\n const webgpuRenderPass = options.renderPass as WebGPURenderPass;\n const instanceCount =\n options.instanceCount && options.instanceCount > 0 ? options.instanceCount : 1;\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 hasExplicitBindings = Boolean(options.bindGroups || options.bindings);\n const bindGroups = _getDefaultBindGroupFactory(this.device).getBindGroups(\n this,\n hasExplicitBindings ? options.bindGroups || options.bindings : this._bindingsByGroup,\n hasExplicitBindings ? options._bindGroupCacheKeys : this._bindGroupCacheKeysByGroup\n );\n for (const [group, bindGroup] of Object.entries(bindGroups)) {\n if (bindGroup) {\n webgpuRenderPass.handle.setBindGroup(Number(group), bindGroup as GPUBindGroup);\n }\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 instanceCount,\n options.firstIndex || 0,\n options.baseVertex || 0,\n options.firstInstance || 0\n );\n } else {\n webgpuRenderPass.handle.draw(\n options.vertexCount || 0,\n instanceCount,\n options.firstVertex || 0,\n options.firstInstance || 0\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 _getBindingsByGroupWebGPU(): BindingsByGroup {\n return this._bindingsByGroup;\n }\n\n _getBindGroupCacheKeysWebGPU(): Partial<Record<number, object>> {\n return this._bindGroupCacheKeysByGroup;\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 pipelineId: this.id\n })\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\nfunction createBindGroupCacheKeys(\n bindingsByGroup: BindingsByGroup\n): Partial<Record<number, object>> {\n const bindGroupCacheKeys: Partial<Record<number, object>> = {};\n for (const [groupKey, groupBindings] of Object.entries(bindingsByGroup)) {\n if (groupBindings && Object.keys(groupBindings).length > 0) {\n bindGroupCacheKeys[Number(groupKey)] = {};\n }\n }\n return bindGroupCacheKeys;\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 /**\n * Internal-only hook for the cached CanvasContext/PresentationContext swapchain path.\n * Rebinds the long-lived default framebuffer wrapper to the current per-frame color view\n * and optional depth attachment without allocating a new luma.gl Framebuffer object.\n */\n _reinitialize(\n colorAttachment: WebGPUTextureView,\n depthStencilAttachment: WebGPUTextureView | null\n ): void {\n this.colorAttachments[0] = colorAttachment;\n // @ts-expect-error Internal-only canvas wrapper reuse mutates this otherwise-readonly attachment.\n this.depthStencilAttachment = depthStencilAttachment;\n this.width = colorAttachment.texture.width;\n this.height = colorAttachment.texture.height;\n\n this.props.width = this.width;\n this.props.height = this.height;\n this.props.colorAttachments = [colorAttachment.texture];\n this.props.depthStencilAttachment = depthStencilAttachment?.texture || null;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {\n ComputePipeline,\n ComputePipelineProps,\n Bindings,\n BindingsByGroup,\n _getDefaultBindGroupFactory,\n normalizeBindingsByGroup\n} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUShader} from './webgpu-shader';\n\nconst EMPTY_BIND_GROUPS: BindingsByGroup = {};\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 private _bindingsByGroup: BindingsByGroup;\n private _bindGroupCacheKeysByGroup: Partial<Record<number, object>>;\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 this._bindingsByGroup = EMPTY_BIND_GROUPS;\n this._bindGroupCacheKeysByGroup = {};\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: Bindings | BindingsByGroup): void {\n const nextBindingsByGroup = normalizeBindingsByGroup(this.shaderLayout, bindings);\n for (const [groupKey, groupBindings] of Object.entries(nextBindingsByGroup)) {\n const group = Number(groupKey);\n for (const [name, binding] of Object.entries(groupBindings || {})) {\n const currentGroupBindings = this._bindingsByGroup[group] || {};\n if (currentGroupBindings[name] !== binding) {\n if (\n !this._bindingsByGroup[group] ||\n this._bindingsByGroup[group] === currentGroupBindings\n ) {\n this._bindingsByGroup[group] = {...currentGroupBindings};\n }\n this._bindingsByGroup[group][name] = binding;\n this._bindGroupCacheKeysByGroup[group] = {};\n }\n }\n }\n }\n\n _getBindGroups(\n bindings?: Bindings | BindingsByGroup,\n bindGroupCacheKeys?: Partial<Record<number, object>>\n ): Partial<Record<number, unknown>> {\n const hasExplicitBindings = Boolean(bindings);\n return _getDefaultBindGroupFactory(this.device).getBindGroups(\n this,\n hasExplicitBindings ? bindings : this._bindingsByGroup,\n hasExplicitBindings ? bindGroupCacheKeys : this._bindGroupCacheKeysByGroup\n );\n }\n\n _getBindingsByGroupWebGPU(): BindingsByGroup {\n return this._bindingsByGroup;\n }\n\n _getBindGroupCacheKeysWebGPU(): Partial<Record<number, object>> {\n return this._bindGroupCacheKeysByGroup;\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 'VertexArray';\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// biome-ignore format: preserve layout\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';\nimport {getCpuHotspotProfiler, getTimestamp} from './helpers/cpu-hotspot-profiler';\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 colorAttachment: WebGPUTexture | null = null;\n private depthStencilAttachment: WebGPUTexture | null = null;\n private framebuffer: WebGPUFramebuffer | 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 this._startObservers();\n }\n\n /** Destroy any textures produced while configured and remove the context configuration. */\n override destroy(): void {\n if (this.framebuffer) {\n this.framebuffer.destroy();\n this.framebuffer = null;\n }\n if (this.colorAttachment) {\n this.colorAttachment.destroy();\n this.colorAttachment = null;\n }\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\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 this._createDepthStencilAttachment(this.device.preferredDepthFormat);\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 const profiler = getCpuHotspotProfiler(this.device);\n const startTime = profiler ? getTimestamp() : 0;\n if (profiler) {\n profiler.framebufferAcquireCount = (profiler.framebufferAcquireCount || 0) + 1;\n profiler.activeDefaultFramebufferAcquireDepth =\n (profiler.activeDefaultFramebufferAcquireDepth || 0) + 1;\n }\n\n try {\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 this.framebuffer ||= new WebGPUFramebuffer(this.device, {\n id: `${this.id}#framebuffer`,\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: null\n });\n this.framebuffer._reinitialize(\n currentColorAttachment.view,\n options?.depthStencilFormat ? this.depthStencilAttachment?.view || null : null\n );\n return this.framebuffer;\n } finally {\n if (profiler) {\n profiler.activeDefaultFramebufferAcquireDepth =\n (profiler.activeDefaultFramebufferAcquireDepth || 1) - 1;\n profiler.framebufferAcquireTimeMs =\n (profiler.framebufferAcquireTimeMs || 0) + (getTimestamp() - startTime);\n }\n }\n }\n\n // PRIMARY METHODS\n\n /** Wrap the current canvas context texture in a luma.gl texture */\n _getCurrentTexture(): WebGPUTexture {\n const profiler = getCpuHotspotProfiler(this.device);\n const currentTextureStartTime = profiler ? getTimestamp() : 0;\n const handle = this.handle.getCurrentTexture();\n if (profiler) {\n profiler.currentTextureAcquireCount = (profiler.currentTextureAcquireCount || 0) + 1;\n profiler.currentTextureAcquireTimeMs =\n (profiler.currentTextureAcquireTimeMs || 0) + (getTimestamp() - currentTextureStartTime);\n }\n if (!this.colorAttachment) {\n this.colorAttachment = 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 return this.colorAttachment;\n }\n\n this.colorAttachment._reinitialize(handle, {\n handle,\n format: this.device.preferredColorFormat,\n width: handle.width,\n height: handle.height\n });\n return this.colorAttachment;\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 const needsNewDepthStencilAttachment =\n !this.depthStencilAttachment ||\n this.depthStencilAttachment.width !== this.drawingBufferWidth ||\n this.depthStencilAttachment.height !== this.drawingBufferHeight ||\n this.depthStencilAttachment.format !== depthStencilFormat;\n if (needsNewDepthStencilAttachment) {\n this.depthStencilAttachment?.destroy();\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\n// biome-ignore format: preserve layout\n// / <reference types=\"@webgpu/types\" />\n\nimport type {PresentationContextProps, TextureFormatDepthStencil} from '@luma.gl/core';\nimport {PresentationContext, Texture, log} from '@luma.gl/core';\nimport type {WebGPUDevice} from './webgpu-device';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\nimport {WebGPUTexture} from './resources/webgpu-texture';\nimport {getCpuHotspotProfiler, getTimestamp} from './helpers/cpu-hotspot-profiler';\n\n/**\n * A WebGPU PresentationContext renders directly into its destination canvas.\n */\nexport class WebGPUPresentationContext extends PresentationContext {\n readonly device: WebGPUDevice;\n readonly handle: GPUCanvasContext;\n\n private colorAttachment: WebGPUTexture | null = null;\n private depthStencilAttachment: WebGPUTexture | null = null;\n private framebuffer: WebGPUFramebuffer | null = null;\n\n get [Symbol.toStringTag](): string {\n return 'WebGPUPresentationContext';\n }\n\n constructor(device: WebGPUDevice, props: PresentationContextProps = {}) {\n super(props);\n const contextLabel = `${this[Symbol.toStringTag]}(${this.id})`;\n\n const context = this.canvas.getContext('webgpu');\n if (!context) {\n throw new Error(`${contextLabel}: Failed to create WebGPU presentation context`);\n }\n this.device = device;\n this.handle = context;\n\n this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`);\n this._configureDevice();\n this._startObservers();\n }\n\n override destroy(): void {\n if (this.framebuffer) {\n this.framebuffer.destroy();\n this.framebuffer = null;\n }\n if (this.colorAttachment) {\n this.colorAttachment.destroy();\n this.colorAttachment = null;\n }\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n this.handle.unconfigure();\n super.destroy();\n }\n\n present(): void {\n this.device.submit();\n }\n\n protected override _configureDevice(): void {\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n\n this.handle.configure({\n device: this.device.handle,\n format: this.device.preferredColorFormat,\n colorSpace: this.props.colorSpace,\n alphaMode: this.props.alphaMode\n });\n\n this._createDepthStencilAttachment(this.device.preferredDepthFormat);\n }\n\n protected override _getCurrentFramebuffer(\n options: {depthStencilFormat?: TextureFormatDepthStencil | false} = {\n depthStencilFormat: 'depth24plus'\n }\n ): WebGPUFramebuffer {\n const profiler = getCpuHotspotProfiler(this.device);\n const startTime = profiler ? getTimestamp() : 0;\n if (profiler) {\n profiler.framebufferAcquireCount = (profiler.framebufferAcquireCount || 0) + 1;\n }\n\n try {\n const currentColorAttachment = this._getCurrentTexture();\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[Symbol.toStringTag]}(${this.id}): Resized to compensate for initial canvas size mismatch ${oldWidth}x${oldHeight} => ${this.drawingBufferWidth}x${this.drawingBufferHeight}px`\n )();\n }\n\n if (options?.depthStencilFormat) {\n this._createDepthStencilAttachment(options.depthStencilFormat);\n }\n\n this.framebuffer ||= new WebGPUFramebuffer(this.device, {\n id: `${this.id}#framebuffer`,\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: null\n });\n this.framebuffer._reinitialize(\n currentColorAttachment.view,\n options?.depthStencilFormat ? this.depthStencilAttachment?.view || null : null\n );\n return this.framebuffer;\n } finally {\n if (profiler) {\n profiler.framebufferAcquireTimeMs =\n (profiler.framebufferAcquireTimeMs || 0) + (getTimestamp() - startTime);\n }\n }\n }\n\n private _getCurrentTexture(): WebGPUTexture {\n const profiler = getCpuHotspotProfiler(this.device);\n const currentTextureStartTime = profiler ? getTimestamp() : 0;\n const handle = this.handle.getCurrentTexture();\n if (profiler) {\n profiler.currentTextureAcquireCount = (profiler.currentTextureAcquireCount || 0) + 1;\n profiler.currentTextureAcquireTimeMs =\n (profiler.currentTextureAcquireTimeMs || 0) + (getTimestamp() - currentTextureStartTime);\n }\n if (!this.colorAttachment) {\n this.colorAttachment = 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 return this.colorAttachment;\n }\n\n this.colorAttachment._reinitialize(handle, {\n handle,\n format: this.device.preferredColorFormat,\n width: handle.width,\n height: handle.height\n });\n return this.colorAttachment;\n }\n\n private _createDepthStencilAttachment(\n depthStencilFormat: TextureFormatDepthStencil\n ): WebGPUTexture {\n const needsNewDepthStencilAttachment =\n !this.depthStencilAttachment ||\n this.depthStencilAttachment.width !== this.drawingBufferWidth ||\n this.depthStencilAttachment.height !== this.drawingBufferHeight ||\n this.depthStencilAttachment.format !== depthStencilFormat;\n if (needsNewDepthStencilAttachment) {\n this.depthStencilAttachment?.destroy();\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, props);\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, Bindings, BindingsByGroup} from '@luma.gl/core';\nimport {Buffer, RenderPass, RenderPipeline, _getDefaultBindGroupFactory, 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';\nimport {getCpuHotspotProfiler, getTimestamp} from '../helpers/cpu-hotspot-profiler';\n\nexport class WebGPURenderPass extends RenderPass {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPassEncoder;\n readonly framebuffer: WebGPUFramebuffer;\n\n /** Active pipeline */\n pipeline: WebGPURenderPipeline | null = null;\n\n /** Latest bindings applied to this pass */\n bindings: Bindings | BindingsByGroup = {};\n\n constructor(\n device: WebGPUDevice,\n props: RenderPassProps = {},\n commandEncoder: GPUCommandEncoder = device.commandEncoder.handle\n ) {\n super(device, props);\n this.device = device;\n const {props: renderPassProps} = this;\n this.framebuffer =\n (renderPassProps.framebuffer as WebGPUFramebuffer) ||\n device.getCanvasContext().getCurrentFramebuffer();\n\n const profiler = getCpuHotspotProfiler(this.device);\n if (profiler) {\n const counterName:\n | 'explicitFramebufferRenderPassCount'\n | 'defaultFramebufferRenderPassCount' = renderPassProps.framebuffer\n ? 'explicitFramebufferRenderPassCount'\n : 'defaultFramebufferRenderPassCount';\n profiler[counterName] = (profiler[counterName] || 0) + 1;\n }\n\n const startTime = profiler ? getTimestamp() : 0;\n try {\n const descriptorAssemblyStartTime = profiler ? getTimestamp() : 0;\n const renderPassDescriptor = this.getRenderPassDescriptor(this.framebuffer);\n\n if (renderPassProps.occlusionQuerySet) {\n renderPassDescriptor.occlusionQuerySet = (\n renderPassProps.occlusionQuerySet as WebGPUQuerySet\n ).handle;\n }\n\n if (renderPassProps.timestampQuerySet) {\n const webgpuTSQuerySet = renderPassProps.timestampQuerySet as WebGPUQuerySet;\n webgpuTSQuerySet?._invalidateResults();\n renderPassDescriptor.timestampWrites = webgpuTSQuerySet\n ? ({\n querySet: webgpuTSQuerySet.handle,\n beginningOfPassWriteIndex: renderPassProps.beginTimestampIndex,\n endOfPassWriteIndex: renderPassProps.endTimestampIndex\n } as GPURenderPassTimestampWrites)\n : undefined;\n }\n if (profiler) {\n profiler.renderPassDescriptorAssemblyCount =\n (profiler.renderPassDescriptorAssemblyCount || 0) + 1;\n profiler.renderPassDescriptorAssemblyTimeMs =\n (profiler.renderPassDescriptorAssemblyTimeMs || 0) +\n (getTimestamp() - descriptorAssemblyStartTime);\n }\n\n this.device.pushErrorScope('validation');\n const beginRenderPassStartTime = profiler ? getTimestamp() : 0;\n this.handle = this.props.handle || commandEncoder.beginRenderPass(renderPassDescriptor);\n if (profiler) {\n profiler.renderPassBeginCount = (profiler.renderPassBeginCount || 0) + 1;\n profiler.renderPassBeginTimeMs =\n (profiler.renderPassBeginTimeMs || 0) + (getTimestamp() - beginRenderPassStartTime);\n }\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 } finally {\n if (profiler) {\n profiler.renderPassSetupCount = (profiler.renderPassSetupCount || 0) + 1;\n profiler.renderPassSetupTimeMs =\n (profiler.renderPassSetupTimeMs || 0) + (getTimestamp() - startTime);\n }\n }\n }\n\n override destroy(): void {\n this.destroyResource();\n }\n\n end(): void {\n if (this.destroyed) {\n return;\n }\n this.handle.end();\n this.destroy();\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: Bindings | BindingsByGroup): void {\n this.bindings = bindings;\n const bindGroups =\n (this.pipeline &&\n _getDefaultBindGroupFactory(this.device).getBindGroups(this.pipeline, bindings)) ||\n {};\n for (const [group, bindGroup] of Object.entries(bindGroups)) {\n if (bindGroup) {\n this.handle.setBindGroup(Number(group), bindGroup as GPUBindGroup);\n }\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 {\n ComputePass,\n ComputePassProps,\n ComputePipeline,\n Buffer,\n Bindings,\n BindingsByGroup,\n _getDefaultBindGroupFactory\n} 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(\n device: WebGPUDevice,\n props: ComputePassProps = {},\n commandEncoder: GPUCommandEncoder = device.commandEncoder.handle\n ) {\n super(device, props);\n this.device = device;\n const {props: computePassProps} = this;\n\n // Set up queries\n let timestampWrites: GPUComputePassTimestampWrites | undefined;\n if (computePassProps.timestampQuerySet) {\n const webgpuQuerySet = computePassProps.timestampQuerySet as WebGPUQuerySet;\n if (webgpuQuerySet) {\n webgpuQuerySet._invalidateResults();\n timestampWrites = {\n querySet: webgpuQuerySet.handle,\n beginningOfPassWriteIndex: computePassProps.beginTimestampIndex,\n endOfPassWriteIndex: computePassProps.endTimestampIndex\n };\n }\n }\n\n this.handle =\n this.props.handle ||\n commandEncoder.beginComputePass({\n label: this.props.id,\n timestampWrites\n });\n }\n\n /** @note no WebGPU destroy method, just gc */\n override destroy(): void {\n this.destroyResource();\n }\n\n end(): void {\n if (this.destroyed) {\n return;\n }\n this.handle.end();\n this.destroy();\n }\n\n setPipeline(pipeline: ComputePipeline): void {\n const wgpuPipeline = pipeline as WebGPUComputePipeline;\n this.handle.setPipeline(wgpuPipeline.handle);\n this._webgpuPipeline = wgpuPipeline;\n const bindGroups = _getDefaultBindGroupFactory(this.device).getBindGroups(\n this._webgpuPipeline,\n this._webgpuPipeline._getBindingsByGroupWebGPU(),\n this._webgpuPipeline._getBindGroupCacheKeysWebGPU()\n );\n for (const [group, bindGroup] of Object.entries(bindGroups)) {\n if (bindGroup) {\n this.handle.setBindGroup(Number(group), bindGroup as GPUBindGroup);\n }\n }\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: Bindings | BindingsByGroup): void {\n const bindGroups =\n (this._webgpuPipeline &&\n _getDefaultBindGroupFactory(this.device).getBindGroups(this._webgpuPipeline, bindings)) ||\n {};\n for (const [group, bindGroup] of Object.entries(bindGroups)) {\n if (bindGroup) {\n this.handle.setBindGroup(Number(group), bindGroup as GPUBindGroup);\n }\n }\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 CommandBufferProps,\n RenderPassProps,\n ComputePassProps,\n CopyBufferToTextureOptions,\n CopyTextureToTextureOptions,\n CopyTextureToBufferOptions\n} from '@luma.gl/core';\nimport {CommandEncoder, CommandEncoderProps, Buffer} 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 this.destroyResource();\n }\n\n finish(props?: CommandBufferProps): 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 this.destroy();\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(\n this.device,\n this._applyTimeProfilingToPassProps(props),\n this.handle\n );\n }\n\n beginComputePass(props: ComputePassProps = {}): WebGPUComputePass {\n return new WebGPUComputePass(\n this.device,\n this._applyTimeProfilingToPassProps(props),\n this.handle\n );\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n\n copyBufferToBuffer(options: {\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): void {\n const webgpuSourceBuffer = options.sourceBuffer as WebGPUBuffer;\n const webgpuDestinationTexture = options.destinationTexture as WebGPUTexture;\n const copyOrigin = options.origin ?? [0, 0, 0];\n const copySize = options.size;\n this.handle.copyBufferToTexture(\n {\n buffer: webgpuSourceBuffer.handle,\n offset: options.byteOffset ?? 0,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage\n },\n {\n texture: webgpuDestinationTexture.handle,\n mipLevel: options.mipLevel ?? 0,\n origin: {\n x: copyOrigin[0] ?? 0,\n y: copyOrigin[1] ?? 0,\n z: copyOrigin[2] ?? 0\n },\n aspect: options.aspect\n },\n {\n width: copySize[0],\n height: copySize[1],\n depthOrArrayLayers: copySize[2]\n }\n );\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n const {\n sourceTexture,\n destinationBuffer,\n origin = [0, 0, 0],\n byteOffset = 0,\n width,\n height,\n depthOrArrayLayers,\n mipLevel,\n aspect\n } = options;\n const webgpuSourceTexture = sourceTexture as WebGPUTexture;\n webgpuSourceTexture.copyToBuffer(\n this.handle,\n {\n x: origin[0] ?? 0,\n y: origin[1] ?? 0,\n z: origin[2] ?? 0,\n width,\n height,\n depthOrArrayLayers,\n mipLevel,\n aspect,\n byteOffset,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage\n },\n destinationBuffer\n );\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n const webgpuSourceTexture = options.sourceTexture as WebGPUTexture;\n const webgpuDestinationTexture = options.destinationTexture as WebGPUTexture;\n const sourceRegion = webgpuSourceTexture._normalizeTextureReadOptions({\n x: options.origin?.[0] ?? 0,\n y: options.origin?.[1] ?? 0,\n z: options.origin?.[2] ?? 0,\n width: options.width,\n height: options.height,\n depthOrArrayLayers: options.depthOrArrayLayers,\n mipLevel: options.mipLevel ?? 0,\n aspect: options.aspect ?? 'all'\n });\n\n this.handle.copyTextureToTexture(\n {\n texture: webgpuSourceTexture.handle,\n mipLevel: sourceRegion.mipLevel,\n origin: {\n x: sourceRegion.x,\n y: sourceRegion.y,\n z: sourceRegion.z\n },\n aspect: sourceRegion.aspect\n },\n {\n texture: webgpuDestinationTexture.handle,\n mipLevel: options.destinationMipLevel ?? 0,\n origin: {\n x: options.destinationOrigin?.[0] ?? 0,\n y: options.destinationOrigin?.[1] ?? 0,\n z: options.destinationOrigin?.[2] ?? 0\n },\n aspect: options.destinationAspect ?? sourceRegion.aspect\n },\n {\n width: sourceRegion.width,\n height: sourceRegion.height,\n depthOrArrayLayers: sourceRegion.depthOrArrayLayers\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 writeTimestamp(querySet: WebGPUQuerySet, queryIndex: number): void {\n querySet._invalidateResults();\n const writeTimestamp = (\n this.handle as GPUCommandEncoder & {\n writeTimestamp?: (querySet: GPUQuerySet, queryIndex: number) => void;\n }\n ).writeTimestamp;\n\n if (writeTimestamp) {\n writeTimestamp.call(this.handle, querySet.handle, queryIndex);\n return;\n }\n\n const computePass = this.handle.beginComputePass({\n timestampWrites: {\n querySet: querySet.handle,\n beginningOfPassWriteIndex: queryIndex\n }\n });\n computePass.end();\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 {Buffer, QuerySet, QuerySetProps} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {\n getCpuHotspotSubmitReason,\n setCpuHotspotSubmitReason\n} from '../helpers/cpu-hotspot-profiler';\n\n/**\n * Immutable\n */\nexport class WebGPUQuerySet extends QuerySet {\n readonly device: WebGPUDevice;\n readonly handle: GPUQuerySet;\n\n protected _resolveBuffer: WebGPUBuffer | null = null;\n protected _readBuffer: WebGPUBuffer | null = null;\n protected _cachedResults: bigint[] | null = null;\n protected _readResultsPromise: Promise<bigint[]> | null = null;\n protected _resultsPendingResolution: boolean = false;\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 if (!this.destroyed) {\n this.handle?.destroy();\n this.destroyResource();\n // @ts-expect-error readonly\n this.handle = null;\n }\n }\n\n isResultAvailable(queryIndex?: number): boolean {\n if (!this._cachedResults) {\n return false;\n }\n\n return queryIndex === undefined\n ? true\n : queryIndex >= 0 && queryIndex < this._cachedResults.length;\n }\n\n async readResults(options?: {firstQuery?: number; queryCount?: number}): Promise<bigint[]> {\n const firstQuery = options?.firstQuery || 0;\n const queryCount = options?.queryCount || this.props.count - firstQuery;\n\n if (firstQuery < 0 || queryCount < 0 || firstQuery + queryCount > this.props.count) {\n throw new Error('Query read range is out of bounds');\n }\n\n let needsFreshResults = true;\n while (needsFreshResults) {\n if (!this._readResultsPromise) {\n this._readResultsPromise = this._readAllResults();\n }\n\n const readResultsPromise = this._readResultsPromise;\n const results = await readResultsPromise;\n\n // A later submit may have invalidated the query set while this read was in flight.\n // Retry so each caller observes the freshest resolved results instead of stale data.\n needsFreshResults = this._resultsPendingResolution;\n if (!needsFreshResults) {\n return results.slice(firstQuery, firstQuery + queryCount);\n }\n }\n\n throw new Error('Query read unexpectedly failed to resolve');\n }\n\n async readTimestampDuration(beginIndex: number, endIndex: number): Promise<number> {\n if (this.props.type !== 'timestamp') {\n throw new Error('Timestamp durations require a timestamp QuerySet');\n }\n if (beginIndex < 0 || endIndex <= beginIndex || endIndex >= this.props.count) {\n throw new Error('Timestamp duration range is out of bounds');\n }\n\n const results = await this.readResults({\n firstQuery: beginIndex,\n queryCount: endIndex - beginIndex + 1\n });\n return Number(results[results.length - 1] - results[0]) / 1e6;\n }\n\n /** Marks any cached query results as stale after new writes have been encoded. */\n _invalidateResults(): void {\n this._cachedResults = null;\n this._resultsPendingResolution = true;\n }\n\n protected async _readAllResults(): Promise<bigint[]> {\n this._ensureBuffers();\n\n try {\n // Use a dedicated encoder so async profiling reads cannot flush or replace the\n // device's active frame encoder while application rendering is in flight.\n if (this._resultsPendingResolution) {\n const commandEncoder = this.device.createCommandEncoder({\n id: `${this.id}-read-results`\n });\n commandEncoder.resolveQuerySet(this, this._resolveBuffer!);\n commandEncoder.copyBufferToBuffer({\n sourceBuffer: this._resolveBuffer!,\n destinationBuffer: this._readBuffer!,\n size: this._resolveBuffer!.byteLength\n });\n const commandBuffer = commandEncoder.finish({\n id: `${this.id}-read-results-command-buffer`\n });\n const previousSubmitReason = getCpuHotspotSubmitReason(this.device) || undefined;\n setCpuHotspotSubmitReason(this.device, 'query-readback');\n try {\n this.device.submit(commandBuffer);\n } finally {\n setCpuHotspotSubmitReason(this.device, previousSubmitReason);\n }\n }\n\n const data = await this._readBuffer!.readAsync(0, this._readBuffer!.byteLength);\n const resultView = new BigUint64Array(data.buffer, data.byteOffset, this.props.count);\n this._cachedResults = Array.from(resultView, value => value);\n this._resultsPendingResolution = false;\n return this._cachedResults;\n } finally {\n this._readResultsPromise = null;\n }\n }\n\n protected _ensureBuffers(): void {\n if (this._resolveBuffer && this._readBuffer) {\n return;\n }\n\n const byteLength = this.props.count * 8;\n this._resolveBuffer = this.device.createBuffer({\n id: `${this.id}-resolve-buffer`,\n usage: Buffer.QUERY_RESOLVE | Buffer.COPY_SRC,\n byteLength\n });\n this.attachResource(this._resolveBuffer);\n\n this._readBuffer = this.device.createBuffer({\n id: `${this.id}-read-buffer`,\n usage: Buffer.COPY_DST | Buffer.MAP_READ,\n byteLength\n });\n this.attachResource(this._readBuffer);\n }\n\n _encodeResolveToReadBuffer(\n commandEncoder: {\n resolveQuerySet: (\n querySet: WebGPUQuerySet,\n destination: WebGPUBuffer,\n options?: {firstQuery?: number; queryCount?: number; destinationOffset?: number}\n ) => void;\n copyBufferToBuffer: (options: {\n sourceBuffer: WebGPUBuffer;\n destinationBuffer: WebGPUBuffer;\n sourceOffset?: number;\n destinationOffset?: number;\n size?: number;\n }) => void;\n },\n options?: {firstQuery?: number; queryCount?: number}\n ): boolean {\n if (!this._resultsPendingResolution) {\n return false;\n }\n\n // If a readback is already mapping the shared read buffer, defer to the fallback read path.\n // That path will submit resolve/copy commands once the current read has completed.\n if (this._readResultsPromise) {\n return false;\n }\n\n this._ensureBuffers();\n const firstQuery = options?.firstQuery || 0;\n const queryCount = options?.queryCount || this.props.count - firstQuery;\n const byteLength = queryCount * BigUint64Array.BYTES_PER_ELEMENT;\n const byteOffset = firstQuery * BigUint64Array.BYTES_PER_ELEMENT;\n\n commandEncoder.resolveQuerySet(this, this._resolveBuffer!, {\n firstQuery,\n queryCount,\n destinationOffset: byteOffset\n });\n commandEncoder.copyBufferToBuffer({\n sourceBuffer: this._resolveBuffer!,\n sourceOffset: byteOffset,\n destinationBuffer: this._readBuffer!,\n destinationOffset: byteOffset,\n size: byteLength\n });\n this._resultsPendingResolution = false;\n return true;\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 bindGroupEntriesByGroup = this.mapShaderLayoutToBindGroupEntriesByGroup();\n\n this.handle = this.device.handle.createPipelineLayout({\n label: props?.id ?? 'unnamed-pipeline-layout',\n bindGroupLayouts: bindGroupEntriesByGroup.map((entries, group) =>\n this.device.handle.createBindGroupLayout({\n label: `bind-group-layout-${group}`,\n entries\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 mapShaderLayoutToBindGroupEntriesByGroup(): GPUBindGroupLayoutEntry[][] {\n const maxGroup = this.props.shaderLayout.bindings.reduce(\n (highestGroup, binding) => Math.max(highestGroup, binding.group),\n -1\n );\n const bindGroupEntriesByGroup: GPUBindGroupLayoutEntry[][] = Array.from(\n {length: maxGroup + 1},\n () => []\n );\n\n for (const binding of this.props.shaderLayout.bindings) {\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 bindGroupEntriesByGroup[binding.group].push({\n binding: binding.location,\n visibility: binding.visibility || VISIBILITY_ALL,\n ...bindingTypeInfo\n });\n }\n\n return bindGroupEntriesByGroup;\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\n .onSubmittedWorkDone()\n .then(() => {\n this._signaled = true;\n })\n .catch(error => {\n if (this.device.shouldIgnoreDroppedInstanceError(error)) {\n return;\n }\n throw error;\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 storageBuffer of parsedWGSL.storage) {\n shaderLayout.bindings.push({\n type: storageBuffer.access === 'read' ? 'read-only-storage' : 'storage',\n name: storageBuffer.name,\n group: storageBuffer.group,\n location: storageBuffer.binding\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// Forked from https://github.com/greggman/webgpu-utils under MIT license\n// Copyright (c) 2022 Gregg Tavares\n\nimport type {\n Texture,\n TextureView,\n TextureFormat,\n TextureFormatColor,\n TextureBindingLayout,\n StorageTextureBindingLayout,\n UniformBufferBindingLayout,\n SamplerBindingLayout\n} from '@luma.gl/core';\nimport {Buffer, textureFormatDecoder} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport type {WebGPUComputePass} from '../resources/webgpu-compute-pass';\nimport type {WebGPURenderPass} from '../resources/webgpu-render-pass';\n\ntype RenderTextureViewDimension = '2d' | '2d-array' | 'cube' | 'cube-array';\ntype TextureCapability = 'render' | 'filter' | 'store';\ntype MipmapPath = 'render' | 'compute';\n\nconst RENDER_DIMENSIONS: ReadonlyArray<RenderTextureViewDimension> = [\n '2d',\n '2d-array',\n 'cube',\n 'cube-array'\n];\n\nconst WORKGROUP_SIZE = {\n x: 4,\n y: 4,\n z: 4\n} as const;\n\nconst RENDER_SOURCE_SAMPLER_LAYOUT: SamplerBindingLayout = {\n type: 'sampler',\n name: 'sourceSampler',\n group: 0,\n location: 0\n};\n\nconst COMPUTE_SOURCE_TEXTURE_LAYOUT: TextureBindingLayout = {\n type: 'texture',\n name: 'sourceTexture',\n group: 0,\n location: 0,\n viewDimension: '3d',\n sampleType: 'float'\n};\n\nconst COMPUTE_UNIFORMS_LAYOUT: UniformBufferBindingLayout = {\n type: 'uniform',\n name: 'uniforms',\n group: 0,\n location: 2\n};\n\n/**\n * Generates mip levels from level 0 to the last mip for an existing WebGPU texture.\n */\nexport function generateMipmapsWebGPU(device: WebGPUDevice, texture: Texture): void {\n if (texture.mipLevels <= 1) {\n return;\n }\n\n if (texture.dimension === '3d') {\n generateMipmaps3D(device, texture);\n return;\n }\n\n if (RENDER_DIMENSIONS.includes(texture.dimension as RenderTextureViewDimension)) {\n generateMipmapsRender(device, texture);\n return;\n }\n\n throw new Error(\n `Cannot generate mipmaps for texture dimension \"${texture.dimension}\" with WebGPU.`\n );\n}\n\nfunction generateMipmapsRender(device: WebGPUDevice, texture: Texture): void {\n validateFormatCapabilities(device, texture, ['render', 'filter'], 'render');\n const colorAttachmentFormat = getColorAttachmentFormat(\n texture.format,\n 'render',\n texture.dimension\n );\n\n const viewDimension = texture.dimension as RenderTextureViewDimension;\n const shaderSource = getRenderMipmapWGSL(viewDimension);\n const sampler = device.createSampler({minFilter: 'linear', magFilter: 'linear'});\n const uniformsBuffer = device.createBuffer({\n byteLength: 16,\n usage: Buffer.UNIFORM | Buffer.COPY_DST\n });\n const uniformValues = new Uint32Array(1);\n const sourceTextureLayout: TextureBindingLayout = {\n type: 'texture',\n name: 'sourceTexture',\n group: 0,\n location: 1,\n viewDimension,\n sampleType: 'float'\n };\n const uniformsLayout: UniformBufferBindingLayout = {\n type: 'uniform',\n name: 'uniforms',\n group: 0,\n location: 2\n };\n const renderShaderLayout = {\n attributes: [],\n bindings: [RENDER_SOURCE_SAMPLER_LAYOUT, sourceTextureLayout, uniformsLayout]\n };\n const vertexShader = device.createShader({\n id: 'mipmap-generation-render-vs',\n source: shaderSource,\n language: 'wgsl',\n stage: 'vertex'\n });\n const fragmentShader = device.createShader({\n id: 'mipmap-generation-render-fs',\n source: shaderSource,\n language: 'wgsl',\n stage: 'fragment'\n });\n const renderPipeline = device.createRenderPipeline({\n id: `mipmap-generation-render:${texture.dimension}:${texture.format}`,\n vs: vertexShader,\n fs: fragmentShader,\n shaderLayout: renderShaderLayout,\n colorAttachmentFormats: [colorAttachmentFormat],\n topology: 'triangle-list'\n });\n\n let sourceWidth = texture.width;\n let sourceHeight = texture.height;\n const layerCount = texture.dimension === '2d' ? 1 : texture.depth;\n\n function renderMipmapLayer(\n sourceView: TextureView,\n baseMipLevel: number,\n baseArrayLayer: number,\n destinationWidth: number,\n destinationHeight: number\n ): void {\n uniformValues[0] = baseArrayLayer;\n uniformsBuffer.write(uniformValues);\n\n const destinationView = texture.createView({\n dimension: '2d',\n baseMipLevel,\n mipLevelCount: 1,\n baseArrayLayer,\n arrayLayerCount: 1\n });\n const framebuffer = device.createFramebuffer({\n colorAttachments: [destinationView]\n });\n const renderPass = device.beginRenderPass({\n id: `mipmap-generation:${texture.format}:${baseMipLevel}:${baseArrayLayer}`,\n framebuffer\n }) as WebGPURenderPass;\n\n try {\n renderPass.setPipeline(renderPipeline);\n renderPass.setBindings({\n sourceSampler: sampler,\n sourceTexture: sourceView,\n uniforms: uniformsBuffer\n });\n renderPass.setParameters({\n viewport: [0, 0, destinationWidth, destinationHeight, 0, 1],\n scissorRect: [0, 0, destinationWidth, destinationHeight]\n });\n renderPass.draw({vertexCount: 3});\n renderPass.end();\n device.submit();\n } finally {\n destinationView.destroy();\n framebuffer.destroy();\n }\n }\n\n try {\n for (let baseMipLevel = 1; baseMipLevel < texture.mipLevels; ++baseMipLevel) {\n validateFormatCapabilities(device, texture, ['render', 'filter'], 'render');\n const sourceMipLevel = baseMipLevel - 1;\n const destinationWidth = Math.max(1, sourceWidth >> 1);\n const destinationHeight = Math.max(1, sourceHeight >> 1);\n\n const sourceView = texture.createView({\n dimension: viewDimension,\n baseMipLevel: sourceMipLevel,\n mipLevelCount: 1,\n baseArrayLayer: 0,\n arrayLayerCount: texture.depth\n });\n\n try {\n for (let baseArrayLayer = 0; baseArrayLayer < layerCount; ++baseArrayLayer) {\n renderMipmapLayer(\n sourceView,\n baseMipLevel,\n baseArrayLayer,\n destinationWidth,\n destinationHeight\n );\n }\n } finally {\n sourceView.destroy();\n }\n\n sourceWidth = destinationWidth;\n sourceHeight = destinationHeight;\n }\n } finally {\n renderPipeline.destroy();\n vertexShader.destroy();\n fragmentShader.destroy();\n sampler.destroy();\n uniformsBuffer.destroy();\n }\n}\n\nfunction getColorAttachmentFormat(\n format: TextureFormat,\n path: MipmapPath,\n dimension: string\n): TextureFormatColor {\n if (textureFormatDecoder.isColor(format)) {\n return format;\n }\n\n throw new Error(\n `Cannot run ${path} mipmap generation for ${dimension} texture with format \"${format}\". ` +\n `Only color textures can be used for this operation. ` +\n `Required capabilities: color. ` +\n `Actual capabilities: color=false.`\n );\n}\n\nfunction generateMipmaps3D(device: WebGPUDevice, texture: Texture): void {\n validateFormatCapabilities(device, texture, ['filter', 'store'], 'compute');\n const format = getColorAttachmentFormat(texture.format, 'compute', texture.dimension);\n const shaderSource = get3DComputeMipmapWGSL(format);\n const destinationTextureLayout: StorageTextureBindingLayout = {\n type: 'storage',\n name: 'destinationTexture',\n group: 0,\n location: 1,\n format,\n viewDimension: '3d',\n access: 'write-only'\n };\n const computeShaderLayout = {\n bindings: [COMPUTE_SOURCE_TEXTURE_LAYOUT, destinationTextureLayout, COMPUTE_UNIFORMS_LAYOUT]\n };\n const computeShader = device.createShader({\n id: 'mipmap-generation-compute',\n source: shaderSource,\n language: 'wgsl',\n stage: 'compute'\n });\n const computePipeline = device.createComputePipeline({\n id: `mipmap-generation-compute:${texture.format}`,\n shader: computeShader,\n shaderLayout: computeShaderLayout\n });\n const uniformsBuffer = device.createBuffer({\n byteLength: 32,\n usage: Buffer.UNIFORM | Buffer.COPY_DST\n });\n const uniformValues = new Uint32Array(8);\n\n let sourceWidth = texture.width;\n let sourceHeight = texture.height;\n let sourceDepth = texture.depth;\n\n try {\n for (\n let destinationMipLevel = 1;\n destinationMipLevel < texture.mipLevels;\n ++destinationMipLevel\n ) {\n validateFormatCapabilities(device, texture, ['filter', 'store'], 'compute');\n const destinationWidth = Math.max(1, sourceWidth >> 1);\n const destinationHeight = Math.max(1, sourceHeight >> 1);\n const destinationDepth = Math.max(1, sourceDepth >> 1);\n\n uniformValues[0] = sourceWidth;\n uniformValues[1] = sourceHeight;\n uniformValues[2] = sourceDepth;\n uniformValues[3] = destinationWidth;\n uniformValues[4] = destinationHeight;\n uniformValues[5] = destinationDepth;\n uniformValues[6] = 0;\n uniformsBuffer.write(uniformValues);\n\n const sourceView = texture.createView({\n dimension: '3d',\n baseMipLevel: destinationMipLevel - 1,\n mipLevelCount: 1,\n baseArrayLayer: 0,\n arrayLayerCount: 1\n });\n const destinationView = texture.createView({\n dimension: '3d',\n baseMipLevel: destinationMipLevel,\n mipLevelCount: 1,\n baseArrayLayer: 0,\n arrayLayerCount: 1\n });\n computePipeline.setBindings({\n sourceTexture: sourceView,\n destinationTexture: destinationView,\n uniforms: uniformsBuffer\n });\n\n try {\n const workgroupsX = Math.ceil(destinationWidth / WORKGROUP_SIZE.x);\n const workgroupsY = Math.ceil(destinationHeight / WORKGROUP_SIZE.y);\n const workgroupsZ = Math.ceil(destinationDepth / WORKGROUP_SIZE.z);\n const computePass = device.beginComputePass({}) as WebGPUComputePass;\n\n computePass.setPipeline(computePipeline);\n computePass.dispatch(workgroupsX, workgroupsY, workgroupsZ);\n computePass.end();\n device.submit();\n } finally {\n sourceView.destroy();\n destinationView.destroy();\n }\n\n sourceWidth = destinationWidth;\n sourceHeight = destinationHeight;\n sourceDepth = destinationDepth;\n }\n } finally {\n computePipeline.destroy();\n computeShader.destroy();\n uniformsBuffer.destroy();\n }\n}\n\nfunction validateFormatCapabilities(\n device: WebGPUDevice,\n texture: Texture,\n requiredCapabilities: ReadonlyArray<TextureCapability>,\n path: MipmapPath\n): void {\n const {format, dimension} = texture;\n const capabilities = device.getTextureFormatCapabilities(format);\n const missingCapabilities = requiredCapabilities.filter(capability => !capabilities[capability]);\n\n if (missingCapabilities.length > 0) {\n const required = requiredCapabilities.join(' + ');\n const actual = requiredCapabilities\n .map(capability => `${capability}=${capabilities[capability]}`)\n .join(', ');\n throw new Error(\n `Cannot run ${path} mipmap generation for ${dimension} texture with format \"${format}\". ` +\n `Required capabilities: ${required}. ` +\n `Actual capabilities: ${actual}.`\n );\n }\n}\n\nfunction getSourceTextureType(dimension: RenderTextureViewDimension): string {\n switch (dimension) {\n case '2d':\n return 'texture_2d<f32>';\n case '2d-array':\n return 'texture_2d_array<f32>';\n case 'cube':\n return 'texture_cube<f32>';\n case 'cube-array':\n return 'texture_cube_array<f32>';\n default:\n throw new Error(`Unsupported render dimension \"${dimension}\" for mipmap generation.`);\n }\n}\n\nfunction getRenderMipmapWGSL(dimension: RenderTextureViewDimension): string {\n const sourceSnippet = getRenderMipmapSampleSnippet(dimension);\n\n return `\nstruct MipmapUniforms {\n sourceLayer: u32,\n};\n\nfn _touchUniform(uniforms: MipmapUniforms) {\n let unusedSourceLayer = uniforms.sourceLayer;\n}\n\nconst faceMat = array(\n mat3x3f(\n 0.0, 0.0, -2.0,\n 0.0, -2.0, 0.0,\n 1.0, 1.0, 1.0\n ), // pos-x\n mat3x3f(\n 0.0, 0.0, 2.0,\n 0.0, -2.0, 0.0,\n -1.0, 1.0, -1.0\n ), // neg-x\n mat3x3f(\n 2.0, 0.0, 0.0,\n 0.0, 0.0, 2.0,\n -1.0, 1.0, -1.0\n ), // pos-y\n mat3x3f(\n 2.0, 0.0, 0.0,\n 0.0, 0.0, -2.0,\n -1.0, -1.0, 1.0\n ), // neg-y\n mat3x3f(\n 2.0, 0.0, 0.0,\n 0.0, -2.0, 0.0,\n -1.0, 1.0, 1.0\n ), // pos-z\n mat3x3f(\n -2.0, 0.0, 0.0,\n 0.0, -2.0, 0.0,\n 1.0, 1.0, -1.0\n ) // neg-z\n);\n\nstruct FragmentInputs {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f\n};\n\nstruct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f\n};\n\n@group(0) @binding(0) var sourceSampler: sampler;\n@group(0) @binding(1) var sourceTexture: ${getSourceTextureType(dimension)};\n@group(0) @binding(2) var<uniform> uniforms: MipmapUniforms;\n\n@vertex\nfn vertexMain(\n @builtin(vertex_index) vertexIndex: u32\n) -> VertexOutput {\n const positions = array(\n vec2f(-1.0, -1.0),\n vec2f(-1.0, 3.0),\n vec2f( 3.0, -1.0)\n );\n\n let xy = positions[vertexIndex];\n return VertexOutput(\n vec4f(xy, 0.0, 1.0),\n xy * vec2f(0.5, -0.5) + vec2f(0.5)\n );\n}\n\n@fragment\nfn fragmentMain(fsInput: VertexOutput) -> @location(0) vec4f {\n _touchUniform(uniforms);\n return ${sourceSnippet};\n}\n`;\n}\n\nfunction getRenderMipmapSampleSnippet(dimension: RenderTextureViewDimension): string {\n const layer = 'uniforms.sourceLayer';\n\n switch (dimension) {\n case '2d':\n return 'textureSampleLevel(sourceTexture, sourceSampler, fsInput.texcoord, 0.0)';\n case '2d-array':\n return (\n 'textureSampleLevel(sourceTexture, sourceSampler, fsInput.texcoord, ' +\n `i32(${layer}), 0.0)`\n );\n case 'cube':\n return (\n 'textureSampleLevel(sourceTexture, sourceSampler, ' +\n `faceMat[i32(${layer})] * vec3f(fract(fsInput.texcoord), 1.0), 0.0)`\n );\n case 'cube-array':\n return (\n 'textureSampleLevel(sourceTexture, sourceSampler, ' +\n `faceMat[i32(${layer} % 6u)] * vec3f(fract(fsInput.texcoord), 1.0), ` +\n `i32(${layer} / 6u), 0.0)`\n );\n default:\n throw new Error(`Unsupported render dimension \"${dimension}\" for mipmap generation.`);\n }\n}\n\nfunction get3DComputeMipmapWGSL(format: TextureFormatColor): string {\n return `\nstruct MipmapUniforms {\n sourceWidth: u32,\n sourceHeight: u32,\n sourceDepth: u32,\n destinationWidth: u32,\n destinationHeight: u32,\n destinationDepth: u32,\n padding: u32,\n};\n\n@group(0) @binding(0) var sourceTexture: texture_3d<f32>;\n@group(0) @binding(1) var destinationTexture: texture_storage_3d<${format}, write>;\n@group(0) @binding(2) var<uniform> uniforms: MipmapUniforms;\n\n@compute @workgroup_size(${WORKGROUP_SIZE.x}, ${WORKGROUP_SIZE.y}, ${WORKGROUP_SIZE.z})\nfn main(@builtin(global_invocation_id) id: vec3<u32>) {\n if (\n id.x >= uniforms.destinationWidth ||\n id.y >= uniforms.destinationHeight ||\n id.z >= uniforms.destinationDepth\n ) {\n return;\n }\n\n let sourceBase = id * 2u;\n let sourceX0 = min(sourceBase.x, uniforms.sourceWidth - 1u);\n let sourceY0 = min(sourceBase.y, uniforms.sourceHeight - 1u);\n let sourceZ0 = min(sourceBase.z, uniforms.sourceDepth - 1u);\n\n let sourceX1 = min(sourceBase.x + 1u, uniforms.sourceWidth - 1u);\n let sourceY1 = min(sourceBase.y + 1u, uniforms.sourceHeight - 1u);\n let sourceZ1 = min(sourceBase.z + 1u, uniforms.sourceDepth - 1u);\n\n var sum = textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX0), i32(sourceY0), i32(sourceZ0)),\n 0\n );\n sum += textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX1), i32(sourceY0), i32(sourceZ0)),\n 0\n );\n sum += textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX0), i32(sourceY1), i32(sourceZ0)),\n 0\n );\n sum += textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX1), i32(sourceY1), i32(sourceZ0)),\n 0\n );\n sum += textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX0), i32(sourceY0), i32(sourceZ1)),\n 0\n );\n sum += textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX1), i32(sourceY0), i32(sourceZ1)),\n 0\n );\n sum += textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX0), i32(sourceY1), i32(sourceZ1)),\n 0\n );\n sum += textureLoad(\n sourceTexture,\n vec3<i32>(i32(sourceX1), i32(sourceY1), i32(sourceZ1)),\n 0\n );\n\n textureStore(\n destinationTexture,\n vec3<i32>(i32(id.x), i32(id.y), i32(id.z)),\n vec4<f32>(sum.xyz / 8.0, sum.w / 8.0)\n );\n}\n`;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {\n Binding,\n BindingDeclaration,\n Bindings,\n ComputeShaderLayout,\n ShaderLayout\n} from '@luma.gl/core';\nimport {Buffer, Sampler, Texture, TextureView, getShaderLayoutBinding, log} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport type {WebGPUBuffer} from '../resources/webgpu-buffer';\nimport type {WebGPUSampler} from '../resources/webgpu-sampler';\nimport type {WebGPUTexture} from '../resources/webgpu-texture';\nimport type {WebGPUTextureView} from '../resources/webgpu-texture-view';\n\ntype AnyShaderLayout = ShaderLayout | ComputeShaderLayout;\ntype BindGroupBindingSummary = {\n name: string;\n location: number;\n type: string;\n};\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: Bindings\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: WebGPUDevice,\n bindGroupLayout: GPUBindGroupLayout,\n shaderLayout: ShaderLayout | ComputeShaderLayout,\n bindings: Bindings,\n group: number,\n label?: string\n): GPUBindGroup | null {\n const entries = getBindGroupEntries(bindings, shaderLayout, group);\n if (entries.length === 0) {\n return null;\n }\n device.pushErrorScope('validation');\n const bindGroup = device.handle.createBindGroup({\n label,\n layout: bindGroupLayout,\n entries\n });\n device.popErrorScope((error: GPUError) => {\n const summary = formatBindGroupCreationErrorSummary(shaderLayout, bindings, entries, group);\n log.error(`bindGroup creation: ${summary}\\nRaw WebGPU error: ${error.message}`, bindGroup)();\n });\n return bindGroup;\n}\n\nexport function formatBindGroupCreationErrorSummary(\n shaderLayout: AnyShaderLayout,\n bindings: Bindings,\n entries: GPUBindGroupEntry[],\n group: number\n): string {\n const expectedBindings = getExpectedBindingsForGroup(shaderLayout, group);\n const expectedByLocation = new Map(\n expectedBindings.map(bindingSummary => [bindingSummary.location, bindingSummary])\n );\n const providedBindings = entries\n .map(entry => expectedByLocation.get(entry.binding) || getUnexpectedEntrySummary(entry))\n .sort(compareBindingSummaries);\n const missingBindings = expectedBindings.filter(\n bindingSummary =>\n !providedBindings.some(provided => provided.location === bindingSummary.location)\n );\n const unexpectedBindings = providedBindings.filter(\n bindingSummary => !expectedByLocation.has(bindingSummary.location)\n );\n const unmatchedLogicalBindings = Object.keys(bindings)\n .filter(bindingName => !resolveGroupBinding(bindingName, bindings, shaderLayout, group))\n .sort();\n\n const lines = [\n `bindGroup creation failed for group ${group}: expected ${expectedBindings.length}, provided ${providedBindings.length}`,\n `expected: ${formatBindingSummaryList(expectedBindings)}`,\n `provided: ${formatBindingSummaryList(providedBindings)}`\n ];\n\n if (missingBindings.length > 0) {\n lines.push(`missing: ${formatBindingSummaryList(missingBindings)}`);\n }\n if (unexpectedBindings.length > 0) {\n lines.push(`unexpected entries: ${formatBindingSummaryList(unexpectedBindings)}`);\n }\n if (unmatchedLogicalBindings.length > 0) {\n lines.push(`unmatched logical bindings: ${unmatchedLogicalBindings.join(', ')}`);\n }\n\n return lines.join('\\n');\n}\n\nexport function getBindGroupLabel(\n pipelineId: string,\n shaderLayout: AnyShaderLayout,\n group: number\n): string {\n const expectedBindings = getExpectedBindingsForGroup(shaderLayout, group);\n const bindingSuffix =\n expectedBindings.length > 0 ? expectedBindings.map(binding => binding.name).join(',') : 'empty';\n return `${pipelineId}/group${group}[${bindingSuffix}]`;\n}\n\n/**\n * @param bindings\n * @returns\n */\nfunction getBindGroupEntries(\n bindings: Bindings,\n shaderLayout: AnyShaderLayout,\n group: number\n): GPUBindGroupEntry[] {\n const entries: GPUBindGroupEntry[] = [];\n\n for (const [bindingName, value] of Object.entries(bindings)) {\n const {bindingLayout, isShadowedAlias} = resolveGroupBinding(\n bindingName,\n bindings,\n shaderLayout,\n group\n ) || {bindingLayout: null, isShadowedAlias: false};\n\n // Mirror the WebGL path: when both `foo` and `fooUniforms` exist in the bindings map,\n // prefer the exact shader binding name and ignore the alias entry.\n if (!isShadowedAlias && bindingLayout) {\n const entry = bindingLayout\n ? getBindGroupEntry(value, bindingLayout.location, undefined, bindingName)\n : null;\n if (entry) {\n entries.push(entry);\n }\n\n // TODO - hack to automatically bind samplers to supplied texture default samplers\n if (value instanceof Texture) {\n const samplerBindingLayout = getShaderLayoutBinding(shaderLayout, `${bindingName}Sampler`, {\n ignoreWarnings: true\n });\n const samplerEntry = samplerBindingLayout\n ? samplerBindingLayout.group === group\n ? getBindGroupEntry(value, samplerBindingLayout.location, {sampler: true}, bindingName)\n : null\n : null;\n if (samplerEntry) {\n entries.push(samplerEntry);\n }\n }\n }\n }\n\n return entries;\n}\n\nfunction getBindGroupEntry(\n binding: Binding,\n index: number,\n options?: {sampler?: boolean},\n bindingName: string = 'unknown'\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 TextureView) {\n return {\n binding: index,\n resource: (binding as WebGPUTextureView).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 ${bindingName}`, binding);\n return null;\n}\n\nfunction getExpectedBindingsForGroup(\n shaderLayout: AnyShaderLayout,\n group: number\n): BindGroupBindingSummary[] {\n return shaderLayout.bindings\n .filter(bindingLayout => bindingLayout.group === group)\n .map(bindingLayout => toBindingSummary(bindingLayout))\n .sort(compareBindingSummaries);\n}\n\nfunction resolveGroupBinding(\n bindingName: string,\n bindings: Bindings,\n shaderLayout: AnyShaderLayout,\n group: number\n): {bindingLayout: BindingDeclaration; isShadowedAlias: boolean} | null {\n const exactBindingLayout = shaderLayout.bindings.find(binding => binding.name === bindingName);\n const bindingLayout =\n exactBindingLayout || getShaderLayoutBinding(shaderLayout, bindingName, {ignoreWarnings: true});\n const isShadowedAlias =\n !exactBindingLayout && bindingLayout ? bindingLayout.name in bindings : false;\n\n if (isShadowedAlias || !bindingLayout || bindingLayout.group !== group) {\n return null;\n }\n\n return {bindingLayout, isShadowedAlias};\n}\n\nfunction toBindingSummary(bindingLayout: BindingDeclaration): BindGroupBindingSummary {\n return {\n name: bindingLayout.name,\n location: bindingLayout.location,\n type: bindingLayout.type\n };\n}\n\nfunction getUnexpectedEntrySummary(entry: GPUBindGroupEntry): BindGroupBindingSummary {\n return {\n name: '?',\n location: entry.binding,\n type: 'unknown'\n };\n}\n\nfunction compareBindingSummaries(\n left: BindGroupBindingSummary,\n right: BindGroupBindingSummary\n): number {\n if (left.location !== right.location) {\n return left.location - right.location;\n }\n return left.name.localeCompare(right.name);\n}\n\nfunction formatBindingSummaryList(bindings: BindGroupBindingSummary[]): string {\n if (bindings.length === 0) {\n return 'none';\n }\n return bindings.map(binding => `${binding.name}@${binding.location}`).join(', ');\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// biome-ignore format: preserve layout\n// / <reference types=\"@webgpu/types\" />\n\nimport type {\n Bindings,\n ComputePipeline,\n ComputeShaderLayout,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n DeviceTextureFormatCapabilities,\n VertexFormat,\n CanvasContextProps,\n PresentationContextProps,\n PresentationContext,\n BufferProps,\n SamplerProps,\n ShaderProps,\n TextureProps,\n Texture,\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 RenderPipeline,\n ShaderLayout\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 {WebGPUPresentationContext} from './webgpu-presentation-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';\nimport {generateMipmapsWebGPU} from './helpers/generate-mipmaps-webgpu';\nimport {getBindGroup} from './helpers/get-bind-group';\nimport {\n getCpuHotspotProfiler as getWebGPUCpuHotspotProfiler,\n getCpuHotspotSubmitReason as getWebGPUCpuHotspotSubmitReason,\n getTimestamp\n} from './helpers/cpu-hotspot-profiler';\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 private _defaultSampler: WebGPUSampler | null = null;\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 = this.handle.lost.then(lostInfo => {\n this._isLost = true;\n return {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.commandEncoder?.destroy();\n this._defaultSampler?.destroy();\n this._defaultSampler = null;\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 getDefaultSampler(): WebGPUSampler {\n this._defaultSampler ||= new WebGPUSampler(this, {\n id: `${this.id}-default-sampler`\n });\n return this._defaultSampler;\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 createPresentationContext(props?: PresentationContextProps): PresentationContext {\n return new WebGPUPresentationContext(this, props);\n }\n\n createPipelineLayout(props: PipelineLayoutProps): WebGPUPipelineLayout {\n return new WebGPUPipelineLayout(this, props);\n }\n\n override generateMipmapsWebGPU(texture: Texture): void {\n generateMipmapsWebGPU(this, texture);\n }\n\n override _createBindGroupLayoutWebGPU(\n pipeline: RenderPipeline | ComputePipeline,\n group: number\n ): GPUBindGroupLayout {\n return (pipeline as WebGPURenderPipeline | WebGPUComputePipeline).handle.getBindGroupLayout(\n group\n );\n }\n\n override _createBindGroupWebGPU(\n bindGroupLayout: unknown,\n shaderLayout: ShaderLayout | ComputeShaderLayout,\n bindings: Bindings,\n group: number,\n label?: string\n ): GPUBindGroup | null {\n if (Object.keys(bindings).length === 0) {\n return this.handle.createBindGroup({\n label,\n layout: bindGroupLayout as GPUBindGroupLayout,\n entries: []\n });\n }\n\n return getBindGroup(\n this,\n bindGroupLayout as GPUBindGroupLayout,\n shaderLayout,\n bindings,\n group,\n label\n );\n }\n\n submit(commandBuffer?: WebGPUCommandBuffer): void {\n let submittedCommandEncoder: WebGPUCommandEncoder | null = null;\n if (!commandBuffer) {\n ({submittedCommandEncoder, commandBuffer} = this._finalizeDefaultCommandEncoderForSubmit());\n }\n\n const profiler = getWebGPUCpuHotspotProfiler(this);\n const startTime = profiler ? getTimestamp() : 0;\n const submitReason = getWebGPUCpuHotspotSubmitReason(this);\n try {\n this.pushErrorScope('validation');\n const queueSubmitStartTime = profiler ? getTimestamp() : 0;\n this.handle.queue.submit([commandBuffer.handle]);\n if (profiler) {\n profiler.queueSubmitCount = (profiler.queueSubmitCount || 0) + 1;\n profiler.queueSubmitTimeMs =\n (profiler.queueSubmitTimeMs || 0) + (getTimestamp() - queueSubmitStartTime);\n }\n this.popErrorScope((error: GPUError) => {\n this.reportError(new Error(`${this} command submission: ${error.message}`), this)();\n this.debug();\n });\n\n if (submittedCommandEncoder) {\n const submitResolveKickoffStartTime = profiler ? getTimestamp() : 0;\n scheduleMicrotask(() => {\n submittedCommandEncoder\n .resolveTimeProfilingQuerySet()\n .then(() => {\n this.commandEncoder._gpuTimeMs = submittedCommandEncoder._gpuTimeMs;\n })\n .catch(() => {});\n });\n if (profiler) {\n profiler.submitResolveKickoffCount = (profiler.submitResolveKickoffCount || 0) + 1;\n profiler.submitResolveKickoffTimeMs =\n (profiler.submitResolveKickoffTimeMs || 0) +\n (getTimestamp() - submitResolveKickoffStartTime);\n }\n }\n } finally {\n if (profiler) {\n profiler.submitCount = (profiler.submitCount || 0) + 1;\n profiler.submitTimeMs = (profiler.submitTimeMs || 0) + (getTimestamp() - startTime);\n const reasonCountKey =\n submitReason === 'query-readback' ? 'queryReadbackSubmitCount' : 'defaultSubmitCount';\n const reasonTimeKey =\n submitReason === 'query-readback' ? 'queryReadbackSubmitTimeMs' : 'defaultSubmitTimeMs';\n profiler[reasonCountKey] = (profiler[reasonCountKey] || 0) + 1;\n profiler[reasonTimeKey] = (profiler[reasonTimeKey] || 0) + (getTimestamp() - startTime);\n }\n const commandBufferDestroyStartTime = profiler ? getTimestamp() : 0;\n commandBuffer.destroy();\n if (profiler) {\n profiler.commandBufferDestroyCount = (profiler.commandBufferDestroyCount || 0) + 1;\n profiler.commandBufferDestroyTimeMs =\n (profiler.commandBufferDestroyTimeMs || 0) +\n (getTimestamp() - commandBufferDestroyStartTime);\n }\n }\n }\n\n private _finalizeDefaultCommandEncoderForSubmit(): {\n submittedCommandEncoder: WebGPUCommandEncoder;\n commandBuffer: WebGPUCommandBuffer;\n } {\n const submittedCommandEncoder = this.commandEncoder;\n if (\n submittedCommandEncoder.getTimeProfilingSlotCount() > 0 &&\n submittedCommandEncoder.getTimeProfilingQuerySet() instanceof WebGPUQuerySet\n ) {\n const querySet = submittedCommandEncoder.getTimeProfilingQuerySet() as WebGPUQuerySet;\n querySet._encodeResolveToReadBuffer(submittedCommandEncoder, {\n firstQuery: 0,\n queryCount: submittedCommandEncoder.getTimeProfilingSlotCount()\n });\n }\n\n const commandBuffer = submittedCommandEncoder.finish();\n this.commandEncoder.destroy();\n this.commandEncoder = this.createCommandEncoder({\n id: submittedCommandEncoder.props.id,\n timeProfilingQuerySet: submittedCommandEncoder.getTimeProfilingQuerySet()\n });\n\n return {submittedCommandEncoder, commandBuffer};\n }\n\n // WebGPU specific\n\n pushErrorScope(scope: 'validation' | 'out-of-memory'): void {\n if (!this.props.debug) {\n return;\n }\n const profiler = getWebGPUCpuHotspotProfiler(this);\n const startTime = profiler ? getTimestamp() : 0;\n this.handle.pushErrorScope(scope);\n if (profiler) {\n profiler.errorScopePushCount = (profiler.errorScopePushCount || 0) + 1;\n profiler.errorScopeTimeMs = (profiler.errorScopeTimeMs || 0) + (getTimestamp() - startTime);\n }\n }\n\n popErrorScope(handler: (error: GPUError) => void): void {\n if (!this.props.debug) {\n return;\n }\n const profiler = getWebGPUCpuHotspotProfiler(this);\n const startTime = profiler ? getTimestamp() : 0;\n this.handle\n .popErrorScope()\n .then((error: GPUError | null) => {\n if (error) {\n handler(error);\n }\n })\n .catch((error: unknown) => {\n if (this.shouldIgnoreDroppedInstanceError(error, 'popErrorScope')) {\n return;\n }\n\n const errorMessage = error instanceof Error ? error.message : String(error);\n this.reportError(new Error(`${this} popErrorScope failed: ${errorMessage}`), this)();\n this.debug();\n });\n if (profiler) {\n profiler.errorScopePopCount = (profiler.errorScopePopCount || 0) + 1;\n profiler.errorScopeTimeMs = (profiler.errorScopeTimeMs || 0) + (getTimestamp() - startTime);\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 const fallback = Boolean(\n (this.adapterInfo as any).isFallbackAdapter ??\n (this.adapter as any).isFallbackAdapter ??\n false\n );\n const softwareRenderer = /SwiftShader/i.test(\n `${vendor} ${renderer} ${this.adapterInfo.architecture || ''}`\n );\n\n const gpu =\n vendor === 'apple' ? 'apple' : softwareRenderer || fallback ? 'software' : '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 =\n ((this.adapterInfo as any).type || '').split(' ')[0].toLowerCase() ||\n (softwareRenderer || fallback ? 'cpu' : 'unknown');\n\n return {\n type: 'webgpu',\n vendor,\n renderer,\n version,\n gpu,\n gpuType,\n gpuBackend,\n gpuArchitecture,\n fallback,\n shadingLanguage: 'wgsl',\n shadingLanguageVersion: 100\n };\n }\n\n shouldIgnoreDroppedInstanceError(error: unknown, operation?: string): boolean {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return (\n errorMessage.includes('Instance dropped') &&\n (!operation || errorMessage.includes(operation)) &&\n (this._isLost ||\n this.info.gpu === 'software' ||\n this.info.gpuType === 'cpu' ||\n Boolean(this.info.fallback))\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 '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\nfunction scheduleMicrotask(callback: () => void): void {\n if (globalThis.queueMicrotask) {\n globalThis.queueMicrotask(callback);\n return;\n }\n Promise.resolve()\n .then(callback)\n .catch(() => {});\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// biome-ignore format: preserve layout\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,aASa;AAbb;;;AAIA,kBAAoE;AAS9D,IAAO,eAAP,cAA4B,mBAAM;MAC7B;MACA;MACA;MACA;MAET,YAAY,QAAsB,OAAkB;AAnBtD;AAoBI,cAAM,QAAQ,KAAK;AACnB,aAAK,SAAS;AAEd,aAAK,aAAa,MAAM,gBAAc,WAAM,SAAN,mBAAY,eAAc;AAChE,aAAK,mBAAmB,KAAK,KAAK,KAAK,aAAa,CAAC,IAAI;AACzD,cAAM,mBAAmB,QAAQ,KAAK,MAAM,YAAY,MAAM,IAAI;AAGlE,cAAM,OAAO,KAAK;AAElB,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,OAAO,YAAY,IAAI,MAAM,GAAG,uBAAuB,MAAM,SAAS,GAAG,IAAI,EAAC;AACnF,eAAK,OAAO,MAAK;QACnB,CAAC;AAED,aAAK,OAAO,eAAe,YAAY;AACvC,YAAI,MAAM,QAAQ,MAAM,UAAU;AAChC,cAAI;AACF,kBAAM,cAAc,KAAK,OAAO,eAAc;AAC9C,gBAAI,MAAM,MAAM;AACd,oB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ACF;EAEA,MAAM,OAAO,QAAiB;AAC5B,UAAM,IAAI,MAAM,wCAAwC;EAC1D;;AAGK,IAAM,gBAAgB,IAAI,cAAa;;;AD7F9C;AACA;AACA;AACA;AACA;AACA;AAEA;",
6
6
  "names": ["import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "import_core", "WebGPUDevice"]
7
7
  }