@luma.gl/webgpu 9.0.0-alpha.20 → 9.0.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/helpers/get-bind-group.js.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.js +1 -1
- package/dist/adapter/resources/webgpu-buffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.d.ts +4 -12
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.d.ts +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-external-texture.d.ts +2 -2
- package/dist/adapter/resources/webgpu-external-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-external-texture.js +2 -2
- package/dist/adapter/resources/webgpu-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.d.ts +1 -18
- package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.js +3 -85
- package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.d.ts +8 -3
- package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js +20 -2
- package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts +3 -3
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.js +1 -1
- package/dist/adapter/resources/webgpu-sampler.js.map +1 -1
- package/dist/adapter/resources/webgpu-shader.d.ts +1 -1
- package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-shader.js +4 -3
- package/dist/adapter/resources/webgpu-shader.js.map +1 -1
- package/dist/adapter/resources/webgpu-texture.d.ts +12 -4
- package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-texture.js +10 -3
- package/dist/adapter/resources/webgpu-texture.js.map +1 -1
- package/dist/adapter/webgpu-canvas-context.d.ts +4 -4
- package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgpu-canvas-context.js +3 -3
- package/dist/adapter/webgpu-canvas-context.js.map +1 -1
- package/dist/adapter/webgpu-device.d.ts +27 -13
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +41 -12
- package/dist/adapter/webgpu-device.js.map +1 -1
- package/dist/dist.dev.js +388 -176
- package/dist/index.cjs +80 -87
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist.min.js +4 -4
- package/package.json +3 -3
- package/src/adapter/helpers/get-bind-group.ts +3 -3
- package/src/adapter/resources/webgpu-buffer.ts +1 -1
- package/src/adapter/resources/webgpu-command-encoder.ts +46 -27
- package/src/adapter/resources/webgpu-compute-pass.ts +4 -4
- package/src/adapter/resources/webgpu-compute-pipeline.ts +2 -2
- package/src/adapter/resources/webgpu-external-texture.ts +2 -2
- package/src/adapter/resources/webgpu-framebuffer.ts +7 -109
- package/src/adapter/resources/webgpu-render-pass.ts +38 -8
- package/src/adapter/resources/webgpu-render-pipeline.ts +4 -4
- package/src/adapter/resources/webgpu-sampler.ts +1 -1
- package/src/adapter/resources/webgpu-shader.ts +3 -3
- package/src/adapter/resources/webgpu-texture.ts +10 -4
- package/src/adapter/webgpu-canvas-context.ts +6 -5
- package/src/adapter/webgpu-device.ts +83 -15
- package/src/index.ts +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-bind-group.js","names":["Buffer","Sampler","Texture","log","cast","makeBindGroupLayout","device","layout","bindings","Error","getBindGroup","bindGroupLayout","entries","getBindGroupEntries","createBindGroup","getShaderLayoutBinding","bindingName","bindingLayout","find","binding","name","warn","concat","value","Object","push","getBindGroupEntry","location","index","resource","buffer","handle","createView"],"sources":["../../../src/adapter/helpers/get-bind-group.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {ShaderLayout, BindingLayout, Binding} from '@luma.gl/api';\nimport {Buffer, Sampler, Texture, log, cast} from '@luma.gl/api';\nimport type WebGPUBuffer from '../resources/webgpu-buffer';\nimport type WebGPUSampler from '../resources/webgpu-sampler';\nimport type WebGPUTexture from '../resources/webgpu-texture';\n\n/**\n * Create a WebGPU \"bind group layout\" from an array of luma.gl bindings\n * @note bind groups can be automatically generated by WebGPU.\n */\nexport function makeBindGroupLayout(device: GPUDevice, layout: GPUBindGroupLayout, bindings: Binding[]): GPUBindGroupLayout {\n throw new Error('not implemented');\n // return device.createBindGroupLayout({\n // layout,\n // entries: getBindGroupEntries(bindings)\n // })\n}\n\n/**\n * Create a WebGPU \"bind group\" from an array of luma.gl bindings\n */\nexport function getBindGroup(\n device: GPUDevice,\n bindGroupLayout: GPUBindGroupLayout,\n layout: ShaderLayout,\n bindings: Record<string, Binding>\n): GPUBindGroup {\n const entries = getBindGroupEntries(bindings, layout);\n return device.createBindGroup({\n layout: bindGroupLayout,\n entries\n });\n}\n\nexport function getShaderLayoutBinding(layout: ShaderLayout, bindingName: string): BindingLayout {\n const bindingLayout = layout.bindings.find(binding => binding.name === bindingName);\n if (!bindingLayout) {\n log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();\n }\n return bindingLayout;\n}\n\n/**\n * @param bindings\n * @returns\n */\nfunction getBindGroupEntries(bindings: Record<string, Binding>, layout: ShaderLayout): GPUBindGroupEntry[] {\n const entries: GPUBindGroupEntry[] = [];\n\n for (const [bindingName, value] of Object.entries(bindings)) {\n const bindingLayout = getShaderLayoutBinding(layout, bindingName);\n if (bindingLayout) {\n entries.push(getBindGroupEntry(value, bindingLayout.location));\n }\n }\n\n return entries;\n}\n\nfunction getBindGroupEntry(binding: Binding, index: number): GPUBindGroupEntry {\n if (binding instanceof Buffer) {\n return {\n binding: index,\n resource: {\n buffer: cast<WebGPUBuffer>(binding).handle\n }\n };\n }\n if (binding instanceof Sampler) {\n return {\n binding: index,\n resource: cast<WebGPUSampler>(binding).handle\n };\n } else if (binding instanceof Texture) {\n return {\n binding: index,\n resource: cast<WebGPUTexture>(binding).handle.createView()\n };\n }\n throw new Error('invalid binding');\n}\n"],"mappings":"AAEA,SAAQA,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAEC,GAAG,EAAEC,IAAI,QAAO,cAAc;AAShE,OAAO,SAASC,mBAAmBA,CAACC,MAAiB,EAAEC,MAA0B,EAAEC,QAAmB,EAAsB;EAC1H,MAAM,IAAIC,KAAK,CAAC,iBAAiB,CAAC;AAKpC;AAKA,OAAO,SAASC,YAAYA,CAC1BJ,MAAiB,EACjBK,eAAmC,EACnCJ,MAAoB,EACpBC,QAAiC,EACnB;EACd,MAAMI,OAAO,GAAGC,mBAAmB,CAACL,QAAQ,EAAED,MAAM,CAAC;EACrD,OAAOD,MAAM,CAACQ,eAAe,CAAC;IAC5BP,MAAM,EAAEI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B,IAAI,CAAgBe,OAAO,CAAC,CAACY,MAAM,CAACC,UAAU;IAC1D,CAAC;EACH;EACA,MAAM,IAAIvB,KAAK,CAAC,iBAAiB,CAAC;AACpC"}
|
|
1
|
+
{"version":3,"file":"get-bind-group.js","names":["Buffer","Sampler","Texture","log","cast","makeBindGroupLayout","device","layout","bindings","Error","getBindGroup","bindGroupLayout","entries","getBindGroupEntries","createBindGroup","getShaderLayoutBinding","bindingName","bindingLayout","find","binding","name","warn","concat","value","Object","push","getBindGroupEntry","location","index","resource","buffer","handle","createView"],"sources":["../../../src/adapter/helpers/get-bind-group.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {ShaderLayout, BindingLayout, Binding} from '@luma.gl/api';\nimport {Buffer, Sampler, Texture, log, cast} from '@luma.gl/api';\nimport type {WebGPUBuffer} from '../resources/webgpu-buffer';\nimport type {WebGPUSampler} from '../resources/webgpu-sampler';\nimport type {WebGPUTexture} from '../resources/webgpu-texture';\n\n/**\n * Create a WebGPU \"bind group layout\" from an array of luma.gl bindings\n * @note bind groups can be automatically generated by WebGPU.\n */\nexport function makeBindGroupLayout(device: GPUDevice, layout: GPUBindGroupLayout, bindings: Binding[]): GPUBindGroupLayout {\n throw new Error('not implemented');\n // return device.createBindGroupLayout({\n // layout,\n // entries: getBindGroupEntries(bindings)\n // })\n}\n\n/**\n * Create a WebGPU \"bind group\" from an array of luma.gl bindings\n */\nexport function getBindGroup(\n device: GPUDevice,\n bindGroupLayout: GPUBindGroupLayout,\n layout: ShaderLayout,\n bindings: Record<string, Binding>\n): GPUBindGroup {\n const entries = getBindGroupEntries(bindings, layout);\n return device.createBindGroup({\n layout: bindGroupLayout,\n entries\n });\n}\n\nexport function getShaderLayoutBinding(layout: ShaderLayout, bindingName: string): BindingLayout {\n const bindingLayout = layout.bindings.find(binding => binding.name === bindingName);\n if (!bindingLayout) {\n log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();\n }\n return bindingLayout;\n}\n\n/**\n * @param bindings\n * @returns\n */\nfunction getBindGroupEntries(bindings: Record<string, Binding>, layout: ShaderLayout): GPUBindGroupEntry[] {\n const entries: GPUBindGroupEntry[] = [];\n\n for (const [bindingName, value] of Object.entries(bindings)) {\n const bindingLayout = getShaderLayoutBinding(layout, bindingName);\n if (bindingLayout) {\n entries.push(getBindGroupEntry(value, bindingLayout.location));\n }\n }\n\n return entries;\n}\n\nfunction getBindGroupEntry(binding: Binding, index: number): GPUBindGroupEntry {\n if (binding instanceof Buffer) {\n return {\n binding: index,\n resource: {\n buffer: cast<WebGPUBuffer>(binding).handle\n }\n };\n }\n if (binding instanceof Sampler) {\n return {\n binding: index,\n resource: cast<WebGPUSampler>(binding).handle\n };\n } else if (binding instanceof Texture) {\n return {\n binding: index,\n resource: cast<WebGPUTexture>(binding).handle.createView()\n };\n }\n throw new Error('invalid binding');\n}\n"],"mappings":"AAEA,SAAQA,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAEC,GAAG,EAAEC,IAAI,QAAO,cAAc;AAShE,OAAO,SAASC,mBAAmBA,CAACC,MAAiB,EAAEC,MAA0B,EAAEC,QAAmB,EAAsB;EAC1H,MAAM,IAAIC,KAAK,CAAC,iBAAiB,CAAC;AAKpC;AAKA,OAAO,SAASC,YAAYA,CAC1BJ,MAAiB,EACjBK,eAAmC,EACnCJ,MAAoB,EACpBC,QAAiC,EACnB;EACd,MAAMI,OAAO,GAAGC,mBAAmB,CAACL,QAAQ,EAAED,MAAM,CAAC;EACrD,OAAOD,MAAM,CAACQ,eAAe,CAAC;IAC5BP,MAAM,EAAEI,eAAe;IACvBC;EACF,CAAC,CAAC;AACJ;AAEA,OAAO,SAASG,sBAAsBA,CAACR,MAAoB,EAAES,WAAmB,EAAiB;EAC/F,MAAMC,aAAa,GAAGV,MAAM,CAACC,QAAQ,CAACU,IAAI,CAACC,OAAO,IAAIA,OAAO,CAACC,IAAI,KAAKJ,WAAW,CAAC;EACnF,IAAI,CAACC,aAAa,EAAE;IAClBd,GAAG,CAACkB,IAAI,YAAAC,MAAA,CAAYN,WAAW,2CAAwC,EAAE;EAC3E;EACA,OAAOC,aAAa;AACtB;AAMA,SAASJ,mBAAmBA,CAACL,QAAiC,EAAED,MAAoB,EAAuB;EACzG,MAAMK,OAA4B,GAAG,EAAE;EAEvC,KAAK,MAAM,CAACI,WAAW,EAAEO,KAAK,CAAC,IAAIC,MAAM,CAACZ,OAAO,CAACJ,QAAQ,CAAC,EAAE;IAC3D,MAAMS,aAAa,GAAGF,sBAAsB,CAACR,MAAM,EAAES,WAAW,CAAC;IACjE,IAAIC,aAAa,EAAE;MACjBL,OAAO,CAACa,IAAI,CAACC,iBAAiB,CAACH,KAAK,EAAEN,aAAa,CAACU,QAAQ,CAAC,CAAC;IAChE;EACF;EAEA,OAAOf,OAAO;AAChB;AAEA,SAASc,iBAAiBA,CAACP,OAAgB,EAAES,KAAa,EAAqB;EAC7E,IAAIT,OAAO,YAAYnB,MAAM,EAAE;IAC7B,OAAO;MACLmB,OAAO,EAAES,KAAK;MACdC,QAAQ,EAAE;QACRC,MAAM,EAAE1B,IAAI,CAAee,OAAO,CAAC,CAACY;MACtC;IACF,CAAC;EACH;EACA,IAAIZ,OAAO,YAAYlB,OAAO,EAAE;IAC9B,OAAO;MACLkB,OAAO,EAAES,KAAK;MACdC,QAAQ,EAAEzB,IAAI,CAAgBe,OAAO,CAAC,CAACY;IACzC,CAAC;EACH,CAAC,MAAM,IAAIZ,OAAO,YAAYjB,OAAO,EAAE;IACrC,OAAO;MACLiB,OAAO,EAAES,KAAK;MACdC,QAAQ,EAAEzB,IAAI,CAAgBe,OAAO,CAAC,CAACY,MAAM,CAACC,UAAU;IAC1D,CAAC;EACH;EACA,MAAM,IAAIvB,KAAK,CAAC,iBAAiB,CAAC;AACpC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="dist" />
|
|
2
2
|
import { Buffer, BufferProps } from '@luma.gl/api';
|
|
3
3
|
import type { WebGPUDevice } from '../webgpu-device';
|
|
4
|
-
export
|
|
4
|
+
export declare class WebGPUBuffer extends Buffer {
|
|
5
5
|
readonly device: WebGPUDevice;
|
|
6
6
|
readonly handle: GPUBuffer;
|
|
7
7
|
readonly byteLength: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAMnD,
|
|
1
|
+
{"version":3,"file":"webgpu-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAMnD,qBAAa,YAAa,SAAQ,MAAM;IACtC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW;IAyB3C,OAAO,IAAI,IAAI;IAKf,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,SAAI;IAUrC,SAAS,CAAC,UAAU,GAAE,MAAU,EAAE,UAAU,GAAE,MAAwB,GAAG,OAAO,CAAC,WAAW,CAAC;IAmB5G,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAQtD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxE,cAAc,CAAC,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW;IAI9D,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -4,7 +4,7 @@ function getByteLength(props) {
|
|
|
4
4
|
var _props$data;
|
|
5
5
|
return props.byteLength || ((_props$data = props.data) === null || _props$data === void 0 ? void 0 : _props$data.byteLength) || 0;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export class WebGPUBuffer extends Buffer {
|
|
8
8
|
constructor(device, props) {
|
|
9
9
|
super(device, props);
|
|
10
10
|
_defineProperty(this, "device", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-buffer.js","names":["Buffer","getByteLength","props","_props$data","byteLength","data","WebGPUBuffer","constructor","device","_defineProperty","mapBuffer","Boolean","handle","createBuffer","size","usage","GPUBufferUsage","VERTEX","COPY_DST","mappedAtCreation","label","id","_writeMapped","unmap","destroy","write","byteOffset","arguments","length","undefined","queue","writeBuffer","buffer","readAsync","tempBuffer","MAP_READ","commandEncoder","createCommandEncoder","copyBufferToBuffer","submit","finish","mapAsync","GPUMapMode","READ","arrayBuffer","getMappedRange","slice","typedArray","set","mode","offset"],"sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"sourcesContent":["// WEBGPU Buffer implementation\nimport {Buffer, BufferProps} from '@luma.gl/api';\nimport type {WebGPUDevice} from '../webgpu-device';\n\nfunction getByteLength(props: BufferProps): number {\n return props.byteLength || props.data?.byteLength || 0;\n}\n\nexport
|
|
1
|
+
{"version":3,"file":"webgpu-buffer.js","names":["Buffer","getByteLength","props","_props$data","byteLength","data","WebGPUBuffer","constructor","device","_defineProperty","mapBuffer","Boolean","handle","createBuffer","size","usage","GPUBufferUsage","VERTEX","COPY_DST","mappedAtCreation","label","id","_writeMapped","unmap","destroy","write","byteOffset","arguments","length","undefined","queue","writeBuffer","buffer","readAsync","tempBuffer","MAP_READ","commandEncoder","createCommandEncoder","copyBufferToBuffer","submit","finish","mapAsync","GPUMapMode","READ","arrayBuffer","getMappedRange","slice","typedArray","set","mode","offset"],"sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"sourcesContent":["// WEBGPU Buffer implementation\nimport {Buffer, BufferProps} from '@luma.gl/api';\nimport type {WebGPUDevice} from '../webgpu-device';\n\nfunction getByteLength(props: BufferProps): number {\n return props.byteLength || props.data?.byteLength || 0;\n}\n\nexport class WebGPUBuffer extends Buffer {\n readonly device: WebGPUDevice;\n readonly handle: GPUBuffer;\n readonly byteLength: number;\n\n constructor(device: WebGPUDevice, props: BufferProps) {\n super(device, props);\n this.device = device;\n\n this.byteLength = getByteLength(props);\n const mapBuffer = Boolean(props.data);\n\n this.handle = this.props.handle || this.device.handle.createBuffer({\n size: this.byteLength,\n // usage defaults to vertex\n usage: this.props.usage || (GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST),\n mappedAtCreation: this.props.mappedAtCreation || mapBuffer,\n label: this.props.id\n });\n\n if (props.data) {\n this._writeMapped(props.data);\n // this.handle.writeAsync({data: props.data, map: false, unmap: false});\n }\n\n if (mapBuffer && !props.mappedAtCreation) {\n this.handle.unmap();\n }\n }\n\n override destroy(): void {\n this.handle.destroy();\n }\n\n // WebGPU provides multiple ways to write a buffer...\n override write(data: ArrayBufferView, byteOffset = 0) {\n this.device.handle.queue.writeBuffer(\n this.handle,\n byteOffset,\n data.buffer,\n data.byteOffset,\n data.byteLength\n );\n }\n\n override async readAsync(byteOffset: number = 0, byteLength: number = this.byteLength): Promise<ArrayBuffer> {\n // We need MAP_READ flag, but only COPY_DST buffers can have MAP_READ flag, so we need to create a temp buffer\n const tempBuffer = new WebGPUBuffer(this.device, {usage: Buffer.MAP_READ | Buffer.COPY_DST, byteLength});\n\n // Now do a GPU-side copy into the temp buffer we can actually read.\n // TODO - we are spinning up an independent command queue here, what does this mean\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);\n this.device.handle.queue.submit([commandEncoder.finish()]);\n\n // Map the temp buffer and read the data.\n await tempBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);\n const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);\n tempBuffer.handle.unmap();\n tempBuffer.destroy();\n\n return arrayBuffer;\n }\n\n _writeMapped<TypedArray>(typedArray: TypedArray): void {\n const arrayBuffer = this.handle.getMappedRange();\n // @ts-expect-error\n new typedArray.constructor(arrayBuffer).set(typedArray);\n }\n\n // WEBGPU API\n\n mapAsync(mode: number, offset: number = 0, size?: number): Promise<void> {\n return this.handle.mapAsync(mode, offset, size);\n }\n\n getMappedRange(offset: number = 0, size?: number): ArrayBuffer {\n return this.handle.getMappedRange(offset, size);\n }\n\n unmap(): void {\n this.handle.unmap();\n }\n}\n"],"mappings":";AACA,SAAQA,MAAM,QAAoB,cAAc;AAGhD,SAASC,aAAaA,CAACC,KAAkB,EAAU;EAAA,IAAAC,WAAA;EACjD,OAAOD,KAAK,CAACE,UAAU,MAAAD,WAAA,GAAID,KAAK,CAACG,IAAI,cAAAF,WAAA,uBAAVA,WAAA,CAAYC,UAAU,KAAI,CAAC;AACxD;AAEA,OAAO,MAAME,YAAY,SAASN,MAAM,CAAC;EAKvCO,WAAWA,CAACC,MAAoB,EAAEN,KAAkB,EAAE;IACpD,KAAK,CAACM,MAAM,EAAEN,KAAK,CAAC;IAACO,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACrB,IAAI,CAACD,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACJ,UAAU,GAAGH,aAAa,CAACC,KAAK,CAAC;IACtC,MAAMQ,SAAS,GAAGC,OAAO,CAACT,KAAK,CAACG,IAAI,CAAC;IAErC,IAAI,CAACO,MAAM,GAAG,IAAI,CAACV,KAAK,CAACU,MAAM,IAAI,IAAI,CAACJ,MAAM,CAACI,MAAM,CAACC,YAAY,CAAC;MACjEC,IAAI,EAAE,IAAI,CAACV,UAAU;MAErBW,KAAK,EAAE,IAAI,CAACb,KAAK,CAACa,KAAK,IAAKC,cAAc,CAACC,M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AAAa,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAC9C,OAAO,IAAI,CAACjB,MAAM,CAACiC,cAAc,CAACK,MAAM,EAAEpC,IAAI,CAAC;EACjD;EAEAS,KAAKA,CAAA,EAAS;IACZ,IAAI,CAACX,MAAM,CAACW,KAAK,EAAE;EACrB;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="dist" />
|
|
2
|
-
import { CommandEncoder, CommandEncoderProps, Buffer, Texture } from '@luma.gl/api';
|
|
2
|
+
import { CommandEncoder, CommandEncoderProps, Buffer, Texture, CopyTextureToTextureOptions, CopyTextureToBufferOptions } from '@luma.gl/api';
|
|
3
3
|
import { WebGPUDevice } from '../webgpu-device';
|
|
4
|
-
export
|
|
4
|
+
export declare class WebGPUCommandEncoder extends CommandEncoder {
|
|
5
5
|
readonly device: WebGPUDevice;
|
|
6
6
|
readonly handle: GPUCommandEncoder;
|
|
7
7
|
constructor(device: WebGPUDevice, props: CommandEncoderProps);
|
|
@@ -27,16 +27,8 @@ export default class WebGPUCommandEncoder extends CommandEncoder {
|
|
|
27
27
|
origin?: number[] | [number, number, number];
|
|
28
28
|
extent?: number[] | [number, number, number];
|
|
29
29
|
}): void;
|
|
30
|
-
copyTextureToBuffer(options:
|
|
31
|
-
|
|
32
|
-
destination: GPUImageCopyBuffer;
|
|
33
|
-
copySize: GPUExtent3D;
|
|
34
|
-
}): void;
|
|
35
|
-
copyTextureToTexture(options: {
|
|
36
|
-
source: GPUImageCopyTexture;
|
|
37
|
-
destination: GPUImageCopyTexture;
|
|
38
|
-
copySize: GPUExtent3D;
|
|
39
|
-
}): void;
|
|
30
|
+
copyTextureToBuffer(options: CopyTextureToBufferOptions): void;
|
|
31
|
+
copyTextureToTexture(options: CopyTextureToTextureOptions): void;
|
|
40
32
|
pushDebugGroup(groupLabel: string): void;
|
|
41
33
|
popDebugGroup(): void;
|
|
42
34
|
insertDebugMarker(markerLabel: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAE,MAAM,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"webgpu-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAE,MAAM,EAAE,OAAO,EAC1D,2BAA2B,EAC3B,0BAA0B,EAG3B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAI9C,qBAAa,oBAAqB,SAAQ,cAAc;IACtD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;gBAEvB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,mBAAmB;IAUnD,OAAO,IAAI,IAAI;IAExB,MAAM,CAAC,OAAO,CAAC,EAAE;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,gBAAgB;IAOjD,kBAAkB,CAAC,OAAO,EACxB;QACE,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,GACA,IAAI;IAUP,mBAAmB,CAAC,OAAO,EACzB;QACA,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QAErB,WAAW,EAAE,OAAO,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,KAAK,GAAG,cAAc,GAAG,YAAY,CAAC;QAE/C,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7C,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KAC7C,GACE,IAAI;IAuBP,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,IAAI;IAW9D,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI;IAWvD,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIxC,aAAa,IAAI,IAAI;IAIrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAatD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { CommandEncoder, cast } from '@luma.gl/api';
|
|
3
|
-
export
|
|
3
|
+
export class WebGPUCommandEncoder extends CommandEncoder {
|
|
4
4
|
constructor(device, props) {
|
|
5
5
|
super(props);
|
|
6
6
|
_defineProperty(this, "device", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-command-encoder.js","names":["CommandEncoder","cast","WebGPUCommandEncoder","constructor","device","props","_defineProperty","handle","createCommandEncoder","label","id","destroy","finish","options","copyBufferToBuffer","_options$sourceOffset","_options$destinationO","_options$size","source","sourceOffset","destination","destinationOffset","size","copyBufferToTexture","_options$offset","_options$mipLevel","_options$origin","buffer","offset","bytesPerRow","rowsPerImage","texture","mipLevel","origin","width","extent","height","depthOrArrayLayers","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps, Buffer, Texture, cast} from '@luma.gl/api';\nimport {WebGPUDevice} from '../webgpu-device';\nimport
|
|
1
|
+
{"version":3,"file":"webgpu-command-encoder.js","names":["CommandEncoder","cast","WebGPUCommandEncoder","constructor","device","props","_defineProperty","handle","createCommandEncoder","label","id","destroy","finish","options","copyBufferToBuffer","_options$sourceOffset","_options$destinationO","_options$size","source","sourceOffset","destination","destinationOffset","size","copyBufferToTexture","_options$offset","_options$mipLevel","_options$origin","buffer","offset","bytesPerRow","rowsPerImage","texture","mipLevel","origin","width","extent","height","depthOrArrayLayers","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps, Buffer, Texture, cast, \n CopyTextureToTextureOptions, \n CopyTextureToBufferOptions\n // CopyBufferToTextureOptions,\n // CopyBufferToBufferOptions,\n} from '@luma.gl/api';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {WebGPUTexture} from './webgpu-texture';\n\nexport class WebGPUCommandEncoder extends CommandEncoder {\n readonly device: WebGPUDevice;\n readonly handle: GPUCommandEncoder;\n\n constructor(device: WebGPUDevice, props: CommandEncoderProps) {\n super(props);\n this.device = device;\n this.handle = props.handle || this.device.handle.createCommandEncoder({\n // TODO was this removed in standard?\n // measureExecutionTime: this.props.measureExecutionTime\n });\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\n\n finish(options?: {id?: string}): GPUCommandBuffer {\n return this.finish(options);\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n\n copyBufferToBuffer(options: // CopyBufferToBufferOptions\n {\n source: Buffer,\n sourceOffset?: number,\n destination: Buffer,\n destinationOffset?: number,\n size?: number\n }\n ): void {\n this.handle.copyBufferToBuffer(\n cast<WebGPUBuffer>(options.source).handle,\n options.sourceOffset ?? 0,\n cast<WebGPUBuffer>(options.destination).handle,\n options.destinationOffset ?? 0,\n options.size ?? 0\n );\n }\n\n copyBufferToTexture(options: // CopyBufferToTextureOptions\n {\n source: Buffer,\n offset?: number,\n bytesPerRow: number,\n rowsPerImage: number,\n\n destination: Texture,\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only',\n\n origin?: number[] | [number, number, number],\n extent?: number[] | [number, number, number]\n }\n ): void {\n this.handle.copyBufferToTexture(\n {\n buffer: cast<WebGPUBuffer>(options.source).handle,\n offset: options.offset ?? 0,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage,\n },\n {\n texture: cast<WebGPUTexture>(options.destination).handle,\n mipLevel: options.mipLevel ?? 0,\n origin: options.origin ?? {},\n // aspect: options.aspect\n },\n {\n // TODO exclamation mark hack\n width: options.extent[0],\n height: options.extent[1],\n depthOrArrayLayers: options.extent[2]\n }\n );\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n // this.handle.copyTextureToBuffer(\n // // source\n // {},\n // // destination\n // {},\n // // copySize\n // {}\n // );\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n // this.handle.copyTextureToTexture(\n // // source\n // {},\n // // destination\n // {},\n // // copySize\n // {}\n // );\n }\n\n override pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n\n override popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n\n override insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}"],"mappings":";AAAA,SAAQA,cAAc,EAAwCC,IAAI,QAK3D,cAAc;AAKrB,OAAO,MAAMC,oBAAoB,SAASF,cAAc,CAAC;EAIvDG,WAAWA,CAACC,MAAoB,EAAEC,KAA0B,EAA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AO,CAACgB,WAAW;MAChCC,YAAY,EAAEjB,OAAO,CAACiB;IACxB,CAAC,EACD;MACEC,OAAO,EAAE9B,IAAI,CAAgBY,OAAO,CAACO,WAAW,CAAC,CAACb,MAAM;MACxDyB,QAAQ,GAAAP,iBAAA,GAAEZ,OAAO,CAACmB,QAAQ,cAAAP,iBAAA,cAAAA,iBAAA,GAAI,CAAC;MAC/BQ,MAAM,GAAAP,eAAA,GAAEb,OAAO,CAACoB,MAAM,cAAAP,eAAA,cAAAA,eAAA,GAAI,CAAC;IAE7B,CAAC,EACD;MAEEQ,KAAK,EAAErB,OAAO,CAACsB,MAAM,CAAC,CAAC,CAAC;MACxBC,MAAM,EAAEvB,OAAO,CAACsB,MAAM,CAAC,CAAC,CAAC;MACzBE,kBAAkB,EAAExB,OAAO,CAACsB,MAAM,CAAC,CAAC;IACtC,CAAC,CACF;EACH;EAEAG,mBAAmBA,CAACzB,OAAmC,EAAQ,CAS/D;EAEA0B,oBAAoBA,CAAC1B,OAAoC,EAAQ,CASjE;EAES2B,cAAcA,CAACC,UAAkB,EAAQ;IAChD,IAAI,CAAClC,MAAM,CAACiC,cAAc,CAACC,UAAU,CAAC;EACxC;EAESC,aAAaA,CAAA,EAAS;IAC7B,IAAI,CAACnC,MAAM,CAACmC,aAAa,EAAE;EAC7B;EAESC,iBAAiBA,CAACC,WAAmB,EAAQ;IACpD,IAAI,CAACrC,MAAM,CAACoC,iBAAiB,CAACC,WAAW,CAAC;EAC5C;AAWF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="dist" />
|
|
2
2
|
import { ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding } from '@luma.gl/api';
|
|
3
3
|
import { WebGPUDevice } from '../webgpu-device';
|
|
4
|
-
export
|
|
4
|
+
export declare class WebGPUComputePass extends ComputePass {
|
|
5
5
|
readonly device: WebGPUDevice;
|
|
6
6
|
readonly handle: GPUComputePassEncoder;
|
|
7
7
|
_bindGroupLayout: GPUBindGroupLayout | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-compute-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAO,MAAM,cAAc,CAAC;AACnG,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAK9C,
|
|
1
|
+
{"version":3,"file":"webgpu-compute-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAO,MAAM,cAAc,CAAC;AACnG,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAK9C,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,gBAAgB,EAAE,kBAAkB,GAAG,IAAI,CAAQ;gBAEvC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAUzD,8CAA8C;IACrC,OAAO,IAAI,IAAI;IAExB,GAAG,IAAI,IAAI;IAIX,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAM5C,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAMtC;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAIjD;;;;OAIG;IACH,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,cAAc,GAAE,MAAU,GAAG,IAAI;IAI1E,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAGxC,aAAa,IAAI,IAAI;IAGrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAO7C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { ComputePass, cast } from '@luma.gl/api';
|
|
3
|
-
export
|
|
3
|
+
export class WebGPUComputePass extends ComputePass {
|
|
4
4
|
constructor(device, props) {
|
|
5
5
|
var _device$commandEncode;
|
|
6
6
|
super(device, props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-compute-pass.js","names":["ComputePass","cast","WebGPUComputePass","constructor","device","props","_device$commandEncode","_defineProperty","handle","commandEncoder","beginComputePass","label","id","destroy","end","setPipeline","pipeline","wgpuPipeline","_bindGroupLayout","_getBindGroupLayout","setBindings","bindings","Error","dispatch","x","y","z","dispatchWorkgroups","dispatchIndirect","indirectBuffer","indirectOffset","arguments","length","undefined","dispatchWorkgroupsIndirect","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"sourcesContent":["import {ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding, cast} from '@luma.gl/api';\nimport {WebGPUDevice} from '../webgpu-device';\nimport WebGPUBuffer from './webgpu-buffer';\n// import WebGPUCommandEncoder from './webgpu-command-encoder';\nimport WebGPUComputePipeline from './webgpu-compute-pipeline';\n\nexport
|
|
1
|
+
{"version":3,"file":"webgpu-compute-pass.js","names":["ComputePass","cast","WebGPUComputePass","constructor","device","props","_device$commandEncode","_defineProperty","handle","commandEncoder","beginComputePass","label","id","destroy","end","setPipeline","pipeline","wgpuPipeline","_bindGroupLayout","_getBindGroupLayout","setBindings","bindings","Error","dispatch","x","y","z","dispatchWorkgroups","dispatchIndirect","indirectBuffer","indirectOffset","arguments","length","undefined","dispatchWorkgroupsIndirect","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"sourcesContent":["import {ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding, cast} from '@luma.gl/api';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\n// import {WebGPUCommandEncoder} from './webgpu-command-encoder';\nimport {WebGPUComputePipeline} from './webgpu-compute-pipeline';\n\nexport class WebGPUComputePass extends ComputePass {\n readonly device: WebGPUDevice;\n readonly handle: GPUComputePassEncoder;\n _bindGroupLayout: GPUBindGroupLayout | null = null;\n\n constructor(device: WebGPUDevice, props: ComputePassProps) {\n super(device, props);\n this.device = device;\n\n this.handle = this.props.handle || device.commandEncoder?.beginComputePass({\n label: this.props.id,\n // timestampWrites?: GPUComputePassTimestampWrites;\n });\n }\n\n /** @note no WebGPU destroy method, just gc */\n override destroy(): void {}\n\n end(): void {\n this.handle.end();\n }\n\n setPipeline(pipeline: ComputePipeline): void {\n const wgpuPipeline = cast<WebGPUComputePipeline>(pipeline);\n this.handle.setPipeline(wgpuPipeline.handle);\n this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Binding[]): void {\n throw new Error('fix me');\n // const bindGroup = getBindGroup(this.device.handle, this._bindGroupLayout, this.props.bindings);\n // this.handle.setBindGroup(0, bindGroup);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param x X dimension of the grid of workgroups to dispatch.\n * @param y Y dimension of the grid of workgroups to dispatch.\n * @param z Z dimension of the grid of workgroups to dispatch.\n */\n dispatch(x: number, y?: number, z?: number): void {\n this.handle.dispatchWorkgroups(x, y, z);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param indirectBuffer buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()\n * @param indirectOffset\n */\n dispatchIndirect(indirectBuffer: Buffer, indirectOffset: number = 0): void {\n this.handle.dispatchWorkgroupsIndirect(cast<WebGPUBuffer>(indirectBuffer).handle, indirectOffset);\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 // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n}\n"],"mappings":";AAAA,SAAQA,WAAW,EAAsDC,IAAI,QAAO,cAAc;AAMlG,OAAO,MAAMC,iBAAiB,SAASF,WAAW,CAAC;EAKjDG,WAAWA,CAACC,MAAoB,EAAEC,KAAuB,EAAE;IAAA,IAAAC,qBAAA;IACzD,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAACE,eAAA;IAAAA,eAAA;IAAAA,eAAA,2BAHuB,IAAI;IAIhD,IAAI,CAACH,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACI,MAAM,GAAG,IAAI,CAACH,KAAK,CAACG,MAAM,MAAAF,qBAAA,GAAIF,MAAM,CAACK,cAAc,cAAAH,qBAAA,uBAArBA,qBAAA,CAAuBI,gBAAgB,CAAC;MACzEC,KAAK,EAAE,IAAI,CAACN,KAAK,CAACO;IAEpB,CAAC,CAAC;EACJ;EAGSC,OAAOA,CAAA,EAAS,CAAC;EAE1BC,GAAGA,CAAA,EAAS;IACV,IAAI,CAACN,MAAM,CAACM,GAAG,EAAE;EACnB;EAEAC,WAAWA,CAACC,QAAyB,EAAQ;IAC3C,MAAMC,YAAY,GAAGhB,IAAI,CAAwBe,QAAQ,CAAC;IAC1D,IAAI,CAACR,MAAM,CAACO,WAAW,CAACE,YAAY,CAACT,MAAM,CAAC;IAC5C,IAAI,CAACU,gBAAgB,GAAGD,YAAY,CAACE,mBAAmB,EAAE;EAC5D;EAGAC,WAAWA,CAACC,QAAmB,EAAQ;IACrC,MAAM,IAAIC,KAAK,CAAC,QAAQ,CAAC;EAG3B;EAQAC,QAAQA,CAACC,CAAS,EAAEC,CAAU,EAAEC,CAAU,EAAQ;IAChD,IAAI,CAAClB,MAAM,CAACmB,kBAAkB,CAACH,CAAC,EAAEC,CAAC,EAAEC,CAAC,CAAC;EACzC;EAOAE,gBAAgBA,CAACC,cAAsB,EAAoC;IAAA,IAAlCC,cAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;IACjE,IAAI,CAACvB,MAAM,CAAC0B,0BAA0B,CAACjC,IAAI,CAAe4B,cAAc,CAAC,CAACrB,MAAM,EAAEsB,cAAc,CAAC;EACnG;EAEAK,cAAcA,CAACC,UAAkB,EAAQ;IACvC,IAAI,CAAC5B,MAAM,CAAC2B,cAAc,CAACC,UAAU,CAAC;EACxC;EACAC,aAAaA,CAAA,EAAS;IACpB,IAAI,CAAC7B,MAAM,CAAC6B,aAAa,EAAE;EAC7B;EACAC,iBAAiBA,CAACC,WAAmB,EAAQ;IAC3C,IAAI,CAAC/B,MAAM,CAAC8B,iBAAiB,CAACC,WAAW,CAAC;EAC5C;AAKF"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ComputePipeline, ComputePipelineProps } from '@luma.gl/api';
|
|
3
3
|
import { WebGPUDevice } from '../webgpu-device';
|
|
4
4
|
/** Creates a new compute pipeline when parameters change */
|
|
5
|
-
export
|
|
5
|
+
export declare class WebGPUComputePipeline extends ComputePipeline {
|
|
6
6
|
device: WebGPUDevice;
|
|
7
7
|
handle: GPUComputePipeline;
|
|
8
8
|
constructor(device: WebGPUDevice, props: ComputePipelineProps);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-compute-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pipeline.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAO,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAK9C,4DAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"webgpu-compute-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pipeline.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAO,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAK9C,4DAA4D;AAC5D,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,kBAAkB,CAAC;gBAEf,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB;IAgB7D,wCAAwC;IACxC,mBAAmB;CAIpB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { ComputePipeline, cast } from '@luma.gl/api';
|
|
3
|
-
export
|
|
3
|
+
export class WebGPUComputePipeline extends ComputePipeline {
|
|
4
4
|
constructor(device, props) {
|
|
5
5
|
super(device, props);
|
|
6
6
|
_defineProperty(this, "device", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-compute-pipeline.js","names":["ComputePipeline","cast","WebGPUComputePipeline","constructor","device","props","_defineProperty","module","cs","handle","createComputePipeline","label","id","compute","entryPoint","csEntryPoint","layout","_getBindGroupLayout","getBindGroupLayout"],"sources":["../../../src/adapter/resources/webgpu-compute-pipeline.ts"],"sourcesContent":["// prettier-ignore\nimport {ComputePipeline, ComputePipelineProps, cast} from '@luma.gl/api';\n\nimport {WebGPUDevice} from '../webgpu-device';\nimport WebGPUShader from './webgpu-shader';\n\n// COMPUTE PIPELINE\n\n/** Creates a new compute pipeline when parameters change */\nexport
|
|
1
|
+
{"version":3,"file":"webgpu-compute-pipeline.js","names":["ComputePipeline","cast","WebGPUComputePipeline","constructor","device","props","_defineProperty","module","cs","handle","createComputePipeline","label","id","compute","entryPoint","csEntryPoint","layout","_getBindGroupLayout","getBindGroupLayout"],"sources":["../../../src/adapter/resources/webgpu-compute-pipeline.ts"],"sourcesContent":["// prettier-ignore\nimport {ComputePipeline, ComputePipelineProps, cast} from '@luma.gl/api';\n\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUShader} from './webgpu-shader';\n\n// COMPUTE PIPELINE\n\n/** Creates a new compute pipeline when parameters change */\nexport class WebGPUComputePipeline extends ComputePipeline {\n device: WebGPUDevice;\n handle: GPUComputePipeline;\n\n constructor(device: WebGPUDevice, props: ComputePipelineProps) {\n super(device, props);\n this.device = device;\n\n const module = cast<WebGPUShader>(this.props.cs).handle;\n this.handle = this.props.handle || this.device.handle.createComputePipeline({\n label: this.props.id,\n compute: {\n module,\n entryPoint: this.props.csEntryPoint,\n // constants: this.props.csConstants\n },\n layout: 'auto'\n });\n }\n\n /** For internal use in render passes */\n _getBindGroupLayout() {\n // TODO: Cache?\n return this.handle.getBindGroupLayout(0);\n }\n}\n"],"mappings":";AACA,SAAQA,eAAe,EAAwBC,IAAI,QAAO,cAAc;AAQxE,OAAO,MAAMC,qBAAqB,SAASF,eAAe,CAAC;EAIzDG,WAAWA,CAACC,MAAoB,EAAEC,KAA2B,EAAE;IAC7D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IACrB,IAAI,CAACF,MAAM,GAAGA,MAAM;IAEpB,MAAMG,MAAM,GAAGN,IAAI,CAAe,IAAI,CAACI,KAAK,CAACG,EAAE,CAAC,CAACC,MAAM;IACvD,IAAI,CAACA,MAAM,GAAG,IAAI,CAACJ,KAAK,CAACI,MAAM,IAAI,IAAI,CAACL,MAAM,CAACK,MAAM,CAACC,qBAAqB,CAAC;MAC1EC,KAAK,EAAE,IAAI,CAACN,KAAK,CAACO,EAAE;MACpBC,OAAO,EAAE;QACPN,MAAM;QACNO,UAAU,EAAE,IAAI,CAACT,KAAK,CAACU;MAEzB,CAAC;MACDC,MAAM,EAAE;IACV,CAAC,CAAC;EACJ;EAGAC,mBAAmBA,CAAA,EAAG;IAEpB,OAAO,IAAI,CAACR,MAAM,CAACS,kBAAkB,CAAC,CAAC,CAAC;EAC1C;AACF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="dist" />
|
|
2
2
|
import { ExternalTexture, ExternalTextureProps, Sampler, SamplerProps } from '@luma.gl/api';
|
|
3
3
|
import type { WebGPUDevice } from '../webgpu-device';
|
|
4
|
-
import WebGPUSampler from './webgpu-sampler';
|
|
4
|
+
import { WebGPUSampler } from './webgpu-sampler';
|
|
5
5
|
/**
|
|
6
6
|
* Cheap, temporary texture view for videos
|
|
7
7
|
* Only valid within same callback, destroyed automatically as a microtask.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export declare class WebGPUExternalTexture extends ExternalTexture {
|
|
10
10
|
readonly device: WebGPUDevice;
|
|
11
11
|
readonly handle: GPUExternalTexture;
|
|
12
12
|
sampler: WebGPUSampler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-external-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-external-texture.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAC1F,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,aAAa,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgpu-external-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-external-texture.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAC1F,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,OAAO,EAAE,aAAa,CAAC;gBAEX,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB;IAUpD,OAAO,IAAI,IAAI;IAMxB,0BAA0B;IAC1B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI;CAKlD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { ExternalTexture } from '@luma.gl/api';
|
|
3
|
-
import WebGPUSampler from "./webgpu-sampler.js";
|
|
4
|
-
export
|
|
3
|
+
import { WebGPUSampler } from "./webgpu-sampler.js";
|
|
4
|
+
export class WebGPUExternalTexture extends ExternalTexture {
|
|
5
5
|
constructor(device, props) {
|
|
6
6
|
super(device, props);
|
|
7
7
|
_defineProperty(this, "device", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-external-texture.js","names":["ExternalTexture","WebGPUSampler","WebGPUExternalTexture","constructor","device","props","_defineProperty","handle","importExternalTexture","source","colorSpace","sampler","destroy","setSampler"],"sources":["../../../src/adapter/resources/webgpu-external-texture.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {ExternalTexture, ExternalTextureProps, Sampler, SamplerProps} from '@luma.gl/api';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport WebGPUSampler from './webgpu-sampler';\n\n/**\n * Cheap, temporary texture view for videos\n * Only valid within same callback, destroyed automatically as a microtask.\n */\nexport
|
|
1
|
+
{"version":3,"file":"webgpu-external-texture.js","names":["ExternalTexture","WebGPUSampler","WebGPUExternalTexture","constructor","device","props","_defineProperty","handle","importExternalTexture","source","colorSpace","sampler","destroy","setSampler"],"sources":["../../../src/adapter/resources/webgpu-external-texture.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {ExternalTexture, ExternalTextureProps, Sampler, SamplerProps} from '@luma.gl/api';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUSampler} from './webgpu-sampler';\n\n/**\n * Cheap, temporary texture view for videos\n * Only valid within same callback, destroyed automatically as a microtask.\n */\nexport class WebGPUExternalTexture extends ExternalTexture {\n readonly device: WebGPUDevice;\n readonly handle: GPUExternalTexture;\n sampler: WebGPUSampler;\n\n constructor(device: WebGPUDevice, props: ExternalTextureProps) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle || this.device.handle.importExternalTexture({\n source: props.source,\n colorSpace: props.colorSpace\n });\n this.sampler = null;\n }\n\n override destroy(): void {\n // External textures are destroyed automatically,\n // as a microtask, instead of manually or upon garbage collection like other resources.\n // this.handle.destroy();\n }\n\n /** Set default sampler */\n setSampler(sampler: Sampler | SamplerProps): this {\n // We can accept a sampler instance or set of props;\n this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n}\n"],"mappings":";AACA,SAAQA,eAAe,QAAoD,cAAc;AAAC,SAElFC,aAAa;AAMrB,OAAO,MAAMC,qBAAqB,SAASF,eAAe,CAAC;EAKzDG,WAAWA,CAACC,MAAoB,EAAEC,KAA2B,EAAE;IAC7D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACrB,IAAI,CAACF,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACG,MAAM,GAAG,IAAI,CAACF,KAAK,CAACE,MAAM,IAAI,IAAI,CAACH,MAAM,CAACG,MAAM,CAACC,qBAAqB,CAAC;MAC1EC,MAAM,EAAEJ,KAAK,CAACI,MAAM;MACpBC,UAAU,EAAEL,KAAK,CAACK;IACpB,CAAC,CAAC;IACF,IAAI,CAACC,OAAO,GAAG,IAAI;EACrB;EAESC,OAAOA,CAAA,EAAS,CAIzB;EAGAC,UAAUA,CAACF,OAA+B,EAAQ;IAEhD,IAAI,CAACA,OAAO,GAAGA,OAAO,YAAYV,aAAa,GAAGU,OAAO,GAAG,IAAIV,aAAa,CAAC,IAAI,CAACG,MAAM,EAAEO,OAAO,CAAC;IACnG,OAAO,IAAI;EACb;AACF"}
|
|
@@ -1,29 +1,12 @@
|
|
|
1
|
-
/// <reference types="dist" />
|
|
2
1
|
import type { FramebufferProps } from '@luma.gl/api';
|
|
3
2
|
import { Framebuffer } from '@luma.gl/api';
|
|
4
3
|
import { WebGPUDevice } from '../webgpu-device';
|
|
5
|
-
import WebGPUTexture from './webgpu-texture';
|
|
6
4
|
/**
|
|
7
5
|
* Create new textures with correct size for all attachments.
|
|
8
6
|
* @note resize() destroys existing textures (if size has changed).
|
|
9
7
|
*/
|
|
10
|
-
export
|
|
8
|
+
export declare class WebGPUFramebuffer extends Framebuffer {
|
|
11
9
|
readonly device: WebGPUDevice;
|
|
12
|
-
colorAttachments: WebGPUTexture[];
|
|
13
|
-
depthStencilAttachment: WebGPUTexture | null;
|
|
14
|
-
/** Partial render pass descriptor. Used by WebGPURenderPass */
|
|
15
|
-
renderPassDescriptor: {
|
|
16
|
-
colorAttachments: GPURenderPassColorAttachment[];
|
|
17
|
-
depthStencilAttachment?: GPURenderPassDepthStencilAttachment;
|
|
18
|
-
};
|
|
19
10
|
constructor(device: WebGPUDevice, props: FramebufferProps);
|
|
20
|
-
/** Create depth stencil texture */
|
|
21
|
-
private createDepthStencilTexture;
|
|
22
|
-
private createColorTexture;
|
|
23
|
-
/**
|
|
24
|
-
* Create new textures with correct size for all attachments.
|
|
25
|
-
* @note destroys existing textures.
|
|
26
|
-
*/
|
|
27
|
-
protected _resizeAttachments(width: number, height: number): void;
|
|
28
11
|
}
|
|
29
12
|
//# sourceMappingURL=webgpu-framebuffer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgpu-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AACzC,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;gBAElB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;CAO1D"}
|
|
@@ -1,93 +1,11 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { Framebuffer
|
|
3
|
-
|
|
4
|
-
export default class WebGPUFramebuffer extends Framebuffer {
|
|
2
|
+
import { Framebuffer } from '@luma.gl/api';
|
|
3
|
+
export class WebGPUFramebuffer extends Framebuffer {
|
|
5
4
|
constructor(device, props) {
|
|
6
5
|
super(device, props);
|
|
7
6
|
_defineProperty(this, "device", void 0);
|
|
8
|
-
_defineProperty(this, "colorAttachments", []);
|
|
9
|
-
_defineProperty(this, "depthStencilAttachment", null);
|
|
10
|
-
_defineProperty(this, "renderPassDescriptor", {
|
|
11
|
-
colorAttachments: []
|
|
12
|
-
});
|
|
13
7
|
this.device = device;
|
|
14
|
-
|
|
15
|
-
this.depthStencilAttachment = this.createDepthStencilTexture(props);
|
|
16
|
-
}
|
|
17
|
-
if (props.colorAttachments) {
|
|
18
|
-
this.colorAttachments = props.colorAttachments.map(colorAttachment => this.createColorTexture(this.props, colorAttachment));
|
|
19
|
-
}
|
|
20
|
-
if (this.depthStencilAttachment) {
|
|
21
|
-
this.renderPassDescriptor.depthStencilAttachment = {
|
|
22
|
-
view: this.depthStencilAttachment.handle.createView(),
|
|
23
|
-
depthClearValue: 1.0,
|
|
24
|
-
depthStoreOp: 'store',
|
|
25
|
-
stencilClearValue: 0,
|
|
26
|
-
stencilStoreOp: 'store'
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
if (this.colorAttachments.length > 0) {
|
|
30
|
-
this.renderPassDescriptor.colorAttachments = this.colorAttachments.map(colorAttachment => ({
|
|
31
|
-
view: colorAttachment.handle.createView(),
|
|
32
|
-
loadOp: 'clear',
|
|
33
|
-
loadValue: [0.0, 0.0, 0.0, 0.0],
|
|
34
|
-
storeOp: 'store'
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
createDepthStencilTexture(props) {
|
|
39
|
-
if (props.depthStencilAttachment instanceof WEBGPUTexture) {
|
|
40
|
-
return props.depthStencilAttachment;
|
|
41
|
-
}
|
|
42
|
-
if (typeof props.depthStencilAttachment === 'string') {
|
|
43
|
-
return this.device._createTexture({
|
|
44
|
-
id: 'depth-stencil-attachment',
|
|
45
|
-
format: props.depthStencilAttachment,
|
|
46
|
-
width: props.width,
|
|
47
|
-
height: props.height,
|
|
48
|
-
usage: Texture.RENDER_ATTACHMENT
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
throw new Error('type');
|
|
52
|
-
}
|
|
53
|
-
createColorTexture(props, texture) {
|
|
54
|
-
if (texture instanceof WEBGPUTexture) {
|
|
55
|
-
return texture;
|
|
56
|
-
}
|
|
57
|
-
if (typeof texture === 'string') {
|
|
58
|
-
return this.device._createTexture({
|
|
59
|
-
id: 'color-attachment',
|
|
60
|
-
format: texture,
|
|
61
|
-
width: props.width,
|
|
62
|
-
height: props.height,
|
|
63
|
-
usage: Texture.RENDER_ATTACHMENT
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
throw new Error('type');
|
|
67
|
-
}
|
|
68
|
-
_resizeAttachments(width, height) {
|
|
69
|
-
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
70
|
-
if (this.colorAttachments[i]) {
|
|
71
|
-
const resizedTexture = this.device._createTexture({
|
|
72
|
-
...this.colorAttachments[i].props,
|
|
73
|
-
width,
|
|
74
|
-
height
|
|
75
|
-
});
|
|
76
|
-
this.colorAttachments[i].destroy();
|
|
77
|
-
this.colorAttachments[i] = resizedTexture;
|
|
78
|
-
this.renderPassDescriptor.colorAttachments[i].view = resizedTexture.handle.createView();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (this.depthStencilAttachment) {
|
|
82
|
-
const resizedTexture = this.device._createTexture({
|
|
83
|
-
...this.depthStencilAttachment.props,
|
|
84
|
-
width,
|
|
85
|
-
height
|
|
86
|
-
});
|
|
87
|
-
this.depthStencilAttachment.destroy();
|
|
88
|
-
this.depthStencilAttachment = resizedTexture;
|
|
89
|
-
this.renderPassDescriptor.depthStencilAttachment.view = resizedTexture.handle.createView();
|
|
90
|
-
}
|
|
8
|
+
this.autoCreateAttachmentTextures();
|
|
91
9
|
}
|
|
92
10
|
}
|
|
93
11
|
//# sourceMappingURL=webgpu-framebuffer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-framebuffer.js","names":["Framebuffer","
|
|
1
|
+
{"version":3,"file":"webgpu-framebuffer.js","names":["Framebuffer","WebGPUFramebuffer","constructor","device","props","_defineProperty","autoCreateAttachmentTextures"],"sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"sourcesContent":["import type {FramebufferProps} from '@luma.gl/api';\nimport {Framebuffer} from '@luma.gl/api';\nimport {WebGPUDevice} from '../webgpu-device';\n\n/**\n * Create new textures with correct size for all attachments.\n * @note resize() destroys existing textures (if size has changed).\n */\nexport class WebGPUFramebuffer extends Framebuffer {\n readonly device: WebGPUDevice;\n\n constructor(device: WebGPUDevice, props: FramebufferProps) {\n super(device, props);\n this.device = device;\n\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n }\n}\n"],"mappings":";AACA,SAAQA,WAAW,QAAO,cAAc;AAOxC,OAAO,MAAMC,iBAAiB,SAASD,WAAW,CAAC;EAGjDE,WAAWA,CAACC,MAAoB,EAAEC,KAAuB,EAAE;IACzD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IACrB,IAAI,CAACF,MAAM,GAAGA,MAAM;IAGpB,IAAI,CAACG,4BAA4B,EAAE;EACrC;AACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="dist" />
|
|
2
|
-
import type { RenderPassProps, RenderPassParameters, Binding } from '@luma.gl/api';
|
|
2
|
+
import type { RenderPassProps, RenderPassParameters, Binding, Framebuffer } from '@luma.gl/api';
|
|
3
3
|
import { Buffer, RenderPass, RenderPipeline } from '@luma.gl/api';
|
|
4
4
|
import { WebGPUDevice } from '../webgpu-device';
|
|
5
|
-
import WebGPURenderPipeline from './webgpu-render-pipeline';
|
|
6
|
-
export
|
|
5
|
+
import { WebGPURenderPipeline } from './webgpu-render-pipeline';
|
|
6
|
+
export declare class WebGPURenderPass extends RenderPass {
|
|
7
7
|
readonly device: WebGPUDevice;
|
|
8
8
|
readonly handle: GPURenderPassEncoder;
|
|
9
9
|
/** Active pipeline */
|
|
@@ -30,5 +30,10 @@ export default class WebGPURenderPass extends RenderPass {
|
|
|
30
30
|
pushDebugGroup(groupLabel: string): void;
|
|
31
31
|
popDebugGroup(): void;
|
|
32
32
|
insertDebugMarker(markerLabel: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Partial render pass descriptor. Used by WebGPURenderPass.
|
|
35
|
+
* @returns attachments fields of a renderpass descriptor.
|
|
36
|
+
*/
|
|
37
|
+
protected getRenderPassDescriptor(framebuffer: Framebuffer): GPURenderPassDescriptor;
|
|
33
38
|
}
|
|
34
39
|
//# sourceMappingURL=webgpu-render-pass.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"webgpu-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AAC9F,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAO,MAAM,cAAc,CAAC;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAI9C,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;AAE9D,qBAAa,gBAAiB,SAAQ,UAAU;IAC9C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAEtC,sBAAsB;IACtB,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAQ;gBAEjC,MAAM,EAAE,YAAY,EAAE,KAAK,GAAE,eAAoB;IASpD,OAAO,IAAI,IAAI;IAExB,GAAG,IAAI,IAAI;IAIX,WAAW,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAK3C,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAQpD,cAAc,CACZ,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,cAAc,EAC3B,MAAM,GAAE,MAAU,EAClB,IAAI,CAAC,EAAE,MAAM,GACZ,IAAI;IAIP,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,IAAI;IAIvE,IAAI,CAAC,OAAO,EAAE;QACZ,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,IAAI;IAmBR,YAAY,IAAI,IAAI;IAKpB,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,IAAI;IAwBrD,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAGxC,aAAa,IAAI,IAAI;IAGrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAc5C;;;OAGG;IACH,SAAS,CAAC,uBAAuB,CAAC,WAAW,EAAE,WAAW,GAAG,uBAAuB;CAuBrF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { RenderPass, cast } from '@luma.gl/api';
|
|
3
|
-
export
|
|
3
|
+
export class WebGPURenderPass extends RenderPass {
|
|
4
4
|
constructor(device) {
|
|
5
5
|
let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6
6
|
super(device, props);
|
|
@@ -9,7 +9,7 @@ export default class WebGPURenderPass extends RenderPass {
|
|
|
9
9
|
_defineProperty(this, "pipeline", null);
|
|
10
10
|
this.device = device;
|
|
11
11
|
const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();
|
|
12
|
-
const renderPassDescriptor = framebuffer
|
|
12
|
+
const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);
|
|
13
13
|
this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);
|
|
14
14
|
this.handle.label = this.props.id;
|
|
15
15
|
}
|
|
@@ -75,5 +75,23 @@ export default class WebGPURenderPass extends RenderPass {
|
|
|
75
75
|
insertDebugMarker(markerLabel) {
|
|
76
76
|
this.handle.insertDebugMarker(markerLabel);
|
|
77
77
|
}
|
|
78
|
+
getRenderPassDescriptor(framebuffer) {
|
|
79
|
+
const renderPassDescriptor = {
|
|
80
|
+
colorAttachments: []
|
|
81
|
+
};
|
|
82
|
+
renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({
|
|
83
|
+
loadOp: 'clear',
|
|
84
|
+
colorClearValue: this.props.clearColor || [0, 0, 0, 0],
|
|
85
|
+
storeOp: this.props.discard ? 'discard' : 'store',
|
|
86
|
+
view: colorAttachment.handle.createView()
|
|
87
|
+
}));
|
|
88
|
+
if (framebuffer.depthStencilAttachment) {
|
|
89
|
+
renderPassDescriptor.depthStencilAttachment = {
|
|
90
|
+
...this.props,
|
|
91
|
+
view: framebuffer.depthStencilAttachment.handle.createView()
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return renderPassDescriptor;
|
|
95
|
+
}
|
|
78
96
|
}
|
|
79
97
|
//# sourceMappingURL=webgpu-render-pass.js.map
|