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
15 changes: 12 additions & 3 deletions include/RenderGraph/FramePassTimer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace crg
using FramePassDestroyFunc = std::function< void( FramePassTimer & ) >;
using OnFramePassDestroy = Signal< FramePassDestroyFunc >;
using OnFramePassDestroyConnection = SignalConnection< OnFramePassDestroy >;
using PassColour = std::array< float, 4u >;

enum class TimerScope
{
Expand Down Expand Up @@ -104,10 +105,12 @@ namespace crg
* Writes the timestamp for the beginning of the pass.
*\param[in] cmd
* The command buffer used to record the begin timestamp.
*\param[in] passIndex
* The pass index.
*\param[in] passId
* The pass ID.
*/
CRG_API void beginPass( VkCommandBuffer commandBuffer )noexcept;
CRG_API void beginPass( VkCommandBuffer commandBuffer
, std::string const & groupName
, uint32_t passId )noexcept;
/**
*\brief
* Writes the timestamp for the end of the pass.
Expand Down Expand Up @@ -142,6 +145,11 @@ namespace crg
return m_name;
}

PassColour const & getColour()const noexcept
{
return m_colour;
}

TimerScope getScope()const noexcept
{
return m_scope;
Expand All @@ -157,6 +165,7 @@ namespace crg
GraphContext & m_context;
TimerScope m_scope{};
std::string m_name{};
PassColour m_colour;
Clock::time_point m_cpuSaveTime{};
Nanoseconds m_cpuTime{};
Nanoseconds m_gpuTime{};
Expand Down
13 changes: 12 additions & 1 deletion source/RenderGraph/FramePassTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace crg
: m_context{ context }
, m_scope{ scope }
, m_name{ name }
, m_colour{ context.getNextRainbowColour() }
, m_timerQueries{ timerQueries }
, m_queries{ { { baseQueryOffset, false, false }, { baseQueryOffset + 2u, false, false } } }
{
Expand All @@ -51,6 +52,7 @@ namespace crg
: m_context{ context }
, m_scope{ scope }
, m_name{ name }
, m_colour{ context.getNextRainbowColour() }
, m_timerQueries{ createQueryPool( context, name, 4u ) }
, m_ownPool{ true }
, m_queries{ { { 0u, false, false }, { 2u, false, false } } }
Expand Down Expand Up @@ -101,8 +103,16 @@ namespace crg
m_gpuTime = 0ns;
}

void FramePassTimer::beginPass( VkCommandBuffer commandBuffer )noexcept
void FramePassTimer::beginPass( VkCommandBuffer commandBuffer
, std::string const & groupName
, uint32_t passId )noexcept
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wrestrict"
m_context.vkCmdBeginDebugBlock( commandBuffer
, { "[" + std::to_string( passId ) + "] " + groupName
, m_colour } );
#pragma GCC diagnostic pop
std::swap( m_queries.front(), m_queries.back() );
auto const & query = m_queries.front();
m_context.vkCmdResetQueryPool( commandBuffer
Expand All @@ -123,6 +133,7 @@ namespace crg
, m_timerQueries
, query.offset + 1u );
query.written = true;
m_context.vkCmdEndDebugBlock( commandBuffer );
}

void FramePassTimer::retrieveGpuTime()noexcept
Expand Down
2 changes: 1 addition & 1 deletion source/RenderGraph/RunnableGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ namespace crg
, VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
, nullptr };
m_context.vkBeginCommandBuffer( m_commandBuffer, &beginInfo );
m_timer.beginPass( m_commandBuffer );
m_timer.beginPass( m_commandBuffer, getName(), 0u );

while ( currPass != m_passes.end() )
{
Expand Down
9 changes: 1 addition & 8 deletions source/RenderGraph/RunnablePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,13 +551,7 @@ namespace crg
}

auto block( m_timer.start() );
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wrestrict"
m_context.vkCmdBeginDebugBlock( commandBuffer
, { "[" + std::to_string( m_pass.getId() ) + "] " + m_pass.getGroupName()
, m_context.getNextRainbowColour() } );
#pragma GCC diagnostic pop
m_timer.beginPass( commandBuffer );
m_timer.beginPass( commandBuffer, m_pass.getGroupName(), m_pass.getId() );

details::prepareResources( commandBuffer, index, context
, m_graph, m_pass, m_callbacks, m_context );
Expand All @@ -575,7 +569,6 @@ namespace crg
}

m_timer.endPass( commandBuffer );
m_context.vkCmdEndDebugBlock( commandBuffer );
}

for ( auto const & [view, action] : m_ruConfig.implicitImageActions )
Expand Down