Dynamic message subscriptions.

Allow components to individually subscribe/unsubscribe to messages,
instead of statically subscribing the entire component type. Use this
for most Interpolate/RenderSubmit messages, to avoid the performance
cost of passing those messages to a large number of components that will
just ignore them anyway.

On Azure Coast this reduces total time per frame by about 30% on a
CPU-bound system.

This was SVN commit r15400.
This commit is contained in:
Ykkrosh
2014-06-19 23:20:12 +00:00
parent ec7a452d4e
commit d936bde74a
12 changed files with 391 additions and 22 deletions
@@ -116,7 +116,6 @@ public:
{
componentManager.SubscribeToMessageType(MT_Update_MotionFormation);
componentManager.SubscribeToMessageType(MT_Update_MotionUnit);
componentManager.SubscribeToMessageType(MT_RenderSubmit); // for debug overlays
componentManager.SubscribeToMessageType(MT_PathResult);
componentManager.SubscribeToMessageType(MT_ValueModification);
}
@@ -403,6 +402,7 @@ public:
}
case MT_RenderSubmit:
{
PROFILE3("UnitMotion::RenderSubmit");
const CMessageRenderSubmit& msgData = static_cast<const CMessageRenderSubmit&> (msg);
RenderSubmit(msgData.collector);
break;
@@ -436,6 +436,12 @@ public:
}
}
void UpdateMessageSubscriptions()
{
bool needRender = m_DebugOverlayEnabled;
GetSimContext().GetComponentManager().DynamicSubscriptionNonsync(MT_RenderSubmit, this, needRender);
}
virtual bool IsMoving()
{
return m_Moving;
@@ -487,6 +493,7 @@ public:
virtual void SetDebugOverlay(bool enabled)
{
m_DebugOverlayEnabled = enabled;
UpdateMessageSubscriptions();
}
virtual bool MoveToPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange);