Added MULTIPLAYER budget. Added profiler markers, visible in PIX.

development
Olex Lozitskiy 4 years ago committed by GitHub
commit fdb9c053ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -39,6 +39,9 @@
#include <AzNetworking/Framework/INetworking.h> #include <AzNetworking/Framework/INetworking.h>
#include <cmath> #include <cmath>
#include <AzCore/Debug/Profiler.h>
AZ_DEFINE_BUDGET(MULTIPLAYER);
namespace AZ::ConsoleTypeHelpers namespace AZ::ConsoleTypeHelpers
{ {
@ -353,6 +356,8 @@ namespace Multiplayer
void MultiplayerSystemComponent::OnTick(float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) void MultiplayerSystemComponent::OnTick(float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
{ {
AZ_PROFILE_SCOPE(MULTIPLAYER, "MultiplayerSystemComponent: OnTick");
if (bg_multiplayerDebugDraw) if (bg_multiplayerDebugDraw)
{ {
m_networkEntityManager.DebugDraw(); m_networkEntityManager.DebugDraw();
@ -395,6 +400,8 @@ namespace Multiplayer
// Send out the game state update to all connections // Send out the game state update to all connections
{ {
AZ_PROFILE_SCOPE(MULTIPLAYER, "MultiplayerSystemComponent: OnTick - SendOutGameStateUpdate");
auto sendNetworkUpdates = [&stats](IConnection& connection) auto sendNetworkUpdates = [&stats](IConnection& connection)
{ {
if (connection.GetUserData() != nullptr) if (connection.GetUserData() != nullptr)
@ -440,6 +447,7 @@ namespace Multiplayer
if (!packet.GetCommandSet().empty()) if (!packet.GetCommandSet().empty())
{ {
AZ_PROFILE_SCOPE(MULTIPLAYER, "MultiplayerSystemComponent: OnTick - SendReliablePackets");
m_networkInterface->GetConnectionSet().VisitConnections(visitor); m_networkInterface->GetConnectionSet().VisitConnections(visitor);
} }
} }
@ -1018,6 +1026,8 @@ namespace Multiplayer
void MultiplayerSystemComponent::TickVisibleNetworkEntities(float deltaTime, float serverRateSeconds) void MultiplayerSystemComponent::TickVisibleNetworkEntities(float deltaTime, float serverRateSeconds)
{ {
AZ_PROFILE_SCOPE(MULTIPLAYER, "MultiplayerSystemComponent: TickVisibleNetworkEntities");
m_tickFactor += deltaTime / serverRateSeconds; m_tickFactor += deltaTime / serverRateSeconds;
// Linear close to the origin, but asymptote at y = 1 // Linear close to the origin, but asymptote at y = 1
m_renderBlendFactor = AZStd::clamp(1.0f - (std::pow(cl_renderTickBlendBase, m_tickFactor)), 0.0f, m_tickFactor); m_renderBlendFactor = AZStd::clamp(1.0f - (std::pow(cl_renderTickBlendBase, m_tickFactor)), 0.0f, m_tickFactor);

@ -26,8 +26,11 @@
#include <AzCore/Component/ComponentApplicationBus.h> #include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/Console/IConsole.h> #include <AzCore/Console/IConsole.h>
#include <AzCore/Console/ILogger.h> #include <AzCore/Console/ILogger.h>
#include <AzCore/Debug/Profiler.h>
#include <AzCore/Math/Transform.h> #include <AzCore/Math/Transform.h>
AZ_DECLARE_BUDGET(MULTIPLAYER);
namespace Multiplayer namespace Multiplayer
{ {
// Current max size for a UdpPacketHeader is 11 bytes // Current max size for a UdpPacketHeader is 11 bytes
@ -78,6 +81,8 @@ namespace Multiplayer
void EntityReplicationManager::ActivatePendingEntities() void EntityReplicationManager::ActivatePendingEntities()
{ {
AZ_PROFILE_SCOPE(MULTIPLAYER, "EntityReplicationManager: ActivatePendingEntities");
AZStd::vector<NetEntityId> notReadyEntities; AZStd::vector<NetEntityId> notReadyEntities;
const AZ::TimeMs endTimeMs = AZ::GetElapsedTimeMs() + m_entityActivationTimeSliceMs; const AZ::TimeMs endTimeMs = AZ::GetElapsedTimeMs() + m_entityActivationTimeSliceMs;
@ -126,17 +131,23 @@ namespace Multiplayer
GetRemoteHostId().GetString().c_str() GetRemoteHostId().GetString().c_str()
); );
// Prep a replication record for send, at this point, everything needs to be sent
for (EntityReplicator* replicator : toSendList)
{ {
replicator->GetPropertyPublisher()->PrepareSerialization(); AZ_PROFILE_SCOPE(MULTIPLAYER, "EntityReplicationManager: SendUpdates - PrepareSerialization");
// Prep a replication record for send, at this point, everything needs to be sent
for (EntityReplicator* replicator : toSendList)
{
replicator->GetPropertyPublisher()->PrepareSerialization();
}
} }
// While our to send list is not empty, build up another packet to send
do
{ {
SendEntityUpdateMessages(toSendList); AZ_PROFILE_SCOPE(MULTIPLAYER, "EntityReplicationManager: SendUpdates - SendEntityUpdateMessages");
} while (!toSendList.empty()); // While our to send list is not empty, build up another packet to send
do
{
SendEntityUpdateMessages(toSendList);
} while (!toSendList.empty());
}
} }
SendEntityRpcs(m_deferredRpcMessagesReliable, true); SendEntityRpcs(m_deferredRpcMessagesReliable, true);
@ -164,6 +175,8 @@ namespace Multiplayer
return EntityReplicatorList(); return EntityReplicatorList();
} }
AZ_PROFILE_SCOPE(MULTIPLAYER, "EntityReplicationManager: GenerateEntityUpdateList");
// Generate a list of all our entities that need updates // Generate a list of all our entities that need updates
EntityReplicatorList toSendList; EntityReplicatorList toSendList;

@ -25,6 +25,8 @@
#include <Multiplayer/Components/NetworkHierarchyRootComponent.h> #include <Multiplayer/Components/NetworkHierarchyRootComponent.h>
#include <Pipeline/NetworkSpawnableHolderComponent.h> #include <Pipeline/NetworkSpawnableHolderComponent.h>
AZ_DECLARE_BUDGET(MULTIPLAYER);
namespace Multiplayer namespace Multiplayer
{ {
AZ_CVAR(bool, net_DebugCheckNetworkEntityManager, false, nullptr, AZ::ConsoleFunctorFlags::Null, "Enables extra debug checks inside the NetworkEntityManager"); AZ_CVAR(bool, net_DebugCheckNetworkEntityManager, false, nullptr, AZ::ConsoleFunctorFlags::Null, "Enables extra debug checks inside the NetworkEntityManager");
@ -203,11 +205,13 @@ namespace Multiplayer
void NetworkEntityManager::NotifyEntitiesDirtied() void NetworkEntityManager::NotifyEntitiesDirtied()
{ {
AZ_PROFILE_SCOPE(MULTIPLAYER, "NetworkEntityManager: NotifyEntitiesDirtied");
m_onEntityMarkedDirty.Signal(); m_onEntityMarkedDirty.Signal();
} }
void NetworkEntityManager::NotifyEntitiesChanged() void NetworkEntityManager::NotifyEntitiesChanged()
{ {
AZ_PROFILE_SCOPE(MULTIPLAYER, "NetworkEntityManager: NotifyEntitiesChanged");
m_onEntityNotifyChanges.Signal(); m_onEntityNotifyChanges.Signal();
} }

Loading…
Cancel
Save