@luma.gl/webgpu 9.2.6 → 9.3.0-alpha.2

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 (39) hide show
  1. package/dist/adapter/resources/webgpu-fence.d.ts +13 -0
  2. package/dist/adapter/resources/webgpu-fence.d.ts.map +1 -0
  3. package/dist/adapter/resources/webgpu-fence.js +25 -0
  4. package/dist/adapter/resources/webgpu-fence.js.map +1 -0
  5. package/dist/adapter/resources/webgpu-texture.d.ts +12 -3
  6. package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
  7. package/dist/adapter/resources/webgpu-texture.js +143 -26
  8. package/dist/adapter/resources/webgpu-texture.js.map +1 -1
  9. package/dist/adapter/webgpu-adapter.d.ts.map +1 -1
  10. package/dist/adapter/webgpu-adapter.js +34 -34
  11. package/dist/adapter/webgpu-adapter.js.map +1 -1
  12. package/dist/adapter/webgpu-canvas-context.d.ts +4 -3
  13. package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
  14. package/dist/adapter/webgpu-canvas-context.js +22 -21
  15. package/dist/adapter/webgpu-canvas-context.js.map +1 -1
  16. package/dist/adapter/webgpu-device.d.ts +3 -1
  17. package/dist/adapter/webgpu-device.d.ts.map +1 -1
  18. package/dist/adapter/webgpu-device.js +14 -3
  19. package/dist/adapter/webgpu-device.js.map +1 -1
  20. package/dist/dist.dev.js +6438 -274
  21. package/dist/dist.min.js +10 -6
  22. package/dist/index.cjs +347 -86
  23. package/dist/index.cjs.map +4 -4
  24. package/dist/index.d.ts +2 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +2 -0
  27. package/dist/index.js.map +1 -1
  28. package/dist/wgsl/get-shader-layout-wgsl.d.ts +8 -0
  29. package/dist/wgsl/get-shader-layout-wgsl.d.ts.map +1 -0
  30. package/dist/wgsl/get-shader-layout-wgsl.js +136 -0
  31. package/dist/wgsl/get-shader-layout-wgsl.js.map +1 -0
  32. package/package.json +5 -4
  33. package/src/adapter/resources/webgpu-fence.ts +30 -0
  34. package/src/adapter/resources/webgpu-texture.ts +202 -88
  35. package/src/adapter/webgpu-adapter.ts +40 -42
  36. package/src/adapter/webgpu-canvas-context.ts +25 -23
  37. package/src/adapter/webgpu-device.ts +19 -4
  38. package/src/index.ts +3 -0
  39. package/src/wgsl/get-shader-layout-wgsl.ts +156 -0
package/dist/index.cjs CHANGED
@@ -267,11 +267,8 @@ var init_webgpu_texture = __esm({
267
267
  sampler;
268
268
  view;
269
269
  constructor(device, props) {
270
- super(device, props);
270
+ super(device, props, { byteAlignment: 256 });
271
271
  this.device = device;
272
- if (this.dimension === "cube") {
273
- this.depth = 6;
274
- }
275
272
  this.device.pushErrorScope("out-of-memory");
276
273
  this.device.pushErrorScope("validation");
277
274
  this.handle = this.props.handle || this.device.handle.createTexture({
@@ -318,6 +315,36 @@ var init_webgpu_texture = __esm({
318
315
  createView(props) {
319
316
  return new WebGPUTextureView(this.device, { ...props, texture: this });
320
317
  }
318
+ copyExternalImage(options_) {
319
+ const options = this._normalizeCopyExternalImageOptions(options_);
320
+ this.device.pushErrorScope("validation");
321
+ this.device.handle.queue.copyExternalImageToTexture(
322
+ // source: GPUImageCopyExternalImage
323
+ {
324
+ source: options.image,
325
+ origin: [options.sourceX, options.sourceY],
326
+ flipY: false
327
+ // options.flipY
328
+ },
329
+ // destination: GPUImageCopyTextureTagged
330
+ {
331
+ texture: this.handle,
332
+ origin: [options.x, options.y, options.z],
333
+ mipLevel: options.mipLevel,
334
+ aspect: options.aspect,
335
+ colorSpace: options.colorSpace,
336
+ premultipliedAlpha: options.premultipliedAlpha
337
+ },
338
+ // copySize: GPUExtent3D
339
+ [options.width, options.height, options.depth]
340
+ // depth is always 1 for 2D textures
341
+ );
342
+ this.device.popErrorScope((error) => {
343
+ this.device.reportError(new Error(`copyExternalImage: ${error.message}`), this)();
344
+ this.device.debug();
345
+ });
346
+ return { width: options.width, height: options.height };
347
+ }
321
348
  copyImageData(options_) {
322
349
  const { width, height, depth } = this;
323
350
  const options = this._normalizeCopyImageDataOptions(options_);
@@ -348,37 +375,118 @@ var init_webgpu_texture = __esm({
348
375
  this.device.debug();
349
376
  });
350
377
  }
351
- copyExternalImage(options_) {
352
- const options = this._normalizeCopyExternalImageOptions(options_);
378
+ generateMipmapsWebGL() {
379
+ import_core4.log.warn(`${this}: generateMipmaps not supported in WebGPU`)();
380
+ }
381
+ getImageDataLayout(options) {
382
+ return {
383
+ byteLength: 0,
384
+ bytesPerRow: 0,
385
+ rowsPerImage: 0
386
+ };
387
+ }
388
+ readBuffer(options = {}, buffer) {
389
+ const { x = 0, y = 0, z = 0, width = this.width, height = this.height, depthOrArrayLayers = this.depth, mipLevel = 0, aspect = "all" } = options;
390
+ const layout = this.computeMemoryLayout(options);
391
+ const { bytesPerRow, rowsPerImage, byteLength } = layout;
392
+ const readBuffer = buffer || this.device.createBuffer({
393
+ byteLength,
394
+ usage: import_core4.Buffer.COPY_DST | import_core4.Buffer.MAP_READ
395
+ });
396
+ const gpuReadBuffer = readBuffer.handle;
397
+ const gpuDevice = this.device.handle;
353
398
  this.device.pushErrorScope("validation");
354
- this.device.handle.queue.copyExternalImageToTexture(
355
- // source: GPUImageCopyExternalImage
399
+ const commandEncoder = gpuDevice.createCommandEncoder();
400
+ commandEncoder.copyTextureToBuffer(
401
+ // source
356
402
  {
357
- source: options.image,
358
- origin: [options.sourceX, options.sourceY],
359
- flipY: options.flipY
403
+ texture: this.handle,
404
+ origin: { x, y, z },
405
+ // origin: [options.x, options.y, 0], // options.depth],
406
+ mipLevel,
407
+ aspect
408
+ // colorSpace: options.colorSpace,
409
+ // premultipliedAlpha: options.premultipliedAlpha
360
410
  },
361
- // destination: GPUImageCopyTextureTagged
411
+ // destination
362
412
  {
363
- texture: this.handle,
364
- origin: [options.x, options.y, 0],
365
- // options.depth],
366
- mipLevel: options.mipLevel,
367
- aspect: options.aspect,
368
- colorSpace: options.colorSpace,
369
- premultipliedAlpha: options.premultipliedAlpha
413
+ buffer: gpuReadBuffer,
414
+ offset: 0,
415
+ bytesPerRow,
416
+ rowsPerImage
370
417
  },
371
- // copySize: GPUExtent3D
372
- [options.width, options.height, 1]
418
+ // copy size
419
+ {
420
+ width,
421
+ height,
422
+ depthOrArrayLayers
423
+ }
373
424
  );
425
+ const commandBuffer = commandEncoder.finish();
426
+ this.device.handle.queue.submit([commandBuffer]);
374
427
  this.device.popErrorScope((error) => {
375
- this.device.reportError(new Error(`copyExternalImage: ${error.message}`), this)();
428
+ this.device.reportError(new Error(`${this} readBuffer: ${error.message}`), this)();
429
+ this.device.debug();
430
+ });
431
+ return readBuffer;
432
+ }
433
+ async readDataAsync(options = {}) {
434
+ const buffer = this.readBuffer(options);
435
+ const data = await buffer.readAsync();
436
+ buffer.destroy();
437
+ return data.buffer;
438
+ }
439
+ writeBuffer(buffer, options = {}) {
440
+ const { x = 0, y = 0, z = 0, width = this.width, height = this.height, depthOrArrayLayers = this.depth, mipLevel = 0, aspect = "all" } = options;
441
+ const layout = this.computeMemoryLayout(options);
442
+ const { bytesPerRow, rowsPerImage } = layout;
443
+ const gpuDevice = this.device.handle;
444
+ this.device.pushErrorScope("validation");
445
+ const commandEncoder = gpuDevice.createCommandEncoder();
446
+ commandEncoder.copyBufferToTexture({
447
+ buffer: buffer.handle,
448
+ offset: 0,
449
+ bytesPerRow,
450
+ rowsPerImage
451
+ }, {
452
+ texture: this.handle,
453
+ origin: { x, y, z },
454
+ mipLevel,
455
+ aspect
456
+ }, { width, height, depthOrArrayLayers });
457
+ const commandBuffer = commandEncoder.finish();
458
+ this.device.handle.queue.submit([commandBuffer]);
459
+ this.device.popErrorScope((error) => {
460
+ this.device.reportError(new Error(`${this} writeBuffer: ${error.message}`), this)();
376
461
  this.device.debug();
377
462
  });
378
- return { width: options.width, height: options.height };
379
463
  }
380
- generateMipmapsWebGL() {
381
- import_core4.log.warn(`${this}: generateMipmaps not supported in WebGPU`)();
464
+ writeData(data, options = {}) {
465
+ const device = this.device;
466
+ const { x = 0, y = 0, z = 0, width = this.width, height = this.height, depthOrArrayLayers = this.depth, mipLevel = 0, aspect = "all" } = options;
467
+ const layout = import_core4.textureFormatDecoder.computeMemoryLayout({
468
+ format: this.format,
469
+ width: this.width,
470
+ height: this.height,
471
+ depth: this.depth,
472
+ byteAlignment: this.byteAlignment
473
+ });
474
+ const { bytesPerRow, rowsPerImage } = layout;
475
+ this.device.pushErrorScope("validation");
476
+ device.handle.queue.writeTexture({
477
+ texture: this.handle,
478
+ mipLevel,
479
+ aspect,
480
+ origin: { x, y, z }
481
+ }, data, {
482
+ offset: 0,
483
+ bytesPerRow,
484
+ rowsPerImage
485
+ }, { width, height, depthOrArrayLayers });
486
+ this.device.popErrorScope((error) => {
487
+ this.device.reportError(new Error(`${this} writeData: ${error.message}`), this)();
488
+ this.device.debug();
489
+ });
382
490
  }
383
491
  };
384
492
  }
@@ -1164,18 +1272,34 @@ var init_webgpu_canvas_context = __esm({
1164
1272
  this.device = device;
1165
1273
  this.handle = context;
1166
1274
  this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
1167
- this._updateDevice();
1275
+ this._configureDevice();
1168
1276
  }
1169
1277
  /** Destroy any textures produced while configured and remove the context configuration. */
1170
1278
  destroy() {
1171
1279
  this.handle.unconfigure();
1172
1280
  super.destroy();
1173
1281
  }
1282
+ // IMPLEMENTATION OF ABSTRACT METHODS
1283
+ /** @see https://www.w3.org/TR/webgpu/#canvas-configuration */
1284
+ _configureDevice() {
1285
+ if (this.depthStencilAttachment) {
1286
+ this.depthStencilAttachment.destroy();
1287
+ this.depthStencilAttachment = null;
1288
+ }
1289
+ this.handle.configure({
1290
+ device: this.device.handle,
1291
+ format: this.device.preferredColorFormat,
1292
+ // Can be used to define e.g. -srgb views
1293
+ // viewFormats: [...]
1294
+ colorSpace: this.props.colorSpace,
1295
+ alphaMode: this.props.alphaMode
1296
+ });
1297
+ }
1174
1298
  /** Update framebuffer with properly resized "swap chain" texture views */
1175
- getCurrentFramebuffer(options = {
1299
+ _getCurrentFramebuffer(options = {
1176
1300
  depthStencilFormat: "depth24plus"
1177
1301
  }) {
1178
- const currentColorAttachment = this.getCurrentTexture();
1302
+ const currentColorAttachment = this._getCurrentTexture();
1179
1303
  if (currentColorAttachment.width !== this.drawingBufferWidth || currentColorAttachment.height !== this.drawingBufferHeight) {
1180
1304
  const [oldWidth, oldHeight] = this.getDrawingBufferSize();
1181
1305
  this.drawingBufferWidth = currentColorAttachment.width;
@@ -1190,23 +1314,9 @@ var init_webgpu_canvas_context = __esm({
1190
1314
  depthStencilAttachment: this.depthStencilAttachment
1191
1315
  });
1192
1316
  }
1193
- // IMPLEMENTATION OF ABSTRACT METHODS
1194
- _updateDevice() {
1195
- if (this.depthStencilAttachment) {
1196
- this.depthStencilAttachment.destroy();
1197
- this.depthStencilAttachment = null;
1198
- }
1199
- this.handle.configure({
1200
- device: this.device.handle,
1201
- format: this.device.preferredColorFormat,
1202
- // Can be used to define e.g. -srgb views
1203
- // viewFormats: [...]
1204
- colorSpace: this.props.colorSpace,
1205
- alphaMode: this.props.alphaMode
1206
- });
1207
- }
1317
+ // PRIMARY METHODS
1208
1318
  /** Wrap the current canvas context texture in a luma.gl texture */
1209
- getCurrentTexture() {
1319
+ _getCurrentTexture() {
1210
1320
  const handle = this.handle.getCurrentTexture();
1211
1321
  return this.device.createTexture({
1212
1322
  id: `${this.id}#color-texture`,
@@ -1725,16 +1835,154 @@ var init_webgpu_pipeline_layout = __esm({
1725
1835
  }
1726
1836
  });
1727
1837
 
1838
+ // dist/adapter/resources/webgpu-fence.js
1839
+ var import_core21, WebGPUFence;
1840
+ var init_webgpu_fence = __esm({
1841
+ "dist/adapter/resources/webgpu-fence.js"() {
1842
+ "use strict";
1843
+ import_core21 = require("@luma.gl/core");
1844
+ WebGPUFence = class extends import_core21.Fence {
1845
+ device;
1846
+ handle = null;
1847
+ signaled;
1848
+ _signaled = false;
1849
+ constructor(device, props = {}) {
1850
+ super(device, {});
1851
+ this.device = device;
1852
+ this.signaled = device.handle.queue.onSubmittedWorkDone().then(() => {
1853
+ this._signaled = true;
1854
+ });
1855
+ }
1856
+ isSignaled() {
1857
+ return this._signaled;
1858
+ }
1859
+ destroy() {
1860
+ }
1861
+ };
1862
+ }
1863
+ });
1864
+
1865
+ // dist/wgsl/get-shader-layout-wgsl.js
1866
+ function getShaderLayoutFromWGSL(source) {
1867
+ var _a;
1868
+ const shaderLayout = { attributes: [], bindings: [] };
1869
+ let parsedWGSL;
1870
+ try {
1871
+ parsedWGSL = parseWGSL(source);
1872
+ } catch (error) {
1873
+ import_core22.log.error(error.message)();
1874
+ return shaderLayout;
1875
+ }
1876
+ for (const uniform of parsedWGSL.uniforms) {
1877
+ const members = [];
1878
+ for (const attribute of ((_a = uniform.type) == null ? void 0 : _a.members) || []) {
1879
+ members.push({
1880
+ name: attribute.name,
1881
+ type: getType(attribute.type)
1882
+ });
1883
+ }
1884
+ shaderLayout.bindings.push({
1885
+ type: "uniform",
1886
+ name: uniform.name,
1887
+ group: uniform.group,
1888
+ location: uniform.binding,
1889
+ // @ts-expect-error TODO - unused for now but needs fixing
1890
+ members
1891
+ });
1892
+ }
1893
+ for (const texture of parsedWGSL.textures) {
1894
+ const bindingDeclaration = {
1895
+ type: "texture",
1896
+ name: texture.name,
1897
+ group: texture.group,
1898
+ location: texture.binding,
1899
+ ...getTextureBindingFromReflect(texture)
1900
+ };
1901
+ shaderLayout.bindings.push(bindingDeclaration);
1902
+ }
1903
+ for (const sampler of parsedWGSL.samplers) {
1904
+ shaderLayout.bindings.push({
1905
+ type: "sampler",
1906
+ name: sampler.name,
1907
+ group: sampler.group,
1908
+ location: sampler.binding
1909
+ });
1910
+ }
1911
+ const vertex = parsedWGSL.entry.vertex[0];
1912
+ const attributeCount = (vertex == null ? void 0 : vertex.inputs.length) || 0;
1913
+ for (let i = 0; i < attributeCount; i++) {
1914
+ const wgslAttribute = vertex.inputs[i];
1915
+ if (wgslAttribute.locationType === "location") {
1916
+ const type = getType(wgslAttribute.type);
1917
+ shaderLayout.attributes.push({
1918
+ name: wgslAttribute.name,
1919
+ location: Number(wgslAttribute.location),
1920
+ type
1921
+ });
1922
+ }
1923
+ }
1924
+ return shaderLayout;
1925
+ }
1926
+ function getType(type) {
1927
+ return (type == null ? void 0 : type.format) ? `${type.name}<${type.format.name}>` : type.name;
1928
+ }
1929
+ function parseWGSL(source) {
1930
+ try {
1931
+ return new import_wgsl_reflect.WgslReflect(source);
1932
+ } catch (error) {
1933
+ if (error instanceof Error) {
1934
+ throw error;
1935
+ }
1936
+ let message = "WGSL parse error";
1937
+ if (typeof error === "object" && (error == null ? void 0 : error.message)) {
1938
+ message += `: ${error.message} `;
1939
+ }
1940
+ if (typeof error === "object" && (error == null ? void 0 : error.token)) {
1941
+ message += error.token.line || "";
1942
+ }
1943
+ throw new Error(message, { cause: error });
1944
+ }
1945
+ }
1946
+ function getTextureBindingFromReflect(v, opts) {
1947
+ var _a;
1948
+ if (v.resourceType !== import_wgsl_reflect.ResourceType.Texture) {
1949
+ throw new Error("Not a texture binding");
1950
+ }
1951
+ const typeName = v.type.name;
1952
+ const component = (_a = v.type.format) == null ? void 0 : _a.name;
1953
+ const viewDimension = typeName.includes("cube_array") ? "cube-array" : typeName.includes("cube") ? "cube" : typeName.includes("2d_array") ? "2d-array" : typeName.includes("3d") ? "3d" : typeName.includes("1d") ? "1d" : "2d";
1954
+ const multisampled = typeName === "texture_multisampled_2d";
1955
+ let sampleType;
1956
+ if (typeName.startsWith("texture_depth")) {
1957
+ sampleType = "depth";
1958
+ } else if (component === "i32") {
1959
+ sampleType = "sint";
1960
+ } else if (component === "u32") {
1961
+ sampleType = "uint";
1962
+ } else {
1963
+ sampleType = "float";
1964
+ }
1965
+ return { viewDimension, sampleType, multisampled };
1966
+ }
1967
+ var import_core22, import_wgsl_reflect;
1968
+ var init_get_shader_layout_wgsl = __esm({
1969
+ "dist/wgsl/get-shader-layout-wgsl.js"() {
1970
+ "use strict";
1971
+ import_core22 = require("@luma.gl/core");
1972
+ import_wgsl_reflect = require("wgsl_reflect");
1973
+ }
1974
+ });
1975
+
1728
1976
  // dist/adapter/webgpu-device.js
1729
1977
  var webgpu_device_exports = {};
1730
1978
  __export(webgpu_device_exports, {
1731
1979
  WebGPUDevice: () => WebGPUDevice
1732
1980
  });
1733
- var import_core21, WebGPUDevice;
1981
+ var import_core23, WebGPUDevice;
1734
1982
  var init_webgpu_device = __esm({
1735
1983
  "dist/adapter/webgpu-device.js"() {
1736
1984
  "use strict";
1737
- import_core21 = require("@luma.gl/core");
1985
+ import_core23 = require("@luma.gl/core");
1738
1986
  init_webgpu_buffer();
1739
1987
  init_webgpu_texture();
1740
1988
  init_webgpu_external_texture();
@@ -1748,7 +1996,9 @@ var init_webgpu_device = __esm({
1748
1996
  init_webgpu_command_encoder();
1749
1997
  init_webgpu_query_set();
1750
1998
  init_webgpu_pipeline_layout();
1751
- WebGPUDevice = class extends import_core21.Device {
1999
+ init_webgpu_fence();
2000
+ init_get_shader_layout_wgsl();
2001
+ WebGPUDevice = class extends import_core23.Device {
1752
2002
  /** The underlying WebGPU device */
1753
2003
  handle;
1754
2004
  /* The underlying WebGPU adapter */
@@ -1791,7 +2041,7 @@ var init_webgpu_device = __esm({
1791
2041
  this._isLost = true;
1792
2042
  resolve({ reason: "destroyed", message: lostInfo.message });
1793
2043
  });
1794
- const canvasContextProps = import_core21.Device._getCanvasContextProps(props);
2044
+ const canvasContextProps = import_core23.Device._getCanvasContextProps(props);
1795
2045
  if (canvasContextProps) {
1796
2046
  this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);
1797
2047
  }
@@ -1807,13 +2057,13 @@ var init_webgpu_device = __esm({
1807
2057
  get isLost() {
1808
2058
  return this._isLost;
1809
2059
  }
2060
+ getShaderLayout(source) {
2061
+ return getShaderLayoutFromWGSL(source);
2062
+ }
1810
2063
  isVertexFormatSupported(format) {
1811
2064
  const info = this.getVertexFormatInfo(format);
1812
2065
  return !info.webglOnly;
1813
2066
  }
1814
- getTextureByteAlignment() {
1815
- return 1;
1816
- }
1817
2067
  createBuffer(props) {
1818
2068
  const newProps = this._normalizeBufferProps(props);
1819
2069
  return new WebGPUBuffer(this, newProps);
@@ -1852,6 +2102,9 @@ var init_webgpu_device = __esm({
1852
2102
  createQuerySet(props) {
1853
2103
  return new WebGPUQuerySet(this, props);
1854
2104
  }
2105
+ createFence() {
2106
+ return new WebGPUFence(this);
2107
+ }
1855
2108
  createCanvasContext(props) {
1856
2109
  return new WebGPUCanvasContext(this, this.adapter, props);
1857
2110
  }
@@ -1914,6 +2167,12 @@ var init_webgpu_device = __esm({
1914
2167
  if (features.has("texture-compression-bc")) {
1915
2168
  features.add("texture-compression-bc5-webgl");
1916
2169
  }
2170
+ if (this.handle.features.has("chromium-experimental-norm16-texture-formats")) {
2171
+ features.add("norm16-renderable-webgl");
2172
+ }
2173
+ if (this.handle.features.has("chromium-experimental-snorm16-texture-formats")) {
2174
+ features.add("snorm16-renderable-webgl");
2175
+ }
1917
2176
  const WEBGPU_ALWAYS_FEATURES = [
1918
2177
  "timer-query-webgl",
1919
2178
  "compilation-status-async-webgl",
@@ -1926,7 +2185,7 @@ var init_webgpu_device = __esm({
1926
2185
  for (const feature of WEBGPU_ALWAYS_FEATURES) {
1927
2186
  features.add(feature);
1928
2187
  }
1929
- return new import_core21.DeviceFeatures(Array.from(features), this.props._disabledFeatures);
2188
+ return new import_core23.DeviceFeatures(Array.from(features), this.props._disabledFeatures);
1930
2189
  }
1931
2190
  _getDeviceSpecificTextureFormatCapabilities(capabilities) {
1932
2191
  const { format } = capabilities;
@@ -1944,16 +2203,18 @@ var dist_exports = {};
1944
2203
  __export(dist_exports, {
1945
2204
  WebGPUBuffer: () => WebGPUBuffer,
1946
2205
  WebGPUDevice: () => WebGPUDevice,
2206
+ WebGPUFence: () => WebGPUFence,
1947
2207
  WebGPUSampler: () => WebGPUSampler,
1948
2208
  WebGPUShader: () => WebGPUShader,
1949
2209
  WebGPUTexture: () => WebGPUTexture,
2210
+ getShaderLayoutFromWGSL: () => getShaderLayoutFromWGSL,
1950
2211
  webgpuAdapter: () => webgpuAdapter
1951
2212
  });
1952
2213
  module.exports = __toCommonJS(dist_exports);
1953
2214
 
1954
2215
  // dist/adapter/webgpu-adapter.js
1955
- var import_core22 = require("@luma.gl/core");
1956
- var WebGPUAdapter = class extends import_core22.Adapter {
2216
+ var import_core24 = require("@luma.gl/core");
2217
+ var WebGPUAdapter = class extends import_core24.Adapter {
1957
2218
  /** type of device's created by this adapter */
1958
2219
  type = "webgpu";
1959
2220
  isSupported() {
@@ -1973,43 +2234,41 @@ var WebGPUAdapter = class extends import_core22.Adapter {
1973
2234
  if (!navigator.gpu) {
1974
2235
  throw new Error("WebGPU not available. Recent Chrome browsers should work.");
1975
2236
  }
1976
- import_core22.log.groupCollapsed(1, "WebGPUDevice created")();
1977
- try {
1978
- const adapter = await navigator.gpu.requestAdapter({
1979
- powerPreference: "high-performance"
1980
- // forceSoftware: false
1981
- });
1982
- if (!adapter) {
1983
- throw new Error("Failed to request WebGPU adapter");
1984
- }
1985
- const adapterInfo = adapter.info || // @ts-ignore
1986
- await ((_a = adapter.requestAdapterInfo) == null ? void 0 : _a.call(adapter));
1987
- import_core22.log.probe(2, "Adapter available", adapterInfo)();
1988
- const requiredFeatures = [];
1989
- const requiredLimits = {};
1990
- if (props._requestMaxLimits) {
1991
- requiredFeatures.push(...Array.from(adapter.features));
1992
- const limits = Object.keys(adapter.limits).filter((key) => !["minSubgroupSize", "maxSubgroupSize"].includes(key));
1993
- for (const key of limits) {
1994
- const limit = key;
1995
- const value = adapter.limits[limit];
1996
- if (typeof value === "number") {
1997
- requiredLimits[limit] = value;
1998
- }
2237
+ const adapter = await navigator.gpu.requestAdapter({
2238
+ powerPreference: "high-performance"
2239
+ // forceSoftware: false
2240
+ });
2241
+ if (!adapter) {
2242
+ throw new Error("Failed to request WebGPU adapter");
2243
+ }
2244
+ const adapterInfo = adapter.info || // @ts-ignore
2245
+ await ((_a = adapter.requestAdapterInfo) == null ? void 0 : _a.call(adapter));
2246
+ const requiredFeatures = [];
2247
+ const requiredLimits = {};
2248
+ if (props._requestMaxLimits) {
2249
+ requiredFeatures.push(...Array.from(adapter.features));
2250
+ const limits = Object.keys(adapter.limits).filter((key) => !["minSubgroupSize", "maxSubgroupSize"].includes(key));
2251
+ for (const key of limits) {
2252
+ const limit = key;
2253
+ const value = adapter.limits[limit];
2254
+ if (typeof value === "number") {
2255
+ requiredLimits[limit] = value;
1999
2256
  }
2000
2257
  }
2001
- const gpuDevice = await adapter.requestDevice({
2002
- requiredFeatures,
2003
- requiredLimits
2004
- });
2005
- import_core22.log.probe(1, "GPUDevice available")();
2006
- const { WebGPUDevice: WebGPUDevice2 } = await Promise.resolve().then(() => (init_webgpu_device(), webgpu_device_exports));
2258
+ }
2259
+ const gpuDevice = await adapter.requestDevice({
2260
+ requiredFeatures,
2261
+ requiredLimits
2262
+ });
2263
+ const { WebGPUDevice: WebGPUDevice2 } = await Promise.resolve().then(() => (init_webgpu_device(), webgpu_device_exports));
2264
+ import_core24.log.groupCollapsed(1, "WebGPUDevice created")();
2265
+ try {
2007
2266
  const device = new WebGPUDevice2(props, gpuDevice, adapter, adapterInfo);
2008
- import_core22.log.probe(1, "Device created. For more info, set chrome://flags/#enable-webgpu-developer-features")();
2009
- import_core22.log.table(1, device.info)();
2267
+ import_core24.log.probe(1, "Device created. For more info, set chrome://flags/#enable-webgpu-developer-features")();
2268
+ import_core24.log.table(1, device.info)();
2010
2269
  return device;
2011
2270
  } finally {
2012
- import_core22.log.groupEnd(1)();
2271
+ import_core24.log.groupEnd(1)();
2013
2272
  }
2014
2273
  }
2015
2274
  async attach(handle) {
@@ -2024,4 +2283,6 @@ init_webgpu_buffer();
2024
2283
  init_webgpu_texture();
2025
2284
  init_webgpu_sampler();
2026
2285
  init_webgpu_shader();
2286
+ init_webgpu_fence();
2287
+ init_get_shader_layout_wgsl();
2027
2288
  //# sourceMappingURL=index.cjs.map