@luma.gl/engine 9.3.6 → 9.4.0-alpha.2
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/animation/animator.d.ts +42 -0
- package/dist/animation/animator.d.ts.map +1 -0
- package/dist/animation/animator.js +53 -0
- package/dist/animation/animator.js.map +1 -0
- package/dist/animation-loop/animation-loop.d.ts +14 -2
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +40 -22
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/animation-loop/animation-props.d.ts +2 -0
- package/dist/animation-loop/animation-props.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.d.ts +1 -0
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +3 -0
- package/dist/animation-loop/make-animation-loop.js.map +1 -1
- package/dist/application-utils/load-file.d.ts +2 -0
- package/dist/application-utils/load-file.d.ts.map +1 -1
- package/dist/application-utils/load-file.js +31 -5
- package/dist/application-utils/load-file.js.map +1 -1
- package/dist/compute/buffer-transform.d.ts +5 -1
- package/dist/compute/buffer-transform.d.ts.map +1 -1
- package/dist/compute/buffer-transform.js +7 -3
- package/dist/compute/buffer-transform.js.map +1 -1
- package/dist/compute/computation.d.ts +20 -8
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +34 -13
- package/dist/compute/computation.js.map +1 -1
- package/dist/compute/swap.d.ts.map +1 -1
- package/dist/compute/swap.js +17 -0
- package/dist/compute/swap.js.map +1 -1
- package/dist/dist.dev.js +4190 -2014
- package/dist/dist.min.js +288 -42
- package/dist/dynamic-buffer/dynamic-buffer.d.ts +171 -0
- package/dist/dynamic-buffer/dynamic-buffer.d.ts.map +1 -0
- package/dist/dynamic-buffer/dynamic-buffer.js +316 -0
- package/dist/dynamic-buffer/dynamic-buffer.js.map +1 -0
- package/dist/dynamic-texture/dynamic-texture.d.ts +14 -1
- package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -1
- package/dist/dynamic-texture/dynamic-texture.js +31 -2
- package/dist/dynamic-texture/dynamic-texture.js.map +1 -1
- package/dist/dynamic-texture/texture-binding-source.d.ts +55 -0
- package/dist/dynamic-texture/texture-binding-source.d.ts.map +1 -0
- package/dist/dynamic-texture/texture-binding-source.js +55 -0
- package/dist/dynamic-texture/texture-binding-source.js.map +1 -0
- package/dist/dynamic-texture/texture-data.d.ts +5 -3
- package/dist/dynamic-texture/texture-data.d.ts.map +1 -1
- package/dist/dynamic-texture/texture-data.js +5 -0
- package/dist/dynamic-texture/texture-data.js.map +1 -1
- package/dist/dynamic-texture/video-texture.d.ts +101 -0
- package/dist/dynamic-texture/video-texture.d.ts.map +1 -0
- package/dist/dynamic-texture/video-texture.js +272 -0
- package/dist/dynamic-texture/video-texture.js.map +1 -0
- package/dist/geometries/cube-geometry.d.ts +1 -0
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +22 -2
- package/dist/geometries/cube-geometry.js.map +1 -1
- package/dist/geometries/plane-geometry.d.ts +10 -0
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js.map +1 -1
- package/dist/geometry/geometry-utils.d.ts +36 -1
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +137 -2
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.d.ts +52 -33
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +70 -19
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts +37 -4
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-geometry.js +44 -36
- package/dist/geometry/gpu-geometry.js.map +1 -1
- package/dist/index.cjs +4045 -1975
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +22 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/material/material-factory.d.ts +2 -1
- package/dist/material/material-factory.d.ts.map +1 -1
- package/dist/material/material-factory.js.map +1 -1
- package/dist/material/material.d.ts +29 -10
- package/dist/material/material.d.ts.map +1 -1
- package/dist/material/material.js +84 -21
- package/dist/material/material.js.map +1 -1
- package/dist/model/model.d.ts +81 -23
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +312 -78
- package/dist/model/model.js.map +1 -1
- package/dist/model/split-uniforms-and-bindings.d.ts +5 -2
- package/dist/model/split-uniforms-and-bindings.d.ts.map +1 -1
- package/dist/model/split-uniforms-and-bindings.js.map +1 -1
- package/dist/models/billboard-texture-model.d.ts +5 -2
- package/dist/models/billboard-texture-model.d.ts.map +1 -1
- package/dist/models/billboard-texture-model.js +28 -10
- package/dist/models/billboard-texture-model.js.map +1 -1
- package/dist/modules/picking/index-color-picking.d.ts +24 -0
- package/dist/modules/picking/index-color-picking.d.ts.map +1 -0
- package/dist/modules/picking/index-color-picking.js +205 -0
- package/dist/modules/picking/index-color-picking.js.map +1 -0
- package/dist/modules/picking/index-picking.d.ts +3 -3
- package/dist/modules/picking/index-picking.d.ts.map +1 -1
- package/dist/modules/picking/index-picking.js +23 -6
- package/dist/modules/picking/index-picking.js.map +1 -1
- package/dist/modules/picking/picking-manager.d.ts +21 -0
- package/dist/modules/picking/picking-manager.d.ts.map +1 -1
- package/dist/modules/picking/picking-manager.js +100 -0
- package/dist/modules/picking/picking-manager.js.map +1 -1
- package/dist/modules/picking/picking-uniforms.d.ts +4 -4
- package/dist/modules/picking/picking-uniforms.d.ts.map +1 -1
- package/dist/modules/picking/picking-uniforms.js +3 -0
- package/dist/modules/picking/picking-uniforms.js.map +1 -1
- package/dist/modules/picking/picking.d.ts +5 -1
- package/dist/modules/picking/picking.d.ts.map +1 -1
- package/dist/modules/picking/picking.js +6 -0
- package/dist/modules/picking/picking.js.map +1 -1
- package/dist/passes/get-fragment-shader.js +4 -4
- package/dist/passes/shader-pass-renderer.d.ts +92 -25
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +467 -72
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- package/dist/passes/texture-transform-module.d.ts +10 -0
- package/dist/passes/texture-transform-module.d.ts.map +1 -0
- package/dist/passes/texture-transform-module.js +50 -0
- package/dist/passes/texture-transform-module.js.map +1 -0
- package/dist/scenegraph/group-node.d.ts +17 -1
- package/dist/scenegraph/group-node.d.ts.map +1 -1
- package/dist/scenegraph/group-node.js +29 -23
- package/dist/scenegraph/group-node.js.map +1 -1
- package/dist/scenegraph/model-node.d.ts +8 -2
- package/dist/scenegraph/model-node.d.ts.map +1 -1
- package/dist/scenegraph/model-node.js +15 -1
- package/dist/scenegraph/model-node.js.map +1 -1
- package/dist/scenegraph/scenegraph-bounds.d.ts +7 -0
- package/dist/scenegraph/scenegraph-bounds.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-bounds.js +25 -0
- package/dist/scenegraph/scenegraph-bounds.js.map +1 -0
- package/dist/shader-inputs.d.ts +33 -16
- package/dist/shader-inputs.d.ts.map +1 -1
- package/dist/shader-inputs.js +42 -12
- package/dist/shader-inputs.js.map +1 -1
- package/dist/utils/buffer-layout-helper.d.ts +0 -1
- package/dist/utils/buffer-layout-helper.d.ts.map +1 -1
- package/dist/utils/buffer-layout-helper.js +2 -11
- package/dist/utils/buffer-layout-helper.js.map +1 -1
- package/dist/utils/buffer-layout-order.d.ts.map +1 -1
- package/dist/utils/buffer-layout-order.js +4 -15
- package/dist/utils/buffer-layout-order.js.map +1 -1
- package/dist/utils/shader-module-utils.d.ts +2 -0
- package/dist/utils/shader-module-utils.d.ts.map +1 -1
- package/dist/utils/shader-module-utils.js +64 -3
- package/dist/utils/shader-module-utils.js.map +1 -1
- package/package.json +4 -4
- package/src/animation/animator.ts +79 -0
- package/src/animation-loop/animation-loop.ts +56 -22
- package/src/animation-loop/animation-props.ts +2 -0
- package/src/animation-loop/make-animation-loop.ts +4 -0
- package/src/application-utils/load-file.ts +38 -5
- package/src/compute/buffer-transform.ts +14 -5
- package/src/compute/computation.ts +53 -21
- package/src/compute/swap.ts +19 -0
- package/src/dynamic-buffer/dynamic-buffer.ts +453 -0
- package/src/dynamic-texture/dynamic-texture.ts +36 -3
- package/src/dynamic-texture/texture-binding-source.ts +94 -0
- package/src/dynamic-texture/texture-data.ts +12 -4
- package/src/dynamic-texture/video-texture.ts +334 -0
- package/src/geometries/cube-geometry.ts +24 -2
- package/src/geometries/plane-geometry.ts +10 -0
- package/src/geometry/geometry-utils.ts +209 -4
- package/src/geometry/geometry.ts +113 -36
- package/src/geometry/gpu-geometry.ts +61 -41
- package/src/index.ts +56 -14
- package/src/material/material-factory.ts +5 -1
- package/src/material/material.ts +123 -27
- package/src/model/model.ts +441 -102
- package/src/model/split-uniforms-and-bindings.ts +7 -3
- package/src/models/billboard-texture-model.ts +33 -12
- package/src/modules/picking/index-color-picking.ts +212 -0
- package/src/modules/picking/index-picking.ts +23 -6
- package/src/modules/picking/picking-manager.ts +141 -0
- package/src/modules/picking/picking-uniforms.ts +7 -4
- package/src/modules/picking/picking.ts +8 -0
- package/src/passes/get-fragment-shader.ts +4 -4
- package/src/passes/shader-pass-renderer.ts +692 -89
- package/src/passes/texture-transform-module.ts +52 -0
- package/src/scenegraph/group-node.ts +63 -26
- package/src/scenegraph/model-node.ts +32 -3
- package/src/scenegraph/scenegraph-bounds.ts +48 -0
- package/src/shader-inputs.ts +65 -17
- package/src/utils/buffer-layout-helper.ts +2 -14
- package/src/utils/buffer-layout-order.ts +14 -24
- package/src/utils/shader-module-utils.ts +109 -3
- package/dist/geometry/gpu-table.d.ts +0 -1
- package/dist/geometry/gpu-table.d.ts.map +0 -1
- package/dist/geometry/gpu-table.js +0 -46
- package/dist/geometry/gpu-table.js.map +0 -1
- package/src/dynamic-texture/texture-data.ts.disabled +0 -296
- package/src/geometry/gpu-table.ts +0 -45
|
@@ -7,6 +7,9 @@ import {getPassthroughFS} from '@luma.gl/shadertools';
|
|
|
7
7
|
import {Model} from '../model/model';
|
|
8
8
|
import type {ModelProps} from '../model/model';
|
|
9
9
|
|
|
10
|
+
const GL_INTERLEAVED_ATTRIBS = 0x8c8c;
|
|
11
|
+
const GL_SEPARATE_ATTRIBS = 0x8c8d;
|
|
12
|
+
|
|
10
13
|
/**
|
|
11
14
|
* Properties for creating a {@link BufferTransform}
|
|
12
15
|
* @note Only works under WebGL2.
|
|
@@ -14,6 +17,10 @@ import type {ModelProps} from '../model/model';
|
|
|
14
17
|
export type BufferTransformProps = Omit<ModelProps, 'fs'> & {
|
|
15
18
|
/** Optional fragment shader - normally not used in transforms */
|
|
16
19
|
fs?: ModelProps['fs']; // override as optional
|
|
20
|
+
/** bufferMode when binding varyings
|
|
21
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
|
|
22
|
+
*/
|
|
23
|
+
feedbackBufferMode?: 'interleaved' | 'separate';
|
|
17
24
|
/** A list of named outputs corresponding to shader declarations (varyings in WebGL) */
|
|
18
25
|
outputs?: string[];
|
|
19
26
|
/** @deprecated Use run({outputBuffers}) instead - Map of output buffers that the shaders will write results of computations to */
|
|
@@ -31,6 +38,7 @@ export class BufferTransform {
|
|
|
31
38
|
|
|
32
39
|
static defaultProps: Required<BufferTransformProps> = {
|
|
33
40
|
...Model.defaultProps,
|
|
41
|
+
feedbackBufferMode: 'separate',
|
|
34
42
|
outputs: undefined!,
|
|
35
43
|
feedbackBuffers: undefined!
|
|
36
44
|
};
|
|
@@ -51,7 +59,10 @@ export class BufferTransform {
|
|
|
51
59
|
fs: props.fs || getPassthroughFS(),
|
|
52
60
|
topology: props.topology || 'point-list',
|
|
53
61
|
varyings: props.outputs || props.varyings,
|
|
54
|
-
...props
|
|
62
|
+
...props,
|
|
63
|
+
bufferMode:
|
|
64
|
+
props.bufferMode ||
|
|
65
|
+
(props.feedbackBufferMode === 'interleaved' ? GL_INTERLEAVED_ATTRIBS : GL_SEPARATE_ATTRIBS)
|
|
55
66
|
});
|
|
56
67
|
|
|
57
68
|
this.transformFeedback = this.device.createTransformFeedback({
|
|
@@ -61,8 +72,6 @@ export class BufferTransform {
|
|
|
61
72
|
});
|
|
62
73
|
|
|
63
74
|
this.model.setTransformFeedback(this.transformFeedback);
|
|
64
|
-
|
|
65
|
-
Object.seal(this);
|
|
66
75
|
}
|
|
67
76
|
|
|
68
77
|
/** Destroy owned resources. */
|
|
@@ -81,7 +90,7 @@ export class BufferTransform {
|
|
|
81
90
|
run(
|
|
82
91
|
options?: RenderPassProps & {
|
|
83
92
|
inputBuffers?: Record<string, Buffer>;
|
|
84
|
-
outputBuffers?: Record<string, Buffer>;
|
|
93
|
+
outputBuffers?: Record<string, Buffer | BufferRange>;
|
|
85
94
|
}
|
|
86
95
|
): void {
|
|
87
96
|
if (options?.inputBuffers) {
|
|
@@ -90,7 +99,7 @@ export class BufferTransform {
|
|
|
90
99
|
if (options?.outputBuffers) {
|
|
91
100
|
this.transformFeedback.setBuffers(options.outputBuffers);
|
|
92
101
|
}
|
|
93
|
-
const renderPass = this.device.beginRenderPass(options);
|
|
102
|
+
const renderPass = this.device.beginRenderPass({discard: true, ...options});
|
|
94
103
|
this.model.draw(renderPass);
|
|
95
104
|
renderPass.end();
|
|
96
105
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type ComputePipelineProps,
|
|
8
8
|
type Shader,
|
|
9
9
|
type Binding,
|
|
10
|
+
type CommandEncoder,
|
|
10
11
|
Device,
|
|
11
12
|
Buffer,
|
|
12
13
|
ComputePipeline,
|
|
@@ -17,10 +18,18 @@ import {
|
|
|
17
18
|
log,
|
|
18
19
|
dataTypeDecoder
|
|
19
20
|
} from '@luma.gl/core';
|
|
20
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
type ShaderModule,
|
|
23
|
+
type ShaderPlugin,
|
|
24
|
+
type PlatformInfo,
|
|
25
|
+
mergeShaderPluginModules,
|
|
26
|
+
resolveShaderPlugins,
|
|
27
|
+
ShaderAssembler
|
|
28
|
+
} from '@luma.gl/shadertools';
|
|
21
29
|
import {type TypedArray, isNumericArray} from '@math.gl/types';
|
|
22
30
|
import {ShaderInputs} from '../shader-inputs';
|
|
23
31
|
import {
|
|
32
|
+
mergeShaderModules,
|
|
24
33
|
mergeShaderModuleBindingsIntoLayout,
|
|
25
34
|
shaderModuleHasUniforms
|
|
26
35
|
} from '../utils/shader-module-utils';
|
|
@@ -33,13 +42,14 @@ const LOG_DRAW_TIMEOUT = 10000;
|
|
|
33
42
|
export type ComputationProps = Omit<ComputePipelineProps, 'shader'> & {
|
|
34
43
|
source?: string;
|
|
35
44
|
|
|
36
|
-
/**
|
|
45
|
+
/** Shadertools shader modules added to shader code. */
|
|
37
46
|
modules?: ShaderModule[];
|
|
38
|
-
/**
|
|
39
|
-
defines?: Record<string, boolean>;
|
|
40
|
-
|
|
47
|
+
/** Shadertools boolean or numeric preprocessor defines that configure shader code. */
|
|
48
|
+
defines?: Record<string, boolean | number>;
|
|
49
|
+
/** Reusable shader assembly plugins resolved for WGSL compute assembly. */
|
|
50
|
+
plugins?: ShaderPlugin[];
|
|
41
51
|
|
|
42
|
-
/** Shader inputs, used to
|
|
52
|
+
/** Shader inputs, used to generate uniform buffers and bindings. */
|
|
43
53
|
shaderInputs?: ShaderInputs;
|
|
44
54
|
|
|
45
55
|
/** Bindings */
|
|
@@ -74,6 +84,7 @@ export class Computation {
|
|
|
74
84
|
source: '',
|
|
75
85
|
modules: [],
|
|
76
86
|
defines: {},
|
|
87
|
+
plugins: [],
|
|
77
88
|
|
|
78
89
|
bindings: undefined!,
|
|
79
90
|
shaderInputs: undefined!,
|
|
@@ -129,20 +140,31 @@ export class Computation {
|
|
|
129
140
|
|
|
130
141
|
Object.assign(this.userData, props.userData);
|
|
131
142
|
|
|
143
|
+
const platformInfo = getPlatformInfo(device);
|
|
144
|
+
const resolvedPlugins = resolveShaderPlugins(this.props.plugins, platformInfo.shaderLanguage);
|
|
145
|
+
if (
|
|
146
|
+
Object.keys(resolvedPlugins.vertexInputs).length > 0 ||
|
|
147
|
+
Object.keys(resolvedPlugins.varyings).length > 0
|
|
148
|
+
) {
|
|
149
|
+
throw new Error('Computation does not support ShaderPlugin vertex inputs or varyings');
|
|
150
|
+
}
|
|
151
|
+
|
|
132
152
|
// Setup shader module inputs
|
|
133
|
-
const
|
|
134
|
-
this.props.modules
|
|
153
|
+
const shaderInputModules = mergeShaderPluginModules(
|
|
154
|
+
this.props.modules,
|
|
155
|
+
resolvedPlugins.modules
|
|
135
156
|
);
|
|
157
|
+
const moduleMap = Object.fromEntries(shaderInputModules.map(module => [module.name, module]));
|
|
136
158
|
// @ts-ignore TODO - fix up typing?
|
|
137
159
|
this.shaderInputs = props.shaderInputs || new ShaderInputs(moduleMap);
|
|
160
|
+
if (props.shaderInputs && resolvedPlugins.modules.length > 0) {
|
|
161
|
+
this.shaderInputs.addModules(resolvedPlugins.modules);
|
|
162
|
+
}
|
|
138
163
|
this.setShaderInputs(this.shaderInputs);
|
|
139
164
|
|
|
140
165
|
// Setup shader assembler
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
// Extract modules from shader inputs if not supplied
|
|
144
|
-
const modules =
|
|
145
|
-
(this.props.modules?.length > 0 ? this.props.modules : this.shaderInputs?.getModules()) || [];
|
|
166
|
+
const modules = mergeShaderModules(this.props.modules, this.shaderInputs?.getModules());
|
|
167
|
+
const defines = {...resolvedPlugins.defines, ...this.props.defines};
|
|
146
168
|
|
|
147
169
|
this.props.shaderLayout =
|
|
148
170
|
mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
@@ -154,7 +176,9 @@ export class Computation {
|
|
|
154
176
|
const {source, getUniforms} = this.props.shaderAssembler.assembleWGSLShader({
|
|
155
177
|
platformInfo,
|
|
156
178
|
...this.props,
|
|
157
|
-
modules
|
|
179
|
+
modules,
|
|
180
|
+
defines,
|
|
181
|
+
pluginInjections: resolvedPlugins.injections
|
|
158
182
|
});
|
|
159
183
|
|
|
160
184
|
this.source = source;
|
|
@@ -177,9 +201,6 @@ export class Computation {
|
|
|
177
201
|
if (props.bindings) {
|
|
178
202
|
this.setBindings(props.bindings);
|
|
179
203
|
}
|
|
180
|
-
|
|
181
|
-
// Catch any access to non-standard props
|
|
182
|
-
Object.seal(this);
|
|
183
204
|
}
|
|
184
205
|
|
|
185
206
|
destroy(): void {
|
|
@@ -192,9 +213,13 @@ export class Computation {
|
|
|
192
213
|
|
|
193
214
|
// Draw call
|
|
194
215
|
|
|
195
|
-
|
|
216
|
+
/**
|
|
217
|
+
* Updates compute shader inputs before opening the compute pass that will
|
|
218
|
+
* consume them.
|
|
219
|
+
*/
|
|
220
|
+
predraw(commandEncoder: CommandEncoder) {
|
|
196
221
|
// Update uniform buffers if needed
|
|
197
|
-
this.updateShaderInputs();
|
|
222
|
+
this.updateShaderInputs(commandEncoder);
|
|
198
223
|
}
|
|
199
224
|
|
|
200
225
|
dispatch(computePass: ComputePass, x: number, y?: number, z?: number): void {
|
|
@@ -271,8 +296,14 @@ export class Computation {
|
|
|
271
296
|
}
|
|
272
297
|
}
|
|
273
298
|
|
|
274
|
-
|
|
275
|
-
|
|
299
|
+
/**
|
|
300
|
+
* Flushes current shader-input values into the internal uniform store.
|
|
301
|
+
*
|
|
302
|
+
* @param commandEncoder - Optional encoder used to order uniform uploads with
|
|
303
|
+
* subsequent compute commands.
|
|
304
|
+
*/
|
|
305
|
+
updateShaderInputs(commandEncoder?: CommandEncoder): void {
|
|
306
|
+
this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(), commandEncoder);
|
|
276
307
|
}
|
|
277
308
|
|
|
278
309
|
/**
|
|
@@ -369,6 +400,7 @@ export function getPlatformInfo(device: Device): PlatformInfo {
|
|
|
369
400
|
shaderLanguage: device.info.shadingLanguage,
|
|
370
401
|
shaderLanguageVersion: device.info.shadingLanguageVersion as 100 | 300,
|
|
371
402
|
gpu: device.info.gpu,
|
|
403
|
+
limits: device.limits as unknown as Record<string, number | undefined>,
|
|
372
404
|
// HACK - we pretend that the DeviceFeatures is a Set, it has a similar API
|
|
373
405
|
features: device.features as unknown as Set<DeviceFeature>
|
|
374
406
|
};
|
package/src/compute/swap.ts
CHANGED
|
@@ -75,6 +75,13 @@ export class SwapFramebuffers extends Swap<Framebuffer> {
|
|
|
75
75
|
const next = device.createFramebuffer({...props, colorAttachments});
|
|
76
76
|
|
|
77
77
|
super({current, next});
|
|
78
|
+
|
|
79
|
+
for (const [index, colorAttachment] of (props.colorAttachments || []).entries()) {
|
|
80
|
+
if (typeof colorAttachment === 'string') {
|
|
81
|
+
current.attachResource(current.colorAttachments[index].texture);
|
|
82
|
+
next.attachResource(next.colorAttachments[index].texture);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
78
85
|
}
|
|
79
86
|
|
|
80
87
|
/**
|
|
@@ -89,15 +96,27 @@ export class SwapFramebuffers extends Swap<Framebuffer> {
|
|
|
89
96
|
const {current, next} = this;
|
|
90
97
|
|
|
91
98
|
this.current = current.clone(size);
|
|
99
|
+
attachFramebufferAttachments(this.current);
|
|
92
100
|
current.destroy();
|
|
93
101
|
|
|
94
102
|
this.next = next.clone(size);
|
|
103
|
+
attachFramebufferAttachments(this.next);
|
|
95
104
|
next.destroy();
|
|
96
105
|
|
|
97
106
|
return true;
|
|
98
107
|
}
|
|
99
108
|
}
|
|
100
109
|
|
|
110
|
+
/** Framebuffer.clone() creates fresh attachments that the replacement framebuffer must own. */
|
|
111
|
+
function attachFramebufferAttachments(framebuffer: Framebuffer): void {
|
|
112
|
+
for (const colorAttachment of framebuffer.colorAttachments) {
|
|
113
|
+
framebuffer.attachResource(colorAttachment.texture);
|
|
114
|
+
}
|
|
115
|
+
if (framebuffer.depthStencilAttachment) {
|
|
116
|
+
framebuffer.attachResource(framebuffer.depthStencilAttachment.texture);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
101
120
|
/** Helper for managing double-buffered GPU buffers */
|
|
102
121
|
export class SwapBuffers extends Swap<Buffer> {
|
|
103
122
|
constructor(device: Device, props: BufferProps) {
|