diff --git a/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.inl b/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.inl index daeb797c42..e349685fd3 100644 --- a/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.inl +++ b/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.inl @@ -25,17 +25,15 @@ namespace AZ { // NOTE: Fix build error in case AZStd::thread_id is not of an arithmetic type, and instead a pointer template::value>::type* = nullptr> - void TextThreadId(ThreadId threadId) + AZStd::string TextThreadId(ThreadId threadId) { - const AZStd::string threadIdText = AZStd::string::format("Thread: %p", threadId); - ImGui::Text(threadIdText.c_str()); + return AZStd::string::format("Thread: %p", threadId); } template::value>::type* = nullptr> - void TextThreadId(ThreadId threadId) + AZStd::string TextThreadId(ThreadId threadId) { - const AZStd::string threadIdText = AZStd::string::format("Thread: %zu", static_cast(threadId)); - ImGui::Text(threadIdText.c_str()); + return AZStd::string::format("Thread: %zu", static_cast(threadId)); } inline float TicksToMs(AZStd::sys_time_t ticks) { @@ -108,7 +106,7 @@ namespace AZ for (ThreadRegionEntry& entry : entries) { - CpuProfilerImGuiHelper::TextThreadId(entry.m_threadId.m_id); + ImGui::Text(CpuProfilerImGuiHelper::TextThreadId(entry.m_threadId.m_id).c_str()); const AZStd::sys_time_t elapsed = entry.m_endTick - entry.m_startTick; ShowTimeInMs(elapsed); @@ -610,7 +608,7 @@ namespace AZ { auto [wx, wy] = ImGui::GetWindowPos(); wy -= ImGui::GetScrollY(); - const AZStd::string threadIdText = AZStd::string::format("Thread %zu", static_cast(threadId.m_id)); + const AZStd::string threadIdText = CpuProfilerImGuiHelper::TextThreadId(threadId.m_id); ImGui::GetWindowDrawList()->AddText({ wx + 10, wy + baseRow * RowHeight + 5 }, IM_COL32_WHITE, threadIdText.c_str()); }