@luma.gl/webgpu 9.0.0-beta.6 → 9.0.0-beta.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.
Files changed (63) hide show
  1. package/dist/adapter/helpers/get-bind-group.d.ts +3 -3
  2. package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
  3. package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
  4. package/dist/adapter/resources/webgpu-buffer.js +3 -1
  5. package/dist/adapter/resources/webgpu-compute-pass.d.ts +14 -8
  6. package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
  7. package/dist/adapter/resources/webgpu-compute-pass.js +18 -13
  8. package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +13 -3
  9. package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
  10. package/dist/adapter/resources/webgpu-compute-pipeline.js +25 -7
  11. package/dist/adapter/resources/webgpu-external-texture.d.ts.map +1 -1
  12. package/dist/adapter/resources/webgpu-external-texture.js +2 -0
  13. package/dist/adapter/resources/webgpu-query-set.d.ts.map +1 -1
  14. package/dist/adapter/resources/webgpu-query-set.js +3 -1
  15. package/dist/adapter/resources/webgpu-render-pipeline.d.ts +49 -1
  16. package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
  17. package/dist/adapter/resources/webgpu-render-pipeline.js +69 -51
  18. package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
  19. package/dist/adapter/resources/webgpu-sampler.js +3 -0
  20. package/dist/adapter/resources/webgpu-shader.d.ts +1 -4
  21. package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
  22. package/dist/adapter/resources/webgpu-shader.js +7 -18
  23. package/dist/adapter/resources/webgpu-texture-view.d.ts.map +1 -1
  24. package/dist/adapter/resources/webgpu-texture-view.js +3 -0
  25. package/dist/adapter/resources/webgpu-texture.d.ts +3 -4
  26. package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
  27. package/dist/adapter/resources/webgpu-texture.js +8 -8
  28. package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
  29. package/dist/adapter/webgpu-canvas-context.js +2 -1
  30. package/dist/adapter/webgpu-device.d.ts +2 -7
  31. package/dist/adapter/webgpu-device.d.ts.map +1 -1
  32. package/dist/adapter/webgpu-device.js +9 -19
  33. package/dist/dist.dev.js +132 -175
  34. package/dist/index.cjs +122 -131
  35. package/dist/index.cjs.map +4 -4
  36. package/dist.min.js +1 -1
  37. package/package.json +2 -2
  38. package/src/adapter/helpers/get-bind-group.ts +4 -4
  39. package/src/adapter/resources/webgpu-buffer.ts +3 -1
  40. package/src/adapter/resources/webgpu-compute-pass.ts +19 -14
  41. package/src/adapter/resources/webgpu-compute-pipeline.ts +36 -9
  42. package/src/adapter/resources/webgpu-external-texture.ts +2 -0
  43. package/src/adapter/resources/webgpu-query-set.ts +3 -1
  44. package/src/adapter/resources/webgpu-render-pipeline.ts +63 -92
  45. package/src/adapter/resources/webgpu-sampler.ts +3 -0
  46. package/src/adapter/resources/webgpu-shader.ts +8 -23
  47. package/src/adapter/resources/webgpu-texture-view.ts +3 -0
  48. package/src/adapter/resources/webgpu-texture.ts +11 -10
  49. package/src/adapter/webgpu-canvas-context.ts +2 -1
  50. package/src/adapter/webgpu-device.ts +11 -20
  51. package/dist/adapter/helpers/generate-mipmaps.d.ts +0 -10
  52. package/dist/adapter/helpers/generate-mipmaps.d.ts.map +0 -1
  53. package/dist/adapter/helpers/generate-mipmaps.js +0 -103
  54. package/dist/adapter/resources/webgpu-query.d.ts +0 -1
  55. package/dist/adapter/resources/webgpu-query.d.ts.map +0 -1
  56. package/dist/adapter/resources/webgpu-query.js +0 -43
  57. package/dist/adapter/webgpu-types.d.ts +0 -1
  58. package/dist/adapter/webgpu-types.d.ts.map +0 -1
  59. package/dist/adapter/webgpu-types.js +0 -0
  60. package/dist/glsl/glsllang.d.ts +0 -3
  61. package/dist/glsl/glsllang.d.ts.map +0 -1
  62. package/dist/glsl/glsllang.js +0 -12
  63. package/src/adapter/helpers/generate-mipmaps.ts +0 -118
@@ -1,5 +1,5 @@
1
1
  /// <reference types="dist" />
2
- import type { ShaderLayout, BindingDeclaration, Binding } from '@luma.gl/core';
2
+ import type { ComputeShaderLayout, BindingDeclaration, Binding } from '@luma.gl/core';
3
3
  /**
4
4
  * Create a WebGPU "bind group layout" from an array of luma.gl bindings
5
5
  * @note bind groups can be automatically generated by WebGPU.
@@ -8,6 +8,6 @@ export declare function makeBindGroupLayout(device: GPUDevice, layout: GPUBindGr
8
8
  /**
9
9
  * Create a WebGPU "bind group" from an array of luma.gl bindings
10
10
  */
11
- export declare function getBindGroup(device: GPUDevice, bindGroupLayout: GPUBindGroupLayout, shaderLayout: ShaderLayout, bindings: Record<string, Binding>): GPUBindGroup;
12
- export declare function getShaderLayoutBinding(shaderLayout: ShaderLayout, bindingName: string): BindingDeclaration;
11
+ export declare function getBindGroup(device: GPUDevice, bindGroupLayout: GPUBindGroupLayout, shaderLayout: ComputeShaderLayout, bindings: Record<string, Binding>): GPUBindGroup;
12
+ export declare function getShaderLayoutBinding(shaderLayout: ComputeShaderLayout, bindingName: string): BindingDeclaration;
13
13
  //# sourceMappingURL=get-bind-group.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-bind-group.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-bind-group.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAC,YAAY,EAAE,kBAAkB,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAM7E;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,OAAO,EAAE,GAClB,kBAAkB,CAMpB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,eAAe,EAAE,kBAAkB,EACnC,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,YAAY,CAMd;AAED,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,MAAM,GAClB,kBAAkB,CASpB"}
1
+ {"version":3,"file":"get-bind-group.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-bind-group.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAC,mBAAmB,EAAE,kBAAkB,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAMpF;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,OAAO,EAAE,GAClB,kBAAkB,CAMpB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,eAAe,EAAE,kBAAkB,EACnC,YAAY,EAAE,mBAAmB,EACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,YAAY,CAMd;AAED,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,mBAAmB,EACjC,WAAW,EAAE,MAAM,GAClB,kBAAkB,CASpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;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;IA8B3C,OAAO,IAAI,IAAI;IAKf,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,SAAI;I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,CAAC,EAAE,MAAM,GAAG,WAAW;IAI9D,KAAK,IAAI,IAAI;CAGd;AA4CD;;;;;;;;EAQE"}
@@ -34,7 +34,9 @@ export class WebGPUBuffer extends Buffer {
34
34
  }
35
35
  }
36
36
  destroy() {
37
- this.handle.destroy();
37
+ this.handle?.destroy();
38
+ // @ts-expect-error readonly
39
+ this.handle = null;
38
40
  }
39
41
  // WebGPU provides multiple ways to write a buffer...
40
42
  write(data, byteOffset = 0) {
@@ -1,30 +1,36 @@
1
1
  /// <reference types="dist" />
2
2
  import { ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding } from '@luma.gl/core';
3
3
  import { WebGPUDevice } from "../webgpu-device.js";
4
+ import { WebGPUComputePipeline } from "./webgpu-compute-pipeline.js";
4
5
  export declare class WebGPUComputePass extends ComputePass {
5
6
  readonly device: WebGPUDevice;
6
7
  readonly handle: GPUComputePassEncoder;
7
- _bindGroupLayout: GPUBindGroupLayout | null;
8
+ _webgpuPipeline: WebGPUComputePipeline | null;
8
9
  constructor(device: WebGPUDevice, props: ComputePassProps);
9
10
  /** @note no WebGPU destroy method, just gc */
10
11
  destroy(): void;
11
12
  end(): void;
12
13
  setPipeline(pipeline: ComputePipeline): void;
13
- /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */
14
+ /**
15
+ * Sets an array of bindings (uniform buffers, samplers, textures, ...)
16
+ * TODO - still some API confusion - does this method go here or on the pipeline?
17
+ */
14
18
  setBindings(bindings: Binding[]): void;
15
19
  /**
16
20
  * Dispatch work to be performed with the current ComputePipeline.
17
- * @param x X dimension of the grid of workgroups to dispatch.
18
- * @param y Y dimension of the grid of workgroups to dispatch.
19
- * @param z Z dimension of the grid of workgroups to dispatch.
21
+ * @param x X dimension of the grid of work groups to dispatch.
22
+ * @param y Y dimension of the grid of work groups to dispatch.
23
+ * @param z Z dimension of the grid of work groups to dispatch.
20
24
  */
21
25
  dispatch(x: number, y?: number, z?: number): void;
22
26
  /**
23
27
  * Dispatch work to be performed with the current ComputePipeline.
24
- * @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()
25
- * @param indirectOffset
28
+ *
29
+ * 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()
30
+ * @param indirectBuffer
31
+ * @param indirectOffset offset in buffer to the beginning of the dispatch data.
26
32
  */
27
- dispatchIndirect(indirectBuffer: Buffer, indirectOffset?: number): void;
33
+ dispatchIndirect(indirectBuffer: Buffer, indirectByteOffset?: number): void;
28
34
  pushDebugGroup(groupLabel: string): void;
29
35
  popDebugGroup(): void;
30
36
  insertDebugMarker(markerLabel: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-compute-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAC,YAAY,EAAC,4BAAyB;AAM9C,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;IAyBzD,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,gB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IAAI;CAG7C"}
@@ -5,7 +5,7 @@ import { ComputePass } from '@luma.gl/core';
5
5
  export class WebGPUComputePass extends ComputePass {
6
6
  device;
7
7
  handle;
8
- _bindGroupLayout = null;
8
+ _webgpuPipeline = null;
9
9
  constructor(device, props) {
10
10
  super(device, props);
11
11
  this.device = device;
@@ -36,31 +36,36 @@ export class WebGPUComputePass extends ComputePass {
36
36
  setPipeline(pipeline) {
37
37
  const wgpuPipeline = pipeline;
38
38
  this.handle.setPipeline(wgpuPipeline.handle);
39
- this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();
39
+ this._webgpuPipeline = wgpuPipeline;
40
+ this.setBindings([]);
40
41
  }
41
- /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */
42
+ /**
43
+ * Sets an array of bindings (uniform buffers, samplers, textures, ...)
44
+ * TODO - still some API confusion - does this method go here or on the pipeline?
45
+ */
42
46
  setBindings(bindings) {
43
- throw new Error('fix me');
44
- // const bindGroup = getBindGroup(this.device.handle, this._bindGroupLayout, this.props.bindings);
45
- // this.handle.setBindGroup(0, bindGroup);
47
+ const bindGroup = this._webgpuPipeline._getBindGroup();
48
+ this.handle.setBindGroup(0, bindGroup);
46
49
  }
47
50
  /**
48
51
  * Dispatch work to be performed with the current ComputePipeline.
49
- * @param x X dimension of the grid of workgroups to dispatch.
50
- * @param y Y dimension of the grid of workgroups to dispatch.
51
- * @param z Z dimension of the grid of workgroups to dispatch.
52
+ * @param x X dimension of the grid of work groups to dispatch.
53
+ * @param y Y dimension of the grid of work groups to dispatch.
54
+ * @param z Z dimension of the grid of work groups to dispatch.
52
55
  */
53
56
  dispatch(x, y, z) {
54
57
  this.handle.dispatchWorkgroups(x, y, z);
55
58
  }
56
59
  /**
57
60
  * Dispatch work to be performed with the current ComputePipeline.
58
- * @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()
59
- * @param indirectOffset
61
+ *
62
+ * 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()
63
+ * @param indirectBuffer
64
+ * @param indirectOffset offset in buffer to the beginning of the dispatch data.
60
65
  */
61
- dispatchIndirect(indirectBuffer, indirectOffset = 0) {
66
+ dispatchIndirect(indirectBuffer, indirectByteOffset = 0) {
62
67
  const webgpuBuffer = indirectBuffer;
63
- this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectOffset);
68
+ this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectByteOffset);
64
69
  }
65
70
  pushDebugGroup(groupLabel) {
66
71
  this.handle.pushDebugGroup(groupLabel);
@@ -1,12 +1,22 @@
1
1
  /// <reference types="dist" />
2
- import { ComputePipeline, ComputePipelineProps } from '@luma.gl/core';
2
+ import { ComputePipeline, ComputePipelineProps, Binding } from '@luma.gl/core';
3
3
  import { WebGPUDevice } from "../webgpu-device.js";
4
4
  /** Creates a new compute pipeline when parameters change */
5
5
  export declare class WebGPUComputePipeline extends ComputePipeline {
6
6
  device: WebGPUDevice;
7
7
  handle: GPUComputePipeline;
8
+ /** For internal use to create BindGroups */
9
+ private _bindGroupLayout;
10
+ private _bindGroup;
11
+ /** For internal use to create BindGroups */
12
+ private _bindings;
8
13
  constructor(device: WebGPUDevice, props: ComputePipelineProps);
9
- /** For internal use in render passes */
10
- _getBindGroupLayout(): GPUBindGroupLayout;
14
+ /**
15
+ * @todo Use renderpass.setBindings() ?
16
+ * @todo Do we want to expose BindGroups in the API and remove this?
17
+ */
18
+ setBindings(bindings: Record<string, Binding>): void;
19
+ /** Return a bind group created by setBindings */
20
+ _getBindGroup(): GPUBindGroup;
11
21
  }
12
22
  //# sourceMappingURL=webgpu-compute-pipeline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-compute-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pipeline.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAC,YAAY,EAAC,4BAAyB;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;IAkB7D,wCAAwC;IACxC,mBAAmB;CAIpB"}
1
+ {"version":3,"file":"webgpu-compute-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pipeline.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE7E,OAAO,EAAC,YAAY,EAAC,4BAAyB;AAK9C,4DAA4D;AAC5D,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,kBAAkB,CAAC;IAE3B,4CAA4C;IAC5C,OAAO,CAAC,gBAAgB,CAAmC;IAC3D,OAAO,CAAC,UAAU,CAA6B;IAC/C,4CAA4C;IAC5C,OAAO,CAAC,SAAS,CAA+B;gBAEpC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB;IAmB7D;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIpD,iDAAiD;IACjD,aAAa;CAgBd"}
@@ -2,30 +2,48 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
  import { ComputePipeline } from '@luma.gl/core';
5
+ import { getBindGroup } from "../helpers/get-bind-group.js";
5
6
  // COMPUTE PIPELINE
6
7
  /** Creates a new compute pipeline when parameters change */
7
8
  export class WebGPUComputePipeline extends ComputePipeline {
8
9
  device;
9
10
  handle;
11
+ /** For internal use to create BindGroups */
12
+ _bindGroupLayout = null;
13
+ _bindGroup = null;
14
+ /** For internal use to create BindGroups */
15
+ _bindings = {};
10
16
  constructor(device, props) {
11
17
  super(device, props);
12
18
  this.device = device;
13
- const webgpuShader = this.props.cs;
19
+ const webgpuShader = this.props.shader;
14
20
  this.handle =
15
21
  this.props.handle ||
16
22
  this.device.handle.createComputePipeline({
17
23
  label: this.props.id,
18
24
  compute: {
19
25
  module: webgpuShader.handle,
20
- entryPoint: this.props.csEntryPoint
21
- // constants: this.props.csConstants
26
+ entryPoint: this.props.entryPoint,
27
+ constants: this.props.constants
22
28
  },
23
29
  layout: 'auto'
24
30
  });
25
31
  }
26
- /** For internal use in render passes */
27
- _getBindGroupLayout() {
28
- // TODO: Cache?
29
- return this.handle.getBindGroupLayout(0);
32
+ /**
33
+ * @todo Use renderpass.setBindings() ?
34
+ * @todo Do we want to expose BindGroups in the API and remove this?
35
+ */
36
+ setBindings(bindings) {
37
+ Object.assign(this._bindings, bindings);
38
+ }
39
+ /** Return a bind group created by setBindings */
40
+ _getBindGroup() {
41
+ // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group
42
+ this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);
43
+ // Set up the bindings
44
+ this._bindGroup =
45
+ this._bindGroup ||
46
+ getBindGroup(this.device.handle, this._bindGroupLayout, this.props.shaderLayout, this._bindings);
47
+ return this._bindGroup;
30
48
  }
31
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-external-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-external-texture.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3F,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AACnD,OAAO,EAAC,aAAa,EAAC,4BAAyB;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;IAYpD,OAAO,IAAI,IAAI;IAMxB,0BAA0B;IAC1B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI;CAMlD"}
1
+ {"version":3,"file":"webgpu-external-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-external-texture.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3F,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AACnD,OAAO,EAAC,aAAa,EAAC,4BAAyB;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;IAYpD,OAAO,IAAI,IAAI;IAQxB,0BAA0B;IAC1B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI;CAMlD"}
@@ -26,6 +26,8 @@ export class WebGPUExternalTexture extends ExternalTexture {
26
26
  // External textures are destroyed automatically,
27
27
  // as a microtask, instead of manually or upon garbage collection like other resources.
28
28
  // this.handle.destroy();
29
+ // @ts-expect-error readonly
30
+ this.handle = null;
29
31
  }
30
32
  /** Set default sampler */
31
33
  setSampler(sampler) {
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-query-set.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-query-set.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,4BAAyB;AAE9C,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,WAAW,GAAG,WAAW,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;gBAEjB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa;IAY7C,OAAO,IAAI,IAAI;CAGzB"}
1
+ {"version":3,"file":"webgpu-query-set.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-query-set.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,4BAAyB;AAE9C,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,WAAW,GAAG,WAAW,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;gBAEjB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa;IAY7C,OAAO,IAAI,IAAI;CAKzB"}
@@ -20,6 +20,8 @@ export class WebGPUQuerySet extends QuerySet {
20
20
  this.handle.label = this.props.id;
21
21
  }
22
22
  destroy() {
23
- this.handle.destroy();
23
+ this.handle?.destroy();
24
+ // @ts-expect-error readonly
25
+ this.handle = null;
24
26
  }
25
27
  }
@@ -10,11 +10,17 @@ export declare class WebGPURenderPipeline extends RenderPipeline {
10
10
  vs: WebGPUShader;
11
11
  fs: WebGPUShader | null;
12
12
  /** For internal use to create BindGroups */
13
+ private _bindings;
13
14
  private _bindGroupLayout;
14
15
  private _bindGroup;
15
16
  constructor(device: WebGPUDevice, props: RenderPipelineProps);
16
17
  destroy(): void;
18
+ /**
19
+ * @todo Use renderpass.setBindings() ?
20
+ * @todo Do we want to expose BindGroups in the API and remove this?
21
+ */
17
22
  setBindings(bindings: Record<string, Binding>): void;
23
+ /** @todo - should this be moved to renderpass? */
18
24
  draw(options: {
19
25
  renderPass: RenderPass;
20
26
  vertexArray: VertexArray;
@@ -25,7 +31,7 @@ export declare class WebGPURenderPipeline extends RenderPipeline {
25
31
  firstIndex?: number;
26
32
  firstInstance?: number;
27
33
  baseVertex?: number;
28
- }): void;
34
+ }): boolean;
29
35
  /** Return a bind group created by setBindings */
30
36
  _getBindGroup(): GPUBindGroup;
31
37
  /**
@@ -33,4 +39,46 @@ export declare class WebGPURenderPipeline extends RenderPipeline {
33
39
  */
34
40
  protected _getRenderPipelineDescriptor(): GPURenderPipelineDescriptor;
35
41
  }
42
+ /**
43
+ _setAttributeBuffers(webgpuRenderPass: WebGPURenderPass) {
44
+ if (this._indexBuffer) {
45
+ webgpuRenderPass.handle.setIndexBuffer(this._indexBuffer.handle, this._indexBuffer.props.indexType);
46
+ }
47
+
48
+ const buffers = this._getBuffers();
49
+ for (let i = 0; i < buffers.length; ++i) {
50
+ const buffer = cast<WebGPUBuffer>(buffers[i]);
51
+ if (!buffer) {
52
+ const attribute = this.props.shaderLayout.attributes.find(
53
+ (attribute) => attribute.location === i
54
+ );
55
+ throw new Error(
56
+ `No buffer provided for attribute '${attribute?.name || ''}' in Model '${this.props.id}'`
57
+ );
58
+ }
59
+ webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);
60
+ }
61
+
62
+ // TODO - HANDLE buffer maps
63
+ /*
64
+ for (const [bufferName, attributeMapping] of Object.entries(this.props.bufferLayout)) {
65
+ const buffer = cast<WebGPUBuffer>(this.props.attributes[bufferName]);
66
+ if (!buffer) {
67
+ log.warn(`Missing buffer for buffer map ${bufferName}`)();
68
+ continue;
69
+ }
70
+
71
+ if ('location' in attributeMapping) {
72
+ // @ts-expect-error TODO model must not depend on webgpu
73
+ renderPass.handle.setVertexBuffer(layout.location, buffer.handle);
74
+ } else {
75
+ for (const [bufferName, mapping] of Object.entries(attributeMapping)) {
76
+ // @ts-expect-error TODO model must not depend on webgpu
77
+ renderPass.handle.setVertexBuffer(field.location, buffer.handle);
78
+ }
79
+ }
80
+ }
81
+ *
82
+ }
83
+ */
36
84
  //# sourceMappingURL=webgpu-render-pipeline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AACpE,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAY,MAAM,eAAe,CAAC;AAS7E,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AAEnD,OAAO,KAAK,EAAC,YAAY,EAAC,2BAAwB;AAKlD,2DAA2D;AAC3D,qBAAa,oBAAqB,SAAQ,cAAc;IACtD,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,iBAAiB,CAAC;IAE1B,EAAE,EAAE,YAAY,CAAC;IACjB,EAAE,EAAE,YAAY,GAAG,IAAI,CAAQ;IAO/B,4CAA4C;IAC5C,OAAO,CAAC,gBAAgB,CAAmC;IAC3D,OAAO,CAAC,UAAU,CAA6B;gBAEnC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,mBAAmB;IAoBnD,OAAO,IAAI,IAAI;IA2BxB,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IASpD,IAAI,CAAC,OAAO,EAAE;QACZ,UAAU,EAAE,UAAU,CAAC;QACvB,WAAW,EAAE,WAAW,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACv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AAa,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,OAAO;IAuCX,iDAAiD;IACjD,aAAa;IAsBb;;OAEG;IACH,SAAS,CAAC,4BAA4B;CA2CvC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCE"}
@@ -11,11 +11,8 @@ export class WebGPURenderPipeline extends RenderPipeline {
11
11
  handle;
12
12
  vs;
13
13
  fs = null;
14
- // private _bufferSlots: Record<string, number>;
15
- // private _buffers: Buffer[];
16
- // private _firstIndex: number;
17
- // private _lastIndex: number;
18
14
  /** For internal use to create BindGroups */
15
+ _bindings;
19
16
  _bindGroupLayout = null;
20
17
  _bindGroup = null;
21
18
  constructor(device, props) {
@@ -32,42 +29,22 @@ export class WebGPURenderPipeline extends RenderPipeline {
32
29
  this.handle.label = this.props.id;
33
30
  this.vs = cast(props.vs);
34
31
  this.fs = cast(props.fs);
35
- // this._bufferSlots = getBufferSlots(this.props.shaderLayout, this.props.bufferLayout);
36
- // this._buffers = new Array<Buffer>(Object.keys(this._bufferSlots).length).fill(null);
32
+ this._bindings = { ...this.props.bindings };
37
33
  }
38
34
  destroy() {
39
35
  // WebGPURenderPipeline has no destroy method.
36
+ this.handle = null;
40
37
  }
41
- // setIndexBuffer(indexBuffer: Buffer): void {
42
- // this._indexBuffer = cast<WebGPUBuffer>(indexBuffer);
43
- // }
44
- // setAttributes(attributes: Record<string, Buffer>): void {
45
- // for (const [name, buffer] of Object.entries(attributes)) {
46
- // const bufferIndex = this._bufferSlots[name];
47
- // if (bufferIndex >= 0) {
48
- // this._buffers[bufferIndex] = buffer;
49
- // } else {
50
- // throw new Error(
51
- // `Setting attribute '${name}' not listed in shader layout for program ${this.id}`
52
- // );
53
- // }
54
- // }
55
- // // for (let i = 0; i < this._bufferSlots.length; ++i) {
56
- // // const bufferName = this._bufferSlots[i];
57
- // // if (attributes[bufferName]) {
58
- // // this.handle
59
- // // }
60
- // // }
61
- // }
38
+ /**
39
+ * @todo Use renderpass.setBindings() ?
40
+ * @todo Do we want to expose BindGroups in the API and remove this?
41
+ */
62
42
  setBindings(bindings) {
63
- // if (isObjectEmpty(bindings)) {
64
- // return;
65
- // }
66
- // Do we want to save things on CPU side?
67
- Object.assign(this.props.bindings, bindings);
43
+ Object.assign(this._bindings, bindings);
68
44
  }
45
+ /** @todo - should this be moved to renderpass? */
69
46
  draw(options) {
70
- const webgpuRenderPass = cast(options.renderPass) || this.device.getDefaultRenderPass();
47
+ const webgpuRenderPass = options.renderPass;
71
48
  // Set pipeline
72
49
  webgpuRenderPass.handle.setPipeline(this.handle);
73
50
  // Set bindings (uniform buffers, textures etc)
@@ -88,18 +65,20 @@ export class WebGPURenderPipeline extends RenderPipeline {
88
65
  }
89
66
  // Note: Rebinds constant attributes before each draw call
90
67
  options.vertexArray.unbindAfterRender(options.renderPass);
68
+ return true;
91
69
  }
92
- // _getBuffers() {
93
- // return this._buffers;
94
- // }
95
70
  /** Return a bind group created by setBindings */
96
71
  _getBindGroup() {
72
+ if (this.props.shaderLayout.bindings.length === 0) {
73
+ return null;
74
+ }
97
75
  // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group
98
76
  this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);
99
77
  // Set up the bindings
78
+ // TODO what if bindings change? We need to rebuild the bind group!
100
79
  this._bindGroup =
101
80
  this._bindGroup ||
102
- getBindGroup(this.device.handle, this._bindGroupLayout, this.props.shaderLayout, this.props.bindings);
81
+ getBindGroup(this.device.handle, this._bindGroupLayout, this.props.shaderLayout, this._bindings);
103
82
  return this._bindGroup;
104
83
  }
105
84
  /**
@@ -109,23 +88,20 @@ export class WebGPURenderPipeline extends RenderPipeline {
109
88
  // Set up the vertex stage
110
89
  const vertex = {
111
90
  module: cast(this.props.vs).handle,
112
- entryPoint: this.props.vsEntryPoint || 'main',
91
+ entryPoint: this.props.vertexEntryPoint || 'main',
113
92
  buffers: getVertexBufferLayout(this.props.shaderLayout, this.props.bufferLayout)
114
93
  };
115
94
  // Set up the fragment stage
116
- let fragment;
117
- if (this.props.fs) {
118
- fragment = {
119
- module: cast(this.props.fs).handle,
120
- entryPoint: this.props.fsEntryPoint || 'main',
121
- targets: [
122
- {
123
- // TODO exclamation mark hack!
124
- format: getWebGPUTextureFormat(this.device?.canvasContext?.format)
125
- }
126
- ]
127
- };
128
- }
95
+ const fragment = {
96
+ module: cast(this.props.fs).handle,
97
+ entryPoint: this.props.fragmentEntryPoint || 'main',
98
+ targets: [
99
+ {
100
+ // TODO exclamation mark hack!
101
+ format: getWebGPUTextureFormat(this.device?.canvasContext?.format)
102
+ }
103
+ ]
104
+ };
129
105
  // WebGPU has more restrictive topology support than WebGL
130
106
  switch (this.props.topology) {
131
107
  case 'triangle-fan-webgl':
@@ -147,3 +123,45 @@ export class WebGPURenderPipeline extends RenderPipeline {
147
123
  return descriptor;
148
124
  }
149
125
  }
126
+ /**
127
+ _setAttributeBuffers(webgpuRenderPass: WebGPURenderPass) {
128
+ if (this._indexBuffer) {
129
+ webgpuRenderPass.handle.setIndexBuffer(this._indexBuffer.handle, this._indexBuffer.props.indexType);
130
+ }
131
+
132
+ const buffers = this._getBuffers();
133
+ for (let i = 0; i < buffers.length; ++i) {
134
+ const buffer = cast<WebGPUBuffer>(buffers[i]);
135
+ if (!buffer) {
136
+ const attribute = this.props.shaderLayout.attributes.find(
137
+ (attribute) => attribute.location === i
138
+ );
139
+ throw new Error(
140
+ `No buffer provided for attribute '${attribute?.name || ''}' in Model '${this.props.id}'`
141
+ );
142
+ }
143
+ webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);
144
+ }
145
+
146
+ // TODO - HANDLE buffer maps
147
+ /*
148
+ for (const [bufferName, attributeMapping] of Object.entries(this.props.bufferLayout)) {
149
+ const buffer = cast<WebGPUBuffer>(this.props.attributes[bufferName]);
150
+ if (!buffer) {
151
+ log.warn(`Missing buffer for buffer map ${bufferName}`)();
152
+ continue;
153
+ }
154
+
155
+ if ('location' in attributeMapping) {
156
+ // @ts-expect-error TODO model must not depend on webgpu
157
+ renderPass.handle.setVertexBuffer(layout.location, buffer.handle);
158
+ } else {
159
+ for (const [bufferName, mapping] of Object.entries(attributeMapping)) {
160
+ // @ts-expect-error TODO model must not depend on webgpu
161
+ renderPass.handle.setVertexBuffer(field.location, buffer.handle);
162
+ }
163
+ }
164
+ }
165
+ *
166
+ }
167
+ */
@@ -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,eAAe,CAAC;AACpD,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AAEnD,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG;IAC9C,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,qBAAa,aAAc,SAAQ,OAAO;IACxC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,kBAAkB;IAclD,OAAO,IAAI,IAAI;CAGzB"}
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,eAAe,CAAC;AACpD,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AAEnD,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG;IAC9C,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,qBAAa,aAAc,SAAQ,OAAO;IACxC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,kBAAkB;IAclD,OAAO,IAAI,IAAI;CAMzB"}
@@ -17,6 +17,9 @@ export class WebGPUSampler extends Sampler {
17
17
  this.handle.label = this.props.id;
18
18
  }
19
19
  destroy() {
20
+ // GPUSampler does not have a destroy method
20
21
  // this.handle.destroy();
22
+ // @ts-expect-error readonly
23
+ this.handle = null;
21
24
  }
22
25
  }
@@ -2,16 +2,13 @@
2
2
  import type { ShaderProps, CompilerMessage } from '@luma.gl/core';
3
3
  import { Shader } from '@luma.gl/core';
4
4
  import type { WebGPUDevice } from "../webgpu-device.js";
5
- export type WebGPUShaderProps = ShaderProps & {
6
- handle?: GPUShaderModule;
7
- };
8
5
  /**
9
6
  * Immutable shader
10
7
  */
11
8
  export declare class WebGPUShader extends Shader {
12
9
  readonly device: WebGPUDevice;
13
10
  readonly handle: GPUShaderModule;
14
- constructor(device: WebGPUDevice, props: WebGPUShaderProps);
11
+ constructor(device: WebGPUDevice, props: ShaderProps);
15
12
  _checkCompilationError(errorScope: Promise<GPUError | null>): Promise<void>;
16
13
  destroy(): void;
17
14
  /** Returns compilation info for this shader */
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-shader.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,eAAe,CAAC;AAChE,OAAO,EAAC,MAAM,EAAM,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AAEnD,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG;IAC5C,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,qBAAa,YAAa,SAAQ,MAAM;IACtC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;gBAErB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,iBAAiB;IAYpD,sBAAsB,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAcxE,OAAO,IAAI,IAAI;IAKxB,+CAA+C;IACzC,kBAAkB,IAAI,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;IAO/D,SAAS,CAAC,YAAY,IAAI,eAAe;CAuB1C"}
1
+ {"version":3,"file":"webgpu-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-shader.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,eAAe,CAAC;AAChE,OAAO,EAAC,MAAM,EAAM,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AAEnD;;GAEG;AACH,qBAAa,YAAa,SAAQ,MAAM;IACtC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;gBAErB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW;IAY9C,sBAAsB,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAcxE,OAAO,IAAI,IAAI;IAOxB,+CAA+C;IACzC,kBAAkB,IAAI,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;IAO/D,SAAS,CAAC,YAAY,IAAI,eAAe;CAU1C"}
@@ -31,6 +31,8 @@ export class WebGPUShader extends Shader {
31
31
  destroy() {
32
32
  // Note: WebGPU does not offer a method to destroy shaders
33
33
  // this.handle.destroy();
34
+ // @ts-expect-error readonly
35
+ this.handle = null;
34
36
  }
35
37
  /** Returns compilation info for this shader */
36
38
  async getCompilationInfo() {
@@ -39,24 +41,11 @@ export class WebGPUShader extends Shader {
39
41
  }
40
42
  // PRIVATE METHODS
41
43
  createHandle() {
42
- const { source, stage } = this.props;
43
- let language = this.props.language;
44
- // Compile from src
45
- if (language === 'auto') {
46
- // wgsl uses C++ "auto" style arrow notation
47
- language = source.includes('->') ? 'wgsl' : 'glsl';
48
- }
49
- switch (language) {
50
- case 'wgsl':
51
- return this.device.handle.createShaderModule({ code: source });
52
- case 'glsl':
53
- return this.device.handle.createShaderModule({
54
- code: source,
55
- // @ts-expect-error
56
- transform: glsl => this.device.glslang.compileGLSL(glsl, stage)
57
- });
58
- default:
59
- throw new Error(language);
44
+ const { source } = this.props;
45
+ const isGLSL = source.includes('#version');
46
+ if (this.props.language === 'glsl' || isGLSL) {
47
+ throw new Error('GLSL shaders are not supported in WebGPU');
60
48
  }
49
+ return this.device.handle.createShaderModule({ code: source });
61
50
  }
62
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-texture-view.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-texture-view.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AACnD,OAAO,KAAK,EAAC,aAAa,EAAC,4BAAyB;AAEpD,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,GAAG;IACtD,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;gBAEpB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,sBAAsB,GAAG;QAAC,OAAO,EAAE,aAAa,CAAA;KAAC;IAmBjF,OAAO,IAAI,IAAI;CAGzB"}
1
+ {"version":3,"file":"webgpu-texture-view.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-texture-view.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AACnD,OAAO,KAAK,EAAC,aAAa,EAAC,4BAAyB;AAEpD,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,GAAG;IACtD,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;gBAEpB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,sBAAsB,GAAG;QAAC,OAAO,EAAE,aAAa,CAAA;KAAC;IAmBjF,OAAO,IAAI,IAAI;CAMzB"}
@@ -27,6 +27,9 @@ export class WebGPUTextureView extends TextureView {
27
27
  this.handle.label = this.props.id;
28
28
  }
29
29
  destroy() {
30
+ // GPUTextureView does not have a destroy method
30
31
  // this.handle.destroy();
32
+ // @ts-expect-error readonly
33
+ this.handle = null;
31
34
  }
32
35
  }