@luma.gl/webgpu 9.0.0-alpha.52 → 9.0.0-alpha.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/webgpu",
3
- "version": "9.0.0-alpha.52",
3
+ "version": "9.0.0-alpha.53",
4
4
  "description": "WebGPU adapter for the luma.gl API",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -37,9 +37,9 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@babel/runtime": "^7.0.0",
40
- "@luma.gl/core": "9.0.0-alpha.52",
40
+ "@luma.gl/core": "9.0.0-alpha.53",
41
41
  "@probe.gl/env": "^4.0.2",
42
42
  "@webgpu/types": "^0.1.34"
43
43
  },
44
- "gitHead": "41fa29f78dc260e5ef4c6a48e657fb5d23c96e8f"
44
+ "gitHead": "f8939f1cf52a15f11ec053d4906e40f0b2a86836"
45
45
  }
@@ -1,9 +1,5 @@
1
- import {CommandEncoder, CommandEncoderProps, Buffer, Texture, cast,
2
- CopyTextureToTextureOptions,
3
- CopyTextureToBufferOptions
4
- // CopyBufferToTextureOptions,
5
- // CopyBufferToBufferOptions,
6
- } from '@luma.gl/core';
1
+ import {CommandEncoder, CommandEncoderProps, Buffer, Texture} from '@luma.gl/core';
2
+ import type {CopyTextureToTextureOptions, CopyTextureToBufferOptions} from '@luma.gl/core';
7
3
  import {WebGPUDevice} from '../webgpu-device';
8
4
  import {WebGPUBuffer} from './webgpu-buffer';
9
5
  import {WebGPUTexture} from './webgpu-texture';
@@ -15,10 +11,12 @@ export class WebGPUCommandEncoder extends CommandEncoder {
15
11
  constructor(device: WebGPUDevice, props: CommandEncoderProps) {
16
12
  super(device, props);
17
13
  this.device = device;
18
- this.handle = props.handle || this.device.handle.createCommandEncoder({
19
- // TODO was this removed in standard?
20
- // measureExecutionTime: this.props.measureExecutionTime
21
- });
14
+ this.handle =
15
+ props.handle ||
16
+ this.device.handle.createCommandEncoder({
17
+ // TODO was this removed in standard?
18
+ // measureExecutionTime: this.props.measureExecutionTime
19
+ });
22
20
  this.handle.label = this.props.id;
23
21
  }
24
22
 
@@ -32,49 +30,51 @@ export class WebGPUCommandEncoder extends CommandEncoder {
32
30
  // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
33
31
 
34
32
  copyBufferToBuffer(options: // CopyBufferToBufferOptions
35
- {
36
- source: Buffer,
37
- sourceOffset?: number,
38
- destination: Buffer,
39
- destinationOffset?: number,
40
- size?: number
41
- }
42
- ): void {
33
+ {
34
+ source: Buffer;
35
+ sourceOffset?: number;
36
+ destination: Buffer;
37
+ destinationOffset?: number;
38
+ size?: number;
39
+ }): void {
40
+ const webgpuSourceBuffer = options.source as WebGPUBuffer;
41
+ const WebGPUDestinationBuffer = options.destination as WebGPUBuffer;
43
42
  this.handle.copyBufferToBuffer(
44
- cast<WebGPUBuffer>(options.source).handle,
43
+ webgpuSourceBuffer.handle,
45
44
  options.sourceOffset ?? 0,
46
- cast<WebGPUBuffer>(options.destination).handle,
45
+ WebGPUDestinationBuffer.handle,
47
46
  options.destinationOffset ?? 0,
48
47
  options.size ?? 0
49
48
  );
50
49
  }
51
50
 
52
51
  copyBufferToTexture(options: // CopyBufferToTextureOptions
53
- {
54
- source: Buffer,
55
- offset?: number,
56
- bytesPerRow: number,
57
- rowsPerImage: number,
52
+ {
53
+ source: Buffer;
54
+ offset?: number;
55
+ bytesPerRow: number;
56
+ rowsPerImage: number;
58
57
 
59
- destination: Texture,
58
+ destination: Texture;
60
59
  mipLevel?: number;
61
- aspect?: 'all' | 'stencil-only' | 'depth-only',
60
+ aspect?: 'all' | 'stencil-only' | 'depth-only';
62
61
 
63
- origin?: number[] | [number, number, number],
64
- extent?: number[] | [number, number, number]
65
- }
66
- ): void {
62
+ origin?: number[] | [number, number, number];
63
+ extent?: number[] | [number, number, number];
64
+ }): void {
65
+ const webgpuSourceBuffer = options.source as WebGPUBuffer;
66
+ const WebGPUDestinationTexture = options.destination as WebGPUTexture;
67
67
  this.handle.copyBufferToTexture(
68
68
  {
69
- buffer: cast<WebGPUBuffer>(options.source).handle,
69
+ buffer: webgpuSourceBuffer.handle,
70
70
  offset: options.offset ?? 0,
71
71
  bytesPerRow: options.bytesPerRow,
72
- rowsPerImage: options.rowsPerImage,
72
+ rowsPerImage: options.rowsPerImage
73
73
  },
74
74
  {
75
- texture: cast<WebGPUTexture>(options.destination).handle,
75
+ texture: WebGPUDestinationTexture.handle,
76
76
  mipLevel: options.mipLevel ?? 0,
77
- origin: options.origin ?? {},
77
+ origin: options.origin ?? {}
78
78
  // aspect: options.aspect
79
79
  },
80
80
  {
@@ -129,4 +129,4 @@ export class WebGPUCommandEncoder extends CommandEncoder {
129
129
  // destination: Buffer,
130
130
  // destinationOffset?: number;
131
131
  // }): void;
132
- }
132
+ }
@@ -1,4 +1,4 @@
1
- import {ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding, cast} from '@luma.gl/core';
1
+ import {ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding} from '@luma.gl/core';
2
2
  import {WebGPUDevice} from '../webgpu-device';
3
3
  import {WebGPUBuffer} from './webgpu-buffer';
4
4
  // import {WebGPUCommandEncoder} from './webgpu-command-encoder';
@@ -27,7 +27,7 @@ export class WebGPUComputePass extends ComputePass {
27
27
  }
28
28
 
29
29
  setPipeline(pipeline: ComputePipeline): void {
30
- const wgpuPipeline = cast<WebGPUComputePipeline>(pipeline);
30
+ const wgpuPipeline = pipeline as WebGPUComputePipeline;
31
31
  this.handle.setPipeline(wgpuPipeline.handle);
32
32
  this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();
33
33
  }
@@ -55,7 +55,8 @@ export class WebGPUComputePass extends ComputePass {
55
55
  * @param indirectOffset
56
56
  */
57
57
  dispatchIndirect(indirectBuffer: Buffer, indirectOffset: number = 0): void {
58
- this.handle.dispatchWorkgroupsIndirect(cast<WebGPUBuffer>(indirectBuffer).handle, indirectOffset);
58
+ const webgpuBuffer = indirectBuffer as WebGPUBuffer;
59
+ this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectOffset);
59
60
  }
60
61
 
61
62
  pushDebugGroup(groupLabel: string): void {
@@ -1,5 +1,5 @@
1
1
  // prettier-ignore
2
- import {ComputePipeline, ComputePipelineProps, cast} from '@luma.gl/core';
2
+ import {ComputePipeline, ComputePipelineProps} from '@luma.gl/core';
3
3
 
4
4
  import {WebGPUDevice} from '../webgpu-device';
5
5
  import {WebGPUShader} from './webgpu-shader';
@@ -15,11 +15,11 @@ export class WebGPUComputePipeline extends ComputePipeline {
15
15
  super(device, props);
16
16
  this.device = device;
17
17
 
18
- const module = cast<WebGPUShader>(this.props.cs).handle;
18
+ const webgpuShader = this.props.cs as WebGPUShader;
19
19
  this.handle = this.props.handle || this.device.handle.createComputePipeline({
20
20
  label: this.props.id,
21
21
  compute: {
22
- module,
22
+ module: webgpuShader.handle,
23
23
  entryPoint: this.props.csEntryPoint,
24
24
  // constants: this.props.csConstants
25
25
  },
@@ -77,7 +77,7 @@ export class WebGPUDevice extends Device {
77
77
  }
78
78
 
79
79
  const adapterInfo = await adapter.requestAdapterInfo();
80
- log.probe(1, 'Adapter available', adapterInfo)();
80
+ log.probe(2, 'Adapter available', adapterInfo)();
81
81
 
82
82
  const gpuDevice = await adapter.requestDevice({
83
83
  requiredFeatures: adapter.features as ReadonlySet<GPUFeatureName>
@@ -91,28 +91,42 @@ export class WebGPUDevice extends Device {
91
91
  log.probe(1, 'DOM is loaded')();
92
92
  }
93
93
 
94
- const device = new WebGPUDevice(gpuDevice, adapter, props);
95
- log.probe(1, 'Device created', device.info)();
94
+ const device = new WebGPUDevice(gpuDevice, adapter, adapterInfo, props);
95
+
96
+ log.probe(1, 'Device created. For more info, set chrome://flags/#enable-webgpu-developer-features')();
96
97
  log.table(1, device.info)();
97
98
  log.groupEnd(1)();
98
99
  return device;
99
100
  }
100
101
 
101
- constructor(device: GPUDevice, adapter: GPUAdapter, props: DeviceProps) {
102
+ constructor(device: GPUDevice, adapter: GPUAdapter, adapterInfo: GPUAdapterInfo, props: DeviceProps) {
102
103
  super({...props, id: props.id || uid('webgpu-device')});
103
104
  this.handle = device;
104
105
  this.adapter = adapter;
105
106
 
107
+ const [driver, driverVersion] = ((adapterInfo as any).driver || '').split(' Version ');
108
+
109
+ // See https://developer.chrome.com/blog/new-in-webgpu-120#adapter_information_updates
110
+ const vendor = adapterInfo.vendor || this.adapter.__brand || 'unknown';
111
+ const renderer = driver || '';
112
+ const version = driverVersion || '';
113
+
114
+ const gpu = vendor === 'apple' ? 'apple' : 'unknown'; // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',
115
+ const gpuArchitecture = adapterInfo.architecture || 'unknown';
116
+ const gpuBackend = (adapterInfo as any).backend || 'unknown';
117
+ const gpuType = ((adapterInfo as any).type || '').split(' ')[0].toLowerCase() || 'unknown'
118
+
106
119
  this._info = {
107
120
  type: 'webgpu',
108
- vendor: this.adapter.__brand,
109
- renderer: '',
110
- version: '',
111
- gpu: 'unknown', // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',
121
+ vendor,
122
+ renderer,
123
+ version,
124
+ gpu,
125
+ gpuType,
126
+ gpuBackend,
127
+ gpuArchitecture,
112
128
  shadingLanguage: 'wgsl',
113
- shadingLanguageVersion: 100,
114
- vendorMasked: '',
115
- rendererMasked: ''
129
+ shadingLanguageVersion: 100
116
130
  };
117
131
 
118
132
  // "Context" loss handling