@luma.gl/webgpu 9.1.0-alpha.2 → 9.1.0-beta.1

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 (108) hide show
  1. package/dist/adapter/helpers/accessor-to-format.js +1 -0
  2. package/dist/adapter/helpers/accessor-to-format.js.map +1 -0
  3. package/dist/adapter/helpers/convert-texture-format.d.ts +0 -1
  4. package/dist/adapter/helpers/convert-texture-format.d.ts.map +1 -1
  5. package/dist/adapter/helpers/convert-texture-format.js +1 -0
  6. package/dist/adapter/helpers/convert-texture-format.js.map +1 -0
  7. package/dist/adapter/helpers/get-bind-group.d.ts +3 -2
  8. package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
  9. package/dist/adapter/helpers/get-bind-group.js +18 -4
  10. package/dist/adapter/helpers/get-bind-group.js.map +1 -0
  11. package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts +0 -1
  12. package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -1
  13. package/dist/adapter/helpers/get-vertex-buffer-layout.js +4 -3
  14. package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -0
  15. package/dist/adapter/helpers/webgpu-parameters.d.ts +0 -1
  16. package/dist/adapter/helpers/webgpu-parameters.d.ts.map +1 -1
  17. package/dist/adapter/helpers/webgpu-parameters.js +1 -0
  18. package/dist/adapter/helpers/webgpu-parameters.js.map +1 -0
  19. package/dist/adapter/resources/webgpu-buffer.d.ts +0 -1
  20. package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
  21. package/dist/adapter/resources/webgpu-buffer.js +1 -0
  22. package/dist/adapter/resources/webgpu-buffer.js.map +1 -0
  23. package/dist/adapter/resources/webgpu-command-encoder.d.ts +4 -5
  24. package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
  25. package/dist/adapter/resources/webgpu-command-encoder.js +22 -4
  26. package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -0
  27. package/dist/adapter/resources/webgpu-compute-pass.d.ts +0 -1
  28. package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
  29. package/dist/adapter/resources/webgpu-compute-pass.js +1 -0
  30. package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -0
  31. package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +0 -1
  32. package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
  33. package/dist/adapter/resources/webgpu-compute-pipeline.js +1 -0
  34. package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -0
  35. package/dist/adapter/resources/webgpu-external-texture.d.ts +0 -1
  36. package/dist/adapter/resources/webgpu-external-texture.d.ts.map +1 -1
  37. package/dist/adapter/resources/webgpu-external-texture.js +1 -0
  38. package/dist/adapter/resources/webgpu-external-texture.js.map +1 -0
  39. package/dist/adapter/resources/webgpu-framebuffer.d.ts +1 -0
  40. package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
  41. package/dist/adapter/resources/webgpu-framebuffer.js +4 -0
  42. package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -0
  43. package/dist/adapter/resources/webgpu-query-set.d.ts +0 -1
  44. package/dist/adapter/resources/webgpu-query-set.d.ts.map +1 -1
  45. package/dist/adapter/resources/webgpu-query-set.js +1 -0
  46. package/dist/adapter/resources/webgpu-query-set.js.map +1 -0
  47. package/dist/adapter/resources/webgpu-render-pass.d.ts +0 -1
  48. package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
  49. package/dist/adapter/resources/webgpu-render-pass.js +19 -6
  50. package/dist/adapter/resources/webgpu-render-pass.js.map +1 -0
  51. package/dist/adapter/resources/webgpu-render-pipeline.d.ts +1 -1
  52. package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
  53. package/dist/adapter/resources/webgpu-render-pipeline.js +42 -6
  54. package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -0
  55. package/dist/adapter/resources/webgpu-sampler.d.ts +1 -2
  56. package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
  57. package/dist/adapter/resources/webgpu-sampler.js +15 -6
  58. package/dist/adapter/resources/webgpu-sampler.js.map +1 -0
  59. package/dist/adapter/resources/webgpu-shader.d.ts +2 -3
  60. package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
  61. package/dist/adapter/resources/webgpu-shader.js +23 -19
  62. package/dist/adapter/resources/webgpu-shader.js.map +1 -0
  63. package/dist/adapter/resources/webgpu-texture-view.d.ts +0 -1
  64. package/dist/adapter/resources/webgpu-texture-view.d.ts.map +1 -1
  65. package/dist/adapter/resources/webgpu-texture-view.js +1 -0
  66. package/dist/adapter/resources/webgpu-texture-view.js.map +1 -0
  67. package/dist/adapter/resources/webgpu-texture.d.ts +3 -7
  68. package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
  69. package/dist/adapter/resources/webgpu-texture.js +26 -23
  70. package/dist/adapter/resources/webgpu-texture.js.map +1 -0
  71. package/dist/adapter/resources/webgpu-vertex-array.d.ts.map +1 -1
  72. package/dist/adapter/resources/webgpu-vertex-array.js +3 -2
  73. package/dist/adapter/resources/webgpu-vertex-array.js.map +1 -0
  74. package/dist/adapter/webgpu-adapter.d.ts +13 -0
  75. package/dist/adapter/webgpu-adapter.d.ts.map +1 -0
  76. package/dist/adapter/webgpu-adapter.js +65 -0
  77. package/dist/adapter/webgpu-adapter.js.map +1 -0
  78. package/dist/adapter/webgpu-canvas-context.d.ts +8 -10
  79. package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
  80. package/dist/adapter/webgpu-canvas-context.js +56 -60
  81. package/dist/adapter/webgpu-canvas-context.js.map +1 -0
  82. package/dist/adapter/webgpu-device.d.ts +11 -18
  83. package/dist/adapter/webgpu-device.d.ts.map +1 -1
  84. package/dist/adapter/webgpu-device.js +43 -88
  85. package/dist/adapter/webgpu-device.js.map +1 -0
  86. package/dist/dist.dev.js +317 -236
  87. package/dist/dist.min.js +5 -1
  88. package/dist/index.cjs +290 -201
  89. package/dist/index.cjs.map +4 -4
  90. package/dist/index.d.ts +2 -0
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +3 -2
  93. package/dist/index.js.map +1 -0
  94. package/package.json +3 -3
  95. package/src/adapter/helpers/get-bind-group.ts +23 -4
  96. package/src/adapter/helpers/get-vertex-buffer-layout.ts +3 -3
  97. package/src/adapter/resources/webgpu-command-encoder.ts +26 -8
  98. package/src/adapter/resources/webgpu-framebuffer.ts +4 -0
  99. package/src/adapter/resources/webgpu-render-pass.ts +29 -14
  100. package/src/adapter/resources/webgpu-render-pipeline.ts +45 -6
  101. package/src/adapter/resources/webgpu-sampler.ts +16 -6
  102. package/src/adapter/resources/webgpu-shader.ts +23 -23
  103. package/src/adapter/resources/webgpu-texture.ts +43 -57
  104. package/src/adapter/resources/webgpu-vertex-array.ts +7 -2
  105. package/src/adapter/webgpu-adapter.ts +88 -0
  106. package/src/adapter/webgpu-canvas-context.ts +67 -69
  107. package/src/adapter/webgpu-device.ts +54 -116
  108. package/src/index.ts +3 -1
@@ -1,8 +1,7 @@
1
1
  // luma.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
- import { CanvasContext, log } from '@luma.gl/core';
5
- import { getWebGPUTextureFormat } from "./helpers/convert-texture-format.js";
4
+ import { CanvasContext, Texture, log } from '@luma.gl/core';
6
5
  import { WebGPUFramebuffer } from "./resources/webgpu-framebuffer.js";
7
6
  /**
8
7
  * Holds a WebGPU Canvas Context
@@ -11,98 +10,95 @@ import { WebGPUFramebuffer } from "./resources/webgpu-framebuffer.js";
11
10
  */
12
11
  export class WebGPUCanvasContext extends CanvasContext {
13
12
  device;
14
- gpuCanvasContext;
15
- /** Format of returned textures: "bgra8unorm", "rgba8unorm", "rgba16float". */
16
- format = navigator.gpu.getPreferredCanvasFormat();
17
- /** Default stencil format for depth textures */
18
- depthStencilFormat = 'depth24plus';
13
+ handle;
19
14
  depthStencilAttachment = null;
15
+ get [Symbol.toStringTag]() {
16
+ return 'WebGPUCanvasContext';
17
+ }
20
18
  constructor(device, adapter, props) {
21
19
  super(props);
22
20
  this.device = device;
23
- // TODO - hack to trigger resize?
24
- this.width = -1;
25
- this.height = -1;
21
+ // Base class constructor cannot access derived methods/fields, so we need to call these functions in the subclass constructor
26
22
  this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
27
- // @ts-ignore TODO - we don't handle OffscreenRenderingContext.
28
- this.gpuCanvasContext = this.canvas.getContext('webgpu');
29
- // TODO this has been replaced
30
- // this.format = this.gpuCanvasContext.getPreferredFormat(adapter);
31
- this.format = 'bgra8unorm';
23
+ this.updateSize([this.drawingBufferWidth, this.drawingBufferHeight]);
32
24
  }
33
25
  /** Destroy any textures produced while configured and remove the context configuration. */
34
26
  destroy() {
35
- this.gpuCanvasContext.unconfigure();
27
+ this.handle.unconfigure();
36
28
  }
37
29
  /** Update framebuffer with properly resized "swap chain" texture views */
38
- getCurrentFramebuffer() {
39
- // Ensure the canvas context size is updated
40
- this.update();
41
- // Wrap the current canvas context texture in a luma.gl texture
42
- // const currentColorAttachment = this.device.createTexture({
43
- // id: 'default-render-target',
44
- // handle: this.gpuCanvasContext.getCurrentTexture(),
45
- // format: this.format,
46
- // width: this.width,
47
- // height: this.height
48
- // });
30
+ getCurrentFramebuffer(options = {
31
+ depthStencilFormat: 'depth24plus'
32
+ }) {
49
33
  // Wrap the current canvas context texture in a luma.gl texture
50
34
  const currentColorAttachment = this.getCurrentTexture();
51
- this.width = currentColorAttachment.width;
52
- this.height = currentColorAttachment.height;
35
+ // TODO - temporary debug code
36
+ if (currentColorAttachment.width !== this.drawingBufferWidth ||
37
+ currentColorAttachment.height !== this.drawingBufferHeight) {
38
+ const [oldWidth, oldHeight] = this.getDrawingBufferSize();
39
+ this.drawingBufferWidth = currentColorAttachment.width;
40
+ this.drawingBufferHeight = currentColorAttachment.height;
41
+ log.log(1, `${this}: Resized to compensate for initial canvas size mismatch ${oldWidth}x${oldHeight} => ${this.drawingBufferWidth}x${this.drawingBufferHeight}px`)();
42
+ }
53
43
  // Resize the depth stencil attachment
54
- this._createDepthStencilAttachment();
44
+ if (options?.depthStencilFormat) {
45
+ this._createDepthStencilAttachment(options?.depthStencilFormat);
46
+ }
55
47
  return new WebGPUFramebuffer(this.device, {
56
48
  colorAttachments: [currentColorAttachment],
57
49
  depthStencilAttachment: this.depthStencilAttachment
58
50
  });
59
51
  }
60
52
  /** Resizes and updates render targets if necessary */
61
- update() {
62
- const [width, height] = this.getPixelSize();
63
- const sizeChanged = width !== this.width || height !== this.height;
64
- if (sizeChanged) {
65
- this.width = width;
66
- this.height = height;
67
- if (this.depthStencilAttachment) {
68
- this.depthStencilAttachment.destroy();
69
- this.depthStencilAttachment = null;
70
- }
71
- // Reconfigure the canvas size.
72
- // https://www.w3.org/TR/webgpu/#canvas-configuration
73
- this.gpuCanvasContext.configure({
74
- device: this.device.handle,
75
- format: getWebGPUTextureFormat(this.format),
76
- // Can be used to define e.g. -srgb views
77
- // viewFormats: [...]
78
- colorSpace: this.props.colorSpace,
79
- alphaMode: this.props.alphaMode
80
- });
81
- log.log(1, `Resized to ${this.width}x${this.height}px`)();
53
+ updateSize(size) {
54
+ if (this.depthStencilAttachment) {
55
+ this.depthStencilAttachment.destroy();
56
+ this.depthStencilAttachment = null;
82
57
  }
58
+ // Reconfigure the canvas size.
59
+ // https://www.w3.org/TR/webgpu/#canvas-configuration
60
+ this.handle.configure({
61
+ device: this.device.handle,
62
+ format: this.device.preferredColorFormat,
63
+ // Can be used to define e.g. -srgb views
64
+ // viewFormats: [...]
65
+ colorSpace: this.props.colorSpace,
66
+ alphaMode: this.props.alphaMode
67
+ });
83
68
  }
84
69
  resize(options) {
85
- this.update();
70
+ if (!this.device.handle)
71
+ return;
72
+ if (this.props.autoResize) {
73
+ return;
74
+ }
75
+ // Resize browser context .
76
+ if (this.canvas) {
77
+ const devicePixelRatio = this.getDevicePixelRatio(options?.useDevicePixels);
78
+ this._setDevicePixelRatio(devicePixelRatio, options);
79
+ return;
80
+ }
86
81
  }
87
82
  /** Wrap the current canvas context texture in a luma.gl texture */
88
83
  getCurrentTexture() {
89
- return this.device._createTexture({
84
+ return this.device.createTexture({
90
85
  id: `${this.id}#color-texture`,
91
- handle: this.gpuCanvasContext.getCurrentTexture(),
92
- format: this.format
86
+ handle: this.handle.getCurrentTexture(),
87
+ format: this.device.preferredColorFormat
93
88
  });
94
89
  }
95
90
  /** We build render targets on demand (i.e. not when size changes but when about to render) */
96
- _createDepthStencilAttachment() {
91
+ _createDepthStencilAttachment(depthStencilFormat) {
97
92
  if (!this.depthStencilAttachment) {
98
93
  this.depthStencilAttachment = this.device.createTexture({
99
94
  id: `${this.id}#depth-stencil-texture`,
100
- format: this.depthStencilFormat,
101
- width: this.width,
102
- height: this.height,
103
- usage: GPUTextureUsage.RENDER_ATTACHMENT
95
+ usage: Texture.RENDER_ATTACHMENT,
96
+ format: depthStencilFormat,
97
+ width: this.drawingBufferWidth,
98
+ height: this.drawingBufferHeight
104
99
  });
105
100
  }
106
101
  return this.depthStencilAttachment;
107
102
  }
108
103
  }
104
+ //# sourceMappingURL=webgpu-canvas-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webgpu-canvas-context.js","sourceRoot":"","sources":["../../src/adapter/webgpu-canvas-context.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAKpC,OAAO,EAAC,aAAa,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAC,iBAAiB,EAAC,0CAAuC;AAGjE;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IAC3C,MAAM,CAAe;IACrB,MAAM,CAAmB;IAE1B,sBAAsB,GAAyB,IAAI,CAAC;IAE5D,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAED,YAAY,MAAoB,EAAE,OAAmB,EAAE,KAAyB;QAC9E,K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AM,CAAC,oBAAoB;SACzC,CAAC,CAAC;IACL,CAAC;IAED,8FAA8F;IAC9F,6BAA6B,CAAC,kBAA6C;QACzE,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC;YACjC,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;gBACtD,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,wBAAwB;gBACtC,KAAK,EAAE,OAAO,CAAC,iBAAiB;gBAChC,MAAM,EAAE,kBAAkB;gBAC1B,KAAK,EAAE,IAAI,CAAC,kBAAkB;gBAC9B,MAAM,EAAE,IAAI,CAAC,mBAAmB;aACjC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACrC,CAAC;CACF"}
@@ -1,5 +1,4 @@
1
- /// <reference types="dist" />
2
- import type { DeviceProps, DeviceInfo, DeviceLimits, CanvasContextProps, BufferProps, SamplerProps, ShaderProps, Texture, TextureProps, TextureFormat, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipelineProps, RenderPassProps, ComputePassProps, VertexArrayProps, TransformFeedback, TransformFeedbackProps, QuerySet, QuerySetProps } from '@luma.gl/core';
1
+ import type { DeviceInfo, DeviceLimits, DeviceTextureFormatCapabilities, CanvasContextProps, BufferProps, SamplerProps, ShaderProps, Texture, TextureProps, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipelineProps, RenderPassProps, ComputePassProps, VertexArrayProps, TransformFeedback, TransformFeedbackProps, QuerySet, QuerySetProps, DeviceProps } from '@luma.gl/core';
3
2
  import { Device, DeviceFeatures } from '@luma.gl/core';
4
3
  import { WebGPUBuffer } from "./resources/webgpu-buffer.js";
5
4
  import { WebGPUTexture } from "./resources/webgpu-texture.js";
@@ -15,13 +14,12 @@ import { WebGPUVertexArray } from "./resources/webgpu-vertex-array.js";
15
14
  import { WebGPUCanvasContext } from "./webgpu-canvas-context.js";
16
15
  /** WebGPU Device implementation */
17
16
  export declare class WebGPUDevice extends Device {
18
- static type: string;
19
- /** type of this device */
20
- readonly type = "webgpu";
21
17
  /** The underlying WebGPU device */
22
18
  readonly handle: GPUDevice;
23
- readonly adapter: GPUAdapter;
24
- readonly adapterInfo: GPUAdapterInfo;
19
+ /** type of this device */
20
+ readonly type = "webgpu";
21
+ readonly preferredColorFormat: "rgba8unorm" | "bgra8unorm";
22
+ readonly preferredDepthFormat = "depth24plus";
25
23
  readonly features: DeviceFeatures;
26
24
  readonly info: DeviceInfo;
27
25
  readonly limits: DeviceLimits;
@@ -29,23 +27,17 @@ export declare class WebGPUDevice extends Device {
29
27
  reason: 'destroyed';
30
28
  message: string;
31
29
  }>;
30
+ renderPass: WebGPURenderPass | null;
32
31
  canvasContext: WebGPUCanvasContext | null;
33
32
  private _isLost;
34
33
  commandEncoder: GPUCommandEncoder | null;
35
- renderPass: WebGPURenderPass | null;
36
- /** Check if WebGPU is available */
37
- static isSupported(): boolean;
38
- static create(props: DeviceProps): Promise<WebGPUDevice>;
39
- constructor(device: GPUDevice, adapter: GPUAdapter, adapterInfo: GPUAdapterInfo, props: DeviceProps);
34
+ readonly adapter: GPUAdapter;
35
+ readonly adapterInfo: GPUAdapterInfo;
36
+ constructor(props: DeviceProps, device: GPUDevice, adapter: GPUAdapter, adapterInfo: GPUAdapterInfo);
40
37
  destroy(): void;
41
- isTextureFormatSupported(format: TextureFormat): boolean;
42
- /** @todo implement proper check? */
43
- isTextureFormatFilterable(format: TextureFormat): boolean;
44
- /** @todo implement proper check? */
45
- isTextureFormatRenderable(format: TextureFormat): boolean;
46
38
  get isLost(): boolean;
47
39
  createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer;
48
- _createTexture(props: TextureProps): WebGPUTexture;
40
+ createTexture(props: TextureProps): WebGPUTexture;
49
41
  createExternalTexture(props: ExternalTextureProps): WebGPUExternalTexture;
50
42
  createShader(props: ShaderProps): WebGPUShader;
51
43
  createSampler(props: SamplerProps): WebGPUSampler;
@@ -65,6 +57,7 @@ export declare class WebGPUDevice extends Device {
65
57
  submit(): void;
66
58
  protected _getInfo(): DeviceInfo;
67
59
  protected _getFeatures(): DeviceFeatures;
60
+ _getDeviceSpecificTextureFormatCapabilities(capabilities: DeviceTextureFormatCapabilities): DeviceTextureFormatCapabilities;
68
61
  copyExternalImageToTexture(options: {
69
62
  texture: Texture;
70
63
  mipLevel?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-device.ts"],"names":[],"mappings":";AAOA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,YAAY,EAEZ,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,OAAO,EACP,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAEhB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,QAAQ,EACR,aAAa,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,MAAM,EAAE,cAAc,EAAqB,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,YAAY,EAAC,qCAAkC;AACvD,OAAO,EAAC,aAAa,EAAC,sCAAmC;AACzD,OAAO,EAAC,qBAAqB,EAAC,+CAA4C;AAC1E,OAAO,EAAC,aAAa,EAAC,sCAAmC;AACzD,OAAO,EAAC,YAAY,EAAC,qCAAkC;AACvD,OAAO,EAAC,oBAAoB,EAAC,8CAA2C;AACxE,OAAO,EAAC,iBAAiB,EAAC,0CAAuC;AACjE,OAAO,EAAC,qBAAqB,EAAC,+CAA4C;AAC1E,OAAO,EAAC,gBAAgB,EAAC,0CAAuC;AAChE,OAAO,EAAC,iBAAiB,EAAC,2CAAwC;AAElE,OAAO,EAAC,iBAAiB,EAAC,2CAAwC;AAElE,OAAO,EAAC,mBAAmB,EAAC,mCAAgC;AAG5D,mCAAmC;AACnC,qBAAa,YA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BAAiB;IAM7D;;;OAGG;IACH,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB;IAKzD,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,iBAAiB;IAS5D,uBAAuB,CAAC,KAAK,EAAE,sBAAsB,GAAG,iBAAiB;IAIhE,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,QAAQ;IAIvD,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,mBAAmB;IAInE,MAAM,IAAI,IAAI;IAgBd,SAAS,CAAC,QAAQ,IAAI,UAAU;IA2BhC,SAAS,CAAC,YAAY,IAAI,cAAc;IAiC/B,2CAA2C,CAClD,YAAY,EAAE,+BAA+B,GAC5C,+BAA+B;IAWlC,0BAA0B,CAAC,OAAO,EAAE;QAClC,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,KAAK,GAAG,cAAc,GAAG,YAAY,CAAC;QAC/C,UAAU,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;QACnC,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAE7B,MAAM,EAAE,WAAW,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,eAAe,CAAC;QAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QAEjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI;CAyCT"}
@@ -1,7 +1,7 @@
1
1
  // luma.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
- import { Device, DeviceFeatures, CanvasContext, log } from '@luma.gl/core';
4
+ import { Device, DeviceFeatures } from '@luma.gl/core';
5
5
  import { WebGPUBuffer } from "./resources/webgpu-buffer.js";
6
6
  import { WebGPUTexture } from "./resources/webgpu-texture.js";
7
7
  import { WebGPUExternalTexture } from "./resources/webgpu-external-texture.js";
@@ -18,73 +18,26 @@ import { WebGPUCanvasContext } from "./webgpu-canvas-context.js";
18
18
  import { WebGPUQuerySet } from "./resources/webgpu-query-set.js";
19
19
  /** WebGPU Device implementation */
20
20
  export class WebGPUDevice extends Device {
21
- static type = 'webgpu';
22
- /** type of this device */
23
- type = 'webgpu';
24
21
  /** The underlying WebGPU device */
25
22
  handle;
26
- /* The underlying WebGPU adapter */
27
- adapter;
28
- /* The underlying WebGPU adapter's info */
29
- adapterInfo;
23
+ /** type of this device */
24
+ type = 'webgpu';
25
+ preferredColorFormat = navigator.gpu.getPreferredCanvasFormat();
26
+ preferredDepthFormat = 'depth24plus';
30
27
  features;
31
28
  info;
32
29
  limits;
33
30
  lost;
34
- canvasContext = null;
31
+ renderPass = null;
32
+ canvasContext;
35
33
  _isLost = false;
34
+ // canvasContext: WebGPUCanvasContext | null = null;
36
35
  commandEncoder = null;
37
- renderPass = null;
38
- /** Check if WebGPU is available */
39
- static isSupported() {
40
- return Boolean(typeof navigator !== 'undefined' && navigator.gpu);
41
- }
42
- static async create(props) {
43
- if (!navigator.gpu) {
44
- throw new Error('WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu');
45
- }
46
- log.groupCollapsed(1, 'WebGPUDevice created')();
47
- const adapter = await navigator.gpu.requestAdapter({
48
- powerPreference: 'high-performance'
49
- // forceSoftware: false
50
- });
51
- if (!adapter) {
52
- throw new Error('Failed to request WebGPU adapter');
53
- }
54
- const adapterInfo = await adapter.requestAdapterInfo();
55
- log.probe(2, 'Adapter available', adapterInfo)();
56
- const requiredFeatures = [];
57
- const requiredLimits = {};
58
- if (props.requestMaxLimits) {
59
- // Require all features
60
- requiredFeatures.push(...Array.from(adapter.features));
61
- // Require all limits
62
- // Filter out chrome specific keys (avoid crash)
63
- const limits = Object.keys(adapter.limits).filter(key => !['minSubgroupSize', 'maxSubgroupSize'].includes(key));
64
- for (const key of limits) {
65
- const limit = key;
66
- const value = adapter.limits[limit];
67
- if (typeof value === 'number') {
68
- requiredLimits[limit] = value;
69
- }
70
- }
71
- }
72
- const gpuDevice = await adapter.requestDevice({
73
- requiredFeatures,
74
- requiredLimits
75
- });
76
- log.probe(1, 'GPUDevice available')();
77
- if (typeof props.canvas === 'string') {
78
- await CanvasContext.pageLoaded;
79
- log.probe(1, 'DOM is loaded')();
80
- }
81
- const device = new WebGPUDevice(gpuDevice, adapter, adapterInfo, props);
82
- log.probe(1, 'Device created. For more info, set chrome://flags/#enable-webgpu-developer-features')();
83
- log.table(1, device.info)();
84
- log.groupEnd(1)();
85
- return device;
86
- }
87
- constructor(device, adapter, adapterInfo, props) {
36
+ /* The underlying WebGPU adapter */
37
+ adapter;
38
+ /* The underlying WebGPU adapter's info */
39
+ adapterInfo;
40
+ constructor(props, device, adapter, adapterInfo) {
88
41
  super({ ...props, id: props.id || 'webgpu-device' });
89
42
  this.handle = device;
90
43
  this.adapter = adapter;
@@ -95,8 +48,13 @@ export class WebGPUDevice extends Device {
95
48
  // Listen for uncaptured WebGPU errors
96
49
  device.addEventListener('uncapturederror', (event) => {
97
50
  // TODO is this the right way to make sure the error is an Error instance?
98
- const errorMessage = event instanceof GPUUncapturedErrorEvent ? event.error.message : 'Unknown error';
99
- this.error(new Error(errorMessage));
51
+ const errorMessage = event instanceof GPUUncapturedErrorEvent ? event.error.message : 'Unknown WebGPU error';
52
+ this.reportError(new Error(errorMessage));
53
+ if (this.props.debug) {
54
+ // eslint-disable-next-line no-debugger
55
+ debugger;
56
+ }
57
+ event.preventDefault();
100
58
  });
101
59
  // "Context" loss handling
102
60
  this.lost = new Promise(async (resolve) => {
@@ -105,14 +63,10 @@ export class WebGPUDevice extends Device {
105
63
  resolve({ reason: 'destroyed', message: lostInfo.message });
106
64
  });
107
65
  // Note: WebGPU devices can be created without a canvas, for compute shader purposes
108
- // if (props.canvas) {
109
- this.canvasContext = new WebGPUCanvasContext(this, this.adapter, {
110
- canvas: props.canvas,
111
- height: props.height,
112
- width: props.width,
113
- container: props.container
114
- });
115
- // }
66
+ if (props.createCanvasContext) {
67
+ const canvasContextProps = props.createCanvasContext === true ? {} : props.createCanvasContext;
68
+ this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);
69
+ }
116
70
  }
117
71
  // TODO
118
72
  // Load the glslang module now so that it is available synchronously when compiling shaders
@@ -121,27 +75,14 @@ export class WebGPUDevice extends Device {
121
75
  destroy() {
122
76
  this.handle.destroy();
123
77
  }
124
- isTextureFormatSupported(format) {
125
- return !format.includes('webgl');
126
- }
127
- /** @todo implement proper check? */
128
- isTextureFormatFilterable(format) {
129
- return (this.isTextureFormatSupported(format) &&
130
- !format.startsWith('depth') &&
131
- !format.startsWith('stencil'));
132
- }
133
- /** @todo implement proper check? */
134
- isTextureFormatRenderable(format) {
135
- return this.isTextureFormatSupported(format);
136
- }
137
78
  get isLost() {
138
79
  return this._isLost;
139
80
  }
140
81
  createBuffer(props) {
141
- const newProps = this._getBufferProps(props);
82
+ const newProps = this._normalizeBufferProps(props);
142
83
  return new WebGPUBuffer(this, newProps);
143
84
  }
144
- _createTexture(props) {
85
+ createTexture(props) {
145
86
  return new WebGPUTexture(this, props);
146
87
  }
147
88
  createExternalTexture(props) {
@@ -191,13 +132,17 @@ export class WebGPUDevice extends Device {
191
132
  return new WebGPUCanvasContext(this, this.adapter, props);
192
133
  }
193
134
  submit() {
194
- // this.renderPass?.end();
195
135
  const commandBuffer = this.commandEncoder?.finish();
196
136
  if (commandBuffer) {
137
+ this.handle.pushErrorScope('validation');
197
138
  this.handle.queue.submit([commandBuffer]);
139
+ this.handle.popErrorScope().then((error) => {
140
+ if (error) {
141
+ this.reportError(new Error(`WebGPU command submission failed: ${error.message}`));
142
+ }
143
+ });
198
144
  }
199
145
  this.commandEncoder = null;
200
- // this.renderPass = null;
201
146
  }
202
147
  // PRIVATE METHODS
203
148
  _getInfo() {
@@ -249,8 +194,17 @@ export class WebGPUDevice extends Device {
249
194
  for (const feature of WEBGPU_ALWAYS_FEATURES) {
250
195
  features.add(feature);
251
196
  }
252
- return new DeviceFeatures(Array.from(features), this.props.disabledFeatures);
197
+ return new DeviceFeatures(Array.from(features), this.props._disabledFeatures);
198
+ }
199
+ _getDeviceSpecificTextureFormatCapabilities(capabilities) {
200
+ const { format } = capabilities;
201
+ if (format.includes('webgl')) {
202
+ return { format, create: false, render: false, filter: false, blend: false, store: false };
203
+ }
204
+ return capabilities;
253
205
  }
206
+ // DEPRECATED METHODS
207
+ // @deprecated
254
208
  copyExternalImageToTexture(options) {
255
209
  const { source, sourceX = 0, sourceY = 0, texture, mipLevel = 0, aspect = 'all', colorSpace = 'display-p3', premultipliedAlpha = false,
256
210
  // destinationX,
@@ -277,3 +231,4 @@ export class WebGPUDevice extends Device {
277
231
  [width, height, depth]);
278
232
  }
279
233
  }
234
+ //# sourceMappingURL=webgpu-device.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webgpu-device.js","sourceRoot":"","sources":["../../src/adapter/webgpu-device.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AA8BpC,OAAO,EAAC,MAAM,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,YAAY,EAAC,qCAAkC;AACvD,OAAO,EAAC,aAAa,EAAC,sCAAmC;AACzD,OAAO,EAAC,qBAAqB,EAAC,+CAA4C;AAC1E,OAAO,EAAC,aAAa,EAAC,sCAAmC;AACzD,OAAO,EAAC,YAAY,EAAC,qCAAkC;AACvD,OAAO,EAAC,oBAAoB,EAAC,8CAA2C;AACxE,OAAO,EAAC,iBAAiB,EAAC,0CAAuC;AACjE,OAAO,EAAC,qBAAqB,EAAC,+CAA4C;AAC1E,OAAO,EAAC,gBAAgB,EAAC,0CAAuC;AAChE,OAAO,EAAC,iBAAiB,EAAC,2CAAwC;AAClE,2EAA2E;AAC3E,OAAO,EAAC,iBAAiB,EAAC,2CAAwC;AAElE,OAAO,E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