@luma.gl/webgpu 9.0.0-alpha.32 → 9.0.0-alpha.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/adapter/helpers/generate-mipmaps.js +18 -6
  2. package/dist/adapter/helpers/generate-mipmaps.js.map +1 -1
  3. package/dist/adapter/helpers/get-bind-group.js +1 -1
  4. package/dist/adapter/helpers/get-bind-group.js.map +1 -1
  5. package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -1
  6. package/dist/adapter/helpers/get-vertex-buffer-layout.js +12 -11
  7. package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -1
  8. package/dist/adapter/helpers/webgpu-parameters.js +1 -1
  9. package/dist/adapter/helpers/webgpu-parameters.js.map +1 -1
  10. package/dist/adapter/resources/webgpu-buffer.js +3 -4
  11. package/dist/adapter/resources/webgpu-buffer.js.map +1 -1
  12. package/dist/adapter/resources/webgpu-command-encoder.js +2 -3
  13. package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
  14. package/dist/adapter/resources/webgpu-compute-pass.js +3 -4
  15. package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
  16. package/dist/adapter/resources/webgpu-compute-pipeline.js +2 -3
  17. package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -1
  18. package/dist/adapter/resources/webgpu-external-texture.js +3 -4
  19. package/dist/adapter/resources/webgpu-external-texture.js.map +1 -1
  20. package/dist/adapter/resources/webgpu-framebuffer.js +1 -2
  21. package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
  22. package/dist/adapter/resources/webgpu-render-pass.js +3 -4
  23. package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
  24. package/dist/adapter/resources/webgpu-render-pipeline.js +13 -14
  25. package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
  26. package/dist/adapter/resources/webgpu-sampler.js +2 -3
  27. package/dist/adapter/resources/webgpu-sampler.js.map +1 -1
  28. package/dist/adapter/resources/webgpu-shader.js +4 -5
  29. package/dist/adapter/resources/webgpu-shader.js.map +1 -1
  30. package/dist/adapter/resources/webgpu-texture.js +6 -7
  31. package/dist/adapter/resources/webgpu-texture.js.map +1 -1
  32. package/dist/adapter/webgpu-canvas-context.js +8 -9
  33. package/dist/adapter/webgpu-canvas-context.js.map +1 -1
  34. package/dist/adapter/webgpu-device.js +10 -11
  35. package/dist/adapter/webgpu-device.js.map +1 -1
  36. package/dist/dist.dev.js +213 -44
  37. package/dist/index.cjs +9 -7
  38. package/dist.min.js +5 -4
  39. package/package.json +3 -3
  40. package/src/adapter/helpers/get-vertex-buffer-layout.ts +12 -9
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-render-pass.js","names":["RenderPass","cast","WebGPURenderPass","constructor","device","props","arguments","length","undefined","_defineProperty","framebuffer","canvasContext","getCurrentFramebuffer","renderPassDescriptor","getRenderPassDescriptor","handle","commandEncoder","beginRenderPass","label","id","destroy","end","setPipeline","pipeline","setBindings","bindings","_this$pipeline","_this$pipeline2","bindGroup","_getBindGroup","setBindGroup","setIndexBuffer","buffer","indexFormat","offset","size","setVertexBuffer","slot","draw","options","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","drawIndirect","setParameters","parameters","blendConstant","stencilReference","scissorRect","viewport","setBlendConstant","setStencilReference","setScissorRect","setViewport","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel","colorAttachments","map","colorAttachment","loadOp","colorClearValue","clearColor","storeOp","discard","view","createView","depthStencilAttachment"],"sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"sourcesContent":["import type {RenderPassProps, RenderPassParameters, Binding, Framebuffer} from '@luma.gl/core';\nimport {Buffer, RenderPass, RenderPipeline, cast} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {WebGPUTexture} from './webgpu-texture';\n// import {WebGPUCommandEncoder} from './webgpu-command-encoder';\nimport {WebGPURenderPipeline} from './webgpu-render-pipeline';\n\nexport class WebGPURenderPass extends RenderPass {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPassEncoder;\n\n /** Active pipeline */\n pipeline: WebGPURenderPipeline | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPassProps = {}) {\n super(device, props);\n this.device = device;\n const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer() ;\n const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);\n this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\n\n end(): void {\n this.handle.end();\n }\n\n setPipeline(pipeline: RenderPipeline): void {\n this.pipeline = cast<WebGPURenderPipeline>(pipeline);\n this.handle.setPipeline(this.pipeline.handle);\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Record<string, Binding>): void {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n\n setIndexBuffer(\n buffer: Buffer,\n indexFormat: GPUIndexFormat,\n offset: number = 0,\n size?: number\n ): void {\n this.handle.setIndexBuffer(cast<WebGPUBuffer>(buffer).handle, indexFormat, offset, size);\n }\n\n setVertexBuffer(slot: number, buffer: Buffer, offset: number = 0): void {\n this.handle.setVertexBuffer(slot, cast<WebGPUBuffer>(buffer).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,\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],\n viewport[5]\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 // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\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: Framebuffer): GPURenderPassDescriptor {\n const renderPassDescriptor: GPURenderPassDescriptor = {\n colorAttachments: []\n };\n\n renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({\n // clear values\n loadOp: 'clear',\n colorClearValue: this.props.clearColor || [0, 0, 0, 0],\n storeOp: this.props.discard? 'discard': 'store',\n // ...colorAttachment,\n view: (colorAttachment as WebGPUTexture).handle.createView()\n }));\n\n if (framebuffer.depthStencilAttachment) {\n renderPassDescriptor.depthStencilAttachment = {\n ...this.props,\n view: (framebuffer.depthStencilAttachment as WebGPUTexture).handle.createView()\n };\n }\n\n return renderPassDescriptor;\n }\n}\n"],"mappings":";AACA,SAAgBA,UAAU,EAAkBC,IAAI,QAAO,eAAe;AAOtE,OAAO,MAAMC,gBAAgB,SAASF,UAAU,CAAC;EAO/CG,WAAWA,CAACC,MAAoB,EAA+B;IAAA,IAA7BC,KAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAC3D,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAACI,eAAA;IAAAA,eAAA;IAAAA,eAAA,mBAHiB,IAAI;IAI1C,IAAI,CAACL,MAAM,GAAGA,MAAM;IACpB,MAAMM,WAAW,GAAGL,KAAK,CAACK,WAAW,IAAIN,MAAM,CAACO,aAAa,CAACC,qBAAqB,CAAC,CAAC;IACrF,MAAMC,oBAAoB,GAAG,IAAI,CAACC,uBAAuB,CAACJ,WAAW,CAAC;IACtE,IAAI,CAACK,MAAM,GAAG,IAAI,CAACV,KAAK,CAACU,MAAM,IAAIX,MAAM,CAACY,cAAc,CAACC,eAAe,CAACJ,oBAAoB,CAAC;IAC9F,IAAI,CAACE,MAAM,CAACG,KAAK,GAAG,IAAI,CAACb,KAAK,CAACc,EAAE;EACnC;EAESC,OAAOA,CAAA,EAAS,CAAC;EAE1BC,GAAGA,CAAA,EAAS;IACV,IAAI,CAACN,MAAM,CAACM,GAAG,CAAC,CAAC;EACnB;EAEAC,WAAWA,CAACC,QAAwB,EAAQ;IAC1C,IAAI,CAACA,QAAQ,GAAGtB,IAAI,CAAuBsB,QAAQ,CAAC;IACpD,IAAI,CAACR,MAAM,CAACO,WAAW,CAAC,IAAI,CAACC,QAAQ,CAACR,MAAM,CAAC;EAC/C;EAGAS,WAAWA,CAACC,QAAiC,EAAQ;IAAA,IAAAC,cAAA,EAAAC,eAAA;IACnD,CAAAD,c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EAgBUhD,uBAAuBA,CAACJ,WAAwB,EAA2B;IACnF,MAAMG,oBAA6C,GAAG;MACpDkD,gBAAgB,EAAE;IACpB,CAAC;IAEDlD,oBAAoB,CAACkD,gBAAgB,GAAGrD,WAAW,CAACqD,gBAAgB,CAACC,GAAG,CAACC,eAAe,KAAK;MAE3FC,MAAM,EAAE,OAAO;MACfC,eAAe,EAAE,IAAI,CAAC9D,KAAK,CAAC+D,UAAU,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;MACtDC,OAAO,EAAE,IAAI,CAAChE,KAAK,CAACiE,OAAO,GAAE,SAAS,GAAE,OAAO;MAE/CC,IAAI,EAAGN,eAAe,CAAmBlD,MAAM,CAACyD,UAAU,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,IAAI9D,WAAW,CAAC+D,sBAAsB,EAAE;MACtC5D,oBAAoB,CAAC4D,sBAAsB,GAAG;QAC5C,GAAG,IAAI,CAACpE,KAAK;QACbkE,IAAI,EAAG7D,WAAW,CAAC+D,sBAAsB,CAAmB1D,MAAM,CAACyD,UAAU,CAAC;MAChF,CAAC;IACH;IAEA,OAAO3D,oBAAoB;EAC7B;AACF"}
1
+ {"version":3,"file":"webgpu-render-pass.js","names":["RenderPass","cast","WebGPURenderPass","constructor","device","props","arguments","length","undefined","handle","pipeline","framebuffer","canvasContext","getCurrentFramebuffer","renderPassDescriptor","getRenderPassDescriptor","commandEncoder","beginRenderPass","label","id","destroy","end","setPipeline","setBindings","bindings","_this$pipeline","_this$pipeline2","bindGroup","_getBindGroup","setBindGroup","setIndexBuffer","buffer","indexFormat","offset","size","setVertexBuffer","slot","draw","options","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","drawIndirect","setParameters","parameters","blendConstant","stencilReference","scissorRect","viewport","setBlendConstant","setStencilReference","setScissorRect","setViewport","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel","colorAttachments","map","colorAttachment","loadOp","colorClearValue","clearColor","storeOp","discard","view","createView","depthStencilAttachment"],"sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"sourcesContent":["import type {RenderPassProps, RenderPassParameters, Binding, Framebuffer} from '@luma.gl/core';\nimport {Buffer, RenderPass, RenderPipeline, cast} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {WebGPUTexture} from './webgpu-texture';\n// import {WebGPUCommandEncoder} from './webgpu-command-encoder';\nimport {WebGPURenderPipeline} from './webgpu-render-pipeline';\n\nexport class WebGPURenderPass extends RenderPass {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPassEncoder;\n\n /** Active pipeline */\n pipeline: WebGPURenderPipeline | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPassProps = {}) {\n super(device, props);\n this.device = device;\n const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer() ;\n const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);\n this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\n\n end(): void {\n this.handle.end();\n }\n\n setPipeline(pipeline: RenderPipeline): void {\n this.pipeline = cast<WebGPURenderPipeline>(pipeline);\n this.handle.setPipeline(this.pipeline.handle);\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Record<string, Binding>): void {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n\n setIndexBuffer(\n buffer: Buffer,\n indexFormat: GPUIndexFormat,\n offset: number = 0,\n size?: number\n ): void {\n this.handle.setIndexBuffer(cast<WebGPUBuffer>(buffer).handle, indexFormat, offset, size);\n }\n\n setVertexBuffer(slot: number, buffer: Buffer, offset: number = 0): void {\n this.handle.setVertexBuffer(slot, cast<WebGPUBuffer>(buffer).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,\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],\n viewport[5]\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 // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\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: Framebuffer): GPURenderPassDescriptor {\n const renderPassDescriptor: GPURenderPassDescriptor = {\n colorAttachments: []\n };\n\n renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({\n // clear values\n loadOp: 'clear',\n colorClearValue: this.props.clearColor || [0, 0, 0, 0],\n storeOp: this.props.discard? 'discard': 'store',\n // ...colorAttachment,\n view: (colorAttachment as WebGPUTexture).handle.createView()\n }));\n\n if (framebuffer.depthStencilAttachment) {\n renderPassDescriptor.depthStencilAttachment = {\n ...this.props,\n view: (framebuffer.depthStencilAttachment as WebGPUTexture).handle.createView()\n };\n }\n\n return renderPassDescriptor;\n }\n}\n"],"mappings":"AACA,SAAgBA,UAAU,EAAkBC,IAAI,QAAO,eAAe;AAOtE,OAAO,MAAMC,gBAAgB,SAASF,UAAU,CAAC;EAO/CG,WAAWA,CAACC,MAAoB,EAA+B;IAAA,IAA7BC,KAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAC3D,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAAC,KAPdD,MAAM;IAAA,KACNK,MAAM;IAAA,KAGfC,QAAQ,GAAgC,IAAI;IAI1C,IAAI,CAACN,MAAM,GAAGA,MAAM;IACpB,MAAMO,WAAW,GAAGN,KAAK,CAACM,WAAW,IAAIP,MAAM,CAACQ,aAAa,CAACC,qBAAqB,CAAC,CAAC;IACrF,MAAMC,oBAAoB,GAAG,IAAI,CAACC,uBAAuB,CAACJ,WAAW,CAAC;IACtE,IAAI,CAACF,MAAM,GAAG,IAAI,CAACJ,KAAK,CAACI,MAAM,IAAIL,MAAM,CAACY,cAAc,CAACC,eAAe,CAACH,oBAAoB,CAAC;IAC9F,IAAI,CAACL,MAAM,CAACS,KAAK,GAAG,IAAI,CAACb,KAAK,CAACc,EAAE;EACnC;EAESC,OAAOA,CAAA,EAAS,CAAC;EAE1BC,GAAGA,CAAA,EAAS;IAC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AAQ,CAAC,CAAC,CACZ,CAAC;IACH;EACF;EAEAK,cAAcA,CAACC,UAAkB,EAAQ;IACvC,IAAI,CAACjD,MAAM,CAACgD,cAAc,CAACC,UAAU,CAAC;EACxC;EACAC,aAAaA,CAAA,EAAS;IACpB,IAAI,CAAClD,MAAM,CAACkD,aAAa,CAAC,CAAC;EAC7B;EACAC,iBAAiBA,CAACC,WAAmB,EAAQ;IAC3C,IAAI,CAACpD,MAAM,CAACmD,iBAAiB,CAACC,WAAW,CAAC;EAC5C;EAgBU9C,uBAAuBA,CAACJ,WAAwB,EAA2B;IACnF,MAAMG,oBAA6C,GAAG;MACpDgD,gBAAgB,EAAE;IACpB,CAAC;IAEDhD,oBAAoB,CAACgD,gBAAgB,GAAGnD,WAAW,CAACmD,gBAAgB,CAACC,GAAG,CAACC,eAAe,KAAK;MAE3FC,MAAM,EAAE,OAAO;MACfC,eAAe,EAAE,IAAI,CAAC7D,KAAK,CAAC8D,UAAU,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;MACtDC,OAAO,EAAE,IAAI,CAAC/D,KAAK,CAACgE,OAAO,GAAE,SAAS,GAAE,OAAO;MAE/CC,IAAI,EAAGN,eAAe,CAAmBvD,MAAM,CAAC8D,UAAU,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,IAAI5D,WAAW,CAAC6D,sBAAsB,EAAE;MACtC1D,oBAAoB,CAAC0D,sBAAsB,GAAG;QAC5C,GAAG,IAAI,CAACnE,KAAK;QACbiE,IAAI,EAAG3D,WAAW,CAAC6D,sBAAsB,CAAmB/D,MAAM,CAAC8D,UAAU,CAAC;MAChF,CAAC;IACH;IAEA,OAAOzD,oBAAoB;EAC7B;AACF"}
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { RenderPipeline, cast, log, isObjectEmpty } from '@luma.gl/core';
3
2
  import { applyParametersToRenderPipelineDescriptor } from "../helpers/webgpu-parameters.js";
4
3
  import { getWebGPUTextureFormat } from "../helpers/convert-texture-format.js";
@@ -7,15 +6,15 @@ import { getVertexBufferLayout, getBufferSlots } from "../helpers/get-vertex-buf
7
6
  export class WebGPURenderPipeline extends RenderPipeline {
8
7
  constructor(device, props) {
9
8
  super(device, props);
10
- _defineProperty(this, "device", void 0);
11
- _defineProperty(this, "handle", void 0);
12
- _defineProperty(this, "vs", void 0);
13
- _defineProperty(this, "fs", null);
14
- _defineProperty(this, "_bufferSlots", void 0);
15
- _defineProperty(this, "_buffers", void 0);
16
- _defineProperty(this, "_indexBuffer", null);
17
- _defineProperty(this, "_bindGroupLayout", void 0);
18
- _defineProperty(this, "_bindGroup", null);
9
+ this.device = void 0;
10
+ this.handle = void 0;
11
+ this.vs = void 0;
12
+ this.fs = null;
13
+ this._bufferSlots = void 0;
14
+ this._buffers = void 0;
15
+ this._indexBuffer = null;
16
+ this._bindGroupLayout = void 0;
17
+ this._bindGroup = null;
19
18
  this.device = device;
20
19
  this.handle = this.props.handle || this.createHandle();
21
20
  this.handle.label = this.props.id;
@@ -28,7 +27,7 @@ export class WebGPURenderPipeline extends RenderPipeline {
28
27
  createHandle() {
29
28
  const descriptor = this._getRenderPipelineDescriptor();
30
29
  const renderPipeline = this.device.handle.createRenderPipeline(descriptor);
31
- log.groupCollapsed(1, "new WebGPRenderPipeline(".concat(this.id, ")"))();
30
+ log.groupCollapsed(1, `new WebGPRenderPipeline(${this.id})`)();
32
31
  log.log(1, JSON.stringify(descriptor, null, 2))();
33
32
  log.groupEnd(1)();
34
33
  return renderPipeline;
@@ -43,7 +42,7 @@ export class WebGPURenderPipeline extends RenderPipeline {
43
42
  if (bufferIndex >= 0) {
44
43
  this._buffers[bufferIndex] = buffer;
45
44
  } else {
46
- throw new Error("Setting attribute '".concat(name, "' not listed in shader layout for program ").concat(this.id));
45
+ throw new Error(`Setting attribute '${name}' not listed in shader layout for program ${this.id}`);
47
46
  }
48
47
  }
49
48
  }
@@ -87,7 +86,7 @@ export class WebGPURenderPipeline extends RenderPipeline {
87
86
  switch (this.props.topology) {
88
87
  case 'triangle-fan-webgl':
89
88
  case 'line-loop-webgl':
90
- throw new Error("WebGPU does not support primitive topology ".concat(this.props.topology));
89
+ throw new Error(`WebGPU does not support primitive topology ${this.props.topology}`);
91
90
  default:
92
91
  }
93
92
  const descriptor = {
@@ -124,7 +123,7 @@ export class WebGPURenderPipeline extends RenderPipeline {
124
123
  const buffer = cast(buffers[i]);
125
124
  if (!buffer) {
126
125
  const attribute = this.props.shaderLayout.attributes.find(attribute => attribute.location === i);
127
- throw new Error("No buffer provided for attribute '".concat((attribute === null || attribute === void 0 ? void 0 : attribute.name) || '', "' in Model '").concat(this.props.id, "'"));
126
+ throw new Error(`No buffer provided for attribute '${(attribute === null || attribute === void 0 ? void 0 : attribute.name) || ''}' in Model '${this.props.id}'`);
128
127
  }
129
128
  webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);
130
129
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-render-pipeline.js","names":["RenderPipeline","cast","log","isObjectEmpty","applyParametersToRenderPipelineDescriptor","getWebGPUTextureFormat","getBindGroup","getVertexBufferLayout","getBufferSlots","WebGPURenderPipeline","constructor","device","props","_defineProperty","handle","createHandle","label","id","vs","fs","_bufferSlots","shaderLayout","bufferLayout","_buffers","Array","Object","keys","length","fill","_bindGroupLayout","getBindGroupLayout","descriptor","_getRenderPipelineDescriptor","renderPipeline","createRenderPipeline","groupCollapsed","concat","JSON","stringify","groupEnd","destroy","setIndexBuffer","indexBuffer","_indexBuffer","setAttributes","attributes","name","buffer","entries","bufferIndex","Error","setConstantAttributes","setBindings","bindings","assign","_bindGroup","setUniforms","uniforms","_getBuffers","_getBindGroup","vertex","module","entryPoint","vsEntryPoint","buffers","fragment","_this$device","fsEntryPoint","targets","format","canvasContext","topology","primitive","layout","parameters","draw","options","webgpuRenderPass","renderPass","getDefaultRenderPass","setPipeline","bindGroup","setBindGroup","_setAttributeBuffers","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","indexType","i","attribute","find","location","setVertexBuffer"],"sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"sourcesContent":["// luma.gl MIT license\n\nimport type {TypedArray, Binding, UniformValue, RenderPass} from '@luma.gl/core';\nimport {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/core';\nimport {applyParametersToRenderPipelineDescriptor} from '../helpers/webgpu-parameters';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport {getBindGroup} from '../helpers/get-bind-group';\nimport {getVertexBufferLayout, getBufferSlots} from '../helpers/get-vertex-buffer-layout';\n// import {convertAttributesVertexBufferToLayout} from '../helpers/get-vertex-buffer-layout';\n// import {mapAccessorToWebGPUFormat} from './helpers/accessor-to-format';\n// import type {BufferAccessors} from './webgpu-pipeline';\n\nimport type {WebGPUDevice} from '../webgpu-device';\nimport 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 device: WebGPUDevice;\n handle: GPURenderPipeline;\n\n vs: WebGPUShader;\n fs: WebGPUShader | null = null;\n\n private _bufferSlots: Record<string, number>;\n private _buffers: Buffer[];\n private _indexBuffer: WebGPUBuffer | null = null;\n // private _firstIndex: number;\n // private _lastIndex: number;\n\n /** For internal use to create BindGroups */\n private _bindGroupLayout: GPUBindGroupLayout;\n private _bindGroup: GPUBindGroup | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPipelineProps) {\n super(device, props);\n this.device = device;\n this.handle = (this.props.handle as GPURenderPipeline) || this.createHandle();\n this.handle.label = this.props.id;\n\n this.vs = cast<WebGPUShader>(props.vs);\n this.fs = cast<WebGPUShader>(props.fs);\n\n this._bufferSlots = getBufferSlots(this.props.shaderLayout, this.props.bufferLayout);\n this._buffers = new Array<Buffer>(Object.keys(this._bufferSlots).length).fill(null);\n this._bindGroupLayout = this.handle.getBindGroupLayout(0);\n }\n\n protected createHandle(): GPURenderPipeline {\n const descriptor = this._getRenderPipelineDescriptor();\n const renderPipeline = this.device.handle.createRenderPipeline(descriptor);\n log.groupCollapsed(1, `new WebGPRenderPipeline(${this.id})`)();\n log.log(1, JSON.stringify(descriptor, null, 2))();\n log.groupEnd(1)();\n return renderPipeline;\n }\n\n override destroy(): void {\n // WebGPURenderPipeline has no destroy method.\n }\n\n setIndexBuffer(indexBuffer: Buffer): void {\n this._indexBuffer = cast<WebGPUBuffer>(indexBuffer);\n }\n\n setAttributes(attributes: Record<string, Buffer>): void {\n for (const [name, buffer] of Object.entries(attributes)) {\n const bufferIndex = this._bufferSlots[name];\n if (bufferIndex >= 0) {\n this._buffers[bufferIndex] = buffer;\n } else {\n throw new Error(\n `Setting attribute '${name}' not listed in shader layout for program ${this.id}`\n );\n }\n }\n // for (let i = 0; i < this._bufferSlots.length; ++i) {\n // const bufferName = this._bufferSlots[i];\n // if (attributes[bufferName]) {\n // this.handle\n // }\n // }\n }\n\n setConstantAttributes(attributes: Record<string, TypedArray>): void {\n throw new Error('not implemented');\n }\n\n setBindings(bindings: Record<string, Binding>): void {\n if (!isObjectEmpty(this.props.bindings)) {\n Object.assign(this.props.bindings, bindings);\n // Set up the bindings\n this._bindGroup = getBindGroup(\n this.device.handle,\n this._bindGroupLayout,\n this.props.shaderLayout,\n this.props.bindings\n );\n }\n }\n\n setUniforms(uniforms: Record<string, UniformValue>): void {\n if (!isObjectEmpty(uniforms)) {\n throw new Error('WebGPU does not support uniforms');\n }\n }\n\n _getBuffers() {\n return this._buffers;\n }\n\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n // assert(this._bindGroup);\n return this._bindGroup;\n }\n\n /** Populate the complex WebGPU GPURenderPipelineDescriptor */\n protected _getRenderPipelineDescriptor() {\n // Set up the vertex stage\n const vertex: GPUVertexState = {\n module: cast<WebGPUShader>(this.props.vs).handle,\n entryPoint: this.props.vsEntryPoint || 'main',\n buffers: getVertexBufferLayout(this.props.shaderLayout, this.props.bufferLayout)\n };\n\n // Set up the fragment stage\n let fragment: GPUFragmentState | undefined;\n if (this.props.fs) {\n fragment = {\n module: cast<WebGPUShader>(this.props.fs).handle,\n entryPoint: this.props.fsEntryPoint || 'main',\n targets: [\n {\n // TODO exclamation mark hack!\n format: getWebGPUTextureFormat(this.device?.canvasContext?.format)\n }\n ]\n };\n }\n\n // WebGPU has more restrictive topology support than WebGL\n switch (this.props.topology) {\n case 'triangle-fan-webgl':\n case 'line-loop-webgl':\n throw new Error(`WebGPU does not support primitive topology ${this.props.topology}`);\n default:\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: 'auto'\n };\n\n // Set parameters on the descriptor\n applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);\n\n return descriptor;\n }\n\n draw(options: {\n renderPass?: RenderPass;\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n const webgpuRenderPass: WebGPURenderPass =\n cast<WebGPURenderPass>(options.renderPass) || this.device.getDefaultRenderPass();\n\n // Set pipeline\n webgpuRenderPass.handle.setPipeline(this.handle);\n\n // Set bindings (uniform buffers, textures etc)\n const bindGroup = this._getBindGroup();\n if (bindGroup) {\n webgpuRenderPass.handle.setBindGroup(0, bindGroup);\n }\n\n // Set attributes\n this._setAttributeBuffers(webgpuRenderPass);\n\n // Draw\n if (options.indexCount) {\n webgpuRenderPass.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n webgpuRenderPass.handle.draw(\n options.vertexCount || 0,\n options.instanceCount,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n _setAttributeBuffers(webgpuRenderPass: WebGPURenderPass) {\n if (this._indexBuffer) {\n webgpuRenderPass.handle.setIndexBuffer(this._indexBuffer.handle, this._indexBuffer.props.indexType);\n }\n\n const buffers = this._getBuffers();\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = cast<WebGPUBuffer>(buffers[i]);\n if (!buffer) {\n const attribute = this.props.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"],"mappings":";AAGA,SAAgBA,cAAc,EAAuBC,IAAI,EAAEC,GAAG,EAAEC,aAAa,QAAO,eAAe;AAAC,SAC5FC,yCAAyC;AAAA,SACzCC,sBAAsB;AAAA,SACtBC,YAAY;AAAA,SACZC,qBAAqB,EAAEC,cAAc;AAa7C,OAAO,MAAMC,oBAAoB,SAAST,cAAc,CAAC;EAiBvDU,WAAWA,CAACC,MAAoB,EAAEC,KAA0B,EAAE;IAC5D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,aAbG,IAAI;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,uBAIc,IAAI;IAAAA,eAAA;IAAAA,eAAA,qBAMN,IAAI;IAI5C,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C,KAAK,IAAIkC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG5B,OAAO,CAACrC,MAAM,EAAE,EAAEiE,CAAC,EAAE;MACvC,MAAM7C,MAAM,GAAG9C,IAAI,CAAe+D,OAAO,CAAC4B,CAAC,CAAC,CAAC;MAC7C,IAAI,CAAC7C,MAAM,EAAE;QACX,MAAM8C,SAAS,GAAG,IAAI,CAACjF,KAAK,CAACS,YAAY,CAACwB,UAAU,CAACiD,IAAI,CACtDD,SAAS,IAAKA,SAAS,CAACE,QAAQ,KAAKH,CACxC,CAAC;QACD,MAAM,IAAI1C,KAAK,sCAAAd,MAAA,CACwB,CAAAyD,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAE/C,IAAI,KAAI,EAAE,kBAAAV,MAAA,CAAe,IAAI,CAACxB,KAAK,CAACK,EAAE,MACxF,CAAC;MACH;MACA4D,gBAAgB,CAAC/D,MAAM,CAACkF,eAAe,CAACJ,CAAC,EAAE7C,MAAM,CAACjC,MAAM,CAAC;IAC3D;EAsBF;AACF"}
1
+ {"version":3,"file":"webgpu-render-pipeline.js","names":["RenderPipeline","cast","log","isObjectEmpty","applyParametersToRenderPipelineDescriptor","getWebGPUTextureFormat","getBindGroup","getVertexBufferLayout","getBufferSlots","WebGPURenderPipeline","constructor","device","props","handle","vs","fs","_bufferSlots","_buffers","_indexBuffer","_bindGroupLayout","_bindGroup","createHandle","label","id","shaderLayout","bufferLayout","Array","Object","keys","length","fill","getBindGroupLayout","descriptor","_getRenderPipelineDescriptor","renderPipeline","createRenderPipeline","groupCollapsed","JSON","stringify","groupEnd","destroy","setIndexBuffer","indexBuffer","setAttributes","attributes","name","buffer","entries","bufferIndex","Error","setConstantAttributes","setBindings","bindings","assign","setUniforms","uniforms","_getBuffers","_getBindGroup","vertex","module","entryPoint","vsEntryPoint","buffers","fragment","_this$device","fsEntryPoint","targets","format","canvasContext","topology","primitive","layout","parameters","draw","options","webgpuRenderPass","renderPass","getDefaultRenderPass","setPipeline","bindGroup","setBindGroup","_setAttributeBuffers","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","indexType","i","attribute","find","location","setVertexBuffer"],"sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"sourcesContent":["// luma.gl MIT license\n\nimport type {TypedArray, Binding, UniformValue, RenderPass} from '@luma.gl/core';\nimport {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/core';\nimport {applyParametersToRenderPipelineDescriptor} from '../helpers/webgpu-parameters';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport {getBindGroup} from '../helpers/get-bind-group';\nimport {getVertexBufferLayout, getBufferSlots} from '../helpers/get-vertex-buffer-layout';\n// import {convertAttributesVertexBufferToLayout} from '../helpers/get-vertex-buffer-layout';\n// import {mapAccessorToWebGPUFormat} from './helpers/accessor-to-format';\n// import type {BufferAccessors} from './webgpu-pipeline';\n\nimport type {WebGPUDevice} from '../webgpu-device';\nimport 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 device: WebGPUDevice;\n handle: GPURenderPipeline;\n\n vs: WebGPUShader;\n fs: WebGPUShader | null = null;\n\n private _bufferSlots: Record<string, number>;\n private _buffers: Buffer[];\n private _indexBuffer: WebGPUBuffer | null = null;\n // private _firstIndex: number;\n // private _lastIndex: number;\n\n /** For internal use to create BindGroups */\n private _bindGroupLayout: GPUBindGroupLayout;\n private _bindGroup: GPUBindGroup | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPipelineProps) {\n super(device, props);\n this.device = device;\n this.handle = (this.props.handle as GPURenderPipeline) || this.createHandle();\n this.handle.label = this.props.id;\n\n this.vs = cast<WebGPUShader>(props.vs);\n this.fs = cast<WebGPUShader>(props.fs);\n\n this._bufferSlots = getBufferSlots(this.props.shaderLayout, this.props.bufferLayout);\n this._buffers = new Array<Buffer>(Object.keys(this._bufferSlots).length).fill(null);\n this._bindGroupLayout = this.handle.getBindGroupLayout(0);\n }\n\n protected createHandle(): GPURenderPipeline {\n const descriptor = this._getRenderPipelineDescriptor();\n const renderPipeline = this.device.handle.createRenderPipeline(descriptor);\n log.groupCollapsed(1, `new WebGPRenderPipeline(${this.id})`)();\n log.log(1, JSON.stringify(descriptor, null, 2))();\n log.groupEnd(1)();\n return renderPipeline;\n }\n\n override destroy(): void {\n // WebGPURenderPipeline has no destroy method.\n }\n\n setIndexBuffer(indexBuffer: Buffer): void {\n this._indexBuffer = cast<WebGPUBuffer>(indexBuffer);\n }\n\n setAttributes(attributes: Record<string, Buffer>): void {\n for (const [name, buffer] of Object.entries(attributes)) {\n const bufferIndex = this._bufferSlots[name];\n if (bufferIndex >= 0) {\n this._buffers[bufferIndex] = buffer;\n } else {\n throw new Error(\n `Setting attribute '${name}' not listed in shader layout for program ${this.id}`\n );\n }\n }\n // for (let i = 0; i < this._bufferSlots.length; ++i) {\n // const bufferName = this._bufferSlots[i];\n // if (attributes[bufferName]) {\n // this.handle\n // }\n // }\n }\n\n setConstantAttributes(attributes: Record<string, TypedArray>): void {\n throw new Error('not implemented');\n }\n\n setBindings(bindings: Record<string, Binding>): void {\n if (!isObjectEmpty(this.props.bindings)) {\n Object.assign(this.props.bindings, bindings);\n // Set up the bindings\n this._bindGroup = getBindGroup(\n this.device.handle,\n this._bindGroupLayout,\n this.props.shaderLayout,\n this.props.bindings\n );\n }\n }\n\n setUniforms(uniforms: Record<string, UniformValue>): void {\n if (!isObjectEmpty(uniforms)) {\n throw new Error('WebGPU does not support uniforms');\n }\n }\n\n _getBuffers() {\n return this._buffers;\n }\n\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n // assert(this._bindGroup);\n return this._bindGroup;\n }\n\n /** Populate the complex WebGPU GPURenderPipelineDescriptor */\n protected _getRenderPipelineDescriptor() {\n // Set up the vertex stage\n const vertex: GPUVertexState = {\n module: cast<WebGPUShader>(this.props.vs).handle,\n entryPoint: this.props.vsEntryPoint || 'main',\n buffers: getVertexBufferLayout(this.props.shaderLayout, this.props.bufferLayout)\n };\n\n // Set up the fragment stage\n let fragment: GPUFragmentState | undefined;\n if (this.props.fs) {\n fragment = {\n module: cast<WebGPUShader>(this.props.fs).handle,\n entryPoint: this.props.fsEntryPoint || 'main',\n targets: [\n {\n // TODO exclamation mark hack!\n format: getWebGPUTextureFormat(this.device?.canvasContext?.format)\n }\n ]\n };\n }\n\n // WebGPU has more restrictive topology support than WebGL\n switch (this.props.topology) {\n case 'triangle-fan-webgl':\n case 'line-loop-webgl':\n throw new Error(`WebGPU does not support primitive topology ${this.props.topology}`);\n default:\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: 'auto'\n };\n\n // Set parameters on the descriptor\n applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);\n\n return descriptor;\n }\n\n draw(options: {\n renderPass?: RenderPass;\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n const webgpuRenderPass: WebGPURenderPass =\n cast<WebGPURenderPass>(options.renderPass) || this.device.getDefaultRenderPass();\n\n // Set pipeline\n webgpuRenderPass.handle.setPipeline(this.handle);\n\n // Set bindings (uniform buffers, textures etc)\n const bindGroup = this._getBindGroup();\n if (bindGroup) {\n webgpuRenderPass.handle.setBindGroup(0, bindGroup);\n }\n\n // Set attributes\n this._setAttributeBuffers(webgpuRenderPass);\n\n // Draw\n if (options.indexCount) {\n webgpuRenderPass.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n webgpuRenderPass.handle.draw(\n options.vertexCount || 0,\n options.instanceCount,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n _setAttributeBuffers(webgpuRenderPass: WebGPURenderPass) {\n if (this._indexBuffer) {\n webgpuRenderPass.handle.setIndexBuffer(this._indexBuffer.handle, this._indexBuffer.props.indexType);\n }\n\n const buffers = this._getBuffers();\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = cast<WebGPUBuffer>(buffers[i]);\n if (!buffer) {\n const attribute = this.props.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"],"mappings":"AAGA,SAAgBA,cAAc,EAAuBC,IAAI,EAAEC,GAAG,EAAEC,aAAa,QAAO,eAAe;AAAC,SAC5FC,yCAAyC;AAAA,SACzCC,sBAAsB;AAAA,SACtBC,YAAY;AAAA,SACZC,qBAAqB,EAAEC,cAAc;AAa7C,OAAO,MAAMC,oBAAoB,SAAST,cAAc,CAAC;EAiBvDU,WAAWA,CAACC,MAAoB,EAAEC,KAA0B,EAAE;IAC5D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAAC,KAjBvBD,MAAM;IAAA,KACNE,MAAM;IAAA,KAENC,EAAE;IAAA,KACFC,EAAE,GAAwB,IAAI;IAAA,KAEtBC,YAAY;IAAA,KACZC,QAAQ;IAAA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AAG,IAAI,CAACN,WAAW,CAAC,CAAC;IAClC,KAAK,IAAIkC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG5B,OAAO,CAACjC,MAAM,EAAE,EAAE6D,CAAC,EAAE;MACvC,MAAM5C,MAAM,GAAG7C,IAAI,CAAe6D,OAAO,CAAC4B,CAAC,CAAC,CAAC;MAC7C,IAAI,CAAC5C,MAAM,EAAE;QACX,MAAM6C,SAAS,GAAG,IAAI,CAAC/E,KAAK,CAACY,YAAY,CAACoB,UAAU,CAACgD,IAAI,CACtDD,SAAS,IAAKA,SAAS,CAACE,QAAQ,KAAKH,CACxC,CAAC;QACD,MAAM,IAAIzC,KAAK,CACZ,qCAAoC,CAAA0C,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAE9C,IAAI,KAAI,EAAG,eAAc,IAAI,CAACjC,KAAK,CAACW,EAAG,GACzF,CAAC;MACH;MACAoD,gBAAgB,CAAC9D,MAAM,CAACiF,eAAe,CAACJ,CAAC,EAAE5C,MAAM,CAACjC,MAAM,CAAC;IAC3D;EAsBF;AACF"}
@@ -1,10 +1,9 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { Sampler } from '@luma.gl/core';
3
2
  export class WebGPUSampler extends Sampler {
4
3
  constructor(device, props) {
5
4
  super(device, props);
6
- _defineProperty(this, "device", void 0);
7
- _defineProperty(this, "handle", void 0);
5
+ this.device = void 0;
6
+ this.handle = void 0;
8
7
  this.device = device;
9
8
  const samplerProps = {
10
9
  ...this.props
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-sampler.js","names":["Sampler","WebGPUSampler","constructor","device","props","_defineProperty","samplerProps","type","compare","handle","createSampler","label","id","destroy"],"sources":["../../../src/adapter/resources/webgpu-sampler.ts"],"sourcesContent":["import {Sampler, SamplerProps} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\n\nexport type WebGPUSamplerProps = SamplerProps & {\n handle?: GPUSampler;\n}\n\n/**\n *\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\n const samplerProps: Partial<WebGPUSamplerProps> = {...this.props};\n if (samplerProps.type !== 'comparison-sampler') {\n delete samplerProps.compare;\n }\n\n this.handle = this.handle || this.device.handle.createSampler(samplerProps);\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {\n // this.handle.destroy();\n }\n}\n"],"mappings":";AAAA,SAAQA,OAAO,QAAqB,eAAe;AAUnD,OAAO,MAAMC,aAAa,SAASD,OAAO,CAAC;EAIzCE,WAAWA,CAACC,MAAoB,EAAEC,KAAyB,EAAE;IAC3D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IACrB,IAAI,CAACF,MAAM,GAAGA,MAAM;IAGpB,MAAMG,YAAyC,GAAG;MAAC,GAAG,IAAI,CAACF;IAAK,CAAC;IACjE,IAAIE,YAAY,CAACC,IAAI,KAAK,oBAAoB,EAAE;MAC9C,OAAOD,YAAY,CAACE,OAAO;IAC7B;IAEA,IAAI,CAACC,MAAM,GAAG,IAAI,CAACA,MAAM,IAAI,IAAI,CAACN,MAAM,CAACM,MAAM,CAACC,aAAa,CAACJ,YAAY,CAAC;IAC3E,IAAI,CAACG,MAAM,CAACE,KAAK,GAAG,IAAI,CAACP,KAAK,CAACQ,EAAE;EACnC;EAESC,OAAOA,CAAA,EAAS,CAEzB;AACF"}
1
+ {"version":3,"file":"webgpu-sampler.js","names":["Sampler","WebGPUSampler","constructor","device","props","handle","samplerProps","type","compare","createSampler","label","id","destroy"],"sources":["../../../src/adapter/resources/webgpu-sampler.ts"],"sourcesContent":["import {Sampler, SamplerProps} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\n\nexport type WebGPUSamplerProps = SamplerProps & {\n handle?: GPUSampler;\n}\n\n/**\n *\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\n const samplerProps: Partial<WebGPUSamplerProps> = {...this.props};\n if (samplerProps.type !== 'comparison-sampler') {\n delete samplerProps.compare;\n }\n\n this.handle = this.handle || this.device.handle.createSampler(samplerProps);\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {\n // this.handle.destroy();\n }\n}\n"],"mappings":"AAAA,SAAQA,OAAO,QAAqB,eAAe;AAUnD,OAAO,MAAMC,aAAa,SAASD,OAAO,CAAC;EAIzCE,WAAWA,CAACC,MAAoB,EAAEC,KAAyB,EAAE;IAC3D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAAC,KAJdD,MAAM;IAAA,KACNE,MAAM;IAIb,IAAI,CAACF,MAAM,GAAGA,MAAM;IAGpB,MAAMG,YAAyC,GAAG;MAAC,GAAG,IAAI,CAACF;IAAK,CAAC;IACjE,IAAIE,YAAY,CAACC,IAAI,KAAK,oBAAoB,EAAE;MAC9C,OAAOD,YAAY,CAACE,OAAO;IAC7B;IAEA,IAAI,CAACH,MAAM,GAAG,IAAI,CAACA,MAAM,IAAI,IAAI,CAACF,MAAM,CAACE,MAAM,CAACI,aAAa,CAACH,YAAY,CAAC;IAC3E,IAAI,CAACD,MAAM,CAACK,KAAK,GAAG,IAAI,CAACN,KAAK,CAACO,EAAE;EACnC;EAESC,OAAOA,CAAA,EAAS,CAEzB;AACF"}
@@ -1,10 +1,9 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { Shader, log } from '@luma.gl/core';
3
2
  export class WebGPUShader extends Shader {
4
3
  constructor(device, props) {
5
4
  super(device, props);
6
- _defineProperty(this, "device", void 0);
7
- _defineProperty(this, "handle", void 0);
5
+ this.device = void 0;
6
+ this.handle = void 0;
8
7
  this.device = device;
9
8
  this.device.handle.pushErrorScope('validation');
10
9
  this.handle = this.props.handle || this.createHandle();
@@ -15,8 +14,8 @@ export class WebGPUShader extends Shader {
15
14
  const error = await errorScope;
16
15
  if (error) {
17
16
  const shaderLog = await this.compilationInfo();
18
- log.error("Shader compilation error: ".concat(error.message), shaderLog)();
19
- throw new Error("Shader compilation error: ".concat(error.message));
17
+ log.error(`Shader compilation error: ${error.message}`, shaderLog)();
18
+ throw new Error(`Shader compilation error: ${error.message}`);
20
19
  }
21
20
  }
22
21
  destroy() {}
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-shader.js","names":["Shader","log","WebGPUShader","constructor","device","props","_defineProperty","handle","pushErrorScope","createHandle","label","id","_checkCompilationError","popErrorScope","errorScope","error","shaderLog","compilationInfo","concat","message","Error","destroy","source","stage","language","includes","createShaderModule","code","transform","glsl","glslang","compileGLSL","getCompilationInfo","messages"],"sources":["../../../src/adapter/resources/webgpu-shader.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {ShaderProps, CompilerMessage} from '@luma.gl/core';\nimport {Shader, log} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\n\nexport type WebGPUShaderProps = ShaderProps & {\n handle?: GPUShaderModule;\n};\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: WebGPUShaderProps) {\n super(device, props);\n this.device = device;\n\n this.device.handle.pushErrorScope('validation');\n\n this.handle = this.props.handle || this.createHandle();\n this.handle.label = this.props.id;\n\n this._checkCompilationError(this.device.handle.popErrorScope());\n }\n\n async _checkCompilationError(errorScope: Promise<GPUError | null>): Promise<void> {\n const error = await errorScope as GPUValidationError;\n if (error) {\n const shaderLog = await this.compilationInfo();\n log.error(`Shader compilation error: ${error.message}`, shaderLog)();\n // Note: Even though this error is asynchronous and thrown after the constructor completes,\n // it will result in a useful stack trace leading back to the constructor\n throw new Error(`Shader compilation error: ${error.message}`);\n }\n }\n\n override destroy(): void {\n // this.handle.destroy();\n }\n\n protected createHandle(): GPUShaderModule {\n const {source, stage} = this.props;\n\n let language = this.props.language;\n // Compile from src\n if (!language) {\n // wgsl uses C++ \"auto\" style arrow notation\n language = source.includes('->') ? 'wgsl' : 'glsl';\n }\n\n switch(language) {\n case 'wgsl':\n return this.device.handle.createShaderModule({code: source});\n case 'glsl':\n return this.device.handle.createShaderModule({\n code: source,\n // @ts-expect-error\n transform: (glsl) => this.device.glslang.compileGLSL(glsl, stage)\n });\n default:\n throw new Error(language);\n }\n }\n\n /** Returns compilation info for this shader */\n async compilationInfo(): Promise<readonly CompilerMessage[]> {\n const compilationInfo = await this.handle.getCompilationInfo();\n return compilationInfo.messages;\n }\n}\n"],"mappings":";AAGA,SAAQA,MAAM,EAAEC,GAAG,QAAO,eAAe;AAUzC,OAAO,MAAMC,YAAY,SAASF,MAAM,CAAC;EAIvCG,WAAWA,CAACC,MAAoB,EAAEC,KAAwB,EAAE;IAC1D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IACrB,IAAI,CAACF,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACA,MAAM,CAACG,MAAM,CAACC,cAAc,CAAC,YAAY,CAAC;IAE/C,IAAI,CAACD,MAAM,GAAG,IAAI,CAACF,KAAK,CAACE,MAAM,IAAI,IAAI,CAACE,YAAY,CAAC,CAAC;IACtD,IAAI,CAACF,MAAM,CAACG,KAAK,GAAG,IAAI,CAACL,KAAK,CAACM,EAAE;IAEjC,IAAI,CAACC,sBAAsB,CAAC,IAAI,CAACR,MAAM,CAACG,MAAM,CAACM,aAAa,CAAC,CAAC,CAAC;EACjE;EAEA,MAAMD,sBAAsBA,CAACE,UAAoC,EAAiB;IAChF,MAAMC,KAAK,GAAG,MAAMD,UAAgC;IACpD,IAAIC,KAAK,EAAE;MACT,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACC,eAAe,CAAC,CAAC;MAC9ChB,GAAG,CAACc,KAAK,8BAAAG,MAAA,CAA8BH,KAAK,CAACI,OAAO,GAAIH,SAAS,CAAC,CAAC,CAAC;MAGpE,MAAM,IAAII,KAAK,8BAAAF,MAAA,CAA8BH,KAAK,CAACI,OAAO,CAAE,CAAC;IAC/D;EACF;EAESE,OAAOA,CAAA,EAAS,CAEzB;EAEUZ,YAAYA,CAAA,EAAoB;IACxC,MAAM;MAACa,MAAM;MAAEC;IAAK,CAAC,GAAG,IAAI,CAAClB,KAAK;IAElC,IAAImB,QAAQ,GAAG,IAAI,CAACnB,KAAK,CAACmB,QAAQ;IAElC,IAAI,CAACA,QAAQ,EAAE;MAEbA,QAAQ,GAAGF,MAAM,CAACG,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,MAAM;IACpD;IAEA,QAAOD,QAAQ;MACb,KAAK,MAAM;QACT,OAAO,IAAI,CAACpB,MAAM,CAACG,MAAM,CAACmB,kBAAkB,CAAC;UAACC,IAAI,EAAEL;QAAM,CAAC,CAAC;MAC9D,KAAK,MAAM;QACT,OAAO,IAAI,CAAClB,MAAM,CAACG,MAAM,CAACmB,kBAAkB,CAAC;UAC3CC,IAAI,EAAEL,MAAM;UAEZM,SAAS,EAAGC,IAAI,IAAK,IAAI,CAACzB,MAAM,CAAC0B,OAAO,CAACC,WAAW,CAACF,IAAI,EAAEN,KAAK;QAClE,CAAC,CAAC;MACJ;QACE,MAAM,IAAIH,KAAK,CAACI,QAAQ,CAAC;IAC7B;EACF;EAGA,MAAMP,eAAeA,CAAA,EAAwC;IAC3D,MAAMA,eAAe,GAAG,MAAM,IAAI,CAACV,MAAM,CAACyB,kBAAkB,CAAC,CAAC;IAC9D,OAAOf,eAAe,CAACgB,QAAQ;EACjC;AACF"}
1
+ {"version":3,"file":"webgpu-shader.js","names":["Shader","log","WebGPUShader","constructor","device","props","handle","pushErrorScope","createHandle","label","id","_checkCompilationError","popErrorScope","errorScope","error","shaderLog","compilationInfo","message","Error","destroy","source","stage","language","includes","createShaderModule","code","transform","glsl","glslang","compileGLSL","getCompilationInfo","messages"],"sources":["../../../src/adapter/resources/webgpu-shader.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {ShaderProps, CompilerMessage} from '@luma.gl/core';\nimport {Shader, log} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\n\nexport type WebGPUShaderProps = ShaderProps & {\n handle?: GPUShaderModule;\n};\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: WebGPUShaderProps) {\n super(device, props);\n this.device = device;\n\n this.device.handle.pushErrorScope('validation');\n\n this.handle = this.props.handle || this.createHandle();\n this.handle.label = this.props.id;\n\n this._checkCompilationError(this.device.handle.popErrorScope());\n }\n\n async _checkCompilationError(errorScope: Promise<GPUError | null>): Promise<void> {\n const error = await errorScope as GPUValidationError;\n if (error) {\n const shaderLog = await this.compilationInfo();\n log.error(`Shader compilation error: ${error.message}`, shaderLog)();\n // Note: Even though this error is asynchronous and thrown after the constructor completes,\n // it will result in a useful stack trace leading back to the constructor\n throw new Error(`Shader compilation error: ${error.message}`);\n }\n }\n\n override destroy(): void {\n // this.handle.destroy();\n }\n\n protected createHandle(): GPUShaderModule {\n const {source, stage} = this.props;\n\n let language = this.props.language;\n // Compile from src\n if (!language) {\n // wgsl uses C++ \"auto\" style arrow notation\n language = source.includes('->') ? 'wgsl' : 'glsl';\n }\n\n switch(language) {\n case 'wgsl':\n return this.device.handle.createShaderModule({code: source});\n case 'glsl':\n return this.device.handle.createShaderModule({\n code: source,\n // @ts-expect-error\n transform: (glsl) => this.device.glslang.compileGLSL(glsl, stage)\n });\n default:\n throw new Error(language);\n }\n }\n\n /** Returns compilation info for this shader */\n async compilationInfo(): Promise<readonly CompilerMessage[]> {\n const compilationInfo = await this.handle.getCompilationInfo();\n return compilationInfo.messages;\n }\n}\n"],"mappings":"AAGA,SAAQA,MAAM,EAAEC,GAAG,QAAO,eAAe;A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Q;MACb,KAAK,MAAM;QACT,OAAO,IAAI,CAAClB,MAAM,CAACE,MAAM,CAACkB,kBAAkB,CAAC;UAACC,IAAI,EAAEL;QAAM,CAAC,CAAC;MAC9D,KAAK,MAAM;QACT,OAAO,IAAI,CAAChB,MAAM,CAACE,MAAM,CAACkB,kBAAkB,CAAC;UAC3CC,IAAI,EAAEL,MAAM;UAEZM,SAAS,EAAGC,IAAI,IAAK,IAAI,CAACvB,MAAM,CAACwB,OAAO,CAACC,WAAW,CAACF,IAAI,EAAEN,KAAK;QAClE,CAAC,CAAC;MACJ;QACE,MAAM,IAAIH,KAAK,CAACI,QAAQ,CAAC;IAC7B;EACF;EAGA,MAAMN,eAAeA,CAAA,EAAwC;IAC3D,MAAMA,eAAe,GAAG,MAAM,IAAI,CAACV,MAAM,CAACwB,kBAAkB,CAAC,CAAC;IAC9D,OAAOd,eAAe,CAACe,QAAQ;EACjC;AACF"}
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { Texture } from '@luma.gl/core';
3
2
  import { getWebGPUTextureFormat } from "../helpers/convert-texture-format.js";
4
3
  import { WebGPUSampler } from "./webgpu-sampler.js";
@@ -13,12 +12,12 @@ const BASE_DIMENSIONS = {
13
12
  export class WebGPUTexture extends Texture {
14
13
  constructor(device, props) {
15
14
  super(device, props);
16
- _defineProperty(this, "device", void 0);
17
- _defineProperty(this, "handle", void 0);
18
- _defineProperty(this, "view", void 0);
19
- _defineProperty(this, "sampler", void 0);
20
- _defineProperty(this, "height", void 0);
21
- _defineProperty(this, "width", void 0);
15
+ this.device = void 0;
16
+ this.handle = void 0;
17
+ this.view = void 0;
18
+ this.sampler = void 0;
19
+ this.height = void 0;
20
+ this.width = void 0;
22
21
  if (typeof this.props.format === 'number') {
23
22
  throw new Error('number format');
24
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-texture.js","names":["Texture","getWebGPUTextureFormat","WebGPUSampler","BASE_DIMENSIONS","WebGPUTexture","constructor","device","props","_defineProperty","format","Error","handle","createHandle","data","setData","width","height","sampler","view","createView","_this$props$data","_this$props$data2","createTexture","size","depthOrArrayLayers","depth","dimension","usage","mipLevelCount","mipLevels","sampleCount","samples","destroy","setSampler","options","setImage","source","sourceX","sourceY","mipLevel","x","y","z","aspect","colorSpace","premultipliedAlpha","queue","copyExternalImageToTexture","origin","texture"],"sources":["../../../src/adapter/resources/webgpu-texture.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {Texture, TextureProps, Sampler, SamplerProps} from '@luma.gl/core';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUSampler} from './webgpu-sampler';\n\nconst BASE_DIMENSIONS: Record<string, '1d' | '2d' | '3d'> = {\n '1d': '1d',\n '2d': '2d',\n '2d-array': '2d',\n 'cube': '2d',\n 'cube-array': '2d',\n '3d': '3d'\n};\n\nexport class WebGPUTexture extends Texture {\n readonly device: WebGPUDevice;\n readonly handle: GPUTexture;\n readonly view: GPUTextureView;\n sampler: WebGPUSampler;\n\n override height: number;\n override width: number;\n\n // static async createFromImageURL(src, usage = 0) {\n // const img = document.createElement('img');\n // img.src = src;\n // await img.decode();\n // return WebGPUTexture(img, usage);\n // }\n\n constructor(device: WebGPUDevice, props: TextureProps) {\n super(device, props);\n\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n this.device = device;\n this.handle = this.props.handle || this.createHandle();\n\n if (this.props.data) {\n this.setData({data: this.props.data} );\n }\n\n this.width = this.handle.width;\n this.height = this.handle.height;\n\n // Create a default sampler. This mimics the WebGL1 API where sampler props are stored on the texture\n // this.setSampler(props.sampler);\n this.sampler = props.sampler instanceof WebGPUSampler ? props.sampler : new WebGPUSampler(this.device, props.sampler);\n\n // TODO - To support texture arrays we need to create custom views...\n // But we are not ready to expose TextureViews to the public API.\n this.view = this.handle.createView({\n // format: this.props.format,\n // dimension: this.props.dimension,\n // aspect = \"all\";\n // baseMipLevel: 0;\n // mipLevelCount;\n // baseArrayLayer = 0;\n // arrayLayerCount;\n });\n }\n\n protected createHandle(): GPUTexture {\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n // Deduce size from data - TODO this is a hack\n // @ts-expect-error\n const width = this.props.width || this.props.data?.width || 1;\n // @ts-expect-error\n const height = this.props.height || this.props.data?.height || 1;\n\n return this.device.handle.createTexture({\n size: {\n width,\n height,\n depthOrArrayLayers: this.props.depth\n },\n dimension: BASE_DIMENSIONS[this.props.dimension],\n format: getWebGPUTextureFormat(this.props.format),\n usage: this.props.usage,\n mipLevelCount: this.props.mipLevels,\n sampleCount: this.props.samples\n });\n }\n\n override destroy(): void {\n this.handle.destroy();\n }\n\n /**\n * Set default sampler\n * Accept a sampler instance or set of props;\n */\n setSampler(sampler: Sampler | SamplerProps): this {\n this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n\n setData(options: {\n data: any;\n }) {\n return this.setImage({source: options.data});\n }\n\n /** Set image */\n setImage(options: {\n source: ImageBitmap | HTMLCanvasElement | OffscreenCanvas;\n width?: number;\n height?: number;\n depth?: number;\n sourceX?: number;\n sourceY?: number;\n mipLevel?: number;\n x?: number;\n y?: number;\n z?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'srgb';\n premultipliedAlpha?: boolean;\n }): {width: number, height: number} {\n const {\n source,\n width = options.source.width,\n height = options.source.height,\n depth = 1,\n sourceX = 0,\n sourceY = 0,\n mipLevel = 0,\n x = 0,\n y = 0,\n z = 0,\n aspect = 'all',\n colorSpace = 'srgb',\n premultipliedAlpha = false\n } = options;\n\n // TODO - max out width\n\n this.device.handle.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: this.handle,\n origin: [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [\n width,\n height,\n depth\n ]\n );\n return {width, height};\n }\n\n /*\n async readPixels() {\n const readbackBuffer = device.createBuffer({\n usage: Buffer.COPY_DST | Buffer.MAP_READ,\n size: 4 * textureWidth * textureHeight,\n });\n\n // Copy data from the texture to the buffer.\n const encoder = device.createCommandEncoder();\n encoder.copyTextureToBuffer(\n { texture },\n { buffer, rowPitch: textureWidth * 4 },\n [textureWidth, textureHeight],\n );\n device.submit([encoder.finish()]);\n\n // Get the data on the CPU.\n await buffer.mapAsync(GPUMapMode.READ);\n saveScreenshot(buffer.getMappedRange());\n buffer.unmap();\n }\n\n setImageData(imageData, usage): this {\n let data = null;\n\n const bytesPerRow = Math.ceil((img.width * 4) / 256) * 256;\n if (bytesPerRow == img.width * 4) {\n data = imageData.data;\n } else {\n data = new Uint8Array(bytesPerRow * img.height);\n let imagePixelIndex = 0;\n for (let y = 0; y < img.height; ++y) {\n for (let x = 0; x < img.width; ++x) {\n const i = x * 4 + y * bytesPerRow;\n data[i] = imageData.data[imagePixelIndex];\n data[i + 1] = imageData.data[imagePixelIndex + 1];\n data[i + 2] = imageData.data[imagePixelIndex + 2];\n data[i + 3] = imageData.data[imagePixelIndex + 3];\n imagePixelIndex += 4;\n }\n }\n }\n return this;\n }\n\n setData(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 setBuffer(textureDataBuffer, {bytesPerRow}): this {\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToTexture(\n {\n buffer: textureDataBuffer,\n bytesPerRow\n },\n {\n texture: this.handle\n },\n {\n width,\n height,\n depth\n }\n );\n\n this.device.handle.defaultQueue.submit([commandEncoder.finish()]);\n return this;\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,CAACI,MAAM,EAAEW,OAAO,CAAC;IACnG,OAAO,IAAI;EACb;EAEAH,OAAOA,CAACoB,OAEP,EAAE;IACD,OAAO,IAAI,CAACC,QAAQ,CAAC;MAACC,MAAM,EAAEF,OAAO,CAACrB;IAAI,CAAC,CAAC;EAC9C;EAGAsB,QAAQA,CAACD,OAcR,EAAmC;IAClC,MAAM;MACJE,MAAM;MACNrB,KAAK,GAAGmB,OAAO,CAACE,MAAM,CAACrB,KAAK;MAC5BC,MAAM,GAAGkB,OAAO,CAACE,MAAM,CAACpB,MAAM;MAC9BS,KAAK,GAAG,CAAC;MACTY,OAAO,GAAG,CAAC;MACXC,OAAO,GAAG,CAAC;MACXC,QAAQ,GAAG,CAAC;MACZC,CAAC,GAAG,CAAC;MACLC,CAAC,GAAG,CAAC;MACLC,CAAC,GAAG,CAAC;MACLC,MAAM,GAAG,KAAK;MACdC,UAAU,GAAG,MAAM;MACnBC,kBAAkB,GAAG;IACvB,CAAC,GAAGX,OAAO;IAIX,IAAI,CAAC5B,MAAM,CAACK,MAAM,CAACmC,KAAK,CAACC,0BAA0B,CAEjD;MACEX,MAAM;MACNY,MAAM,EAAE,CAACX,OAAO,EAAEC,OAAO;IAC3B,CAAC,EAED;MACEW,OAAO,EAAE,IAAI,CAACtC,MAAM;MACpBqC,MAAM,EAAE,CAACR,CAAC,EAAEC,CAAC,EAAEC,CAAC,CAAC;MACjBH,QAAQ;MACRI,MAAM;MACNC,UAAU;MACVC;IACF,CAAC,EAED,CACE9B,KAAK,EACLC,MAAM,EACNS,KAAK,CAET,CAAC;IACD,OAAO;MAACV,KAAK;MAAEC;IAAM,CAAC;EACxB;AAmFF"}
1
+ {"version":3,"file":"webgpu-texture.js","names":["Texture","getWebGPUTextureFormat","WebGPUSampler","BASE_DIMENSIONS","WebGPUTexture","constructor","device","props","handle","view","sampler","height","width","format","Error","createHandle","data","setData","createView","_this$props$data","_this$props$data2","createTexture","size","depthOrArrayLayers","depth","dimension","usage","mipLevelCount","mipLevels","sampleCount","samples","destroy","setSampler","options","setImage","source","sourceX","sourceY","mipLevel","x","y","z","aspect","colorSpace","premultipliedAlpha","queue","copyExternalImageToTexture","origin","texture"],"sources":["../../../src/adapter/resources/webgpu-texture.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {Texture, TextureProps, Sampler, SamplerProps} from '@luma.gl/core';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUSampler} from './webgpu-sampler';\n\nconst BASE_DIMENSIONS: Record<string, '1d' | '2d' | '3d'> = {\n '1d': '1d',\n '2d': '2d',\n '2d-array': '2d',\n 'cube': '2d',\n 'cube-array': '2d',\n '3d': '3d'\n};\n\nexport class WebGPUTexture extends Texture {\n readonly device: WebGPUDevice;\n readonly handle: GPUTexture;\n readonly view: GPUTextureView;\n sampler: WebGPUSampler;\n\n override height: number;\n override width: number;\n\n // static async createFromImageURL(src, usage = 0) {\n // const img = document.createElement('img');\n // img.src = src;\n // await img.decode();\n // return WebGPUTexture(img, usage);\n // }\n\n constructor(device: WebGPUDevice, props: TextureProps) {\n super(device, props);\n\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n this.device = device;\n this.handle = this.props.handle || this.createHandle();\n\n if (this.props.data) {\n this.setData({data: this.props.data} );\n }\n\n this.width = this.handle.width;\n this.height = this.handle.height;\n\n // Create a default sampler. This mimics the WebGL1 API where sampler props are stored on the texture\n // this.setSampler(props.sampler);\n this.sampler = props.sampler instanceof WebGPUSampler ? props.sampler : new WebGPUSampler(this.device, props.sampler);\n\n // TODO - To support texture arrays we need to create custom views...\n // But we are not ready to expose TextureViews to the public API.\n this.view = this.handle.createView({\n // format: this.props.format,\n // dimension: this.props.dimension,\n // aspect = \"all\";\n // baseMipLevel: 0;\n // mipLevelCount;\n // baseArrayLayer = 0;\n // arrayLayerCount;\n });\n }\n\n protected createHandle(): GPUTexture {\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n // Deduce size from data - TODO this is a hack\n // @ts-expect-error\n const width = this.props.width || this.props.data?.width || 1;\n // @ts-expect-error\n const height = this.props.height || this.props.data?.height || 1;\n\n return this.device.handle.createTexture({\n size: {\n width,\n height,\n depthOrArrayLayers: this.props.depth\n },\n dimension: BASE_DIMENSIONS[this.props.dimension],\n format: getWebGPUTextureFormat(this.props.format),\n usage: this.props.usage,\n mipLevelCount: this.props.mipLevels,\n sampleCount: this.props.samples\n });\n }\n\n override destroy(): void {\n this.handle.destroy();\n }\n\n /**\n * Set default sampler\n * Accept a sampler instance or set of props;\n */\n setSampler(sampler: Sampler | SamplerProps): this {\n this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n\n setData(options: {\n data: any;\n }) {\n return this.setImage({source: options.data});\n }\n\n /** Set image */\n setImage(options: {\n source: ImageBitmap | HTMLCanvasElement | OffscreenCanvas;\n width?: number;\n height?: number;\n depth?: number;\n sourceX?: number;\n sourceY?: number;\n mipLevel?: number;\n x?: number;\n y?: number;\n z?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'srgb';\n premultipliedAlpha?: boolean;\n }): {width: number, height: number} {\n const {\n source,\n width = options.source.width,\n height = options.source.height,\n depth = 1,\n sourceX = 0,\n sourceY = 0,\n mipLevel = 0,\n x = 0,\n y = 0,\n z = 0,\n aspect = 'all',\n colorSpace = 'srgb',\n premultipliedAlpha = false\n } = options;\n\n // TODO - max out width\n\n this.device.handle.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: this.handle,\n origin: [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [\n width,\n height,\n depth\n ]\n );\n return {width, height};\n }\n\n /*\n async readPixels() {\n const readbackBuffer = device.createBuffer({\n usage: Buffer.COPY_DST | Buffer.MAP_READ,\n size: 4 * textureWidth * textureHeight,\n });\n\n // Copy data from the texture to the buffer.\n const encoder = device.createCommandEncoder();\n encoder.copyTextureToBuffer(\n { texture },\n { buffer, rowPitch: textureWidth * 4 },\n [textureWidth, textureHeight],\n );\n device.submit([encoder.finish()]);\n\n // Get the data on the CPU.\n await buffer.mapAsync(GPUMapMode.READ);\n saveScreenshot(buffer.getMappedRange());\n buffer.unmap();\n }\n\n setImageData(imageData, usage): this {\n let data = null;\n\n const bytesPerRow = Math.ceil((img.width * 4) / 256) * 256;\n if (bytesPerRow == img.width * 4) {\n data = imageData.data;\n } else {\n data = new Uint8Array(bytesPerRow * img.height);\n let imagePixelIndex = 0;\n for (let y = 0; y < img.height; ++y) {\n for (let x = 0; x < img.width; ++x) {\n const i = x * 4 + y * bytesPerRow;\n data[i] = imageData.data[imagePixelIndex];\n data[i + 1] = imageData.data[imagePixelIndex + 1];\n data[i + 2] = imageData.data[imagePixelIndex + 2];\n data[i + 3] = imageData.data[imagePixelIndex + 3];\n imagePixelIndex += 4;\n }\n }\n }\n return this;\n }\n\n setData(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 setBuffer(textureDataBuffer, {bytesPerRow}): this {\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToTexture(\n {\n buffer: textureDataBuffer,\n bytesPerRow\n },\n {\n texture: this.handle\n },\n {\n width,\n height,\n depth\n }\n );\n\n this.device.handle.defaultQueue.submit([commandEncoder.finish()]);\n return this;\n }\n */\n}\n"],"mappings":"AACA,SAAQA,OAAO,QAA4C,eAAe;AAAC,SACnEC,sBAAsB;AAAA,SAEtBC,aAAa;AAErB,MAAMC,eAAmD,GAAG;EAC1D,I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O,IAAI,CAACC,QAAQ,CAAC;MAACC,MAAM,EAAEF,OAAO,CAACjB;IAAI,CAAC,CAAC;EAC9C;EAGAkB,QAAQA,CAACD,OAcR,EAAmC;IAClC,MAAM;MACJE,MAAM;MACNvB,KAAK,GAAGqB,OAAO,CAACE,MAAM,CAACvB,KAAK;MAC5BD,MAAM,GAAGsB,OAAO,CAACE,MAAM,CAACxB,MAAM;MAC9Ba,KAAK,GAAG,CAAC;MACTY,OAAO,GAAG,CAAC;MACXC,OAAO,GAAG,CAAC;MACXC,QAAQ,GAAG,CAAC;MACZC,CAAC,GAAG,CAAC;MACLC,CAAC,GAAG,CAAC;MACLC,CAAC,GAAG,CAAC;MACLC,MAAM,GAAG,KAAK;MACdC,UAAU,GAAG,MAAM;MACnBC,kBAAkB,GAAG;IACvB,CAAC,GAAGX,OAAO;IAIX,IAAI,CAAC3B,MAAM,CAACE,MAAM,CAACqC,KAAK,CAACC,0BAA0B,CAEjD;MACEX,MAAM;MACNY,MAAM,EAAE,CAACX,OAAO,EAAEC,OAAO;IAC3B,CAAC,EAED;MACEW,OAAO,EAAE,IAAI,CAACxC,MAAM;MACpBuC,MAAM,EAAE,CAACR,CAAC,EAAEC,CAAC,EAAEC,CAAC,CAAC;MACjBH,QAAQ;MACRI,MAAM;MACNC,UAAU;MACVC;IACF,CAAC,EAED,CACEhC,KAAK,EACLD,MAAM,EACNa,KAAK,CAET,CAAC;IACD,OAAO;MAACZ,KAAK;MAAED;IAAM,CAAC;EACxB;AAmFF"}
@@ -1,20 +1,19 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { CanvasContext, log } from '@luma.gl/core';
3
2
  import { getWebGPUTextureFormat } from "./helpers/convert-texture-format.js";
4
3
  import { WebGPUFramebuffer } from "./resources/webgpu-framebuffer.js";
5
4
  export class WebGPUCanvasContext extends CanvasContext {
6
5
  constructor(device, adapter, props) {
7
6
  super(props);
8
- _defineProperty(this, "device", void 0);
9
- _defineProperty(this, "gpuCanvasContext", void 0);
10
- _defineProperty(this, "format", void 0);
11
- _defineProperty(this, "depthStencilFormat", 'depth24plus');
12
- _defineProperty(this, "sampleCount", 1);
13
- _defineProperty(this, "depthStencilAttachment", null);
7
+ this.device = void 0;
8
+ this.gpuCanvasContext = void 0;
9
+ this.format = void 0;
10
+ this.depthStencilFormat = 'depth24plus';
11
+ this.sampleCount = 1;
12
+ this.depthStencilAttachment = null;
14
13
  this.device = device;
15
14
  this.width = -1;
16
15
  this.height = -1;
17
- this._setAutoCreatedCanvasId("".concat(this.device.id, "-canvas"));
16
+ this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
18
17
  this.gpuCanvasContext = this.canvas.getContext('webgpu');
19
18
  this.format = this.gpuCanvasContext.getPreferredFormat(adapter);
20
19
  }
@@ -52,7 +51,7 @@ export class WebGPUCanvasContext extends CanvasContext {
52
51
  colorSpace: this.props.colorSpace,
53
52
  alphaMode: this.props.alphaMode
54
53
  });
55
- log.log(1, "Resized to ".concat(this.width, "x").concat(this.height, "px"))();
54
+ log.log(1, `Resized to ${this.width}x${this.height}px`)();
56
55
  }
57
56
  }
58
57
  resize(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-canvas-context.js","names":["CanvasContext","log","getWebGPUTextureFormat","WebGPUFramebuffer","WebGPUCanvasContext","constructor","device","adapter","props","_defineProperty","width","height","_setAutoCreatedCanvasId","concat","id","gpuCanvasContext","canvas","getContext","format","getPreferredFormat","destroy","unconfigure","getCurrentFramebuffer","update","currentColorAttachment","createTexture","handle","getCurrentTexture","_createDepthStencilAttachment","colorAttachments","depthStencilAttachment","getPixelSize","sizeChanged","configure","colorSpace","alphaMode","resize","options","depthStencilFormat","usage","GPUTextureUsage","RENDER_ATTACHMENT"],"sources":["../../src/adapter/webgpu-canvas-context.ts"],"sourcesContent":["import type {Texture, TextureFormat, CanvasContextProps} from '@luma.gl/core';\nimport {CanvasContext, log} from '@luma.gl/core';\nimport {getWebGPUTextureFormat} from './helpers/convert-texture-format';\nimport {WebGPUDevice} from './webgpu-device';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\n\n/** \n * Holds a WebGPU Canvas Context which handles resizing etc \n */\nexport class WebGPUCanvasContext extends CanvasContext {\n readonly device: WebGPUDevice;\n readonly gpuCanvasContext: GPUCanvasContext;\n readonly format: TextureFormat;\n depthStencilFormat: TextureFormat = 'depth24plus';\n sampleCount: number = 1;\n\n private depthStencilAttachment: Texture | null = null;\n\n constructor(device: WebGPUDevice, adapter: GPUAdapter, props: CanvasContextProps) {\n super(props);\n this.device = device;\n // TODO - hack to trigger resize?\n this.width = -1;\n this.height = -1;\n \n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n // @ts-ignore TODO - we don't handle OffscreenRenderingContext.\n this.gpuCanvasContext = this.canvas.getContext('webgpu') ;\n // @ts-expect-error TODO this has been replaced\n this.format = this.gpuCanvasContext.getPreferredFormat(adapter);\n }\n\n destroy(): void {\n this.gpuCanvasContext.unconfigure();\n }\n\n /** Update framebuffer with properly resized \"swap chain\" texture views */\n getCurrentFramebuffer(): WebGPUFramebuffer {\n // Ensure the canvas context size is updated\n this.update();\n\n // Wrap the current canvas context texture in a luma.gl texture \n const currentColorAttachment = this.device.createTexture({\n id: 'default-render-target',\n handle: this.gpuCanvasContext.getCurrentTexture(),\n format: this.format,\n width: this.width,\n height: this.height\n });\n\n // Resize the depth stencil attachment\n this._createDepthStencilAttachment();\n\n return new WebGPUFramebuffer(this.device, {\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: this.depthStencilAttachment\n });\n }\n\n /** Resizes and updates render targets if necessary */\n update() {\n const [width, height] = this.getPixelSize();\n\n const sizeChanged = width !== this.width || height !== this.height;\n\n if (sizeChanged) {\n this.width = width;\n this.height = height;\n\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n\n // Reconfigure the canvas size.\n // https://www.w3.org/TR/webgpu/#canvas-configuration\n this.gpuCanvasContext.configure({\n device: this.device.handle,\n format: getWebGPUTextureFormat(this.format),\n // size: [this.width, this.height],\n colorSpace: this.props.colorSpace,\n alphaMode: this.props.alphaMode\n });\n\n log.log(1, `Resized to ${this.width}x${this.height}px`)();\n }\n\n }\n\n resize(options?: {width?: number; height?: number; useDevicePixels?: boolean | number}): void {\n this.update();\n }\n\n /** We build render targets on demand (i.e. not when size changes but when about to render) */\n _createDepthStencilAttachment() {\n if (!this.depthStencilAttachment) {\n this.depthStencilAttachment = this.device.createTexture({\n id: 'depth-stencil-target',\n format: this.depthStencilFormat,\n width: this.width,\n height: this.height,\n usage: GPUTextureUsage.RENDER_ATTACHMENT\n });\n }\n return this.depthStencilAttachment;\n }\n}\n"],"mappings":";AACA,SAAQA,aAAa,EAAEC,GAAG,QAAO,eAAe;AAAC,SACzCC,sBAAsB;AAAA,SAEtBC,iBAAiB;AAKzB,OAAO,MAAMC,mBAAmB,SAASJ,aAAa,CAAC;EASrDK,WAAWA,CAACC,MAAoB,EAAEC,OAAmB,EAAEC,KAAyB,EAAE;IAChF,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,6BANqB,aAAa;IAAAA,eAAA,sBAC3B,CAAC;IAAAA,eAAA,iCAE0B,IAAI;IAInD,IAAI,CAACH,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACI,KAAK,GAAG,CAAC,CAAC;IACf,IAAI,CAACC,MAAM,GAAG,CAAC,CAAC;IAEhB,IAAI,CAACC,uBAAuB,IAAAC,MAAA,CAAI,IAAI,CAACP,MAAM,CAACQ,EAAE,YAAS,CAAC;IAExD,IAAI,CAACC,gBAAgB,GAAG,IAAI,CAACC,MAAM,CAACC,UAAU,CAAC,QAAQ,CAAC;IAExD,IAAI,CAACC,MAAM,GAAG,IAAI,CAACH,gBAAgB,CAACI,kBAAkB,CAACZ,OAAO,CAAC;EACjE;EAEAa,OAAOA,CAAA,EAAS;IACd,IAAI,CAACL,gBAAgB,C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0B,UAAU;QACjCC,SAAS,EAAE,IAAI,CAAC3B,KAAK,CAAC2B;MACxB,CAAC,CAAC;MAEFlC,GAAG,CAACA,GAAG,CAAC,CAAC,gBAAAY,MAAA,CAAgB,IAAI,CAACH,KAAK,OAAAG,MAAA,CAAI,IAAI,CAACF,MAAM,OAAI,CAAC,CAAC,CAAC;IAC3D;EAEF;EAEAyB,MAAMA,CAACC,OAA+E,EAAQ;IAC5F,IAAI,CAACd,MAAM,CAAC,CAAC;EACf;EAGAK,6BAA6BA,CAAA,EAAG;IAC9B,IAAI,CAAC,IAAI,CAACE,sBAAsB,EAAE;MAChC,IAAI,CAACA,sBAAsB,GAAG,IAAI,CAACxB,MAAM,CAACmB,aAAa,CAAC;QACtDX,EAAE,EAAE,sBAAsB;QAC1BI,MAAM,EAAE,IAAI,CAACoB,kBAAkB;QAC/B5B,KAAK,EAAE,IAAI,CAACA,KAAK;QACjBC,MAAM,EAAE,IAAI,CAACA,MAAM;QACnB4B,KAAK,EAAEC,eAAe,CAACC;MACzB,CAAC,CAAC;IACJ;IACA,OAAO,IAAI,CAACX,sBAAsB;EACpC;AACF"}
1
+ {"version":3,"file":"webgpu-canvas-context.js","names":["CanvasContext","log","getWebGPUTextureFormat","WebGPUFramebuffer","WebGPUCanvasContext","constructor","device","adapter","props","gpuCanvasContext","format","depthStencilFormat","sampleCount","depthStencilAttachment","width","height","_setAutoCreatedCanvasId","id","canvas","getContext","getPreferredFormat","destroy","unconfigure","getCurrentFramebuffer","update","currentColorAttachment","createTexture","handle","getCurrentTexture","_createDepthStencilAttachment","colorAttachments","getPixelSize","sizeChanged","configure","colorSpace","alphaMode","resize","options","usage","GPUTextureUsage","RENDER_ATTACHMENT"],"sources":["../../src/adapter/webgpu-canvas-context.ts"],"sourcesContent":["import type {Texture, TextureFormat, CanvasContextProps} from '@luma.gl/core';\nimport {CanvasContext, log} from '@luma.gl/core';\nimport {getWebGPUTextureFormat} from './helpers/convert-texture-format';\nimport {WebGPUDevice} from './webgpu-device';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\n\n/** \n * Holds a WebGPU Canvas Context which handles resizing etc \n */\nexport class WebGPUCanvasContext extends CanvasContext {\n readonly device: WebGPUDevice;\n readonly gpuCanvasContext: GPUCanvasContext;\n readonly format: TextureFormat;\n depthStencilFormat: TextureFormat = 'depth24plus';\n sampleCount: number = 1;\n\n private depthStencilAttachment: Texture | null = null;\n\n constructor(device: WebGPUDevice, adapter: GPUAdapter, props: CanvasContextProps) {\n super(props);\n this.device = device;\n // TODO - hack to trigger resize?\n this.width = -1;\n this.height = -1;\n \n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n // @ts-ignore TODO - we don't handle OffscreenRenderingContext.\n this.gpuCanvasContext = this.canvas.getContext('webgpu') ;\n // @ts-expect-error TODO this has been replaced\n this.format = this.gpuCanvasContext.getPreferredFormat(adapter);\n }\n\n destroy(): void {\n this.gpuCanvasContext.unconfigure();\n }\n\n /** Update framebuffer with properly resized \"swap chain\" texture views */\n getCurrentFramebuffer(): WebGPUFramebuffer {\n // Ensure the canvas context size is updated\n this.update();\n\n // Wrap the current canvas context texture in a luma.gl texture \n const currentColorAttachment = this.device.createTexture({\n id: 'default-render-target',\n handle: this.gpuCanvasContext.getCurrentTexture(),\n format: this.format,\n width: this.width,\n height: this.height\n });\n\n // Resize the depth stencil attachment\n this._createDepthStencilAttachment();\n\n return new WebGPUFramebuffer(this.device, {\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: this.depthStencilAttachment\n });\n }\n\n /** Resizes and updates render targets if necessary */\n update() {\n const [width, height] = this.getPixelSize();\n\n const sizeChanged = width !== this.width || height !== this.height;\n\n if (sizeChanged) {\n this.width = width;\n this.height = height;\n\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n\n // Reconfigure the canvas size.\n // https://www.w3.org/TR/webgpu/#canvas-configuration\n this.gpuCanvasContext.configure({\n device: this.device.handle,\n format: getWebGPUTextureFormat(this.format),\n // size: [this.width, this.height],\n colorSpace: this.props.colorSpace,\n alphaMode: this.props.alphaMode\n });\n\n log.log(1, `Resized to ${this.width}x${this.height}px`)();\n }\n\n }\n\n resize(options?: {width?: number; height?: number; useDevicePixels?: boolean | number}): void {\n this.update();\n }\n\n /** We build render targets on demand (i.e. not when size changes but when about to render) */\n _createDepthStencilAttachment() {\n if (!this.depthStencilAttachment) {\n this.depthStencilAttachment = this.device.createTexture({\n id: 'depth-stencil-target',\n format: this.depthStencilFormat,\n width: this.width,\n height: this.height,\n usage: GPUTextureUsage.RENDER_ATTACHMENT\n });\n }\n return this.depthStencilAttachment;\n }\n}\n"],"mappings":"AACA,SAAQA,aAAa,EAAEC,GAAG,QAAO,eAAe;AAAC,SACzCC,sBAAsB;AAAA,SAEtBC,iBAAiB;AAKzB,OAAO,MAAMC,mBAAmB,SAASJ,aAAa,CAAC;EASrDK,WAAWA,CAACC,MAAoB,EAAEC,OAAmB,EAAEC,KAAyB,EAAE;IAChF,KAAK,CAACA,KAAK,CAAC;IAAC,KATNF,MAAM;IAAA,KACNG,gBAAgB;IAAA,KAChBC,MAAM;IAAA,KACfC,kBAAkB,GAAkB,aAAa;IAAA,KACjDC,WAAW,GAAW,CAAC;IAAA,KAEfC,sBAAsB,GAAmB,IAAI;IAInD,IAAI,CAACP,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACQ,KAAK,GAAG,CAAC,CAAC;IACf,IAAI,CAACC,MAAM,GAAG,CAAC,CAAC;IAEhB,IAAI,CAACC,uBAAuB,CAAE,GAAE,IAAI,CAACV,MAAM,CAACW,EAAG,SAAQ,CAAC;IAExD,IAAI,CAACR,gBAAgB,GAAG,IAAI,CAACS,MAAM,CAACC,UAAU,CAAC,QAAQ,CAAC;IAExD,IAAI,CAACT,MAAM,GAAG,IAAI,CAACD,gBAAgB,CAACW,kBAAkB,CAACb,OAAO,CAAC;EACjE;EAEAc,OAAOA,CAAA,EAAS;IACd,IAAI,CAACZ,gBAA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AK,CAAC0B,UAAU;QACjCC,SAAS,EAAE,IAAI,CAAC3B,KAAK,CAAC2B;MACxB,CAAC,CAAC;MAEFlC,GAAG,CAACA,GAAG,CAAC,CAAC,EAAG,cAAa,IAAI,CAACa,KAAM,IAAG,IAAI,CAACC,MAAO,IAAG,CAAC,CAAC,CAAC;IAC3D;EAEF;EAEAqB,MAAMA,CAACC,OAA+E,EAAQ;IAC5F,IAAI,CAACb,MAAM,CAAC,CAAC;EACf;EAGAK,6BAA6BA,CAAA,EAAG;IAC9B,IAAI,CAAC,IAAI,CAAChB,sBAAsB,EAAE;MAChC,IAAI,CAACA,sBAAsB,GAAG,IAAI,CAACP,MAAM,CAACoB,aAAa,CAAC;QACtDT,EAAE,EAAE,sBAAsB;QAC1BP,MAAM,EAAE,IAAI,CAACC,kBAAkB;QAC/BG,KAAK,EAAE,IAAI,CAACA,KAAK;QACjBC,MAAM,EAAE,IAAI,CAACA,MAAM;QACnBuB,KAAK,EAAEC,eAAe,CAACC;MACzB,CAAC,CAAC;IACJ;IACA,OAAO,IAAI,CAAC3B,sBAAsB;EACpC;AACF"}
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { Device, CanvasContext, log, uid } from '@luma.gl/core';
3
2
  import { WebGPUBuffer } from "./resources/webgpu-buffer.js";
4
3
  import { WebGPUTexture } from "./resources/webgpu-texture.js";
@@ -46,15 +45,15 @@ export class WebGPUDevice extends Device {
46
45
  ...props,
47
46
  id: props.id || uid('webgpu-device')
48
47
  });
49
- _defineProperty(this, "handle", void 0);
50
- _defineProperty(this, "adapter", void 0);
51
- _defineProperty(this, "lost", void 0);
52
- _defineProperty(this, "canvasContext", null);
53
- _defineProperty(this, "commandEncoder", null);
54
- _defineProperty(this, "renderPass", null);
55
- _defineProperty(this, "_info", void 0);
56
- _defineProperty(this, "_isLost", false);
57
- _defineProperty(this, "features", void 0);
48
+ this.handle = void 0;
49
+ this.adapter = void 0;
50
+ this.lost = void 0;
51
+ this.canvasContext = null;
52
+ this.commandEncoder = null;
53
+ this.renderPass = null;
54
+ this._info = void 0;
55
+ this._isLost = false;
56
+ this.features = void 0;
58
57
  this.handle = device;
59
58
  this.adapter = adapter;
60
59
  this._info = {
@@ -222,5 +221,5 @@ export class WebGPUDevice extends Device {
222
221
  }, [width, height, depth]);
223
222
  }
224
223
  }
225
- _defineProperty(WebGPUDevice, "type", 'webgpu');
224
+ WebGPUDevice.type = 'webgpu';
226
225
  //# sourceMappingURL=webgpu-device.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-device.js","names":["Device","CanvasContext","log","uid","WebGPUBuffer","WebGPUTexture","WebGPUExternalTexture","WebGPUSampler","WebGPUShader","WebGPURenderPipeline","WebGPUComputePipeline","WebGPURenderPass","WebGPUComputePass","WebGPUCanvasContext","WebGPUDevice","isSupported","Boolean","navigator","gpu","create","props","Error","groupCollapsed","adapter","requestAdapter","powerPreference","adapterInfo","requestAdapterInfo","probe","gpuDevice","requestDevice","requiredFeatures","features","canvas","pageLoaded","device","info","table","groupEnd","constructor","id","_defineProperty","handle","_info","type","vendor","__brand","renderer","version","shadingLanguages","shadingLanguageVersions","glsl","wgsl","vendorMasked","rendererMasked","lost","Promise","resolve","lostInfo","_isLost","reason","message","canvasContext","_getFeatures","destroy","limits","isTextureFormatSupported","format","includes","isTextureFormatFilterable","isTextureFormatRenderable","isLost","createBuffer","newProps","_getBufferProps","_createTexture","createExternalTexture","createShader","createSampler","createRenderPipeline","createFramebuffer","createComputePipeline","beginRenderPass","commandEncoder","createCommandEncoder","beginComputePass","createCanvasContext","getDefaultRenderPass","_this$canvasContext","renderPass","framebuffer","getCurrentFramebuffer","submit","_this$renderPass","_this$commandEncoder","end","commandBuffer","finish","queue","Set","has","delete","add","copyExternalImageToTexture","options","_this$handle","source","sourceX","sourceY","texture","mipLevel","aspect","colorSpace","premultipliedAlpha","width","height","depth","webGpuTexture","origin"],"sources":["../../src/adapter/webgpu-device.ts"],"sourcesContent":["// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n BufferProps,\n SamplerProps,\n ShaderProps,\n Texture,\n TextureProps,\n TextureFormat,\n ExternalTextureProps,\n FramebufferProps,\n RenderPipelineProps,\n ComputePipelineProps,\n RenderPassProps,\n ComputePassProps,\n // CommandEncoderProps\n} from '@luma.gl/core';\nimport {Device, CanvasContext, log, uid} from '@luma.gl/core';\nimport {WebGPUBuffer} from './resources/webgpu-buffer';\nimport {WebGPUTexture} from './resources/webgpu-texture';\nimport {WebGPUExternalTexture} from './resources/webgpu-external-texture';\nimport {WebGPUSampler} from './resources/webgpu-sampler';\nimport {WebGPUShader} from './resources/webgpu-shader';\nimport {WebGPURenderPipeline} from './resources/webgpu-render-pipeline';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\nimport {WebGPUComputePipeline} from './resources/webgpu-compute-pipeline';\nimport {WebGPURenderPass} from './resources/webgpu-render-pass';\nimport {WebGPUComputePass} from './resources/webgpu-compute-pass';\n// import {WebGPUCommandEncoder} from './resources/webgpu-command-encoder';\n\nimport {WebGPUCanvasContext} from './webgpu-canvas-context';\n// import {loadGlslangModule} from '../glsl/glslang';\n\n/** WebGPU Device implementation */\nexport class WebGPUDevice extends Device {\n readonly handle: GPUDevice;\n readonly adapter: GPUAdapter;\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n canvasContext: WebGPUCanvasContext | null = null;\n\n commandEncoder: GPUCommandEncoder | null = null;\n renderPass: WebGPURenderPass | null = null;\n\n private _info: DeviceInfo;\n private _isLost: boolean = false;\n\n static type: string = 'webgpu';\n\n /** Check if WebGPU is available */\n static isSupported(): boolean {\n return Boolean(typeof navigator !== 'undefined' && navigator.gpu);\n }\n\n static async create(props: DeviceProps): Promise<WebGPUDevice> {\n if (!navigator.gpu) {\n throw new Error(\n 'WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu'\n );\n }\n log.groupCollapsed(1, 'WebGPUDevice created')();\n const adapter = await navigator.gpu.requestAdapter({\n powerPreference: 'high-performance'\n // forceSoftware: false\n });\n if (!adapter) {\n throw new Error('Failed to request WebGPU adapter');\n }\n\n const adapterInfo = await adapter.requestAdapterInfo();\n log.probe(1, 'Adapter available', adapterInfo)();\n\n const gpuDevice = await adapter.requestDevice({\n requiredFeatures: adapter.features as ReadonlySet<GPUFeatureName>\n // TODO ensure we obtain best limits\n // requiredLimits: adapter.limits\n });\n log.probe(1, 'GPUDevice available')();\n\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n log.probe(1, 'DOM is loaded')();\n }\n\n const device = new WebGPUDevice(gpuDevice, adapter, props);\n log.probe(1, 'Device created', device.info)();\n log.table(1, device.info)();\n log.groupEnd(1)();\n return device;\n }\n\n constructor(device: GPUDevice, adapter: GPUAdapter, props: DeviceProps) {\n super({...props, id: props.id || uid('webgpu-device')});\n this.handle = device;\n this.adapter = adapter;\n\n this._info = {\n type: 'webgpu',\n vendor: this.adapter.__brand,\n renderer: '',\n version: '',\n gpu: 'unknown', // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',\n shadingLanguages: ['glsl', 'wgsl'],\n shadingLanguageVersions: {\n glsl: '450',\n wgsl: '100'\n },\n vendorMasked: '',\n rendererMasked: ''\n };\n\n // \"Context\" loss handling\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(async (resolve) => {\n const lostInfo = await this.handle.lost;\n this._isLost = true;\n resolve({reason: 'destroyed', message: lostInfo.message});\n });\n\n // Note: WebGPU devices can be created without a canvas, for compute shader purposes\n if (props.canvas) {\n this.canvasContext = new WebGPUCanvasContext(this, this.adapter, {canvas: props.canvas});\n }\n\n this.features = this._getFeatures();\n }\n\n // TODO\n // Load the glslang module now so that it is available synchronously when compiling shaders\n // const {glsl = true} = props;\n // this.glslang = glsl && await loadGlslangModule();\n\n destroy(): void {\n this.handle.destroy();\n }\n\n get info(): DeviceInfo {\n return this._info;\n }\n\n features: Set<DeviceFeature>;\n\n get limits(): DeviceLimits {\n return this.handle.limits;\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return !format.includes('webgl');\n }\n\n /** @todo implement proper check? */\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n /** @todo implement proper check? */\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n get isLost(): boolean {\n return this._isLost;\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer {\n const newProps = this._getBufferProps(props);\n return new WebGPUBuffer(this, newProps);\n }\n\n _createTexture(props: TextureProps): WebGPUTexture {\n return new WebGPUTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): WebGPUExternalTexture {\n return new WebGPUExternalTexture(this, props);\n }\n\n createShader(props: ShaderProps): WebGPUShader {\n return new WebGPUShader(this, props);\n }\n\n createSampler(props: SamplerProps): WebGPUSampler {\n return new WebGPUSampler(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WebGPURenderPipeline {\n return new WebGPURenderPipeline(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WebGPUFramebuffer {\n throw new Error('Not implemented');\n }\n\n createComputePipeline(props: ComputePipelineProps): WebGPUComputePipeline {\n return new WebGPUComputePipeline(this, props);\n }\n\n // WebGPU specifics\n\n /**\n * Allows a render pass to begin against a canvas context\n * @todo need to support a \"Framebuffer\" equivalent (aka preconfigured RenderPassDescriptors?).\n */\n beginRenderPass(props: RenderPassProps): WebGPURenderPass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPURenderPass(this, props);\n }\n\n beginComputePass(props: ComputePassProps): WebGPUComputePass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPUComputePass(this, props);\n }\n\n // createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {\n // return new WebGPUCommandEncoder(this, props);\n // }\n\n createCanvasContext(props: CanvasContextProps): WebGPUCanvasContext {\n return new WebGPUCanvasContext(this, this.adapter, props);\n }\n\n /**\n * Gets default renderpass encoder.\n * Creates a new encoder against default canvasContext if not already created\n * @note Called internally by Model.\n */\n getDefaultRenderPass(): WebGPURenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext?.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\n\n submit(): void {\n this.renderPass?.end();\n const commandBuffer = this.commandEncoder?.finish();\n if (commandBuffer) {\n this.handle.queue.submit([commandBuffer]);\n }\n this.commandEncoder = null;\n this.renderPass = null;\n }\n\n _getFeatures() {\n // WebGPU Features\n const features = new Set<DeviceFeature>(this.handle.features as Set<DeviceFeature>);\n\n // Fixups for pre-standard names: https://github.com/webgpu-native/webgpu-headers/issues/133\n // @ts-expect-error Chrome Canary v99\n if (features.has('depth-clamping')) {\n // @ts-expect-error Chrome Canary v99\n features.delete('depth-clamping');\n features.add('depth-clip-control');\n }\n\n // Add subsets\n if (features.has('texture-compression-bc')) {\n features.add('texture-compression-bc5-webgl');\n }\n\n features.add('webgpu');\n\n features.add('timer-query-webgl');\n\n // WEBGL1 SUPPORT\n features.add('vertex-array-object-webgl1');\n features.add('instanced-rendering-webgl1');\n features.add('multiple-render-targets-webgl1');\n features.add('index-uint32-webgl1');\n features.add('blend-minmax-webgl1');\n features.add('texture-blend-float-webgl1');\n\n // TEXTURES, RENDERBUFFERS\n features.add('texture-formats-srgb-webgl1');\n\n // TEXTURES\n features.add('texture-formats-depth-webgl1');\n features.add('texture-formats-float32-webgl1');\n features.add('texture-formats-float16-webgl1');\n\n features.add('texture-filter-linear-float32-webgl');\n features.add('texture-filter-linear-float16-webgl');\n features.add('texture-filter-anisotropic-webgl');\n\n // FRAMEBUFFERS, TEXTURES AND RENDERBUFFERS\n features.add('texture-renderable-rgba32float-webgl');\n features.add('texture-renderable-float32-webgl');\n features.add('texture-renderable-float16-webgl');\n\n // GLSL extensions\n features.add('glsl-frag-data');\n features.add('glsl-frag-depth');\n features.add('glsl-derivatives');\n features.add('glsl-texture-lod');\n\n return features;\n }\n\n copyExternalImageToTexture(options: {\n texture: Texture;\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'display-p3' | 'srgb';\n premultipliedAlpha?: boolean;\n\n source: ImageBitmap | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas;\n sourceX?: number;\n sourceY?: number;\n\n width?: number;\n height?: number;\n depth?: number;\n }): void {\n const {\n source,\n sourceX = 0,\n sourceY = 0,\n\n texture,\n mipLevel = 0,\n aspect = 'all',\n colorSpace = 'display-p3',\n premultipliedAlpha = false,\n // destinationX,\n // destinationY,\n // desitnationZ,\n\n width = texture.width,\n height = texture.height,\n depth = 1\n } = options;\n\n const webGpuTexture = texture as WebGPUTexture;\n\n this.handle?.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: webGpuTexture.handle,\n origin: [0, 0, 0], // [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [\n width,\n height,\n depth\n ]\n )\n }\n}\n"],"mappings":";AAuBA,SAAQA,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,QAAO,eAAe;AAAC,SACtDC,YAAY;AAAA,SACZC,aAAa;AAAA,SACbC,qBAAqB;AAAA,SACrBC,aAAa;AAAA,SACbC,YAAY;AAAA,SACZC,oBAAoB;AAAA,SAEpBC,qBAAqB;AAAA,SACrBC,gBAAgB;AAAA,SAChBC,iBAAiB;AAAA,SAGjBC,mBAAmB;AAI3B,OAAO,MAAMC,YAAY,SAASd,MAAM,CAAC;EAevC,OAAOe,WAAWA,CAAA,EAAY;IAC5B,OAAOC,OAAO,CAAC,OAAOC,SAAS,KAAK,WAAW,IAAIA,S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uBAAXA,YAAA,CAAaP,KAAK,CAACK,0BAA0B,CAE3C;MACEG,MAAM;MACNY,MAAM,EAAE,CAACX,OAAO,EAAEC,OAAO;IAC3B,CAAC,EAED;MACEC,OAAO,EAAEQ,aAAa,CAAC3E,MAAM;MAC7B4E,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;MACjBR,QAAQ;MACRC,MAAM;MACNC,UAAU;MACVC;IACF,CAAC,EAED,CACEC,KAAK,EACLC,MAAM,EACNC,KAAK,CAET,CAAC;EACH;AACF;AAAC3E,eAAA,CAnUY3B,YAAY,UAYD,QAAQ"}
1
+ {"version":3,"file":"webgpu-device.js","names":["Device","CanvasContext","log","uid","WebGPUBuffer","WebGPUTexture","WebGPUExternalTexture","WebGPUSampler","WebGPUShader","WebGPURenderPipeline","WebGPUComputePipeline","WebGPURenderPass","WebGPUComputePass","WebGPUCanvasContext","WebGPUDevice","isSupported","Boolean","navigator","gpu","create","props","Error","groupCollapsed","adapter","requestAdapter","powerPreference","adapterInfo","requestAdapterInfo","probe","gpuDevice","requestDevice","requiredFeatures","features","canvas","pageLoaded","device","info","table","groupEnd","constructor","id","handle","lost","canvasContext","commandEncoder","renderPass","_info","_isLost","type","vendor","__brand","renderer","version","shadingLanguages","shadingLanguageVersions","glsl","wgsl","vendorMasked","rendererMasked","Promise","resolve","lostInfo","reason","message","_getFeatures","destroy","limits","isTextureFormatSupported","format","includes","isTextureFormatFilterable","isTextureFormatRenderable","isLost","createBuffer","newProps","_getBufferProps","_createTexture","createExternalTexture","createShader","createSampler","createRenderPipeline","createFramebuffer","createComputePipeline","beginRenderPass","createCommandEncoder","beginComputePass","createCanvasContext","getDefaultRenderPass","_this$canvasContext","framebuffer","getCurrentFramebuffer","submit","_this$renderPass","_this$commandEncoder","end","commandBuffer","finish","queue","Set","has","delete","add","copyExternalImageToTexture","options","_this$handle","source","sourceX","sourceY","texture","mipLevel","aspect","colorSpace","premultipliedAlpha","width","height","depth","webGpuTexture","origin"],"sources":["../../src/adapter/webgpu-device.ts"],"sourcesContent":["// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n BufferProps,\n SamplerProps,\n ShaderProps,\n Texture,\n TextureProps,\n TextureFormat,\n ExternalTextureProps,\n FramebufferProps,\n RenderPipelineProps,\n ComputePipelineProps,\n RenderPassProps,\n ComputePassProps,\n // CommandEncoderProps\n} from '@luma.gl/core';\nimport {Device, CanvasContext, log, uid} from '@luma.gl/core';\nimport {WebGPUBuffer} from './resources/webgpu-buffer';\nimport {WebGPUTexture} from './resources/webgpu-texture';\nimport {WebGPUExternalTexture} from './resources/webgpu-external-texture';\nimport {WebGPUSampler} from './resources/webgpu-sampler';\nimport {WebGPUShader} from './resources/webgpu-shader';\nimport {WebGPURenderPipeline} from './resources/webgpu-render-pipeline';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\nimport {WebGPUComputePipeline} from './resources/webgpu-compute-pipeline';\nimport {WebGPURenderPass} from './resources/webgpu-render-pass';\nimport {WebGPUComputePass} from './resources/webgpu-compute-pass';\n// import {WebGPUCommandEncoder} from './resources/webgpu-command-encoder';\n\nimport {WebGPUCanvasContext} from './webgpu-canvas-context';\n// import {loadGlslangModule} from '../glsl/glslang';\n\n/** WebGPU Device implementation */\nexport class WebGPUDevice extends Device {\n readonly handle: GPUDevice;\n readonly adapter: GPUAdapter;\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n canvasContext: WebGPUCanvasContext | null = null;\n\n commandEncoder: GPUCommandEncoder | null = null;\n renderPass: WebGPURenderPass | null = null;\n\n private _info: DeviceInfo;\n private _isLost: boolean = false;\n\n static type: string = 'webgpu';\n\n /** Check if WebGPU is available */\n static isSupported(): boolean {\n return Boolean(typeof navigator !== 'undefined' && navigator.gpu);\n }\n\n static async create(props: DeviceProps): Promise<WebGPUDevice> {\n if (!navigator.gpu) {\n throw new Error(\n 'WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu'\n );\n }\n log.groupCollapsed(1, 'WebGPUDevice created')();\n const adapter = await navigator.gpu.requestAdapter({\n powerPreference: 'high-performance'\n // forceSoftware: false\n });\n if (!adapter) {\n throw new Error('Failed to request WebGPU adapter');\n }\n\n const adapterInfo = await adapter.requestAdapterInfo();\n log.probe(1, 'Adapter available', adapterInfo)();\n\n const gpuDevice = await adapter.requestDevice({\n requiredFeatures: adapter.features as ReadonlySet<GPUFeatureName>\n // TODO ensure we obtain best limits\n // requiredLimits: adapter.limits\n });\n log.probe(1, 'GPUDevice available')();\n\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n log.probe(1, 'DOM is loaded')();\n }\n\n const device = new WebGPUDevice(gpuDevice, adapter, props);\n log.probe(1, 'Device created', device.info)();\n log.table(1, device.info)();\n log.groupEnd(1)();\n return device;\n }\n\n constructor(device: GPUDevice, adapter: GPUAdapter, props: DeviceProps) {\n super({...props, id: props.id || uid('webgpu-device')});\n this.handle = device;\n this.adapter = adapter;\n\n this._info = {\n type: 'webgpu',\n vendor: this.adapter.__brand,\n renderer: '',\n version: '',\n gpu: 'unknown', // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',\n shadingLanguages: ['glsl', 'wgsl'],\n shadingLanguageVersions: {\n glsl: '450',\n wgsl: '100'\n },\n vendorMasked: '',\n rendererMasked: ''\n };\n\n // \"Context\" loss handling\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(async (resolve) => {\n const lostInfo = await this.handle.lost;\n this._isLost = true;\n resolve({reason: 'destroyed', message: lostInfo.message});\n });\n\n // Note: WebGPU devices can be created without a canvas, for compute shader purposes\n if (props.canvas) {\n this.canvasContext = new WebGPUCanvasContext(this, this.adapter, {canvas: props.canvas});\n }\n\n this.features = this._getFeatures();\n }\n\n // TODO\n // Load the glslang module now so that it is available synchronously when compiling shaders\n // const {glsl = true} = props;\n // this.glslang = glsl && await loadGlslangModule();\n\n destroy(): void {\n this.handle.destroy();\n }\n\n get info(): DeviceInfo {\n return this._info;\n }\n\n features: Set<DeviceFeature>;\n\n get limits(): DeviceLimits {\n return this.handle.limits;\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return !format.includes('webgl');\n }\n\n /** @todo implement proper check? */\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n /** @todo implement proper check? */\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n get isLost(): boolean {\n return this._isLost;\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer {\n const newProps = this._getBufferProps(props);\n return new WebGPUBuffer(this, newProps);\n }\n\n _createTexture(props: TextureProps): WebGPUTexture {\n return new WebGPUTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): WebGPUExternalTexture {\n return new WebGPUExternalTexture(this, props);\n }\n\n createShader(props: ShaderProps): WebGPUShader {\n return new WebGPUShader(this, props);\n }\n\n createSampler(props: SamplerProps): WebGPUSampler {\n return new WebGPUSampler(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WebGPURenderPipeline {\n return new WebGPURenderPipeline(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WebGPUFramebuffer {\n throw new Error('Not implemented');\n }\n\n createComputePipeline(props: ComputePipelineProps): WebGPUComputePipeline {\n return new WebGPUComputePipeline(this, props);\n }\n\n // WebGPU specifics\n\n /**\n * Allows a render pass to begin against a canvas context\n * @todo need to support a \"Framebuffer\" equivalent (aka preconfigured RenderPassDescriptors?).\n */\n beginRenderPass(props: RenderPassProps): WebGPURenderPass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPURenderPass(this, props);\n }\n\n beginComputePass(props: ComputePassProps): WebGPUComputePass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPUComputePass(this, props);\n }\n\n // createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {\n // return new WebGPUCommandEncoder(this, props);\n // }\n\n createCanvasContext(props: CanvasContextProps): WebGPUCanvasContext {\n return new WebGPUCanvasContext(this, this.adapter, props);\n }\n\n /**\n * Gets default renderpass encoder.\n * Creates a new encoder against default canvasContext if not already created\n * @note Called internally by Model.\n */\n getDefaultRenderPass(): WebGPURenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext?.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\n\n submit(): void {\n this.renderPass?.end();\n const commandBuffer = this.commandEncoder?.finish();\n if (commandBuffer) {\n this.handle.queue.submit([commandBuffer]);\n }\n this.commandEncoder = null;\n this.renderPass = null;\n }\n\n _getFeatures() {\n // WebGPU Features\n const features = new Set<DeviceFeature>(this.handle.features as Set<DeviceFeature>);\n\n // Fixups for pre-standard names: https://github.com/webgpu-native/webgpu-headers/issues/133\n // @ts-expect-error Chrome Canary v99\n if (features.has('depth-clamping')) {\n // @ts-expect-error Chrome Canary v99\n features.delete('depth-clamping');\n features.add('depth-clip-control');\n }\n\n // Add subsets\n if (features.has('texture-compression-bc')) {\n features.add('texture-compression-bc5-webgl');\n }\n\n features.add('webgpu');\n\n features.add('timer-query-webgl');\n\n // WEBGL1 SUPPORT\n features.add('vertex-array-object-webgl1');\n features.add('instanced-rendering-webgl1');\n features.add('multiple-render-targets-webgl1');\n features.add('index-uint32-webgl1');\n features.add('blend-minmax-webgl1');\n features.add('texture-blend-float-webgl1');\n\n // TEXTURES, RENDERBUFFERS\n features.add('texture-formats-srgb-webgl1');\n\n // TEXTURES\n features.add('texture-formats-depth-webgl1');\n features.add('texture-formats-float32-webgl1');\n features.add('texture-formats-float16-webgl1');\n\n features.add('texture-filter-linear-float32-webgl');\n features.add('texture-filter-linear-float16-webgl');\n features.add('texture-filter-anisotropic-webgl');\n\n // FRAMEBUFFERS, TEXTURES AND RENDERBUFFERS\n features.add('texture-renderable-rgba32float-webgl');\n features.add('texture-renderable-float32-webgl');\n features.add('texture-renderable-float16-webgl');\n\n // GLSL extensions\n features.add('glsl-frag-data');\n features.add('glsl-frag-depth');\n features.add('glsl-derivatives');\n features.add('glsl-texture-lod');\n\n return features;\n }\n\n copyExternalImageToTexture(options: {\n texture: Texture;\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'display-p3' | 'srgb';\n premultipliedAlpha?: boolean;\n\n source: ImageBitmap | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas;\n sourceX?: number;\n sourceY?: number;\n\n width?: number;\n height?: number;\n depth?: number;\n }): void {\n const {\n source,\n sourceX = 0,\n sourceY = 0,\n\n texture,\n mipLevel = 0,\n aspect = 'all',\n colorSpace = 'display-p3',\n premultipliedAlpha = false,\n // destinationX,\n // destinationY,\n // desitnationZ,\n\n width = texture.width,\n height = texture.height,\n depth = 1\n } = options;\n\n const webGpuTexture = texture as WebGPUTexture;\n\n this.handle?.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: webGpuTexture.handle,\n origin: [0, 0, 0], // [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [\n width,\n height,\n depth\n ]\n )\n }\n}\n"],"mappings":"AAuBA,SAAQA,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,QAAO,eAAe;AAAC,SACtDC,YAAY;AAAA,SACZC,aAAa;AAAA,SACbC,qBAAqB;AAAA,SACrBC,aAAa;AAAA,SACbC,YAAY;AAAA,SACZC,oBAAoB;AAAA,SAEpBC,qBAAqB;AAAA,SACrBC,gBAAgB;AAAA,SAChBC,iBAAiB;AAAA,SAGjBC,mBAAmB;AAI3B,OAAO,MAAMC,YAAY,SAASd,MAAM,CAAC;EAevC,OAAOe,WAAWA,CAAA,EAAY;IAC5B,OAAOC,OAAO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