@luma.gl/core 9.0.0-beta.3 → 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/attribute-utils/get-attribute-from-layouts.js +140 -109
- package/dist/adapter/canvas-context.js +305 -233
- package/dist/adapter/device.d.ts +9 -11
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +114 -95
- package/dist/adapter/resources/buffer.d.ts +1 -1
- package/dist/adapter/resources/buffer.d.ts.map +1 -1
- package/dist/adapter/resources/buffer.js +65 -57
- package/dist/adapter/resources/command-buffer.js +13 -13
- package/dist/adapter/resources/command-encoder.js +17 -17
- package/dist/adapter/resources/compute-pass.js +10 -13
- package/dist/adapter/resources/compute-pipeline.js +19 -18
- package/dist/adapter/resources/external-texture.js +10 -15
- package/dist/adapter/resources/framebuffer.js +155 -94
- package/dist/adapter/resources/render-pass.js +28 -21
- package/dist/adapter/resources/render-pipeline.d.ts +3 -1
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/render-pipeline.js +37 -34
- package/dist/adapter/resources/resource.js +131 -93
- package/dist/adapter/resources/sampler.js +24 -24
- package/dist/adapter/resources/shader.d.ts +2 -2
- package/dist/adapter/resources/shader.d.ts.map +1 -1
- package/dist/adapter/resources/shader.js +90 -78
- package/dist/adapter/resources/texture.js +49 -43
- package/dist/adapter/resources/transform-feedback.d.ts +2 -2
- package/dist/adapter/resources/transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/transform-feedback.js +13 -15
- package/dist/adapter/resources/vertex-array.js +30 -22
- package/dist/adapter/type-utils/decode-attribute-type.js +56 -52
- package/dist/adapter/type-utils/decode-data-type.js +36 -35
- package/dist/adapter/type-utils/decode-shader-types.js +36 -97
- package/dist/adapter/type-utils/decode-texture-format.js +160 -93
- package/dist/adapter/type-utils/decode-vertex-format.js +28 -23
- package/dist/adapter/type-utils/vertex-format-from-attribute.js +69 -65
- package/dist/adapter/type-utils/wgsl-utils.js +14 -13
- package/dist/adapter/types/accessor.js +0 -1
- package/dist/adapter/types/buffer-layout.js +0 -1
- package/dist/adapter/types/parameters.js +31 -26
- package/dist/adapter/types/shader-layout.js +0 -1
- package/dist/adapter/types/shader-types.js +2 -1
- package/dist/adapter/types/texture-formats.d.ts +1 -1
- package/dist/adapter/types/texture-formats.d.ts.map +1 -1
- package/dist/adapter/types/texture-formats.js +2 -1
- package/dist/adapter/types/types.js +0 -1
- package/dist/adapter/types/vertex-formats.js +2 -1
- package/dist/dist.dev.js +453 -270
- package/dist/index.cjs +66 -168
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -46
- package/dist/init.js +29 -19
- package/dist/lib/compiler-log/compiler-message.js +2 -1
- package/dist/lib/compiler-log/format-compiler-log.js +66 -48
- package/dist/lib/compiler-log/get-shader-info.js +22 -19
- package/dist/lib/luma.d.ts.map +1 -1
- package/dist/lib/luma.js +60 -55
- package/dist/lib/uniforms/uniform-block.d.ts +0 -1
- package/dist/lib/uniforms/uniform-block.d.ts.map +1 -1
- package/dist/lib/uniforms/uniform-block.js +50 -43
- package/dist/lib/uniforms/uniform-buffer-layout.js +87 -70
- package/dist/lib/uniforms/uniform-store.js +112 -79
- package/dist/lib/uniforms/uniform.js +13 -16
- package/dist/types.js +1 -3
- package/dist/utils/array-equal.js +25 -23
- package/dist/utils/array-utils-flat.js +28 -28
- package/dist/utils/assert.js +5 -4
- package/dist/utils/cast.js +2 -2
- package/dist/utils/check-props.js +28 -27
- package/dist/utils/deep-equal.js +39 -32
- package/dist/utils/format-value.js +33 -39
- package/dist/utils/is-array.js +17 -6
- package/dist/utils/load-file.js +62 -37
- package/dist/utils/log.js +2 -4
- package/dist/utils/random.js +10 -9
- package/dist/utils/request-animation-frame.js +9 -3
- package/dist/utils/stats-manager.js +13 -14
- package/dist/utils/stub-methods.js +13 -13
- package/dist/utils/utils.d.ts +0 -6
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +20 -15
- package/dist.min.js +8 -23
- package/package.json +6 -6
- package/src/adapter/device.ts +38 -59
- package/src/adapter/resources/buffer.ts +1 -1
- package/src/adapter/resources/render-pipeline.ts +3 -1
- package/src/adapter/resources/shader.ts +2 -2
- package/src/adapter/resources/transform-feedback.ts +2 -2
- package/src/adapter/types/texture-formats.ts +1 -1
- package/src/index.ts +1 -1
- package/src/lib/luma.ts +0 -2
- package/src/lib/uniforms/uniform-block.ts +0 -1
- package/src/utils/utils.ts +0 -9
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.js.map +0 -1
- package/dist/adapter/canvas-context.js.map +0 -1
- package/dist/adapter/device.js.map +0 -1
- package/dist/adapter/resources/buffer.js.map +0 -1
- package/dist/adapter/resources/command-buffer.js.map +0 -1
- package/dist/adapter/resources/command-encoder.js.map +0 -1
- package/dist/adapter/resources/compute-pass.js.map +0 -1
- package/dist/adapter/resources/compute-pipeline.js.map +0 -1
- package/dist/adapter/resources/external-texture.js.map +0 -1
- package/dist/adapter/resources/framebuffer.js.map +0 -1
- package/dist/adapter/resources/render-pass.js.map +0 -1
- package/dist/adapter/resources/render-pipeline.js.map +0 -1
- package/dist/adapter/resources/resource.js.map +0 -1
- package/dist/adapter/resources/sampler.js.map +0 -1
- package/dist/adapter/resources/shader.js.map +0 -1
- package/dist/adapter/resources/texture.js.map +0 -1
- package/dist/adapter/resources/transform-feedback.js.map +0 -1
- package/dist/adapter/resources/vertex-array.js.map +0 -1
- package/dist/adapter/type-utils/decode-attribute-type.js.map +0 -1
- package/dist/adapter/type-utils/decode-data-type.js.map +0 -1
- package/dist/adapter/type-utils/decode-shader-types.js.map +0 -1
- package/dist/adapter/type-utils/decode-texture-format.js.map +0 -1
- package/dist/adapter/type-utils/decode-vertex-format.js.map +0 -1
- package/dist/adapter/type-utils/vertex-format-from-attribute.js.map +0 -1
- package/dist/adapter/type-utils/wgsl-utils.js.map +0 -1
- package/dist/adapter/types/accessor.js.map +0 -1
- package/dist/adapter/types/buffer-layout.js.map +0 -1
- package/dist/adapter/types/parameters.js.map +0 -1
- package/dist/adapter/types/shader-layout.js.map +0 -1
- package/dist/adapter/types/shader-types.js.map +0 -1
- package/dist/adapter/types/texture-formats.js.map +0 -1
- package/dist/adapter/types/types.js.map +0 -1
- package/dist/adapter/types/vertex-formats.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/init.js.map +0 -1
- package/dist/lib/compiler-log/compiler-message.js.map +0 -1
- package/dist/lib/compiler-log/format-compiler-log.js.map +0 -1
- package/dist/lib/compiler-log/get-shader-info.js.map +0 -1
- package/dist/lib/luma.js.map +0 -1
- package/dist/lib/uniforms/uniform-block.js.map +0 -1
- package/dist/lib/uniforms/uniform-buffer-layout.js.map +0 -1
- package/dist/lib/uniforms/uniform-store.js.map +0 -1
- package/dist/lib/uniforms/uniform.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/array-equal.js.map +0 -1
- package/dist/utils/array-utils-flat.js.map +0 -1
- package/dist/utils/assert.js.map +0 -1
- package/dist/utils/cast.js.map +0 -1
- package/dist/utils/check-props.js.map +0 -1
- package/dist/utils/deep-equal.js.map +0 -1
- package/dist/utils/format-value.js.map +0 -1
- package/dist/utils/is-array.js.map +0 -1
- package/dist/utils/load-file.js.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/random.js.map +0 -1
- package/dist/utils/request-animation-frame.js.map +0 -1
- package/dist/utils/stats-manager.js.map +0 -1
- package/dist/utils/stub-methods.js.map +0 -1
- package/dist/utils/utils.js.map +0 -1
|
@@ -1,102 +1,163 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
import { Resource } from './resource';
|
|
4
|
+
import { Texture } from './texture';
|
|
5
|
+
import { log } from '../../utils/log';
|
|
6
|
+
/**
|
|
7
|
+
* Create new textures with correct size for all attachments.
|
|
8
|
+
* @note resize() destroys existing textures (if size has changed).
|
|
9
|
+
*/
|
|
6
10
|
export class Framebuffer extends Resource {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.depthStencilAttachment = null;
|
|
17
|
-
this.width = this.props.width;
|
|
18
|
-
this.height = this.props.height;
|
|
19
|
-
}
|
|
20
|
-
resize(size) {
|
|
21
|
-
let updateSize = !size;
|
|
22
|
-
if (size) {
|
|
23
|
-
const [width, height] = Array.isArray(size) ? size : [size.width, size.height];
|
|
24
|
-
updateSize = updateSize || height !== this.height || width !== this.width;
|
|
25
|
-
this.width = width;
|
|
26
|
-
this.height = height;
|
|
11
|
+
static defaultProps = {
|
|
12
|
+
...Resource.defaultProps,
|
|
13
|
+
width: 1,
|
|
14
|
+
height: 1,
|
|
15
|
+
colorAttachments: [], // ['rgba8unorm-unsized'],
|
|
16
|
+
depthStencilAttachment: null // 'depth24plus-stencil8'
|
|
17
|
+
};
|
|
18
|
+
get [Symbol.toStringTag]() {
|
|
19
|
+
return 'Framebuffer';
|
|
27
20
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
/** Width of all attachments in this framebuffer */
|
|
22
|
+
width;
|
|
23
|
+
/** Height of all attachments in this framebuffer */
|
|
24
|
+
height;
|
|
25
|
+
/** Color attachments */
|
|
26
|
+
colorAttachments = [];
|
|
27
|
+
/** Depth-stencil attachment, if provided */
|
|
28
|
+
depthStencilAttachment = null;
|
|
29
|
+
constructor(device, props = {}) {
|
|
30
|
+
super(device, props, Framebuffer.defaultProps);
|
|
31
|
+
this.width = this.props.width;
|
|
32
|
+
this.height = this.props.height;
|
|
33
|
+
// NOTE: call from subclass constructor as we cannot call overridden methods here (subclass not yet constructed)
|
|
34
|
+
// this.autoCreateAttachmentTextures();
|
|
31
35
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const texture = this.createDepthStencilTexture(this.props.depthStencilAttachment);
|
|
45
|
-
this.attachResource(texture);
|
|
46
|
-
this.depthStencilAttachment = texture;
|
|
47
|
-
} else {
|
|
48
|
-
this.depthStencilAttachment = this.props.depthStencilAttachment;
|
|
49
|
-
}
|
|
36
|
+
resize(size) {
|
|
37
|
+
let updateSize = !size;
|
|
38
|
+
if (size) {
|
|
39
|
+
const [width, height] = Array.isArray(size) ? size : [size.width, size.height];
|
|
40
|
+
updateSize = updateSize || height !== this.height || width !== this.width;
|
|
41
|
+
this.width = width;
|
|
42
|
+
this.height = height;
|
|
43
|
+
}
|
|
44
|
+
if (updateSize) {
|
|
45
|
+
log.log(2, `Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)();
|
|
46
|
+
this.resizeAttachments(this.width, this.height);
|
|
47
|
+
}
|
|
50
48
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
49
|
+
// /** Returns fully populated attachment object. */
|
|
50
|
+
// protected normalizeColorAttachment(
|
|
51
|
+
// attachment: Texture | ColorTextureFormat
|
|
52
|
+
// ): Required<ColorAttachment> {
|
|
53
|
+
// const COLOR_ATTACHMENT_DEFAULTS: Required<ColorAttachment> = {
|
|
54
|
+
// texture: undefined!,
|
|
55
|
+
// format: undefined!,
|
|
56
|
+
// clearValue: [0.0, 0.0, 0.0, 0.0],
|
|
57
|
+
// loadOp: 'clear',
|
|
58
|
+
// storeOp: 'store'
|
|
59
|
+
// };
|
|
60
|
+
// if (attachment instanceof Texture) {
|
|
61
|
+
// return {...COLOR_ATTACHMENT_DEFAULTS, texture: attachment};
|
|
62
|
+
// }
|
|
63
|
+
// if (typeof attachment === 'string') {
|
|
64
|
+
// return {...COLOR_ATTACHMENT_DEFAULTS, format: attachment};
|
|
65
|
+
// }
|
|
66
|
+
// return {...COLOR_ATTACHMENT_DEFAULTS, ...attachment};
|
|
67
|
+
// }
|
|
68
|
+
// /** Wraps texture inside fully populated attachment object. */
|
|
69
|
+
// protected normalizeDepthStencilAttachment(
|
|
70
|
+
// attachment: DepthStencilAttachment | Texture | DepthStencilTextureFormat
|
|
71
|
+
// ): Required<DepthStencilAttachment> {
|
|
72
|
+
// const DEPTH_STENCIL_ATTACHMENT_DEFAULTS: Required<DepthStencilAttachment> = {
|
|
73
|
+
// texture: undefined!,
|
|
74
|
+
// format: undefined!,
|
|
75
|
+
// depthClearValue: 1.0,
|
|
76
|
+
// depthLoadOp: 'clear',
|
|
77
|
+
// depthStoreOp: 'store',
|
|
78
|
+
// depthReadOnly: false,
|
|
79
|
+
// stencilClearValue: 0,
|
|
80
|
+
// stencilLoadOp: 'clear',
|
|
81
|
+
// stencilStoreOp: 'store',
|
|
82
|
+
// stencilReadOnly: false
|
|
83
|
+
// };
|
|
84
|
+
// if (typeof attachment === 'string') {
|
|
85
|
+
// return {...DEPTH_STENCIL_ATTACHMENT_DEFAULTS, format: attachment};
|
|
86
|
+
// }
|
|
87
|
+
// // @ts-expect-error attachment instanceof Texture doesn't cover Renderbuffer
|
|
88
|
+
// if (attachment.handle || attachment instanceof Texture) {
|
|
89
|
+
// return {...DEPTH_STENCIL_ATTACHMENT_DEFAULTS, texture: attachment as Texture};
|
|
90
|
+
// }
|
|
91
|
+
// return {...DEPTH_STENCIL_ATTACHMENT_DEFAULTS, ...attachment};
|
|
92
|
+
// }
|
|
93
|
+
/** Auto creates any textures */
|
|
94
|
+
autoCreateAttachmentTextures() {
|
|
95
|
+
this.colorAttachments = this.props.colorAttachments.map(attachment => {
|
|
96
|
+
if (typeof attachment === 'string') {
|
|
97
|
+
const texture = this.createColorTexture(attachment);
|
|
98
|
+
this.attachResource(texture);
|
|
99
|
+
return texture;
|
|
100
|
+
}
|
|
101
|
+
return attachment;
|
|
77
102
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
103
|
+
if (this.props.depthStencilAttachment) {
|
|
104
|
+
if (typeof this.props.depthStencilAttachment === 'string') {
|
|
105
|
+
const texture = this.createDepthStencilTexture(this.props.depthStencilAttachment);
|
|
106
|
+
this.attachResource(texture);
|
|
107
|
+
this.depthStencilAttachment = texture;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
this.depthStencilAttachment = this.props.depthStencilAttachment;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
82
113
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
114
|
+
/** Create a color texture */
|
|
115
|
+
createColorTexture(format) {
|
|
116
|
+
return this.device.createTexture({
|
|
117
|
+
id: 'color-attachment',
|
|
118
|
+
usage: Texture.RENDER_ATTACHMENT,
|
|
119
|
+
format,
|
|
120
|
+
width: this.width,
|
|
121
|
+
height: this.height,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/** Create depth stencil texture */
|
|
125
|
+
createDepthStencilTexture(format) {
|
|
126
|
+
return this.device.createTexture({
|
|
127
|
+
id: 'depth-stencil-attachment',
|
|
128
|
+
usage: Texture.RENDER_ATTACHMENT,
|
|
129
|
+
format,
|
|
130
|
+
width: this.width,
|
|
131
|
+
height: this.height
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Default implementation of resize
|
|
136
|
+
* Creates new textures with correct size for all attachments.
|
|
137
|
+
* and destroys existing textures if owned
|
|
138
|
+
*/
|
|
139
|
+
resizeAttachments(width, height) {
|
|
140
|
+
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
141
|
+
if (this.colorAttachments[i]) {
|
|
142
|
+
const resizedTexture = this.device._createTexture({
|
|
143
|
+
...this.colorAttachments[i].props,
|
|
144
|
+
width,
|
|
145
|
+
height
|
|
146
|
+
});
|
|
147
|
+
this.destroyAttachedResource(this.colorAttachments[i]);
|
|
148
|
+
this.colorAttachments[i] = resizedTexture;
|
|
149
|
+
this.attachResource(resizedTexture);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (this.depthStencilAttachment) {
|
|
153
|
+
const resizedTexture = this.device._createTexture({
|
|
154
|
+
...this.depthStencilAttachment.props,
|
|
155
|
+
width,
|
|
156
|
+
height
|
|
157
|
+
});
|
|
158
|
+
this.destroyAttachedResource(this.depthStencilAttachment);
|
|
159
|
+
this.depthStencilAttachment = resizedTexture;
|
|
160
|
+
this.attachResource(resizedTexture);
|
|
161
|
+
}
|
|
92
162
|
}
|
|
93
|
-
}
|
|
94
163
|
}
|
|
95
|
-
Framebuffer.defaultProps = {
|
|
96
|
-
...Resource.defaultProps,
|
|
97
|
-
width: 1,
|
|
98
|
-
height: 1,
|
|
99
|
-
colorAttachments: [],
|
|
100
|
-
depthStencilAttachment: null
|
|
101
|
-
};
|
|
102
|
-
//# sourceMappingURL=framebuffer.js.map
|
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
import { Resource } from
|
|
3
|
-
|
|
1
|
+
// import {Binding} from '../types/shader-layout';
|
|
2
|
+
import { Resource } from './resource';
|
|
3
|
+
/**
|
|
4
|
+
* A RenderPass instance is a required parameter to all draw calls.
|
|
5
|
+
*
|
|
6
|
+
* It holds a combination of
|
|
7
|
+
* - render targets (specified via a framebuffer)
|
|
8
|
+
* - clear colors, read/write, discard information for the framebuffer attachments
|
|
9
|
+
* - a couple of mutable parameters ()
|
|
10
|
+
*/
|
|
4
11
|
export class RenderPass extends Resource {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
/** Default properties for RenderPass */
|
|
13
|
+
static defaultProps = {
|
|
14
|
+
...Resource.defaultProps,
|
|
15
|
+
framebuffer: null,
|
|
16
|
+
parameters: undefined,
|
|
17
|
+
clearColor: [0, 0, 0, 0],
|
|
18
|
+
clearDepth: 1,
|
|
19
|
+
clearStencil: 0,
|
|
20
|
+
depthReadOnly: false,
|
|
21
|
+
stencilReadOnly: false,
|
|
22
|
+
discard: false
|
|
23
|
+
};
|
|
24
|
+
get [Symbol.toStringTag]() {
|
|
25
|
+
return 'RenderPass';
|
|
26
|
+
}
|
|
27
|
+
constructor(device, props) {
|
|
28
|
+
super(device, props, RenderPass.defaultProps);
|
|
29
|
+
}
|
|
11
30
|
}
|
|
12
|
-
RenderPass.defaultProps = {
|
|
13
|
-
...Resource.defaultProps,
|
|
14
|
-
framebuffer: null,
|
|
15
|
-
parameters: undefined,
|
|
16
|
-
clearColor: [0, 0, 0, 0],
|
|
17
|
-
clearDepth: 1,
|
|
18
|
-
clearStencil: 0,
|
|
19
|
-
depthReadOnly: false,
|
|
20
|
-
stencilReadOnly: false,
|
|
21
|
-
discard: false
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=render-pass.js.map
|
|
@@ -54,6 +54,8 @@ export declare abstract class RenderPipeline extends Resource<RenderPipelineProp
|
|
|
54
54
|
shaderLayout: ShaderLayout;
|
|
55
55
|
/** Buffer map describing buffer interleaving etc */
|
|
56
56
|
readonly bufferLayout: BufferLayout[];
|
|
57
|
+
/** The linking status of the pipeline. 'pending' if linking is asynchronous, and on production */
|
|
58
|
+
linkStatus: 'pending' | 'success' | 'error';
|
|
57
59
|
constructor(device: Device, props: RenderPipelineProps);
|
|
58
60
|
/** Set bindings (stored on pipeline and set before each call) */
|
|
59
61
|
abstract setBindings(bindings: Record<string, Binding>): void;
|
|
@@ -82,7 +84,7 @@ export declare abstract class RenderPipeline extends Resource<RenderPipelineProp
|
|
|
82
84
|
/** First instance to draw from */
|
|
83
85
|
firstInstance?: number;
|
|
84
86
|
baseVertex?: number;
|
|
85
|
-
/** Transform feedback. WebGL
|
|
87
|
+
/** Transform feedback. WebGL only. */
|
|
86
88
|
transformFeedback?: TransformFeedback;
|
|
87
89
|
}): void;
|
|
88
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/render-pipeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAC,iBAAiB,EAAE,wBAAwB,EAAC,MAAM,qBAAqB,CAAC;AACrF,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAC,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAEvD,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAGhD,6BAA6B;IAC7B,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,WAAW,CAAC,E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AiE;QACjE,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,wBAAwB;QACxB,WAAW,EAAE,WAAW,CAAC;QACzB,uCAAuC;QACvC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,2CAA2C;QAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,6CAA6C;QAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,gCAAgC;QAChC,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,+BAA+B;QAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,kCAAkC;QAClC,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,sCAAsC;QACtC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;KACvC,GAAG,IAAI;CACT"}
|
|
@@ -1,36 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
import { Resource } from
|
|
3
|
-
|
|
1
|
+
// import {normalizeAttributeMap} from '../helpers/attribute-bindings';
|
|
2
|
+
import { Resource } from './resource';
|
|
3
|
+
/**
|
|
4
|
+
* A compiled and linked shader program
|
|
5
|
+
*/
|
|
4
6
|
export class RenderPipeline extends Resource {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
static defaultProps = {
|
|
8
|
+
...Resource.defaultProps,
|
|
9
|
+
vs: null,
|
|
10
|
+
vsEntryPoint: '', // main
|
|
11
|
+
vsConstants: {},
|
|
12
|
+
fs: null,
|
|
13
|
+
fsEntryPoint: '', // main
|
|
14
|
+
fsConstants: {},
|
|
15
|
+
shaderLayout: null,
|
|
16
|
+
bufferLayout: [],
|
|
17
|
+
topology: 'triangle-list',
|
|
18
|
+
parameters: {},
|
|
19
|
+
vertexCount: 0,
|
|
20
|
+
instanceCount: 0,
|
|
21
|
+
bindings: {},
|
|
22
|
+
uniforms: {}
|
|
23
|
+
};
|
|
24
|
+
get [Symbol.toStringTag]() {
|
|
25
|
+
return 'RenderPipeline';
|
|
26
|
+
}
|
|
27
|
+
hash = '';
|
|
28
|
+
/** The merged layout */
|
|
29
|
+
shaderLayout;
|
|
30
|
+
/** Buffer map describing buffer interleaving etc */
|
|
31
|
+
bufferLayout;
|
|
32
|
+
/** The linking status of the pipeline. 'pending' if linking is asynchronous, and on production */
|
|
33
|
+
linkStatus = 'pending';
|
|
34
|
+
constructor(device, props) {
|
|
35
|
+
super(device, props, RenderPipeline.defaultProps);
|
|
36
|
+
this.shaderLayout = this.props.shaderLayout;
|
|
37
|
+
this.bufferLayout = this.props.bufferLayout || [];
|
|
38
|
+
}
|
|
18
39
|
}
|
|
19
|
-
RenderPipeline.defaultProps = {
|
|
20
|
-
...Resource.defaultProps,
|
|
21
|
-
vs: null,
|
|
22
|
-
vsEntryPoint: '',
|
|
23
|
-
vsConstants: {},
|
|
24
|
-
fs: null,
|
|
25
|
-
fsEntryPoint: '',
|
|
26
|
-
fsConstants: {},
|
|
27
|
-
shaderLayout: null,
|
|
28
|
-
bufferLayout: [],
|
|
29
|
-
topology: 'triangle-list',
|
|
30
|
-
parameters: {},
|
|
31
|
-
vertexCount: 0,
|
|
32
|
-
instanceCount: 0,
|
|
33
|
-
bindings: {},
|
|
34
|
-
uniforms: {}
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=render-pipeline.js.map
|
|
@@ -1,101 +1,139 @@
|
|
|
1
|
-
import { uid } from
|
|
1
|
+
import { uid } from '../../utils/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for GPU (WebGPU/WebGL) Resources
|
|
4
|
+
*/
|
|
2
5
|
export class Resource {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
/** Default properties for resource */
|
|
7
|
+
static defaultProps = {
|
|
8
|
+
id: 'undefined',
|
|
9
|
+
handle: undefined,
|
|
10
|
+
userData: undefined,
|
|
11
|
+
};
|
|
12
|
+
/** props.id, for debugging. */
|
|
13
|
+
id;
|
|
14
|
+
props;
|
|
15
|
+
userData = {};
|
|
16
|
+
_device;
|
|
17
|
+
/** Whether this resource has been destroyed */
|
|
18
|
+
destroyed = false;
|
|
19
|
+
/** For resources that allocate GPU memory */
|
|
20
|
+
allocatedBytes = 0;
|
|
21
|
+
/** Attached resources will be destroyed when this resource is destroyed. Tracks auto-created "sub" resources. */
|
|
22
|
+
_attachedResources = new Set();
|
|
23
|
+
/**
|
|
24
|
+
* Create a new Resource. Called from Subclass
|
|
25
|
+
*/
|
|
26
|
+
constructor(device, props, defaultProps) {
|
|
27
|
+
if (!device) {
|
|
28
|
+
throw new Error('no device');
|
|
29
|
+
}
|
|
30
|
+
this._device = device;
|
|
31
|
+
this.props = selectivelyMerge(props, defaultProps);
|
|
32
|
+
const id = this.props.id !== 'undefined' ? this.props.id : uid(this[Symbol.toStringTag]);
|
|
33
|
+
this.props.id = id;
|
|
34
|
+
this.id = id;
|
|
35
|
+
this.userData = this.props.userData || {};
|
|
36
|
+
this.addStats();
|
|
14
37
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.userData = this.props.userData || {};
|
|
21
|
-
this.addStats();
|
|
22
|
-
}
|
|
23
|
-
destroy() {
|
|
24
|
-
this.destroyResource();
|
|
25
|
-
}
|
|
26
|
-
delete() {
|
|
27
|
-
this.destroy();
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
toString() {
|
|
31
|
-
return `${this[Symbol.toStringTag] || this.constructor.name}(${this.id})`;
|
|
32
|
-
}
|
|
33
|
-
getProps() {
|
|
34
|
-
return this.props;
|
|
35
|
-
}
|
|
36
|
-
attachResource(resource) {
|
|
37
|
-
this._attachedResources.add(resource);
|
|
38
|
-
}
|
|
39
|
-
detachResource(resource) {
|
|
40
|
-
this._attachedResources.delete(resource);
|
|
41
|
-
}
|
|
42
|
-
destroyAttachedResource(resource) {
|
|
43
|
-
if (this._attachedResources.delete(resource)) {
|
|
44
|
-
resource.destroy();
|
|
38
|
+
/**
|
|
39
|
+
* destroy can be called on any resource to release it before it is garbage collected.
|
|
40
|
+
*/
|
|
41
|
+
destroy() {
|
|
42
|
+
this.destroyResource();
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
/** @deprecated Use destroy() */
|
|
45
|
+
delete() {
|
|
46
|
+
this.destroy();
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
toString() {
|
|
50
|
+
return `${this[Symbol.toStringTag] || this.constructor.name}(${this.id})`;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Combines a map of user props and default props, only including props from defaultProps
|
|
54
|
+
* @returns returns a map of overridden default props
|
|
55
|
+
*/
|
|
56
|
+
getProps() {
|
|
57
|
+
return this.props;
|
|
58
|
+
}
|
|
59
|
+
// ATTACHED RESOURCES
|
|
60
|
+
/**
|
|
61
|
+
* Attaches a resource. Attached resources are auto destroyed when this resource is destroyed
|
|
62
|
+
* Called automatically when sub resources are auto created but can be called by application
|
|
63
|
+
*/
|
|
64
|
+
attachResource(resource) {
|
|
65
|
+
this._attachedResources.add(resource);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Detach an attached resource. The resource will no longer be auto-destroyed when this resource is destroyed.
|
|
69
|
+
*/
|
|
70
|
+
detachResource(resource) {
|
|
71
|
+
this._attachedResources.delete(resource);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Destroys a resource (only if owned), and removes from the owned (auto-destroy) list for this resource.
|
|
75
|
+
*/
|
|
76
|
+
destroyAttachedResource(resource) {
|
|
77
|
+
if (this._attachedResources.delete(resource)) {
|
|
78
|
+
resource.destroy();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** Destroy all owned resources. Make sure the resources are no longer needed before calling. */
|
|
82
|
+
destroyAttachedResources() {
|
|
83
|
+
for (const resource of Object.values(this._attachedResources)) {
|
|
84
|
+
resource.destroy();
|
|
85
|
+
}
|
|
86
|
+
// don't remove while we are iterating
|
|
87
|
+
this._attachedResources = new Set();
|
|
88
|
+
}
|
|
89
|
+
// PROTECTED METHODS
|
|
90
|
+
/** Perform all destroy steps. Can be called by derived resources when overriding destroy() */
|
|
91
|
+
destroyResource() {
|
|
92
|
+
this.destroyAttachedResources();
|
|
93
|
+
this.removeStats();
|
|
94
|
+
this.destroyed = true;
|
|
95
|
+
}
|
|
96
|
+
/** Called by .destroy() to track object destruction. Subclass must call if overriding destroy() */
|
|
97
|
+
removeStats() {
|
|
98
|
+
const stats = this._device.statsManager.getStats('Resource Counts');
|
|
99
|
+
const name = this[Symbol.toStringTag];
|
|
100
|
+
stats.get(`${name}s Active`).decrementCount();
|
|
101
|
+
}
|
|
102
|
+
/** Called by subclass to track memory allocations */
|
|
103
|
+
trackAllocatedMemory(bytes, name = this[Symbol.toStringTag]) {
|
|
104
|
+
const stats = this._device.statsManager.getStats('Resource Counts');
|
|
105
|
+
stats.get('GPU Memory').addCount(bytes);
|
|
106
|
+
stats.get(`${name} Memory`).addCount(bytes);
|
|
107
|
+
this.allocatedBytes = bytes;
|
|
108
|
+
}
|
|
109
|
+
/** Called by subclass to track memory deallocations */
|
|
110
|
+
trackDeallocatedMemory(name = this[Symbol.toStringTag]) {
|
|
111
|
+
const stats = this._device.statsManager.getStats('Resource Counts');
|
|
112
|
+
stats.get('GPU Memory').subtractCount(this.allocatedBytes);
|
|
113
|
+
stats.get(`${name} Memory`).subtractCount(this.allocatedBytes);
|
|
114
|
+
this.allocatedBytes = 0;
|
|
115
|
+
}
|
|
116
|
+
/** Called by resource constructor to track object creation */
|
|
117
|
+
addStats() {
|
|
118
|
+
const stats = this._device.statsManager.getStats('Resource Counts');
|
|
119
|
+
const name = this[Symbol.toStringTag];
|
|
120
|
+
stats.get('Resources Created').incrementCount();
|
|
121
|
+
stats.get(`${name}s Created`).incrementCount();
|
|
122
|
+
stats.get(`${name}s Active`).incrementCount();
|
|
50
123
|
}
|
|
51
|
-
this._attachedResources = new Set();
|
|
52
|
-
}
|
|
53
|
-
destroyResource() {
|
|
54
|
-
this.destroyAttachedResources();
|
|
55
|
-
this.removeStats();
|
|
56
|
-
this.destroyed = true;
|
|
57
|
-
}
|
|
58
|
-
removeStats() {
|
|
59
|
-
const stats = this._device.statsManager.getStats('Resource Counts');
|
|
60
|
-
const name = this[Symbol.toStringTag];
|
|
61
|
-
stats.get(`${name}s Active`).decrementCount();
|
|
62
|
-
}
|
|
63
|
-
trackAllocatedMemory(bytes) {
|
|
64
|
-
let name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this[Symbol.toStringTag];
|
|
65
|
-
const stats = this._device.statsManager.getStats('Resource Counts');
|
|
66
|
-
stats.get('GPU Memory').addCount(bytes);
|
|
67
|
-
stats.get(`${name} Memory`).addCount(bytes);
|
|
68
|
-
this.allocatedBytes = bytes;
|
|
69
|
-
}
|
|
70
|
-
trackDeallocatedMemory() {
|
|
71
|
-
let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this[Symbol.toStringTag];
|
|
72
|
-
const stats = this._device.statsManager.getStats('Resource Counts');
|
|
73
|
-
stats.get('GPU Memory').subtractCount(this.allocatedBytes);
|
|
74
|
-
stats.get(`${name} Memory`).subtractCount(this.allocatedBytes);
|
|
75
|
-
this.allocatedBytes = 0;
|
|
76
|
-
}
|
|
77
|
-
addStats() {
|
|
78
|
-
const stats = this._device.statsManager.getStats('Resource Counts');
|
|
79
|
-
const name = this[Symbol.toStringTag];
|
|
80
|
-
stats.get('Resources Created').incrementCount();
|
|
81
|
-
stats.get(`${name}s Created`).incrementCount();
|
|
82
|
-
stats.get(`${name}s Active`).incrementCount();
|
|
83
|
-
}
|
|
84
124
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Combines a map of user props and default props, only including props from defaultProps
|
|
127
|
+
* @param props
|
|
128
|
+
* @param defaultProps
|
|
129
|
+
* @returns returns a map of overridden default props
|
|
130
|
+
*/
|
|
90
131
|
function selectivelyMerge(props, defaultProps) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
mergedProps[key] = props[key];
|
|
132
|
+
const mergedProps = { ...defaultProps };
|
|
133
|
+
for (const key in props) {
|
|
134
|
+
if (props[key] !== undefined) {
|
|
135
|
+
mergedProps[key] = props[key];
|
|
136
|
+
}
|
|
97
137
|
}
|
|
98
|
-
|
|
99
|
-
return mergedProps;
|
|
138
|
+
return mergedProps;
|
|
100
139
|
}
|
|
101
|
-
//# sourceMappingURL=resource.js.map
|