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

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 (121) hide show
  1. package/LICENSE +3 -1
  2. package/dist/adapter/helpers/accessor-to-format.js.map +1 -1
  3. package/dist/adapter/helpers/convert-texture-format.d.ts +2 -2
  4. package/dist/adapter/helpers/convert-texture-format.d.ts.map +1 -1
  5. package/dist/adapter/helpers/convert-texture-format.js +0 -1
  6. package/dist/adapter/helpers/convert-texture-format.js.map +1 -1
  7. package/dist/adapter/helpers/generate-mipmaps.d.ts +1 -1
  8. package/dist/adapter/helpers/generate-mipmaps.js +20 -15
  9. package/dist/adapter/helpers/generate-mipmaps.js.map +1 -1
  10. package/dist/adapter/helpers/get-bind-group.d.ts +4 -4
  11. package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
  12. package/dist/adapter/helpers/get-bind-group.js +8 -17
  13. package/dist/adapter/helpers/get-bind-group.js.map +1 -1
  14. package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts +5 -5
  15. package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -1
  16. package/dist/adapter/helpers/get-vertex-buffer-layout.js +32 -40
  17. package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -1
  18. package/dist/adapter/helpers/webgpu-parameters.d.ts +2 -2
  19. package/dist/adapter/helpers/webgpu-parameters.d.ts.map +1 -1
  20. package/dist/adapter/helpers/webgpu-parameters.js +51 -48
  21. package/dist/adapter/helpers/webgpu-parameters.js.map +1 -1
  22. package/dist/adapter/resources/webgpu-buffer.d.ts +5 -6
  23. package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
  24. package/dist/adapter/resources/webgpu-buffer.js +19 -33
  25. package/dist/adapter/resources/webgpu-buffer.js.map +1 -1
  26. package/dist/adapter/resources/webgpu-command-encoder.d.ts +6 -15
  27. package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
  28. package/dist/adapter/resources/webgpu-command-encoder.js +11 -29
  29. package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
  30. package/dist/adapter/resources/webgpu-compute-pass.d.ts +6 -6
  31. package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
  32. package/dist/adapter/resources/webgpu-compute-pass.js +14 -27
  33. package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
  34. package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +4 -4
  35. package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
  36. package/dist/adapter/resources/webgpu-compute-pipeline.js +6 -11
  37. package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -1
  38. package/dist/adapter/resources/webgpu-external-texture.d.ts +5 -5
  39. package/dist/adapter/resources/webgpu-external-texture.d.ts.map +1 -1
  40. package/dist/adapter/resources/webgpu-external-texture.js +6 -14
  41. package/dist/adapter/resources/webgpu-external-texture.js.map +1 -1
  42. package/dist/adapter/resources/webgpu-framebuffer.d.ts +4 -21
  43. package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
  44. package/dist/adapter/resources/webgpu-framebuffer.js +4 -105
  45. package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
  46. package/dist/adapter/resources/webgpu-query.js.map +1 -1
  47. package/dist/adapter/resources/webgpu-render-pass.d.ts +12 -7
  48. package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
  49. package/dist/adapter/resources/webgpu-render-pass.js +59 -36
  50. package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
  51. package/dist/adapter/resources/webgpu-render-pipeline.d.ts +14 -10
  52. package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
  53. package/dist/adapter/resources/webgpu-render-pipeline.js +50 -67
  54. package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
  55. package/dist/adapter/resources/webgpu-sampler.d.ts +5 -5
  56. package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
  57. package/dist/adapter/resources/webgpu-sampler.js +11 -11
  58. package/dist/adapter/resources/webgpu-sampler.js.map +1 -1
  59. package/dist/adapter/resources/webgpu-shader.d.ts +9 -9
  60. package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
  61. package/dist/adapter/resources/webgpu-shader.js +15 -29
  62. package/dist/adapter/resources/webgpu-shader.js.map +1 -1
  63. package/dist/adapter/resources/webgpu-texture.d.ts +15 -8
  64. package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
  65. package/dist/adapter/resources/webgpu-texture.js +17 -27
  66. package/dist/adapter/resources/webgpu-texture.js.map +1 -1
  67. package/dist/adapter/resources/webgpu-vertex-array.d.ts +26 -0
  68. package/dist/adapter/resources/webgpu-vertex-array.d.ts.map +1 -0
  69. package/dist/adapter/resources/webgpu-vertex-array.js +39 -0
  70. package/dist/adapter/resources/webgpu-vertex-array.js.map +1 -0
  71. package/dist/adapter/webgpu-canvas-context.d.ts +16 -12
  72. package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
  73. package/dist/adapter/webgpu-canvas-context.js +26 -47
  74. package/dist/adapter/webgpu-canvas-context.js.map +1 -1
  75. package/dist/adapter/webgpu-device.d.ts +39 -22
  76. package/dist/adapter/webgpu-device.d.ts.map +1 -1
  77. package/dist/adapter/webgpu-device.js +94 -95
  78. package/dist/adapter/webgpu-device.js.map +1 -1
  79. package/dist/adapter/webgpu-types.js.map +1 -1
  80. package/dist/dist.dev.js +3134 -0
  81. package/dist/glsl/glsllang.js +0 -1
  82. package/dist/glsl/glsllang.js.map +1 -1
  83. package/dist/index.cjs +1519 -0
  84. package/dist/index.d.ts +5 -7
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +5 -7
  87. package/dist/index.js.map +1 -1
  88. package/dist.min.js +30 -0
  89. package/package.json +18 -9
  90. package/src/adapter/helpers/accessor-to-format.ts +1 -2
  91. package/src/adapter/helpers/convert-texture-format.ts +1 -1
  92. package/src/adapter/helpers/generate-mipmaps.ts +2 -2
  93. package/src/adapter/helpers/get-bind-group.ts +22 -12
  94. package/src/adapter/helpers/get-vertex-buffer-layout.ts +55 -34
  95. package/src/adapter/helpers/webgpu-parameters.ts +56 -47
  96. package/src/adapter/resources/webgpu-buffer.ts +11 -12
  97. package/src/adapter/resources/webgpu-command-encoder.ts +62 -41
  98. package/src/adapter/resources/webgpu-compute-pass.ts +13 -13
  99. package/src/adapter/resources/webgpu-compute-pipeline.ts +6 -5
  100. package/src/adapter/resources/webgpu-external-texture.ts +5 -5
  101. package/src/adapter/resources/webgpu-framebuffer.ts +8 -109
  102. package/src/adapter/resources/webgpu-query.ts +3 -3
  103. package/src/adapter/resources/webgpu-render-pass.ts +74 -18
  104. package/src/adapter/resources/webgpu-render-pipeline.ts +64 -39
  105. package/src/adapter/resources/webgpu-sampler.ts +12 -5
  106. package/src/adapter/resources/webgpu-shader.ts +22 -16
  107. package/src/adapter/resources/webgpu-texture.ts +22 -8
  108. package/src/adapter/resources/webgpu-vertex-array.ts +74 -0
  109. package/src/adapter/webgpu-canvas-context.ts +52 -27
  110. package/src/adapter/webgpu-device.ts +158 -64
  111. package/src/index.ts +7 -9
  112. package/dist/bundle.d.ts +0 -2
  113. package/dist/bundle.d.ts.map +0 -1
  114. package/dist/bundle.js +0 -5
  115. package/dist/bundle.js.map +0 -1
  116. package/dist/init.d.ts +0 -2
  117. package/dist/init.d.ts.map +0 -1
  118. package/dist/init.js +0 -4
  119. package/dist/init.js.map +0 -1
  120. package/src/bundle.ts +0 -4
  121. package/src/init.ts +0 -4
@@ -1,13 +1,14 @@
1
- /// <reference types="@webgpu/types" />
2
- /// <reference types="offscreencanvas" />
3
- import { Texture, TextureProps, Sampler, SamplerProps } from '@luma.gl/api';
4
- import type WebGPUDevice from '../webgpu-device';
5
- import WebGPUSampler from './webgpu-sampler';
6
- export default class WebGPUTexture extends Texture {
1
+ /// <reference types="dist" />
2
+ import { Texture, TextureProps, Sampler, SamplerProps } from '@luma.gl/core';
3
+ import type { WebGPUDevice } from '../webgpu-device';
4
+ import { WebGPUSampler } from './webgpu-sampler';
5
+ export declare class WebGPUTexture extends Texture {
7
6
  readonly device: WebGPUDevice;
8
7
  readonly handle: GPUTexture;
9
8
  readonly view: GPUTextureView;
10
9
  sampler: WebGPUSampler;
10
+ height: number;
11
+ width: number;
11
12
  constructor(device: WebGPUDevice, props: TextureProps);
12
13
  protected createHandle(): GPUTexture;
13
14
  destroy(): void;
@@ -18,7 +19,10 @@ export default class WebGPUTexture extends Texture {
18
19
  setSampler(sampler: Sampler | SamplerProps): this;
19
20
  setData(options: {
20
21
  data: any;
21
- }): this;
22
+ }): {
23
+ width: number;
24
+ height: number;
25
+ };
22
26
  /** Set image */
23
27
  setImage(options: {
24
28
  source: ImageBitmap | HTMLCanvasElement | OffscreenCanvas;
@@ -34,6 +38,9 @@ export default class WebGPUTexture extends Texture {
34
38
  aspect?: 'all' | 'stencil-only' | 'depth-only';
35
39
  colorSpace?: 'srgb';
36
40
  premultipliedAlpha?: boolean;
37
- }): this;
41
+ }): {
42
+ width: number;
43
+ height: number;
44
+ };
38
45
  }
39
46
  //# sourceMappingURL=webgpu-texture.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-texture.ts"],"names":[],"mappings":";;AACA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAS,MAAM,cAAc,CAAC;AAElF,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAW7C,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAChD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,OAAO,EAAE,aAAa,CAAC;gBASX,MAAM,EAAE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QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,OAAO,EAAE,aAAa,CAAC;IAEd,MAAM,EAAE,MAAM,CAAK;IACnB,KAAK,EAAE,MAAM,CAAK;gBASf,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY;IAyCrD,SAAS,CAAC,YAAY,IAAI,UAAU;IAyB3B,OAAO,IAAI,IAAI;IAIxB;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI;IAKjD,OAAO,CAAC,OAAO,EAAE;QACf,IAAI,EAAE,GAAG,CAAC;KACX;;;;IAID,gBAAgB;IAChB,QAAQ,CAAC,OAAO,EAAE;QAChB,MAAM,EAAE,WAAW,GAAG,iBAAiB,GAAG,eAAe,CAAC;QAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,MAAM,CAAC,EAAE,KAAK,GAAG,cAAc,GAAG,YAAY,CAAC;QAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,GAAG;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC;CA6HpC"}
@@ -1,7 +1,6 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { Texture } from '@luma.gl/api';
3
- import { getWebGPUTextureFormat } from '../helpers/convert-texture-format';
4
- import WebGPUSampler from './webgpu-sampler';
1
+ import { Texture } from '@luma.gl/core';
2
+ import { getWebGPUTextureFormat } from "../helpers/convert-texture-format.js";
3
+ import { WebGPUSampler } from "./webgpu-sampler.js";
5
4
  const BASE_DIMENSIONS = {
6
5
  '1d': '1d',
7
6
  '2d': '2d',
@@ -10,42 +9,35 @@ const BASE_DIMENSIONS = {
10
9
  'cube-array': '2d',
11
10
  '3d': '3d'
12
11
  };
13
- export default class WebGPUTexture extends Texture {
12
+ export class WebGPUTexture extends Texture {
14
13
  constructor(device, props) {
15
14
  super(device, props);
16
-
17
- _defineProperty(this, "device", void 0);
18
-
19
- _defineProperty(this, "handle", void 0);
20
-
21
- _defineProperty(this, "view", void 0);
22
-
23
- _defineProperty(this, "sampler", void 0);
24
-
15
+ this.device = void 0;
16
+ this.handle = void 0;
17
+ this.view = void 0;
18
+ this.sampler = void 0;
19
+ this.height = 1;
20
+ this.width = 1;
25
21
  if (typeof this.props.format === 'number') {
26
22
  throw new Error('number format');
27
23
  }
28
-
29
24
  this.device = device;
30
25
  this.handle = this.props.handle || this.createHandle();
31
-
32
26
  if (this.props.data) {
33
27
  this.setData({
34
28
  data: this.props.data
35
29
  });
36
30
  }
37
-
38
- this.setSampler(props.sampler);
31
+ this.width = this.handle.width;
32
+ this.height = this.handle.height;
33
+ this.sampler = props.sampler instanceof WebGPUSampler ? props.sampler : new WebGPUSampler(this.device, props.sampler);
39
34
  this.view = this.handle.createView({});
40
35
  }
41
-
42
36
  createHandle() {
43
37
  var _this$props$data, _this$props$data2;
44
-
45
38
  if (typeof this.props.format === 'number') {
46
39
  throw new Error('number format');
47
40
  }
48
-
49
41
  const width = this.props.width || ((_this$props$data = this.props.data) === null || _this$props$data === void 0 ? void 0 : _this$props$data.width) || 1;
50
42
  const height = this.props.height || ((_this$props$data2 = this.props.data) === null || _this$props$data2 === void 0 ? void 0 : _this$props$data2.height) || 1;
51
43
  return this.device.handle.createTexture({
@@ -61,22 +53,18 @@ export default class WebGPUTexture extends Texture {
61
53
  sampleCount: this.props.samples
62
54
  });
63
55
  }
64
-
65
56
  destroy() {
66
57
  this.handle.destroy();
67
58
  }
68
-
69
59
  setSampler(sampler) {
70
60
  this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);
71
61
  return this;
72
62
  }
73
-
74
63
  setData(options) {
75
64
  return this.setImage({
76
65
  source: options.data
77
66
  });
78
67
  }
79
-
80
68
  setImage(options) {
81
69
  const {
82
70
  source,
@@ -104,8 +92,10 @@ export default class WebGPUTexture extends Texture {
104
92
  colorSpace,
105
93
  premultipliedAlpha
106
94
  }, [width, height, depth]);
107
- return this;
95
+ return {
96
+ width,
97
+ height
98
+ };
108
99
  }
109
-
110
100
  }
111
101
  //# sourceMappingURL=webgpu-texture.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-texture.ts"],"names":["Texture","getWebGPUTextureFormat","WebGPUSampler","BASE_DIMENSIONS","WebGPUTexture","constructor","device","props","format","Error","handle","createHandle","data","setData","setSampler","sampler","view","createView","width","height","createTexture","size","depthOrArrayLayers","depth","dimension","usage","mipLevelCount","mipLevels","sampleCount","samples","destroy","options","setImage","source","sourceX","sourceY","mipLevel","x","y","z","aspect","colorSpace","premultipliedAlpha","queue","copyExternalImageToTexture","origin","texture"],"mappings":";AACA,SAAQA,OAAR,QAAmE,cAAnE;AACA,SAAQC,sBAAR,QAAqC,mCAArC;AAEA,OAAOC,aAAP,MAA0B,kBAA1B;AAEA,MAAMC,eAAmD,GAAG;AAC1D,QAAM,IADoD;AAE1D,QAAM,IAFoD;AAG1D,cAAY,IAH8C;AAI1D,UAAQ,IAJkD;AAK1D,gBAAc,IAL4C;AAM1D,QAAM;AANoD,CAA5D;AASA,eAAe,MAAMC,aAAN,SAA4BJ,OAA5B,CAAoC;AAajDK,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAA4C;AACrD,UAAMD,MAAN,EAAcC,KAAd;;AADqD;;AAAA;;AAAA;;AAAA;;AAGrD,QAAI,OAAO,KAAKA,KAAL,CAAWC,MAAlB,KAA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,EAOE;AACEW,MAAAA,OAAO,EAAE,KAAKpC,MADhB;AAEEmC,MAAAA,MAAM,EAAE,CAACR,CAAD,EAAIC,CAAJ,EAAOC,CAAP,CAFV;AAGEH,MAAAA,QAHF;AAIEI,MAAAA,MAJF;AAKEC,MAAAA,UALF;AAMEC,MAAAA;AANF,KAPF,EAgBE,CACExB,KADF,EAEEC,MAFF,EAGEI,KAHF,CAhBF;AAsBA,WAAO,IAAP;AACD;;AAhJgD","sourcesContent":["// luma.gl, MIT license\nimport {Texture, TextureProps, Sampler, SamplerProps, assert} from '@luma.gl/api';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport type WebGPUDevice from '../webgpu-device';\nimport WebGPUSampler from './webgpu-sampler';\n\nconst BASE_DIMENSIONS: Record<string, '1d' | '2d' | '3d'> = {\n '1d': '1d',\n '2d': '2d',\n '2d-array': '2d',\n 'cube': '2d',\n 'cube-array': '2d',\n '3d': '3d'\n};\n\nexport default class WebGPUTexture extends Texture {\n readonly device: WebGPUDevice;\n readonly handle: GPUTexture;\n readonly view: GPUTextureView;\n sampler: WebGPUSampler;\n\n // static async createFromImageURL(src, usage = 0) {\n // const img = document.createElement('img');\n // img.src = src;\n // await img.decode();\n // return WebGPUTexture(img, usage);\n // }\n\n constructor(device: WebGPUDevice, props: TextureProps) {\n super(device, props);\n\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n this.device = device;\n this.handle = this.props.handle || this.createHandle();\n\n if (this.props.data) {\n this.setData({data: this.props.data} );\n }\n\n // Create a default sampler. This mimics the WebGL1 API where sampler props are stored on the texture\n this.setSampler(props.sampler);\n\n // TODO - To support texture arrays we need to create custom views...\n // But we are not ready to expose TextureViews to the public API.\n this.view = this.handle.createView({\n // format: this.props.format,\n // dimension: this.props.dimension,\n // aspect = \"all\";\n // baseMipLevel: 0;\n // mipLevelCount;\n // baseArrayLayer = 0;\n // arrayLayerCount;\n });\n }\n\n protected createHandle(): GPUTexture {\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n // Deduce size from data - TODO this is a hack\n // @ts-expect-error\n const width = this.props.width || this.props.data?.width || 1;\n // @ts-expect-error\n const height = this.props.height || this.props.data?.height || 1;\n\n return this.device.handle.createTexture({\n size: {\n width,\n height,\n depthOrArrayLayers: this.props.depth\n },\n dimension: BASE_DIMENSIONS[this.props.dimension],\n format: getWebGPUTextureFormat(this.props.format),\n usage: this.props.usage,\n mipLevelCount: this.props.mipLevels,\n sampleCount: this.props.samples\n });\n }\n\n destroy(): void {\n this.handle.destroy();\n }\n\n /**\n * Set default sampler\n * Accept a sampler instance or set of props;\n */\n setSampler(sampler: Sampler | SamplerProps): this {\n this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n\n setData(options: {\n data: any;\n }) {\n return this.setImage({source: options.data});\n }\n\n /** Set image */\n setImage(options: {\n source: ImageBitmap | HTMLCanvasElement | OffscreenCanvas;\n width?: number;\n height?: number;\n depth?: number;\n sourceX?: number;\n sourceY?: number;\n mipLevel?: number;\n x?: number;\n y?: number;\n z?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'srgb';\n premultipliedAlpha?: boolean;\n }): this {\n const {\n source,\n width = options.source.width,\n height = options.source.height,\n depth = 1,\n sourceX = 0,\n sourceY = 0,\n mipLevel = 0,\n x = 0,\n y = 0,\n z = 0,\n aspect = 'all',\n colorSpace = 'srgb',\n premultipliedAlpha = false\n } = options;\n\n // TODO - max out width\n\n this.device.handle.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: this.handle,\n origin: [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [\n width,\n height,\n depth\n ]\n );\n return this;\n }\n\n /*\n async readPixels() {\n const readbackBuffer = device.createBuffer({\n usage: Buffer.COPY_DST | Buffer.MAP_READ,\n size: 4 * textureWidth * textureHeight,\n });\n\n // Copy data from the texture to the buffer.\n const encoder = device.createCommandEncoder();\n encoder.copyTextureToBuffer(\n { texture },\n { buffer, rowPitch: textureWidth * 4 },\n [textureWidth, textureHeight],\n );\n device.submit([encoder.finish()]);\n\n // Get the data on the CPU.\n await buffer.mapAsync(GPUMapMode.READ);\n saveScreenshot(buffer.getMappedRange());\n buffer.unmap();\n }\n\n setImageData(imageData, usage): this {\n let data = null;\n\n const bytesPerRow = Math.ceil((img.width * 4) / 256) * 256;\n if (bytesPerRow == img.width * 4) {\n data = imageData.data;\n } else {\n data = new Uint8Array(bytesPerRow * img.height);\n let imagePixelIndex = 0;\n for (let y = 0; y < img.height; ++y) {\n for (let x = 0; x < img.width; ++x) {\n const i = x * 4 + y * bytesPerRow;\n data[i] = imageData.data[imagePixelIndex];\n data[i + 1] = imageData.data[imagePixelIndex + 1];\n data[i + 2] = imageData.data[imagePixelIndex + 2];\n data[i + 3] = imageData.data[imagePixelIndex + 3];\n imagePixelIndex += 4;\n }\n }\n }\n return this;\n }\n\n setData(data): this {\n const textureDataBuffer = this.device.handle.createBuffer({\n size: data.byteLength,\n usage: Buffer.COPY_DST | Buffer.COPY_SRC,\n mappedAtCreation: true\n });\n new Uint8Array(textureDataBuffer.getMappedRange()).set(data);\n textureDataBuffer.unmap();\n\n this.setBuffer(textureDataBuffer);\n\n textureDataBuffer.destroy();\n return this;\n }\n\n setBuffer(textureDataBuffer, {bytesPerRow}): this {\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToTexture(\n {\n buffer: textureDataBuffer,\n bytesPerRow\n },\n {\n texture: this.handle\n },\n {\n width,\n height,\n depth\n }\n );\n\n this.device.handle.defaultQueue.submit([commandEncoder.finish()]);\n return this;\n }\n */\n}\n"],"file":"webgpu-texture.js"}
1
+ {"version":3,"file":"webgpu-texture.js","names":["Texture","getWebGPUTextureFormat","WebGPUSampler","BASE_DIMENSIONS","WebGPUTexture","constructor","device","props","handle","view","sampler","height","width","format","Error","createHandle","data","setData","createView","_this$props$data","_this$props$data2","createTexture","size","depthOrArrayLayers","depth","dimension","usage","mipLevelCount","mipLevels","sampleCount","samples","destroy","setSampler","options","setImage","source","sourceX","sourceY","mipLevel","x","y","z","aspect","colorSpace","premultipliedAlpha","queue","copyExternalImageToTexture","origin","texture"],"sources":["../../../src/adapter/resources/webgpu-texture.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {Texture, TextureProps, Sampler, SamplerProps} from '@luma.gl/core';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUSampler} from './webgpu-sampler';\n\nconst BASE_DIMENSIONS: Record<string, '1d' | '2d' | '3d'> = {\n '1d': '1d',\n '2d': '2d',\n '2d-array': '2d',\n 'cube': '2d',\n 'cube-array': '2d',\n '3d': '3d'\n};\n\nexport class WebGPUTexture extends Texture {\n readonly device: WebGPUDevice;\n readonly handle: GPUTexture;\n readonly view: GPUTextureView;\n sampler: WebGPUSampler;\n\n override height: number = 1;\n override width: number = 1;\n\n // static async createFromImageURL(src, usage = 0) {\n // const img = document.createElement('img');\n // img.src = src;\n // await img.decode();\n // return WebGPUTexture(img, usage);\n // }\n\n constructor(device: WebGPUDevice, props: TextureProps) {\n super(device, props);\n\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n this.device = device;\n this.handle = this.props.handle || this.createHandle();\n\n if (this.props.data) {\n this.setData({data: this.props.data} );\n }\n\n this.width = this.handle.width;\n this.height = this.handle.height;\n // Why not just read all properties directly from the texture\n // this.depthOrArrayLayers = this.handle.depthOrArrayLayers;\n // this.mipLevelCount = this.handle.mipLevelCount;\n // this.sampleCount = this.handle.sampleCount;\n // this.dimension = this.handle.dimension;\n // this.format = this.handle.format;\n // this.usage = this.handle.usage;\n\n // Create a default sampler. This mimics the WebGL1 API where sampler props are stored on the texture\n // this.setSampler(props.sampler);\n this.sampler = props.sampler instanceof WebGPUSampler ? props.sampler : new WebGPUSampler(this.device, props.sampler);\n\n // TODO - To support texture arrays we need to create custom views...\n // But we are not ready to expose TextureViews to the public API.\n this.view = this.handle.createView({\n // format: this.props.format,\n // dimension: this.props.dimension,\n // aspect = \"all\";\n // baseMipLevel: 0;\n // mipLevelCount;\n // baseArrayLayer = 0;\n // arrayLayerCount;\n });\n }\n\n protected createHandle(): GPUTexture {\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n // Deduce size from data - TODO this is a hack\n // @ts-expect-error\n const width = this.props.width || this.props.data?.width || 1;\n // @ts-expect-error\n const height = this.props.height || this.props.data?.height || 1;\n\n return this.device.handle.createTexture({\n size: {\n width,\n height,\n depthOrArrayLayers: this.props.depth\n },\n dimension: BASE_DIMENSIONS[this.props.dimension],\n format: getWebGPUTextureFormat(this.props.format),\n usage: this.props.usage,\n mipLevelCount: this.props.mipLevels,\n sampleCount: this.props.samples\n });\n }\n\n override destroy(): void {\n this.handle.destroy();\n }\n\n /**\n * Set default sampler\n * Accept a sampler instance or set of props;\n */\n setSampler(sampler: Sampler | SamplerProps): this {\n this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n\n setData(options: {\n data: any;\n }) {\n return this.setImage({source: options.data});\n }\n\n /** Set image */\n setImage(options: {\n source: ImageBitmap | HTMLCanvasElement | OffscreenCanvas;\n width?: number;\n height?: number;\n depth?: number;\n sourceX?: number;\n sourceY?: number;\n mipLevel?: number;\n x?: number;\n y?: number;\n z?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'srgb';\n premultipliedAlpha?: boolean;\n }): {width: number, height: number} {\n const {\n source,\n width = options.source.width,\n height = options.source.height,\n depth = 1,\n sourceX = 0,\n sourceY = 0,\n mipLevel = 0,\n x = 0,\n y = 0,\n z = 0,\n aspect = 'all',\n colorSpace = 'srgb',\n premultipliedAlpha = false\n } = options;\n\n // TODO - max out width\n\n this.device.handle.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: this.handle,\n origin: [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [\n width,\n height,\n depth\n ]\n );\n return {width, height};\n }\n\n /*\n async readPixels() {\n const readbackBuffer = device.createBuffer({\n usage: Buffer.COPY_DST | Buffer.MAP_READ,\n size: 4 * textureWidth * textureHeight,\n });\n\n // Copy data from the texture to the buffer.\n const encoder = device.createCommandEncoder();\n encoder.copyTextureToBuffer(\n { texture },\n { buffer, rowPitch: textureWidth * 4 },\n [textureWidth, textureHeight],\n );\n device.submit([encoder.finish()]);\n\n // Get the data on the CPU.\n await buffer.mapAsync(GPUMapMode.READ);\n saveScreenshot(buffer.getMappedRange());\n buffer.unmap();\n }\n\n setImageData(imageData, usage): this {\n let data = null;\n\n const bytesPerRow = Math.ceil((img.width * 4) / 256) * 256;\n if (bytesPerRow == img.width * 4) {\n data = imageData.data;\n } else {\n data = new Uint8Array(bytesPerRow * img.height);\n let imagePixelIndex = 0;\n for (let y = 0; y < img.height; ++y) {\n for (let x = 0; x < img.width; ++x) {\n const i = x * 4 + y * bytesPerRow;\n data[i] = imageData.data[imagePixelIndex];\n data[i + 1] = imageData.data[imagePixelIndex + 1];\n data[i + 2] = imageData.data[imagePixelIndex + 2];\n data[i + 3] = imageData.data[imagePixelIndex + 3];\n imagePixelIndex += 4;\n }\n }\n }\n return this;\n }\n\n setData(data): this {\n const textureDataBuffer = this.device.handle.createBuffer({\n size: data.byteLength,\n usage: Buffer.COPY_DST | Buffer.COPY_SRC,\n mappedAtCreation: true\n });\n new Uint8Array(textureDataBuffer.getMappedRange()).set(data);\n textureDataBuffer.unmap();\n\n this.setBuffer(textureDataBuffer);\n\n textureDataBuffer.destroy();\n return this;\n }\n\n setBuffer(textureDataBuffer, {bytesPerRow}): this {\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToTexture(\n {\n buffer: textureDataBuffer,\n bytesPerRow\n },\n {\n texture: this.handle\n },\n {\n width,\n height,\n depth\n }\n );\n\n this.device.handle.defaultQueue.submit([commandEncoder.finish()]);\n return this;\n }\n */\n}\n"],"mappings":"AACA,SAAQA,OAAO,QAA4C,eAAe;AAAC,SACnEC,sBAAsB;AAAA,SAEtBC,aAAa;AAErB,MAAMC,eAAmD,GAAG;EAC1D,IAAI,EAAE,IAAI;EACV,IAAI,EAAE,IAAI;EACV,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,IAAI;EACZ,YAAY,EAAE,IAAI;EAClB,IAAI,EAAE;AACR,CAAC;AAED,OAAO,MAAMC,aAAa,SAASJ,OAAO,CAAC;EAgBzCK,WAAWA,CAACC,MAAoB,EAAEC,KAAmB,EAAE;IACrD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAAC,KAhBdD,MAAM;IAAA,KACNE,MAAM;IAAA,KACNC,IAAI;IAAA,KACbC,OAAO;IAAA,KAEEC,MAAM,GAAW,CAAC;IAAA,KAClBC,KAAK,GAAW,CAAC;IAYxB,IAAI,OAAO,IAAI,CAACL,KAAK,CAACM,MAAM,KAAK,QAAQ,EAAE;MACzC,MAAM,IAAIC,KAAK,CAAC,eAAe,CAAC;IAClC;IAEA,IAAI,CAACR,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,MAAM,GAAG,IAAI,CAACD,KAAK,CAACC,MAAM,IAAI,IAAI,CAACO,YAAY,CAAC,CAAC;IAEtD,IAAI,IAAI,CAACR,KAAK,CAACS,IAAI,EAAE;MACnB,IAAI,CAACC,OAAO,CAAC;QAACD,IAAI,EAAE,IAAI,CAACT,KAAK,CAACS;MAAI,CAAG,CAAC;IACzC;IAEA,IAAI,CAACJ,KAAK,GAAG,IAAI,CAACJ,MAAM,CAACI,KAAK;IAC9B,IAAI,CAACD,MAAM,GAAG,IAAI,CAACH,MAAM,CAACG,MAAM;I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M,CAAC;EACxB;AAmFF"}
@@ -0,0 +1,26 @@
1
+ import type { Device, Buffer, VertexArrayProps, RenderPass, TypedArray } from '@luma.gl/core';
2
+ import { VertexArray } from '@luma.gl/core';
3
+ import { WebGPUDevice } from '../webgpu-device';
4
+ /** VertexArrayObject wrapper */
5
+ export declare class WebGPUVertexArray extends VertexArray {
6
+ get [Symbol.toStringTag](): string;
7
+ readonly device: WebGPUDevice;
8
+ /** Vertex Array is a helper class under WebGPU */
9
+ readonly handle: never;
10
+ /** * Attribute 0 can not be disable on most desktop OpenGL based browsers */
11
+ static isConstantAttributeZeroSupported(device: Device): boolean;
12
+ constructor(device: WebGPUDevice, props?: VertexArrayProps);
13
+ destroy(): void;
14
+ /**
15
+ * Set an elements buffer, for indexed rendering.
16
+ * Must be a Buffer bound to buffer with usage bit Buffer.INDEX set.
17
+ */
18
+ setIndexBuffer(buffer: Buffer | null): void;
19
+ /** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
20
+ setBuffer(location: number, buffer: Buffer): void;
21
+ /** Set a location in vertex attributes array to a constant value, disables the location */
22
+ setConstant(location: number, value: TypedArray): void;
23
+ bindBeforeRender(renderPass: RenderPass, firstIndex?: number, indexCount?: number): void;
24
+ unbindAfterRender(renderPass: RenderPass): void;
25
+ }
26
+ //# sourceMappingURL=webgpu-vertex-array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webgpu-vertex-array.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-vertex-array.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAC,WAAW,EAAM,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAK9C,gCAAgC;AAChC,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;IAED,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IAEvB,6EAA6E;IAC7E,MAAM,CAAC,gCAAgC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;gBAKpD,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,gBAAgB;IAKjD,OAAO,IAAI,IAAI;IAExB;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAK3C,gGAAgG;IAChG,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IASjD,2FAA2F;IAClF,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IAItD,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAWxF,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;CAGzD"}
@@ -0,0 +1,39 @@
1
+ let _Symbol$toStringTag;
2
+ import { VertexArray, log } from '@luma.gl/core';
3
+ import { getBrowser } from '@probe.gl/env';
4
+ _Symbol$toStringTag = Symbol.toStringTag;
5
+ export class WebGPUVertexArray extends VertexArray {
6
+ get [_Symbol$toStringTag]() {
7
+ return 'WebGPUVertexArray';
8
+ }
9
+ static isConstantAttributeZeroSupported(device) {
10
+ return device.info.type === 'webgl2' || getBrowser() === 'Chrome';
11
+ }
12
+ constructor(device, props) {
13
+ super(device, props);
14
+ this.device = void 0;
15
+ this.handle = void 0;
16
+ this.device = device;
17
+ }
18
+ destroy() {}
19
+ setIndexBuffer(buffer) {
20
+ this.indexBuffer = buffer;
21
+ }
22
+ setBuffer(location, buffer) {
23
+ this.attributes[location] = buffer;
24
+ }
25
+ setConstant(location, value) {
26
+ log.warn(`${this.id} constant attributes not supported on WebGPU`);
27
+ }
28
+ bindBeforeRender(renderPass, firstIndex, indexCount) {
29
+ const webgpuRenderPass = renderPass;
30
+ const webgpuIndexBuffer = this.indexBuffer;
31
+ webgpuRenderPass.handle.setIndexBuffer(webgpuIndexBuffer === null || webgpuIndexBuffer === void 0 ? void 0 : webgpuIndexBuffer.handle, webgpuIndexBuffer === null || webgpuIndexBuffer === void 0 ? void 0 : webgpuIndexBuffer.indexType);
32
+ for (let location = 0; location < this.maxVertexAttributes; location++) {
33
+ const webgpuBuffer = this.attributes[location];
34
+ webgpuRenderPass.handle.setVertexBuffer(location, webgpuBuffer.handle);
35
+ }
36
+ }
37
+ unbindAfterRender(renderPass) {}
38
+ }
39
+ //# sourceMappingURL=webgpu-vertex-array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webgpu-vertex-array.js","names":["VertexArray","log","getBrowser","_Symbol$toStringTag","Symbol","toStringTag","WebGPUVertexArray","isConstantAttributeZeroSupported","device","info","type","constructor","props","handle","destroy","setIndexBuffer","buffer","indexBuffer","setBuffer","location","attributes","setConstant","value","warn","id","bindBeforeRender","renderPass","firstIndex","indexCount","webgpuRenderPass","webgpuIndexBuffer","indexType","maxVertexAttributes","webgpuBuffer","setVertexBuffer","unbindAfterRender"],"sources":["../../../src/adapter/resources/webgpu-vertex-array.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {Device, Buffer, VertexArrayProps, RenderPass, TypedArray} from '@luma.gl/core';\nimport {VertexArray, log} from '@luma.gl/core';\nimport {getBrowser} from '@probe.gl/env';\n\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from '../resources/webgpu-buffer';\n\nimport {WebGPURenderPass} from './webgpu-render-pass';\n\n/** VertexArrayObject wrapper */\nexport class WebGPUVertexArray extends VertexArray {\n override get [Symbol.toStringTag](): string {\n return 'WebGPUVertexArray';\n }\n\n readonly device: WebGPUDevice;\n /** Vertex Array is a helper class under WebGPU */\n readonly handle: never;\n\n /** * Attribute 0 can not be disable on most desktop OpenGL based browsers */\n static isConstantAttributeZeroSupported(device: Device): boolean {\n return device.info.type === 'webgl2' || getBrowser() === 'Chrome';\n }\n\n // Create a VertexArray\n constructor(device: WebGPUDevice, props?: VertexArrayProps) {\n super(device, props);\n this.device = device;\n }\n\n override destroy(): void {}\n\n /**\n * Set an elements buffer, for indexed rendering.\n * Must be a Buffer bound to buffer with usage bit Buffer.INDEX set. \n */\n setIndexBuffer(buffer: Buffer | null): void {\n // assert(!elementBuffer || elementBuffer.glTarget === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n this.indexBuffer = buffer;\n }\n\n /** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */\n setBuffer(location: number, buffer: Buffer): void {\n // Sanity check target\n // if (buffer.glUsage === GL.ELEMENT_ARRAY_BUFFER) {\n // throw new Error('Use setIndexBuffer');\n // }\n\n this.attributes[location] = buffer;\n }\n\n /** Set a location in vertex attributes array to a constant value, disables the location */\n override setConstant(location: number, value: TypedArray): void {\n log.warn(`${this.id} constant attributes not supported on WebGPU`)\n }\n\n override bindBeforeRender(renderPass: RenderPass, firstIndex?: number, indexCount?: number): void {\n const webgpuRenderPass = renderPass as WebGPURenderPass;\n const webgpuIndexBuffer = this.indexBuffer as WebGPUBuffer;\n webgpuRenderPass.handle.setIndexBuffer(webgpuIndexBuffer?.handle, webgpuIndexBuffer?.indexType);\n for (let location = 0; location < this.maxVertexAttributes; location++) {\n const webgpuBuffer = this.attributes[location] as WebGPUBuffer;\n webgpuRenderPass.handle.setVertexBuffer(location, webgpuBuffer.handle);\n }\n // TODO - emit warnings/errors/throw if constants have been set on this vertex array\n }\n\n override unbindAfterRender(renderPass: RenderPass): void {\n // On WebGPU we don't unbind\n }\n}\n"],"mappings":";AAIA,SAAQA,WAAW,EAAEC,GAAG,QAAO,eAAe;AAC9C,SAAQC,UAAU,QAAO,eAAe;AAACC,mBAAA,G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ACtE,MAAMc,YAAY,GAAG,IAAI,CAACb,UAAU,CAACD,QAAQ,CAAiB;MAC9DU,gBAAgB,CAAChB,MAAM,CAACqB,eAAe,CAACf,QAAQ,EAAEc,YAAY,CAACpB,MAAM,CAAC;IACxE;EAEF;EAESsB,iBAAiBA,CAACT,UAAsB,EAAQ,CAEzD;AACF"}
@@ -1,24 +1,28 @@
1
- /// <reference types="@webgpu/types" />
2
- import type { Texture, TextureFormat, CanvasContextProps } from '@luma.gl/api';
3
- import { CanvasContext } from '@luma.gl/api';
4
- import WebGPUDevice from './webgpu-device';
5
- import WEBGPUFramebuffer from './resources/webgpu-framebuffer';
1
+ /// <reference types="dist" />
2
+ import type { Texture, TextureFormat, CanvasContextProps } from '@luma.gl/core';
3
+ import { CanvasContext } from '@luma.gl/core';
4
+ import { WebGPUDevice } from './webgpu-device';
5
+ import { WebGPUFramebuffer } from './resources/webgpu-framebuffer';
6
+ import { WebGPUTexture } from './resources/webgpu-texture';
6
7
  /**
7
- * Holds a WebGPU Canvas Context which handles resizing etc
8
+ * Holds a WebGPU Canvas Context
9
+ * The primary job of the CanvasContext is to generate textures for rendering into the current canvas
10
+ * It also manages canvas sizing calculations and resizing.
8
11
  */
9
- export default class WebGPUCanvasContext extends CanvasContext {
12
+ export declare class WebGPUCanvasContext extends CanvasContext {
10
13
  readonly device: WebGPUDevice;
11
14
  readonly gpuCanvasContext: GPUCanvasContext;
15
+ /** Format of returned textures: "bgra8unorm", "rgba8unorm", "rgba16float". */
12
16
  readonly format: TextureFormat;
13
- width: number;
14
- height: number;
17
+ /** Default stencil format for depth textures */
15
18
  depthStencilFormat: TextureFormat;
16
- sampleCount: number;
17
19
  private depthStencilAttachment;
18
20
  constructor(device: WebGPUDevice, adapter: GPUAdapter, props: CanvasContextProps);
21
+ /** Destroy any textures produced while configured and remove the context configuration. */
19
22
  destroy(): void;
23
+ getCurrentTexture(): WebGPUTexture;
20
24
  /** Update framebuffer with properly resized "swap chain" texture views */
21
- getCurrentFramebuffer(): WEBGPUFramebuffer;
25
+ getCurrentFramebuffer(): WebGPUFramebuffer;
22
26
  /** Resizes and updates render targets if necessary */
23
27
  update(): void;
24
28
  resize(options?: {
@@ -27,6 +31,6 @@ export default class WebGPUCanvasContext extends CanvasContext {
27
31
  useDevicePixels?: boolean | number;
28
32
  }): void;
29
33
  /** We build render targets on demand (i.e. not when size changes but when about to render) */
30
- _createDepthStencilAttachment(): Texture;
34
+ _createDepthStencilAttachment(): Texture<import("@luma.gl/core").TextureProps>;
31
35
  }
32
36
  //# sourceMappingURL=webgpu-canvas-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-canvas-context.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAC,aAAa,EAAM,MAAM,cAAc,CAAC;AAEhD,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,aAAa;IAC5D,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAM;IACnB,MAAM,EAAE,MAAM,CAAM;IACpB,kBAAkB,EAAE,aAAa,CAAiB;IAClD,WAAW,EAAE,MAAM,CAAK;IAExB,OAAO,CAAC,sBAAsB,CAAU;gBAE5B,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,kBAAkB;IAOhF,OAAO;IAIP,0EAA0E;IAC1E,qBAAqB,IAAI,iBAAiB;IAsB1C,sDAAsD;IACtD,MAAM;IA6BN,MAAM,CAAC,OAAO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;KAAC,GAAG,IAAI;IAI7F,8FAA8F;IAC9F,6BAA6B;CAY9B"}
@@ -1,82 +1,63 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { CanvasContext, log } from '@luma.gl/api';
3
- import { getWebGPUTextureFormat } from './helpers/convert-texture-format';
4
- import WEBGPUFramebuffer from './resources/webgpu-framebuffer';
5
- export default class WebGPUCanvasContext extends CanvasContext {
1
+ import { CanvasContext, log } from '@luma.gl/core';
2
+ import { getWebGPUTextureFormat } from "./helpers/convert-texture-format.js";
3
+ import { WebGPUFramebuffer } from "./resources/webgpu-framebuffer.js";
4
+ export class WebGPUCanvasContext extends CanvasContext {
6
5
  constructor(device, adapter, props) {
7
6
  super(props);
8
-
9
- _defineProperty(this, "device", void 0);
10
-
11
- _defineProperty(this, "gpuCanvasContext", void 0);
12
-
13
- _defineProperty(this, "format", void 0);
14
-
15
- _defineProperty(this, "width", -1);
16
-
17
- _defineProperty(this, "height", -1);
18
-
19
- _defineProperty(this, "depthStencilFormat", 'depth24plus');
20
-
21
- _defineProperty(this, "sampleCount", 1);
22
-
23
- _defineProperty(this, "depthStencilAttachment", void 0);
24
-
7
+ this.device = void 0;
8
+ this.gpuCanvasContext = void 0;
9
+ this.format = navigator.gpu.getPreferredCanvasFormat();
10
+ this.depthStencilFormat = 'depth24plus';
11
+ this.depthStencilAttachment = null;
25
12
  this.device = device;
13
+ this.width = -1;
14
+ this.height = -1;
15
+ this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
26
16
  this.gpuCanvasContext = this.canvas.getContext('webgpu');
27
- this.format = this.gpuCanvasContext.getPreferredFormat(adapter);
17
+ this.format = 'bgra8unorm';
28
18
  }
29
-
30
19
  destroy() {
31
20
  this.gpuCanvasContext.unconfigure();
32
21
  }
33
-
34
- getCurrentFramebuffer() {
35
- this.update();
36
- const currentColorAttachment = this.device.createTexture({
22
+ getCurrentTexture() {
23
+ return this.device._createTexture({
37
24
  id: 'default-render-target',
38
- handle: this.gpuCanvasContext.getCurrentTexture(),
39
- format: this.format,
40
- width: this.width,
41
- height: this.height
25
+ handle: this.gpuCanvasContext.getCurrentTexture()
42
26
  });
43
-
27
+ }
28
+ getCurrentFramebuffer() {
29
+ this.update();
30
+ const currentColorAttachment = this.getCurrentTexture();
31
+ this.width = currentColorAttachment.width;
32
+ this.height = currentColorAttachment.height;
44
33
  this._createDepthStencilAttachment();
45
-
46
- return new WEBGPUFramebuffer(this.device, {
34
+ return new WebGPUFramebuffer(this.device, {
47
35
  colorAttachments: [currentColorAttachment],
48
36
  depthStencilAttachment: this.depthStencilAttachment
49
37
  });
50
38
  }
51
-
52
39
  update() {
53
40
  const [width, height] = this.getPixelSize();
54
41
  const sizeChanged = width !== this.width || height !== this.height;
55
-
56
42
  if (sizeChanged) {
57
43
  this.width = width;
58
44
  this.height = height;
59
-
60
45
  if (this.depthStencilAttachment) {
61
46
  this.depthStencilAttachment.destroy();
62
- this.depthStencilAttachment = undefined;
47
+ this.depthStencilAttachment = null;
63
48
  }
64
-
65
49
  this.gpuCanvasContext.configure({
66
50
  device: this.device.handle,
67
51
  format: getWebGPUTextureFormat(this.format),
68
- size: [this.width, this.height],
69
52
  colorSpace: this.props.colorSpace,
70
- compositingAlphaMode: this.props.compositingAlphaMode
53
+ alphaMode: this.props.alphaMode
71
54
  });
72
- log.log(1, "Resized to ".concat(this.width, "x").concat(this.height, "px"))();
55
+ log.log(1, `Resized to ${this.width}x${this.height}px`)();
73
56
  }
74
57
  }
75
-
76
58
  resize(options) {
77
59
  this.update();
78
60
  }
79
-
80
61
  _createDepthStencilAttachment() {
81
62
  if (!this.depthStencilAttachment) {
82
63
  this.depthStencilAttachment = this.device.createTexture({
@@ -87,9 +68,7 @@ export default class WebGPUCanvasContext extends CanvasContext {
87
68
  usage: GPUTextureUsage.RENDER_ATTACHMENT
88
69
  });
89
70
  }
90
-
91
71
  return this.depthStencilAttachment;
92
72
  }
93
-
94
73
  }
95
74
  //# sourceMappingURL=webgpu-canvas-context.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/adapter/webgpu-canvas-context.ts"],"names":["CanvasContext","log","getWebGPUTextureFormat","WEBGPUFramebuffer","WebGPUCanvasContext","constructor","device","adapter","props","gpuCanvasContext","canvas","getContext","format","getPreferredFormat","destroy","unconfigure","getCurrentFramebuffer","update","currentColorAttachment","createTexture","id","handle","getCurrentTexture","width","height","_createDepthStencilAttachment","colorAttachments","depthStencilAttachment","getPixelSize","sizeChanged","undefined","configure","size","colorSpace","compositingAlphaMode","resize","options","depthStencilFormat","usage","GPUTextureUsage","RENDER_ATTACHMENT"],"mappings":";AACA,SAAQA,aAAR,EAAuBC,GAAvB,QAAiC,cAAjC;AACA,SAAQC,sBAAR,QAAqC,kCAArC;AAEA,OAAOC,iBAAP,MAA8B,gCAA9B;AAKA,eAAe,MAAMC,mBAAN,SAAkCJ,aAAlC,CAAgD;AAW7DK,EAAAA,WAAW,CAACC,MAAD,EAAuBC,OAAvB,EAA4CC,KAA5C,EAAuE;AAChF,UAAMA,KAAN;;AADgF;;AAAA;;AAAA;;AAAA,mCAPlE,CAAC,CAOiE;;AAAA,oCANjE,CAAC,CAMgE;;AAAA,gDAL9C,aAK8C;;AAAA,yCAJ5D,CAI4D;;AAAA;;AAEhF,SAAKF,MAAL,GAAcA,MAAd;AACA,SAAKG,gBAAL,GAAwB,KAAKC,MAAL,CAAYC,UAAZ,CAAuB,QAAvB,CAAxB;AACA,SAAKC,MAAL,GAAc,KAAKH,gBAAL,CAAsBI,kBAAtB,CAAyCN,OAAzC,CAAd;AACD;;AAEDO,EAAAA,OAAO,GAAG;AACR,SAAKL,gBAAL,CAAsBM,WAAtB;AACD;;AAGDC,EAAAA,qBAAqB,GAAsB;AAEzC,SAAKC,MAAL;AAGA,UAAMC,sBAAsB,GAAG,KAAKZ,MAAL,CAAYa,aAAZ,CAA0B;AACvDC,MAAAA,EAAE,EAAE,uBADmD;AAEvDC,MAAAA,MAAM,EAAE,KAAKZ,gBAAL,CAA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AAwF;AAC5F,SAAKnB,MAAL;AACD;;AAGDQ,EAAAA,6BAA6B,GAAG;AAC9B,QAAI,CAAC,KAAKE,sBAAV,EAAkC;AAChC,WAAKA,sBAAL,GAA8B,KAAKrB,MAAL,CAAYa,aAAZ,CAA0B;AACtDC,QAAAA,EAAE,EAAE,sBADkD;AAEtDR,QAAAA,MAAM,EAAE,KAAKyB,kBAFyC;AAGtDd,QAAAA,KAAK,EAAE,KAAKA,KAH0C;AAItDC,QAAAA,MAAM,EAAE,KAAKA,MAJyC;AAKtDc,QAAAA,KAAK,EAAEC,eAAe,CAACC;AAL+B,OAA1B,CAA9B;AAOD;;AACD,WAAO,KAAKb,sBAAZ;AACD;;AA3F4D","sourcesContent":["import type {Texture, TextureFormat, CanvasContextProps} from '@luma.gl/api';\nimport {CanvasContext, log} from '@luma.gl/api';\nimport {getWebGPUTextureFormat} from './helpers/convert-texture-format';\nimport WebGPUDevice from './webgpu-device';\nimport WEBGPUFramebuffer from './resources/webgpu-framebuffer';\n\n/** \n * Holds a WebGPU Canvas Context which handles resizing etc \n */\nexport default class WebGPUCanvasContext extends CanvasContext {\n readonly device: WebGPUDevice;\n readonly gpuCanvasContext: GPUCanvasContext;\n readonly format: TextureFormat;\n width: number = -1;\n height: number = -1;\n depthStencilFormat: TextureFormat = 'depth24plus';\n sampleCount: number = 1;\n\n private depthStencilAttachment: Texture;\n\n constructor(device: WebGPUDevice, adapter: GPUAdapter, props: CanvasContextProps) {\n super(props);\n this.device = device;\n this.gpuCanvasContext = this.canvas.getContext('webgpu') as GPUCanvasContext;\n this.format = this.gpuCanvasContext.getPreferredFormat(adapter);\n }\n\n destroy() {\n this.gpuCanvasContext.unconfigure();\n }\n\n /** Update framebuffer with properly resized \"swap chain\" texture views */\n getCurrentFramebuffer(): WEBGPUFramebuffer {\n // Ensure the canvas context size is updated\n this.update();\n\n // Wrap the current canvas context texture in a luma.gl texture \n const currentColorAttachment = this.device.createTexture({\n id: 'default-render-target',\n handle: this.gpuCanvasContext.getCurrentTexture(),\n format: this.format,\n width: this.width,\n height: this.height\n });\n\n // Resize the depth stencil attachment\n this._createDepthStencilAttachment();\n\n return new WEBGPUFramebuffer(this.device, {\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: this.depthStencilAttachment\n });\n }\n\n /** Resizes and updates render targets if necessary */\n update() {\n const [width, height] = this.getPixelSize();\n\n const sizeChanged = width !== this.width || height !== this.height;\n\n if (sizeChanged) {\n this.width = width;\n this.height = height;\n\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = undefined;\n }\n\n // Reconfigure the canvas size.\n // https://www.w3.org/TR/webgpu/#canvas-configuration\n this.gpuCanvasContext.configure({\n device: this.device.handle,\n format: getWebGPUTextureFormat(this.format),\n size: [this.width, this.height],\n colorSpace: this.props.colorSpace,\n compositingAlphaMode: this.props.compositingAlphaMode\n });\n\n log.log(1, `Resized to ${this.width}x${this.height}px`)();\n }\n\n }\n\n resize(options?: {width?: number; height?: number; useDevicePixels?: boolean | number}): void {\n this.update();\n }\n\n /** We build render targets on demand (i.e. not when size changes but when about to render) */\n _createDepthStencilAttachment() {\n if (!this.depthStencilAttachment) {\n this.depthStencilAttachment = this.device.createTexture({\n id: 'depth-stencil-target',\n format: this.depthStencilFormat,\n width: this.width,\n height: this.height,\n usage: GPUTextureUsage.RENDER_ATTACHMENT\n });\n }\n return this.depthStencilAttachment;\n }\n}\n"],"file":"webgpu-canvas-context.js"}
1
+ {"version":3,"file":"webgpu-canvas-context.js","names":["CanvasContext","log","getWebGPUTextureFormat","WebGPUFramebuffer","WebGPUCanvasContext","constructor","device","adapter","props","gpuCanvasContext","format","navigator","gpu","getPreferredCanvasFormat","depthStencilFormat","depthStencilAttachment","width","height","_setAutoCreatedCanvasId","id","canvas","getContext","destroy","unconfigure","getCurrentTexture","_createTexture","handle","getCurrentFramebuffer","update","currentColorAttachment","_createDepthStencilAttachment","colorAttachments","getPixelSize","sizeChanged","configure","colorSpace","alphaMode","resize","options","createTexture","usage","GPUTextureUsage","RENDER_ATTACHMENT"],"sources":["../../src/adapter/webgpu-canvas-context.ts"],"sourcesContent":["// / <reference types=\"@webgpu/types\" />\nimport type {Texture, TextureFormat, CanvasContextProps} from '@luma.gl/core';\nimport {CanvasContext, log} from '@luma.gl/core';\nimport {getWebGPUTextureFormat} from './helpers/convert-texture-format';\nimport {WebGPUDevice} from './webgpu-device';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\nimport {WebGPUTexture} from './resources/webgpu-texture';\n\n/** \n * Holds a WebGPU Canvas Context\n * The primary job of the CanvasContext is to generate textures for rendering into the current canvas\n * It also manages canvas sizing calculations and resizing.\n */\nexport class WebGPUCanvasContext extends CanvasContext {\n readonly device: WebGPUDevice;\n readonly gpuCanvasContext: GPUCanvasContext;\n /** Format of returned textures: \"bgra8unorm\", \"rgba8unorm\", \"rgba16float\". */\n readonly format: TextureFormat = navigator.gpu.getPreferredCanvasFormat();\n /** Default stencil format for depth textures */\n depthStencilFormat: TextureFormat = 'depth24plus';\n\n private depthStencilAttachment: Texture | null = null;\n\n constructor(device: WebGPUDevice, adapter: GPUAdapter, props: CanvasContextProps) {\n super(props);\n this.device = device;\n // TODO - hack to trigger resize?\n this.width = -1;\n this.height = -1;\n\n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n // @ts-ignore TODO - we don't handle OffscreenRenderingContext.\n this.gpuCanvasContext = this.canvas.getContext('webgpu');\n // TODO this has been replaced\n // this.format = this.gpuCanvasContext.getPreferredFormat(adapter);\n this.format = 'bgra8unorm';\n }\n\n /** Destroy any textures produced while configured and remove the context configuration. */\n destroy(): void {\n this.gpuCanvasContext.unconfigure();\n }\n\n getCurrentTexture(): WebGPUTexture {\n // Wrap the current canvas context texture in a luma.gl texture \n return this.device._createTexture({\n id: 'default-render-target',\n handle: this.gpuCanvasContext.getCurrentTexture()\n });\n }\n\n /** Update framebuffer with properly resized \"swap chain\" texture views */\n getCurrentFramebuffer(): WebGPUFramebuffer {\n // Ensure the canvas context size is updated\n this.update();\n\n // Wrap the current canvas context texture in a luma.gl texture\n // const currentColorAttachment = this.device.createTexture({\n // id: 'default-render-target',\n // handle: this.gpuCanvasContext.getCurrentTexture(),\n // format: this.format,\n // width: this.width,\n // height: this.height\n // });\n\n // Wrap the current canvas context texture in a luma.gl texture \n const currentColorAttachment = this.getCurrentTexture();\n this.width = currentColorAttachment.width;\n this.height = currentColorAttachment.height;\n\n // Resize the depth stencil attachment\n this._createDepthStencilAttachment();\n\n return new WebGPUFramebuffer(this.device, {\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: this.depthStencilAttachment\n });\n }\n\n /** Resizes and updates render targets if necessary */\n update() {\n const [width, height] = this.getPixelSize();\n\n const sizeChanged = width !== this.width || height !== this.height;\n\n if (sizeChanged) {\n this.width = width;\n this.height = height;\n\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n\n // Reconfigure the canvas size.\n // https://www.w3.org/TR/webgpu/#canvas-configuration\n this.gpuCanvasContext.configure({\n device: this.device.handle,\n format: getWebGPUTextureFormat(this.format),\n // Can be used to define e.g. -srgb views\n // viewFormats: [...]\n colorSpace: this.props.colorSpace,\n alphaMode: this.props.alphaMode\n });\n\n log.log(1, `Resized to ${this.width}x${this.height}px`)();\n }\n }\n\n resize(options?: {width?: number; height?: number; useDevicePixels?: boolean | number}): void {\n this.update();\n }\n\n /** We build render targets on demand (i.e. not when size changes but when about to render) */\n _createDepthStencilAttachment() {\n if (!this.depthStencilAttachment) {\n this.depthStencilAttachment = this.device.createTexture({\n id: 'depth-stencil-target',\n format: this.depthStencilFormat,\n width: this.width,\n height: this.height,\n usage: GPUTextureUsage.RENDER_ATTACHMENT\n });\n }\n return this.depthStencilAttachment;\n }\n}\n"],"mappings":"AAEA,SAAQA,aAAa,EAAEC,GAAG,QAAO,eAAe;AAAC,SACzCC,sBAAsB;AAAA,SAEtBC,iBAAiB;AAQzB,OAAO,MAAM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T,MAAM,EAAE,IAAI,CAACI,kBAAkB;QAC/BE,KAAK,EAAE,IAAI,CAACA,KAAK;QACjBC,MAAM,EAAE,IAAI,CAACA,MAAM;QACnBuB,KAAK,EAAEC,eAAe,CAACC;MACzB,CAAC,CAAC;IACJ;IACA,OAAO,IAAI,CAAC3B,sBAAsB;EACpC;AACF"}
@@ -1,28 +1,29 @@
1
- /// <reference types="@webgpu/types" />
2
- import type { DeviceProps, DeviceInfo, DeviceLimits, DeviceFeature, CanvasContextProps, BufferProps, SamplerProps, ShaderProps, TextureProps, TextureFormat, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipelineProps, RenderPassProps, ComputePassProps } from '@luma.gl/api';
3
- import { Device } from '@luma.gl/api';
4
- import WebGPUBuffer from './resources/webgpu-buffer';
5
- import WebGPUTexture from './resources/webgpu-texture';
6
- import WebGPUExternalTexture from './resources/webgpu-external-texture';
7
- import WebGPUSampler from './resources/webgpu-sampler';
8
- import WebGPUShader from './resources/webgpu-shader';
9
- import WebGPURenderPipeline from './resources/webgpu-render-pipeline';
10
- import WebGPUFramebuffer from './resources/webgpu-framebuffer';
11
- import WebGPUComputePipeline from './resources/webgpu-compute-pipeline';
12
- import WebGPURenderPass from './resources/webgpu-render-pass';
13
- import WebGPUComputePass from './resources/webgpu-compute-pass';
14
- import WebGPUCanvasContext from './webgpu-canvas-context';
1
+ /// <reference types="dist" />
2
+ import type { DeviceProps, DeviceInfo, DeviceLimits, DeviceFeature, CanvasContextProps, BufferProps, SamplerProps, ShaderProps, Texture, TextureProps, TextureFormat, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipelineProps, RenderPassProps, ComputePassProps, VertexArrayProps, TransformFeedback, TransformFeedbackProps } from '@luma.gl/core';
3
+ import { Device } from '@luma.gl/core';
4
+ import { WebGPUBuffer } from './resources/webgpu-buffer';
5
+ import { WebGPUTexture } from './resources/webgpu-texture';
6
+ import { WebGPUExternalTexture } from './resources/webgpu-external-texture';
7
+ import { WebGPUSampler } from './resources/webgpu-sampler';
8
+ import { WebGPUShader } from './resources/webgpu-shader';
9
+ import { WebGPURenderPipeline } from './resources/webgpu-render-pipeline';
10
+ import { WebGPUFramebuffer } from './resources/webgpu-framebuffer';
11
+ import { WebGPUComputePipeline } from './resources/webgpu-compute-pipeline';
12
+ import { WebGPURenderPass } from './resources/webgpu-render-pass';
13
+ import { WebGPUComputePass } from './resources/webgpu-compute-pass';
14
+ import { WebGPUVertexArray } from './resources/webgpu-vertex-array';
15
+ import { WebGPUCanvasContext } from './webgpu-canvas-context';
15
16
  /** WebGPU Device implementation */
16
- export default class WebGPUDevice extends Device {
17
+ export declare class WebGPUDevice extends Device {
17
18
  readonly handle: GPUDevice;
18
19
  readonly adapter: GPUAdapter;
19
20
  readonly lost: Promise<{
20
21
  reason: 'destroyed';
21
22
  message: string;
22
23
  }>;
23
- canvasContext: WebGPUCanvasContext | undefined;
24
- commandEncoder: GPUCommandEncoder;
25
- renderPass: WebGPURenderPass;
24
+ canvasContext: WebGPUCanvasContext | null;
25
+ commandEncoder: GPUCommandEncoder | null;
26
+ renderPass: WebGPURenderPass | null;
26
27
  private _info;
27
28
  private _isLost;
28
29
  static type: string;
@@ -40,7 +41,7 @@ export default class WebGPUDevice extends Device {
40
41
  /** @todo implement proper check? */
41
42
  isTextureFormatRenderable(format: TextureFormat): boolean;
42
43
  get isLost(): boolean;
43
- _createBuffer(props: BufferProps): WebGPUBuffer;
44
+ createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer;
44
45
  _createTexture(props: TextureProps): WebGPUTexture;
45
46
  createExternalTexture(props: ExternalTextureProps): WebGPUExternalTexture;
46
47
  createShader(props: ShaderProps): WebGPUShader;
@@ -48,20 +49,36 @@ export default class WebGPUDevice extends Device {
48
49
  createRenderPipeline(props: RenderPipelineProps): WebGPURenderPipeline;
49
50
  createFramebuffer(props: FramebufferProps): WebGPUFramebuffer;
50
51
  createComputePipeline(props: ComputePipelineProps): WebGPUComputePipeline;
52
+ createVertexArray(props: VertexArrayProps): WebGPUVertexArray;
51
53
  /**
52
54
  * Allows a render pass to begin against a canvas context
53
55
  * @todo need to support a "Framebuffer" equivalent (aka preconfigured RenderPassDescriptors?).
54
56
  */
55
- beginRenderPass(props?: RenderPassProps): WebGPURenderPass;
56
- beginComputePass(props?: ComputePassProps): WebGPUComputePass;
57
- createCanvasContext(props?: CanvasContextProps): WebGPUCanvasContext;
57
+ beginRenderPass(props: RenderPassProps): WebGPURenderPass;
58
+ beginComputePass(props: ComputePassProps): WebGPUComputePass;
59
+ createTransformFeedback(props: TransformFeedbackProps): TransformFeedback;
60
+ createCanvasContext(props: CanvasContextProps): WebGPUCanvasContext;
58
61
  /**
59
62
  * Gets default renderpass encoder.
60
63
  * Creates a new encoder against default canvasContext if not already created
61
64
  * @note Called internally by Model.
65
+ * @deprecated Create explicit pass with device.beginRenderPass
62
66
  */
63
67
  getDefaultRenderPass(): WebGPURenderPass;
64
68
  submit(): void;
65
69
  _getFeatures(): Set<DeviceFeature>;
70
+ copyExternalImageToTexture(options: {
71
+ texture: Texture;
72
+ mipLevel?: number;
73
+ aspect?: 'all' | 'stencil-only' | 'depth-only';
74
+ colorSpace?: 'display-p3' | 'srgb';
75
+ premultipliedAlpha?: boolean;
76
+ source: ImageBitmap | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas;
77
+ sourceX?: number;
78
+ sourceY?: number;
79
+ width?: number;
80
+ height?: number;
81
+ depth?: number;
82
+ }): void;
66
83
  }
67
84
  //# sourceMappingURL=webgpu-device.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-device.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB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