@playcanvas/inspector 0.1.0
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/LICENSE +19 -0
- package/README.md +110 -0
- package/package.json +62 -0
- package/src/asset-usage.js +108 -0
- package/src/asset-view.js +370 -0
- package/src/camera-view.js +128 -0
- package/src/debug.js +31 -0
- package/src/describe.js +302 -0
- package/src/entity-inspector-script.js +130 -0
- package/src/frame-graph-view.js +767 -0
- package/src/hierarchy-view.js +475 -0
- package/src/index.js +4 -0
- package/src/input/fly-controller.js +116 -0
- package/src/input/input.js +299 -0
- package/src/input/math.js +8 -0
- package/src/input/orbit-controller.js +158 -0
- package/src/input/pose.js +207 -0
- package/src/inspector.js +3293 -0
- package/src/instance-survey.js +50 -0
- package/src/list-view.js +410 -0
- package/src/material-view.js +197 -0
- package/src/memory-view.js +344 -0
- package/src/mesh-view.js +235 -0
- package/src/model.js +170 -0
- package/src/node-model.js +404 -0
- package/src/physics-debug.js +527 -0
- package/src/physics-view.js +314 -0
- package/src/picker/picker.js +545 -0
- package/src/picker/render-pass-picker.js +206 -0
- package/src/property-view.js +628 -0
- package/src/render-target-view.js +288 -0
- package/src/renderers/texture-renderer-shaders.js +139 -0
- package/src/renderers/texture-renderer.js +430 -0
- package/src/renderers/wire-renderer.js +954 -0
- package/src/script-view.js +288 -0
- package/src/shader-view.js +287 -0
- package/src/styles.js +918 -0
- package/src/texture-view.js +186 -0
- package/src/tooltip.js +72 -0
- package/src/viewport-tools.js +695 -0
- package/types/asset-usage.d.ts +23 -0
- package/types/asset-view.d.ts +94 -0
- package/types/camera-view.d.ts +45 -0
- package/types/debug.d.ts +14 -0
- package/types/describe.d.ts +43 -0
- package/types/entity-inspector-script.d.ts +87 -0
- package/types/frame-graph-view.d.ts +155 -0
- package/types/hierarchy-view.d.ts +172 -0
- package/types/index.d.ts +3 -0
- package/types/input/fly-controller.d.ts +42 -0
- package/types/input/input.d.ts +192 -0
- package/types/input/math.d.ts +1 -0
- package/types/input/orbit-controller.d.ts +63 -0
- package/types/input/pose.d.ts +126 -0
- package/types/inspector.d.ts +1304 -0
- package/types/instance-survey.d.ts +35 -0
- package/types/list-view.d.ts +151 -0
- package/types/material-view.d.ts +63 -0
- package/types/memory-view.d.ts +95 -0
- package/types/mesh-view.d.ts +89 -0
- package/types/model.d.ts +104 -0
- package/types/node-model.d.ts +54 -0
- package/types/physics-debug.d.ts +254 -0
- package/types/physics-view.d.ts +81 -0
- package/types/picker/picker.d.ts +255 -0
- package/types/picker/render-pass-picker.d.ts +47 -0
- package/types/property-view.d.ts +189 -0
- package/types/render-target-view.d.ts +98 -0
- package/types/renderers/texture-renderer-shaders.d.ts +9 -0
- package/types/renderers/texture-renderer.d.ts +231 -0
- package/types/renderers/wire-renderer.d.ts +347 -0
- package/types/script-view.d.ts +56 -0
- package/types/shader-view.d.ts +46 -0
- package/types/styles.d.ts +22 -0
- package/types/texture-view.d.ts +30 -0
- package/types/tooltip.d.ts +17 -0
- package/types/viewport-tools.d.ts +237 -0
|
@@ -0,0 +1,767 @@
|
|
|
1
|
+
import { FramePass, RenderPassForward, SHADER_FORWARD } from 'playcanvas';
|
|
2
|
+
|
|
3
|
+
import { describeValue } from './describe.js';
|
|
4
|
+
import { nodeLabel } from './memory-view.js';
|
|
5
|
+
import { formatName, makeSection, passDisplayName, push, read, reflectRows, renderTargetSummary } from './model.js';
|
|
6
|
+
import { meshInstanceRows } from './node-model.js';
|
|
7
|
+
|
|
8
|
+
/** @import { AppBase } from 'playcanvas' */
|
|
9
|
+
/** @import { GraphicsDevice } from 'playcanvas' */
|
|
10
|
+
/** @import { RenderTarget } from 'playcanvas' */
|
|
11
|
+
/** @import { Described } from './describe.js' */
|
|
12
|
+
/** @import { ListRow } from './list-view.js' */
|
|
13
|
+
/** @import { PropertyRow, PropertySection } from './model.js' */
|
|
14
|
+
/** @import { MeshInstance } from 'playcanvas' */
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* One pass of a captured frame.
|
|
18
|
+
*
|
|
19
|
+
* @typedef {object} PassEntry
|
|
20
|
+
* @ignore
|
|
21
|
+
* @property {FramePass} pass - The pass.
|
|
22
|
+
* @property {number} index - The position in execution order.
|
|
23
|
+
* @property {string} key - A key stable across frames for passes that are recreated each frame.
|
|
24
|
+
* @property {number} depth - How many passes own this one, through their before and after passes or
|
|
25
|
+
* as the children of a multi-view pass.
|
|
26
|
+
* @property {FramePass|null} parent - The pass owning this one, if any.
|
|
27
|
+
* @property {number} children - The number of passes this one owns directly.
|
|
28
|
+
* @property {number} views - The XR views the pass is replicated for, or 0 outside multi-view.
|
|
29
|
+
* @property {RenderTarget|null|undefined} renderTarget - The target the pass renders to, with the
|
|
30
|
+
* backbuffer resolved to the device's backbuffer object; undefined for passes that render nothing.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The frame graph of one frame, flattened.
|
|
35
|
+
*
|
|
36
|
+
* @typedef {object} FrameSnapshot
|
|
37
|
+
* @ignore
|
|
38
|
+
* @property {PassEntry[]} entries - The passes in execution order.
|
|
39
|
+
* @property {Map<RenderTarget, PassEntry[]>} usage - The passes rendering into each target.
|
|
40
|
+
* @property {Map<string, number>} nameCounts - How many passes share each profiler name.
|
|
41
|
+
* @property {Map<string, number>|null} timings - GPU time per profiler name, when profiling is on.
|
|
42
|
+
* @property {number|undefined} frameTime - The GPU time of the whole frame, when known.
|
|
43
|
+
* @property {Map<object, VisibleList|null>} visible - What each layer step of a forward pass drew,
|
|
44
|
+
* by step, or null when its camera has not culled the layer.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The mesh instances a layer step submitted in one frame, in draw order.
|
|
49
|
+
*
|
|
50
|
+
* @typedef {object} VisibleList
|
|
51
|
+
* @ignore
|
|
52
|
+
* @property {MeshInstance[]} instances - The instances, after culling, the transparency split and
|
|
53
|
+
* sorting, including any debug lines the immediate renderer added.
|
|
54
|
+
* @property {number} drawn - How many were actually drawn, leaving out {@link skipped}.
|
|
55
|
+
* @property {Set<MeshInstance>} skipped - Instances the forward renderer passes over: masked out of
|
|
56
|
+
* the step's shader pass, or instanced with no instances and no draw commands.
|
|
57
|
+
* @property {Set<MeshInstance>} debugLines - Instances that are batches of debug lines.
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The context the pass model needs besides the pass.
|
|
62
|
+
*
|
|
63
|
+
* @typedef {object} PassModelContext
|
|
64
|
+
* @ignore
|
|
65
|
+
* @property {GraphicsDevice} device - The device.
|
|
66
|
+
* @property {FrameSnapshot|null} frame - The captured frame.
|
|
67
|
+
* @property {string|null} [passKey] - The list key of the pass, to keep its pages apart from others.
|
|
68
|
+
* @property {Map<string, number>} [pages] - The page shown for each layer step, kept across refreshes.
|
|
69
|
+
* @property {string} [filter] - A lower-cased filter the listed instances must match by node name.
|
|
70
|
+
* @property {boolean} [stable] - Whether the app is paused or the frame frozen, so pages hold still.
|
|
71
|
+
* @property {DebugFrameContext|null} [debug] - The debug frame, when it is on.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* What the pass and step models need to show a debug frame: the draw it stops at, and how to
|
|
76
|
+
* choose another.
|
|
77
|
+
*
|
|
78
|
+
* @typedef {object} DebugFrameContext
|
|
79
|
+
* @ignore
|
|
80
|
+
* @property {string|null} stepKey - The list key of the layer step the frame stops in.
|
|
81
|
+
* @property {number} index - The draw it stops at, in that step's list.
|
|
82
|
+
* @property {MeshInstance|null} instance - The instance drawn last.
|
|
83
|
+
* @property {(stepKey: string, index: number, instance: MeshInstance) => void} choose - Makes an
|
|
84
|
+
* instance the last one drawn.
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* What a layer step row of the pass list selects: one step of a forward pass, rather than the pass.
|
|
89
|
+
*
|
|
90
|
+
* @ignore
|
|
91
|
+
*/
|
|
92
|
+
class LayerStepSelection {
|
|
93
|
+
/**
|
|
94
|
+
* @param {RenderPassForward} pass - The forward pass the step belongs to.
|
|
95
|
+
* @param {*} step - The layer render step.
|
|
96
|
+
* @param {number} index - The step's index within the pass.
|
|
97
|
+
*/
|
|
98
|
+
constructor(pass, step, index) {
|
|
99
|
+
this.pass = pass;
|
|
100
|
+
this.step = step;
|
|
101
|
+
this.index = index;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** How many mesh instances a page of a layer step shows. */
|
|
106
|
+
const INSTANCES_PER_PAGE = 200;
|
|
107
|
+
|
|
108
|
+
/** @type {WeakMap<object, number>} */
|
|
109
|
+
const instanceIds = new WeakMap();
|
|
110
|
+
let nextInstanceId = 1;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @param {MeshInstance} instance - A mesh instance.
|
|
114
|
+
* @returns {number} An id that stays the same for the lifetime of the instance, so an instance
|
|
115
|
+
* opened in the list stays open when the draw order changes.
|
|
116
|
+
*/
|
|
117
|
+
function instanceId(instance) {
|
|
118
|
+
let id = instanceIds.get(instance);
|
|
119
|
+
if (id === undefined) {
|
|
120
|
+
id = nextInstanceId++;
|
|
121
|
+
instanceIds.set(instance, id);
|
|
122
|
+
}
|
|
123
|
+
return id;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Reads what a layer step drew in the last frame. The culler fills each layer's list per camera and
|
|
128
|
+
* sub-layer, the forward renderer sorts it in place and adds debug lines to it, and it is only
|
|
129
|
+
* cleared when the next frame culls again, so between frames it holds exactly what was submitted.
|
|
130
|
+
* The layer's store is read directly: its accessor creates an empty entry for a camera it has not
|
|
131
|
+
* seen, which would change the engine's state.
|
|
132
|
+
*
|
|
133
|
+
* @param {*} step - A layer render step of a forward pass.
|
|
134
|
+
* @param {Set<MeshInstance>} debugLines - The mesh instances of the immediate renderer's batches.
|
|
135
|
+
* @returns {VisibleList|null} What it drew, or null when its camera has not culled the layer.
|
|
136
|
+
*/
|
|
137
|
+
function captureVisible(step, debugLines) {
|
|
138
|
+
const camera = step.cameraComponent?.camera;
|
|
139
|
+
const culled = camera ? step.layer?._visibleInstances?.get(camera) : undefined;
|
|
140
|
+
if (!culled) return null;
|
|
141
|
+
const list = step.transparent ? culled.transparent : culled.opaque;
|
|
142
|
+
|
|
143
|
+
// the checks the forward renderer makes before drawing. A mask that the owner toggles during
|
|
144
|
+
// the frame, as the texture preview quads do, reads as it was left afterwards
|
|
145
|
+
const pass = camera.shaderPassInfo?.index ?? SHADER_FORWARD;
|
|
146
|
+
const skipped = new Set();
|
|
147
|
+
for (const instance of list) {
|
|
148
|
+
if ((instance.shaderPassMask & (1 << pass)) === 0) {
|
|
149
|
+
skipped.add(instance);
|
|
150
|
+
} else if (instance.instancingData && instance.instancingData.count <= 0 && !instance.getDrawCommands?.(camera)) {
|
|
151
|
+
skipped.add(instance);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return { instances: list.slice(), drawn: list.length - skipped.size, skipped, debugLines };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @param {MeshInstance} instance - A mesh instance drawn by a layer step.
|
|
160
|
+
* @param {VisibleList} list - The list it was drawn from.
|
|
161
|
+
* @returns {string} The name to show and filter it by.
|
|
162
|
+
*/
|
|
163
|
+
function instanceName(instance, list) {
|
|
164
|
+
return list.debugLines.has(instance) ? 'debug lines' : nodeLabel(instance.node ?? null);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @param {VisibleList|null} list - What a layer step drew.
|
|
169
|
+
* @param {string} filter - A lower-cased filter.
|
|
170
|
+
* @returns {boolean} Whether any instance it drew matches the filter by name.
|
|
171
|
+
*/
|
|
172
|
+
function drewMatching(list, filter) {
|
|
173
|
+
return !!list?.instances.some(instance => instanceName(instance, list).toLowerCase().includes(filter));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @param {VisibleList|null} list - What a layer step drew.
|
|
178
|
+
* @param {*} layer - The step's layer.
|
|
179
|
+
* @returns {string} How many meshes it drew, out of how many the layer holds.
|
|
180
|
+
*/
|
|
181
|
+
function drawnText(list, layer) {
|
|
182
|
+
const total = layer.meshInstances.length;
|
|
183
|
+
return list ? `${list.drawn} of ${total} meshes` : `${total} meshes, not culled for this camera`;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* One page of what a layer step drew, in draw order, each instance opening into its own rows. Long
|
|
188
|
+
* lists page rather than show everything, since every shown row is re-read on each refresh. The
|
|
189
|
+
* filter narrows the list by node name before paging.
|
|
190
|
+
*
|
|
191
|
+
* @param {VisibleList} list - What the step drew.
|
|
192
|
+
* @param {string} key - Identifies the step across refreshes, to remember its page.
|
|
193
|
+
* @param {PassModelContext} ctx - The pages, the filter and whether the frame holds still.
|
|
194
|
+
* @returns {PropertyRow[]} The rows.
|
|
195
|
+
*/
|
|
196
|
+
function instancePage(list, key, ctx) {
|
|
197
|
+
const filter = ctx.filter ?? '';
|
|
198
|
+
const pages = ctx.pages ?? new Map();
|
|
199
|
+
const matching = [];
|
|
200
|
+
list.instances.forEach((instance, index) => {
|
|
201
|
+
if (!filter || instanceName(instance, list).toLowerCase().includes(filter)) matching.push(index);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
const count = Math.max(1, Math.ceil(matching.length / INSTANCES_PER_PAGE));
|
|
205
|
+
const page = Math.min(pages.get(key) ?? 0, count - 1);
|
|
206
|
+
pages.set(key, page);
|
|
207
|
+
const start = page * INSTANCES_PER_PAGE;
|
|
208
|
+
const shown = matching.slice(start, start + INSTANCES_PER_PAGE);
|
|
209
|
+
|
|
210
|
+
const rows = [];
|
|
211
|
+
if (matching.length > INSTANCES_PER_PAGE || filter) {
|
|
212
|
+
rows.push({
|
|
213
|
+
key: 'pager',
|
|
214
|
+
label: 'showing',
|
|
215
|
+
value: {
|
|
216
|
+
text: `${matching.length ? `${start + 1}–${start + shown.length}` : 'none'} of ${matching.length}` +
|
|
217
|
+
`${filter ? ` matching "${filter}"` : ''}${ctx.stable ? '' : ' · live: pause or freeze to page steadily'}`,
|
|
218
|
+
cls: 'num',
|
|
219
|
+
actions: [
|
|
220
|
+
{ text: '‹', title: 'Previous page', disabled: page === 0, run: () => pages.set(key, page - 1) },
|
|
221
|
+
{ text: '›', title: 'Next page', disabled: page >= count - 1, run: () => pages.set(key, page + 1) }
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
for (const index of shown) {
|
|
228
|
+
const instance = list.instances[index];
|
|
229
|
+
const skipped = list.skipped.has(instance);
|
|
230
|
+
const material = instance.material ? `material "${instance.material.name}"` : 'no material';
|
|
231
|
+
// in a debug frame an instance is a choice of where the frame stops, and opens from its caret
|
|
232
|
+
const debug = ctx.debug ?? null;
|
|
233
|
+
rows.push({
|
|
234
|
+
key: `mi${instanceId(instance)}`,
|
|
235
|
+
label: `${index}`,
|
|
236
|
+
group: true,
|
|
237
|
+
value: {
|
|
238
|
+
text: `${instanceName(instance, list)} · ${material} · ${instance.mesh?.vertexBuffer?.numVertices ?? 0} verts` +
|
|
239
|
+
`${skipped ? ' · not drawn in this pass' : ''}`,
|
|
240
|
+
cls: skipped ? 'null' : 'obj',
|
|
241
|
+
expand: () => meshInstanceRows(instance),
|
|
242
|
+
select: debug ? () => debug.choose(key, index, instance) : undefined,
|
|
243
|
+
active: !!debug && debug.stepKey === key && debug.instance === instance
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
if (!matching.length && !filter) {
|
|
248
|
+
rows.push({ key: 'none', label: '', value: { text: 'nothing drawn', cls: 'null' } });
|
|
249
|
+
}
|
|
250
|
+
return rows;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// pass properties the model shows explicitly, or that are plumbing
|
|
254
|
+
const SKIP_PASS = [
|
|
255
|
+
'name', 'enabled', 'executeEnabled', 'requiresCubemaps', 'device', 'renderTarget', 'colorOps',
|
|
256
|
+
'colorArrayOps', 'depthStencilOps', 'beforePasses', 'afterPasses', 'children', 'samples',
|
|
257
|
+
'scaleX', 'scaleY', 'options', 'fullSizeClearRect', 'layerRenderSteps', 'renderer', 'scene',
|
|
258
|
+
'shadowRenderer'
|
|
259
|
+
];
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Mirrors how the GPU profiler keys its per-pass timings.
|
|
263
|
+
*
|
|
264
|
+
* @param {FramePass} pass - The pass.
|
|
265
|
+
* @returns {string} The profiler name.
|
|
266
|
+
*/
|
|
267
|
+
function profilerName(pass) {
|
|
268
|
+
const name = pass.name;
|
|
269
|
+
return name.startsWith('RenderPass') ? name.slice(10) : name;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* @param {object} ops - Color attachment ops.
|
|
274
|
+
* @returns {string} Load and store actions in the trace's notation.
|
|
275
|
+
*/
|
|
276
|
+
function colorOpsText(ops) {
|
|
277
|
+
return `${ops.clear ? 'clear' : 'load'}→${ops.store ? 'store' : 'discard'}` +
|
|
278
|
+
`${ops.resolve ? ' resolve' : ''}${ops.genMipmaps ? ' mipmaps' : ''}`;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* @param {object} ops - Depth-stencil ops.
|
|
283
|
+
* @returns {string} Depth load and store actions.
|
|
284
|
+
*/
|
|
285
|
+
function depthOpsText(ops) {
|
|
286
|
+
return `${ops.clearDepth ? 'clear' : 'load'}→${ops.storeDepth ? 'store' : 'discard'}${ops.resolveDepth ? ' resolve' : ''}`;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* @param {object} ops - Depth-stencil ops.
|
|
291
|
+
* @returns {string} Stencil load and store actions.
|
|
292
|
+
*/
|
|
293
|
+
function stencilOpsText(ops) {
|
|
294
|
+
return `${ops.clearStencil ? 'clear' : 'load'}→${ops.storeStencil ? 'store' : 'discard'}`;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* @param {FramePass} pass - The pass.
|
|
299
|
+
* @param {RenderTarget} rt - Its resolved target.
|
|
300
|
+
* @param {GraphicsDevice} device - The device.
|
|
301
|
+
* @returns {number} The number of color attachments the pass writes.
|
|
302
|
+
*/
|
|
303
|
+
function colorCount(pass, rt, device) {
|
|
304
|
+
const attachments = rt === device.backBuffer ? 1 : (rt.colorBufferCount ?? 0);
|
|
305
|
+
return Math.min(attachments, pass.colorArrayOps?.length ?? 0);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* @param {RenderTarget} rt - A target.
|
|
310
|
+
* @param {number} index - A color attachment index.
|
|
311
|
+
* @param {GraphicsDevice} device - The device.
|
|
312
|
+
* @returns {number|undefined} The attachment's pixel format.
|
|
313
|
+
*/
|
|
314
|
+
function colorFormat(rt, index, device) {
|
|
315
|
+
return rt === device.backBuffer ? device.backBufferFormat : rt.getColorBuffer?.(index)?.format;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Walks the frame graph the app rendered last and flattens it into execution order, the same
|
|
320
|
+
* order the render pass trace prints. Wrapper passes are recognized through their before, after and
|
|
321
|
+
* multi-view child lists so their members can be indented.
|
|
322
|
+
*
|
|
323
|
+
* @param {AppBase} app - The app.
|
|
324
|
+
* @returns {FrameSnapshot} The snapshot.
|
|
325
|
+
*/
|
|
326
|
+
function captureFrameGraph(app) {
|
|
327
|
+
const device = app.graphicsDevice;
|
|
328
|
+
const passes = app.frameGraph?.renderPasses ?? [];
|
|
329
|
+
|
|
330
|
+
/** @type {Map<FramePass, FramePass>} */
|
|
331
|
+
const parentOf = new Map();
|
|
332
|
+
const mark = (pass) => {
|
|
333
|
+
const children = [...pass.beforePasses, ...pass.afterPasses, ...(Array.isArray(pass.children) ? pass.children : [])];
|
|
334
|
+
for (const child of children) {
|
|
335
|
+
parentOf.set(child, pass);
|
|
336
|
+
mark(child);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
passes.forEach(mark);
|
|
340
|
+
|
|
341
|
+
/** @type {PassEntry[]} */
|
|
342
|
+
const entries = [];
|
|
343
|
+
const usage = new Map();
|
|
344
|
+
const nameCounts = new Map();
|
|
345
|
+
const childCounts = new Map();
|
|
346
|
+
const views = device.xrSubImages?.length ?? 0;
|
|
347
|
+
|
|
348
|
+
const add = (pass, inMultiView) => {
|
|
349
|
+
let depth = 0;
|
|
350
|
+
for (let p = parentOf.get(pass); p; p = parentOf.get(p)) depth++;
|
|
351
|
+
|
|
352
|
+
const parent = parentOf.get(pass) ?? null;
|
|
353
|
+
if (parent) childCounts.set(parent, (childCounts.get(parent) ?? 0) + 1);
|
|
354
|
+
|
|
355
|
+
const raw = pass.renderTarget;
|
|
356
|
+
const renderTarget = raw === undefined ? undefined : (raw ?? device.backBuffer ?? null);
|
|
357
|
+
|
|
358
|
+
const index = entries.length;
|
|
359
|
+
const entry = { pass, index, key: `${index}:${pass.name}`, depth, parent, children: 0, views: inMultiView ? views : 0, renderTarget };
|
|
360
|
+
entries.push(entry);
|
|
361
|
+
|
|
362
|
+
if (renderTarget) {
|
|
363
|
+
let list = usage.get(renderTarget);
|
|
364
|
+
if (!list) usage.set(renderTarget, list = []);
|
|
365
|
+
list.push(entry);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const name = profilerName(pass);
|
|
369
|
+
nameCounts.set(name, (nameCounts.get(name) ?? 0) + 1);
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
for (const pass of passes) {
|
|
373
|
+
add(pass, false);
|
|
374
|
+
if (Array.isArray(pass.children)) {
|
|
375
|
+
for (const child of pass.children) add(child, true);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
for (const entry of entries) {
|
|
379
|
+
entry.children = childCounts.get(entry.pass) ?? 0;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// what each forward pass layer step drew, copied now so a frozen frame keeps its own lists
|
|
383
|
+
const debugLines = new Set();
|
|
384
|
+
for (const batches of app.scene?.immediate?.batchesMap?.values() ?? []) {
|
|
385
|
+
for (const batch of batches.map?.values() ?? []) {
|
|
386
|
+
if (batch.meshInstance) debugLines.add(batch.meshInstance);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
const visible = new Map();
|
|
390
|
+
for (const entry of entries) {
|
|
391
|
+
if (!(entry.pass instanceof RenderPassForward)) continue;
|
|
392
|
+
for (const step of entry.pass.layerRenderSteps) {
|
|
393
|
+
visible.set(step, captureVisible(step, debugLines));
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const profiler = device.gpuProfiler;
|
|
398
|
+
return {
|
|
399
|
+
entries,
|
|
400
|
+
usage,
|
|
401
|
+
nameCounts,
|
|
402
|
+
timings: profiler?.enabled ? profiler.passTimings : null,
|
|
403
|
+
frameTime: profiler?.frameTime,
|
|
404
|
+
visible
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* The text the render pass trace would print for a pass, used as the row tooltip.
|
|
410
|
+
*
|
|
411
|
+
* @param {PassEntry} entry - The pass entry.
|
|
412
|
+
* @param {GraphicsDevice} device - The device.
|
|
413
|
+
* @returns {string} The multi-line text.
|
|
414
|
+
*/
|
|
415
|
+
function passTitle(entry, device) {
|
|
416
|
+
const { pass, index, renderTarget: rt } = entry;
|
|
417
|
+
const lines = [`${pass._skipStart ? '++' : index}: ${pass.name}${pass.executeEnabled ? '' : ' DISABLED'}`];
|
|
418
|
+
|
|
419
|
+
if (rt) {
|
|
420
|
+
lines.push(`RT: ${renderTargetSummary(rt, device)}`);
|
|
421
|
+
const count = colorCount(pass, rt, device);
|
|
422
|
+
for (let i = 0; i < count; i++) {
|
|
423
|
+
const ops = pass.colorArrayOps[i];
|
|
424
|
+
lines.push(`color[${i}]: ${colorOpsText(ops)} [${formatName(colorFormat(rt, i, device))}]` +
|
|
425
|
+
`${ops.clear ? ` clear ${ops.clearValue?.toString?.(true, true) ?? ''}` : ''}`);
|
|
426
|
+
}
|
|
427
|
+
const ds = pass.depthStencilOps;
|
|
428
|
+
if (ds && rt.depth) {
|
|
429
|
+
lines.push(`depth: ${depthOpsText(ds)}${rt.depthBuffer ? ` [${formatName(rt.depthBuffer.format)}]` : ''}` +
|
|
430
|
+
`${ds.clearDepth ? ` clear ${ds.clearDepthValue}` : ''}`);
|
|
431
|
+
}
|
|
432
|
+
if (ds && rt.stencil) {
|
|
433
|
+
lines.push(`stencil: ${stencilOpsText(ds)}${ds.clearStencil ? ` clear ${ds.clearStencilValue}` : ''}`);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
return lines.join('\n');
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Turns a snapshot into list rows: one per pass, plus one per layer step of a forward pass and one
|
|
442
|
+
* naming the light of a shadow pass. Render target cells link to the target, camera and light
|
|
443
|
+
* cells link to their entities.
|
|
444
|
+
*
|
|
445
|
+
* @param {FrameSnapshot} frame - The snapshot.
|
|
446
|
+
* @param {GraphicsDevice} device - The device.
|
|
447
|
+
* @returns {ListRow[]} The rows.
|
|
448
|
+
*/
|
|
449
|
+
function passRows(frame, device) {
|
|
450
|
+
/** @type {ListRow[]} */
|
|
451
|
+
const rows = [];
|
|
452
|
+
// for the brackets: the entry each row belongs to, and the row of each entry's pass
|
|
453
|
+
const rowEntries = [];
|
|
454
|
+
const passRowOf = [];
|
|
455
|
+
|
|
456
|
+
for (const entry of frame.entries) {
|
|
457
|
+
const { pass, index, renderTarget } = entry;
|
|
458
|
+
const name = passDisplayName(pass);
|
|
459
|
+
const merged = pass._skipStart;
|
|
460
|
+
|
|
461
|
+
const cells = [
|
|
462
|
+
{ text: merged ? `${index}+` : String(index), cls: 'pci-cell-index', title: merged ? 'Merged into the previous pass: same render target, nothing cleared' : '' },
|
|
463
|
+
{ text: name, cls: 'pci-cell-name' }
|
|
464
|
+
];
|
|
465
|
+
if (!pass.executeEnabled) cells.push({ text: 'DISABLED', cls: 'pci-cell-tag' });
|
|
466
|
+
if (entry.views > 1) cells.push({ text: `×${entry.views} views`, cls: 'pci-cell-tag pci-cell-tag-info' });
|
|
467
|
+
if (renderTarget) {
|
|
468
|
+
cells.push({ text: renderTargetSummary(renderTarget, device), cls: 'pci-cell-info', target: renderTarget });
|
|
469
|
+
} else if (entry.children) {
|
|
470
|
+
// a pass rendering nothing owns passes only to add them to the frame, and does no work
|
|
471
|
+
const own = pass.execute === FramePass.prototype.execute ? ' · no work of its own' : '';
|
|
472
|
+
const verb = Array.isArray(/** @type {any} */ (pass).children) ? 'runs' : 'owns';
|
|
473
|
+
cells.push({ text: `${verb} ${entry.children} pass${entry.children === 1 ? '' : 'es'}${own}`, cls: 'pci-cell-info' });
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
const profiler = profilerName(pass);
|
|
477
|
+
const time = frame.timings?.get(profiler);
|
|
478
|
+
if (time !== undefined) {
|
|
479
|
+
const shared = frame.nameCounts.get(profiler) ?? 1;
|
|
480
|
+
cells.push({
|
|
481
|
+
text: `${time.toFixed(2)} ms${shared > 1 ? ' Σ' : ''}`,
|
|
482
|
+
cls: 'pci-cell-time',
|
|
483
|
+
title: shared > 1 ? `GPU time summed over ${shared} passes named ${profiler}` : 'GPU time'
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// a forward pass also matches the filter by the names of what it drew, so a name finds the
|
|
488
|
+
// passes and steps that rendered it
|
|
489
|
+
const steps = pass instanceof RenderPassForward ? pass.layerRenderSteps : [];
|
|
490
|
+
const lists = steps.map(step => frame.visible?.get(step) ?? null);
|
|
491
|
+
const passMatches = steps.length ?
|
|
492
|
+
filter => name.toLowerCase().includes(filter) || lists.some(list => drewMatching(list, filter)) : undefined;
|
|
493
|
+
// hovering the pass previews what it rendered into; the screen needs no preview
|
|
494
|
+
const preview = renderTarget && renderTarget !== device.backBuffer ? renderTarget : undefined;
|
|
495
|
+
passRowOf[index] = rows.length;
|
|
496
|
+
rows.push({ key: entry.key, item: pass, name, matches: passMatches, preview, dim: !pass.executeEnabled, title: passTitle(entry, device), cells });
|
|
497
|
+
|
|
498
|
+
steps.forEach((step, i) => {
|
|
499
|
+
const layer = step.layer;
|
|
500
|
+
const enabled = layer.enabled && (pass.layerComposition?.isEnabled(layer, step.transparent) ?? true);
|
|
501
|
+
const camera = step.cameraComponent?.entity;
|
|
502
|
+
const flags = `${step.firstCameraUse ? ' · first' : ''}${step.lastCameraUse ? ' · last' : ''}${enabled ? '' : ' · disabled'}`;
|
|
503
|
+
rows.push({
|
|
504
|
+
key: `${entry.key}/${i}`,
|
|
505
|
+
item: new LayerStepSelection(pass, step, i),
|
|
506
|
+
name,
|
|
507
|
+
matches: filter => name.toLowerCase().includes(filter) || drewMatching(lists[i], filter),
|
|
508
|
+
preview,
|
|
509
|
+
indent: 1,
|
|
510
|
+
dim: !enabled,
|
|
511
|
+
cells: [
|
|
512
|
+
{ text: '', cls: 'pci-cell-index' },
|
|
513
|
+
{ text: camera?.name ?? '-', cls: 'pci-cell-info', target: camera ?? undefined, title: 'Camera' },
|
|
514
|
+
{ text: `· ${layer.name} · ${step.transparent ? 'transparent' : 'opaque'} · ${drawnText(lists[i], layer)}${flags}`, cls: 'pci-cell-info' }
|
|
515
|
+
]
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
const lightNode = /** @type {any} */ (pass).light?._node;
|
|
520
|
+
if (lightNode) {
|
|
521
|
+
rows.push({
|
|
522
|
+
key: `${entry.key}/light`,
|
|
523
|
+
item: pass,
|
|
524
|
+
name,
|
|
525
|
+
preview,
|
|
526
|
+
indent: 1,
|
|
527
|
+
cells: [
|
|
528
|
+
{ text: '', cls: 'pci-cell-index' },
|
|
529
|
+
{ text: 'light', cls: 'pci-cell-info' },
|
|
530
|
+
{ text: lightNode.name, cls: 'pci-cell-info', target: lightNode }
|
|
531
|
+
]
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// every row after an entry's pass row, up to the next one, belongs to that entry
|
|
537
|
+
let current = -1;
|
|
538
|
+
for (let row = 0; row < rows.length; row++) {
|
|
539
|
+
if (passRowOf[current + 1] === row) current++;
|
|
540
|
+
rowEntries.push(current);
|
|
541
|
+
}
|
|
542
|
+
const guides = passGuides(frame, rowEntries, passRowOf);
|
|
543
|
+
if (guides) {
|
|
544
|
+
rows.forEach((row, i) => {
|
|
545
|
+
row.guides = guides[i];
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
return rows;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* The brackets of the pass list. The passes a pass owns, its before and after passes and the
|
|
554
|
+
* children of a multi-view pass, are added to the frame right around it, so a pass and everything
|
|
555
|
+
* it owns always fill a run of consecutive rows. Each owner brackets that run in the lane of its
|
|
556
|
+
* own depth, and ticks its own row, which sits below its before passes and above its after passes.
|
|
557
|
+
* The rows themselves are not indented: the frame executes them one after the other.
|
|
558
|
+
*
|
|
559
|
+
* @param {FrameSnapshot} frame - The frame.
|
|
560
|
+
* @param {number[]} rowEntries - The index of the entry each row belongs to, in row order.
|
|
561
|
+
* @param {number[]} passRowOf - The row of each entry's own pass row.
|
|
562
|
+
* @returns {import('./list-view.js').ListGuides[]|null} The brackets of each row, or null when no
|
|
563
|
+
* pass owns another.
|
|
564
|
+
*/
|
|
565
|
+
function passGuides(frame, rowEntries, passRowOf) {
|
|
566
|
+
const { entries } = frame;
|
|
567
|
+
const lanes = entries.reduce((count, entry) => (entry.children ? Math.max(count, entry.depth + 1) : count), 0);
|
|
568
|
+
if (!lanes) return null;
|
|
569
|
+
|
|
570
|
+
// the first and last entry each owner spans, over everything it owns, however deep
|
|
571
|
+
const entryOf = new Map(entries.map(entry => [entry.pass, entry]));
|
|
572
|
+
const first = new Map();
|
|
573
|
+
const last = new Map();
|
|
574
|
+
for (const entry of entries) {
|
|
575
|
+
for (let owner = entryOf.get(entry.parent); owner; owner = entryOf.get(owner.parent)) {
|
|
576
|
+
first.set(owner, Math.min(first.get(owner) ?? owner.index, entry.index));
|
|
577
|
+
last.set(owner, Math.max(last.get(owner) ?? owner.index, entry.index));
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// the rows of an entry run from its pass row to the row before the next entry's pass row
|
|
582
|
+
const lastRowOf = (index) => {
|
|
583
|
+
let row = passRowOf[index];
|
|
584
|
+
while (row + 1 < rowEntries.length && rowEntries[row + 1] === index) row++;
|
|
585
|
+
return row;
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
const guides = rowEntries.map(() => ({ lanes, segments: new Array(lanes).fill(null), tick: -1 }));
|
|
589
|
+
for (const [owner, start] of first) {
|
|
590
|
+
const top = passRowOf[Math.min(start, owner.index)];
|
|
591
|
+
const bottom = lastRowOf(Math.max(last.get(owner), owner.index));
|
|
592
|
+
for (let row = top; row <= bottom; row++) {
|
|
593
|
+
guides[row].segments[owner.depth] = row === top ? 'start' : row === bottom ? 'end' : 'mid';
|
|
594
|
+
}
|
|
595
|
+
guides[passRowOf[owner.index]].tick = owner.depth;
|
|
596
|
+
}
|
|
597
|
+
return guides;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* @param {FramePass[]} passes - Passes.
|
|
602
|
+
* @returns {Described} A count that expands into one linked row per pass.
|
|
603
|
+
*/
|
|
604
|
+
function passList(passes) {
|
|
605
|
+
return {
|
|
606
|
+
text: `${passes.length} pass${passes.length === 1 ? '' : 'es'}`,
|
|
607
|
+
cls: 'obj',
|
|
608
|
+
items: passes.map((pass, i) => ({ label: `[${i}]`, text: passDisplayName(pass), cls: 'ref', target: pass }))
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Everything the property view shows for a pass: identity and structure, the render target and
|
|
614
|
+
* its attachment ops as the trace prints them, the layer steps of a forward pass, and every other
|
|
615
|
+
* public property the pass class exposes.
|
|
616
|
+
*
|
|
617
|
+
* @param {FramePass} pass - The pass.
|
|
618
|
+
* @param {PassModelContext} ctx - The device, the frame the pass was captured in, and the paging
|
|
619
|
+
* state of its layer steps.
|
|
620
|
+
* @returns {PropertySection[]} The sections.
|
|
621
|
+
*/
|
|
622
|
+
function buildPassModel(pass, ctx) {
|
|
623
|
+
const { device, frame } = ctx;
|
|
624
|
+
const entry = frame?.entries.find(e => e.pass === pass);
|
|
625
|
+
const sections = [];
|
|
626
|
+
|
|
627
|
+
const general = makeSection('pass', passDisplayName(pass));
|
|
628
|
+
push(general, 'name', describeValue(pass.name));
|
|
629
|
+
push(general, 'class', describeValue(pass.constructor.name));
|
|
630
|
+
if (entry) push(general, 'index', describeValue(entry.index));
|
|
631
|
+
push(general, 'enabled', read(pass, 'enabled'));
|
|
632
|
+
push(general, 'execute enabled', read(pass, 'executeEnabled'));
|
|
633
|
+
if (pass._skipStart) push(general, 'merged with previous', describeValue(true));
|
|
634
|
+
if (pass._skipEnd) push(general, 'merged with next', describeValue(true));
|
|
635
|
+
if (entry?.parent) {
|
|
636
|
+
const runs = Array.isArray(/** @type {any} */ (entry.parent).children) && /** @type {any} */ (entry.parent).children.includes(pass);
|
|
637
|
+
push(general, runs ? 'run by' : 'owned by', { text: passDisplayName(entry.parent), cls: 'ref', target: entry.parent });
|
|
638
|
+
}
|
|
639
|
+
if (pass.beforePasses.length) push(general, 'before passes', passList(pass.beforePasses));
|
|
640
|
+
if (pass.afterPasses.length) push(general, 'after passes', passList(pass.afterPasses));
|
|
641
|
+
const children = /** @type {any} */ (pass).children;
|
|
642
|
+
if (Array.isArray(children) && children.length) push(general, 'per-view passes', passList(children));
|
|
643
|
+
push(general, 'requires cubemaps', read(pass, 'requiresCubemaps'));
|
|
644
|
+
sections.push(general);
|
|
645
|
+
|
|
646
|
+
const rt = entry ? entry.renderTarget : (pass.renderTarget === undefined ? undefined : (pass.renderTarget ?? device.backBuffer));
|
|
647
|
+
if (rt !== undefined) {
|
|
648
|
+
const target = makeSection('target', 'Render target');
|
|
649
|
+
push(target, 'target', rt ? { text: renderTargetSummary(rt, device), cls: 'ref', target: rt } : { text: 'Backbuffer', cls: 'obj' });
|
|
650
|
+
push(target, 'samples', read(pass, 'samples'));
|
|
651
|
+
push(target, 'options', read(pass, 'options'));
|
|
652
|
+
push(target, 'full-size clear rect', read(pass, 'fullSizeClearRect'));
|
|
653
|
+
sections.push(target);
|
|
654
|
+
|
|
655
|
+
if (rt) {
|
|
656
|
+
const count = colorCount(pass, rt, device);
|
|
657
|
+
for (let i = 0; i < count; i++) {
|
|
658
|
+
const ops = pass.colorArrayOps[i];
|
|
659
|
+
const section = makeSection(`color${i}`, `Color ${i}`);
|
|
660
|
+
push(section, 'ops', { text: colorOpsText(ops), cls: 'obj' });
|
|
661
|
+
push(section, 'format', { text: formatName(colorFormat(rt, i, device)), cls: 'obj' });
|
|
662
|
+
push(section, 'clear', read(ops, 'clear'));
|
|
663
|
+
push(section, 'clear value', read(ops, 'clearValue'));
|
|
664
|
+
push(section, 'store', read(ops, 'store'));
|
|
665
|
+
push(section, 'resolve', read(ops, 'resolve'));
|
|
666
|
+
push(section, 'generate mipmaps', read(ops, 'genMipmaps'));
|
|
667
|
+
sections.push(section);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
const ds = pass.depthStencilOps;
|
|
671
|
+
if (ds && (rt.depth || rt.stencil)) {
|
|
672
|
+
const section = makeSection('depth', 'Depth / stencil');
|
|
673
|
+
if (rt.depthBuffer) push(section, 'format', { text: formatName(rt.depthBuffer.format), cls: 'obj' });
|
|
674
|
+
if (rt.depth) {
|
|
675
|
+
push(section, 'depth ops', { text: depthOpsText(ds), cls: 'obj' });
|
|
676
|
+
push(section, 'clear depth value', read(ds, 'clearDepthValue'));
|
|
677
|
+
}
|
|
678
|
+
if (rt.stencil) {
|
|
679
|
+
push(section, 'stencil ops', { text: stencilOpsText(ds), cls: 'obj' });
|
|
680
|
+
push(section, 'clear stencil value', read(ds, 'clearStencilValue'));
|
|
681
|
+
}
|
|
682
|
+
sections.push(section);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
if (pass instanceof RenderPassForward) {
|
|
688
|
+
const section = makeSection('steps', 'Layer render steps');
|
|
689
|
+
pass.layerRenderSteps.forEach((step, i) => {
|
|
690
|
+
const layer = step.layer;
|
|
691
|
+
const enabled = layer.enabled && (pass.layerComposition?.isEnabled(layer, step.transparent) ?? true);
|
|
692
|
+
const clears = `${step.clearColor ? 'color ' : ''}${step.clearDepth ? 'depth ' : ''}${step.clearStencil ? 'stencil' : ''}`.trim();
|
|
693
|
+
push(section, `[${i}] camera`, describeValue(step.cameraComponent?.entity ?? null));
|
|
694
|
+
push(section, `[${i}] layer`, describeValue(layer));
|
|
695
|
+
const list = ctx.frame?.visible?.get(step) ?? null;
|
|
696
|
+
push(section, `[${i}] draws`, {
|
|
697
|
+
text: `${step.transparent ? 'transparent' : 'opaque'}, ${drawnText(list, layer)}` +
|
|
698
|
+
`${enabled ? '' : ', disabled'}${step.firstCameraUse ? ', first camera use' : ''}${step.lastCameraUse ? ', last camera use' : ''}`,
|
|
699
|
+
cls: 'obj',
|
|
700
|
+
expand: list ? () => instancePage(list, `${ctx.passKey ?? ''}/${i}`, ctx) : undefined
|
|
701
|
+
});
|
|
702
|
+
push(section, `[${i}] clears`, { text: clears || 'nothing', cls: clears ? 'obj' : 'null' });
|
|
703
|
+
});
|
|
704
|
+
sections.push(section);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
const rest = makeSection('props', 'Properties');
|
|
708
|
+
reflectRows(rest, pass, [FramePass.prototype], SKIP_PASS);
|
|
709
|
+
if (rest.rows.length) sections.push(rest);
|
|
710
|
+
|
|
711
|
+
return sections;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* @param {*} step - A layer render step.
|
|
716
|
+
* @param {RenderPassForward} pass - The pass it belongs to.
|
|
717
|
+
* @returns {boolean} Whether the step's layer and sub-layer are enabled.
|
|
718
|
+
*/
|
|
719
|
+
function stepEnabled(step, pass) {
|
|
720
|
+
return step.layer.enabled && (pass.layerComposition?.isEnabled(step.layer, step.transparent) ?? true);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Everything the property view shows for one layer step of a forward pass: the camera and layer it
|
|
725
|
+
* renders, what it clears, and the instances it drew in draw order, listed straight away and paged
|
|
726
|
+
* the same way as under the pass, sharing the page.
|
|
727
|
+
*
|
|
728
|
+
* @param {LayerStepSelection} selection - The step and its pass.
|
|
729
|
+
* @param {PassModelContext} ctx - The frame the step was captured in, and the paging state, where
|
|
730
|
+
* `passKey` is the key of the step's own row.
|
|
731
|
+
* @returns {PropertySection[]} The sections.
|
|
732
|
+
*/
|
|
733
|
+
function buildStepModel(selection, ctx) {
|
|
734
|
+
const { pass, step, index } = selection;
|
|
735
|
+
const layer = step.layer;
|
|
736
|
+
const list = ctx.frame?.visible?.get(step) ?? null;
|
|
737
|
+
const enabled = stepEnabled(step, pass);
|
|
738
|
+
const clears = `${step.clearColor ? 'color ' : ''}${step.clearDepth ? 'depth ' : ''}${step.clearStencil ? 'stencil' : ''}`.trim();
|
|
739
|
+
const sections = [];
|
|
740
|
+
|
|
741
|
+
const general = makeSection('step', `${passDisplayName(pass)} › ${layer.name} ${step.transparent ? 'transparent' : 'opaque'}`);
|
|
742
|
+
push(general, 'pass', { text: `${passDisplayName(pass)}, step ${index}`, cls: 'ref', target: pass });
|
|
743
|
+
push(general, 'camera', describeValue(step.cameraComponent?.entity ?? null));
|
|
744
|
+
push(general, 'layer', describeValue(layer));
|
|
745
|
+
push(general, 'sub-layer', { text: step.transparent ? 'transparent' : 'opaque', cls: 'obj' });
|
|
746
|
+
push(general, 'draws', { text: drawnText(list, layer), cls: list ? 'num' : 'null' });
|
|
747
|
+
push(general, 'enabled', describeValue(enabled));
|
|
748
|
+
push(general, 'clears', { text: clears || 'nothing', cls: clears ? 'obj' : 'null' });
|
|
749
|
+
if (step.firstCameraUse) push(general, 'first camera use', describeValue(true));
|
|
750
|
+
if (step.lastCameraUse) push(general, 'last camera use', describeValue(true));
|
|
751
|
+
if (ctx.debug?.stepKey === ctx.passKey && list) {
|
|
752
|
+
push(general, 'debug frame', { text: `stops after draw ${ctx.debug.index} of ${list.instances.length}`, cls: 'num' });
|
|
753
|
+
}
|
|
754
|
+
sections.push(general);
|
|
755
|
+
|
|
756
|
+
const drawn = makeSection('instances', 'Drawn instances');
|
|
757
|
+
if (list) {
|
|
758
|
+
drawn.rows.push(...instancePage(list, ctx.passKey ?? '', ctx));
|
|
759
|
+
} else {
|
|
760
|
+
push(drawn, 'instances', { text: 'the camera has not culled this layer', cls: 'null' });
|
|
761
|
+
}
|
|
762
|
+
sections.push(drawn);
|
|
763
|
+
|
|
764
|
+
return sections;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
export { INSTANCES_PER_PAGE, LayerStepSelection, buildPassModel, buildStepModel, captureFrameGraph, passRows };
|