@zephyr3d/scene 0.9.1 → 0.9.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/animationset.js +135 -133
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/cloth/gpu_cloth_system.js +9 -1
- package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
- package/dist/animation/fixed_geometry_cache_track.js +5 -1
- package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
- package/dist/animation/geometry_cache_utils.js +20 -4
- package/dist/animation/geometry_cache_utils.js.map +1 -1
- package/dist/animation/ik/ik_angle_constraint.js +2 -6
- package/dist/animation/ik/ik_angle_constraint.js.map +1 -1
- package/dist/animation/ik/two_bone_ik_solver.js +2 -6
- package/dist/animation/ik/two_bone_ik_solver.js.map +1 -1
- package/dist/animation/joint_dynamics/collision.js +60 -12
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/constraints.js +20 -4
- package/dist/animation/joint_dynamics/constraints.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +151 -103
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +21 -11
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js +15 -3
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/pca_geometry_cache_track.js +5 -1
- package/dist/animation/pca_geometry_cache_track.js.map +1 -1
- package/dist/animation/skeleton.js +2 -2
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js +2 -6
- package/dist/animation/skeleton_modifier.js.map +1 -1
- package/dist/animation/spring/spring_system.js +87 -114
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/app/app.js.map +1 -1
- package/dist/app/engine.js +1 -1
- package/dist/app/engine.js.map +1 -1
- package/dist/app/screen.js +4 -4
- package/dist/app/screen.js.map +1 -1
- package/dist/app/scriptingsystem.js +24 -1
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +22 -1
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +2 -2
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/model.js +3 -3
- package/dist/asset/model.js.map +1 -1
- package/dist/camera/camera.js +185 -185
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/orbit.js.map +1 -1
- package/dist/index.d.ts +794 -261
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/material/material.js +290 -288
- package/dist/material/material.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/sprite.js +6 -6
- package/dist/material/sprite.js.map +1 -1
- package/dist/material/terrain-cm.js +2 -2
- package/dist/material/terrain-cm.js.map +1 -1
- package/dist/posteffect/taa.js +31 -39
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/drawable.js +5 -1
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/rendergraph/device_pool_allocator.js +29 -3
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/executor.js +283 -33
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +338 -108
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +236 -156
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +10 -0
- package/dist/render/rendergraph/history_resources.js.map +1 -0
- package/dist/render/rendergraph/rendergraph.js +162 -35
- package/dist/render/rendergraph/rendergraph.js.map +1 -1
- package/dist/render/rendergraph/types.js +36 -16
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/rendertarget.js +5 -1
- package/dist/render/rendertarget.js.map +1 -1
- package/dist/render/screenrendertarget.js +5 -1
- package/dist/render/screenrendertarget.js.map +1 -1
- package/dist/render/sky.js +4 -4
- package/dist/render/sky.js.map +1 -1
- package/dist/scene/basesprite.js +2 -2
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/graph_node.js +1 -1
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/mesh.js +4 -20
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/particlesys.js +1 -1
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene_node.js +2 -2
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/script_attachment.js +15 -3
- package/dist/scene/script_attachment.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +3 -3
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shapes/box.js +1 -1
- package/dist/shapes/box.js.map +1 -1
- package/dist/shapes/capsule.js +0 -3
- package/dist/shapes/capsule.js.map +1 -1
- package/dist/shapes/cylinder.js +0 -3
- package/dist/shapes/cylinder.js.map +1 -1
- package/dist/shapes/plane.js +0 -3
- package/dist/shapes/plane.js.map +1 -1
- package/dist/shapes/tetrahedron.js +3 -9
- package/dist/shapes/tetrahedron.js.map +1 -1
- package/dist/shapes/torus.js +4 -7
- package/dist/shapes/torus.js.map +1 -1
- package/dist/utility/blueprint/material/inputs.js +3 -3
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +493 -493
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/serialization/manager.js +34 -3
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +45 -0
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +53 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +10 -0
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +30 -0
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +63 -0
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +11 -0
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/misc.js +2 -0
- package/dist/utility/serialization/scene/misc.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +19 -0
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +22 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +33 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +39 -0
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/script.js +2 -0
- package/dist/utility/serialization/scene/script.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +6 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +9 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +21 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js +5 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RGHandle, RGPass, RGResource } from './types.js';
|
|
1
|
+
import { RGHandle, RGPass, RGResource, RGSubpass } from './types.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Render Graph — declarative, configurable render pipeline.
|
|
@@ -6,7 +6,7 @@ import { RGHandle, RGPass, RGResource } from './types.js';
|
|
|
6
6
|
* Usage:
|
|
7
7
|
* ```ts
|
|
8
8
|
* const graph = new RenderGraph();
|
|
9
|
-
*
|
|
9
|
+
* let backbuffer = graph.importTexture('backbuffer');
|
|
10
10
|
*
|
|
11
11
|
* let linearDepth: RGHandle;
|
|
12
12
|
* graph.addPass('DepthPrepass', (builder) => {
|
|
@@ -16,7 +16,7 @@ import { RGHandle, RGPass, RGResource } from './types.js';
|
|
|
16
16
|
*
|
|
17
17
|
* graph.addPass('LightPass', (builder) => {
|
|
18
18
|
* builder.read(linearDepth);
|
|
19
|
-
* builder.write(backbuffer);
|
|
19
|
+
* backbuffer = builder.write(backbuffer);
|
|
20
20
|
* builder.setExecute(() => { ... });
|
|
21
21
|
* });
|
|
22
22
|
*
|
|
@@ -72,13 +72,13 @@ import { RGHandle, RGPass, RGResource } from './types.js';
|
|
|
72
72
|
* Performs dead-pass culling, topological sorting, and resource lifetime analysis.
|
|
73
73
|
*
|
|
74
74
|
* @param outputs - Handles of resources that must be produced (graph sinks).
|
|
75
|
+
* If a resource was passed to {@link RGPassBuilder.write}, use the returned
|
|
76
|
+
* post-write handle here, not the original handle.
|
|
75
77
|
* Passes that do not contribute to these outputs (directly or transitively)
|
|
76
78
|
* are culled, unless marked as side-effect passes.
|
|
77
79
|
* @returns The compiled graph ready for execution.
|
|
78
80
|
*/ compile(outputs) {
|
|
79
|
-
|
|
80
|
-
return this._compiled;
|
|
81
|
-
}
|
|
81
|
+
this._validateOutputs(outputs);
|
|
82
82
|
// 1. Mark alive passes via backward traversal from outputs + side-effect passes
|
|
83
83
|
this._cullDeadPasses(outputs);
|
|
84
84
|
// 2. Topological sort of alive passes
|
|
@@ -96,15 +96,28 @@ import { RGHandle, RGPass, RGResource } from './types.js';
|
|
|
96
96
|
*
|
|
97
97
|
* For automatic resource allocation/release, use {@link RenderGraphExecutor} instead.
|
|
98
98
|
*
|
|
99
|
-
* @param compiled - The compiled graph from {@link compile}.
|
|
99
|
+
* @param compiled - The compiled graph from {@link RenderGraph.compile}.
|
|
100
100
|
*/ execute(compiled) {
|
|
101
101
|
const noopCtx = {
|
|
102
102
|
getTexture () {
|
|
103
103
|
throw new Error('RenderGraph.execute(): resource resolution not available. Use RenderGraphExecutor for managed execution.');
|
|
104
|
+
},
|
|
105
|
+
getFramebuffer () {
|
|
106
|
+
throw new Error('RenderGraph.execute(): framebuffer resolution not available. Use RenderGraphExecutor for managed execution.');
|
|
107
|
+
},
|
|
108
|
+
createFramebuffer () {
|
|
109
|
+
throw new Error('RenderGraph.execute(): framebuffer allocation not available. Use RenderGraphExecutor for managed execution.');
|
|
110
|
+
},
|
|
111
|
+
deferCleanup () {
|
|
112
|
+
// No-op in unmanaged execution mode.
|
|
104
113
|
}
|
|
105
114
|
};
|
|
106
115
|
for (const pass of compiled.orderedPasses){
|
|
107
|
-
if (pass.
|
|
116
|
+
if (pass.subpasses.length > 0) {
|
|
117
|
+
for (const subpass of pass.subpasses){
|
|
118
|
+
subpass.executeFn(noopCtx, pass.data);
|
|
119
|
+
}
|
|
120
|
+
} else if (pass.executeFn) {
|
|
108
121
|
pass.executeFn(noopCtx, pass.data);
|
|
109
122
|
}
|
|
110
123
|
}
|
|
@@ -143,19 +156,41 @@ import { RGHandle, RGPass, RGResource } from './types.js';
|
|
|
143
156
|
if (res.kind === 'transient' && !res.producer) {
|
|
144
157
|
throw new Error(`RenderGraph: pass "${pass.name}" attempts to read transient resource "${res.name}" ` + `which has no producer. Ensure the resource is created before being read.`);
|
|
145
158
|
}
|
|
146
|
-
pass.reads.
|
|
147
|
-
|
|
159
|
+
if (!pass.reads.includes(res)) {
|
|
160
|
+
pass.reads.push(res);
|
|
161
|
+
}
|
|
162
|
+
if (!res.consumers.includes(pass)) {
|
|
163
|
+
res.consumers.push(pass);
|
|
164
|
+
}
|
|
148
165
|
},
|
|
149
166
|
write (handle) {
|
|
150
167
|
const res = graph._resources.get(handle._id);
|
|
151
168
|
if (!res) {
|
|
152
169
|
throw new Error(`RenderGraph: unknown resource "${handle.name}" (id=${handle._id})`);
|
|
153
170
|
}
|
|
154
|
-
if (res.
|
|
155
|
-
throw new Error(`RenderGraph:
|
|
171
|
+
if (res.kind === 'token') {
|
|
172
|
+
throw new Error(`RenderGraph: pass "${pass.name}" attempts to write token "${res.name}". ` + `Use createToken() to produce ordering tokens.`);
|
|
156
173
|
}
|
|
157
|
-
res.
|
|
158
|
-
|
|
174
|
+
if (res.kind === 'framebuffer') {
|
|
175
|
+
throw new Error(`RenderGraph: pass "${pass.name}" attempts to write framebuffer "${res.name}". ` + `Create a new framebuffer view instead.`);
|
|
176
|
+
}
|
|
177
|
+
for (const consumer of res.consumers){
|
|
178
|
+
if (consumer !== pass && !pass.dependencies.includes(consumer)) {
|
|
179
|
+
pass.dependencies.push(consumer);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (res.producer && res.producer !== pass && !pass.dependencies.includes(res.producer)) {
|
|
183
|
+
pass.dependencies.push(res.producer);
|
|
184
|
+
}
|
|
185
|
+
const id = graph._nextResourceId++;
|
|
186
|
+
const versionName = `${res.name}@${pass.name}`;
|
|
187
|
+
const version = new RGResource(id, versionName, res.kind, res.desc, res.physicalId);
|
|
188
|
+
version.producer = pass;
|
|
189
|
+
graph._resources.set(id, version);
|
|
190
|
+
if (!pass.writes.includes(version)) {
|
|
191
|
+
pass.writes.push(version);
|
|
192
|
+
}
|
|
193
|
+
return new RGHandle(id, versionName);
|
|
159
194
|
},
|
|
160
195
|
createTexture (desc) {
|
|
161
196
|
const id = graph._nextResourceId++;
|
|
@@ -166,15 +201,62 @@ import { RGHandle, RGPass, RGResource } from './types.js';
|
|
|
166
201
|
pass.writes.push(res);
|
|
167
202
|
return new RGHandle(id, name);
|
|
168
203
|
},
|
|
204
|
+
createToken (name) {
|
|
205
|
+
const id = graph._nextResourceId++;
|
|
206
|
+
const tokenName = name ?? `_token_${id}`;
|
|
207
|
+
const res = new RGResource(id, tokenName, 'token', null);
|
|
208
|
+
res.producer = pass;
|
|
209
|
+
graph._resources.set(id, res);
|
|
210
|
+
pass.writes.push(res);
|
|
211
|
+
return new RGHandle(id, tokenName);
|
|
212
|
+
},
|
|
213
|
+
createFramebuffer (desc) {
|
|
214
|
+
const id = graph._nextResourceId++;
|
|
215
|
+
const name = desc.label ?? `_fb_${id}`;
|
|
216
|
+
const res = new RGResource(id, name, 'framebuffer', desc);
|
|
217
|
+
res.producer = pass;
|
|
218
|
+
graph._resources.set(id, res);
|
|
219
|
+
pass.writes.push(res);
|
|
220
|
+
graph._declareFramebufferAttachmentDeps(pass, desc);
|
|
221
|
+
return new RGHandle(id, name);
|
|
222
|
+
},
|
|
169
223
|
sideEffect () {
|
|
170
224
|
pass.hasSideEffect = true;
|
|
171
225
|
},
|
|
226
|
+
addSubpass (name, fn) {
|
|
227
|
+
if (pass.executeFn) {
|
|
228
|
+
throw new Error(`RenderGraph: pass "${pass.name}" cannot use addSubpass() after setExecute(). ` + `Use either subpasses or a single execute callback.`);
|
|
229
|
+
}
|
|
230
|
+
pass.subpasses.push(new RGSubpass(name, fn));
|
|
231
|
+
},
|
|
172
232
|
setExecute (fn) {
|
|
233
|
+
if (pass.subpasses.length > 0) {
|
|
234
|
+
throw new Error(`RenderGraph: pass "${pass.name}" cannot use setExecute() after addSubpass(). ` + `Use either subpasses or a single execute callback.`);
|
|
235
|
+
}
|
|
173
236
|
pass.executeFn = fn;
|
|
174
237
|
}
|
|
175
238
|
};
|
|
176
239
|
}
|
|
177
240
|
// ─── Private: Dead Pass Culling ─────────────────────────────────────
|
|
241
|
+
/** @internal */ _validateOutputs(outputs) {
|
|
242
|
+
const latestVersions = new Map();
|
|
243
|
+
for (const res of this._resources.values()){
|
|
244
|
+
const current = latestVersions.get(res.physicalId);
|
|
245
|
+
if (!current || res.id > current.id) {
|
|
246
|
+
latestVersions.set(res.physicalId, res);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
for (const handle of outputs){
|
|
250
|
+
const res = this._resources.get(handle._id);
|
|
251
|
+
if (!res) {
|
|
252
|
+
throw new Error(`RenderGraph: unknown output resource "${handle.name}" (id=${handle._id})`);
|
|
253
|
+
}
|
|
254
|
+
const latest = latestVersions.get(res.physicalId);
|
|
255
|
+
if (latest && latest.id !== res.id) {
|
|
256
|
+
throw new Error(`RenderGraph: output resource "${res.name}" (id=${res.id}) is not the latest version. ` + `Use the handle returned by builder.write(); latest is "${latest.name}" (id=${latest.id}).`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
178
260
|
/** @internal */ _cullDeadPasses(outputs) {
|
|
179
261
|
// Start with all passes marked dead
|
|
180
262
|
for (const pass of this._passes){
|
|
@@ -183,23 +265,35 @@ import { RGHandle, RGPass, RGResource } from './types.js';
|
|
|
183
265
|
// Seed: resources that are requested outputs
|
|
184
266
|
const neededResources = new Set();
|
|
185
267
|
const stack = [];
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (res) {
|
|
268
|
+
const markResourceNeeded = (res)=>{
|
|
269
|
+
if (!neededResources.has(res.id)) {
|
|
189
270
|
neededResources.add(res.id);
|
|
190
271
|
stack.push(res);
|
|
191
272
|
}
|
|
273
|
+
};
|
|
274
|
+
const markPassAlive = (pass)=>{
|
|
275
|
+
if (pass.alive) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
pass.alive = true;
|
|
279
|
+
for (const dep of pass.reads){
|
|
280
|
+
markResourceNeeded(dep);
|
|
281
|
+
}
|
|
282
|
+
for (const dependency of pass.dependencies){
|
|
283
|
+
markPassAlive(dependency);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
for (const handle of outputs){
|
|
287
|
+
const res = this._resources.get(handle._id);
|
|
288
|
+
if (!res) {
|
|
289
|
+
throw new Error(`RenderGraph: unknown output resource "${handle.name}" (id=${handle._id})`);
|
|
290
|
+
}
|
|
291
|
+
markResourceNeeded(res);
|
|
192
292
|
}
|
|
193
293
|
// Seed: side-effect passes (always alive) — push their read dependencies
|
|
194
294
|
for (const pass of this._passes){
|
|
195
295
|
if (pass.hasSideEffect) {
|
|
196
|
-
pass
|
|
197
|
-
for (const res of pass.reads){
|
|
198
|
-
if (!neededResources.has(res.id)) {
|
|
199
|
-
neededResources.add(res.id);
|
|
200
|
-
stack.push(res);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
296
|
+
markPassAlive(pass);
|
|
203
297
|
}
|
|
204
298
|
}
|
|
205
299
|
// Backward traversal: for each needed resource, mark its producer alive
|
|
@@ -207,16 +301,38 @@ import { RGHandle, RGPass, RGResource } from './types.js';
|
|
|
207
301
|
while(stack.length > 0){
|
|
208
302
|
const res = stack.pop();
|
|
209
303
|
const producer = res.producer;
|
|
210
|
-
if (producer
|
|
211
|
-
producer
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
304
|
+
if (producer) {
|
|
305
|
+
markPassAlive(producer);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/** @internal */ _declareFramebufferAttachmentDeps(pass, desc) {
|
|
310
|
+
const declare = (attachment)=>{
|
|
311
|
+
if (attachment instanceof RGHandle) {
|
|
312
|
+
const res = this._resources.get(attachment._id);
|
|
313
|
+
if (!res) {
|
|
314
|
+
throw new Error(`RenderGraph: unknown framebuffer attachment "${attachment.name}" (id=${attachment._id})`);
|
|
315
|
+
}
|
|
316
|
+
if (res.kind !== 'transient' && res.kind !== 'imported') {
|
|
317
|
+
throw new Error(`RenderGraph: framebuffer attachment "${res.name}" must be a texture resource, got ${res.kind}.`);
|
|
318
|
+
}
|
|
319
|
+
if (res.producer !== pass) {
|
|
320
|
+
if (!pass.reads.includes(res)) {
|
|
321
|
+
pass.reads.push(res);
|
|
322
|
+
}
|
|
323
|
+
if (!res.consumers.includes(pass)) {
|
|
324
|
+
res.consumers.push(pass);
|
|
216
325
|
}
|
|
217
326
|
}
|
|
218
327
|
}
|
|
328
|
+
};
|
|
329
|
+
const colors = Array.isArray(desc.colorAttachments) ? desc.colorAttachments : desc.colorAttachments ? [
|
|
330
|
+
desc.colorAttachments
|
|
331
|
+
] : [];
|
|
332
|
+
for (const attachment of colors){
|
|
333
|
+
declare(attachment);
|
|
219
334
|
}
|
|
335
|
+
declare(desc.depthAttachment);
|
|
220
336
|
}
|
|
221
337
|
// ─── Private: Topological Sort (Kahn's Algorithm) ───────────────────
|
|
222
338
|
/** @internal */ _topologicalSort() {
|
|
@@ -232,17 +348,28 @@ import { RGHandle, RGPass, RGResource } from './types.js';
|
|
|
232
348
|
inDegree.set(pass, 0);
|
|
233
349
|
adjacency.set(pass, []);
|
|
234
350
|
}
|
|
351
|
+
const addEdge = (from, to)=>{
|
|
352
|
+
if (from === to || !aliveSet.has(from) || !aliveSet.has(to)) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
const neighbors = adjacency.get(from);
|
|
356
|
+
if (!neighbors.includes(to)) {
|
|
357
|
+
neighbors.push(to);
|
|
358
|
+
inDegree.set(to, inDegree.get(to) + 1);
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
for (const pass of alivePasses){
|
|
362
|
+
for (const dependency of pass.dependencies){
|
|
363
|
+
addEdge(dependency, pass);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
235
366
|
// For each resource, its producer has an edge to each of its consumers
|
|
236
367
|
for (const res of this._resources.values()){
|
|
237
368
|
if (!res.producer || !aliveSet.has(res.producer)) {
|
|
238
369
|
continue;
|
|
239
370
|
}
|
|
240
371
|
for (const consumer of res.consumers){
|
|
241
|
-
|
|
242
|
-
continue;
|
|
243
|
-
}
|
|
244
|
-
adjacency.get(res.producer).push(consumer);
|
|
245
|
-
inDegree.set(consumer, inDegree.get(consumer) + 1);
|
|
372
|
+
addEdge(res.producer, consumer);
|
|
246
373
|
}
|
|
247
374
|
}
|
|
248
375
|
// Kahn's algorithm
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rendergraph.js","sources":["../../../src/render/rendergraph/rendergraph.ts"],"sourcesContent":["import {\r\n RGHandle,\r\n RGResource,\r\n RGPass,\r\n type RGTextureDesc,\r\n type RGPassBuilder,\r\n type RGExecuteFn,\r\n type RGExecuteContext,\r\n type CompiledRenderGraph,\r\n type RGResourceLifetime\r\n} from './types';\r\n\r\n/**\r\n * Render Graph — declarative, configurable render pipeline.\r\n *\r\n * Usage:\r\n * ```ts\r\n * const graph = new RenderGraph();\r\n * const backbuffer = graph.importTexture('backbuffer');\r\n *\r\n * let linearDepth: RGHandle;\r\n * graph.addPass('DepthPrepass', (builder) => {\r\n * linearDepth = builder.createTexture({ format: 'r32f', label: 'linearDepth' });\r\n * builder.setExecute(() => { ... });\r\n * });\r\n *\r\n * graph.addPass('LightPass', (builder) => {\r\n * builder.read(linearDepth);\r\n * builder.write(backbuffer);\r\n * builder.setExecute(() => { ... });\r\n * });\r\n *\r\n * const compiled = graph.compile([backbuffer]);\r\n * graph.execute(compiled);\r\n * graph.reset();\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class RenderGraph {\r\n /** @internal */\r\n private _nextResourceId = 0;\r\n /** @internal */\r\n private _resources: Map<number, RGResource> = new Map();\r\n /** @internal */\r\n private _passes: RGPass[] = [];\r\n /** @internal */\r\n private _compiled: CompiledRenderGraph | null = null;\r\n\r\n // ─── Graph Building ─────────────────────────────────────────────────\r\n\r\n /**\r\n * Import an external (persistent) texture into the graph.\r\n *\r\n * Imported resources are not allocated or released by the graph.\r\n * Typically used for the backbuffer or any texture that outlives a single frame.\r\n *\r\n * @param name - Debug label for the imported resource.\r\n * @returns A handle referencing the imported resource.\r\n */\r\n importTexture(name: string): RGHandle {\r\n const id = this._nextResourceId++;\r\n const resource = new RGResource(id, name, 'imported', null);\r\n this._resources.set(id, resource);\r\n this._compiled = null;\r\n return new RGHandle(id, name);\r\n }\r\n\r\n /**\r\n * Add a render pass to the graph.\r\n *\r\n * The setup callback receives a {@link RGPassBuilder} to declare resource\r\n * dependencies. Call `builder.setExecute(fn)` inside setup to provide the\r\n * execution callback.\r\n *\r\n * @param name - Debug label for the pass.\r\n * @param setup - Setup callback that declares resources and sets the execute function.\r\n */\r\n addPass<T = void>(name: string, setup: (builder: RGPassBuilder) => T): T {\r\n const pass = new RGPass(this._passes.length, name);\r\n const builder = this._createBuilder(pass);\r\n const data = setup(builder);\r\n pass.data = data;\r\n this._passes.push(pass);\r\n this._compiled = null;\r\n return data;\r\n }\r\n\r\n // ─── Compilation ────────────────────────────────────────────────────\r\n\r\n /**\r\n * Compile the render graph.\r\n *\r\n * Performs dead-pass culling, topological sorting, and resource lifetime analysis.\r\n *\r\n * @param outputs - Handles of resources that must be produced (graph sinks).\r\n * Passes that do not contribute to these outputs (directly or transitively)\r\n * are culled, unless marked as side-effect passes.\r\n * @returns The compiled graph ready for execution.\r\n */\r\n compile(outputs: RGHandle[]): CompiledRenderGraph {\r\n if (this._compiled) {\r\n return this._compiled;\r\n }\r\n // 1. Mark alive passes via backward traversal from outputs + side-effect passes\r\n this._cullDeadPasses(outputs);\r\n // 2. Topological sort of alive passes\r\n const ordered = this._topologicalSort();\r\n // 3. Resource lifetime analysis\r\n const lifetimes = this._analyzeLifetimes(ordered);\r\n\r\n this._compiled = { orderedPasses: ordered, lifetimes };\r\n return this._compiled;\r\n }\r\n\r\n /**\r\n * Execute a compiled render graph (simple mode, no resource management).\r\n *\r\n * For automatic resource allocation/release, use {@link RenderGraphExecutor} instead.\r\n *\r\n * @param compiled - The compiled graph from {@link compile}.\r\n */\r\n execute(compiled: CompiledRenderGraph): void {\r\n const noopCtx: RGExecuteContext = {\r\n getTexture() {\r\n throw new Error(\r\n 'RenderGraph.execute(): resource resolution not available. Use RenderGraphExecutor for managed execution.'\r\n );\r\n }\r\n };\r\n for (const pass of compiled.orderedPasses) {\r\n if (pass.executeFn) {\r\n (pass.executeFn as RGExecuteFn<unknown>)(noopCtx, pass.data);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Reset the graph for the next frame.\r\n *\r\n * Clears all passes, transient resources, and compiled state.\r\n * Imported resources are also cleared — re-import them each frame.\r\n */\r\n reset(): void {\r\n this._passes.length = 0;\r\n this._resources.clear();\r\n this._nextResourceId = 0;\r\n this._compiled = null;\r\n }\r\n\r\n // ─── Accessors (for testing / debugging) ────────────────────────────\r\n\r\n /** @internal */\r\n getResource(handle: RGHandle): RGResource | undefined {\r\n return this._resources.get(handle._id);\r\n }\r\n\r\n /** @internal */\r\n get passes(): ReadonlyArray<RGPass> {\r\n return this._passes;\r\n }\r\n\r\n /** @internal */\r\n get resources(): ReadonlyMap<number, RGResource> {\r\n return this._resources;\r\n }\r\n\r\n // ─── Private: Builder ───────────────────────────────────────────────\r\n\r\n /** @internal */\r\n private _createBuilder(pass: RGPass): RGPassBuilder {\r\n const graph = this;\r\n return {\r\n read(handle: RGHandle): void {\r\n const res = graph._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n // Validate that transient resources have a producer\r\n if (res.kind === 'transient' && !res.producer) {\r\n throw new Error(\r\n `RenderGraph: pass \"${pass.name}\" attempts to read transient resource \"${res.name}\" ` +\r\n `which has no producer. Ensure the resource is created before being read.`\r\n );\r\n }\r\n pass.reads.push(res);\r\n res.consumers.push(pass);\r\n },\r\n write(handle: RGHandle): void {\r\n const res = graph._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n if (res.producer && res.producer !== pass) {\r\n throw new Error(\r\n `RenderGraph: resource \"${res.name}\" already produced by pass \"${res.producer.name}\", ` +\r\n `cannot be written by pass \"${pass.name}\"`\r\n );\r\n }\r\n res.producer = pass;\r\n pass.writes.push(res);\r\n },\r\n createTexture(desc: RGTextureDesc): RGHandle {\r\n const id = graph._nextResourceId++;\r\n const name = desc.label ?? `_tex_${id}`;\r\n const res = new RGResource(id, name, 'transient', desc);\r\n res.producer = pass;\r\n graph._resources.set(id, res);\r\n pass.writes.push(res);\r\n return new RGHandle(id, name);\r\n },\r\n sideEffect(): void {\r\n pass.hasSideEffect = true;\r\n },\r\n setExecute<D>(fn: RGExecuteFn<D>): void {\r\n pass.executeFn = fn as RGExecuteFn<unknown>;\r\n }\r\n };\r\n }\r\n\r\n // ─── Private: Dead Pass Culling ─────────────────────────────────────\r\n\r\n /** @internal */\r\n private _cullDeadPasses(outputs: RGHandle[]): void {\r\n // Start with all passes marked dead\r\n for (const pass of this._passes) {\r\n pass.alive = false;\r\n }\r\n\r\n // Seed: resources that are requested outputs\r\n const neededResources = new Set<number>();\r\n const stack: RGResource[] = [];\r\n\r\n for (const handle of outputs) {\r\n const res = this._resources.get(handle._id);\r\n if (res) {\r\n neededResources.add(res.id);\r\n stack.push(res);\r\n }\r\n }\r\n\r\n // Seed: side-effect passes (always alive) — push their read dependencies\r\n for (const pass of this._passes) {\r\n if (pass.hasSideEffect) {\r\n pass.alive = true;\r\n for (const res of pass.reads) {\r\n if (!neededResources.has(res.id)) {\r\n neededResources.add(res.id);\r\n stack.push(res);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Backward traversal: for each needed resource, mark its producer alive\r\n // and recursively mark the producer's read dependencies as needed\r\n while (stack.length > 0) {\r\n const res = stack.pop()!;\r\n const producer = res.producer;\r\n if (producer && !producer.alive) {\r\n producer.alive = true;\r\n for (const dep of producer.reads) {\r\n if (!neededResources.has(dep.id)) {\r\n neededResources.add(dep.id);\r\n stack.push(dep);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // ─── Private: Topological Sort (Kahn's Algorithm) ───────────────────\r\n\r\n /** @internal */\r\n private _topologicalSort(): RGPass[] {\r\n const alivePasses = this._passes.filter((p) => p.alive);\r\n if (alivePasses.length === 0) {\r\n return [];\r\n }\r\n\r\n // Build adjacency: producer -> consumers (only among alive passes)\r\n const aliveSet = new Set(alivePasses);\r\n const inDegree = new Map<RGPass, number>();\r\n const adjacency = new Map<RGPass, RGPass[]>();\r\n\r\n for (const pass of alivePasses) {\r\n inDegree.set(pass, 0);\r\n adjacency.set(pass, []);\r\n }\r\n\r\n // For each resource, its producer has an edge to each of its consumers\r\n for (const res of this._resources.values()) {\r\n if (!res.producer || !aliveSet.has(res.producer)) {\r\n continue;\r\n }\r\n for (const consumer of res.consumers) {\r\n if (!aliveSet.has(consumer)) {\r\n continue;\r\n }\r\n adjacency.get(res.producer)!.push(consumer);\r\n inDegree.set(consumer, inDegree.get(consumer)! + 1);\r\n }\r\n }\r\n\r\n // Kahn's algorithm\r\n const queue: RGPass[] = [];\r\n for (const pass of alivePasses) {\r\n if (inDegree.get(pass) === 0) {\r\n queue.push(pass);\r\n }\r\n }\r\n\r\n const result: RGPass[] = [];\r\n while (queue.length > 0) {\r\n const pass = queue.shift()!;\r\n result.push(pass);\r\n for (const neighbor of adjacency.get(pass)!) {\r\n const deg = inDegree.get(neighbor)! - 1;\r\n inDegree.set(neighbor, deg);\r\n if (deg === 0) {\r\n queue.push(neighbor);\r\n }\r\n }\r\n }\r\n\r\n if (result.length !== alivePasses.length) {\r\n // Find passes that are part of the cycle (those with non-zero in-degree)\r\n const cycleParticipants: string[] = [];\r\n for (const [pass, degree] of inDegree) {\r\n if (degree > 0) {\r\n cycleParticipants.push(pass.name);\r\n }\r\n }\r\n throw new Error(\r\n `RenderGraph: circular dependency detected. ` +\r\n `Sorted ${result.length} of ${alivePasses.length} alive passes. ` +\r\n `Passes in cycle: [${cycleParticipants.join(', ')}]`\r\n );\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // ─── Private: Resource Lifetime Analysis ────────────────────────────\r\n\r\n /** @internal */\r\n private _analyzeLifetimes(orderedPasses: RGPass[]): Map<number, RGResourceLifetime> {\r\n const lifetimes = new Map<number, RGResourceLifetime>();\r\n\r\n // Build pass -> order index map\r\n const orderMap = new Map<RGPass, number>();\r\n for (let i = 0; i < orderedPasses.length; i++) {\r\n orderMap.set(orderedPasses[i], i);\r\n }\r\n\r\n for (const res of this._resources.values()) {\r\n let first = Infinity;\r\n let last = -Infinity;\r\n\r\n // Producer\r\n if (res.producer && orderMap.has(res.producer)) {\r\n const idx = orderMap.get(res.producer)!;\r\n first = Math.min(first, idx);\r\n last = Math.max(last, idx);\r\n }\r\n\r\n // Consumers\r\n for (const consumer of res.consumers) {\r\n if (orderMap.has(consumer)) {\r\n const idx = orderMap.get(consumer)!;\r\n first = Math.min(first, idx);\r\n last = Math.max(last, idx);\r\n }\r\n }\r\n\r\n if (first !== Infinity) {\r\n lifetimes.set(res.id, { resource: res, firstUse: first, lastUse: last });\r\n }\r\n }\r\n\r\n return lifetimes;\r\n }\r\n}\r\n"],"names":["RenderGraph","_nextResourceId","_resources","Map","_passes","_compiled","importTexture","name","id","resource","RGResource","set","RGHandle","addPass","setup","pass","RGPass","length","builder","_createBuilder","data","push","compile","outputs","_cullDeadPasses","ordered","_topologicalSort","lifetimes","_analyzeLifetimes","orderedPasses","execute","compiled","noopCtx","getTexture","Error","executeFn","reset","clear","getResource","handle","get","_id","passes","resources","graph","read","res","kind","producer","reads","consumers","write","writes","createTexture","desc","label","sideEffect","hasSideEffect","setExecute","fn","alive","neededResources","Set","stack","add","has","pop","dep","alivePasses","filter","p","aliveSet","inDegree","adjacency","values","consumer","queue","result","shift","neighbor","deg","cycleParticipants","degree","join","orderMap","i","first","Infinity","last","idx","Math","min","max","firstUse","lastUse"],"mappings":";;AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BC,IACM,MAAMA,WAAAA,CAAAA;qBAEX,eAAQC,GAAkB,CAAE;AAC5B,qBACQC,UAAsC,GAAA,IAAIC,GAAM,EAAA;AACxD,qBACQC,OAAoB,GAAA,EAAE;qBAE9B,SAAQC,GAAwC,IAAK;;AAIrD;;;;;;;;MASAC,aAAAA,CAAcC,IAAY,EAAY;QACpC,MAAMC,EAAAA,GAAK,IAAI,CAACP,eAAe,EAAA;AAC/B,QAAA,MAAMQ,QAAW,GAAA,IAAIC,UAAWF,CAAAA,EAAAA,EAAID,MAAM,UAAY,EAAA,IAAA,CAAA;AACtD,QAAA,IAAI,CAACL,UAAU,CAACS,GAAG,CAACH,EAAIC,EAAAA,QAAAA,CAAAA;QACxB,IAAI,CAACJ,SAAS,GAAG,IAAA;QACjB,OAAO,IAAIO,SAASJ,EAAID,EAAAA,IAAAA,CAAAA;AAC1B;AAEA;;;;;;;;;AASC,MACDM,OAAkBN,CAAAA,IAAY,EAAEO,KAAoC,EAAK;QACvE,MA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QC,GAAAA,QAAAA;AACZ,YAAA,IAAIC,OAAO,CAACD,QAAAA;;YAGZ,IAAIzC,GAAAA,CAAIE,QAAQ,IAAIoC,QAAAA,CAASnB,GAAG,CAACnB,GAAAA,CAAIE,QAAQ,CAAG,EAAA;AAC9C,gBAAA,MAAMyC,GAAML,GAAAA,QAAAA,CAAS5C,GAAG,CAACM,IAAIE,QAAQ,CAAA;gBACrCsC,KAAQI,GAAAA,IAAAA,CAAKC,GAAG,CAACL,KAAOG,EAAAA,GAAAA,CAAAA;gBACxBD,IAAOE,GAAAA,IAAAA,CAAKE,GAAG,CAACJ,IAAMC,EAAAA,GAAAA,CAAAA;AACxB;;AAGA,YAAA,KAAK,MAAMd,QAAAA,IAAY7B,GAAII,CAAAA,SAAS,CAAE;gBACpC,IAAIkC,QAAAA,CAASnB,GAAG,CAACU,QAAW,CAAA,EAAA;oBAC1B,MAAMc,GAAAA,GAAML,QAAS5C,CAAAA,GAAG,CAACmC,QAAAA,CAAAA;oBACzBW,KAAQI,GAAAA,IAAAA,CAAKC,GAAG,CAACL,KAAOG,EAAAA,GAAAA,CAAAA;oBACxBD,IAAOE,GAAAA,IAAAA,CAAKE,GAAG,CAACJ,IAAMC,EAAAA,GAAAA,CAAAA;AACxB;AACF;AAEA,YAAA,IAAIH,UAAUC,QAAU,EAAA;AACtB5D,gBAAAA,SAAAA,CAAUhB,GAAG,CAACmC,GAAItC,CAAAA,EAAE,EAAE;oBAAEC,QAAUqC,EAAAA,GAAAA;oBAAK+C,QAAUP,EAAAA,KAAAA;oBAAOQ,OAASN,EAAAA;AAAK,iBAAA,CAAA;AACxE;AACF;QAEA,OAAO7D,SAAAA;AACT;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"rendergraph.js","sources":["../../../src/render/rendergraph/rendergraph.ts"],"sourcesContent":["import {\r\n RGHandle,\r\n RGResource,\r\n RGPass,\r\n RGSubpass,\r\n type RGTextureDesc,\r\n type RGPassBuilder,\r\n type RGExecuteFn,\r\n type RGExecuteContext,\r\n type CompiledRenderGraph,\r\n type RGResourceLifetime\r\n} from './types';\r\n\r\n/**\r\n * Render Graph — declarative, configurable render pipeline.\r\n *\r\n * Usage:\r\n * ```ts\r\n * const graph = new RenderGraph();\r\n * let backbuffer = graph.importTexture('backbuffer');\r\n *\r\n * let linearDepth: RGHandle;\r\n * graph.addPass('DepthPrepass', (builder) => {\r\n * linearDepth = builder.createTexture({ format: 'r32f', label: 'linearDepth' });\r\n * builder.setExecute(() => { ... });\r\n * });\r\n *\r\n * graph.addPass('LightPass', (builder) => {\r\n * builder.read(linearDepth);\r\n * backbuffer = builder.write(backbuffer);\r\n * builder.setExecute(() => { ... });\r\n * });\r\n *\r\n * const compiled = graph.compile([backbuffer]);\r\n * graph.execute(compiled);\r\n * graph.reset();\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class RenderGraph {\r\n /** @internal */\r\n private _nextResourceId = 0;\r\n /** @internal */\r\n private _resources: Map<number, RGResource> = new Map();\r\n /** @internal */\r\n private _passes: RGPass[] = [];\r\n /** @internal */\r\n private _compiled: CompiledRenderGraph | null = null;\r\n\r\n // ─── Graph Building ─────────────────────────────────────────────────\r\n\r\n /**\r\n * Import an external (persistent) texture into the graph.\r\n *\r\n * Imported resources are not allocated or released by the graph.\r\n * Typically used for the backbuffer or any texture that outlives a single frame.\r\n *\r\n * @param name - Debug label for the imported resource.\r\n * @returns A handle referencing the imported resource.\r\n */\r\n importTexture(name: string): RGHandle {\r\n const id = this._nextResourceId++;\r\n const resource = new RGResource(id, name, 'imported', null);\r\n this._resources.set(id, resource);\r\n this._compiled = null;\r\n return new RGHandle(id, name);\r\n }\r\n\r\n /**\r\n * Add a render pass to the graph.\r\n *\r\n * The setup callback receives a {@link RGPassBuilder} to declare resource\r\n * dependencies. Call `builder.setExecute(fn)` inside setup to provide the\r\n * execution callback.\r\n *\r\n * @param name - Debug label for the pass.\r\n * @param setup - Setup callback that declares resources and sets the execute function.\r\n */\r\n addPass<T = void>(name: string, setup: (builder: RGPassBuilder) => T): T {\r\n const pass = new RGPass(this._passes.length, name);\r\n const builder = this._createBuilder(pass);\r\n const data = setup(builder);\r\n pass.data = data;\r\n this._passes.push(pass);\r\n this._compiled = null;\r\n return data;\r\n }\r\n\r\n // ─── Compilation ────────────────────────────────────────────────────\r\n\r\n /**\r\n * Compile the render graph.\r\n *\r\n * Performs dead-pass culling, topological sorting, and resource lifetime analysis.\r\n *\r\n * @param outputs - Handles of resources that must be produced (graph sinks).\r\n * If a resource was passed to {@link RGPassBuilder.write}, use the returned\r\n * post-write handle here, not the original handle.\r\n * Passes that do not contribute to these outputs (directly or transitively)\r\n * are culled, unless marked as side-effect passes.\r\n * @returns The compiled graph ready for execution.\r\n */\r\n compile(outputs: RGHandle[]): CompiledRenderGraph {\r\n this._validateOutputs(outputs);\r\n // 1. Mark alive passes via backward traversal from outputs + side-effect passes\r\n this._cullDeadPasses(outputs);\r\n // 2. Topological sort of alive passes\r\n const ordered = this._topologicalSort();\r\n // 3. Resource lifetime analysis\r\n const lifetimes = this._analyzeLifetimes(ordered);\r\n\r\n this._compiled = { orderedPasses: ordered, lifetimes };\r\n return this._compiled;\r\n }\r\n\r\n /**\r\n * Execute a compiled render graph (simple mode, no resource management).\r\n *\r\n * For automatic resource allocation/release, use {@link RenderGraphExecutor} instead.\r\n *\r\n * @param compiled - The compiled graph from {@link RenderGraph.compile}.\r\n */\r\n execute(compiled: CompiledRenderGraph): void {\r\n const noopCtx: RGExecuteContext = {\r\n getTexture() {\r\n throw new Error(\r\n 'RenderGraph.execute(): resource resolution not available. Use RenderGraphExecutor for managed execution.'\r\n );\r\n },\r\n getFramebuffer() {\r\n throw new Error(\r\n 'RenderGraph.execute(): framebuffer resolution not available. Use RenderGraphExecutor for managed execution.'\r\n );\r\n },\r\n createFramebuffer() {\r\n throw new Error(\r\n 'RenderGraph.execute(): framebuffer allocation not available. Use RenderGraphExecutor for managed execution.'\r\n );\r\n },\r\n deferCleanup() {\r\n // No-op in unmanaged execution mode.\r\n }\r\n };\r\n for (const pass of compiled.orderedPasses) {\r\n if (pass.subpasses.length > 0) {\r\n for (const subpass of pass.subpasses) {\r\n (subpass.executeFn as RGExecuteFn<unknown>)(noopCtx, pass.data);\r\n }\r\n } else if (pass.executeFn) {\r\n (pass.executeFn as RGExecuteFn<unknown>)(noopCtx, pass.data);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Reset the graph for the next frame.\r\n *\r\n * Clears all passes, transient resources, and compiled state.\r\n * Imported resources are also cleared — re-import them each frame.\r\n */\r\n reset(): void {\r\n this._passes.length = 0;\r\n this._resources.clear();\r\n this._nextResourceId = 0;\r\n this._compiled = null;\r\n }\r\n\r\n // ─── Accessors (for testing / debugging) ────────────────────────────\r\n\r\n /** @internal */\r\n getResource(handle: RGHandle): RGResource | undefined {\r\n return this._resources.get(handle._id);\r\n }\r\n\r\n /** @internal */\r\n get passes(): ReadonlyArray<RGPass> {\r\n return this._passes;\r\n }\r\n\r\n /** @internal */\r\n get resources(): ReadonlyMap<number, RGResource> {\r\n return this._resources;\r\n }\r\n\r\n // ─── Private: Builder ───────────────────────────────────────────────\r\n\r\n /** @internal */\r\n private _createBuilder(pass: RGPass): RGPassBuilder {\r\n const graph = this;\r\n return {\r\n read(handle: RGHandle): void {\r\n const res = graph._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n // Validate that transient resources have a producer\r\n if (res.kind === 'transient' && !res.producer) {\r\n throw new Error(\r\n `RenderGraph: pass \"${pass.name}\" attempts to read transient resource \"${res.name}\" ` +\r\n `which has no producer. Ensure the resource is created before being read.`\r\n );\r\n }\r\n if (!pass.reads.includes(res)) {\r\n pass.reads.push(res);\r\n }\r\n if (!res.consumers.includes(pass)) {\r\n res.consumers.push(pass);\r\n }\r\n },\r\n write(handle: RGHandle): RGHandle {\r\n const res = graph._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n if (res.kind === 'token') {\r\n throw new Error(\r\n `RenderGraph: pass \"${pass.name}\" attempts to write token \"${res.name}\". ` +\r\n `Use createToken() to produce ordering tokens.`\r\n );\r\n }\r\n if (res.kind === 'framebuffer') {\r\n throw new Error(\r\n `RenderGraph: pass \"${pass.name}\" attempts to write framebuffer \"${res.name}\". ` +\r\n `Create a new framebuffer view instead.`\r\n );\r\n }\r\n for (const consumer of res.consumers) {\r\n if (consumer !== pass && !pass.dependencies.includes(consumer)) {\r\n pass.dependencies.push(consumer);\r\n }\r\n }\r\n if (res.producer && res.producer !== pass && !pass.dependencies.includes(res.producer)) {\r\n pass.dependencies.push(res.producer);\r\n }\r\n const id = graph._nextResourceId++;\r\n const versionName = `${res.name}@${pass.name}`;\r\n const version = new RGResource(id, versionName, res.kind, res.desc, res.physicalId);\r\n version.producer = pass;\r\n graph._resources.set(id, version);\r\n if (!pass.writes.includes(version)) {\r\n pass.writes.push(version);\r\n }\r\n return new RGHandle(id, versionName);\r\n },\r\n createTexture(desc: RGTextureDesc): RGHandle {\r\n const id = graph._nextResourceId++;\r\n const name = desc.label ?? `_tex_${id}`;\r\n const res = new RGResource(id, name, 'transient', desc);\r\n res.producer = pass;\r\n graph._resources.set(id, res);\r\n pass.writes.push(res);\r\n return new RGHandle(id, name);\r\n },\r\n createToken(name?: string): RGHandle {\r\n const id = graph._nextResourceId++;\r\n const tokenName = name ?? `_token_${id}`;\r\n const res = new RGResource(id, tokenName, 'token', null);\r\n res.producer = pass;\r\n graph._resources.set(id, res);\r\n pass.writes.push(res);\r\n return new RGHandle(id, tokenName);\r\n },\r\n createFramebuffer(desc): RGHandle {\r\n const id = graph._nextResourceId++;\r\n const name = desc.label ?? `_fb_${id}`;\r\n const res = new RGResource(id, name, 'framebuffer', desc);\r\n res.producer = pass;\r\n graph._resources.set(id, res);\r\n pass.writes.push(res);\r\n graph._declareFramebufferAttachmentDeps(pass, desc);\r\n return new RGHandle(id, name);\r\n },\r\n sideEffect(): void {\r\n pass.hasSideEffect = true;\r\n },\r\n addSubpass<D>(name: string, fn: RGExecuteFn<D>): void {\r\n if (pass.executeFn) {\r\n throw new Error(\r\n `RenderGraph: pass \"${pass.name}\" cannot use addSubpass() after setExecute(). ` +\r\n `Use either subpasses or a single execute callback.`\r\n );\r\n }\r\n pass.subpasses.push(new RGSubpass(name, fn as RGExecuteFn<unknown>));\r\n },\r\n setExecute<D>(fn: RGExecuteFn<D>): void {\r\n if (pass.subpasses.length > 0) {\r\n throw new Error(\r\n `RenderGraph: pass \"${pass.name}\" cannot use setExecute() after addSubpass(). ` +\r\n `Use either subpasses or a single execute callback.`\r\n );\r\n }\r\n pass.executeFn = fn as RGExecuteFn<unknown>;\r\n }\r\n };\r\n }\r\n\r\n // ─── Private: Dead Pass Culling ─────────────────────────────────────\r\n\r\n /** @internal */\r\n private _validateOutputs(outputs: RGHandle[]): void {\r\n const latestVersions = new Map<number, RGResource>();\r\n for (const res of this._resources.values()) {\r\n const current = latestVersions.get(res.physicalId);\r\n if (!current || res.id > current.id) {\r\n latestVersions.set(res.physicalId, res);\r\n }\r\n }\r\n\r\n for (const handle of outputs) {\r\n const res = this._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown output resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n const latest = latestVersions.get(res.physicalId);\r\n if (latest && latest.id !== res.id) {\r\n throw new Error(\r\n `RenderGraph: output resource \"${res.name}\" (id=${res.id}) is not the latest version. ` +\r\n `Use the handle returned by builder.write(); latest is \"${latest.name}\" (id=${latest.id}).`\r\n );\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n private _cullDeadPasses(outputs: RGHandle[]): void {\r\n // Start with all passes marked dead\r\n for (const pass of this._passes) {\r\n pass.alive = false;\r\n }\r\n\r\n // Seed: resources that are requested outputs\r\n const neededResources = new Set<number>();\r\n const stack: RGResource[] = [];\r\n const markResourceNeeded = (res: RGResource) => {\r\n if (!neededResources.has(res.id)) {\r\n neededResources.add(res.id);\r\n stack.push(res);\r\n }\r\n };\r\n const markPassAlive = (pass: RGPass) => {\r\n if (pass.alive) {\r\n return;\r\n }\r\n pass.alive = true;\r\n for (const dep of pass.reads) {\r\n markResourceNeeded(dep);\r\n }\r\n for (const dependency of pass.dependencies) {\r\n markPassAlive(dependency);\r\n }\r\n };\r\n\r\n for (const handle of outputs) {\r\n const res = this._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown output resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n markResourceNeeded(res);\r\n }\r\n\r\n // Seed: side-effect passes (always alive) — push their read dependencies\r\n for (const pass of this._passes) {\r\n if (pass.hasSideEffect) {\r\n markPassAlive(pass);\r\n }\r\n }\r\n\r\n // Backward traversal: for each needed resource, mark its producer alive\r\n // and recursively mark the producer's read dependencies as needed\r\n while (stack.length > 0) {\r\n const res = stack.pop()!;\r\n const producer = res.producer;\r\n if (producer) {\r\n markPassAlive(producer);\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n private _declareFramebufferAttachmentDeps(\r\n pass: RGPass,\r\n desc: { colorAttachments: unknown | unknown[] | null; depthAttachment?: unknown | null }\r\n ): void {\r\n const declare = (attachment: unknown) => {\r\n if (attachment instanceof RGHandle) {\r\n const res = this._resources.get(attachment._id);\r\n if (!res) {\r\n throw new Error(\r\n `RenderGraph: unknown framebuffer attachment \"${attachment.name}\" (id=${attachment._id})`\r\n );\r\n }\r\n if (res.kind !== 'transient' && res.kind !== 'imported') {\r\n throw new Error(\r\n `RenderGraph: framebuffer attachment \"${res.name}\" must be a texture resource, got ${res.kind}.`\r\n );\r\n }\r\n if (res.producer !== pass) {\r\n if (!pass.reads.includes(res)) {\r\n pass.reads.push(res);\r\n }\r\n if (!res.consumers.includes(pass)) {\r\n res.consumers.push(pass);\r\n }\r\n }\r\n }\r\n };\r\n const colors = Array.isArray(desc.colorAttachments)\r\n ? desc.colorAttachments\r\n : desc.colorAttachments\r\n ? [desc.colorAttachments]\r\n : [];\r\n for (const attachment of colors) {\r\n declare(attachment);\r\n }\r\n declare(desc.depthAttachment);\r\n }\r\n\r\n // ─── Private: Topological Sort (Kahn's Algorithm) ───────────────────\r\n\r\n /** @internal */\r\n private _topologicalSort(): RGPass[] {\r\n const alivePasses = this._passes.filter((p) => p.alive);\r\n if (alivePasses.length === 0) {\r\n return [];\r\n }\r\n\r\n // Build adjacency: producer -> consumers (only among alive passes)\r\n const aliveSet = new Set(alivePasses);\r\n const inDegree = new Map<RGPass, number>();\r\n const adjacency = new Map<RGPass, RGPass[]>();\r\n\r\n for (const pass of alivePasses) {\r\n inDegree.set(pass, 0);\r\n adjacency.set(pass, []);\r\n }\r\n\r\n const addEdge = (from: RGPass, to: RGPass) => {\r\n if (from === to || !aliveSet.has(from) || !aliveSet.has(to)) {\r\n return;\r\n }\r\n const neighbors = adjacency.get(from)!;\r\n if (!neighbors.includes(to)) {\r\n neighbors.push(to);\r\n inDegree.set(to, inDegree.get(to)! + 1);\r\n }\r\n };\r\n\r\n for (const pass of alivePasses) {\r\n for (const dependency of pass.dependencies) {\r\n addEdge(dependency, pass);\r\n }\r\n }\r\n\r\n // For each resource, its producer has an edge to each of its consumers\r\n for (const res of this._resources.values()) {\r\n if (!res.producer || !aliveSet.has(res.producer)) {\r\n continue;\r\n }\r\n for (const consumer of res.consumers) {\r\n addEdge(res.producer, consumer);\r\n }\r\n }\r\n\r\n // Kahn's algorithm\r\n const queue: RGPass[] = [];\r\n for (const pass of alivePasses) {\r\n if (inDegree.get(pass) === 0) {\r\n queue.push(pass);\r\n }\r\n }\r\n\r\n const result: RGPass[] = [];\r\n while (queue.length > 0) {\r\n const pass = queue.shift()!;\r\n result.push(pass);\r\n for (const neighbor of adjacency.get(pass)!) {\r\n const deg = inDegree.get(neighbor)! - 1;\r\n inDegree.set(neighbor, deg);\r\n if (deg === 0) {\r\n queue.push(neighbor);\r\n }\r\n }\r\n }\r\n\r\n if (result.length !== alivePasses.length) {\r\n // Find passes that are part of the cycle (those with non-zero in-degree)\r\n const cycleParticipants: string[] = [];\r\n for (const [pass, degree] of inDegree) {\r\n if (degree > 0) {\r\n cycleParticipants.push(pass.name);\r\n }\r\n }\r\n throw new Error(\r\n `RenderGraph: circular dependency detected. ` +\r\n `Sorted ${result.length} of ${alivePasses.length} alive passes. ` +\r\n `Passes in cycle: [${cycleParticipants.join(', ')}]`\r\n );\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // ─── Private: Resource Lifetime Analysis ────────────────────────────\r\n\r\n /** @internal */\r\n private _analyzeLifetimes(orderedPasses: RGPass[]): Map<number, RGResourceLifetime> {\r\n const lifetimes = new Map<number, RGResourceLifetime>();\r\n\r\n // Build pass -> order index map\r\n const orderMap = new Map<RGPass, number>();\r\n for (let i = 0; i < orderedPasses.length; i++) {\r\n orderMap.set(orderedPasses[i], i);\r\n }\r\n\r\n for (const res of this._resources.values()) {\r\n let first = Infinity;\r\n let last = -Infinity;\r\n\r\n // Producer\r\n if (res.producer && orderMap.has(res.producer)) {\r\n const idx = orderMap.get(res.producer)!;\r\n first = Math.min(first, idx);\r\n last = Math.max(last, idx);\r\n }\r\n\r\n // Consumers\r\n for (const consumer of res.consumers) {\r\n if (orderMap.has(consumer)) {\r\n const idx = orderMap.get(consumer)!;\r\n first = Math.min(first, idx);\r\n last = Math.max(last, idx);\r\n }\r\n }\r\n\r\n if (first !== Infinity) {\r\n lifetimes.set(res.id, { resource: res, firstUse: first, lastUse: last });\r\n }\r\n }\r\n\r\n return lifetimes;\r\n }\r\n}\r\n"],"names":["RenderGraph","_nextResourceId","_resources","Map","_passes","_compiled","importTexture","name","id","resource","RGResource","set","RGHandle","addPass","setup","pass","RGPass","length","builder","_createBuilder","data","push","compile","outputs","_validateOutputs","_cullDeadPasses","ordered","_topologicalSort","lifetimes","_analyzeLifetimes","orderedPasses","execute","compiled","noopCtx","getTexture","Error","getFramebuffer","createFramebuffer","deferCleanup","subpasses","subpass","executeFn","reset","clear","getResource","handle","get","_id","passes","resources","graph","read","res","kind","producer","reads","includes","consumers","write","consumer","dependencies","versionName","version","desc","physicalId","writes","createTexture","label","createToken","tokenName","_declareFramebufferAttachmentDeps","sideEffect","hasSideEffect","addSubpass","fn","RGSubpass","setExecute","latestVersions","values","current","latest","alive","neededResources","Set","stack","markResourceNeeded","has","add","markPassAlive","dep","dependency","pop","declare","attachment","colors","Array","isArray","colorAttachments","depthAttachment","alivePasses","filter","p","aliveSet","inDegree","adjacency","addEdge","from","to","neighbors","queue","result","shift","neighbor","deg","cycleParticipants","degree","join","orderMap","i","first","Infinity","last","idx","Math","min","max","firstUse","lastUse"],"mappings":";;AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BC,IACM,MAAMA,WAAAA,CAAAA;qBAEX,eAAQC,GAAkB,CAAE;AAC5B,qBACQC,UAAsC,GAAA,IAAIC,GAAM,EAAA;AACxD,qBACQC,OAAoB,GAAA,EAAE;qBAE9B,SAAQC,GAAwC,IAAK;;AAIrD;;;;;;;;MASAC,aAAAA,CAAcC,IAAY,EAAY;QACpC,MAAMC,EAAAA,GAAK,IAAI,CAACP,eAAe,EAAA;AAC/B,QAAA,MAAMQ,QAAW,GAAA,IAAIC,UAAWF,CAAAA,EAAAA,EAAID,MAAM,UAAY,EAAA,IAAA,CAAA;AACtD,QAAA,IAAI,CAACL,UAAU,CAACS,GAAG,CAACH,EAAIC,EAAAA,QAAAA,CAAAA;QACxB,IAAI,CAACJ,SAAS,GAAG,IAAA;QACjB,OAAO,IAAIO,SAASJ,EAAID,EAAAA,IAAAA,CAAAA;AAC1B;AAEA;;;;;;;;;AASC,MACDM,OAAkBN,CAAAA,IAAY,EAAEO,KAAoC,EAAK;QACvE,MAAMC,IAAAA,GAAO,IAAIC,MAAO,CAAA,IAAI,CAACZ,OAAO,CAACa,MAAM,EAAEV,IAAAA,CAAAA;AAC7C,QAAA,MAAMW,OAAU,GAAA,IAAI,CAACC,cAAc,CAACJ,IAAAA,CAAAA;AACpC,QA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vE,CAAAA,GAAG,CAACa,QAAAA,CAAAA;oBACzB4D,KAAQI,GAAAA,IAAAA,CAAKC,GAAG,CAACL,KAAOG,EAAAA,GAAAA,CAAAA;oBACxBD,IAAOE,GAAAA,IAAAA,CAAKE,GAAG,CAACJ,IAAMC,EAAAA,GAAAA,CAAAA;AACxB;AACF;AAEA,YAAA,IAAIH,UAAUC,QAAU,EAAA;AACtB5F,gBAAAA,SAAAA,CAAUjB,GAAG,CAACyC,GAAI5C,CAAAA,EAAE,EAAE;oBAAEC,QAAU2C,EAAAA,GAAAA;oBAAK0E,QAAUP,EAAAA,KAAAA;oBAAOQ,OAASN,EAAAA;AAAK,iBAAA,CAAA;AACxE;AACF;QAEA,OAAO7F,SAAAA;AACT;AACF;;;;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// ─── Handles ────────────────────────────────────────────────────────────
|
|
2
|
-
/**
|
|
3
|
-
* Opaque handle referencing a resource within the render graph.
|
|
4
|
-
*
|
|
5
|
-
* Handles are obtained from {@link RGPassBuilder.createTexture}, {@link
|
|
6
|
-
* or {@link RGPassBuilder.write}. They are lightweight identifiers
|
|
7
|
-
* dependencies between passes.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
2
|
+
/**
|
|
3
|
+
* Opaque handle referencing a resource within the render graph.
|
|
4
|
+
*
|
|
5
|
+
* Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RGPassBuilder.createFramebuffer},
|
|
6
|
+
* {@link RenderGraph.importTexture}, or {@link RGPassBuilder.write}. They are lightweight identifiers
|
|
7
|
+
* used to declare dependencies between passes.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
10
|
*/ class RGHandle {
|
|
11
11
|
/** @internal */ _id;
|
|
12
12
|
/** @internal */ _name;
|
|
@@ -18,34 +18,54 @@
|
|
|
18
18
|
return this._name;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Internal bookkeeping for a resource within the render graph.
|
|
23
|
-
* @public
|
|
21
|
+
/**
|
|
22
|
+
* Internal bookkeeping for a resource within the render graph.
|
|
23
|
+
* @public
|
|
24
24
|
*/ class RGResource {
|
|
25
25
|
id;
|
|
26
26
|
name;
|
|
27
27
|
kind;
|
|
28
28
|
desc;
|
|
29
|
+
/** Resource ID of the physical backing resource used by imported versions. */ physicalId;
|
|
29
30
|
/** The pass that creates / writes this resource (null for imported until written). */ producer = null;
|
|
30
31
|
/** Passes that read this resource. */ consumers = [];
|
|
31
|
-
constructor(id, name, kind, desc){
|
|
32
|
+
constructor(id, name, kind, desc, physicalId = id){
|
|
32
33
|
this.id = id;
|
|
33
34
|
this.name = name;
|
|
34
35
|
this.kind = kind;
|
|
35
36
|
this.desc = desc;
|
|
37
|
+
this.physicalId = physicalId;
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
40
|
+
/**
|
|
41
|
+
* Ordered execution step inside a render graph pass.
|
|
42
|
+
*
|
|
43
|
+
* Subpasses share the parent pass's resource declarations, lifetime, culling,
|
|
44
|
+
* and access validation. They are intended to make multi-step pass bodies
|
|
45
|
+
* explicit without splitting graph-level resource dependencies.
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*/ class RGSubpass {
|
|
49
|
+
name;
|
|
50
|
+
executeFn;
|
|
51
|
+
constructor(name, executeFn){
|
|
52
|
+
this.name = name;
|
|
53
|
+
this.executeFn = executeFn;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Internal bookkeeping for a pass within the render graph.
|
|
58
|
+
* @public
|
|
41
59
|
*/ class RGPass {
|
|
42
60
|
index;
|
|
43
61
|
name;
|
|
44
62
|
/** Resources this pass reads (dependencies). */ reads = [];
|
|
45
63
|
/** Resources this pass creates or writes. */ writes = [];
|
|
64
|
+
/** Passes that must complete before this pass due to non-resource hazards. */ dependencies = [];
|
|
46
65
|
/** Whether this pass has side effects and must not be culled. */ hasSideEffect = false;
|
|
47
66
|
/** User data returned from the setup function. */ data = null;
|
|
48
67
|
/** Execute callback. */ executeFn = null;
|
|
68
|
+
/** Ordered subpasses for passes with multiple logical execution steps. */ subpasses = [];
|
|
49
69
|
/** Set during compilation: true if this pass is needed. */ alive = true;
|
|
50
70
|
constructor(index, name){
|
|
51
71
|
this.index = index;
|
|
@@ -53,5 +73,5 @@
|
|
|
53
73
|
}
|
|
54
74
|
}
|
|
55
75
|
|
|
56
|
-
export { RGHandle, RGPass, RGResource };
|
|
76
|
+
export { RGHandle, RGPass, RGResource, RGSubpass };
|
|
57
77
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type { TextureFormat } from '@zephyr3d/device';\r\n\r\n// ─── Resource Descriptors ───────────────────────────────────────────────\r\n\r\n/**\r\n * Sizing mode for render graph textures.\r\n *\r\n * - 'absolute': fixed pixel dimensions\r\n * - 'backbuffer-relative': scaled relative to the backbuffer size\r\n *\r\n * @public\r\n */\r\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\r\n\r\n/**\r\n * Descriptor for a transient texture resource within the render graph.\r\n *\r\n * Transient textures are allocated and released automatically by the graph compiler.\r\n *\r\n * @public\r\n */\r\nexport interface RGTextureDesc {\r\n /** Debug label for this resource. */\r\n label?: string;\r\n /** Texture format (e.g. 'rgba8unorm', 'r32f', 'rgba16f'). */\r\n format: TextureFormat;\r\n /** Sizing mode. Default 'backbuffer-relative'. */\r\n sizeMode?: RGSizeMode;\r\n /** Width in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n width?: number;\r\n /** Height in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n height?: number;\r\n /** Number of mip levels. Default 1. */\r\n mipLevels?: number;\r\n}\r\n\r\n// ─── Handles ────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Opaque handle referencing a resource within the render graph.\r\n *\r\n * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RenderGraph.importTexture},\r\n * or {@link RGPassBuilder.write}. They are lightweight identifiers used to declare\r\n * dependencies between passes.\r\n *\r\n * @public\r\n */\r\nexport class RGHandle {\r\n /** @internal */\r\n readonly _id: number;\r\n /** @internal */\r\n readonly _name: string;\r\n\r\n /** @internal */\r\n constructor(id: number, name: string) {\r\n this._id = id;\r\n this._name = name;\r\n }\r\n\r\n /** Debug-friendly name of the referenced resource. */\r\n get name(): string {\r\n return this._name;\r\n }\r\n}\r\n\r\n// ─── Internal Resource Tracking ─────────────────────────────────────────\r\n\r\n/** @public */\r\nexport type RGResourceKind = 'transient' | 'imported';\r\n\r\n/**\r\n * Internal bookkeeping for a resource within the render graph.\r\n * @public\r\n */\r\nexport class RGResource {\r\n readonly id: number;\r\n readonly name: string;\r\n readonly kind: RGResourceKind;\r\n readonly desc: RGTextureDesc | null;\r\n /** The pass that creates / writes this resource (null for imported until written). */\r\n producer: RGPass | null = null;\r\n /** Passes that read this resource. */\r\n readonly consumers: RGPass[] = [];\r\n\r\n constructor(id: number, name: string, kind: RGResourceKind, desc: RGTextureDesc | null) {\r\n this.id = id;\r\n this.name = name;\r\n this.kind = kind;\r\n this.desc = desc;\r\n }\r\n}\r\n\r\n// ─── Internal Pass Tracking ─────────────────────────────────────────────\r\n\r\n// ─── Execution Context ──────────────────────────────────────────────\r\n\r\n/**\r\n * Context passed to pass execute callbacks during graph execution.\r\n *\r\n * Provides access to resolved GPU resources by their handles.\r\n *\r\n * @public\r\n */\r\nexport interface RGExecuteContext {\r\n /**\r\n * Resolve a handle to the actual GPU texture object.\r\n *\r\n * For transient resources, this returns the texture allocated by the executor.\r\n * For imported resources, this returns the texture registered via\r\n * {@link RenderGraphExecutor.setImportedTexture}.\r\n *\r\n * @param handle - Handle of the resource to resolve.\r\n * @returns The resolved texture object (type depends on the allocator).\r\n */\r\n getTexture<TTexture = unknown>(handle: RGHandle): TTexture;\r\n}\r\n\r\n/**\r\n * Execute callback signature.\r\n *\r\n * The callback receives a context for resolving handles to GPU resources,\r\n * plus the user data returned from the setup function.\r\n *\r\n * @public\r\n */\r\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\r\n\r\n/**\r\n * Internal bookkeeping for a pass within the render graph.\r\n * @public\r\n */\r\nexport class RGPass<T = unknown> {\r\n readonly index: number;\r\n readonly name: string;\r\n /** Resources this pass reads (dependencies). */\r\n readonly reads: RGResource[] = [];\r\n /** Resources this pass creates or writes. */\r\n readonly writes: RGResource[] = [];\r\n /** Whether this pass has side effects and must not be culled. */\r\n hasSideEffect = false;\r\n /** User data returned from the setup function. */\r\n data: T | null = null;\r\n /** Execute callback. */\r\n executeFn: RGExecuteFn<T> | null = null;\r\n /** Set during compilation: true if this pass is needed. */\r\n alive = true;\r\n\r\n constructor(index: number, name: string) {\r\n this.index = index;\r\n this.name = name;\r\n }\r\n}\r\n\r\n// ─── Pass Builder ───────────────────────────────────────────────────────\r\n\r\n/**\r\n * Builder interface used within the setup callback of {@link RenderGraph.addPass}\r\n * to declare a pass's resource requirements.\r\n *\r\n * @public\r\n */\r\nexport interface RGPassBuilder {\r\n /**\r\n * Declare a read dependency on an existing resource.\r\n *\r\n * The resource must have been created by a prior pass or imported into the graph.\r\n *\r\n * @param handle - Handle of the resource to read.\r\n */\r\n read(handle: RGHandle): void;\r\n\r\n /**\r\n * Declare that this pass writes to an existing resource (typically an imported resource).\r\n *\r\n * @param handle - Handle of the resource to write to.\r\n */\r\n write(handle: RGHandle): void;\r\n\r\n /**\r\n * Create a new transient texture resource that this pass will produce.\r\n *\r\n * @param desc - Texture descriptor.\r\n * @returns A handle referencing the newly created resource.\r\n */\r\n createTexture(desc: RGTextureDesc): RGHandle;\r\n\r\n /**\r\n * Mark this pass as having side effects.\r\n *\r\n * Side-effect passes are never culled by the graph compiler, regardless of\r\n * whether their outputs are consumed. Use this for GPU readback, picking,\r\n * debug overlays, etc.\r\n */\r\n sideEffect(): void;\r\n\r\n /**\r\n * Set the execution callback for this pass.\r\n *\r\n * @param fn - Callback invoked during graph execution.\r\n */\r\n setExecute<D>(fn: RGExecuteFn<D>): void;\r\n}\r\n\r\n// ─── Compiled Graph ─────────────────────────────────────────────────────\r\n\r\n/**\r\n * Lifetime information for a resource within the compiled graph.\r\n *\r\n * @public\r\n */\r\nexport interface RGResourceLifetime {\r\n /** The resource. */\r\n readonly resource: RGResource;\r\n /** Index of the first pass that uses (produces or reads) this resource. */\r\n readonly firstUse: number;\r\n /** Index of the last pass that uses this resource. */\r\n readonly lastUse: number;\r\n}\r\n\r\n/**\r\n * Result of compiling a render graph.\r\n *\r\n * Contains the ordered list of passes to execute and lifetime information\r\n * for automatic resource management.\r\n *\r\n * @public\r\n */\r\nexport interface CompiledRenderGraph {\r\n /** Topologically sorted passes (only non-culled passes). */\r\n readonly orderedPasses: ReadonlyArray<RGPass>;\r\n /** Resource lifetime information keyed by resource ID. */\r\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\r\n}\r\n\r\n// ─── Texture Allocator ──────────────────────────────────────────────\r\n\r\n/**\r\n * Resolved dimensions for a texture allocation.\r\n * @public\r\n */\r\nexport interface RGResolvedSize {\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/**\r\n * Interface for allocating and releasing transient textures.\r\n *\r\n * Implement this to bridge the render graph with your GPU device's resource pool.\r\n * The executor calls {@link allocate} before a resource's first use and\r\n * {@link release} after its last use.\r\n *\r\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\r\n * @public\r\n */\r\nexport interface RGTextureAllocator<TTexture = unknown> {\r\n /**\r\n * Allocate a transient texture matching the given descriptor and resolved size.\r\n *\r\n * @param desc - The texture descriptor from the pass builder.\r\n * @param size - The resolved pixel dimensions.\r\n * @returns The allocated texture object.\r\n */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize): TTexture;\r\n\r\n /**\r\n * Release a previously allocated transient texture back to the pool.\r\n *\r\n * @param texture - The texture to release.\r\n */\r\n release(texture: TTexture): void;\r\n}\r\n"],"names":["RGHandle","id","name","_id","_name","RGResource","kind","desc","producer","consumers","RGPass","index","reads","writes","hasSideEffect","data","executeFn","alive"],"mappings":"AAoCA;AAEA;;;;;;;;AAQC,IACM,MAAMA,QAAAA,CAAAA;qBAEX,GAAqB;qBAErB,KAAuB;AAEvB,qBACA,WAAA,CAAYC,EAAU,EAAEC,IAAY,CAAE;QACpC,IAAI,CAACC,GAAG,GAAGF,EAAAA;QACX,IAAI,CAACG,KAAK,GAAGF,IAAAA;AACf;2DAGA,IAAIA,IAAe,GAAA;QACjB,OAAO,IAAI,CAACE,KAAK;AACnB;AACF;AAOA;;;AAGC,IACM,MAAMC,UAAAA,CAAAA;IACFJ,EAAW;IACXC,IAAa;IACbI,IAAqB;IACrBC,IAA2B;2FAEpCC,WAA0B,IAAK;AAC/B,2CACSC,SAAsB,GAAA,EAAE;AAEjC,IAAA,WAAA,CAAYR,EAAU,EAAEC,IAAY,EAAEI,IAAoB,EAAEC,IAA0B,CAAE;QACtF,IAAI,CAACN,EAAE,GAAGA,EAAAA;QACV,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACI,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACC,IAAI,GAAGA,IAAAA;AACd;AACF;AAqCA;;;AAGC,IACM,MAAMG,MAAAA,CAAAA;IACFC,KAAc;IACdT,IAAa;AACtB,qDACSU,KAAsB,GAAA,EAAE;AACjC,kDACSC,MAAuB,GAAA,EAAE;sEAElCC,gBAAgB,KAAM;uDAEtBC,OAAiB,IAAK;6BAEtBC,YAAmC,IAAK;gEAExCC,QAAQ,IAAK;IAEb,WAAYN,CAAAA,KAAa,EAAET,IAAY,CAAE;QACvC,IAAI,CAACS,KAAK,GAAGA,KAAAA;QACb,IAAI,CAACT,IAAI,GAAGA,IAAAA;AACd;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type { TextureFormat } from '@zephyr3d/device';\n\n// ─── Resource Descriptors ───────────────────────────────────────────────\n\n/**\n * Sizing mode for render graph textures.\n *\n * - 'absolute': fixed pixel dimensions\n * - 'backbuffer-relative': scaled relative to the backbuffer size\n *\n * @public\n */\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\n\n/**\n * Descriptor for a transient texture resource within the render graph.\n *\n * Transient textures are allocated and released automatically by the graph compiler.\n *\n * @public\n */\nexport interface RGTextureDesc {\n /** Debug label for this resource. */\n label?: string;\n /** Texture format (e.g. 'rgba8unorm', 'r32f', 'rgba16f'). */\n format: TextureFormat;\n /** Sizing mode. Default 'backbuffer-relative'. */\n sizeMode?: RGSizeMode;\n /** Width in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\n width?: number;\n /** Height in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\n height?: number;\n /** Number of mip levels. Default 1. */\n mipLevels?: number;\n}\n\n// ─── Handles ────────────────────────────────────────────────────────────\n\n/**\n * Opaque handle referencing a resource within the render graph.\n *\n * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RGPassBuilder.createFramebuffer},\n * {@link RenderGraph.importTexture}, or {@link RGPassBuilder.write}. They are lightweight identifiers\n * used to declare dependencies between passes.\n *\n * @public\n */\nexport class RGHandle {\n /** @internal */\n readonly _id: number;\n /** @internal */\n readonly _name: string;\n\n /** @internal */\n constructor(id: number, name: string) {\n this._id = id;\n this._name = name;\n }\n\n /** Debug-friendly name of the referenced resource. */\n get name(): string {\n return this._name;\n }\n}\n\n// ─── Internal Resource Tracking ─────────────────────────────────────────\n\n/** @public */\nexport type RGResourceKind = 'transient' | 'imported' | 'token' | 'framebuffer';\n\n/**\n * Internal bookkeeping for a resource within the render graph.\n * @public\n */\nexport class RGResource {\n readonly id: number;\n readonly name: string;\n readonly kind: RGResourceKind;\n readonly desc: RGTextureDesc | RGFramebufferDesc | null;\n /** Resource ID of the physical backing resource used by imported versions. */\n readonly physicalId: number;\n /** The pass that creates / writes this resource (null for imported until written). */\n producer: RGPass | null = null;\n /** Passes that read this resource. */\n readonly consumers: RGPass[] = [];\n\n constructor(\n id: number,\n name: string,\n kind: RGResourceKind,\n desc: RGTextureDesc | RGFramebufferDesc | null,\n physicalId = id\n ) {\n this.id = id;\n this.name = name;\n this.kind = kind;\n this.desc = desc;\n this.physicalId = physicalId;\n }\n}\n\n// ─── Internal Pass Tracking ─────────────────────────────────────────────\n\n// ─── Execution Context ──────────────────────────────────────────────\n\n/**\n * Context passed to pass execute callbacks during graph execution.\n *\n * Provides access to resolved GPU resources by their handles.\n *\n * @public\n */\nexport interface RGExecuteContext {\n /**\n * Resolve a handle to the actual GPU texture object.\n *\n * For transient resources, this returns the texture allocated by the executor.\n * For imported resources, this returns the texture registered via\n * {@link RenderGraphExecutor.setImportedTexture}. The handle must be declared\n * by the current pass with {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\n *\n * @param handle - Handle of the resource to resolve.\n * @returns The resolved texture object (type depends on the allocator).\n */\n getTexture<TTexture = unknown>(handle: RGHandle): TTexture;\n\n /**\n * Resolve a framebuffer handle to the actual backend framebuffer object.\n *\n * The handle must be declared by the current pass with {@link RGPassBuilder.read}\n * or created by the same pass with {@link RGPassBuilder.createFramebuffer}.\n *\n * @param handle - Handle returned from {@link RGPassBuilder.createFramebuffer}.\n * @returns The resolved framebuffer object (type depends on the allocator).\n */\n getFramebuffer<TFramebuffer = unknown>(handle: RGHandle): TFramebuffer;\n\n /**\n * Create a temporary framebuffer managed by the graph executor.\n *\n * The framebuffer is released automatically when graph execution finishes or\n * aborts. Attachments may be actual backend resources or texture formats,\n * depending on the allocator implementation. If an attachment is an\n * {@link RGHandle}, the current pass must declare it with\n * {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\n *\n * @param desc - Framebuffer descriptor.\n * @returns The allocated framebuffer object (type depends on the allocator).\n */\n createFramebuffer<TFramebuffer = unknown>(desc: RGFramebufferDesc): TFramebuffer;\n\n /**\n * Register a cleanup callback to run when graph execution finishes or aborts.\n *\n * Callbacks run in reverse registration order. Use this for temporary objects\n * created inside pass execution that are not graph resources, such as pooled\n * framebuffers wrapping graph-managed textures. If pass execution throws, the\n * executor still runs cleanup callbacks and preserves the original pass error\n * ahead of cleanup errors.\n *\n * @param callback - Cleanup function to invoke after execution.\n */\n deferCleanup(callback: () => void): void;\n}\n\n/**\n * Execute callback signature.\n *\n * The callback receives a context for resolving handles to GPU resources,\n * plus the user data returned from the setup function.\n *\n * @public\n */\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\n\n/**\n * Ordered execution step inside a render graph pass.\n *\n * Subpasses share the parent pass's resource declarations, lifetime, culling,\n * and access validation. They are intended to make multi-step pass bodies\n * explicit without splitting graph-level resource dependencies.\n *\n * @public\n */\nexport class RGSubpass<T = unknown> {\n readonly name: string;\n readonly executeFn: RGExecuteFn<T>;\n\n constructor(name: string, executeFn: RGExecuteFn<T>) {\n this.name = name;\n this.executeFn = executeFn;\n }\n}\n\n/**\n * Internal bookkeeping for a pass within the render graph.\n * @public\n */\nexport class RGPass<T = unknown> {\n readonly index: number;\n readonly name: string;\n /** Resources this pass reads (dependencies). */\n readonly reads: RGResource[] = [];\n /** Resources this pass creates or writes. */\n readonly writes: RGResource[] = [];\n /** Passes that must complete before this pass due to non-resource hazards. */\n readonly dependencies: RGPass[] = [];\n /** Whether this pass has side effects and must not be culled. */\n hasSideEffect = false;\n /** User data returned from the setup function. */\n data: T | null = null;\n /** Execute callback. */\n executeFn: RGExecuteFn<T> | null = null;\n /** Ordered subpasses for passes with multiple logical execution steps. */\n readonly subpasses: RGSubpass<T>[] = [];\n /** Set during compilation: true if this pass is needed. */\n alive = true;\n\n constructor(index: number, name: string) {\n this.index = index;\n this.name = name;\n }\n}\n\n// ─── Pass Builder ───────────────────────────────────────────────────────\n\n/**\n * Builder interface used within the setup callback of {@link RenderGraph.addPass}\n * to declare a pass's resource requirements.\n *\n * @public\n */\nexport interface RGPassBuilder {\n /**\n * Declare a read dependency on an existing resource.\n *\n * The resource must have been created by a prior pass or imported into the graph.\n *\n * @param handle - Handle of the resource to read.\n */\n read(handle: RGHandle): void;\n\n /**\n * Declare that this pass writes a new version of an existing resource.\n *\n * The returned handle represents the post-write version. Use it for subsequent\n * reads and as the graph output passed to {@link RenderGraph.compile}. Passing\n * an older version of the same resource to `compile()` is rejected because it\n * usually means the caller ignored the handle returned by `write()`. If the pass\n * needs the previous contents, call {@link RGPassBuilder.read} on the input handle explicitly\n * before writing.\n *\n * @param handle - Handle of the resource to write to.\n * @returns A handle referencing the newly written version.\n */\n write(handle: RGHandle): RGHandle;\n\n /**\n * Create a new transient texture resource that this pass will produce.\n *\n * @param desc - Texture descriptor.\n * @returns A handle referencing the newly created resource.\n */\n createTexture(desc: RGTextureDesc): RGHandle;\n\n /**\n * Create a logical dependency token produced by this pass.\n *\n * Tokens do not resolve to GPU resources and are not allocated by the executor.\n * They are useful for ordering passes whose dependencies are side effects rather\n * than texture reads/writes.\n *\n * @param name - Debug label for this token.\n * @returns A handle referencing the newly created token.\n */\n createToken(name?: string): RGHandle;\n\n /**\n * Create a graph-managed framebuffer view.\n *\n * The graph compiler infers dependencies from any attachment handles in the\n * descriptor. The executor creates and releases the framebuffer automatically.\n *\n * @param desc - Framebuffer descriptor.\n * @returns A handle referencing the framebuffer view.\n */\n createFramebuffer(desc: RGFramebufferDesc): RGHandle;\n\n /**\n * Mark this pass as having side effects.\n *\n * Side-effect passes are never culled by the graph compiler, regardless of\n * whether their outputs are consumed. Use this for GPU readback, picking,\n * debug overlays, etc.\n */\n sideEffect(): void;\n\n /**\n * Add an ordered logical subpass to this pass.\n *\n * Subpasses execute in registration order and share the parent pass's declared\n * reads, writes, framebuffer views, and user data. A pass may use either\n * subpasses or {@link RGPassBuilder.setExecute}, but not both.\n *\n * @param name - Debug label for the subpass.\n * @param fn - Callback invoked when this subpass executes.\n */\n addSubpass<D>(name: string, fn: RGExecuteFn<D>): void;\n\n /**\n * Set the execution callback for this pass.\n *\n * A pass may use either this method or {@link RGPassBuilder.addSubpass}, but not both.\n *\n * @param fn - Callback invoked during graph execution.\n */\n setExecute<D>(fn: RGExecuteFn<D>): void;\n}\n\n// ─── Compiled Graph ─────────────────────────────────────────────────────\n\n/**\n * Lifetime information for a resource within the compiled graph.\n *\n * @public\n */\nexport interface RGResourceLifetime {\n /** The resource. */\n readonly resource: RGResource;\n /** Index of the first pass that uses (produces or reads) this resource. */\n readonly firstUse: number;\n /** Index of the last pass that uses this resource. */\n readonly lastUse: number;\n}\n\n/**\n * Result of compiling a render graph.\n *\n * Contains the ordered list of passes to execute and lifetime information\n * for automatic resource management.\n *\n * @public\n */\nexport interface CompiledRenderGraph {\n /** Topologically sorted passes (only non-culled passes). */\n readonly orderedPasses: ReadonlyArray<RGPass>;\n /** Resource lifetime information keyed by resource ID. */\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\n}\n\n// ─── Texture Allocator ──────────────────────────────────────────────\n\n/**\n * Resolved dimensions for a texture allocation.\n * @public\n */\nexport interface RGResolvedSize {\n width: number;\n height: number;\n}\n\n/**\n * Descriptor for a framebuffer view managed by the graph or created temporarily during pass execution.\n *\n * This is intentionally backend-agnostic: graph-managed descriptors may use\n * {@link RGHandle} attachments, and executor-created descriptors use resolved\n * resources or texture formats understood by the allocator.\n *\n * @public\n */\nexport interface RGFramebufferDesc {\n /** Debug label for this framebuffer. */\n label?: string;\n /** Framebuffer width. Required when attachments are formats. */\n width?: number;\n /** Framebuffer height. Required when attachments are formats. */\n height?: number;\n /** Color attachments or formats. */\n colorAttachments: unknown | unknown[] | null;\n /** Depth/stencil attachment or format. */\n depthAttachment?: unknown | null;\n /** Whether color attachments created from formats should support mipmapping. */\n mipmapping?: boolean;\n /** Framebuffer sample count. */\n sampleCount?: number;\n /** Whether to ignore depth/stencil during MSAA resolve. */\n ignoreDepthStencil?: boolean;\n /** Attachment mip level. */\n attachmentMipLevel?: number;\n /** Attachment cubemap face. */\n attachmentCubeface?: number;\n /** Attachment array layer. */\n attachmentLayer?: number;\n}\n\n/**\n * Interface for allocating and releasing transient textures.\n *\n * Implement this to bridge the render graph with your GPU device's resource pool.\n * The executor calls `allocate()` before a resource's first use and\n * `release()` after its last use.\n *\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\n * @public\n */\nexport interface RGTextureAllocator<TTexture = unknown, TFramebuffer = unknown> {\n /**\n * Allocate a transient texture matching the given descriptor and resolved size.\n *\n * @param desc - The texture descriptor from the pass builder.\n * @param size - The resolved pixel dimensions.\n * @returns The allocated texture object.\n */\n allocate(desc: RGTextureDesc, size: RGResolvedSize): TTexture;\n\n /**\n * Release a previously allocated transient texture back to the pool.\n *\n * @param texture - The texture to release.\n */\n release(texture: TTexture): void;\n\n /**\n * Allocate a temporary framebuffer matching the given descriptor.\n *\n * Implementations should not auto-release this framebuffer; the graph executor\n * calls {@link RGTextureAllocator.releaseFramebuffer} when execution completes or aborts.\n *\n * @param desc - Framebuffer descriptor.\n * @returns The allocated framebuffer object.\n */\n allocateFramebuffer?(desc: RGFramebufferDesc): TFramebuffer;\n\n /**\n * Release a previously allocated temporary framebuffer.\n *\n * @param framebuffer - The framebuffer to release.\n */\n releaseFramebuffer?(framebuffer: TFramebuffer): void;\n}\n"],"names":["RGHandle","id","name","_id","_name","RGResource","kind","desc","producer","consumers","physicalId","RGSubpass","executeFn","RGPass","index","reads","writes","dependencies","hasSideEffect","data","subpasses","alive"],"mappings":"AAoCA;AAEA;;;;;;;;AAQC,IACM,MAAMA,QAAAA,CAAAA;qBAEX,GAAqB;qBAErB,KAAuB;AAEvB,qBACA,WAAA,CAAYC,EAAU,EAAEC,IAAY,CAAE;QACpC,IAAI,CAACC,GAAG,GAAGF,EAAAA;QACX,IAAI,CAACG,KAAK,GAAGF,IAAAA;AACf;2DAGA,IAAIA,IAAe,GAAA;QACjB,OAAO,IAAI,CAACE,KAAK;AACnB;AACF;AAOA;;;AAGC,IACM,MAAMC,UAAAA,CAAAA;IACFJ,EAAW;IACXC,IAAa;IACbI,IAAqB;IACrBC,IAA+C;mFAExD,UAA4B;2FAE5BC,WAA0B,IAAK;AAC/B,2CACSC,SAAsB,GAAA,EAAE;IAEjC,WACER,CAAAA,EAAU,EACVC,IAAY,EACZI,IAAoB,EACpBC,IAA8C,EAC9CG,UAAaT,GAAAA,EAAE,CACf;QACA,IAAI,CAACA,EAAE,GAAGA,EAAAA;QACV,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACI,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACG,UAAU,GAAGA,UAAAA;AACpB;AACF;AA4EA;;;;;;;;AAQC,IACM,MAAMC,SAAAA,CAAAA;IACFT,IAAa;IACbU,SAA0B;IAEnC,WAAYV,CAAAA,IAAY,EAAEU,SAAyB,CAAE;QACnD,IAAI,CAACV,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACU,SAAS,GAAGA,SAAAA;AACnB;AACF;AAEA;;;AAGC,IACM,MAAMC,MAAAA,CAAAA;IACFC,KAAc;IACdZ,IAAa;AACtB,qDACSa,KAAsB,GAAA,EAAE;AACjC,kDACSC,MAAuB,GAAA,EAAE;AAClC,mFACSC,YAAyB,GAAA,EAAE;sEAEpCC,gBAAgB,KAAM;uDAEtBC,OAAiB,IAAK;6BAEtBP,YAAmC,IAAK;AACxC,+EACSQ,SAA4B,GAAA,EAAE;gEAEvCC,QAAQ,IAAK;IAEb,WAAYP,CAAAA,KAAa,EAAEZ,IAAY,CAAE;QACvC,IAAI,CAACY,KAAK,GAAGA,KAAAA;QACb,IAAI,CAACZ,IAAI,GAAGA,IAAAA;AACd;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rendertarget.js","sources":["../../src/render/rendertarget.ts"],"sourcesContent":["import type { Matrix4x4, Nullable } from '@zephyr3d/base';\r\n\r\nexport abstract class RenderTarget {\r\n abstract getVersion(): number;\r\n abstract calcViewport(outViewport?: Nullable<number[]>): number[];\r\n abstract calcRelativeViewport(outViewport?: Nullable<number[]>): number[];\r\n abstract calcPerspectiveProjection(\r\n fov: number,\r\n nearClip: number,\r\n farClip: number,\r\n outMatrix?: Matrix4x4\r\n ): Matrix4x4;\r\n abstract calcOrthographicProjection(nearClip: number, farClip: number, outMatrix?: Matrix4x4): Matrix4x4;\r\n}\r\n"],"names":["RenderTarget"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rendertarget.js","sources":["../../src/render/rendertarget.ts"],"sourcesContent":["import type { Matrix4x4, Nullable } from '@zephyr3d/base';\r\n\r\n/**\r\n * Abstract render target used to derive viewports and projection matrices.\r\n *\r\n * @public\r\n */\r\nexport abstract class RenderTarget {\r\n abstract getVersion(): number;\r\n abstract calcViewport(outViewport?: Nullable<number[]>): number[];\r\n abstract calcRelativeViewport(outViewport?: Nullable<number[]>): number[];\r\n abstract calcPerspectiveProjection(\r\n fov: number,\r\n nearClip: number,\r\n farClip: number,\r\n outMatrix?: Matrix4x4\r\n ): Matrix4x4;\r\n abstract calcOrthographicProjection(nearClip: number, farClip: number, outMatrix?: Matrix4x4): Matrix4x4;\r\n}\r\n"],"names":["RenderTarget"],"mappings":"AAEA;;;;AAIC,IACM,MAAeA,YAAAA,CAAAA;AAWtB;;;;"}
|