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
11 changes: 9 additions & 2 deletions include/RenderGraph/Attachment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ namespace crg

CRG_API VkDescriptorType getDescriptorType()const;
CRG_API WriteDescriptorSet getWrite( uint32_t binding
, uint32_t count )const;
, uint32_t count
, uint32_t index )const;
CRG_API VkAccessFlags getAccessMask( bool isInput
, bool isOutput )const;
CRG_API VkPipelineStageFlags getPipelineStageFlags( bool isCompute )const;
Expand All @@ -260,6 +261,11 @@ namespace crg
return Flag( flags & FlagKind( flag ) ) == flag;
}

uint32_t getBufferCount()const
{
return uint32_t( buffer.getCount() );
}

bool isUniform()const
{
return hasFlag( Flag::Uniform );
Expand Down Expand Up @@ -351,10 +357,11 @@ namespace crg
*/
/**@{*/
CRG_API uint32_t getViewCount()const;
CRG_API uint32_t getBufferCount()const;
CRG_API ImageViewId view( uint32_t index = 0u )const;
CRG_API VkImageLayout getImageLayout( bool separateDepthStencilLayouts )const;
CRG_API VkDescriptorType getDescriptorType()const;
CRG_API WriteDescriptorSet getBufferWrite()const;
CRG_API WriteDescriptorSet getBufferWrite( uint32_t index = 0u )const;
CRG_API VkAccessFlags getAccessMask()const;
CRG_API VkPipelineStageFlags getPipelineStageFlags( bool isCompute )const;

Expand Down
6 changes: 4 additions & 2 deletions include/RenderGraph/FrameGraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ namespace crg
CRG_API LayoutState getFinalLayoutState( ImageId image
, VkImageViewType viewType
, VkImageSubresourceRange range )const;
CRG_API LayoutState getFinalLayoutState( ImageViewId view )const;
CRG_API AccessState getFinalAccessState( Buffer const & buffer )const;
CRG_API LayoutState getFinalLayoutState( ImageViewId view
, uint32_t passIndex = 0u )const;
CRG_API AccessState getFinalAccessState( Buffer const & buffer
, uint32_t passIndex = 0u )const;
CRG_API void addInput( ImageId image
, VkImageViewType viewType
, VkImageSubresourceRange range
Expand Down
42 changes: 41 additions & 1 deletion include/RenderGraph/FrameGraphPrerequisites.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ namespace crg

using VkAttachmentDescriptionArray = std::vector< VkAttachmentDescription >;
using VkAttachmentReferenceArray = std::vector< VkAttachmentReference >;
using VkBufferArray = std::vector< VkBuffer >;
using VkBufferViewArray = std::vector< VkBufferView >;
using VkDescriptorBufferInfoArray = std::vector< VkDescriptorBufferInfo >;
using VkDescriptorImageInfoArray = std::vector< VkDescriptorImageInfo >;
Expand Down Expand Up @@ -198,9 +199,46 @@ namespace crg

struct Buffer
{
VkBuffer buffer;
std::string name;

Buffer( VkBufferArray pbuffers
, std::string pname )noexcept
: name{ std::move( pname ) }
, m_buffers{ std::move( pbuffers ) }
{
}

Buffer( VkBuffer buffer
, std::string name )noexcept
: Buffer{ VkBufferArray{ buffer }, std::move( name ) }
{
}

VkBuffer const & buffer( uint32_t index = 0 )const noexcept
{
return m_buffers.size() == 1u
? m_buffers.front()
: m_buffers[index];
}

VkBuffer & buffer( uint32_t index = 0 )noexcept
{
return m_buffers.size() == 1u
? m_buffers.front()
: m_buffers[index];
}

size_t getCount()const noexcept
{
return m_buffers.size();
}

private:
VkBufferArray m_buffers;

friend CRG_API bool operator==( Buffer const & lhs, Buffer const & rhs );
};

CRG_API bool operator==( Buffer const & lhs, Buffer const & rhs );

struct VertexBuffer
Expand Down Expand Up @@ -391,6 +429,8 @@ namespace crg
CRG_API bool isStencilFormat( VkFormat fmt )noexcept;
CRG_API bool isColourFormat( VkFormat fmt )noexcept;
CRG_API bool isDepthStencilFormat( VkFormat fmt )noexcept;
CRG_API ImageViewId const & resolveView( ImageViewId const & view
, uint32_t passIndex );

template< typename T >
static size_t hashCombine( size_t hash
Expand Down
6 changes: 4 additions & 2 deletions include/RenderGraph/FramePassGroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ namespace crg
*/
/**@[*/
CRG_API ResourceHandler & getHandler()const;
CRG_API LayoutState getFinalLayoutState( ImageViewId view )const;
CRG_API AccessState getFinalAccessState( Buffer const & buffer )const;
CRG_API LayoutState getFinalLayoutState( ImageViewId view
, uint32_t passIndex = 0u )const;
CRG_API AccessState getFinalAccessState( Buffer const & buffer
, uint32_t passIndex = 0u )const;
CRG_API ImageId createImage( ImageData const & img )const;
CRG_API ImageViewId createView( ImageViewData const & view )const;
CRG_API void addInput( ImageId image
Expand Down
4 changes: 2 additions & 2 deletions include/RenderGraph/RunnablePass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ namespace crg
*\param[in] index
* The pass index.
*/
CRG_API void recordCurrent( RecordContext & context );
CRG_API uint32_t recordCurrent( RecordContext & context );
/**
*\brief
* Re-records the pass commands into its command buffer.
*/
CRG_API void reRecordCurrent();
CRG_API uint32_t reRecordCurrent();
/**
*\brief
* Submits this pass' command buffer to the given queue.
Expand Down
29 changes: 26 additions & 3 deletions include/RenderGraph/RunnablePasses/ComputePass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ namespace crg
*/
auto & passIndex( uint32_t const * config )
{
m_passIndex = config;
m_getPassIndex = [config]()
{
return *config;
};
return *this;
}
/**
Expand All @@ -87,6 +90,15 @@ namespace crg
}
/**
*\param[in] config
* The pass index callback.
*/
auto & getPassIndex( RunnablePass::GetPassIndexCallback config )
{
m_getPassIndex = config;
return *this;
}
/**
*\param[in] config
* The callback checking the enable status of the pass.
*/
auto & isEnabled( RunnablePass::IsEnabledCallback config )
Expand All @@ -105,6 +117,15 @@ namespace crg
}
/**
*\param[in] config
* The callback initialising the pass.
*/
auto & initialise( RunnablePass::InitialiseCallback config )
{
m_initialise = config;
return *this;
}
/**
*\param[in] config
* The callback ending the pass.
*/
auto & end( RunnablePass::RecordCallback config )
Expand Down Expand Up @@ -141,9 +162,10 @@ namespace crg
}

pp::ConfigT< WrapperT > m_baseConfig{};
WrapperT< uint32_t const * > m_passIndex{};
WrapperT< RunnablePass::InitialiseCallback > m_initialise{};
WrapperT< bool const * > m_enabled{};
WrapperT< RunnablePass::IsEnabledCallback > m_isEnabled{};
WrapperT< RunnablePass::GetPassIndexCallback > m_getPassIndex{};
WrapperT< RunnablePass::RecordCallback > m_recordInto{};
WrapperT< RunnablePass::RecordCallback > m_end{};
WrapperT< uint32_t > m_groupCountX{};
Expand All @@ -154,9 +176,10 @@ namespace crg
template<>
struct ConfigT< RawTypeT >
{
RawTypeT< uint32_t const * > passIndex{ nullptr };
RawTypeT< RunnablePass::InitialiseCallback > initialise{};
RawTypeT< bool const * > enabled{ nullptr };
std::optional< RunnablePass::IsEnabledCallback > isEnabled{};
RawTypeT< RunnablePass::GetPassIndexCallback > getPassIndex{};
RawTypeT< RunnablePass::RecordCallback > recordInto{};
RawTypeT< RunnablePass::RecordCallback > end{};
RawTypeT< uint32_t > groupCountX{ 1u };
Expand Down
1 change: 1 addition & 0 deletions include/RenderGraph/RunnablePasses/RenderPassHolder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,6 @@ namespace crg
PassData const * m_currentPass{};
VkPipelineColorBlendAttachmentStateArray m_blendAttachs;
uint32_t m_layers{};
uint32_t m_index{};
};
}
18 changes: 13 additions & 5 deletions source/RenderGraph/Attachment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ namespace crg
}

WriteDescriptorSet BufferAttachment::getWrite( uint32_t binding
, uint32_t count )const
, uint32_t count
, uint32_t index )const
{
WriteDescriptorSet result{ binding
, 0u
Expand All @@ -84,12 +85,12 @@ namespace crg

if ( isView() )
{
result.bufferViewInfo.push_back( VkDescriptorBufferInfo{ buffer.buffer, range.offset, range.size } );
result.bufferViewInfo.push_back( VkDescriptorBufferInfo{ buffer.buffer( index ), range.offset, range.size } );
result.texelBufferView.push_back( view );
}
else
{
result.bufferInfo.push_back( VkDescriptorBufferInfo{ buffer.buffer, range.offset, range.size } );
result.bufferInfo.push_back( VkDescriptorBufferInfo{ buffer.buffer( index ), range.offset, range.size } );
}

return result;
Expand Down Expand Up @@ -579,6 +580,13 @@ namespace crg
: uint32_t{};
}

uint32_t Attachment::getBufferCount()const
{
return isBuffer()
? buffer.getBufferCount()
: uint32_t{};
}

ImageViewId Attachment::view( uint32_t index )const
{
return isImage()
Expand All @@ -604,10 +612,10 @@ namespace crg
return buffer.getDescriptorType();
}

WriteDescriptorSet Attachment::getBufferWrite()const
WriteDescriptorSet Attachment::getBufferWrite( uint32_t index )const
{
assert( isBuffer() );
return buffer.getWrite( binding, 1u );
return buffer.getWrite( binding, 1u, index );
}

VkAccessFlags Attachment::getAccessMask()const
Expand Down
2 changes: 1 addition & 1 deletion source/RenderGraph/AttachmentTransition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace crg

bool operator==( Buffer const & lhs, Buffer const & rhs )
{
return lhs.buffer == rhs.buffer;
return lhs.m_buffers == rhs.m_buffers;
}

AttachmentTransitions mergeIdenticalTransitions( AttachmentTransitions transitions )
Expand Down
27 changes: 21 additions & 6 deletions source/RenderGraph/FrameGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,23 @@ namespace crg
return m_finalState.getLayoutState( image, viewType, range );
}

LayoutState FrameGraph::getFinalLayoutState( ImageViewId view )const
LayoutState FrameGraph::getFinalLayoutState( ImageViewId view
, uint32_t passIndex )const
{
return getFinalLayoutState( view.data->image
, view.data->info.viewType
, view.data->info.subresourceRange );
if ( view.data->source.empty() )
{
return getFinalLayoutState( view.data->image
, view.data->info.viewType
, view.data->info.subresourceRange );
}

return getFinalLayoutState( view.data->source[passIndex], 0u );
}

AccessState FrameGraph::getFinalAccessState( Buffer const & buffer )const
AccessState FrameGraph::getFinalAccessState( Buffer const & buffer
, uint32_t passIndex )const
{
return m_finalState.getAccessState( buffer.buffer, { 0u, VK_WHOLE_SIZE } );
return m_finalState.getAccessState( buffer.buffer( passIndex ), { 0u, VK_WHOLE_SIZE } );
}

void FrameGraph::addInput( ImageId image
Expand Down Expand Up @@ -677,4 +684,12 @@ namespace crg
{
return isDepthFormat( fmt ) && isStencilFormat( fmt );
}

ImageViewId const & resolveView( ImageViewId const & view
, uint32_t passIndex )
{
return view.data->source.empty()
? view
: view.data->source[passIndex];
}
}
4 changes: 2 additions & 2 deletions source/RenderGraph/FramePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ namespace crg
if constexpr ( sizeof( size_t ) == sizeof( uint64_t ) )
{
return size_t( pass.id ) << 32u
| ( ptrdiff_t( buffer.buffer ) & 0xFFFFFFFF );
| ( ptrdiff_t( buffer.buffer() ) & 0xFFFFFFFF );
}
else
{
return size_t( pass.id ) << 16u
| ( ptrdiff_t( buffer.buffer ) & 0x0000FFFF );
| ( ptrdiff_t( buffer.buffer() ) & 0x0000FFFF );
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/RenderGraph/FramePassDependenciesBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ namespace crg
static bool areOverlapping( Buffer const & lhs
, Buffer const & rhs )
{
return lhs.buffer == rhs.buffer;
return lhs.buffer() == rhs.buffer();
}

template< typename DataT >
Expand Down Expand Up @@ -626,7 +626,7 @@ namespace crg

static bool match( Buffer const & lhs, Buffer const & rhs )
{
return lhs.buffer != rhs.buffer;
return lhs.buffer() != rhs.buffer();
}

static bool match( ImageViewId const & lhs, ImageViewId const & rhs )
Expand Down
10 changes: 6 additions & 4 deletions source/RenderGraph/FramePassGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,16 @@ namespace crg
return m_graph.getHandler();
}

LayoutState FramePassGroup::getFinalLayoutState( ImageViewId view )const
LayoutState FramePassGroup::getFinalLayoutState( ImageViewId view
, uint32_t passIndex )const
{
return m_graph.getFinalLayoutState( view );
return m_graph.getFinalLayoutState( view, passIndex );
}

AccessState FramePassGroup::getFinalAccessState( Buffer const & buffer )const
AccessState FramePassGroup::getFinalAccessState( Buffer const & buffer
, uint32_t passIndex )const
{
return m_graph.getFinalAccessState( buffer );
return m_graph.getFinalAccessState( buffer, passIndex );
}

ImageId FramePassGroup::createImage( ImageData const & img )const
Expand Down
Loading