PerthThe worklog
An open-world game, built in the open
Credits & data

Worklog › Code

Measured

A page of instances mounts in one step: about 20 µs

The first version of the streamer replayed a cell one placement at a time: an engine instance, an entry in the culler's tree and several calls for every object. At 200 km/h a city needs something like ten thousand new instances a second, so that could not stay.

Now a visual page is a block of 52-byte records that goes to the GPU as it is. The visibility buffer culls, draws and shades the records in the main view, in shadow passes and in reflection probes. Mounting makes no engine instance, puts nothing in the culler, and makes no call for a record.

Measured on an RTX 5060 Ti:

Instances in the cellMount, old pathMount, pagesUnmount, old pathUnmount, pages
1,0001.9 msabout 20 µs5 ms8 µs
3,0008.0 msabout 20 µs26 ms8 µs
10,00022 msabout 20 µs106 ms8 µs

The cost on the main thread no longer grows with what is in the cell, which was the requirement. A drive at 56 m/s and a flight at 100 m/s over a made-up world had no frame over 9.2 ms at any of the three sizes.

The renderer skips a whole page whose bounds are outside the view; inside a page the GPU culls and picks detail for each cluster, as it already did.

A page instance must be opaque and static. Anything alpha-tested, transparent or with moving vertices is diverted to the slow path, one record at a time. A view holds at most 262,144 page instances.