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

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 (60) hide show
  1. package/dist/adapter/helpers/accessor-to-format.js +99 -1
  2. package/dist/adapter/helpers/convert-texture-format.js +5 -5
  3. package/dist/adapter/helpers/generate-mipmaps.js +76 -82
  4. package/dist/adapter/helpers/get-bind-group.js +54 -41
  5. package/dist/adapter/helpers/get-vertex-buffer-layout.js +110 -80
  6. package/dist/adapter/helpers/webgpu-parameters.js +182 -125
  7. package/dist/adapter/resources/webgpu-buffer.js +110 -62
  8. package/dist/adapter/resources/webgpu-command-encoder.js +73 -49
  9. package/dist/adapter/resources/webgpu-compute-pass.js +54 -41
  10. package/dist/adapter/resources/webgpu-compute-pipeline.js +24 -19
  11. package/dist/adapter/resources/webgpu-external-texture.js +29 -19
  12. package/dist/adapter/resources/webgpu-framebuffer.js +11 -7
  13. package/dist/adapter/resources/webgpu-query.js +42 -1
  14. package/dist/adapter/resources/webgpu-render-pass.js +115 -105
  15. package/dist/adapter/resources/webgpu-render-pipeline.js +148 -83
  16. package/dist/adapter/resources/webgpu-sampler.js +18 -15
  17. package/dist/adapter/resources/webgpu-shader.js +55 -45
  18. package/dist/adapter/resources/webgpu-texture.js +129 -109
  19. package/dist/adapter/resources/webgpu-vertex-array.d.ts +4 -1
  20. package/dist/adapter/resources/webgpu-vertex-array.d.ts.map +1 -1
  21. package/dist/adapter/resources/webgpu-vertex-array.js +64 -41
  22. package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
  23. package/dist/adapter/webgpu-canvas-context.js +100 -69
  24. package/dist/adapter/webgpu-device.d.ts.map +1 -1
  25. package/dist/adapter/webgpu-device.js +257 -230
  26. package/dist/adapter/webgpu-types.js +0 -2
  27. package/dist/dist.dev.js +661 -2178
  28. package/dist/glsl/glsllang.js +9 -6
  29. package/dist/index.cjs +58 -239
  30. package/dist/index.cjs.map +7 -0
  31. package/dist/index.js +9 -6
  32. package/dist.min.js +1 -22
  33. package/package.json +9 -7
  34. package/src/adapter/resources/webgpu-vertex-array.ts +5 -2
  35. package/src/adapter/webgpu-canvas-context.ts +1 -0
  36. package/src/adapter/webgpu-device.ts +16 -36
  37. package/dist/adapter/helpers/accessor-to-format.js.map +0 -1
  38. package/dist/adapter/helpers/convert-texture-format.js.map +0 -1
  39. package/dist/adapter/helpers/generate-mipmaps.js.map +0 -1
  40. package/dist/adapter/helpers/get-bind-group.js.map +0 -1
  41. package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +0 -1
  42. package/dist/adapter/helpers/webgpu-parameters.js.map +0 -1
  43. package/dist/adapter/resources/webgpu-buffer.js.map +0 -1
  44. package/dist/adapter/resources/webgpu-command-encoder.js.map +0 -1
  45. package/dist/adapter/resources/webgpu-compute-pass.js.map +0 -1
  46. package/dist/adapter/resources/webgpu-compute-pipeline.js.map +0 -1
  47. package/dist/adapter/resources/webgpu-external-texture.js.map +0 -1
  48. package/dist/adapter/resources/webgpu-framebuffer.js.map +0 -1
  49. package/dist/adapter/resources/webgpu-query.js.map +0 -1
  50. package/dist/adapter/resources/webgpu-render-pass.js.map +0 -1
  51. package/dist/adapter/resources/webgpu-render-pipeline.js.map +0 -1
  52. package/dist/adapter/resources/webgpu-sampler.js.map +0 -1
  53. package/dist/adapter/resources/webgpu-shader.js.map +0 -1
  54. package/dist/adapter/resources/webgpu-texture.js.map +0 -1
  55. package/dist/adapter/resources/webgpu-vertex-array.js.map +0 -1
  56. package/dist/adapter/webgpu-canvas-context.js.map +0 -1
  57. package/dist/adapter/webgpu-device.js.map +0 -1
  58. package/dist/adapter/webgpu-types.js.map +0 -1
  59. package/dist/glsl/glsllang.js.map +0 -1
  60. package/dist/index.js.map +0 -1
@@ -1,44 +1,57 @@
1
1
  import { ComputePass } from '@luma.gl/core';
2
2
  export class WebGPUComputePass extends ComputePass {
3
- constructor(device, props) {
4
- var _device$commandEncode;
5
- super(device, props);
6
- this.device = void 0;
7
- this.handle = void 0;
8
- this._bindGroupLayout = null;
9
- this.device = device;
10
- this.handle = this.props.handle || ((_device$commandEncode = device.commandEncoder) === null || _device$commandEncode === void 0 ? void 0 : _device$commandEncode.beginComputePass({
11
- label: this.props.id
12
- }));
13
- }
14
- destroy() {}
15
- end() {
16
- this.handle.end();
17
- }
18
- setPipeline(pipeline) {
19
- const wgpuPipeline = pipeline;
20
- this.handle.setPipeline(wgpuPipeline.handle);
21
- this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();
22
- }
23
- setBindings(bindings) {
24
- throw new Error('fix me');
25
- }
26
- dispatch(x, y, z) {
27
- this.handle.dispatchWorkgroups(x, y, z);
28
- }
29
- dispatchIndirect(indirectBuffer) {
30
- let indirectOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
31
- const webgpuBuffer = indirectBuffer;
32
- this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectOffset);
33
- }
34
- pushDebugGroup(groupLabel) {
35
- this.handle.pushDebugGroup(groupLabel);
36
- }
37
- popDebugGroup() {
38
- this.handle.popDebugGroup();
39
- }
40
- insertDebugMarker(markerLabel) {
41
- this.handle.insertDebugMarker(markerLabel);
42
- }
3
+ device;
4
+ handle;
5
+ _bindGroupLayout = null;
6
+ constructor(device, props) {
7
+ super(device, props);
8
+ this.device = device;
9
+ this.handle = this.props.handle || device.commandEncoder?.beginComputePass({
10
+ label: this.props.id,
11
+ // timestampWrites?: GPUComputePassTimestampWrites;
12
+ });
13
+ }
14
+ /** @note no WebGPU destroy method, just gc */
15
+ destroy() { }
16
+ end() {
17
+ this.handle.end();
18
+ }
19
+ setPipeline(pipeline) {
20
+ const wgpuPipeline = pipeline;
21
+ this.handle.setPipeline(wgpuPipeline.handle);
22
+ this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();
23
+ }
24
+ /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */
25
+ 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);
29
+ }
30
+ /**
31
+ * 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.
35
+ */
36
+ dispatch(x, y, z) {
37
+ this.handle.dispatchWorkgroups(x, y, z);
38
+ }
39
+ /**
40
+ * 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
43
+ */
44
+ dispatchIndirect(indirectBuffer, indirectOffset = 0) {
45
+ const webgpuBuffer = indirectBuffer;
46
+ this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectOffset);
47
+ }
48
+ pushDebugGroup(groupLabel) {
49
+ this.handle.pushDebugGroup(groupLabel);
50
+ }
51
+ popDebugGroup() {
52
+ this.handle.popDebugGroup();
53
+ }
54
+ insertDebugMarker(markerLabel) {
55
+ this.handle.insertDebugMarker(markerLabel);
56
+ }
43
57
  }
44
- //# sourceMappingURL=webgpu-compute-pass.js.map
@@ -1,22 +1,27 @@
1
+ // prettier-ignore
1
2
  import { ComputePipeline } from '@luma.gl/core';
3
+ // COMPUTE PIPELINE
4
+ /** Creates a new compute pipeline when parameters change */
2
5
  export class WebGPUComputePipeline extends ComputePipeline {
3
- constructor(device, props) {
4
- super(device, props);
5
- this.device = void 0;
6
- this.handle = void 0;
7
- this.device = device;
8
- const webgpuShader = this.props.cs;
9
- this.handle = this.props.handle || this.device.handle.createComputePipeline({
10
- label: this.props.id,
11
- compute: {
12
- module: webgpuShader.handle,
13
- entryPoint: this.props.csEntryPoint
14
- },
15
- layout: 'auto'
16
- });
17
- }
18
- _getBindGroupLayout() {
19
- return this.handle.getBindGroupLayout(0);
20
- }
6
+ device;
7
+ handle;
8
+ constructor(device, props) {
9
+ super(device, props);
10
+ 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
+ });
21
+ }
22
+ /** For internal use in render passes */
23
+ _getBindGroupLayout() {
24
+ // TODO: Cache?
25
+ return this.handle.getBindGroupLayout(0);
26
+ }
21
27
  }
22
- //# sourceMappingURL=webgpu-compute-pipeline.js.map
@@ -1,22 +1,32 @@
1
+ // luma.gl, MIT license
1
2
  import { ExternalTexture } from '@luma.gl/core';
2
- import { WebGPUSampler } from "./webgpu-sampler.js";
3
+ import { WebGPUSampler } from './webgpu-sampler';
4
+ /**
5
+ * Cheap, temporary texture view for videos
6
+ * Only valid within same callback, destroyed automatically as a microtask.
7
+ */
3
8
  export class WebGPUExternalTexture extends ExternalTexture {
4
- constructor(device, props) {
5
- super(device, props);
6
- this.device = void 0;
7
- this.handle = void 0;
8
- this.sampler = void 0;
9
- this.device = device;
10
- this.handle = this.props.handle || this.device.handle.importExternalTexture({
11
- source: props.source,
12
- colorSpace: props.colorSpace
13
- });
14
- this.sampler = null;
15
- }
16
- destroy() {}
17
- setSampler(sampler) {
18
- this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);
19
- return this;
20
- }
9
+ device;
10
+ handle;
11
+ sampler;
12
+ constructor(device, props) {
13
+ super(device, props);
14
+ this.device = device;
15
+ this.handle = this.props.handle || this.device.handle.importExternalTexture({
16
+ source: props.source,
17
+ colorSpace: props.colorSpace
18
+ });
19
+ this.sampler = null;
20
+ }
21
+ destroy() {
22
+ // External textures are destroyed automatically,
23
+ // as a microtask, instead of manually or upon garbage collection like other resources.
24
+ // this.handle.destroy();
25
+ }
26
+ /** Set default sampler */
27
+ setSampler(sampler) {
28
+ // We can accept a sampler instance or set of props;
29
+ this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);
30
+ return this;
31
+ }
21
32
  }
22
- //# sourceMappingURL=webgpu-external-texture.js.map
@@ -1,10 +1,14 @@
1
1
  import { Framebuffer } from '@luma.gl/core';
2
+ /**
3
+ * Create new textures with correct size for all attachments.
4
+ * @note resize() destroys existing textures (if size has changed).
5
+ */
2
6
  export class WebGPUFramebuffer extends Framebuffer {
3
- constructor(device, props) {
4
- super(device, props);
5
- this.device = void 0;
6
- this.device = device;
7
- this.autoCreateAttachmentTextures();
8
- }
7
+ device;
8
+ constructor(device, props) {
9
+ super(device, props);
10
+ this.device = device;
11
+ // Auto create textures for attachments if needed
12
+ this.autoCreateAttachmentTextures();
13
+ }
9
14
  }
10
- //# sourceMappingURL=webgpu-framebuffer.js.map
@@ -1,2 +1,43 @@
1
+ /*
2
+ import {Resource, Query, QueryProps} from '@luma.gl/core';
3
+ import {WebGPUDevice} from '../webgpu-device';
1
4
 
2
- //# sourceMappingURL=webgpu-query.js.map
5
+ export type WebGPUQueryProps = QueryProps & {
6
+ handle?: any;
7
+ };
8
+
9
+ const DEFAULT_QUERY_PROPS: Required<WebGPUQueryProps> = {
10
+ id: undefined,
11
+ handle: undefined,
12
+ userData: undefined,
13
+ type: 'timestamp',
14
+ count: 1,
15
+ pipelineStatistics: []
16
+ };
17
+
18
+ /**
19
+ * Immutable
20
+ *
21
+ class WebGPUQuery extends Resource<WebGPUQueryProps> implements Query {
22
+ readonly device: WebGPUDevice;
23
+ readonly handle: GPUQuerySet;
24
+
25
+ constructor(device: WebGPUDevice, props: WebGPUQueryProps) {
26
+ super(device, props, DEFAULT_QUERY_PROPS);
27
+ this.handle = this.props.handle as GPUQuerySet || this.createHandle();
28
+ this.handle.label = this.props.id;
29
+ }
30
+
31
+ protected createHandle() {
32
+ return this.device.handle.createQuerySet({
33
+ type: this.props.type,
34
+ count: this.props.count,
35
+ pipelineStatistics: this.props.pipelineStatistics
36
+ });
37
+ }
38
+
39
+ override destroy(): void {
40
+ this.handle.destroy();
41
+ }
42
+ }
43
+ */
@@ -1,115 +1,125 @@
1
1
  import { RenderPass, cast, log } from '@luma.gl/core';
2
2
  export class WebGPURenderPass extends RenderPass {
3
- constructor(device) {
4
- let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5
- super(device, props);
6
- this.device = void 0;
7
- this.handle = void 0;
8
- this.pipeline = null;
9
- this.device = device;
10
- const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();
11
- const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);
12
- log.groupCollapsed(3, `new WebGPURenderPass(${this.id})`)();
13
- log.probe(3, JSON.stringify(renderPassDescriptor, null, 2))();
14
- log.groupEnd(3)();
15
- this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);
16
- this.handle.label = this.props.id;
17
- }
18
- destroy() {}
19
- end() {
20
- this.handle.end();
21
- }
22
- setPipeline(pipeline) {
23
- this.pipeline = cast(pipeline);
24
- this.handle.setPipeline(this.pipeline.handle);
25
- }
26
- setBindings(bindings) {
27
- var _this$pipeline, _this$pipeline2;
28
- (_this$pipeline = this.pipeline) === null || _this$pipeline === void 0 ? void 0 : _this$pipeline.setBindings(bindings);
29
- const bindGroup = (_this$pipeline2 = this.pipeline) === null || _this$pipeline2 === void 0 ? void 0 : _this$pipeline2._getBindGroup();
30
- if (bindGroup) {
31
- this.handle.setBindGroup(0, bindGroup);
3
+ device;
4
+ handle;
5
+ /** Active pipeline */
6
+ pipeline = null;
7
+ constructor(device, props = {}) {
8
+ super(device, props);
9
+ this.device = device;
10
+ const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();
11
+ const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);
12
+ log.groupCollapsed(3, `new WebGPURenderPass(${this.id})`)();
13
+ log.probe(3, JSON.stringify(renderPassDescriptor, null, 2))();
14
+ log.groupEnd(3)();
15
+ this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);
16
+ this.handle.label = this.props.id;
32
17
  }
33
- }
34
- setIndexBuffer(buffer, indexFormat) {
35
- let offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
36
- let size = arguments.length > 3 ? arguments[3] : undefined;
37
- this.handle.setIndexBuffer(cast(buffer).handle, indexFormat, offset, size);
38
- }
39
- setVertexBuffer(slot, buffer) {
40
- let offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
41
- this.handle.setVertexBuffer(slot, cast(buffer).handle, offset);
42
- }
43
- draw(options) {
44
- if (options.indexCount) {
45
- this.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);
46
- } else {
47
- this.handle.draw(options.vertexCount || 0, options.instanceCount || 1, options.firstIndex, options.firstInstance);
18
+ destroy() { }
19
+ end() {
20
+ this.handle.end();
48
21
  }
49
- }
50
- drawIndirect() {}
51
- setParameters(parameters) {
52
- const {
53
- blendConstant,
54
- stencilReference,
55
- scissorRect,
56
- viewport
57
- } = parameters;
58
- if (blendConstant) {
59
- this.handle.setBlendConstant(blendConstant);
22
+ setPipeline(pipeline) {
23
+ this.pipeline = cast(pipeline);
24
+ this.handle.setPipeline(this.pipeline.handle);
60
25
  }
61
- if (stencilReference) {
62
- this.handle.setStencilReference(stencilReference);
26
+ /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */
27
+ setBindings(bindings) {
28
+ this.pipeline?.setBindings(bindings);
29
+ const bindGroup = this.pipeline?._getBindGroup();
30
+ if (bindGroup) {
31
+ this.handle.setBindGroup(0, bindGroup);
32
+ }
63
33
  }
64
- if (scissorRect) {
65
- this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);
34
+ setIndexBuffer(buffer, indexFormat, offset = 0, size) {
35
+ this.handle.setIndexBuffer(cast(buffer).handle, indexFormat, offset, size);
66
36
  }
67
- if (viewport) {
68
- this.handle.setViewport(viewport[0], viewport[1], viewport[2], viewport[3], viewport[4], viewport[5]);
37
+ setVertexBuffer(slot, buffer, offset = 0) {
38
+ this.handle.setVertexBuffer(slot, cast(buffer).handle, offset);
69
39
  }
70
- }
71
- pushDebugGroup(groupLabel) {
72
- this.handle.pushDebugGroup(groupLabel);
73
- }
74
- popDebugGroup() {
75
- this.handle.popDebugGroup();
76
- }
77
- insertDebugMarker(markerLabel) {
78
- this.handle.insertDebugMarker(markerLabel);
79
- }
80
- getRenderPassDescriptor(framebuffer) {
81
- const renderPassDescriptor = {
82
- colorAttachments: []
83
- };
84
- renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({
85
- loadOp: this.props.clearColor !== false ? 'clear' : 'load',
86
- colorClearValue: this.props.clearColor || [0, 0, 0, 0],
87
- storeOp: this.props.discard ? 'discard' : 'store',
88
- view: colorAttachment.createView()
89
- }));
90
- if (framebuffer.depthStencilAttachment) {
91
- renderPassDescriptor.depthStencilAttachment = {
92
- view: framebuffer.depthStencilAttachment.createView()
93
- };
94
- const {
95
- depthStencilAttachment
96
- } = renderPassDescriptor;
97
- if (this.props.depthReadOnly) {
98
- depthStencilAttachment.depthReadOnly = true;
99
- }
100
- depthStencilAttachment.depthClearValue = this.props.clearDepth || 0;
101
- const hasDepthAspect = true;
102
- if (hasDepthAspect) {
103
- depthStencilAttachment.depthLoadOp = this.props.clearDepth !== false ? 'clear' : 'load';
104
- depthStencilAttachment.depthStoreOp = 'store';
105
- }
106
- const hasStencilAspect = false;
107
- if (hasStencilAspect) {
108
- depthStencilAttachment.stencilLoadOp = this.props.clearStencil !== false ? 'clear' : 'load';
109
- depthStencilAttachment.stencilStoreOp = 'store';
110
- }
40
+ draw(options) {
41
+ if (options.indexCount) {
42
+ this.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);
43
+ }
44
+ else {
45
+ this.handle.draw(options.vertexCount || 0, options.instanceCount || 1, options.firstIndex, options.firstInstance);
46
+ }
47
+ }
48
+ drawIndirect() {
49
+ // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
50
+ // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
51
+ }
52
+ setParameters(parameters) {
53
+ const { blendConstant, stencilReference, scissorRect, viewport } = parameters;
54
+ if (blendConstant) {
55
+ this.handle.setBlendConstant(blendConstant);
56
+ }
57
+ if (stencilReference) {
58
+ this.handle.setStencilReference(stencilReference);
59
+ }
60
+ if (scissorRect) {
61
+ this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);
62
+ }
63
+ // TODO - explain how 3 dimensions vs 2 in WebGL works.
64
+ if (viewport) {
65
+ this.handle.setViewport(viewport[0], viewport[1], viewport[2], viewport[3], viewport[4], viewport[5]);
66
+ }
67
+ }
68
+ pushDebugGroup(groupLabel) {
69
+ this.handle.pushDebugGroup(groupLabel);
70
+ }
71
+ popDebugGroup() {
72
+ this.handle.popDebugGroup();
73
+ }
74
+ insertDebugMarker(markerLabel) {
75
+ this.handle.insertDebugMarker(markerLabel);
76
+ }
77
+ // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
78
+ // beginOcclusionQuery(queryIndex: number): void;
79
+ // endOcclusionQuery(): void;
80
+ // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
81
+ // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
82
+ // executeBundles(bundles: Iterable<GPURenderBundle>): void;
83
+ // INTERNAL
84
+ /**
85
+ * Partial render pass descriptor. Used by WebGPURenderPass.
86
+ * @returns attachments fields of a renderpass descriptor.
87
+ */
88
+ getRenderPassDescriptor(framebuffer) {
89
+ const renderPassDescriptor = {
90
+ colorAttachments: []
91
+ };
92
+ renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({
93
+ // clear values
94
+ loadOp: this.props.clearColor !== false ? 'clear' : 'load',
95
+ colorClearValue: this.props.clearColor || [0, 0, 0, 0],
96
+ storeOp: this.props.discard ? 'discard' : 'store',
97
+ // ...colorAttachment,
98
+ view: colorAttachment.createView()
99
+ }));
100
+ if (framebuffer.depthStencilAttachment) {
101
+ renderPassDescriptor.depthStencilAttachment = {
102
+ view: framebuffer.depthStencilAttachment.createView()
103
+ };
104
+ const { depthStencilAttachment } = renderPassDescriptor;
105
+ // DEPTH
106
+ if (this.props.depthReadOnly) {
107
+ depthStencilAttachment.depthReadOnly = true;
108
+ }
109
+ depthStencilAttachment.depthClearValue = this.props.clearDepth || 0;
110
+ // WebGPU only wants us to set these parameters if the texture format actually has a depth aspect
111
+ const hasDepthAspect = true;
112
+ if (hasDepthAspect) {
113
+ depthStencilAttachment.depthLoadOp = this.props.clearDepth !== false ? 'clear' : 'load';
114
+ depthStencilAttachment.depthStoreOp = 'store'; // TODO - support 'discard'?
115
+ }
116
+ // WebGPU only wants us to set these parameters if the texture format actually has a stencil aspect
117
+ const hasStencilAspect = false;
118
+ if (hasStencilAspect) {
119
+ depthStencilAttachment.stencilLoadOp = this.props.clearStencil !== false ? 'clear' : 'load';
120
+ depthStencilAttachment.stencilStoreOp = 'store'; // TODO - support 'discard'?
121
+ }
122
+ }
123
+ return renderPassDescriptor;
111
124
  }
112
- return renderPassDescriptor;
113
- }
114
125
  }
115
- //# sourceMappingURL=webgpu-render-pass.js.map