diff --git a/include/RenderGraph/RunnablePass.hpp b/include/RenderGraph/RunnablePass.hpp index 1623879..710d89d 100644 --- a/include/RenderGraph/RunnablePass.hpp +++ b/include/RenderGraph/RunnablePass.hpp @@ -85,19 +85,43 @@ namespace crg struct Config { /** - *\param[in] config - * The callback to recording the pass. + *\param[in] view + * The action's target viex. + *\param[in] action + * The implicit action. */ auto & implicitAction( ImageViewId view , RecordContext::ImplicitAction action ) { - actions.emplace( view, action ); + implicitActions.emplace( view, action ); + return *this; + } + + /** + *\param[in] action + * The action to run before the pass recording. + */ + auto & prePassAction( RecordContext::ImplicitAction action ) + { + prePassActions.emplace_back( action ); + return *this; + } + + /** + *\param[in] action + * The action to run after the pass recording. + */ + auto & postPassAction( RecordContext::ImplicitAction action ) + { + postPassActions.emplace_back( action ); return *this; } uint32_t maxPassCount{ 1u }; bool resettable{ false }; - std::map< ImageViewId, RecordContext::ImplicitAction > actions{}; + std::vector< RecordContext::ImplicitAction > prePassActions{}; + std::vector< RecordContext::ImplicitAction > postPassActions{}; + std::map< ImageViewId, RecordContext::ImplicitAction > implicitActions{}; }; } diff --git a/source/RenderGraph/RunnablePass.cpp b/source/RenderGraph/RunnablePass.cpp index 7eb6995..ac4ecf1 100644 --- a/source/RenderGraph/RunnablePass.cpp +++ b/source/RenderGraph/RunnablePass.cpp @@ -535,13 +535,23 @@ namespace crg } } + for ( auto & action : m_ruConfig.prePassActions ) + { + action( context, commandBuffer, index ); + } + m_callbacks.record( context, commandBuffer, index ); + for ( auto & action : m_ruConfig.postPassActions ) + { + action( context, commandBuffer, index ); + } + m_timer.endPass( commandBuffer ); m_context.vkCmdEndDebugBlock( commandBuffer ); } - for ( auto & action : m_ruConfig.actions ) + for ( auto & action : m_ruConfig.implicitActions ) { context.registerImplicitTransition( *this , action.first diff --git a/source/RenderGraph/RunnablePasses/RenderMesh.cpp b/source/RenderGraph/RunnablePasses/RenderMesh.cpp index d4aa01a..e622690 100644 --- a/source/RenderGraph/RunnablePasses/RenderMesh.cpp +++ b/source/RenderGraph/RunnablePasses/RenderMesh.cpp @@ -21,7 +21,9 @@ namespace crg , IsEnabledCallback( [this](){ return m_renderMesh.isEnabled(); } ) } , { ruConfig.maxPassCount , true /*resettable*/ - , ruConfig.actions } } + , ruConfig.prePassActions + , ruConfig.postPassActions + , ruConfig.implicitActions } } , m_renderMesh{ pass , context , graph diff --git a/source/RenderGraph/RunnablePasses/RenderQuad.cpp b/source/RenderGraph/RunnablePasses/RenderQuad.cpp index 34f5d24..5d61a50 100644 --- a/source/RenderGraph/RunnablePasses/RenderQuad.cpp +++ b/source/RenderGraph/RunnablePasses/RenderQuad.cpp @@ -21,7 +21,9 @@ namespace crg , IsEnabledCallback( [this](){ return m_renderQuad.isEnabled(); } ) } , { ruConfig.maxPassCount , true /*resettable*/ - , ruConfig.actions } } + , ruConfig.prePassActions + , ruConfig.postPassActions + , ruConfig.implicitActions } } , m_renderQuad{ pass , context , graph