3 ms·
>, create three million Meshes I didn't watch the presentation so I may be wrong but it's possible you're misinterpret how Mesh was intended to be used. The "
by jasode 11y ago
>, create three million Meshes
I didn't watch the presentation so I may be wrong but it's possible you're misinterpret how Mesh was intended to be used.
The "million" objects is meant to be inside one Mesh. Mesh is singular. The vertices are plural (millions).
If there's more than one Mesh, it would be dozens or hundreds of Mesh (per video game characters).
- jzwinck 11y agoBut if you only ever create a single Mesh, then you wouldn't care to coalesce the allocations, because three allocations instead of one is inconsequential in the course of an entire program lifetime. I agree that there are many vertices and edges within each Mesh, but there better also be tons of Meshes within one program, or there is no problem to begin with.
- svalorzen 11y agoI believe that the main problem is not allocation time (games already have loading times, that's not a problem), but fast access and not breaking the cache.
- jzwinck 11y agoThe title of the first slide in the video is "Heap allocations are expensive!" And using a pool the way I'm proposing does not fragment the heap. It might be slightly worse if you serially touch a lot of Meshes which have only a few vertices and edges each, but this is a corner case and a trade-off anyway.
- slavik81 11y agoMeshes are typically quite big. Moving two small blocks of data together helps to improve cache behaviour as the two blocks can then fit in a single cache line. Moving two giant blocks of data closer together is not going to make much difference, because they probably span hundreds or thousands of cache lines anyways.