Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions include/RenderGraph/FramePassTimer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ namespace crg
using OnFramePassDestroy = Signal< FramePassDestroyFunc >;
using OnFramePassDestroyConnection = SignalConnection< OnFramePassDestroy >;

enum class TimerScope
{
eGraph,
ePass,
eUpdate,
};

class FramePassTimerBlock
{
public:
Expand Down Expand Up @@ -54,6 +61,7 @@ namespace crg
*/
CRG_API FramePassTimer( GraphContext & context
, std::string const & name
, TimerScope scope
, VkQueryPool timerQueries
, uint32_t & baseQueryOffset );
/**
Expand All @@ -67,7 +75,8 @@ namespace crg
* The timer name.
*/
CRG_API FramePassTimer( GraphContext & context
, std::string const & name );
, std::string const & name
, TimerScope scope );
CRG_API ~FramePassTimer();
/**
*\brief
Expand Down Expand Up @@ -117,20 +126,25 @@ namespace crg
* Getters.
*/
/**@{*/
Nanoseconds getCpuTime()const
Nanoseconds getCpuTime()const noexcept
{
return m_cpuTime;
}

Nanoseconds getGpuTime()const
Nanoseconds getGpuTime()const noexcept
{
return m_gpuTime;
}

std::string const & getName()const
std::string const & getName()const noexcept
{
return m_name;
}

TimerScope getScope()const noexcept
{
return m_scope;
}
/**@}*/

OnFramePassDestroy onDestroy;
Expand All @@ -140,6 +154,7 @@ namespace crg

private:
GraphContext & m_context;
TimerScope m_scope;
std::string m_name;
Clock::time_point m_cpuSaveTime;
Nanoseconds m_cpuTime;
Expand Down
6 changes: 5 additions & 1 deletion source/RenderGraph/FramePassTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ namespace crg

FramePassTimer::FramePassTimer( GraphContext & context
, std::string const & name
, TimerScope scope
, VkQueryPool timerQueries
, uint32_t & baseQueryOffset )
: m_context{ context }
, m_scope{ scope }
, m_name{ name }
, m_cpuTime{ 0ns }
, m_gpuTime{ 0ns }
Expand All @@ -57,8 +59,10 @@ namespace crg
}

FramePassTimer::FramePassTimer( GraphContext & context
, std::string const & name )
, std::string const & name
, TimerScope scope )
: m_context{ context }
, m_scope{ scope }
, m_name{ name }
, m_cpuTime{ 0ns }
, m_gpuTime{ 0ns }
Expand Down
8 changes: 7 additions & 1 deletion source/RenderGraph/RunnableGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ namespace crg
, m_fence{ m_context
, graph.getName() + "/Graph"
, { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, VK_FENCE_CREATE_SIGNALED_BIT } }
, m_timer{ context, graph.getName() + "/Graph", getTimerQueryPool(), getTimerQueryOffset() }
, m_timer{ context, graph.getName() + "/Graph", TimerScope::eGraph, getTimerQueryPool(), getTimerQueryOffset() }
{
if ( m_context.device )
{
Expand Down Expand Up @@ -363,6 +363,12 @@ namespace crg
std::vector< VkPipelineStageFlags > dstStageMasks;
convert( toWait, semaphores, dstStageMasks );
m_timer.notifyPassRender();

for ( auto & pass : m_passes )
{
pass->notifyPassRender();
}

VkSubmitInfo submitInfo{ VK_STRUCTURE_TYPE_SUBMIT_INFO
, nullptr
, uint32_t( semaphores.size() )
Expand Down
7 changes: 5 additions & 2 deletions source/RenderGraph/RunnablePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ namespace crg
, m_callbacks{ std::move( callbacks ) }
, m_ruConfig{ std::move( ruConfig ) }
, m_pipelineState{ m_callbacks.getPipelineState() }
, m_timer{ context, pass.getGroupName(), graph.getTimerQueryPool(), graph.getTimerQueryOffset() }
, m_timer{ context, pass.getGroupName(), TimerScope::ePass, graph.getTimerQueryPool(), graph.getTimerQueryOffset() }
{
for ( uint32_t i = 0u; i < m_ruConfig.maxPassCount; ++i )
{
Expand Down Expand Up @@ -645,7 +645,10 @@ namespace crg

void RunnablePass::notifyPassRender()
{
m_timer.notifyPassRender();
if ( isEnabled() )
{
m_timer.notifyPassRender( getIndex() );
}
}

VkCommandBuffer RunnablePass::doCreateCommandBuffer( std::string const & suffix )
Expand Down