@playcanvas/inspector 0.4.0 → 0.6.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.
@@ -79,6 +79,16 @@ export namespace KIND_NAMES {
79
79
  * @returns {ListRow[]} The rows.
80
80
  */
81
81
  export function memoryRows(device: GraphicsDevice, owners: Map<Buffer, BufferOwner[]>): ListRow[];
82
+ /**
83
+ * What the Memory tab measures in a snapshot: every texture and buffer on the device, a group per
84
+ * kind. Textures are split by whether they are attached to a render target, and each buffer is
85
+ * named after what uses it, as in the list. The per-draw uniform pool counts as one.
86
+ *
87
+ * @param {GraphicsDevice} device - The device.
88
+ * @param {Map<Buffer, BufferOwner[]>} owners - The owners of each buffer.
89
+ * @returns {SnapshotContent} The textures and buffers measured.
90
+ */
91
+ export function memorySnapshot(device: GraphicsDevice, owners: Map<Buffer, BufferOwner[]>): SnapshotContent;
82
92
  /**
83
93
  * @param {GraphNode|null} node - The node a mesh instance draws at.
84
94
  * @returns {string} Its name, after its parent's when it has one below the root: imported models
@@ -100,3 +110,4 @@ import type { AppBase } from 'playcanvas';
100
110
  import type { PropertySection } from './model.js';
101
111
  import type { GraphicsDevice } from 'playcanvas';
102
112
  import type { ListRow } from './list-view.js';
113
+ import type { SnapshotContent } from './snapshot-view.js';
@@ -75,6 +75,17 @@ export function meshListRows(survey: MeshSurvey): ListRow[];
75
75
  * @returns {string} The note, or an empty string when every vertex buffer is accounted for.
76
76
  */
77
77
  export function meshNote(survey: MeshSurvey): string;
78
+ /**
79
+ * What the Meshes tab measures in a snapshot: the vertex and index buffers of every mesh found, a
80
+ * group per asset holding the meshes, and for meshes of no asset, a group per way they were found.
81
+ * A model file loads as a container with a render asset per mesh, so meshes are grouped by the
82
+ * container's file rather than by those.
83
+ *
84
+ * @param {MeshSurvey} survey - The meshes found.
85
+ * @param {AssetRegistry|null} registry - The registry, to find the containers.
86
+ * @returns {SnapshotContent} The meshes measured.
87
+ */
88
+ export function meshSnapshot(survey: MeshSurvey, registry: AssetRegistry | null): SnapshotContent;
78
89
  /**
79
90
  * Finds the meshes of the app. Nothing keeps a list of them, so they are found through what uses
80
91
  * them: the mesh instances of the components and layers, see {@link collectMeshInstances}; the
@@ -94,3 +105,5 @@ import { Mesh } from 'playcanvas';
94
105
  import type { AppBase } from 'playcanvas';
95
106
  import type { PropertySection } from './model.js';
96
107
  import type { ListRow } from './list-view.js';
108
+ import type { AssetRegistry } from 'playcanvas';
109
+ import type { SnapshotContent } from './snapshot-view.js';
@@ -28,6 +28,27 @@ export function captureJson(capture: PerfCapture, from: number, to: number, devi
28
28
  * @returns {object} The frame.
29
29
  */
30
30
  export function frameJson(capture: PerfCapture, seq: number): object;
31
+ /**
32
+ * @param {PerfCapture} capture - The capture.
33
+ * @param {number} from - The first frame.
34
+ * @param {number} to - The last frame, inclusive.
35
+ * @returns {object} What the frames have in common: how many, and the norms they are judged by.
36
+ */
37
+ export function header(capture: PerfCapture, from: number, to: number): object;
38
+ /**
39
+ * @param {PerfLoad} load - Something that loaded, or a moment.
40
+ * @param {number} tick - When the entry it is in began, which its times count from.
41
+ * @returns {object} It: what it was, when it began and how long it took, its request and its size.
42
+ * A moment has only when it was.
43
+ */
44
+ export function loadJson(load: PerfLoad, tick: number): object;
45
+ /**
46
+ * @param {PerfCapture} capture - The capture.
47
+ * @param {number} seq - A kept frame.
48
+ * @returns {Record<string, number>} Its GPU passes by name, those sharing a name summed, empty
49
+ * until its timings resolved.
50
+ */
51
+ export function passesOf(capture: PerfCapture, seq: number): Record<string, number>;
31
52
  /**
32
53
  * The figures of frames selected together: their averages, 95th percentiles and largest.
33
54
  *
@@ -59,3 +80,4 @@ export function seriesRows(capture: PerfCapture, key: string, from: number, to:
59
80
  */
60
81
  export function toCsv(rows: object[]): string;
61
82
  import type { PerfCapture } from './perf-capture.js';
83
+ import type { PerfLoad } from './perf-capture.js';
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Gives objects of the app ids that stay the same for as long as the registry lives, and looks
3
+ * them up again by id, without keeping them alive: an object the app lets go of is collected as
4
+ * usual, and its id then finds nothing.
5
+ *
6
+ * @ignore
7
+ */
8
+ export class RefRegistry {
9
+ /**
10
+ * @type {WeakMap<object, string>}
11
+ * @private
12
+ */
13
+ private _ids;
14
+ /**
15
+ * @type {Map<string, WeakRef<object>>}
16
+ * @private
17
+ */
18
+ private _objects;
19
+ /**
20
+ * @type {number}
21
+ * @private
22
+ */
23
+ private _next;
24
+ /**
25
+ * The number of ids at which the ids of collected objects are next dropped.
26
+ *
27
+ * @type {number}
28
+ * @private
29
+ */
30
+ private _sweepAt;
31
+ /**
32
+ * The ids given by key, see {@link RefRegistry#keyedId}, and how each finds its object.
33
+ *
34
+ * @type {Map<string, string>}
35
+ * @private
36
+ */
37
+ private _keyIds;
38
+ /**
39
+ * @type {Map<string, () => object|null>}
40
+ * @private
41
+ */
42
+ private _resolvers;
43
+ /**
44
+ * @param {object} obj - An object or a function, such as a script class.
45
+ * @returns {string} Its id, such as `material:12`.
46
+ */
47
+ idOf(obj: object): string;
48
+ /**
49
+ * Gives an id to whatever stands at a stable key, rather than to one object, for things the
50
+ * app rebuilds every frame, such as some passes of the frame graph. The id then finds the
51
+ * object standing at the key when it is looked up.
52
+ *
53
+ * @param {string} kind - The kind the id is prefixed with.
54
+ * @param {string} key - The stable key.
55
+ * @param {() => object|null} resolve - Finds the object at the key now.
56
+ * @returns {string} The id, the same for every call with the same kind and key.
57
+ */
58
+ keyedId(kind: string, key: string, resolve: () => object | null): string;
59
+ /**
60
+ * @param {string} id - An id given by {@link RefRegistry#idOf} or {@link RefRegistry#keyedId}.
61
+ * @returns {object|null} The object, or null when the id is unknown or its object is gone.
62
+ */
63
+ get(id: string): object | null;
64
+ /**
65
+ * Drops the ids of objects that were collected.
66
+ *
67
+ * @private
68
+ */
69
+ private _sweep;
70
+ }
71
+ /**
72
+ * @param {object} obj - An object.
73
+ * @returns {string} The kind its id is prefixed with, so an id says what it stands for.
74
+ */
75
+ export function kindOf(obj: object): string;
@@ -28,10 +28,11 @@ export function buildRenderTargetModel(rt: RenderTarget, ctx: {
28
28
  frame: FrameSnapshot | null;
29
29
  }): PropertySection[];
30
30
  /**
31
- * The r, g, b and a channels an uncompressed color format stores, read from its name: R8 stores
32
- * 'r', RG16F 'rg', SRGB8 'rgb', BGRA8 and RGB10A2 'rgba'. Sampling a channel the format lacks
33
- * returns a constant (0, or 1 for alpha), so a preview of it shows nothing. Empty when the name
34
- * carries no channel letters: depth, the packed 111110F and compressed formats.
31
+ * The r, g, b and a channels an uncompressed color format stores, read from its name, where each
32
+ * run of channel letters is followed by its bit count: R8 stores 'r', RG16F 'rg', SRGB8, RG11B10F
33
+ * and RGB9E5 'rgb', BGRA8 and RGB10A2 'rgba'. Sampling a channel the format lacks returns a
34
+ * constant (0, or 1 for alpha), so a preview of it shows nothing. Empty when the name carries no
35
+ * channel letters with bit counts: depth, and compressed formats such as ATC_RGB or BC7_RGBA.
35
36
  *
36
37
  * @param {number} format - A PIXELFORMAT_* constant.
37
38
  * @returns {string} The stored channels as lower-case letters from 'rgba', or ''.
@@ -81,6 +82,17 @@ export function previewSupport(texture: Texture | null, device: GraphicsDevice):
81
82
  * @returns {ListRow[]} The rows.
82
83
  */
83
84
  export function renderTargetRows(device: GraphicsDevice, frame: FrameSnapshot | null): ListRow[];
85
+ /**
86
+ * What the Render targets tab measures in a snapshot: the GPU memory of every target's
87
+ * attachments, a group per target. A texture attached to several targets, such as a depth buffer
88
+ * shared by passes or a target per mip level, is counted once, under the first. Buffers the device
89
+ * keeps for a target without a texture to measure, such as the multisampled buffers it resolves
90
+ * from, an internal depth buffer and the swap chain, are estimated from their dimensions.
91
+ *
92
+ * @param {GraphicsDevice} device - The device.
93
+ * @returns {SnapshotContent} The attachments measured.
94
+ */
95
+ export function renderTargetSnapshot(device: GraphicsDevice): SnapshotContent;
84
96
  /**
85
97
  * Whether a texture holds its rows bottom-up, as a render target with the bottom origin stores
86
98
  * them, or with the native origin on WebGL2. The texture renderer shows row 0 at the top, so such
@@ -99,3 +111,4 @@ import type { GraphicsDevice } from 'playcanvas';
99
111
  import type { FrameSnapshot } from './frame-graph-view.js';
100
112
  import type { PropertySection } from './model.js';
101
113
  import type { ListRow } from './list-view.js';
114
+ import type { SnapshotContent } from './snapshot-view.js';
@@ -37,6 +37,17 @@ export function formatUniformBuffer(format: UniformBufferFormat): string;
37
37
  * @returns {ListRow[]} The rows.
38
38
  */
39
39
  export function shaderRows(device: GraphicsDevice): ListRow[];
40
+ /**
41
+ * What the Shaders tab measures in a snapshot: the length of every shader's source, as the
42
+ * preprocessor left it, in a group per family. The engine names the variants it generates after
43
+ * their generator, then their pass, such as 'standard-forward-proc', so the family is the name up
44
+ * to its first dash; and the treemap shows how many variants each family made, as well as their
45
+ * size.
46
+ *
47
+ * @param {GraphicsDevice} device - The device.
48
+ * @returns {SnapshotContent} The shaders measured.
49
+ */
50
+ export function shaderSnapshot(device: GraphicsDevice): SnapshotContent;
40
51
  /**
41
52
  * @param {Shader} shader - A shader.
42
53
  * @returns {string} The compilation state: 'failed', 'ready' or 'compiling'.
@@ -48,3 +59,4 @@ import type { GraphicsDevice } from 'playcanvas';
48
59
  import type { BindGroupFormat } from 'playcanvas';
49
60
  import type { UniformBufferFormat } from 'playcanvas';
50
61
  import type { ListRow } from './list-view.js';
62
+ import type { SnapshotContent } from './snapshot-view.js';
@@ -0,0 +1,166 @@
1
+ /**
2
+ * What a tab measures when a snapshot of it is captured.
3
+ */
4
+ export type SnapshotContent = {
5
+ /**
6
+ * - What the sizes are, in a few words, such as 'GPU memory'.
7
+ */
8
+ measure: string;
9
+ /**
10
+ * - What was measured.
11
+ */
12
+ items: SnapshotItem[];
13
+ /**
14
+ * - What the items leave out, such as assets of unknown size.
15
+ */
16
+ note?: string;
17
+ };
18
+ /**
19
+ * A snapshot of a tab: what it measured at one moment, kept to be drawn as a treemap later.
20
+ */
21
+ export type Snapshot = {
22
+ /**
23
+ * - Its number among the snapshots of its tab, from 1. Never reused.
24
+ */
25
+ number: number;
26
+ /**
27
+ * - When it was captured, in milliseconds since the epoch.
28
+ */
29
+ time: number;
30
+ /**
31
+ * - What the sizes are.
32
+ */
33
+ measure: string;
34
+ /**
35
+ * - What was measured.
36
+ */
37
+ items: SnapshotItem[];
38
+ /**
39
+ * - What the items leave out, or an empty string.
40
+ */
41
+ note: string;
42
+ /**
43
+ * - The sum of the sizes of the items.
44
+ */
45
+ total: number;
46
+ };
47
+ /**
48
+ * The snapshots of one tab. The inspector keeps them, so they survive the panel being built
49
+ * again when it docks back from its own window.
50
+ */
51
+ export type SnapshotList = {
52
+ /**
53
+ * - The snapshots, oldest first.
54
+ */
55
+ snapshots: Snapshot[];
56
+ /**
57
+ * - The numbers of the snapshots ticked.
58
+ */
59
+ ticked: Set<number>;
60
+ /**
61
+ * - The number the next snapshot takes.
62
+ */
63
+ next: number;
64
+ };
65
+ /**
66
+ * The snapshots section of a tab: a bar to capture, compare and delete snapshots, over the list of
67
+ * them. Each opens as a treemap in a tab of its own; ticking two and comparing opens one treemap
68
+ * marking what changed between them. A snapshot is taken only when asked, rather than on every
69
+ * refresh, so it holds still to be read and compared.
70
+ *
71
+ * @ignore
72
+ */
73
+ export class SnapshotPanel {
74
+ /**
75
+ * @param {SnapshotList} state - The tab's snapshots.
76
+ * @param {string} title - The name of the tab.
77
+ * @param {() => SnapshotContent} measure - Measures the tab now.
78
+ * @param {(data: TreemapData) => void} show - Shows a treemap, in a tab of its own.
79
+ */
80
+ constructor(state: SnapshotList, title: string, measure: () => SnapshotContent, show: (data: TreemapData) => void);
81
+ /**
82
+ * The section, placed under the tab's own list.
83
+ *
84
+ * @type {HTMLElement}
85
+ */
86
+ el: HTMLElement;
87
+ /**
88
+ * The snapshots, kept by the inspector.
89
+ *
90
+ * @type {SnapshotList}
91
+ * @private
92
+ */
93
+ private _state;
94
+ /**
95
+ * The name of the tab, such as 'Memory'.
96
+ *
97
+ * @type {string}
98
+ * @private
99
+ */
100
+ private _title;
101
+ /**
102
+ * Measures the tab now.
103
+ *
104
+ * @type {() => SnapshotContent}
105
+ * @private
106
+ */
107
+ private _measure;
108
+ /**
109
+ * Shows a treemap, in a tab of its own.
110
+ *
111
+ * @type {(data: TreemapData) => void}
112
+ * @private
113
+ */
114
+ private _show;
115
+ /**
116
+ * @type {ListView}
117
+ * @private
118
+ */
119
+ private _list;
120
+ /**
121
+ * @type {Record<'capture'|'compare'|'delete'|'deleteAll', HTMLButtonElement>}
122
+ * @private
123
+ */
124
+ private _buttons;
125
+ /**
126
+ * Says what the section is for, while it has no snapshots.
127
+ *
128
+ * @type {HTMLElement}
129
+ * @private
130
+ */
131
+ private _hint;
132
+ /**
133
+ * Captures a snapshot of the tab and adds it to the list.
134
+ *
135
+ * @returns {Snapshot} The snapshot.
136
+ */
137
+ capture(): Snapshot;
138
+ /**
139
+ * Opens the two ticked snapshots as one treemap, the earlier compared against the later.
140
+ */
141
+ compare(): void;
142
+ /**
143
+ * Opens a snapshot as a treemap in a tab of its own, or two compared.
144
+ *
145
+ * @param {Snapshot} snapshot - The snapshot, or the later of the two compared.
146
+ * @param {Snapshot} [before] - The earlier snapshot to compare it against.
147
+ */
148
+ open(snapshot: Snapshot, before?: Snapshot): void;
149
+ /**
150
+ * Deletes snapshots.
151
+ *
152
+ * @param {number[]} numbers - The numbers of the snapshots.
153
+ */
154
+ delete(numbers: number[]): void;
155
+ /**
156
+ * Brings the list and the buttons up to date with the snapshots.
157
+ */
158
+ refresh(): void;
159
+ }
160
+ /**
161
+ * @returns {SnapshotList} A list with no snapshots yet.
162
+ * @ignore
163
+ */
164
+ export function createSnapshotList(): SnapshotList;
165
+ import type { SnapshotItem } from './treemap-view.js';
166
+ import type { TreemapData } from './treemap-view.js';
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @param {GraphicsDevice} device - The device.
3
+ * @returns {Map<Texture, RenderTarget[]>} The render targets each attached texture belongs to.
4
+ */
5
+ export function attachmentTargets(device: GraphicsDevice): Map<Texture, RenderTarget[]>;
1
6
  /**
2
7
  * Everything the property view shows for a texture: its storage, the render targets it is attached
3
8
  * to (linked), and every other public property.
@@ -19,6 +24,11 @@ export function buildTextureModel(texture: Texture, ctx: {
19
24
  * @returns {Texture[]} The textures.
20
25
  */
21
26
  export function collectTextures(device: GraphicsDevice): Texture[];
27
+ /**
28
+ * @param {Texture} texture - A texture.
29
+ * @returns {string} Its dimensions, with the shape when it is not a plain 2D texture.
30
+ */
31
+ export function shapeText(texture: Texture): string;
22
32
  /**
23
33
  * One row per texture on the device, largest first, tagged when it is a render target attachment.
24
34
  *
@@ -26,8 +36,9 @@ export function collectTextures(device: GraphicsDevice): Texture[];
26
36
  * @returns {ListRow[]} The rows.
27
37
  */
28
38
  export function textureRows(device: GraphicsDevice): ListRow[];
29
- import type { Texture } from 'playcanvas';
30
39
  import type { GraphicsDevice } from 'playcanvas';
40
+ import type { Texture } from 'playcanvas';
41
+ import type { RenderTarget } from 'playcanvas';
31
42
  import type { AppBase } from 'playcanvas';
32
43
  import type { PropertySection } from './model.js';
33
44
  import type { ListRow } from './list-view.js';