Add InputLatencyMs stat to ProfilingTools

This commit is contained in:
2026-07-22 09:59:36 +02:00
parent 90947905cc
commit c306781eb3
4 changed files with 13 additions and 0 deletions
+2
View File
@@ -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();
+3
View File
@@ -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
+5
View File
@@ -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>