@driftengine/tools 4.0.0 → 4.1.1
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/README.md +64 -2
- package/dist/index.d.ts +7 -3
- package/dist/index.js +4 -3
- package/dist/inspector.d.ts +42 -0
- package/dist/inspector.js +55 -0
- package/dist/network.d.ts +42 -0
- package/dist/network.js +43 -0
- package/dist/overlay.d.ts +70 -0
- package/dist/overlay.js +275 -0
- package/dist/profiler.d.ts +29 -1
- package/dist/profiler.js +40 -1
- package/package.json +6 -6
- package/src/index.ts +30 -0
- package/src/inspector.ts +77 -0
- package/src/network.ts +68 -0
- package/src/overlay.ts +342 -0
- package/src/profiler.ts +52 -1
package/src/profiler.ts
CHANGED
|
@@ -17,7 +17,17 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { addUiChild, createUiNode } from '@driftengine/ui2d';
|
|
19
19
|
import type { UiNode } from '@driftengine/ui2d';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
GPU_SLOTS,
|
|
22
|
+
createPassTimings,
|
|
23
|
+
passLabel,
|
|
24
|
+
passMs,
|
|
25
|
+
recordPassLabel,
|
|
26
|
+
recordPassSample,
|
|
27
|
+
resetPassTimings,
|
|
28
|
+
type GpuSample,
|
|
29
|
+
type PassTimings,
|
|
30
|
+
} from '@driftengine/core';
|
|
21
31
|
import { residentCount, type ResidencyTable } from '@driftengine/texture';
|
|
22
32
|
import type { Command } from './command.ts';
|
|
23
33
|
import { createPanelRoot, emptyPanel, type Panel } from './panel.ts';
|
|
@@ -195,3 +205,44 @@ export const profilerPanel: Panel<ProfilerWorld, ProfilerView> = {
|
|
|
195
205
|
return null;
|
|
196
206
|
},
|
|
197
207
|
};
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* A `PassTimings` labelled with the engine's own GPU brackets.
|
|
211
|
+
*
|
|
212
|
+
* **The engine fills no timings for anybody.** `PassTimings` is a container and
|
|
213
|
+
* `RendererApi.gpuTimer` is a source, and joining the two is the same twenty lines wherever it is
|
|
214
|
+
* written — the slots are `GPU_SLOTS` and never the game's, because a second backend measuring the
|
|
215
|
+
* same frame owes the same three numbers. So it is written here once rather than in every consumer
|
|
216
|
+
* that wants a frame readout, which is the argument that put the overlay in this package.
|
|
217
|
+
*
|
|
218
|
+
* Labelled and unsampled, so every row shows `—` until a frame resolves. That is the distinction
|
|
219
|
+
* `profilerRows` exists to keep: a bracket nothing has measured yet is not a bracket that ran in no
|
|
220
|
+
* time.
|
|
221
|
+
*/
|
|
222
|
+
export function createGpuPassTimings(): PassTimings {
|
|
223
|
+
const timings = createPassTimings(GPU_SLOTS.length);
|
|
224
|
+
for (let slot = 0; slot < GPU_SLOTS.length; slot += 1) {
|
|
225
|
+
recordPassLabel(timings, slot, GPU_SLOTS[slot] ?? '');
|
|
226
|
+
}
|
|
227
|
+
return timings;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Write one resolved sample over the three rows.
|
|
232
|
+
*
|
|
233
|
+
* **It resets first, and the first draft did not.** `recordPassSample` accumulates on purpose,
|
|
234
|
+
* because a pass may be sampled several times in one frame — a shadow pass runs per cascade — and
|
|
235
|
+
* the row a reader wants is what that pass cost altogether. A `GpuSample` is the opposite: it is
|
|
236
|
+
* one resolved frame's three totals, already summed by the timer. Adding it to what was there left
|
|
237
|
+
* the rows climbing forever, which reads as a leak in whatever the game last changed rather than as
|
|
238
|
+
* a defect in the readout. `resetPassTimings` is how the engine's own frame starts, and the labels
|
|
239
|
+
* survive it, which is why the rows do not flicker.
|
|
240
|
+
*
|
|
241
|
+
* A caller wanting an average across frames has `FrameHistory` for it.
|
|
242
|
+
*/
|
|
243
|
+
export function recordGpuSample(timings: PassTimings, sample: GpuSample): void {
|
|
244
|
+
resetPassTimings(timings);
|
|
245
|
+
recordPassSample(timings, 0, sample.shadows);
|
|
246
|
+
recordPassSample(timings, 1, sample.reflection);
|
|
247
|
+
recordPassSample(timings, 2, sample.rest);
|
|
248
|
+
}
|