ATOM-13791 Editor: ImGui profiling tools doesn't work correctly due to disabled RenderPipelines

- Added pause/resume button to ImGui Profiler to pause/resume profiling
- Added showing pass execution timeline
- Change TimestampResult to include both begin tick and duration tick. Update some function names of TimestampResult.
- Update some functions names in Pass.
- Stop showing accumulated time for ParentPass.
- Fixed a crash issue with ImGuiManager which doesn't have default font.
This commit is contained in:
qingtao
2021-04-14 22:48:46 -07:00
parent 70c2d5ee40
commit fa7f61cf0d
13 changed files with 291 additions and 124 deletions
@@ -21,41 +21,39 @@ namespace AZ
namespace RPI
{
// --- TimestampResult ---
TimestampResult::TimestampResult(uint64_t timestampInTicks)
TimestampResult::TimestampResult(uint64_t beginTick, uint64_t endTick, RHI::HardwareQueueClass hardwareQueueClass)
{
m_timestampInTicks = timestampInTicks;
AZ_Assert(endTick >= beginTick, "TimestampResult: bad inputs");
m_begin = beginTick;
m_duration = endTick - beginTick;
m_hardwareQueueClass = hardwareQueueClass;
}
TimestampResult::TimestampResult(uint64_t timestampQueryResultLow, uint64_t timestampQueryResultHigh)
{
const uint64_t low = AZStd::min(timestampQueryResultLow, timestampQueryResultHigh);
const uint64_t high = AZStd::max(timestampQueryResultLow, timestampQueryResultHigh);
m_timestampInTicks = high - low;
}
TimestampResult::TimestampResult(AZStd::array_view<TimestampResult>&& timestampResultArray)
{
// Loop through all the child passes, and accumulate all the timestampTicks
for (const TimestampResult& timestampResult : timestampResultArray)
{
m_timestampInTicks += timestampResult.m_timestampInTicks;
}
}
uint64_t TimestampResult::GetTimestampInNanoseconds() const
uint64_t TimestampResult::GetDurationInNanoseconds() const
{
const RHI::Ptr<RHI::Device> device = RHI::GetRHIDevice();
const AZStd::chrono::microseconds timeInMicroseconds = device->GpuTimestampToMicroseconds(m_timestampInTicks, RHI::HardwareQueueClass::Graphics);
const AZStd::chrono::microseconds timeInMicroseconds = device->GpuTimestampToMicroseconds(m_duration, m_hardwareQueueClass);
const auto timeInNanoseconds = AZStd::chrono::nanoseconds(timeInMicroseconds);
return static_cast<uint64_t>(timeInNanoseconds.count());
}
uint64_t TimestampResult::GetTimestampInTicks() const
uint64_t TimestampResult::GetDurationInTicks() const
{
return m_timestampInTicks;
return m_duration;
}
uint64_t TimestampResult::GetTimestampBeginInTicks() const
{
return m_begin;
}
void TimestampResult::Add(const TimestampResult& extent)
{
uint64_t end1 = m_begin + m_duration;
uint64_t end2 = extent.m_begin + extent.m_duration;
m_begin = m_begin < extent.m_begin ? m_begin : extent.m_begin;
m_duration = (end1 > end2 ? end1 : end2) - m_begin;
}
// --- PipelineStatisticsResult ---
@@ -393,19 +393,6 @@ namespace AZ
}
}
TimestampResult ParentPass::GetTimestampResultInternal() const
{
AZStd::vector<TimestampResult> timestampResultArray;
timestampResultArray.reserve(m_children.size());
// Calculate the Timestamp result by summing all of its child's TimestampResults
for (const Ptr<Pass>& childPass : m_children)
{
timestampResultArray.emplace_back(childPass->GetTimestampResult());
}
return TimestampResult(timestampResultArray);
}
PipelineStatisticsResult ParentPass::GetPipelineStatisticsResultInternal() const
{
AZStd::vector<PipelineStatisticsResult> pipelineStatisticsResultArray;
@@ -414,7 +401,7 @@ namespace AZ
// Calculate the PipelineStatistics result by summing all of its child's PipelineStatistics
for (const Ptr<Pass>& childPass : m_children)
{
pipelineStatisticsResultArray.emplace_back(childPass->GetPipelineStatisticsResult());
pipelineStatisticsResultArray.emplace_back(childPass->GetLatestPipelineStatisticsResult());
}
return PipelineStatisticsResult(pipelineStatisticsResultArray);
}
@@ -1273,24 +1273,14 @@ namespace AZ
}
}
TimestampResult Pass::GetTimestampResult() const
TimestampResult Pass::GetLatestTimestampResult() const
{
if (IsEnabled() && IsTimestampQueryEnabled())
{
return GetTimestampResultInternal();
}
return TimestampResult();
return GetTimestampResultInternal();
}
PipelineStatisticsResult Pass::GetPipelineStatisticsResult() const
PipelineStatisticsResult Pass::GetLatestPipelineStatisticsResult() const
{
if (IsEnabled() && IsPipelineStatisticsQueryEnabled())
{
return GetPipelineStatisticsResultInternal();
}
return PipelineStatisticsResult();
return GetPipelineStatisticsResultInternal();
}
TimestampResult Pass::GetTimestampResultInternal() const
@@ -539,7 +539,7 @@ namespace AZ
const uint32_t TimestampResultQueryCount = 2u;
uint64_t timestampResult[TimestampResultQueryCount] = {0};
query->GetLatestResult(&timestampResult, sizeof(uint64_t) * TimestampResultQueryCount);
m_timestampResult = TimestampResult(timestampResult[0], timestampResult[1]);
m_timestampResult = TimestampResult(timestampResult[0], timestampResult[1], RHI::HardwareQueueClass::Graphics);
});
ExecuteOnPipelineStatisticsQuery([this](RHI::Ptr<Query> query)