Visualizer: fix empty rows being shown (#2881)

Fixes a bug with the visualizer where there would be empty rows shown,
e.g. threads without any profiling regions. This was especially
noticable when going from a high thread count sample (MultiThread) to a
low thread count sample, where most of the visualizer would be empty
lines. This adds a data culling step to remove the threads without any
remaining execution data + an early out so that all threads shown
onscreen must have some regions recorded.

Signed-off-by: Jacob Hilliard <jhlliar@amazon.com>
This commit is contained in:
Jacob Hilliard
2021-08-11 15:32:11 -07:00
committed by GitHub
parent 7e5cbdab1e
commit 016cfef6ca
@@ -329,7 +329,7 @@ namespace AZ
ImGui::Text("Viewport width: %.3f ms", CpuProfilerImGuiHelper::TicksToMs(GetViewportTickWidth()));
ImGui::Text("Ticks [%lld , %lld]", m_viewportStartTick, m_viewportEndTick);
ImGui::Text("Recording %ld threads", RHI::CpuProfiler::Get()->GetTimeRegionMap().size());
ImGui::Text("Recording %zu threads", m_savedData.size());
ImGui::Text("%llu profiling events saved", m_savedRegionCount);
ImGui::NextColumn();
@@ -389,6 +389,11 @@ namespace AZ
return wrapper.m_startTick < target;
});
if (regionItr == singleThreadData.end())
{
continue;
}
// Draw all of the blocks for a given thread/row
u64 maxDepth = 0;
while (regionItr != singleThreadData.end())
@@ -559,6 +564,14 @@ namespace AZ
m_savedRegionCount -= sizeBeforeRemove - savedRegions.size();
}
// Remove any threads from the top-level map that no longer hold data
AZStd::erase_if(
m_savedData,
[](const auto& singleThreadDataEntry)
{
return singleThreadDataEntry.second.empty();
});
}
inline void ImGuiCpuProfiler::DrawBlock(const TimeRegion& block, u64 targetRow)