@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.
- package/dist/adapter/helpers/accessor-to-format.js +99 -1
- package/dist/adapter/helpers/convert-texture-format.js +5 -5
- package/dist/adapter/helpers/generate-mipmaps.js +76 -82
- package/dist/adapter/helpers/get-bind-group.js +54 -41
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +110 -80
- package/dist/adapter/helpers/webgpu-parameters.js +182 -125
- package/dist/adapter/resources/webgpu-buffer.js +110 -62
- package/dist/adapter/resources/webgpu-command-encoder.js +73 -49
- package/dist/adapter/resources/webgpu-compute-pass.js +54 -41
- package/dist/adapter/resources/webgpu-compute-pipeline.js +24 -19
- package/dist/adapter/resources/webgpu-external-texture.js +29 -19
- package/dist/adapter/resources/webgpu-framebuffer.js +11 -7
- package/dist/adapter/resources/webgpu-query.js +42 -1
- package/dist/adapter/resources/webgpu-render-pass.js +115 -105
- package/dist/adapter/resources/webgpu-render-pipeline.js +148 -83
- package/dist/adapter/resources/webgpu-sampler.js +18 -15
- package/dist/adapter/resources/webgpu-shader.js +55 -45
- package/dist/adapter/resources/webgpu-texture.js +129 -109
- package/dist/adapter/resources/webgpu-vertex-array.d.ts +4 -1
- package/dist/adapter/resources/webgpu-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-vertex-array.js +64 -41
- package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgpu-canvas-context.js +100 -69
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +257 -230
- package/dist/adapter/webgpu-types.js +0 -2
- package/dist/dist.dev.js +661 -2178
- package/dist/glsl/glsllang.js +9 -6
- package/dist/index.cjs +58 -239
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +9 -6
- package/dist.min.js +1 -22
- package/package.json +9 -7
- package/src/adapter/resources/webgpu-vertex-array.ts +5 -2
- package/src/adapter/webgpu-canvas-context.ts +1 -0
- package/src/adapter/webgpu-device.ts +16 -36
- package/dist/adapter/helpers/accessor-to-format.js.map +0 -1
- package/dist/adapter/helpers/convert-texture-format.js.map +0 -1
- package/dist/adapter/helpers/generate-mipmaps.js.map +0 -1
- package/dist/adapter/helpers/get-bind-group.js.map +0 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +0 -1
- package/dist/adapter/helpers/webgpu-parameters.js.map +0 -1
- package/dist/adapter/resources/webgpu-buffer.js.map +0 -1
- package/dist/adapter/resources/webgpu-command-encoder.js.map +0 -1
- package/dist/adapter/resources/webgpu-compute-pass.js.map +0 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js.map +0 -1
- package/dist/adapter/resources/webgpu-external-texture.js.map +0 -1
- package/dist/adapter/resources/webgpu-framebuffer.js.map +0 -1
- package/dist/adapter/resources/webgpu-query.js.map +0 -1
- package/dist/adapter/resources/webgpu-render-pass.js.map +0 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +0 -1
- package/dist/adapter/resources/webgpu-sampler.js.map +0 -1
- package/dist/adapter/resources/webgpu-shader.js.map +0 -1
- package/dist/adapter/resources/webgpu-texture.js.map +0 -1
- package/dist/adapter/resources/webgpu-vertex-array.js.map +0 -1
- package/dist/adapter/webgpu-canvas-context.js.map +0 -1
- package/dist/adapter/webgpu-device.js.map +0 -1
- package/dist/adapter/webgpu-types.js.map +0 -1
- package/dist/glsl/glsllang.js.map +0 -1
- 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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
35
|
-
|
|
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
|
-
|
|
51
|
-
|
|
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
|
-
|
|
62
|
-
|
|
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
|
-
|
|
65
|
-
|
|
34
|
+
setIndexBuffer(buffer, indexFormat, offset = 0, size) {
|
|
35
|
+
this.handle.setIndexBuffer(cast(buffer).handle, indexFormat, offset, size);
|
|
66
36
|
}
|
|
67
|
-
|
|
68
|
-
|
|
37
|
+
setVertexBuffer(slot, buffer, offset = 0) {
|
|
38
|
+
this.handle.setVertexBuffer(slot, cast(buffer).handle, offset);
|
|
69
39
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|