@luma.gl/webgpu 9.0.0-alpha.5 → 9.0.0-alpha.7

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.
@@ -2,11 +2,14 @@
2
2
  import type { Binding, RenderPass } from '@luma.gl/api';
3
3
  import { Buffer, RenderPipeline, RenderPipelineProps } from '@luma.gl/api';
4
4
  import type WebGPUDevice from '../webgpu-device';
5
+ import type WebGPUShader from './webgpu-shader';
5
6
  import type WebGPURenderPass from './webgpu-render-pass';
6
7
  /** Creates a new render pipeline when parameters change */
7
8
  export default class WebGPURenderPipeline extends RenderPipeline {
8
9
  device: WebGPUDevice;
9
10
  handle: GPURenderPipeline;
11
+ vs: WebGPUShader;
12
+ fs: WebGPUShader | null;
10
13
  private _bufferSlots;
11
14
  private _buffers;
12
15
  private _indexBuffer;
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AACtD,OAAO,EAAC,MAAM,EAAE,cAAc,EAAE,mBAAmB,EAA2B,MAAM,cAAc,CAAC;AASnG,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAGjD,OAAO,KAAK,gBAAgB,MAAM,sBAAsB,CAAC;AAIzD,2DAA2D;AAC3D,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,cAAc;IAC9D,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,iBAAiB,CAAC;IAE1B,OAAO,CAAC,YAAY,CAAyB;IAC7C,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,YAAY,CAAe;IAInC,4CAA4C;IAC5C,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,OAAO,CAAC,UAAU,CAAsB;gBAE5B,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,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B,EAAE,gBAAgB;CAwCxD"}
@@ -12,6 +12,10 @@ export default class WebGPURenderPipeline extends RenderPipeline {
12
12
 
13
13
  _defineProperty(this, "handle", void 0);
14
14
 
15
+ _defineProperty(this, "vs", void 0);
16
+
17
+ _defineProperty(this, "fs", null);
18
+
15
19
  _defineProperty(this, "_bufferSlots", void 0);
16
20
 
17
21
  _defineProperty(this, "_buffers", void 0);
@@ -25,6 +29,8 @@ export default class WebGPURenderPipeline extends RenderPipeline {
25
29
  this.device = device;
26
30
  this.handle = this.props.handle || this.createHandle();
27
31
  this.handle.label = this.props.id;
32
+ this.vs = cast(props.vs);
33
+ this.fs = cast(props.fs);
28
34
  this._bufferSlots = getBufferSlots(this.props.layout, this.props.bufferMap);
29
35
  this._buffers = new Array(Object.keys(this._bufferSlots).length).fill(null);
30
36
  this._bindGroupLayout = this.handle.getBindGroupLayout(0);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"names":["RenderPipeline","cast","log","isObjectEmpty","applyParametersToRenderPipelineDescriptor","getWebGPUTextureFormat","getBindGroup","getVertexBufferLayout","getBufferSlots","WebGPURenderPipeline","constructor","device","props","handle","createHandle","label","id","_bufferSlots","layout","bufferMap","_buffers","Array","Object","keys","length","fill","_bindGroupLayout","getBindGroupLayout","descriptor","_getRenderPipelineDescriptor","renderPipeline","createRenderPipeline","groupCollapsed","JSON","stringify","groupEnd","destroy","setIndexBuffer","indexBuffer","_indexBuffer","setAttributes","attributes","name","buffer","entries","bufferIndex","Error","setBindings","bindings","assign","_bindGroup","setUniforms","uniforms","_getBuffers","_getBindGroup","vertex","module","vs","entryPoint","vsEntryPoint","buffers","fragment","fs","fsEntryPoint","targets","format","canvasContext","primitive","topology","parameters","draw","options","webgpuRenderPass","renderPass","getDefaultRenderPass","setPipeline","setBindGroup","_setAttributeBuffers","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","indexType","i","attribute","find","location","setVertexBuffer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ACX,cAAM4C,SAAS,GAAG,KAAK3E,KAAL,CAAWM,MAAX,CAAkBuB,UAAlB,CAA6B+C,IAA7B,CACfD,SAAD,IAAeA,SAAS,CAACE,QAAV,KAAuBH,CADtB,CAAlB;AAGA,cAAM,IAAIxC,KAAJ,6CACiC,CAAAyC,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAE7C,IAAX,KAAmB,EADpD,yBACqE,KAAK9B,KAAL,CAAWI,EADhF,OAAN;AAGD;;AACDwD,MAAAA,gBAAgB,CAAC3D,MAAjB,CAAwB6E,eAAxB,CAAwCJ,CAAxC,EAA2C3C,MAAM,CAAC9B,MAAlD;AACD;AAsBF;;AAnN8D","sourcesContent":["import type {Binding, RenderPass} from '@luma.gl/api';\nimport {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/api';\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 default class WebGPURenderPipeline extends RenderPipeline {\n device: WebGPUDevice;\n handle: GPURenderPipeline;\n\n private _bufferSlots: Record<string, number>;\n private _buffers: Buffer[];\n private _indexBuffer: WebGPUBuffer;\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;\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._bufferSlots = getBufferSlots(this.props.layout, this.props.bufferMap);\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 destroy() {\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 /** Set the bindings */\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.layout,\n this.props.bindings\n );\n }\n }\n\n setUniforms(uniforms: Record<string, any>): 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.layout, this.props.bufferMap)\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 format: getWebGPUTextureFormat(this.device.canvasContext.format)\n }\n ]\n };\n }\n\n // Create a partially populated descriptor\n let descriptor: GPURenderPipelineDescriptor = {\n vertex,\n fragment,\n primitive: {\n topology: this.props.topology\n }\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 =\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 if (this._getBindGroup()) {\n webgpuRenderPass.handle.setBindGroup(0, this._getBindGroup());\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,\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.layout.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.bufferMap)) {\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"],"file":"webgpu-render-pipeline.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"names":["RenderPipeline","cast","log","isObjectEmpty","applyParametersToRenderPipelineDescriptor","getWebGPUTextureFormat","getBindGroup","getVertexBufferLayout","getBufferSlots","WebGPURenderPipeline","constructor","device","props","handle","createHandle","label","id","vs","fs","_bufferSlots","layout","bufferMap","_buffers","Array","Object","keys","length","fill","_bindGroupLayout","getBindGroupLayout","descriptor","_getRenderPipelineDescriptor","renderPipeline","createRenderPipeline","groupCollapsed","JSON","stringify","groupEnd","destroy","setIndexBuffer","indexBuffer","_indexBuffer","setAttributes","attributes","name","buffer","entries","bufferIndex","Error","setBindings","bindings","assign","_bindGroup","setUniforms","uniforms","_getBuffers","_getBindGroup","vertex","module","entryPoint","vsEntryPoint","buffers","fragment","fsEntryPoint","targets","format","canvasContext","primitive","topology","parameters","draw","options","webgpuRenderPass","renderPass","getDefaultRenderPass","setPipeline","setBindGroup","_setAttributeBuffers","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","indexType","i","attribute","find","location","setVertexBuffer"],"mappings":";AACA,SAAgBA,cAAhB,EAAqDC,IAArD,EAA2DC,GAA3D,EAAgEC,aAAhE,QAAoF,cAApF;AACA,SAAQC,yCAAR,QAAwD,8BAAxD;AACA,SAAQC,sBAAR,QAAqC,mCAArC;AACA,SAAQC,YAAR,QAA2B,2BAA3B;AACA,SAAQC,qBAAR,EAA+BC,cAA/B,QAAoD,qCAApD;AAaA,eAAe,MAAMC,oBAAN,SAAmCT,cAAnC,CAAkD;AAiB/DU,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAmD;AAC5D,UAAMD,MAAN,EAAcC,KAAd;;AAD4D;;AAAA;;AAAA;;AAAA,gCAZpC,IAYoC;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,wCAF3B,IAE2B;;AAE5D,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,MAAL,GAAe,KAAKD,KAAL,CAAWC,MAAZ,IAA4C,KAAKC,YAAL,EAA1D;AACA,SAAKD,MAAL,CAAYE,KAAZ,GAAoB,KAAKH,KAAL,CAAWI,EAA/B;AAEA,SAAKC,EAAL,GAAUhB,IAAI,CAAeW,KAAK,CAACK,EAArB,CAAd;AACA,SAAKC,EAAL,GAAUjB,IAAI,CAAeW,KAAK,CAACM,EAArB,CAAd;AAEA,SAAKC,YAAL,GAAoBX,cAAc,CAAC,KAAKI,KAAL,CAAWQ,MAAZ,EAAoB,KAAKR,KAAL,CAAWS,SAA/B,CAAlC;AACA,SAAKC,QAAL,GAAgB,IAAIC,KAAJ,CAAkBC,MAAM,CAACC,IAAP,CAAY,KAAKN,YAAjB,EAA+BO,MAAjD,EAAyDC,IAAzD,CAA8D,IAA9D,CAAhB;AACA,SAAKC,gBAAL,GAAwB,KAAKf,MAAL,CAAYgB,kBAAZ,CAA+B,CAA/B,C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ByE,SAAzF;AACD;;AAED,UAAMxB,OAAO,GAAG,KAAKN,WAAL,EAAhB;;AACA,SAAK,IAAI+B,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGzB,OAAO,CAACnC,MAA5B,EAAoC,EAAE4D,CAAtC,EAAyC;AACvC,YAAMzC,MAAM,GAAG5C,IAAI,CAAe4D,OAAO,CAACyB,CAAD,CAAtB,CAAnB;;AACA,UAAI,CAACzC,MAAL,EAAa;AACX,cAAM0C,SAAS,GAAG,KAAK3E,KAAL,CAAWQ,MAAX,CAAkBuB,UAAlB,CAA6B6C,IAA7B,CACfD,SAAD,IAAeA,SAAS,CAACE,QAAV,KAAuBH,CADtB,CAAlB;AAGA,cAAM,IAAItC,KAAJ,6CACiC,CAAAuC,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAE3C,IAAX,KAAmB,EADpD,yBACqE,KAAKhC,KAAL,CAAWI,EADhF,OAAN;AAGD;;AACDwD,MAAAA,gBAAgB,CAAC3D,MAAjB,CAAwB6E,eAAxB,CAAwCJ,CAAxC,EAA2CzC,MAAM,CAAChC,MAAlD;AACD;AAsBF;;AAzN8D","sourcesContent":["import type {Binding, RenderPass, Shader} from '@luma.gl/api';\nimport {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/api';\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 default 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;\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;\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.layout, this.props.bufferMap);\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 destroy() {\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 /** Set the bindings */\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.layout,\n this.props.bindings\n );\n }\n }\n\n setUniforms(uniforms: Record<string, any>): 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.layout, this.props.bufferMap)\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 format: getWebGPUTextureFormat(this.device.canvasContext.format)\n }\n ]\n };\n }\n\n // Create a partially populated descriptor\n let descriptor: GPURenderPipelineDescriptor = {\n vertex,\n fragment,\n primitive: {\n topology: this.props.topology\n }\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 =\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 if (this._getBindGroup()) {\n webgpuRenderPass.handle.setBindGroup(0, this._getBindGroup());\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,\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.layout.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.bufferMap)) {\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"],"file":"webgpu-render-pipeline.js"}
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-sampler.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-sampler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAEjD,oBAAY,kBAAkB,GAAG,YAAY,GAAG;IAC9C,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAChD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,kBAAkB;IAO3D,OAAO,IAAI,IAAI;CAGhB"}
1
+ {"version":3,"file":"webgpu-sampler.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-sampler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAEjD,oBAAY,kBAAkB,GAAG,YAAY,GAAG;IAC9C,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAChD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,kBAAkB;IAc3D,OAAO,IAAI,IAAI;CAGhB"}
@@ -9,6 +9,12 @@ export default class WebGPUSampler extends Sampler {
9
9
  _defineProperty(this, "handle", void 0);
10
10
 
11
11
  this.device = device;
12
+ const samplerProps = this.props;
13
+
14
+ if (samplerProps.type !== 'comparison-sampler') {
15
+ delete samplerProps.compare;
16
+ }
17
+
12
18
  this.handle = this.handle || this.device.handle.createSampler(this.props);
13
19
  this.handle.label = this.props.id;
14
20
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-sampler.ts"],"names":["Sampler","WebGPUSampler","constructor","device","props","handle","createSampler","label","id","destroy"],"mappings":";AAAA,SAAQA,OAAR,QAAoC,cAApC;AAUA,eAAe,MAAMC,aAAN,SAA4BD,OAA5B,CAAoC;AAIjDE,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAkD;AAC3D,UAAMD,MAAN,EAAcC,KAAd;;AAD2D;;AAAA;;AAE3D,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,MAAL,GAAc,KAAKA,MAAL,IAAe,KAAKF,MAAL,CAAYE,MAAZ,CAAmBC,aAAnB,CAAiC,KAAKF,KAAtC,CAA7B;AACA,SAAKC,MAAL,CAAYE,KAAZ,GAAoB,KAAKH,KAAL,CAAWI,EAA/B;AACD;;AAEDC,EAAAA,OAAO,GAAS,CAEf;;AAbgD","sourcesContent":["import {Sampler, SamplerProps} from '@luma.gl/api';\nimport type WebGPUDevice from '../webgpu-device';\n\nexport type WebGPUSamplerProps = SamplerProps & {\n handle?: GPUSampler;\n}\n\n/**\n *\n */\nexport default 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 this.handle = this.handle || this.device.handle.createSampler(this.props);\n this.handle.label = this.props.id;\n }\n\n destroy(): void {\n // this.handle.destroy();\n }\n}\n"],"file":"webgpu-sampler.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-sampler.ts"],"names":["Sampler","WebGPUSampler","constructor","device","props","samplerProps","type","compare","handle","createSampler","label","id","destroy"],"mappings":";AAAA,SAAQA,OAAR,QAAoC,cAApC;AAUA,eAAe,MAAMC,aAAN,SAA4BD,OAA5B,CAAoC;AAIjDE,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAkD;AAC3D,UAAMD,MAAN,EAAcC,KAAd;;AAD2D;;AAAA;;AAE3D,SAAKD,MAAL,GAAcA,MAAd;AAGA,UAAME,YAAY,GAAG,KAAKD,KAA1B;;AACA,QAAIC,YAAY,CAACC,IAAb,KAAsB,oBAA1B,EAAgD;AAC9C,aAAOD,YAAY,CAACE,OAApB;AACD;;AAED,SAAKC,MAAL,GAAc,KAAKA,MAAL,IAAe,KAAKL,MAAL,CAAYK,MAAZ,CAAmBC,aAAnB,CAAiC,KAAKL,KAAtC,CAA7B;AACA,SAAKI,MAAL,CAAYE,KAAZ,GAAoB,KAAKN,KAAL,CAAWO,EAA/B;AACD;;AAEDC,EAAAA,OAAO,GAAS,CAEf;;AApBgD","sourcesContent":["import {Sampler, SamplerProps} from '@luma.gl/api';\nimport type WebGPUDevice from '../webgpu-device';\n\nexport type WebGPUSamplerProps = SamplerProps & {\n handle?: GPUSampler;\n}\n\n/**\n *\n */\nexport default 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 = this.props;\n if (samplerProps.type !== 'comparison-sampler') {\n delete samplerProps.compare;\n }\n\n this.handle = this.handle || this.device.handle.createSampler(this.props);\n this.handle.label = this.props.id;\n }\n\n destroy(): void {\n // this.handle.destroy();\n }\n}\n"],"file":"webgpu-sampler.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/webgpu",
3
- "version": "9.0.0-alpha.5",
3
+ "version": "9.0.0-alpha.7",
4
4
  "description": "WebGPU adapter for the luma.gl API",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,9 +28,9 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@babel/runtime": "^7.0.0",
31
- "@luma.gl/api": "9.0.0-alpha.5",
31
+ "@luma.gl/api": "9.0.0-alpha.7",
32
32
  "@webgpu/types": "^0.1.9",
33
33
  "probe.gl": "^3.2.1"
34
34
  },
35
- "gitHead": "729cfdd272836270d0f59793b8a36a2a3aea47ca"
35
+ "gitHead": "c1fbf71bb1311dcdc54338d82d299f8ed0d73346"
36
36
  }
@@ -1,4 +1,4 @@
1
- import type {Binding, RenderPass} from '@luma.gl/api';
1
+ import type {Binding, RenderPass, Shader} from '@luma.gl/api';
2
2
  import {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/api';
3
3
  import {applyParametersToRenderPipelineDescriptor} from '../helpers/webgpu-parameters';
4
4
  import {getWebGPUTextureFormat} from '../helpers/convert-texture-format';
@@ -20,6 +20,9 @@ export default class WebGPURenderPipeline extends RenderPipeline {
20
20
  device: WebGPUDevice;
21
21
  handle: GPURenderPipeline;
22
22
 
23
+ vs: WebGPUShader;
24
+ fs: WebGPUShader | null = null;
25
+
23
26
  private _bufferSlots: Record<string, number>;
24
27
  private _buffers: Buffer[];
25
28
  private _indexBuffer: WebGPUBuffer;
@@ -36,6 +39,9 @@ export default class WebGPURenderPipeline extends RenderPipeline {
36
39
  this.handle = (this.props.handle as GPURenderPipeline) || this.createHandle();
37
40
  this.handle.label = this.props.id;
38
41
 
42
+ this.vs = cast<WebGPUShader>(props.vs);
43
+ this.fs = cast<WebGPUShader>(props.fs);
44
+
39
45
  this._bufferSlots = getBufferSlots(this.props.layout, this.props.bufferMap);
40
46
  this._buffers = new Array<Buffer>(Object.keys(this._bufferSlots).length).fill(null);
41
47
  this._bindGroupLayout = this.handle.getBindGroupLayout(0);
@@ -15,6 +15,13 @@ export default class WebGPUSampler extends Sampler {
15
15
  constructor(device: WebGPUDevice, props: WebGPUSamplerProps) {
16
16
  super(device, props);
17
17
  this.device = device;
18
+
19
+ // Prepare sampler props
20
+ const samplerProps = this.props;
21
+ if (samplerProps.type !== 'comparison-sampler') {
22
+ delete samplerProps.compare;
23
+ }
24
+
18
25
  this.handle = this.handle || this.device.handle.createSampler(this.props);
19
26
  this.handle.label = this.props.id;
20
27
  }