Add InputLatencyMs stat to ProfilingTools
This commit is contained in:
@@ -753,6 +753,8 @@ void GPUDevice::DrawEnd()
|
||||
}
|
||||
#if COMPILE_WITH_PROFILER
|
||||
const double presentEnd = Platform::GetTimeSeconds();
|
||||
extern double LastInputLatency, LastInputReadTime;
|
||||
LastInputLatency = (float)(presentEnd - LastInputReadTime);
|
||||
ProfilerGPU::OnPresentTime((float)((presentEnd - presentStart) * 1000.0));
|
||||
#endif
|
||||
GetMainContext()->OnPresent();
|
||||
|
||||
@@ -50,6 +50,8 @@ namespace
|
||||
InputDevice::EventQueue InputEvents;
|
||||
}
|
||||
|
||||
double LastInputReadTime = 0;
|
||||
|
||||
class InputService : public EngineService
|
||||
{
|
||||
public:
|
||||
@@ -860,6 +862,7 @@ void InputService::Update()
|
||||
const auto frame = Time::Update.TicksCount;
|
||||
const auto dt = Time::Update.UnscaledDeltaTime.GetTotalSeconds();
|
||||
InputEvents.Clear();
|
||||
LastInputReadTime = Platform::GetTimeSeconds();
|
||||
|
||||
// If application has no user focus then simply clear the state
|
||||
if (!Engine::HasFocus)
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
};
|
||||
|
||||
ProfilingToolsService ProfilingToolsServiceInstance;
|
||||
double LastInputLatency = 0;
|
||||
|
||||
void ProfilingToolsService::Update()
|
||||
{
|
||||
@@ -52,6 +53,8 @@ void ProfilingToolsService::Update()
|
||||
float presentTime;
|
||||
ProfilerGPU::GetLastFrameData(stats.DrawGPUTimeMs, presentTime, stats.DrawStats);
|
||||
stats.DrawCPUTimeMs = Math::Max(stats.DrawCPUTimeMs - presentTime, 0.0f); // Remove swapchain present wait time to exclude from drawing on CPU
|
||||
|
||||
stats.InputLatencyMs = (float)(LastInputLatency * 1000.0);
|
||||
}
|
||||
|
||||
// Extract CPU profiler events
|
||||
|
||||
@@ -81,6 +81,11 @@ public:
|
||||
/// </summary>
|
||||
API_FIELD() float DrawGPUTimeMs;
|
||||
|
||||
/// <summary>
|
||||
/// The time between player inputs reading and frame presentation to display (in milliseconds).
|
||||
/// </summary>
|
||||
API_FIELD() float InputLatencyMs;
|
||||
|
||||
/// <summary>
|
||||
/// The last rendered frame stats.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user