Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Report render target memory and allocate targets only when used

Nguyen Xuan An61a3f2347563
diff --git a/bench/runtime/README.md b/bench/runtime/README.md
index 64140a49..c771fa26 100644
--- a/bench/runtime/README.md
+++ b/bench/runtime/README.md
@@ -1,6 +1,6 @@
# Runtime against three.js
-This suite compares what a frame costs in 67js and in three.js on 7 matching scenes. **three.js wins most of them today.**
+This suite compares what a frame costs in 67js and in three.js on 7 matching scenes. **three.js wins most of them today, but 67js wins the GPU frame in 2 of 7 scenes.**
## Culling and levels of detail (issue 37)
@@ -23,52 +23,56 @@ CI does not run this suite. It needs Chrome and a GPU, and `tests/runtime-report
## Result
-Measured on 2026-10-31 at 960 by 540 with 4 MSAA samples, against three.js 0.186.1. A ratio above 1 means that 67js costs more.
+Measured on 2026-11-03 at 960 by 540 with 4 MSAA samples, against three.js 0.186.1, after the issue 74 changes. The GPU was between 5 and 95 percent busy before the runs (`gpuBusyBefore` in `report.json`; 8 percent before the first scene), so the RTX 3060 numbers are noisy. A ratio above 1 means that 67js costs more.
**Full frame on SwiftShader, in milliseconds.** This is the path that a headless agent uses.
| Scene | 67js | three.js | Ratio |
| --- | --- | --- | --- |
-| `instanced-objects` | 631 | 48 (instanced 44) | 13.3 |
-| `many-materials` | 2,207 | 237 | 9.3 |
-| `many-lights` | 1,506 | 261 | 5.8 |
-| `transparency` | 1,699 | 131 | 12.9 |
-| `moving-shadows` | 411 | 43 | 9.5 |
-| `large-mesh` | 2,216 | 221 | 10.0 |
-| `skinned-characters` | 730 | 68 | 10.8 |
+| `instanced-objects` | 101 | 34 (instanced 43) | 3.0 |
+| `many-materials` | 524 | 193 | 2.7 |
+| `many-lights` | 367 | 144 | 2.6 |
+| `transparency` | 329 | 67 | 4.9 |
+| `moving-shadows` | 73 | 28 | 2.6 |
+| `large-mesh` | 443 | 172 | 2.6 |
+| `skinned-characters` | 177 | 45 | 3.9 |
-**Full frame on an RTX 3060, in milliseconds.** Other jobs were using the GPU during this run, so these numbers are noisy.
+**Full frame on an RTX 3060, in milliseconds.** Other jobs shared the GPU during parts of this run, so these numbers are noisy.
| Scene | 67js | three.js | Ratio |
| --- | --- | --- | --- |
-| `instanced-objects` | 1.25 | 4.34 (instanced 0.36) | 0.3 |
-| `many-materials` | 4.75 | 2.97 | 1.6 |
-| `many-lights` | 4.54 | 2.46 | 1.8 |
-| `transparency` | 2.70 | 1.35 | 2.0 |
-| `moving-shadows` | 2.34 | 1.85 | 1.3 |
-| `large-mesh` | 4.24 | 0.59 | 7.2 |
-| `skinned-characters` | 9.02 | 3.13 | 2.9 |
+| `instanced-objects` | 0.84 | 2.36 (instanced 0.27) | 0.4 |
+| `many-materials` | 2.32 | 1.62 | 1.4 |
+| `many-lights` | 1.41 | 0.85 | 1.7 |
+| `transparency` | 0.97 | 0.74 | 1.3 |
+| `moving-shadows` | 0.85 | 1.16 | 0.7 |
+| `large-mesh` | 2.38 | 0.37 | 6.4 |
+| `skinned-characters` | 4.02 | 1.99 | 2.0 |
**First frame on an RTX 3060, in milliseconds.** Each run has an empty browser profile, so no shader cache helps either engine.
| Scene | 67js | three.js | Ratio |
| --- | --- | --- | --- |
-| `instanced-objects` | 2,608 | 204 | 12.8 |
-| `many-materials` | 2,564 | 269 | 9.5 |
-| `many-lights` | 2,655 | 276 | 9.6 |
-| `transparency` | 2,853 | 231 | 12.4 |
-| `moving-shadows` | 2,606 | 245 | 10.6 |
-| `large-mesh` | 3,113 | 459 | 6.8 |
-| `skinned-characters` | 3,266 | 551 | 5.9 |
+| `instanced-objects` | 257 | 85 | 3.0 |
+| `many-materials` | 233 | 109 | 2.1 |
+| `many-lights` | 230 | 123 | 1.9 |
+| `transparency` | 225 | 132 | 1.7 |
+| `moving-shadows` | 259 | 119 | 2.2 |
+| `large-mesh` | 394 | 246 | 1.6 |
+| `skinned-characters` | 310 | 289 | 1.1 |
+
+## GPU memory per render target
+
+Each 67js result in `report.json` lists its render targets (`renderTargets`: name, size, format, samples, bytes). The same list comes from `renderer.memoryReport()`. At 960 by 540 with 4 samples, for `instanced-objects` and `large-outdoor` alike: `shadowMap` 16 MB (2048 by 2048 depth), `multisampleColor` 15.82 MB (RGBA16F), `multisampleDepth` 7.91 MB and `frameColor` 3.96 MB. The counter totals 45.31 MB and 47.54 MB, so 1.6 to 3.8 MB is geometry and textures.
## Where each engine wins
**three.js wins:**
- Full frames on SwiftShader, in every scene.
-- Full frames on the RTX 3060, in 6 of 7 scenes. In the seventh, an `InstancedMesh` beats 67js by 3.5 times.
+- Full frames on the RTX 3060, in 5 of 7 scenes. 67js is faster than three.js with separate meshes in `instanced-objects` and `moving-shadows`, but an `InstancedMesh` beats 67js in `instanced-objects` by 3.1 times.
- The first frame, in every scene.
-- GPU memory that WebGL calls show, in every scene. 67js allocates about 46 MB for its render targets.
+- GPU memory that WebGL calls show, in every scene. 67js allocates about 44 MB for its render targets (it was 46 MB): 16 MB shadow map, 15.8 MB multisampled colour, 7.9 MB multisampled depth and 4 MB resolved colour at this size. A scene with no shadow casters allocates a one texel shadow map instead of 16 MB, and bloom, ambient occlusion, cascades and the point light atlas allocate only when used. The benchmark scenes all cast shadows. three.js shows 0 to 32 MB because its targets live in the canvas, which the counter leaves out.
- Fewer triangles when objects are off camera, because it culls them. 67js draws all of them (issue 37).
- Heap memory in `skinned-characters`, because three.js clones one parsed file.
diff --git a/bench/runtime/adapters.js b/bench/runtime/adapters.js
index 809c1bc7..1665fc4e 100644
--- a/bench/runtime/adapters.js
+++ b/bench/runtime/adapters.js
@@ -73,6 +73,7 @@ export async function create67Adapter(canvas, scene, characters, { culling = tru
const frame = { eye: scene.camera.eye, target: scene.camera.target, up: [0, 1, 0], fov: scene.camera.fov, near: scene.camera.near, far: scene.camera.far, environment, time: 0, exposure: 1, effects: {} };
return {
context: renderer.context,
+ memoryReport: () => renderer.memoryReport(),
update(time) {
if (scene.update) {
scene.update(time);
diff --git a/bench/runtime/harness.js b/bench/runtime/harness.js
index 05c17508..21f0057b 100644
--- a/bench/runtime/harness.js
+++ b/bench/runtime/harness.js
@@ -183,6 +183,7 @@ async function runBenchmark(sceneId, engine, frames) {
fullFrameMilliseconds: median(fullFrameTimes),
drawCalls, triangles,
gpuBytes: watcher.gpuBytes(),
+ renderTargets: adapter.memoryReport?.().targets ?? null,
heapBytes: heapBefore === null ? null : heapBytes() - heapBefore,
glError: adapter.context.getError(),
// The frame at time 0 after many frames must match the first frame drawn: nothing may depend on what came before.
diff --git a/bench/runtime/report.json b/bench/runtime/report.json
index f25ab3d2..fd95e7d1 100644
--- a/bench/runtime/report.json
+++ b/bench/runtime/report.json
@@ -12,398 +12,1357 @@
"gpu": {
"instanced-objects": {
"67js": {
- "firstFrameMilliseconds": 2608,
+ "firstFrameMilliseconds": 257,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.07,
- "gpuMilliseconds": 0.66,
- "fullFrameMilliseconds": 1.25,
+ "renderCpuMilliseconds": 0.28,
+ "gpuMilliseconds": 0.25,
+ "fullFrameMilliseconds": 0.84,
"drawCalls": 3,
- "triangles": 60002,
- "gpuMegabytes": 46.51,
- "heapMegabytes": 5,
- "gpuBusyBefore": 95
+ "triangles": 49850,
+ "gpuMegabytes": 45.31,
+ "heapMegabytes": 5.9,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 8
},
"three": {
- "firstFrameMilliseconds": 204,
+ "firstFrameMilliseconds": 85,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 3.91,
- "gpuMilliseconds": 0.3,
- "fullFrameMilliseconds": 4.34,
+ "renderCpuMilliseconds": 1.96,
+ "gpuMilliseconds": 0.09,
+ "fullFrameMilliseconds": 2.36,
"drawCalls": 4154,
"triangles": 49848,
"gpuMegabytes": 0,
"heapMegabytes": 8.5,
- "gpuBusyBefore": 41
+ "renderTargets": null,
+ "gpuBusyBefore": 9
},
"three-instanced": {
- "firstFrameMilliseconds": 190,
+ "firstFrameMilliseconds": 79,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.05,
+ "renderCpuMilliseconds": 0.04,
"gpuMilliseconds": 0.05,
- "fullFrameMilliseconds": 0.36,
+ "fullFrameMilliseconds": 0.27,
"drawCalls": 1,
"triangles": 60000,
"gpuMegabytes": 0.31,
"heapMegabytes": 2.4,
- "gpuBusyBefore": 10
+ "renderTargets": null,
+ "gpuBusyBefore": 12
+ }
+ },
+ "large-outdoor": {
+ "67js": {
+ "firstFrameMilliseconds": 264,
+ "updateMilliseconds": 0,
+ "renderCpuMilliseconds": 0.35,
+ "gpuMilliseconds": 0.58,
+ "fullFrameMilliseconds": 1.31,
+ "drawCalls": 6,
+ "triangles": 270474,
+ "gpuMegabytes": 47.54,
+ "heapMegabytes": 6.8,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 19
+ },
+ "three": {
+ "firstFrameMilliseconds": 108,
+ "updateMilliseconds": 0,
+ "renderCpuMilliseconds": 3.73,
+ "gpuMilliseconds": 0.72,
+ "fullFrameMilliseconds": 4.47,
+ "drawCalls": 4542,
+ "triangles": 4359372,
+ "gpuMegabytes": 0.03,
+ "heapMegabytes": 9.8,
+ "renderTargets": null,
+ "gpuBusyBefore": 48
+ },
+ "67js-no-lod": {
+ "firstFrameMilliseconds": 256,
+ "updateMilliseconds": 0,
+ "renderCpuMilliseconds": 0.45,
+ "gpuMilliseconds": 8.2,
+ "fullFrameMilliseconds": 9.29,
+ "drawCalls": 4,
+ "triangles": 4359374,
+ "gpuMegabytes": 45.65,
+ "heapMegabytes": 6.4,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 22
+ },
+ "67js-no-culling": {
+ "firstFrameMilliseconds": 256,
+ "updateMilliseconds": 0,
+ "renderCpuMilliseconds": 0.13,
+ "gpuMilliseconds": 10.66,
+ "fullFrameMilliseconds": 11.27,
+ "drawCalls": 4,
+ "triangles": 5760014,
+ "gpuMegabytes": 44.72,
+ "heapMegabytes": 5.6,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 23
}
},
"many-materials": {
"67js": {
- "firstFrameMilliseconds": 2564,
+ "firstFrameMilliseconds": 233,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.11,
- "gpuMilliseconds": 4.24,
- "fullFrameMilliseconds": 4.75,
+ "renderCpuMilliseconds": 0.19,
+ "gpuMilliseconds": 1.54,
+ "fullFrameMilliseconds": 2.32,
"drawCalls": 4,
- "triangles": 960014,
- "gpuMegabytes": 45.91,
- "heapMegabytes": 2.4,
- "gpuBusyBefore": 19
+ "triangles": 925454,
+ "gpuMegabytes": 44.09,
+ "heapMegabytes": 2.7,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 95
},
"three": {
- "firstFrameMilliseconds": 269,
+ "firstFrameMilliseconds": 109,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 2.34,
+ "renderCpuMilliseconds": 1.09,
"gpuMilliseconds": 0.19,
- "fullFrameMilliseconds": 2.97,
+ "fullFrameMilliseconds": 1.62,
"drawCalls": 965,
"triangles": 925452,
"gpuMegabytes": 0.03,
"heapMegabytes": 12.9,
- "gpuBusyBefore": 84
+ "renderTargets": null,
+ "gpuBusyBefore": 78
}
},
"many-lights": {
"67js": {
- "firstFrameMilliseconds": 2655,
+ "firstFrameMilliseconds": 230,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.11,
- "gpuMilliseconds": 3.78,
- "fullFrameMilliseconds": 4.54,
+ "renderCpuMilliseconds": 0.1,
+ "gpuMilliseconds": 0.99,
+ "fullFrameMilliseconds": 1.41,
"drawCalls": 4,
- "triangles": 384014,
- "gpuMegabytes": 45.82,
- "heapMegabytes": 1.6,
- "gpuBusyBefore": 13
+ "triangles": 368654,
+ "gpuMegabytes": 43.9,
+ "heapMegabytes": 1.8,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 20
},
"three": {
- "firstFrameMilliseconds": 276,
+ "firstFrameMilliseconds": 123,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.82,
+ "renderCpuMilliseconds": 0.27,
"gpuMilliseconds": 0.33,
- "fullFrameMilliseconds": 2.46,
+ "fullFrameMilliseconds": 0.85,
"drawCalls": 385,
"triangles": 368652,
"gpuMegabytes": 0.03,
"heapMegabytes": 2.3,
- "gpuBusyBefore": 92
+ "renderTargets": null,
+ "gpuBusyBefore": 16
}
},
"transparency": {
"67js": {
- "firstFrameMilliseconds": 2853,
+ "firstFrameMilliseconds": 225,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.16,
- "gpuMilliseconds": 2.02,
- "fullFrameMilliseconds": 2.7,
+ "renderCpuMilliseconds": 0.12,
+ "gpuMilliseconds": 0.59,
+ "fullFrameMilliseconds": 0.97,
"drawCalls": 4,
"triangles": 288014,
- "gpuMegabytes": 45.8,
- "heapMegabytes": 1.4,
- "gpuBusyBefore": 88
+ "gpuMegabytes": 43.82,
+ "heapMegabytes": 1.9,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 31
},
"three": {
- "firstFrameMilliseconds": 231,
+ "firstFrameMilliseconds": 132,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.55,
- "gpuMilliseconds": 0.16,
- "fullFrameMilliseconds": 1.35,
+ "renderCpuMilliseconds": 0.34,
+ "gpuMilliseconds": 0.17,
+ "fullFrameMilliseconds": 0.74,
"drawCalls": 301,
"triangles": 288012,
"gpuMegabytes": 0.03,
- "heapMegabytes": 5,
- "gpuBusyBefore": 83
+ "heapMegabytes": 5.4,
+ "renderTargets": null,
+ "gpuBusyBefore": 67
}
},
"moving-shadows": {
"67js": {
- "firstFrameMilliseconds": 2606,
- "updateMilliseconds": 0.54,
+ "firstFrameMilliseconds": 259,
+ "updateMilliseconds": 0.64,
"renderCpuMilliseconds": 0.21,
- "gpuMilliseconds": 1.34,
- "fullFrameMilliseconds": 2.34,
+ "gpuMilliseconds": 0.31,
+ "fullFrameMilliseconds": 0.85,
"drawCalls": 4,
"triangles": 12026,
- "gpuMegabytes": 45.8,
- "heapMegabytes": 1.4,
- "gpuBusyBefore": 8
+ "gpuMegabytes": 43.83,
+ "heapMegabytes": 1.6,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 29
},
"three": {
- "firstFrameMilliseconds": 245,
- "updateMilliseconds": 0.05,
- "renderCpuMilliseconds": 1.31,
- "gpuMilliseconds": 0.16,
- "fullFrameMilliseconds": 1.85,
+ "firstFrameMilliseconds": 119,
+ "updateMilliseconds": 0.02,
+ "renderCpuMilliseconds": 0.73,
+ "gpuMilliseconds": 0.17,
+ "fullFrameMilliseconds": 1.16,
"drawCalls": 1002,
"triangles": 12024,
"gpuMegabytes": 32,
- "heapMegabytes": 2.2,
- "gpuBusyBefore": 98
+ "heapMegabytes": 2.1,
+ "renderTargets": null,
+ "gpuBusyBefore": 22
}
},
"large-mesh": {
"67js": {
- "firstFrameMilliseconds": 3113,
+ "firstFrameMilliseconds": 394,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.11,
- "gpuMilliseconds": 3.57,
- "fullFrameMilliseconds": 4.24,
+ "renderCpuMilliseconds": 0.08,
+ "gpuMilliseconds": 2.01,
+ "fullFrameMilliseconds": 2.38,
"drawCalls": 3,
"triangles": 1046530,
- "gpuMegabytes": 73.75,
- "heapMegabytes": 28.6,
- "gpuBusyBefore": 10
+ "gpuMegabytes": 71.77,
+ "heapMegabytes": 28.7,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 11
},
"three": {
- "firstFrameMilliseconds": 459,
+ "firstFrameMilliseconds": 246,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.05,
+ "renderCpuMilliseconds": 0.04,
"gpuMilliseconds": 0.15,
- "fullFrameMilliseconds": 0.59,
+ "fullFrameMilliseconds": 0.37,
"drawCalls": 1,
"triangles": 1046528,
"gpuMegabytes": 24.01,
"heapMegabytes": 29,
- "gpuBusyBefore": 85
+ "renderTargets": null,
+ "gpuBusyBefore": 24
}
},
"skinned-characters": {
"67js": {
- "firstFrameMilliseconds": 3266,
- "updateMilliseconds": 7.57,
- "renderCpuMilliseconds": 1.27,
- "gpuMilliseconds": 5.17,
- "fullFrameMilliseconds": 9.02,
+ "firstFrameMilliseconds": 310,
+ "updateMilliseconds": 5.22,
+ "renderCpuMilliseconds": 0.81,
+ "gpuMilliseconds": 1.83,
+ "fullFrameMilliseconds": 4.02,
"drawCalls": 308,
"triangles": 51818,
- "gpuMegabytes": 49.02,
- "heapMegabytes": 17.8,
- "gpuBusyBefore": 73
+ "gpuMegabytes": 47.04,
+ "heapMegabytes": 17.4,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 5
},
"three": {
- "firstFrameMilliseconds": 551,
- "updateMilliseconds": 0.05,
- "renderCpuMilliseconds": 1.84,
- "gpuMilliseconds": 0.37,
- "fullFrameMilliseconds": 3.13,
+ "firstFrameMilliseconds": 289,
+ "updateMilliseconds": 0.03,
+ "renderCpuMilliseconds": 0.89,
+ "gpuMilliseconds": 0.39,
+ "fullFrameMilliseconds": 1.99,
"drawCalls": 306,
"triangles": 51816,
"gpuMegabytes": 32.34,
- "heapMegabytes": 5.6,
- "gpuBusyBefore": 79
+ "heapMegabytes": 4.2,
+ "renderTargets": null,
+ "gpuBusyBefore": 24
}
}
},
"cpu": {
"instanced-objects": {
"67js": {
- "firstFrameMilliseconds": 2109,
+ "firstFrameMilliseconds": 476,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.2,
- "gpuMilliseconds": 629.74,
- "fullFrameMilliseconds": 631.01,
+ "renderCpuMilliseconds": 0.46,
+ "gpuMilliseconds": 100.21,
+ "fullFrameMilliseconds": 101.49,
"drawCalls": 3,
- "triangles": 60002,
- "gpuMegabytes": 46.51,
- "heapMegabytes": 4.9,
- "gpuBusyBefore": 78
+ "triangles": 49850,
+ "gpuMegabytes": 45.31,
+ "heapMegabytes": 5.9,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 5
},
"three": {
- "firstFrameMilliseconds": 290,
- "updateMilliseconds": 0,
- "renderCpuMilliseconds": 7.87,
- "gpuMilliseconds": 36.89,
- "fullFrameMilliseconds": 47.58,
+ "firstFrameMilliseconds": 221,
+ "updateMilliseconds": 0.01,
+ "renderCpuMilliseconds": 2.5,
+ "gpuMilliseconds": 29.36,
+ "fullFrameMilliseconds": 33.66,
"drawCalls": 4154,
"triangles": 49848,
"gpuMegabytes": 0,
"heapMegabytes": 8.5,
- "gpuBusyBefore": 35
+ "renderTargets": null,
+ "gpuBusyBefore": 5
},
"three-instanced": {
- "firstFrameMilliseconds": 347,
+ "firstFrameMilliseconds": 252,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.18,
- "gpuMilliseconds": 42.69,
- "fullFrameMilliseconds": 43.66,
+ "renderCpuMilliseconds": 0.16,
+ "gpuMilliseconds": 41.3,
+ "fullFrameMilliseconds": 42.77,
"drawCalls": 1,
"triangles": 60000,
"gpuMegabytes": 0.31,
"heapMegabytes": 2.4,
- "gpuBusyBefore": 78
+ "renderTargets": null,
+ "gpuBusyBefore": 5
+ }
+ },
+ "large-outdoor": {
+ "67js": {
+ "firstFrameMilliseconds": 572,
+ "updateMilliseconds": 0,
+ "renderCpuMilliseconds": 0.63,
+ "gpuMilliseconds": 178.69,
+ "fullFrameMilliseconds": 180.13,
+ "drawCalls": 6,
+ "triangles": 270474,
+ "gpuMegabytes": 47.54,
+ "heapMegabytes": 6.8,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 5
+ },
+ "three": {
+ "firstFrameMilliseconds": 979,
+ "updateMilliseconds": 0.01,
+ "renderCpuMilliseconds": 8.91,
+ "gpuMilliseconds": 849.75,
+ "fullFrameMilliseconds": 860.61,
+ "drawCalls": 4542,
+ "triangles": 4359372,
+ "gpuMegabytes": 0.03,
+ "heapMegabytes": 9.8,
+ "renderTargets": null,
+ "gpuBusyBefore": 15
+ },
+ "67js-no-lod": {
+ "firstFrameMilliseconds": 2560,
+ "updateMilliseconds": 0,
+ "renderCpuMilliseconds": 1.38,
+ "gpuMilliseconds": 1978.28,
+ "fullFrameMilliseconds": 1981.26,
+ "drawCalls": 4,
+ "triangles": 4359374,
+ "gpuMegabytes": 45.65,
+ "heapMegabytes": 6.4,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 6
+ },
+ "67js-no-culling": {
+ "firstFrameMilliseconds": 3224,
+ "updateMilliseconds": 0.01,
+ "renderCpuMilliseconds": 0.3,
+ "gpuMilliseconds": 2207.13,
+ "fullFrameMilliseconds": 2209.16,
+ "drawCalls": 4,
+ "triangles": 5760014,
+ "gpuMegabytes": 44.72,
+ "heapMegabytes": 5.6,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 7
}
},
"many-materials": {
"67js": {
- "firstFrameMilliseconds": 3681,
+ "firstFrameMilliseconds": 785,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.2,
- "gpuMilliseconds": 2206.27,
- "fullFrameMilliseconds": 2207.49,
+ "renderCpuMilliseconds": 0.59,
+ "gpuMilliseconds": 521.53,
+ "fullFrameMilliseconds": 524.17,
"drawCalls": 4,
- "triangles": 960014,
- "gpuMegabytes": 45.91,
- "heapMegabytes": 2.4,
- "gpuBusyBefore": 90
+ "triangles": 925454,
+ "gpuMegabytes": 44.09,
+ "heapMegabytes": 2.7,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 6
},
"three": {
- "firstFrameMilliseconds": 542,
- "updateMilliseconds": 0,
- "renderCpuMilliseconds": 4.51,
- "gpuMilliseconds": 231.55,
- "fullFrameMilliseconds": 236.68,
+ "firstFrameMilliseconds": 442,
+ "updateMilliseconds": 0.01,
+ "renderCpuMilliseconds": 5.09,
+ "gpuMilliseconds": 186.14,
+ "fullFrameMilliseconds": 193.38,
"drawCalls": 965,
"triangles": 925452,
"gpuMegabytes": 0.03,
"heapMegabytes": 12.9,
+ "renderTargets": null,
"gpuBusyBefore": 5
}
},
"many-lights": {
"67js": {
- "firstFrameMilliseconds": 3080,
+ "firstFrameMilliseconds": 930,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.26,
- "gpuMilliseconds": 1504.6,
- "fullFrameMilliseconds": 1506.23,
+ "renderCpuMilliseconds": 0.31,
+ "gpuMilliseconds": 365.31,
+ "fullFrameMilliseconds": 367.25,
"drawCalls": 4,
- "triangles": 384014,
- "gpuMegabytes": 45.82,
- "heapMegabytes": 1.6,
+ "triangles": 368654,
+ "gpuMegabytes": 43.9,
+ "heapMegabytes": 1.8,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
"gpuBusyBefore": 5
},
"three": {
- "firstFrameMilliseconds": 444,
+ "firstFrameMilliseconds": 360,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 1.12,
- "gpuMilliseconds": 258.75,
- "fullFrameMilliseconds": 261.08,
+ "renderCpuMilliseconds": 0.83,
+ "gpuMilliseconds": 141.51,
+ "fullFrameMilliseconds": 143.81,
"drawCalls": 385,
"triangles": 368652,
"gpuMegabytes": 0.03,
"heapMegabytes": 2.3,
+ "renderTargets": null,
"gpuBusyBefore": 5
}
},
"transparency": {
"67js": {
- "firstFrameMilliseconds": 3834,
+ "firstFrameMilliseconds": 622,
"updateMilliseconds": 0,
"renderCpuMilliseconds": 0.39,
- "gpuMilliseconds": 1697.26,
- "fullFrameMilliseconds": 1698.63,
+ "gpuMilliseconds": 327.9,
+ "fullFrameMilliseconds": 329.12,
"drawCalls": 4,
"triangles": 288014,
- "gpuMegabytes": 45.8,
- "heapMegabytes": 1.3,
- "gpuBusyBefore": 30
+ "gpuMegabytes": 43.82,
+ "heapMegabytes": 1.4,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 6
},
"three": {
- "firstFrameMilliseconds": 461,
+ "firstFrameMilliseconds": 287,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 1.78,
- "gpuMilliseconds": 128.53,
- "fullFrameMilliseconds": 131.2,
+ "renderCpuMilliseconds": 0.85,
+ "gpuMilliseconds": 65.71,
+ "fullFrameMilliseconds": 67.27,
"drawCalls": 301,
"triangles": 288012,
"gpuMegabytes": 0.03,
"heapMegabytes": 4.9,
+ "renderTargets": null,
"gpuBusyBefore": 5
}
},
"moving-shadows": {
"67js": {
- "firstFrameMilliseconds": 1756,
- "updateMilliseconds": 1.44,
- "renderCpuMilliseconds": 0.45,
- "gpuMilliseconds": 409.61,
- "fullFrameMilliseconds": 411.28,
+ "firstFrameMilliseconds": 394,
+ "updateMilliseconds": 0.95,
+ "renderCpuMilliseconds": 0.38,
+ "gpuMilliseconds": 71.38,
+ "fullFrameMilliseconds": 72.76,
"drawCalls": 4,
"triangles": 12026,
- "gpuMegabytes": 45.8,
- "heapMegabytes": 1.4,
+ "gpuMegabytes": 43.83,
+ "heapMegabytes": 1.5,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
"gpuBusyBefore": 5
},
"three": {
- "firstFrameMilliseconds": 336,
- "updateMilliseconds": 0.15,
- "renderCpuMilliseconds": 2.59,
- "gpuMilliseconds": 39.22,
- "fullFrameMilliseconds": 43.1,
+ "firstFrameMilliseconds": 252,
+ "updateMilliseconds": 0.11,
+ "renderCpuMilliseconds": 1.25,
+ "gpuMilliseconds": 25.5,
+ "fullFrameMilliseconds": 28.05,
"drawCalls": 1002,
"triangles": 12024,
"gpuMegabytes": 32,
"heapMegabytes": 2.1,
- "gpuBusyBefore": 6
+ "renderTargets": null,
+ "gpuBusyBefore": 5
}
},
"large-mesh": {
"67js": {
- "firstFrameMilliseconds": 4154,
+ "firstFrameMilliseconds": 1005,
"updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.21,
- "gpuMilliseconds": 2214.27,
- "fullFrameMilliseconds": 2215.82,
+ "renderCpuMilliseconds": 0.17,
+ "gpuMilliseconds": 441.89,
+ "fullFrameMilliseconds": 443.42,
"drawCalls": 3,
"triangles": 1046530,
- "gpuMegabytes": 73.75,
- "heapMegabytes": 28.6,
- "gpuBusyBefore": 31
+ "gpuMegabytes": 71.77,
+ "heapMegabytes": 28.7,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 5
},
"three": {
- "firstFrameMilliseconds": 797,
- "updateMilliseconds": 0,
- "renderCpuMilliseconds": 0.18,
- "gpuMilliseconds": 219.34,
- "fullFrameMilliseconds": 220.5,
+ "firstFrameMilliseconds": 408,
+ "updateMilliseconds": 0.01,
+ "renderCpuMilliseconds": 0.13,
+ "gpuMilliseconds": 170.53,
+ "fullFrameMilliseconds": 171.83,
"drawCalls": 1,
"triangles": 1046528,
"gpuMegabytes": 24.01,
"heapMegabytes": 29,
- "gpuBusyBefore": 12
+ "renderTargets": null,
+ "gpuBusyBefore": 5
}
},
"skinned-characters": {
"67js": {
- "firstFrameMilliseconds": 2295,
- "updateMilliseconds": 11.43,
- "renderCpuMilliseconds": 1.43,
- "gpuMilliseconds": 721.09,
- "fullFrameMilliseconds": 730.07,
+ "firstFrameMilliseconds": 474,
+ "updateMilliseconds": 13.55,
+ "renderCpuMilliseconds": 2.13,
+ "gpuMilliseconds": 167.93,
+ "fullFrameMilliseconds": 177.29,
"drawCalls": 308,
"triangles": 51818,
- "gpuMegabytes": 49.02,
- "heapMegabytes": 17.7,
- "gpuBusyBefore": 7
+ "gpuMegabytes": 47.04,
+ "heapMegabytes": 17.3,
+ "renderTargets": [
+ {
+ "name": "shadowMap",
+ "width": 2048,
+ "height": 2048,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 1,
+ "bytes": 16777216,
+ "megabytes": 16
+ },
+ {
+ "name": "multisampleColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 4,
+ "bytes": 16588800,
+ "megabytes": 15.82
+ },
+ {
+ "name": "multisampleDepth",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "DEPTH_COMPONENT24",
+ "samples": 4,
+ "bytes": 8294400,
+ "megabytes": 7.91
+ },
+ {
+ "name": "frameColor",
+ "width": 960,
+ "height": 540,
+ "layers": 1,
+ "format": "RGBA16F",
+ "samples": 1,
+ "bytes": 4147200,
+ "megabytes": 3.96
+ }
+ ],
+ "gpuBusyBefore": 5
},
"three": {
- "firstFrameMilliseconds": 640,
- "updateMilliseconds": 0.09,
- "renderCpuMilliseconds": 2.96,
- "gpuMilliseconds": 63.23,
- "fullFrameMilliseconds": 67.76,
+ "firstFrameMilliseconds": 728,
+ "updateMilliseconds": 0.11,
+ "renderCpuMilliseconds": 3.14,
+ "gpuMilliseconds": 40.03,
+ "fullFrameMilliseconds": 44.94,
"drawCalls": 306,
"triangles": 51816,
"gpuMegabytes": 32.34,
"heapMegabytes": 5.5,
- "gpuBusyBefore": 6
+ "renderTargets": null,
+ "gpuBusyBefore": 7
}
}
}
},
"scenes": {
"instanced-objects": "5,000 boxes that share a geometry and a material",
+ "large-outdoor": "6000 spheres of about 1,000 triangles over 600 by 600 units, seen from the edge",
"many-materials": "1,000 spheres with 1,000 different materials",
"many-lights": "400 spheres lit by 8 point lights",
"transparency": "300 overlapping translucent spheres that need sorting",
@@ -412,20 +1371,22 @@
"skinned-characters": "8 animated copies of a CC0 robot, at one spot with different clip times"
},
"pictureDifference": {
- "cpu-instanced-objects": 0.0456,
+ "cpu-instanced-objects": 0.0468,
"cpu-large-mesh": 0.027,
- "cpu-many-lights": 0.131,
- "cpu-many-materials": 0.2411,
- "cpu-moving-shadows": 0.091,
- "cpu-skinned-characters": 0.1037,
- "cpu-transparency": 0.1293,
- "gpu-instanced-objects": 0.0465,
- "gpu-large-mesh": 0.027,
- "gpu-many-lights": 0.1315,
- "gpu-many-materials": 0.2411,
- "gpu-moving-shadows": 0.0903,
- "gpu-skinned-characters": 0.1038,
- "gpu-transparency": 0.1293
+ "cpu-large-outdoor": 0.0431,
+ "cpu-many-lights": 0.1327,
+ "cpu-many-materials": 0.2684,
+ "cpu-moving-shadows": 0.0731,
+ "cpu-skinned-characters": 0.1072,
+ "cpu-transparency": 0.1307,
+ "gpu-instanced-objects": 0.0477,
+ "gpu-large-mesh": 0.0271,
+ "gpu-large-outdoor": 0.0431,
+ "gpu-many-lights": 0.1331,
+ "gpu-many-materials": 0.2691,
+ "gpu-moving-shadows": 0.0721,
+ "gpu-skinned-characters": 0.1074,
+ "gpu-transparency": 0.1307
},
"threeVersion": "0.186.1"
}
diff --git a/bench/runtime/run.mjs b/bench/runtime/run.mjs
index 48fb7bba..5b840c9e 100644
--- a/bench/runtime/run.mjs
+++ b/bench/runtime/run.mjs
@@ -94,6 +94,7 @@ function summarize({ image: _image, repeatable: _repeatable, glError: _glError,
triangles: rounded(result.triangles, 0),
gpuMegabytes: rounded(result.gpuBytes / 1048576, 2),
heapMegabytes: result.heapBytes === null ? null : rounded(result.heapBytes / 1048576, 1),
+ renderTargets: result.renderTargets,
};
}
@@ -119,7 +120,8 @@ 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, 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}%`);
+ console.log(`${backendName} ${sceneId.padEnd(20)} ${engine.padEnd(16)} first ${summary.firstFrameMilliseconds} 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 ? `
+ targets: ${summary.renderTargets.map(target => `${target.name} ${target.megabytes} MB`).join(", ")}` : ""}`);
}
}
} finally {
diff --git a/bench/size/budgets.json b/bench/size/budgets.json
index 9ab881d6..37c3bcd2 100644
--- a/bench/size/budgets.json
+++ b/bench/size/budgets.json
@@ -6,7 +6,7 @@
"agent-scene": 100000
},
"budgets": {
- "entry:core": 89050,
+ "entry:core": 89706,
"entry:model": 14400,
"entry:nature": 13200,
"entry:motion": 15260,
@@ -35,9 +35,9 @@
"entry:path-tracer": 15960,
"entry:texture-set": 900,
"entry:agent-scene": 80770,
- "entry:agent-scene+lazy": 263350,
+ "entry:agent-scene+lazy": 263417,
"entry:agent-asset": 112170,
- "entry:agent-asset+lazy": 274720,
+ "entry:agent-asset+lazy": 274790,
"entry:hdri": 3300,
"entry:camera-effects": 8600,
"entry:water-reflection": 27030,
@@ -45,11 +45,11 @@
"entry:gaussian-splats": 11023,
"entry:material-layer-shaders": 21400,
"entry:light-linking": 19720,
- "entry:cascaded-shadows": 28530,
- "scene:lit-box": 66030,
- "scene:gltf-box": 90310,
- "scene:gltf-box+lazy": 93640,
- "scene:agent-scene": 109840,
- "scene:agent-scene+lazy": 292420
+ "entry:cascaded-shadows": 28595,
+ "scene:lit-box": 66661,
+ "scene:gltf-box": 90957,
+ "scene:gltf-box+lazy": 94284,
+ "scene:agent-scene": 110452,
+ "scene:agent-scene+lazy": 293100
}
}
diff --git a/changes/287.md b/changes/287.md
new file mode 100644
index 00000000..b3e3c752
--- /dev/null
+++ b/changes/287.md
@@ -0,0 +1 @@
+- Add `renderer.memoryReport()` and a per-target GPU memory list in the runtime benchmark (issue #287), and allocate render targets only when used: bloom targets on the first bloom frame, a one texel shadow map for scenes with no shadow casters (16 MB saved), and a local shadow atlas with one row per four tiles in use (24 MB down to 6 MB for one light). Reference pictures are byte identical on all 23 scenes on both backends. `bench/runtime/report.json` is rerun after issue 74.
diff --git a/src/cascaded-shadows.js b/src/cascaded-shadows.js
index 9e860a43..a24ef4da 100644
--- a/src/cascaded-shadows.js
+++ b/src/cascaded-shadows.js
@@ -220,7 +220,10 @@ export class CascadedShadows {
/** Redraws the slice maps when the camera, the light or a caster moved. Call once a frame after the camera is set. */
update(renderer, casterChanged) {
const context = renderer.context;
- if (!this.texture) this.allocate(context);
+ if (!this.texture) {
+ this.allocate(context);
+ renderer.renderTargets.record('cascadedShadowMaps', { width: this.resolution, height: this.resolution, layers: this.count, format: 'DEPTH_COMPONENT24' });
+ }
const moved = this.fitToCamera(renderer);
if (!moved && !casterChanged && this.drawCount > 0) return;
this.previousMatrices.set(this.matrices);
@@ -258,7 +261,8 @@ export class CascadedShadows {
context.uniform4fv(this.locations.cascadeFrame, this.forward);
}
- dispose(context) {
+ dispose(context, renderTargets = null) {
+ renderTargets?.release('cascadedShadowMaps');
if (this.texture) context.deleteTexture(this.texture);
if (this.framebuffer) context.deleteFramebuffer(this.framebuffer);
this.texture = null;
diff --git a/src/render-passes.js b/src/render-passes.js
index 83fa1d1b..4ec9a8f8 100644
--- a/src/render-passes.js
+++ b/src/render-passes.js
@@ -52,6 +52,7 @@ export function installRenderPasses(renderer) {
context.deleteTexture(target.texture);
context.deleteRenderbuffer(target.depth);
context.deleteFramebuffer(target.framebuffer);
+ renderer.renderTargets.release('passColor', 'passDepth');
target = null;
}
@@ -73,7 +74,12 @@ export function installRenderPasses(renderer) {
copyProgram = compileProgram(context, fullscreenVertex, passCopyFragment);
copyTextureUniform = context.getUniformLocation(copyProgram, 'sourceTexture');
}
- target ??= createPassTarget(context, renderer.canvas.width, renderer.canvas.height);
+ if (!target) {
+ const { width, height } = renderer.canvas;
+ target = createPassTarget(context, width, height);
+ renderer.renderTargets.record('passColor', { width, height, format: 'RGBA8' });
+ renderer.renderTargets.record('passDepth', { width, height, format: 'DEPTH_COMPONENT24' });
+ }
return mode;
}
diff --git a/src/render-target-ledger.js b/src/render-target-ledger.js
new file mode 100644
index 00000000..f391e1bd
--- /dev/null
+++ b/src/render-target-ledger.js
@@ -0,0 +1,25 @@
+// Lists the GPU render targets a renderer owns, so an agent can read what each one costs.
+// Sizes follow the texel format, so they are the same on every machine, whatever padding a driver adds.
+const BYTES_PER_PIXEL = { R8: 1, RGBA8: 4, RGBA16F: 8, DEPTH_COMPONENT24: 4 };
+const BYTES_PER_MEGABYTE = 1048576;
+
+export class RenderTargetLedger {
+ targets = new Map();
+
+ /** `samples` is 1 for a plain texture; `layers` is the slice count of an array texture. */
+ record(name, { width, height, format, samples = 1, layers = 1 }) {
+ const bytes = width * height * layers * samples * BYTES_PER_PIXEL[format];
+ this.targets.set(name, { name, width, height, layers, format, samples, bytes, megabytes: Number((bytes / BYTES_PER_MEGABYTE).toFixed(2)) });
+ }
+
+ release(...names) {
+ for (const name of names) this.targets.delete(name);
+ }
+
+ /** Every live target, largest first, and the total. */
+ report() {
+ const targets = [...this.targets.values()].sort((first, second) => second.bytes - first.bytes);
+ const totalBytes = targets.reduce((total, target) => total + target.bytes, 0);
+ return { totalBytes, totalMegabytes: Number((totalBytes / BYTES_PER_MEGABYTE).toFixed(2)), targets };
+ }
+}
diff --git a/src/renderer.js b/src/renderer.js
index 148940e9..06c3ea0d 100644
--- a/src/renderer.js
+++ b/src/renderer.js
@@ -8,7 +8,8 @@ import { applyProjection } from './camera.js';
import { resolveEffects } from './effects.js';
import { frameDiagnostics } from './frame-diagnostics.js';
import { createLightingState, updateLightingState } from './lighting.js';
-import { SHADOW_ATLAS_WIDTH, SHADOW_ATLAS_HEIGHT, tileViewport, writeShadowTile } from './local-shadows.js';
+import { RenderTargetLedger } from './render-target-ledger.js';
+import { SHADOW_ATLAS_WIDTH, SHADOW_TILE_SIZE, SHADOW_TILES_PER_ROW, tileViewport, writeShadowTile } from './local-shadows.js';
import { resolveVolumeFog, volumeShadowAmbient } from './volumetric.js';
import { assertEnvironmentMap, createEnvironmentResources, environmentBackgroundFragment, environmentBrdfFragment, environmentPrefilterFragment, estimateEnvironmentBytes } from './environment.js';
import { validateSkinGeometry, validateSkinPose, skinTextureLayout, packSkinInfluences } from './skinning.js';
@@ -477,6 +478,7 @@ export class Renderer67 {
this.diagnostics = [];
this.activeLightDirection = environment.lightDirection ?? [-3, 6, 4];
this.shadowCascades = shadowCascades;
+ this.renderTargets = new RenderTargetLedger();
this.memoryBudgetMiB = memoryBudgetMiB;
this.hdr = Boolean(hdr && !benchmark && this.context.getExtension('EXT_color_buffer_float'));
if (volume.density > 0 && !this.hdr) throw new Error('Volume fog requires EXT_color_buffer_float for HDR rendering');
@@ -1296,10 +1298,16 @@ export class Renderer67 {
createShadowMap() {
const context = this.context;
const allocateShadow = !this.shadowTexture;
+ // A scene with nothing to cast keeps a one texel map that stays cleared to the far depth, so every point reads as lit.
+ this.shadowMapSize ??= this.batches.some(batch => !batch.floor && batch.castShadow) ? SHADOW_MAP_SIZE : 1;
+ const mapSize = this.shadowMapSize;
if (allocateShadow) this.shadowTexture = context.createTexture();
context.activeTexture(context.TEXTURE0);
context.bindTexture(context.TEXTURE_2D, this.shadowTexture);
- if (allocateShadow) context.texImage2D(context.TEXTURE_2D, 0, context.DEPTH_COMPONENT24, SHADOW_MAP_SIZE, SHADOW_MAP_SIZE, 0, context.DEPTH_COMPONENT, context.UNSIGNED_INT, null);
+ if (allocateShadow) {
+ context.texImage2D(context.TEXTURE_2D, 0, context.DEPTH_COMPONENT24, mapSize, mapSize, 0, context.DEPTH_COMPONENT, context.UNSIGNED_INT, null);
+ this.renderTargets.record('shadowMap', { width: mapSize, height: mapSize, format: 'DEPTH_COMPONENT24' });
+ }
// Compare on fetch (the default function is LEQUAL) with linear filtering gives a 2 x 2 percentage-closer result from one fetch.
context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.LINEAR);
context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MAG_FILTER, context.LINEAR);
@@ -1316,12 +1324,12 @@ export class Renderer67 {
const lightView = mat4.lookAt(mat4.create(), light.eye, light.target, light.up ?? [0, 1, 0]);
mat4.ortho(this.lightProjection, -light.extent, light.extent, -light.extent, light.extent, light.near, light.far);
mat4.multiply(this.lightProjection, this.lightProjection, lightView);
- context.viewport(0, 0, SHADOW_MAP_SIZE, SHADOW_MAP_SIZE);
+ context.viewport(0, 0, mapSize, mapSize);
context.enable(context.DEPTH_TEST);
context.enable(context.CULL_FACE);
context.clear(context.DEPTH_BUFFER_BIT);
this.shadowBiasPerSlope = shadowBiasPerSlope(light, SHADOW_MAP_SIZE);
- this.drawShadowCasters(this.lightProjection, SHADOW_MAP_SIZE);
+ this.drawShadowCasters(this.lightProjection, mapSize);
context.bindFramebuffer(context.FRAMEBUFFER, null);
this.shadowsDirty = false;
}
@@ -1369,12 +1377,17 @@ export class Renderer67 {
context.enable(context.CULL_FACE);
}
- allocateLocalShadowAtlas() {
+ // The atlas has one row of tiles per four shadow tiles in use. The shader fetches by texel, so the height is free.
+ allocateLocalShadowAtlas(tileCount) {
const context = this.context;
+ if (this.localShadowTexture) context.deleteTexture(this.localShadowTexture);
+ if (this.localShadowFramebuffer) context.deleteFramebuffer(this.localShadowFramebuffer);
+ this.localShadowAtlasHeight = Math.ceil(tileCount / SHADOW_TILES_PER_ROW) * SHADOW_TILE_SIZE;
this.localShadowTexture = context.createTexture();
context.activeTexture(context.TEXTURE0 + LOCAL_SHADOW_UNIT);
context.bindTexture(context.TEXTURE_2D, this.localShadowTexture);
- context.texImage2D(context.TEXTURE_2D, 0, context.DEPTH_COMPONENT24, SHADOW_ATLAS_WIDTH, SHADOW_ATLAS_HEIGHT, 0, context.DEPTH_COMPONENT, context.UNSIGNED_INT, null);
+ context.texImage2D(context.TEXTURE_2D, 0, context.DEPTH_COMPONENT24, SHADOW_ATLAS_WIDTH, this.localShadowAtlasHeight, 0, context.DEPTH_COMPONENT, context.UNSIGNED_INT, null);
+ this.renderTargets.record('localShadowAtlas', { width: SHADOW_ATLAS_WIDTH, height: this.localShadowAtlasHeight, format: 'DEPTH_COMPONENT24' });
context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST);
context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MAG_FILTER, context.NEAREST);
context.texParameteri(context.TEXTURE_2D, context.TEXTURE_WRAP_S, context.CLAMP_TO_EDGE);
@@ -1405,9 +1418,9 @@ export class Renderer67 {
previous.set(matrices);
this.localShadowTileCount = casters.length;
const context = this.context;
- if (!this.localShadowTexture) this.allocateLocalShadowAtlas();
+ if (!this.localShadowTexture || Math.ceil(casters.length / SHADOW_TILES_PER_ROW) * SHADOW_TILE_SIZE > this.localShadowAtlasHeight) this.allocateLocalShadowAtlas(casters.length);
context.bindFramebuffer(context.FRAMEBUFFER, this.localShadowFramebuffer);
- context.viewport(0, 0, SHADOW_ATLAS_WIDTH, SHADOW_ATLAS_HEIGHT);
+ context.viewport(0, 0, SHADOW_ATLAS_WIDTH, this.localShadowAtlasHeight);
context.enable(context.DEPTH_TEST);
context.clear(context.DEPTH_BUFFER_BIT);
for (let tile = 0; tile < casters.length; tile++) {
@@ -1439,6 +1452,11 @@ export class Renderer67 {
this.projection[8] = !this.benchmark && !this.world && this.canvas.clientWidth > 700 ? -0.25 : 0;
}
+ /** Every GPU render target this renderer holds: name, size, format, samples and bytes, largest first, with the total. */
+ memoryReport() {
+ return this.renderTargets.report();
+ }
+
releaseFrameTargets() {
const context = this.context;
if (this.multisampleFramebuffer) context.deleteFramebuffer(this.multisampleFramebuffer);
@@ -1452,6 +1470,7 @@ export class Renderer67 {
context.deleteFramebuffer(target.framebuffer);
}
this.bloomTargets = [];
+ this.renderTargets.release('multisampleColor', 'multisampleDepth', 'frameColor', 'sceneDepth', 'bloomA', 'bloomB');
this.releaseOcclusionTarget();
this.passSupport?.releaseTargets(context);
for (const stage of this.postStages ?? []) stage.releaseTargets(context);
@@ -1467,6 +1486,7 @@ export class Renderer67 {
if (!this.occlusionTarget) return;
this.context.deleteTexture(this.occlusionTarget.texture);
this.context.deleteFramebuffer(this.occlusionTarget.framebuffer);
+ this.renderTargets.release('ambientOcclusion');
this.occlusionTarget = null;
}
@@ -1489,6 +1509,7 @@ export class Renderer67 {
const texture = context.createTexture();
context.bindTexture(context.TEXTURE_2D, texture);
context.texImage2D(context.TEXTURE_2D, 0, context.R8, width, height, 0, context.RED, context.UNSIGNED_BYTE, null);
+ this.renderTargets.record('ambientOcclusion', { width, height, format: 'R8' });
context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.LINEAR);
context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MAG_FILTER, context.LINEAR);
context.texParameteri(context.TEXTURE_2D, context.TEXTURE_WRAP_S, context.CLAMP_TO_EDGE);
@@ -1535,6 +1556,9 @@ export class Renderer67 {
context.renderbufferStorageMultisample(context.RENDERBUFFER, this.multisampleSamples, context.DEPTH_COMPONENT24, width, height);
context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, this.multisampleDepth);
if (context.checkFramebufferStatus(context.FRAMEBUFFER) !== context.FRAMEBUFFER_COMPLETE) throw new Error('Multisample framebuffer allocation failed. Choose a lower quality preset.');
+ this.renderTargets.record('multisampleColor', { width, height, format: this.hdr ? 'RGBA16F' : 'RGBA8', samples: this.multisampleSamples });
+ this.renderTargets.record('multisampleDepth', { width, height, format: 'DEPTH_COMPONENT24', samples: this.multisampleSamples });
+ this.renderTargets.record('frameColor', { width, height, format: this.hdr ? 'RGBA16F' : 'RGBA8' });
this.frameTexture = context.createTexture();
context.bindTexture(context.TEXTURE_2D, this.frameTexture);
context.texImage2D(context.TEXTURE_2D, 0, this.hdr ? context.RGBA16F : context.RGBA8, width, height, 0, context.RGBA, this.hdr ? context.HALF_FLOAT : context.UNSIGNED_BYTE, null);
@@ -1554,24 +1578,11 @@ export class Renderer67 {
context.texParameteri(context.TEXTURE_2D, context.TEXTURE_WRAP_S, context.CLAMP_TO_EDGE);
context.texParameteri(context.TEXTURE_2D, context.TEXTURE_WRAP_T, context.CLAMP_TO_EDGE);
context.framebufferTexture2D(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.TEXTURE_2D, this.depthTexture, 0);
+ this.renderTargets.record('sceneDepth', { width, height, format: 'DEPTH_COMPONENT24' });
}
if (context.checkFramebufferStatus(context.FRAMEBUFFER) !== context.FRAMEBUFFER_COMPLETE) throw new Error('Resolve framebuffer allocation failed. Choose a lower quality preset.');
this.bloomWidth = Math.max(1, Math.ceil(width / 2));
this.bloomHeight = Math.max(1, Math.ceil(height / 2));
- for (let index = 0; index < 2; index++) {
- const texture = context.createTexture();
- const framebuffer = context.createFramebuffer();
- this.bloomTargets.push({ texture, framebuffer });
- context.bindTexture(context.TEXTURE_2D, texture);
- context.texImage2D(context.TEXTURE_2D, 0, this.hdr ? context.RGBA16F : context.RGBA8, this.bloomWidth, this.bloomHeight, 0, context.RGBA, this.hdr ? context.HALF_FLOAT : context.UNSIGNED_BYTE, null);
- context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.LINEAR);
- context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MAG_FILTER, context.LINEAR);
- context.texParameteri(context.TEXTURE_2D, context.TEXTURE_WRAP_S, context.CLAMP_TO_EDGE);
- context.texParameteri(context.TEXTURE_2D, context.TEXTURE_WRAP_T, context.CLAMP_TO_EDGE);
- context.bindFramebuffer(context.FRAMEBUFFER, framebuffer);
- context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, texture, 0);
- if (context.checkFramebufferStatus(context.FRAMEBUFFER) !== context.FRAMEBUFFER_COMPLETE) throw new Error('Bloom framebuffer allocation failed. Choose a lower quality preset.');
- }
context.bindFramebuffer(context.FRAMEBUFFER, null);
}
@@ -1872,8 +1883,32 @@ export class Renderer67 {
context.bindVertexArray(null);
}
+ // Allocated on the first frame that asks for bloom, so scenes without it pay nothing.
+ ensureBloomTargets() {
+ if (this.bloomTargets.length > 0) return;
+ const context = this.context;
+ for (let index = 0; index < 2; index++) {
+ const texture = context.createTexture();
+ const framebuffer = context.createFramebuffer();
+ this.bloomTargets.push({ texture, framebuffer });
+ context.bindTexture(context.TEXTURE_2D, texture);
+ context.texImage2D(context.TEXTURE_2D, 0, this.hdr ? context.RGBA16F : context.RGBA8, this.bloomWidth, this.bloomHeight, 0, context.RGBA, this.hdr ? context.HALF_FLOAT : context.UNSIGNED_BYTE, null);
+ context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.LINEAR);
+ context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MAG_FILTER, context.LINEAR);
+ context.texParameteri(context.TEXTURE_2D, context.TEXTURE_WRAP_S, context.CLAMP_TO_EDGE);
+ context.texParameteri(context.TEXTURE_2D, context.TEXTURE_WRAP_T, context.CLAMP_TO_EDGE);
+ context.bindFramebuffer(context.FRAMEBUFFER, framebuffer);
+ context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, texture, 0);
+ if (context.checkFramebufferStatus(context.FRAMEBUFFER) !== context.FRAMEBUFFER_COMPLETE) throw new Error('Bloom framebuffer allocation failed. Choose a lower quality preset.');
+ }
+ context.bindFramebuffer(context.FRAMEBUFFER, null);
+ this.renderTargets.record('bloomA', { width: this.bloomWidth, height: this.bloomHeight, format: this.hdr ? 'RGBA16F' : 'RGBA8' });
+ this.renderTargets.record('bloomB', { width: this.bloomWidth, height: this.bloomHeight, format: this.hdr ? 'RGBA16F' : 'RGBA8' });
+ }
+
drawBloom(bloom, sourceTexture = this.frameTexture) {
const context = this.context;
+ this.ensureBloomTargets();
context.disable(context.DEPTH_TEST);
context.disable(context.CULL_FACE);
context.bindVertexArray(null);
@@ -2229,7 +2264,7 @@ export class Renderer67 {
dispose() {
this.releaseFrameTargets();
- this.shadowCascades?.dispose(this.context);
+ this.shadowCascades?.dispose(this.context, this.renderTargets);
if (this.localShadowTexture) this.context.deleteTexture(this.localShadowTexture);
if (this.localShadowFramebuffer) this.context.deleteFramebuffer(this.localShadowFramebuffer);
this.batches.forEach((batch) => {
diff --git a/tests/render-target-memory.test.js b/tests/render-target-memory.test.js
new file mode 100644
index 00000000..08e4b59e
--- /dev/null
+++ b/tests/render-target-memory.test.js
@@ -0,0 +1,70 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { Renderer67 } from '../src/renderer.js';
+import { RenderTargetLedger } from '../src/render-target-ledger.js';
+
+const BYTES_PER_MEGABYTE = 1048576;
+
+test('the ledger sizes a target by pixels, layers, samples and format and lists the largest first', () => {
+ const ledger = new RenderTargetLedger();
+ ledger.record('frameColor', { width: 960, height: 540, format: 'RGBA16F' });
+ ledger.record('multisampleColor', { width: 960, height: 540, format: 'RGBA16F', samples: 4 });
+ ledger.record('cascades', { width: 2048, height: 2048, layers: 3, format: 'DEPTH_COMPONENT24' });
+ const report = ledger.report();
+ assert.deepEqual(report.targets.map(target => target.name), ['cascades', 'multisampleColor', 'frameColor']);
+ assert.equal(report.targets[1].bytes, 960 * 540 * 4 * 8);
+ assert.equal(report.targets[0].bytes, 2048 * 2048 * 3 * 4);
+ assert.equal(report.totalBytes, report.targets.reduce((total, target) => total + target.bytes, 0));
+ assert.equal(report.totalMegabytes, Number((report.totalBytes / BYTES_PER_MEGABYTE).toFixed(2)));
+});
+
+test('the ledger forgets released targets', () => {
+ const ledger = new RenderTargetLedger();
+ ledger.record('first', { width: 4, height: 4, format: 'R8' });
+ ledger.record('second', { width: 4, height: 4, format: 'RGBA8' });
+ ledger.release('first', 'missing');
+ assert.deepEqual(ledger.report().targets.map(target => target.name), ['second']);
+});
+
+function recordingContext() {
+ const sizes = [];
+ const context = new Proxy({}, {
+ get(_, name) {
+ if (name === 'texImage2D') return (_target, _level, _format, width, height) => sizes.push([width, height]);
+ if (name === 'checkFramebufferStatus') return () => context.FRAMEBUFFER_COMPLETE;
+ if (name === 'FRAMEBUFFER_COMPLETE') return 1;
+ if (name === 'createTexture' || name === 'createFramebuffer') return () => ({});
+ return typeof name === 'string' && /^[A-Z_0-9]+$/.test(name) ? 1 : () => {};
+ },
+ });
+ return { context, sizes };
+}
+
+function shadowRenderer(batches) {
+ const { context, sizes } = recordingContext();
+ const renderer = Object.create(Renderer67.prototype);
+ Object.assign(renderer, {
+ context, batches, renderTargets: new RenderTargetLedger(), world: null, activeLightDirection: [1, 2, 3], shadowBounds: {},
+ lightProjection: new Float32Array(16), windState: { time: 0, strength: 0 }, drawShadowCasters() {},
+ });
+ return { renderer, sizes };
+}
+
+test('a scene with nothing to cast keeps a one texel shadow map and a casting scene keeps the full one', () => {
+ const empty = shadowRenderer([{ floor: true, castShadow: true }, { castShadow: false }]);
+ empty.renderer.createShadowMap();
+ assert.deepEqual(empty.sizes[0], [1, 1]);
+ assert.equal(empty.renderer.memoryReport().targets[0].bytes, 4);
+ const casting = shadowRenderer([{ castShadow: true }]);
+ casting.renderer.createShadowMap();
+ assert.deepEqual(casting.sizes[0], [2048, 2048]);
+ assert.equal(casting.renderer.memoryReport().totalBytes, 2048 * 2048 * 4);
+});
+
+test('the local shadow atlas holds one row of tiles per four shadow tiles and regrows when more are needed', () => {
+ const { renderer, sizes } = shadowRenderer([]);
+ renderer.allocateLocalShadowAtlas(1);
+ renderer.allocateLocalShadowAtlas(6);
+ assert.deepEqual(sizes, [[2048, 512], [2048, 1024]]);
+ assert.equal(renderer.memoryReport().targets[0].height, 1024);
+});
diff --git a/tests/runtime-report.test.js b/tests/runtime-report.test.js
index 3ae28099..b649d61d 100644
--- a/tests/runtime-report.test.js
+++ b/tests/runtime-report.test.js
@@ -4,7 +4,7 @@ import test from 'node:test';
const report = JSON.parse(readFileSync(new URL('../bench/runtime/report.json', import.meta.url), 'utf8'));
const manifest = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
-const EXPECTED_SCENES = ['instanced-objects', 'large-mesh', 'many-lights', 'many-materials', 'moving-shadows', 'skinned-characters', 'transparency'];
+const EXPECTED_SCENES = ['instanced-objects', 'large-mesh', 'large-outdoor', 'many-lights', 'many-materials', 'moving-shadows', 'skinned-characters', 'transparency'];
const REQUIRED_MEASURES = ['firstFrameMilliseconds', 'fullFrameMilliseconds', 'renderCpuMilliseconds', 'gpuMegabytes', 'drawCalls', 'triangles'];
test('the runtime report covers every scene in both engines on both backends', () => {
@@ -25,6 +25,15 @@ test('each picture difference is recorded, and the three.js version matches the
for (const scene of EXPECTED_SCENES) assert.ok(report.pictureDifference[`gpu-${scene}`] >= 0, scene);
});
+test('each 67js result lists its render targets, and they fit in the GPU memory the counter saw', () => {
+ for (const backend of ['gpu', 'cpu']) {
+ for (const [scene, engines] of Object.entries(report.results[backend])) {
+ const targetMegabytes = engines['67js'].renderTargets.reduce((total, target) => total + target.bytes, 0) / 1048576;
+ assert.ok(targetMegabytes > 0 && targetMegabytes <= engines['67js'].gpuMegabytes, `${backend} ${scene}`);
+ }
+ }
+});
+
test('the report names real hardware and a software renderer, and no local paths', () => {
assert.doesNotMatch(report.graphics.gpu, /swiftshader/i);
assert.match(report.graphics.cpu, /swiftshader/i);