mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Reuse some allocations in ClientMap rendering
This commit is contained in:
parent
a9c197b1e5
commit
37d2bc8a5f
1 changed files with 13 additions and 4 deletions
|
@ -120,6 +120,11 @@ namespace {
|
||||||
inline T subtract_or_zero(T a, T b) {
|
inline T subtract_or_zero(T a, T b) {
|
||||||
return b >= a ? T(0) : (a - b);
|
return b >= a ? T(0) : (a - b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// file-scope thread-local instances of the above two data structures, because
|
||||||
|
// allocating memory in a hot path can be expensive.
|
||||||
|
thread_local MeshBufListMaps tl_meshbuflistmaps;
|
||||||
|
thread_local DrawDescriptorList tl_drawdescriptorlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CachedMeshBuffer::drop()
|
void CachedMeshBuffer::drop()
|
||||||
|
@ -978,8 +983,10 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
||||||
*/
|
*/
|
||||||
TimeTaker tt_collect("");
|
TimeTaker tt_collect("");
|
||||||
|
|
||||||
MeshBufListMaps grouped_buffers;
|
MeshBufListMaps &grouped_buffers = tl_meshbuflistmaps;
|
||||||
DrawDescriptorList draw_order;
|
DrawDescriptorList &draw_order = tl_drawdescriptorlist;
|
||||||
|
grouped_buffers.clear();
|
||||||
|
draw_order.clear();
|
||||||
|
|
||||||
auto is_frustum_culled = m_client->getCamera()->getFrustumCuller();
|
auto is_frustum_culled = m_client->getCamera()->getFrustumCuller();
|
||||||
|
|
||||||
|
@ -1375,8 +1382,10 @@ void ClientMap::renderMapShadows(video::IVideoDriver *driver,
|
||||||
return intToFloat(mesh_grid.getMeshPos(pos) * MAP_BLOCKSIZE - m_camera_offset, BS);
|
return intToFloat(mesh_grid.getMeshPos(pos) * MAP_BLOCKSIZE - m_camera_offset, BS);
|
||||||
};
|
};
|
||||||
|
|
||||||
MeshBufListMaps grouped_buffers;
|
MeshBufListMaps &grouped_buffers = tl_meshbuflistmaps;
|
||||||
DrawDescriptorList draw_order;
|
DrawDescriptorList &draw_order = tl_drawdescriptorlist;
|
||||||
|
grouped_buffers.clear();
|
||||||
|
draw_order.clear();
|
||||||
|
|
||||||
std::size_t count = 0;
|
std::size_t count = 0;
|
||||||
std::size_t meshes_per_frame = m_drawlist_shadow.size() / total_frames + 1;
|
std::size_t meshes_per_frame = m_drawlist_shadow.size() / total_frames + 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue