@luma.gl/webgpu 9.0.0-beta.5 → 9.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/adapter/helpers/accessor-to-format.js +4 -1
  2. package/dist/adapter/helpers/convert-texture-format.d.ts.map +1 -1
  3. package/dist/adapter/helpers/convert-texture-format.js +3 -0
  4. package/dist/adapter/helpers/get-bind-group.d.ts +3 -3
  5. package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
  6. package/dist/adapter/helpers/get-bind-group.js +3 -0
  7. package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -1
  8. package/dist/adapter/helpers/get-vertex-buffer-layout.js +9 -2
  9. package/dist/adapter/helpers/webgpu-parameters.d.ts.map +1 -1
  10. package/dist/adapter/helpers/webgpu-parameters.js +3 -0
  11. package/dist/adapter/resources/webgpu-buffer.d.ts +1 -1
  12. package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
  13. package/dist/adapter/resources/webgpu-buffer.js +19 -10
  14. package/dist/adapter/resources/webgpu-command-encoder.d.ts +7 -1
  15. package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
  16. package/dist/adapter/resources/webgpu-command-encoder.js +8 -0
  17. package/dist/adapter/resources/webgpu-compute-pass.d.ts +15 -9
  18. package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
  19. package/dist/adapter/resources/webgpu-compute-pass.js +39 -17
  20. package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +14 -4
  21. package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
  22. package/dist/adapter/resources/webgpu-compute-pipeline.js +37 -15
  23. package/dist/adapter/resources/webgpu-external-texture.d.ts +2 -2
  24. package/dist/adapter/resources/webgpu-external-texture.d.ts.map +1 -1
  25. package/dist/adapter/resources/webgpu-external-texture.js +14 -7
  26. package/dist/adapter/resources/webgpu-framebuffer.d.ts +1 -1
  27. package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
  28. package/dist/adapter/resources/webgpu-framebuffer.js +3 -0
  29. package/dist/adapter/resources/webgpu-query-set.d.ts +17 -0
  30. package/dist/adapter/resources/webgpu-query-set.d.ts.map +1 -0
  31. package/dist/adapter/resources/webgpu-query-set.js +27 -0
  32. package/dist/adapter/resources/webgpu-render-pass.d.ts +4 -2
  33. package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
  34. package/dist/adapter/resources/webgpu-render-pass.js +27 -9
  35. package/dist/adapter/resources/webgpu-render-pipeline.d.ts +52 -5
  36. package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
  37. package/dist/adapter/resources/webgpu-render-pipeline.js +76 -66
  38. package/dist/adapter/resources/webgpu-sampler.d.ts +1 -1
  39. package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
  40. package/dist/adapter/resources/webgpu-sampler.js +3 -0
  41. package/dist/adapter/resources/webgpu-shader.d.ts +2 -5
  42. package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
  43. package/dist/adapter/resources/webgpu-shader.js +10 -20
  44. package/dist/adapter/resources/webgpu-texture-view.d.ts +20 -0
  45. package/dist/adapter/resources/webgpu-texture-view.d.ts.map +1 -0
  46. package/dist/adapter/resources/webgpu-texture-view.js +35 -0
  47. package/dist/adapter/resources/webgpu-texture.d.ts +8 -8
  48. package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
  49. package/dist/adapter/resources/webgpu-texture.js +25 -22
  50. package/dist/adapter/resources/webgpu-vertex-array.d.ts +7 -9
  51. package/dist/adapter/resources/webgpu-vertex-array.d.ts.map +1 -1
  52. package/dist/adapter/resources/webgpu-vertex-array.js +11 -13
  53. package/dist/adapter/webgpu-canvas-context.d.ts +3 -3
  54. package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
  55. package/dist/adapter/webgpu-canvas-context.js +8 -5
  56. package/dist/adapter/webgpu-device.d.ts +26 -28
  57. package/dist/adapter/webgpu-device.d.ts.map +1 -1
  58. package/dist/adapter/webgpu-device.js +81 -74
  59. package/dist/dist.dev.js +339 -305
  60. package/dist/index.cjs +313 -250
  61. package/dist/index.cjs.map +4 -4
  62. package/dist/index.d.ts +5 -5
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +7 -6
  65. package/dist.min.js +1 -1
  66. package/package.json +2 -2
  67. package/src/adapter/helpers/accessor-to-format.ts +5 -1
  68. package/src/adapter/helpers/convert-texture-format.ts +4 -1
  69. package/src/adapter/helpers/get-bind-group.ts +12 -6
  70. package/src/adapter/helpers/get-vertex-buffer-layout.ts +12 -4
  71. package/src/adapter/helpers/webgpu-parameters.ts +79 -15
  72. package/src/adapter/resources/webgpu-buffer.ts +24 -11
  73. package/src/adapter/resources/webgpu-command-encoder.ts +24 -9
  74. package/src/adapter/resources/webgpu-compute-pass.ts +45 -22
  75. package/src/adapter/resources/webgpu-compute-pipeline.ts +48 -16
  76. package/src/adapter/resources/webgpu-external-texture.ts +14 -6
  77. package/src/adapter/resources/webgpu-framebuffer.ts +4 -0
  78. package/src/adapter/resources/webgpu-query-set.ts +37 -0
  79. package/src/adapter/resources/webgpu-render-pass.ts +37 -14
  80. package/src/adapter/resources/webgpu-render-pipeline.ts +75 -115
  81. package/src/adapter/resources/webgpu-sampler.ts +4 -1
  82. package/src/adapter/resources/webgpu-shader.ts +11 -25
  83. package/src/adapter/resources/webgpu-texture-view.ts +46 -0
  84. package/src/adapter/resources/webgpu-texture.ts +33 -28
  85. package/src/adapter/resources/webgpu-vertex-array.ts +25 -20
  86. package/src/adapter/webgpu-canvas-context.ts +10 -5
  87. package/src/adapter/webgpu-device.ts +99 -76
  88. package/src/index.ts +2 -1
  89. package/dist/adapter/helpers/generate-mipmaps.d.ts +0 -10
  90. package/dist/adapter/helpers/generate-mipmaps.d.ts.map +0 -1
  91. package/dist/adapter/helpers/generate-mipmaps.js +0 -94
  92. package/dist/adapter/resources/webgpu-query.d.ts +0 -1
  93. package/dist/adapter/resources/webgpu-query.d.ts.map +0 -1
  94. package/dist/adapter/resources/webgpu-query.js +0 -43
  95. package/dist/adapter/webgpu-types.d.ts +0 -1
  96. package/dist/adapter/webgpu-types.d.ts.map +0 -1
  97. package/dist/adapter/webgpu-types.js +0 -0
  98. package/dist/glsl/glsllang.d.ts +0 -3
  99. package/dist/glsl/glsllang.d.ts.map +0 -1
  100. package/dist/glsl/glsllang.js +0 -12
  101. package/src/adapter/helpers/generate-mipmaps.ts +0 -107
  102. package/src/adapter/resources/webgpu-query.ts +0 -43
  103. package/src/adapter/webgpu-types.ts +0 -0
  104. package/src/glsl/glsllang.ts +0 -14
@@ -1,3 +1,6 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  /*
2
5
  import {assert} from '@luma.gl/core';
3
6
 
@@ -97,4 +100,4 @@ export function mapAccessorToWebGPUFormat(accessor) {
97
100
  }
98
101
  throw new Error('illegal accessor');
99
102
  }
100
- */
103
+ */
@@ -1 +1 @@
1
- {"version":3,"file":"convert-texture-format.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/convert-texture-format.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAE5C,mDAAmD;AACnD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,GAAG,gBAAgB,CAK9E"}
1
+ {"version":3,"file":"convert-texture-format.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/convert-texture-format.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAE5C,mDAAmD;AACnD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,GAAG,gBAAgB,CAK9E"}
@@ -1,3 +1,6 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  /** Ensure a texture format is WebGPU compatible */
2
5
  export function getWebGPUTextureFormat(format) {
3
6
  if (format.includes('webgl')) {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="dist" />
2
- import type { ShaderLayout, BindingDeclaration, Binding } from '@luma.gl/core';
2
+ import type { ComputeShaderLayout, BindingDeclaration, Binding } from '@luma.gl/core';
3
3
  /**
4
4
  * Create a WebGPU "bind group layout" from an array of luma.gl bindings
5
5
  * @note bind groups can be automatically generated by WebGPU.
@@ -8,6 +8,6 @@ export declare function makeBindGroupLayout(device: GPUDevice, layout: GPUBindGr
8
8
  /**
9
9
  * Create a WebGPU "bind group" from an array of luma.gl bindings
10
10
  */
11
- export declare function getBindGroup(device: GPUDevice, bindGroupLayout: GPUBindGroupLayout, shaderLayout: ShaderLayout, bindings: Record<string, Binding>): GPUBindGroup;
12
- export declare function getShaderLayoutBinding(shaderLayout: ShaderLayout, bindingName: string): BindingDeclaration;
11
+ export declare function getBindGroup(device: GPUDevice, bindGroupLayout: GPUBindGroupLayout, shaderLayout: ComputeShaderLayout, bindings: Record<string, Binding>): GPUBindGroup;
12
+ export declare function getShaderLayoutBinding(shaderLayout: ComputeShaderLayout, bindingName: string): BindingDeclaration;
13
13
  //# sourceMappingURL=get-bind-group.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-bind-group.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-bind-group.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAC,YAAY,EAAE,kBAAkB,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAM7E;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,OAAO,EAAE,GAClB,kBAAkB,CAMpB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,eAAe,EAAE,kBAAkB,EACnC,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,YAAY,CAMd;AAED,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,MAAM,GAClB,kBAAkB,CAMpB"}
1
+ {"version":3,"file":"get-bind-group.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-bind-group.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAC,mBAAmB,EAAE,kBAAkB,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAMpF;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,OAAO,EAAE,GAClB,kBAAkB,CAMpB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,eAAe,EAAE,kBAAkB,EACnC,YAAY,EAAE,mBAAmB,EACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,YAAY,CAMd;AAED,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,mBAAmB,EACjC,WAAW,EAAE,MAAM,GAClB,kBAAkB,CASpB"}
@@ -1,3 +1,6 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { Buffer, Sampler, Texture, log, cast } from '@luma.gl/core';
2
5
  /**
3
6
  * Create a WebGPU "bind group layout" from an array of luma.gl bindings
@@ -1 +1 @@
1
- {"version":3,"file":"get-vertex-buffer-layout.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAqC,MAAM,eAAe,CAAC;AAYlG;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAAE,GAC3B,qBAAqB,EAAE,CAuEzB;AAED,wBAAgB,cAAc,CAC5B,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAAE,GAC3B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BxB"}
1
+ {"version":3,"file":"get-vertex-buffer-layout.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAqC,MAAM,eAAe,CAAC;AAYlG;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAAE,GAC3B,qBAAqB,EAAE,CA4EzB;AAED,wBAAgB,cAAc,CAC5B,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAAE,GAC3B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BxB"}
@@ -1,3 +1,6 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { log, decodeVertexFormat } from '@luma.gl/core';
2
5
  // import {getAttributeInfosFromLayouts} from '@luma.gl/core';
3
6
  /** Throw error on any WebGL-only vertex formats */
@@ -30,7 +33,9 @@ export function getVertexBufferLayout(shaderLayout, bufferLayout) {
30
33
  for (const attributeMapping of mapping.attributes) {
31
34
  const attributeName = attributeMapping.attribute;
32
35
  const attributeLayout = findAttributeLayout(shaderLayout, attributeName, usedAttributes);
33
- stepMode = attributeLayout.stepMode || (attributeLayout.name.startsWith('instance') ? 'instance' : 'vertex');
36
+ stepMode =
37
+ attributeLayout.stepMode ||
38
+ (attributeLayout.name.startsWith('instance') ? 'instance' : 'vertex');
34
39
  vertexAttributes.push({
35
40
  format: getWebGPUVertexFormat(attributeMapping.format || mapping.format),
36
41
  offset: attributeMapping.byteOffset,
@@ -46,7 +51,9 @@ export function getVertexBufferLayout(shaderLayout, bufferLayout) {
46
51
  continue; // eslint-disable-line no-continue
47
52
  }
48
53
  byteStride = decodeVertexFormat(mapping.format).byteLength;
49
- stepMode = attributeLayout.stepMode || (attributeLayout.name.startsWith('instance') ? 'instance' : 'vertex');
54
+ stepMode =
55
+ attributeLayout.stepMode ||
56
+ (attributeLayout.name.startsWith('instance') ? 'instance' : 'vertex');
50
57
  vertexAttributes.push({
51
58
  format: getWebGPUVertexFormat(mapping.format),
52
59
  // We only support 0 offset for non-interleaved buffer layouts
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/webgpu-parameters.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAezC;;;GAGG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,UAAU,EAAE,QAAQ,CAsJ9D,CAAC;AAgCF,wBAAgB,yCAAyC,CACvD,kBAAkB,EAAE,2BAA2B,EAC/C,UAAU,GAAE,UAAe,GAC1B,IAAI,CAIN"}
1
+ {"version":3,"file":"webgpu-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/webgpu-parameters.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAezC;;;GAGG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,UAAU,EAAE,QAAQ,CAkN9D,CAAC;AAgCF,wBAAgB,yCAAyC,CACvD,kBAAkB,EAAE,2BAA2B,EAC/C,UAAU,GAAE,UAAe,GAC1B,IAAI,CAIN"}
@@ -1,3 +1,6 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  function addDepthStencil(descriptor) {
2
5
  descriptor.depthStencil = descriptor.depthStencil || {
3
6
  // required, set something
@@ -1,6 +1,6 @@
1
1
  /// <reference types="dist" />
2
2
  import { Buffer, BufferProps } from '@luma.gl/core';
3
- import type { WebGPUDevice } from '../webgpu-device';
3
+ import type { WebGPUDevice } from "../webgpu-device.js";
4
4
  export declare class WebGPUBuffer extends Buffer {
5
5
  readonly device: WebGPUDevice;
6
6
  readonly handle: GPUBuffer;
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAMnD,qBAAa,YAAa,SAAQ,MAAM;IACtC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW;IA4B3C,OAAO,IAAI,IAAI;IAKf,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,SAAI;IAUrC,SAAS,CAAC,UAAU,GAAE,MAAU,EAAE,UAAU,GAAE,MAAwB,GAAG,OAAO,CAAC,UAAU,CAAC;IAmB3G,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAQtD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxE,cAAc,CAAC,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW;IAI9D,KAAK,IAAI,IAAI;CAGd;AA4CD;;;;;;;;EAQE"}
1
+ {"version":3,"file":"webgpu-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AAMnD,qBAAa,YAAa,SAAQ,MAAM;IACtC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW;IA8B3C,OAAO,IAAI,IAAI;IAOf,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,SAAI;IAUrC,SAAS,CACtB,UAAU,GAAE,MAAU,EACtB,UAAU,GAAE,MAAwB,GACnC,OAAO,CAAC,UAAU,CAAC;IAsBtB,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAQtD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxE,cAAc,CAAC,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW;IAI9D,KAAK,IAAI,IAAI;CAGd;AA4CD;;;;;;;;EAQE"}
@@ -1,4 +1,6 @@
1
- // WEBGPU Buffer implementation
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
2
4
  import { Buffer } from '@luma.gl/core';
3
5
  function getByteLength(props) {
4
6
  return props.byteLength || props.data?.byteLength || 0;
@@ -14,13 +16,15 @@ export class WebGPUBuffer extends Buffer {
14
16
  const mapBuffer = Boolean(props.data);
15
17
  // WebGPU buffers must be aligned to 4 bytes
16
18
  const size = Math.ceil(this.byteLength / 4) * 4;
17
- this.handle = this.props.handle || this.device.handle.createBuffer({
18
- size,
19
- // usage defaults to vertex
20
- usage: this.props.usage || (GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST),
21
- mappedAtCreation: this.props.mappedAtCreation || mapBuffer,
22
- label: this.props.id
23
- });
19
+ this.handle =
20
+ this.props.handle ||
21
+ this.device.handle.createBuffer({
22
+ size,
23
+ // usage defaults to vertex
24
+ usage: this.props.usage || GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
25
+ mappedAtCreation: this.props.mappedAtCreation || mapBuffer,
26
+ label: this.props.id
27
+ });
24
28
  if (props.data) {
25
29
  this._writeMapped(props.data);
26
30
  // this.handle.writeAsync({data: props.data, map: false, unmap: false});
@@ -30,7 +34,9 @@ export class WebGPUBuffer extends Buffer {
30
34
  }
31
35
  }
32
36
  destroy() {
33
- this.handle.destroy();
37
+ this.handle?.destroy();
38
+ // @ts-expect-error readonly
39
+ this.handle = null;
34
40
  }
35
41
  // WebGPU provides multiple ways to write a buffer...
36
42
  write(data, byteOffset = 0) {
@@ -38,7 +44,10 @@ export class WebGPUBuffer extends Buffer {
38
44
  }
39
45
  async readAsync(byteOffset = 0, byteLength = this.byteLength) {
40
46
  // We need MAP_READ flag, but only COPY_DST buffers can have MAP_READ flag, so we need to create a temp buffer
41
- const tempBuffer = new WebGPUBuffer(this.device, { usage: Buffer.MAP_READ | Buffer.COPY_DST, byteLength });
47
+ const tempBuffer = new WebGPUBuffer(this.device, {
48
+ usage: Buffer.MAP_READ | Buffer.COPY_DST,
49
+ byteLength
50
+ });
42
51
  // Now do a GPU-side copy into the temp buffer we can actually read.
43
52
  // TODO - we are spinning up an independent command queue here, what does this mean
44
53
  const commandEncoder = this.device.handle.createCommandEncoder();
@@ -1,7 +1,8 @@
1
1
  /// <reference types="dist" />
2
2
  import { CommandEncoder, CommandEncoderProps, Buffer, Texture } from '@luma.gl/core';
3
3
  import type { CopyTextureToTextureOptions, CopyTextureToBufferOptions } from '@luma.gl/core';
4
- import { WebGPUDevice } from '../webgpu-device';
4
+ import { WebGPUDevice } from "../webgpu-device.js";
5
+ import { WebGPUQuerySet } from "./webgpu-query-set.js";
5
6
  export declare class WebGPUCommandEncoder extends CommandEncoder {
6
7
  readonly device: WebGPUDevice;
7
8
  readonly handle: GPUCommandEncoder;
@@ -33,5 +34,10 @@ export declare class WebGPUCommandEncoder extends CommandEncoder {
33
34
  pushDebugGroup(groupLabel: string): void;
34
35
  popDebugGroup(): void;
35
36
  insertDebugMarker(markerLabel: string): void;
37
+ resolveQuerySet(querySet: WebGPUQuerySet, destination: Buffer, options?: {
38
+ firstQuery?: number;
39
+ queryCount?: number;
40
+ destinationOffset?: number;
41
+ }): void;
36
42
  }
37
43
  //# sourceMappingURL=webgpu-command-encoder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AACnF,OAAO,KAAK,EAAC,2BAA2B,EAAE,0BAA0B,EAAC,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAI9C,qBAAa,oBAAqB,SAAQ,cAAc;IACtD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;gBAEvB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,mBAAmB;IAYnD,OAAO,IAAI,IAAI;IAExB,MAAM,CAAC,OAAO,CAAC,EAAE;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,gBAAgB;IAOjD,kBAAkB,CAAC,OAAO,EAC1B;QACE,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,IAAI;IAYR,mBAAmB,CAAC,OAAO,EAC3B;QACE,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE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
1
4
  import { CommandEncoder } from '@luma.gl/core';
2
5
  export class WebGPUCommandEncoder extends CommandEncoder {
3
6
  device;
@@ -73,4 +76,9 @@ export class WebGPUCommandEncoder extends CommandEncoder {
73
76
  insertDebugMarker(markerLabel) {
74
77
  this.handle.insertDebugMarker(markerLabel);
75
78
  }
79
+ resolveQuerySet(querySet, destination, options) {
80
+ const webgpuQuerySet = querySet;
81
+ const webgpuBuffer = destination;
82
+ this.handle.resolveQuerySet(webgpuQuerySet.handle, options.firstQuery || 0, options.queryCount || querySet.props.count - (options.firstQuery || 0), webgpuBuffer.handle, options.destinationOffset || 0);
83
+ }
76
84
  }
@@ -1,30 +1,36 @@
1
1
  /// <reference types="dist" />
2
2
  import { ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding } from '@luma.gl/core';
3
- import { WebGPUDevice } from '../webgpu-device';
3
+ import { WebGPUDevice } from "../webgpu-device.js";
4
+ import { WebGPUComputePipeline } from "./webgpu-compute-pipeline.js";
4
5
  export declare class WebGPUComputePass extends ComputePass {
5
6
  readonly device: WebGPUDevice;
6
7
  readonly handle: GPUComputePassEncoder;
7
- _bindGroupLayout: GPUBindGroupLayout | null;
8
+ _webgpuPipeline: WebGPUComputePipeline | null;
8
9
  constructor(device: WebGPUDevice, props: ComputePassProps);
9
10
  /** @note no WebGPU destroy method, just gc */
10
11
  destroy(): void;
11
12
  end(): void;
12
13
  setPipeline(pipeline: ComputePipeline): void;
13
- /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */
14
+ /**
15
+ * Sets an array of bindings (uniform buffers, samplers, textures, ...)
16
+ * TODO - still some API confusion - does this method go here or on the pipeline?
17
+ */
14
18
  setBindings(bindings: Binding[]): void;
15
19
  /**
16
20
  * Dispatch work to be performed with the current ComputePipeline.
17
- * @param x X dimension of the grid of workgroups to dispatch.
18
- * @param y Y dimension of the grid of workgroups to dispatch.
19
- * @param z Z dimension of the grid of workgroups to dispatch.
21
+ * @param x X dimension of the grid of work groups to dispatch.
22
+ * @param y Y dimension of the grid of work groups to dispatch.
23
+ * @param z Z dimension of the grid of work groups to dispatch.
20
24
  */
21
25
  dispatch(x: number, y?: number, z?: number): void;
22
26
  /**
23
27
  * Dispatch work to be performed with the current ComputePipeline.
24
- * @param indirectBuffer buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()
25
- * @param indirectOffset
28
+ *
29
+ * Buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()
30
+ * @param indirectBuffer
31
+ * @param indirectOffset offset in buffer to the beginning of the dispatch data.
26
32
  */
27
- dispatchIndirect(indirectBuffer: Buffer, indirectOffset?: number): void;
33
+ dispatchIndirect(indirectBuffer: Buffer, indirectByteOffset?: number): void;
28
34
  pushDebugGroup(groupLabel: string): void;
29
35
  popDebugGroup(): void;
30
36
  insertDebugMarker(markerLabel: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-compute-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAK9C,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,gBAAgB,EAAE,kBAAkB,GAAG,IAAI,CAAQ;gBAEvC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAUzD,8CAA8C;IACrC,OAAO,IAAI,IAAI;IAExB,GAAG,IAAI,IAAI;IAIX,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAM5C,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAM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B,GAAE,MAAU,GAAG,IAAI;IAK9E,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIxC,aAAa,IAAI,IAAI;IAIrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAG7C"}
@@ -1,15 +1,32 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { ComputePass } from '@luma.gl/core';
2
5
  export class WebGPUComputePass extends ComputePass {
3
6
  device;
4
7
  handle;
5
- _bindGroupLayout = null;
8
+ _webgpuPipeline = null;
6
9
  constructor(device, props) {
7
10
  super(device, props);
8
11
  this.device = device;
9
- this.handle = this.props.handle || device.commandEncoder?.beginComputePass({
10
- label: this.props.id,
11
- // timestampWrites?: GPUComputePassTimestampWrites;
12
- });
12
+ // Set up queries
13
+ let timestampWrites;
14
+ if (device.features.has('timestamp-query')) {
15
+ const webgpuQuerySet = props.timestampQuerySet;
16
+ if (webgpuQuerySet) {
17
+ timestampWrites = {
18
+ querySet: webgpuQuerySet.handle,
19
+ beginningOfPassWriteIndex: props.beginTimestampIndex,
20
+ endOfPassWriteIndex: props.endTimestampIndex
21
+ };
22
+ }
23
+ }
24
+ this.handle =
25
+ this.props.handle ||
26
+ device.commandEncoder?.beginComputePass({
27
+ label: this.props.id,
28
+ timestampWrites
29
+ });
13
30
  }
14
31
  /** @note no WebGPU destroy method, just gc */
15
32
  destroy() { }
@@ -19,31 +36,36 @@ export class WebGPUComputePass extends ComputePass {
19
36
  setPipeline(pipeline) {
20
37
  const wgpuPipeline = pipeline;
21
38
  this.handle.setPipeline(wgpuPipeline.handle);
22
- this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();
39
+ this._webgpuPipeline = wgpuPipeline;
40
+ this.setBindings([]);
23
41
  }
24
- /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */
42
+ /**
43
+ * Sets an array of bindings (uniform buffers, samplers, textures, ...)
44
+ * TODO - still some API confusion - does this method go here or on the pipeline?
45
+ */
25
46
  setBindings(bindings) {
26
- throw new Error('fix me');
27
- // const bindGroup = getBindGroup(this.device.handle, this._bindGroupLayout, this.props.bindings);
28
- // this.handle.setBindGroup(0, bindGroup);
47
+ const bindGroup = this._webgpuPipeline._getBindGroup();
48
+ this.handle.setBindGroup(0, bindGroup);
29
49
  }
30
50
  /**
31
51
  * Dispatch work to be performed with the current ComputePipeline.
32
- * @param x X dimension of the grid of workgroups to dispatch.
33
- * @param y Y dimension of the grid of workgroups to dispatch.
34
- * @param z Z dimension of the grid of workgroups to dispatch.
52
+ * @param x X dimension of the grid of work groups to dispatch.
53
+ * @param y Y dimension of the grid of work groups to dispatch.
54
+ * @param z Z dimension of the grid of work groups to dispatch.
35
55
  */
36
56
  dispatch(x, y, z) {
37
57
  this.handle.dispatchWorkgroups(x, y, z);
38
58
  }
39
59
  /**
40
60
  * Dispatch work to be performed with the current ComputePipeline.
41
- * @param indirectBuffer buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()
42
- * @param indirectOffset
61
+ *
62
+ * Buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()
63
+ * @param indirectBuffer
64
+ * @param indirectOffset offset in buffer to the beginning of the dispatch data.
43
65
  */
44
- dispatchIndirect(indirectBuffer, indirectOffset = 0) {
66
+ dispatchIndirect(indirectBuffer, indirectByteOffset = 0) {
45
67
  const webgpuBuffer = indirectBuffer;
46
- this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectOffset);
68
+ this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectByteOffset);
47
69
  }
48
70
  pushDebugGroup(groupLabel) {
49
71
  this.handle.pushDebugGroup(groupLabel);
@@ -1,12 +1,22 @@
1
1
  /// <reference types="dist" />
2
- import { ComputePipeline, ComputePipelineProps } from '@luma.gl/core';
3
- import { WebGPUDevice } from '../webgpu-device';
2
+ import { ComputePipeline, ComputePipelineProps, Binding } from '@luma.gl/core';
3
+ import { WebGPUDevice } from "../webgpu-device.js";
4
4
  /** Creates a new compute pipeline when parameters change */
5
5
  export declare class WebGPUComputePipeline extends ComputePipeline {
6
6
  device: WebGPUDevice;
7
7
  handle: GPUComputePipeline;
8
+ /** For internal use to create BindGroups */
9
+ private _bindGroupLayout;
10
+ private _bindGroup;
11
+ /** For internal use to create BindGroups */
12
+ private _bindings;
8
13
  constructor(device: WebGPUDevice, props: ComputePipelineProps);
9
- /** For internal use in render passes */
10
- _getBindGroupLayout(): GPUBindGroupLayout;
14
+ /**
15
+ * @todo Use renderpass.setBindings() ?
16
+ * @todo Do we want to expose BindGroups in the API and remove this?
17
+ */
18
+ setBindings(bindings: Record<string, Binding>): void;
19
+ /** Return a bind group created by setBindings */
20
+ _getBindGroup(): GPUBindGroup;
11
21
  }
12
22
  //# sourceMappingURL=webgpu-compute-pipeline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-compute-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pipeline.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAK9C,4DAA4D;AAC5D,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,kBAAkB,CAAC;gBAEf,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB;IAgB7D,wCAAwC;IACxC,mBAAmB;CAIpB"}
1
+ {"version":3,"file":"webgpu-compute-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pipeline.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE7E,OAAO,EAAC,YAAY,EAAC,4BAAyB;AAK9C,4DAA4D;AAC5D,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,kBAAkB,CAAC;IAE3B,4CAA4C;IAC5C,OAAO,CAAC,gBAAgB,CAAmC;IAC3D,OAAO,CAAC,UAAU,CAA6B;IAC/C,4CAA4C;IAC5C,OAAO,CAAC,SAAS,CAA+B;gBAEpC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB;IAmB7D;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIpD,iDAAiD;IACjD,aAAa;CAgBd"}
@@ -1,27 +1,49 @@
1
- // prettier-ignore
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
2
4
  import { ComputePipeline } from '@luma.gl/core';
5
+ import { getBindGroup } from "../helpers/get-bind-group.js";
3
6
  // COMPUTE PIPELINE
4
7
  /** Creates a new compute pipeline when parameters change */
5
8
  export class WebGPUComputePipeline extends ComputePipeline {
6
9
  device;
7
10
  handle;
11
+ /** For internal use to create BindGroups */
12
+ _bindGroupLayout = null;
13
+ _bindGroup = null;
14
+ /** For internal use to create BindGroups */
15
+ _bindings = {};
8
16
  constructor(device, props) {
9
17
  super(device, props);
10
18
  this.device = device;
11
- const webgpuShader = this.props.cs;
12
- this.handle = this.props.handle || this.device.handle.createComputePipeline({
13
- label: this.props.id,
14
- compute: {
15
- module: webgpuShader.handle,
16
- entryPoint: this.props.csEntryPoint,
17
- // constants: this.props.csConstants
18
- },
19
- layout: 'auto'
20
- });
19
+ const webgpuShader = this.props.shader;
20
+ this.handle =
21
+ this.props.handle ||
22
+ this.device.handle.createComputePipeline({
23
+ label: this.props.id,
24
+ compute: {
25
+ module: webgpuShader.handle,
26
+ entryPoint: this.props.entryPoint,
27
+ constants: this.props.constants
28
+ },
29
+ layout: 'auto'
30
+ });
21
31
  }
22
- /** For internal use in render passes */
23
- _getBindGroupLayout() {
24
- // TODO: Cache?
25
- return this.handle.getBindGroupLayout(0);
32
+ /**
33
+ * @todo Use renderpass.setBindings() ?
34
+ * @todo Do we want to expose BindGroups in the API and remove this?
35
+ */
36
+ setBindings(bindings) {
37
+ Object.assign(this._bindings, bindings);
38
+ }
39
+ /** Return a bind group created by setBindings */
40
+ _getBindGroup() {
41
+ // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group
42
+ this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);
43
+ // Set up the bindings
44
+ this._bindGroup =
45
+ this._bindGroup ||
46
+ getBindGroup(this.device.handle, this._bindGroupLayout, this.props.shaderLayout, this._bindings);
47
+ return this._bindGroup;
26
48
  }
27
49
  }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="dist" />
2
2
  import { ExternalTexture, ExternalTextureProps, Sampler, SamplerProps } from '@luma.gl/core';
3
- import type { WebGPUDevice } from '../webgpu-device';
4
- import { WebGPUSampler } from './webgpu-sampler';
3
+ import type { WebGPUDevice } from "../webgpu-device.js";
4
+ import { WebGPUSampler } from "./webgpu-sampler.js";
5
5
  /**
6
6
  * Cheap, temporary texture view for videos
7
7
  * Only valid within same callback, destroyed automatically as a microtask.
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-external-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-external-texture.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3F,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,OAAO,EAAE,aAAa,CAAC;gBAEX,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB;IAUpD,OAAO,IAAI,IAAI;IAMxB,0BAA0B;IAC1B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI;CAKlD"}
1
+ {"version":3,"file":"webgpu-external-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-external-texture.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3F,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AACnD,OAAO,EAAC,aAAa,EAAC,4BAAyB;AAE/C;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,OAAO,EAAE,aAAa,CAAC;gBAEX,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB;IAYpD,OAAO,IAAI,IAAI;IAQxB,0BAA0B;IAC1B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI;CAMlD"}
@@ -1,6 +1,8 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
2
4
  import { ExternalTexture } from '@luma.gl/core';
3
- import { WebGPUSampler } from './webgpu-sampler';
5
+ import { WebGPUSampler } from "./webgpu-sampler.js";
4
6
  /**
5
7
  * Cheap, temporary texture view for videos
6
8
  * Only valid within same callback, destroyed automatically as a microtask.
@@ -12,21 +14,26 @@ export class WebGPUExternalTexture extends ExternalTexture {
12
14
  constructor(device, props) {
13
15
  super(device, props);
14
16
  this.device = device;
15
- this.handle = this.props.handle || this.device.handle.importExternalTexture({
16
- source: props.source,
17
- colorSpace: props.colorSpace
18
- });
17
+ this.handle =
18
+ this.props.handle ||
19
+ this.device.handle.importExternalTexture({
20
+ source: props.source,
21
+ colorSpace: props.colorSpace
22
+ });
19
23
  this.sampler = null;
20
24
  }
21
25
  destroy() {
22
26
  // External textures are destroyed automatically,
23
27
  // as a microtask, instead of manually or upon garbage collection like other resources.
24
28
  // this.handle.destroy();
29
+ // @ts-expect-error readonly
30
+ this.handle = null;
25
31
  }
26
32
  /** Set default sampler */
27
33
  setSampler(sampler) {
28
34
  // We can accept a sampler instance or set of props;
29
- this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);
35
+ this.sampler =
36
+ sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);
30
37
  return this;
31
38
  }
32
39
  }
@@ -1,6 +1,6 @@
1
1
  import type { FramebufferProps } from '@luma.gl/core';
2
2
  import { Framebuffer } from '@luma.gl/core';
3
- import { WebGPUDevice } from '../webgpu-device';
3
+ import { WebGPUDevice } from "../webgpu-device.js";
4
4
  /**
5
5
  * Create new textures with correct size for all attachments.
6
6
  * @note resize() destroys existing textures (if size has changed).
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;gBAElB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;CAO1D"}
1
+ {"version":3,"file":"webgpu-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,YAAY,EAAC,4BAAyB;AAE9C;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;gBAElB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;CAO1D"}
@@ -1,3 +1,6 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { Framebuffer } from '@luma.gl/core';
2
5
  /**
3
6
  * Create new textures with correct size for all attachments.
@@ -0,0 +1,17 @@
1
+ /// <reference types="dist" />
2
+ import { QuerySet, QuerySetProps } from '@luma.gl/core';
3
+ import { WebGPUDevice } from "../webgpu-device.js";
4
+ export type QuerySetProps2 = {
5
+ type: 'occlusion' | 'timestamp';
6
+ count: number;
7
+ };
8
+ /**
9
+ * Immutable
10
+ */
11
+ export declare class WebGPUQuerySet extends QuerySet {
12
+ readonly device: WebGPUDevice;
13
+ readonly handle: GPUQuerySet;
14
+ constructor(device: WebGPUDevice, props: QuerySetProps);
15
+ destroy(): void;
16
+ }
17
+ //# sourceMappingURL=webgpu-query-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webgpu-query-set.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-query-set.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,4BAAyB;AAE9C,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,WAAW,GAAG,WAAW,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;gBAEjB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa;IAY7C,OAAO,IAAI,IAAI;CAKzB"}
@@ -0,0 +1,27 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import { QuerySet } from '@luma.gl/core';
5
+ /**
6
+ * Immutable
7
+ */
8
+ export class WebGPUQuerySet extends QuerySet {
9
+ device;
10
+ handle;
11
+ constructor(device, props) {
12
+ super(device, props);
13
+ this.device = device;
14
+ this.handle =
15
+ this.props.handle ||
16
+ this.device.handle.createQuerySet({
17
+ type: this.props.type,
18
+ count: this.props.count
19
+ });
20
+ this.handle.label = this.props.id;
21
+ }
22
+ destroy() {
23
+ this.handle?.destroy();
24
+ // @ts-expect-error readonly
25
+ this.handle = null;
26
+ }
27
+ }
@@ -1,8 +1,8 @@
1
1
  /// <reference types="dist" />
2
2
  import type { RenderPassProps, RenderPassParameters, Binding, Framebuffer } from '@luma.gl/core';
3
3
  import { Buffer, RenderPass, RenderPipeline } from '@luma.gl/core';
4
- import { WebGPUDevice } from '../webgpu-device';
5
- import { WebGPURenderPipeline } from './webgpu-render-pipeline';
4
+ import { WebGPUDevice } from "../webgpu-device.js";
5
+ import { WebGPURenderPipeline } from "./webgpu-render-pipeline.js";
6
6
  export declare class WebGPURenderPass extends RenderPass {
7
7
  readonly device: WebGPUDevice;
8
8
  readonly handle: GPURenderPassEncoder;
@@ -30,6 +30,8 @@ export declare class WebGPURenderPass extends RenderPass {
30
30
  pushDebugGroup(groupLabel: string): void;
31
31
  popDebugGroup(): void;
32
32
  insertDebugMarker(markerLabel: string): void;
33
+ beginOcclusionQuery(queryIndex: number): void;
34
+ endOcclusionQuery(): void;
33
35
  /**
34
36
  * Partial render pass descriptor. Used by WebGPURenderPass.
35
37
  * @returns attachments fields of a renderpass descriptor.