3D engine that AI agents drive
Bench: split skinned update into posing and updateParts
Nguyen Xuan Anf668ac09b75d
diff --git a/bench/runtime/adapters.js b/bench/runtime/adapters.jsindex 1665fc4e..8d99c307 100644--- a/bench/runtime/adapters.js+++ b/bench/runtime/adapters.js@@ -74,6 +74,8 @@ export async function create67Adapter(canvas, scene, characters, { culling = trureturn {context: renderer.context,memoryReport: () => renderer.memoryReport(),+ // Time spent in renderer.updateParts after animation, so the update splits into posing and upload.+ updatePartsTimes: [],update(time) {if (scene.update) {scene.update(time);@@ -81,7 +83,9 @@ export async function create67Adapter(canvas, scene, characters, { culling = tru}if (assets.length) {assets.forEach((asset, index) => asset.applyAnimation(time + index * SECONDS_PER_CHARACTER_OFFSET, 0));+ const beforeUpload = performance.now();renderer.updateParts(parts);+ this.updatePartsTimes.push(performance.now() - beforeUpload);}},render() {diff --git a/bench/runtime/harness.js b/bench/runtime/harness.jsindex 21f0057b..31d74465 100644--- a/bench/runtime/harness.js+++ b/bench/runtime/harness.js@@ -146,6 +146,7 @@ async function runBenchmark(sceneId, engine, frames) {const fullFrameTimes = [];const queries = [];watcher.resetDrawCounters();+ if (adapter.updatePartsTimes) adapter.updatePartsTimes.length = 0;for (let frame = 0; frame < frames; frame++) {time += FRAME_TIME_STEP;const beforeUpdate = performance.now();@@ -178,6 +179,7 @@ async function runBenchmark(sceneId, engine, frames) {scene: sceneId, engine,firstFrameMilliseconds,updateMilliseconds: median(updateTimes),+ updatePartsMilliseconds: adapter.updatePartsTimes?.length ? median(adapter.updatePartsTimes) : null,renderCpuMilliseconds: median(renderTimes),gpuMilliseconds: median(gpuTimes),fullFrameMilliseconds: median(fullFrameTimes),diff --git a/bench/runtime/run.mjs b/bench/runtime/run.mjsindex 8e59116c..87444531 100644--- a/bench/runtime/run.mjs+++ b/bench/runtime/run.mjs@@ -87,6 +87,7 @@ function summarize({ image: _image, repeatable: _repeatable, glError: _glError,return {firstFrameMilliseconds: rounded(result.firstFrameMilliseconds, 0),updateMilliseconds: rounded(result.updateMilliseconds),+ updatePartsMilliseconds: result.updatePartsMilliseconds === null ? null : rounded(result.updatePartsMilliseconds),renderCpuMilliseconds: rounded(result.renderCpuMilliseconds),gpuMilliseconds: rounded(result.gpuMilliseconds),fullFrameMilliseconds: rounded(result.fullFrameMilliseconds),@@ -120,7 +121,7 @@ async function runBackend(backendName, serverUrl, report) {report.results[backendName][sceneId] ??= {};report.results[backendName][sceneId][engine] = { ...summarize(result), gpuBusyBefore };const summary = report.results[backendName][sceneId][engine];- console.log(`${backendName} ${sceneId.padEnd(20)} ${engine.padEnd(16)} first ${summary.firstFrameMilliseconds} ms, update ${summary.updateMilliseconds} ms, render ${summary.renderCpuMilliseconds} ms, frame ${summary.fullFrameMilliseconds} ms, ${summary.drawCalls} draws, ${summary.triangles} tris, gpu mem ${summary.gpuMegabytes} MB, heap ${summary.heapMegabytes} MB, busy ${gpuBusyBefore}%${summary.renderTargets ? `+ console.log(`${backendName} ${sceneId.padEnd(20)} ${engine.padEnd(16)} first ${summary.firstFrameMilliseconds} ms, update ${summary.updateMilliseconds} ms${summary.updatePartsMilliseconds === null ? "" : ` (updateParts ${summary.updatePartsMilliseconds})`}, render ${summary.renderCpuMilliseconds} ms, frame ${summary.fullFrameMilliseconds} ms, ${summary.drawCalls} draws, ${summary.triangles} tris, gpu mem ${summary.gpuMegabytes} MB, heap ${summary.heapMegabytes} MB, busy ${gpuBusyBefore}%${summary.renderTargets ? `targets: ${summary.renderTargets.map(target => `${target.name} ${target.megabytes} MB`).join(", ")}` : ""}`);}}