diff --git a/include/RenderGraph/Attachment.hpp b/include/RenderGraph/Attachment.hpp index a4e5225..12d0a47 100644 --- a/include/RenderGraph/Attachment.hpp +++ b/include/RenderGraph/Attachment.hpp @@ -184,6 +184,7 @@ namespace crg ClearValue clearValue{}; PipelineColorBlendAttachmentState blendState = DefaultBlendState; ImageLayout wantedLayout{}; + FlagKind flags{}; private: CRG_API ImageAttachment() = default; @@ -198,10 +199,8 @@ namespace crg , PipelineColorBlendAttachmentState blendState , ImageLayout wantedLayout ); - FlagKind flags{}; - friend bool operator==( ImageAttachment const & lhs - , ImageAttachment const & rhs ) + , ImageAttachment const & rhs )noexcept { return lhs.flags == rhs.flags && lhs.views == rhs.views @@ -304,6 +303,8 @@ namespace crg public: BufferViewIdArray buffers; + FlagKind flags{}; + AccessState wantedAccess{}; private: CRG_API BufferAttachment() = default; @@ -312,10 +313,8 @@ namespace crg , BufferViewIdArray views , AccessState access = {} ); - FlagKind flags{}; - AccessState wantedAccess{}; - - friend bool operator==( BufferAttachment const & lhs, BufferAttachment const & rhs ) + friend bool operator==( BufferAttachment const & lhs + , BufferAttachment const & rhs )noexcept { return lhs.flags == rhs.flags && lhs.buffers == rhs.buffers; @@ -327,6 +326,9 @@ namespace crg */ struct Attachment { + friend struct FramePass; + friend class FrameGraph; + class Token { friend struct Attachment; @@ -335,8 +337,41 @@ namespace crg private: Token() noexcept = default; }; - friend struct FramePass; - friend class FrameGraph; + + struct Source + { + Source( Attachment const * parent + , FramePass const * pass + , ImageAttachment const & attach ) + : parent{ parent } + , pass{ pass } + , imageAttach{ &attach } + { + } + + Source( Attachment const * parent + , FramePass const * pass + , BufferAttachment const & attach ) + : parent{ parent } + , pass{ pass } + , bufferAttach{ &attach } + { + } + + explicit Source( AttachmentPtr sourceAttach ) + : pass{ sourceAttach->pass } + , imageAttach{ sourceAttach->isImage() ? &sourceAttach->imageAttach : nullptr } + , bufferAttach{ sourceAttach->isBuffer() ? &sourceAttach->bufferAttach : nullptr } + , attach{ std::move( sourceAttach ) } + { + } + + Attachment const * parent{}; + FramePass const * pass{}; + ImageAttachment const * imageAttach{}; + BufferAttachment const * bufferAttach{}; + AttachmentPtr attach; + }; /** *\brief * The flags qualifying an Attachment. @@ -670,41 +705,8 @@ namespace crg std::string name{}; ImageAttachment imageAttach{}; BufferAttachment bufferAttach{}; - struct Source - { - Source( Attachment const * parent - , FramePass const * pass - , ImageAttachment const & attach ) - : parent{ parent } - , pass{ pass } - , imageAttach{ &attach } - { - } - - Source( Attachment const * parent - , FramePass const * pass - , BufferAttachment const & attach ) - : parent{ parent } - , pass{ pass } - , bufferAttach{ &attach } - { - } - - explicit Source( AttachmentPtr sourceAttach ) - : pass{ sourceAttach->pass } - , imageAttach{ sourceAttach->isImage() ? &sourceAttach->imageAttach : nullptr } - , bufferAttach{ sourceAttach->isBuffer() ? &sourceAttach->bufferAttach : nullptr } - , attach{ std::move( sourceAttach ) } - { - } - - Attachment const * parent{}; - FramePass const * pass{}; - ImageAttachment const * imageAttach{}; - BufferAttachment const * bufferAttach{}; - AttachmentPtr attach; - }; std::vector< Source > source{}; + FlagKind flags{}; /**@}*/ CRG_API Attachment( ImageViewId view @@ -746,11 +748,8 @@ namespace crg , Token token ); private: - void initSources(); - FlagKind flags{}; - friend bool operator==( Attachment const & lhs , Attachment const & rhs ) { diff --git a/include/RenderGraph/FrameGraphStructs.hpp b/include/RenderGraph/FrameGraphStructs.hpp index e773495..d9cf211 100644 --- a/include/RenderGraph/FrameGraphStructs.hpp +++ b/include/RenderGraph/FrameGraphStructs.hpp @@ -17,7 +17,7 @@ namespace crg int32_t y{}; private: - friend bool operator==( Offset2D const & lhs, Offset2D const & rhs ) = default; + friend bool operator==( Offset2D const & lhs, Offset2D const & rhs )noexcept = default; }; struct Extent2D @@ -26,7 +26,7 @@ namespace crg uint32_t height{}; private: - friend bool operator==( Extent2D const & lhs, Extent2D const & rhs ) = default; + friend bool operator==( Extent2D const & lhs, Extent2D const & rhs )noexcept = default; }; struct Rect2D @@ -35,7 +35,7 @@ namespace crg Extent2D extent{}; private: - friend bool operator==( Rect2D const & lhs, Rect2D const & rhs ) = default; + friend bool operator==( Rect2D const & lhs, Rect2D const & rhs )noexcept = default; }; struct Offset3D @@ -45,7 +45,7 @@ namespace crg int32_t z{}; private: - friend bool operator==( Offset3D const & lhs, Offset3D const & rhs ) = default; + friend bool operator==( Offset3D const & lhs, Offset3D const & rhs )noexcept = default; }; struct Extent3D @@ -55,7 +55,7 @@ namespace crg uint32_t depth{}; private: - friend bool operator==( Extent3D const & lhs, Extent3D const & rhs ) = default; + friend bool operator==( Extent3D const & lhs, Extent3D const & rhs )noexcept = default; }; struct Rect3D @@ -64,7 +64,7 @@ namespace crg Extent3D extent{}; private: - friend bool operator==( Rect3D const & lhs, Rect3D const & rhs ) = default; + friend bool operator==( Rect3D const & lhs, Rect3D const & rhs )noexcept = default; }; struct BufferSubresourceRange @@ -73,7 +73,14 @@ namespace crg DeviceSize size{}; private: - friend bool operator==( BufferSubresourceRange const & lhs, BufferSubresourceRange const & rhs ) = default; + friend bool operator==( BufferSubresourceRange const & lhs, BufferSubresourceRange const & rhs )noexcept = default; + + friend std::strong_ordering operator<=>( BufferSubresourceRange const & lhs, BufferSubresourceRange const & rhs )noexcept + { + if ( auto c = lhs.offset <=> rhs.offset; c != std::strong_ordering::equal ) + return c; + return lhs.size <=> rhs.size; + } }; struct ImageSubresourceRange @@ -85,7 +92,20 @@ namespace crg uint32_t layerCount{}; private: - friend bool operator==( ImageSubresourceRange const & lhs, ImageSubresourceRange const & rhs ) = default; + friend bool operator==( ImageSubresourceRange const & lhs, ImageSubresourceRange const & rhs )noexcept = default; + + friend std::strong_ordering operator<=>( ImageSubresourceRange const & lhs, ImageSubresourceRange const & rhs )noexcept + { + if ( auto c = lhs.aspectMask <=> rhs.aspectMask; c != std::strong_ordering::equal ) + return c; + if ( auto c = lhs.baseArrayLayer <=> rhs.baseArrayLayer; c != std::strong_ordering::equal ) + return c; + if ( auto c = lhs.layerCount <=> rhs.layerCount; c != std::strong_ordering::equal ) + return c; + if ( auto c = lhs.baseMipLevel <=> rhs.baseMipLevel; c != std::strong_ordering::equal ) + return c; + return lhs.levelCount <=> rhs.levelCount; + } }; struct BufferCreateInfo @@ -96,7 +116,7 @@ namespace crg MemoryPropertyFlags memory{}; private: - friend bool operator==( BufferCreateInfo const & lhs, BufferCreateInfo const & rhs ) = default; + friend bool operator==( BufferCreateInfo const & lhs, BufferCreateInfo const & rhs )noexcept = default; }; struct BufferViewCreateInfo @@ -105,7 +125,7 @@ namespace crg BufferSubresourceRange subresourceRange{}; private: - friend bool operator==( BufferViewCreateInfo const & lhs, BufferViewCreateInfo const & rhs ) = default; + friend bool operator==( BufferViewCreateInfo const & lhs, BufferViewCreateInfo const & rhs )noexcept = default; }; struct ImageCreateInfo @@ -122,7 +142,7 @@ namespace crg MemoryPropertyFlags memory{}; private: - friend bool operator==( ImageCreateInfo const & lhs, ImageCreateInfo const & rhs ) = default; + friend bool operator==( ImageCreateInfo const & lhs, ImageCreateInfo const & rhs )noexcept = default; }; struct ImageViewCreateInfo @@ -133,12 +153,12 @@ namespace crg ImageSubresourceRange subresourceRange{}; private: - friend bool operator==( ImageViewCreateInfo const & lhs, ImageViewCreateInfo const & rhs ) = default; + friend bool operator==( ImageViewCreateInfo const & lhs, ImageViewCreateInfo const & rhs )noexcept = default; }; struct ClearColorValue { - enum ValueIndex + enum class ValueIndex { eFloat32, eInt32, @@ -168,32 +188,32 @@ namespace crg constexpr bool isFloat32()const noexcept { - return m_value.index() == eFloat32; + return m_value.index() == uint32_t( ValueIndex::eFloat32 ); } constexpr bool isInt32()const noexcept { - return m_value.index() == eInt32; + return m_value.index() == uint32_t( ValueIndex::eInt32 ); } constexpr bool isUInt32()const noexcept { - return m_value.index() == eUInt32; + return m_value.index() == uint32_t( ValueIndex::eUInt32 ); } constexpr std::array< float, 4u > const & float32()const noexcept { - return std::get< eFloat32 >( m_value ); + return std::get< uint32_t( ValueIndex::eFloat32 ) >( m_value ); } constexpr std::array< int32_t, 4u > const & int32()const noexcept { - return std::get< eInt32 >( m_value ); + return std::get< uint32_t( ValueIndex::eInt32 ) >( m_value ); } constexpr std::array< uint32_t, 4u > const & uint32()const noexcept { - return std::get< eUInt32 >( m_value ); + return std::get< uint32_t( ValueIndex::eUInt32 ) >( m_value ); } private: @@ -201,7 +221,7 @@ namespace crg , std::array< int32_t, 4u > , std::array< uint32_t, 4u > > m_value; - friend bool operator==( ClearColorValue const & lhs, ClearColorValue const & rhs ) = default; + friend bool operator==( ClearColorValue const & lhs, ClearColorValue const & rhs )noexcept = default; }; struct ClearDepthStencilValue @@ -210,12 +230,12 @@ namespace crg uint32_t stencil{}; private: - friend bool operator==( ClearDepthStencilValue const & lhs, ClearDepthStencilValue const & rhs ) = default; + friend bool operator==( ClearDepthStencilValue const & lhs, ClearDepthStencilValue const & rhs )noexcept = default; }; struct ClearValue { - enum ValueIndex + enum class ValueIndex { eColor, eDepthStencil, @@ -233,28 +253,28 @@ namespace crg constexpr bool isColor()const noexcept { - return m_value.index() == eColor; + return m_value.index() == uint32_t( ValueIndex::eColor ); } constexpr bool isDepthStencil()const noexcept { - return m_value.index() == eDepthStencil; + return m_value.index() == uint32_t( ValueIndex::eDepthStencil ); } constexpr ClearColorValue const & color()const noexcept { - return std::get< eColor >( m_value ); + return std::get< uint32_t( ValueIndex::eColor ) >( m_value ); } constexpr ClearDepthStencilValue const & depthStencil()const noexcept { - return std::get< eDepthStencil >( m_value ); + return std::get< uint32_t( ValueIndex::eDepthStencil ) >( m_value ); } private: std::variant< ClearColorValue, ClearDepthStencilValue > m_value; - friend bool operator==( ClearValue const & lhs, ClearValue const & rhs ) = default; + friend bool operator==( ClearValue const & lhs, ClearValue const & rhs )noexcept = default; }; struct PipelineColorBlendAttachmentState @@ -269,7 +289,7 @@ namespace crg ColorComponentFlags colorWriteMask{ ColorComponentFlags::eR | ColorComponentFlags::eG | ColorComponentFlags::eB | ColorComponentFlags::eA }; private: - friend bool operator==( PipelineColorBlendAttachmentState const & lhs, PipelineColorBlendAttachmentState const & rhs ) = default; + friend bool operator==( PipelineColorBlendAttachmentState const & lhs, PipelineColorBlendAttachmentState const & rhs )noexcept = default; }; struct PipelineState @@ -278,7 +298,7 @@ namespace crg PipelineStageFlags pipelineStage{}; private: - friend bool operator==( PipelineState const & lhs, PipelineState const & rhs ) = default; + friend bool operator==( PipelineState const & lhs, PipelineState const & rhs )noexcept = default; }; struct LayoutState diff --git a/include/RenderGraph/FramePass.hpp b/include/RenderGraph/FramePass.hpp index dad7301..db874ec 100644 --- a/include/RenderGraph/FramePass.hpp +++ b/include/RenderGraph/FramePass.hpp @@ -19,19 +19,18 @@ namespace crg struct FramePass { - protected: - friend struct FramePassGroup; - /** - *\name - * Construction. - */ - /**@{*/ - CRG_API FramePass( FramePassGroup const & group - , FrameGraph & graph - , uint32_t id - , std::string const & name - , RunnablePassCreator runnableCreator ); - /**@}*/ + public: + struct SampledAttachment + { + SampledAttachment( Attachment const * attach, SamplerDesc sampler )noexcept + : attach{ attach } + , sampler{ std::move( sampler ) } + { + } + + Attachment const * attach; + SamplerDesc sampler; + }; public: /** @@ -69,6 +68,16 @@ namespace crg *\brief * Creates a uniform buffer single-pass attachment. */ + template< typename EnumT > + void addInputUniformBufferT( BufferViewIdArray buffers + , EnumT binding ) + { + addInputUniformBuffer( std::move( buffers ), uint32_t( binding ) ); + } + /** + *\brief + * Creates a uniform buffer single-pass attachment. + */ void addInputUniformBuffer( BufferViewId buffer , uint32_t binding ) { @@ -76,6 +85,16 @@ namespace crg } /** *\brief + * Creates a uniform buffer single-pass attachment. + */ + template< typename EnumT > + void addInputUniformBufferT( BufferViewId buffer + , EnumT binding ) + { + addInputUniformBufferT( BufferViewIdArray{ buffer }, binding ); + } + /** + *\brief * Creates a sampled image multi-pass attachment. */ CRG_API void addInputSampledImage( ImageViewIdArray views @@ -85,6 +104,17 @@ namespace crg *\brief * Creates a sampled image single-pass attachment. */ + template< typename EnumT > + void addInputSampledImageT( ImageViewIdArray views + , EnumT binding + , SamplerDesc samplerDesc = SamplerDesc{} ) + { + addInputSampledImage( std::move( views ), uint32_t( binding ), std::move( samplerDesc ) ); + } + /** + *\brief + * Creates a sampled image single-pass attachment. + */ void addInputSampledImage( ImageViewId view , uint32_t binding , SamplerDesc samplerDesc = SamplerDesc{} ) @@ -93,17 +123,49 @@ namespace crg } /** *\brief + * Creates a sampled image single-pass attachment. + */ + template< typename EnumT > + void addInputSampledImageT( ImageViewId view + , EnumT binding + , SamplerDesc samplerDesc = SamplerDesc{} ) + { + addInputSampledImageT( ImageViewIdArray{ view }, binding, std::move( samplerDesc ) ); + } + /** + *\brief * Creates an input uniform attachment. */ CRG_API void addInputUniform( Attachment const & attach , uint32_t binding ); /** *\brief + * Creates an input uniform attachment. + */ + template< typename EnumT > + void addInputUniformT( Attachment const & attach + , EnumT binding ) + { + addInputUniform( attach, uint32_t( binding ) ); + } + /** + *\brief * Creates a sampled image attachment. */ CRG_API void addInputSampled( Attachment const & attach , uint32_t binding , SamplerDesc samplerDesc = SamplerDesc{} ); + /** + *\brief + * Creates a sampled image attachment. + */ + template< typename EnumT > + void addInputSampledT( Attachment const & attach + , EnumT binding + , SamplerDesc samplerDesc = SamplerDesc{} ) + { + addInputSampled( attach, uint32_t( binding ), std::move( samplerDesc ) ); + } /**@}*/ # pragma endregion # pragma region Storage @@ -120,6 +182,16 @@ namespace crg , uint32_t binding ); /** *\brief + * Creates a storage buffer multi-pass attachment. + */ + template< typename EnumT > + void addInputStorageBufferT( BufferViewIdArray buffers + , EnumT binding ) + { + addInputStorageBuffer( std::move( buffers ), uint32_t( binding ) ); + } + /** + *\brief * Creates a storage buffer single-pass attachment. */ void addInputStorageBuffer( BufferViewId buffer @@ -129,6 +201,16 @@ namespace crg } /** *\brief + * Creates a storage buffer single-pass attachment. + */ + template< typename EnumT > + void addInputStorageBufferT( BufferViewId buffer + , EnumT binding ) + { + addInputStorageBufferT( BufferViewIdArray{ buffer }, binding ); + } + /** + *\brief * Creates an input storage attachment. */ CRG_API void addInputStorageImage( ImageViewIdArray views @@ -137,6 +219,16 @@ namespace crg *\brief * Creates an input storage attachment. */ + template< typename EnumT > + void addInputStorageImageT( ImageViewIdArray views + , EnumT binding ) + { + addInputStorageImage( std::move( views ), uint32_t( binding ) ); + } + /** + *\brief + * Creates an input storage attachment. + */ void addInputStorageImage( ImageViewId view , uint32_t binding ) { @@ -146,22 +238,62 @@ namespace crg *\brief * Creates an input storage attachment. */ + template< typename EnumT > + void addInputStorageImageT( ImageViewId view + , EnumT binding ) + { + addInputStorageImageT( ImageViewIdArray{ view }, binding ); + } + /** + *\brief + * Creates an input storage attachment. + */ CRG_API void addInputStorage( Attachment const & attach , uint32_t binding ); /** *\brief + * Creates an input storage attachment. + */ + template< typename EnumT > + void addInputStorageT( Attachment const & attach + , EnumT binding ) + { + addInputStorage( attach, uint32_t( binding ) ); + } + /** + *\brief * Creates an input/output storage attachment. */ CRG_API Attachment const * addInOutStorage( Attachment const & attach , uint32_t binding ); /** *\brief + * Creates an input/output storage attachment. + */ + template< typename EnumT > + Attachment const * addInOutStorageT( Attachment const & attach + , EnumT binding ) + { + return addInOutStorage( attach, uint32_t( binding ) ); + } + /** + *\brief * Creates an output storage buffer multi-pass attachment. */ CRG_API Attachment const * addOutputStorageBuffer( BufferViewIdArray buffers , uint32_t binding ); /** *\brief + * Creates an output storage buffer multi-pass attachment. + */ + template< typename EnumT > + Attachment const * addOutputStorageBufferT( BufferViewIdArray buffers + , EnumT binding ) + { + return addOutputStorageBuffer( std::move( buffers ), uint32_t( binding ) ); + } + /** + *\brief * Creates an output storage buffer single-pass attachment. */ Attachment const * addOutputStorageBuffer( BufferViewId buffer @@ -171,12 +303,32 @@ namespace crg } /** *\brief + * Creates an output storage buffer single-pass attachment. + */ + template< typename EnumT > + Attachment const * addOutputStorageBufferT( BufferViewId buffer + , EnumT binding ) + { + return addOutputStorageBufferT( BufferViewIdArray{ buffer }, binding ); + } + /** + *\brief * Creates a storage buffer multi-pass attachment that will be cleared a the beginning of the pass. */ CRG_API Attachment const * addClearableOutputStorageBuffer( BufferViewIdArray buffers , uint32_t binding ); /** *\brief + * Creates a storage buffer multi-pass attachment that will be cleared a the beginning of the pass. + */ + template< typename EnumT > + Attachment const * addClearableOutputStorageBufferT( BufferViewIdArray buffers + , EnumT binding ) + { + return addClearableOutputStorageBuffer( std::move( buffers ), uint32_t( binding ) ); + } + /** + *\brief * Creates a storage buffer single-pass attachment that will be cleared a the beginning of the pass. */ Attachment const * addClearableOutputStorageBuffer( BufferViewId buffer @@ -186,29 +338,71 @@ namespace crg } /** *\brief + * Creates a storage buffer single-pass attachment that will be cleared a the beginning of the pass. + */ + template< typename EnumT > + Attachment const * addClearableOutputStorageBufferT( BufferViewId buffer + , EnumT binding ) + { + return addClearableOutputStorageBufferT( BufferViewIdArray{ buffer }, binding ); + } + /** + *\brief * Creates a storage image multi-pass attachment. */ CRG_API Attachment const * addOutputStorageImage( ImageViewIdArray view , uint32_t binding ); /** *\brief + * Creates a storage image multi-pass attachment. + */ + template< typename EnumT > + Attachment const * addOutputStorageImageT( ImageViewIdArray views + , EnumT binding ) + { + return addOutputStorageImage( std::move( views ), uint32_t( binding ) ); + } + /** + *\brief * Creates a storage image single-pass attachment. */ Attachment const * addOutputStorageImage( ImageViewId view , uint32_t binding ) { - return addOutputStorageImage( ImageViewIdArray{ view } - , binding ); + return addOutputStorageImage( ImageViewIdArray{ view }, binding ); + } + /** + *\brief + * Creates a storage image single-pass attachment. + */ + template< typename EnumT > + Attachment const * addOutputStorageImageT( ImageViewId view + , EnumT binding ) + { + return addOutputStorageImageT( ImageViewIdArray{ view }, binding ); } /** *\brief * Creates a storage image multi-pass attachment. */ - CRG_API Attachment const * addClearableOutputStorageImage( ImageViewIdArray view + CRG_API Attachment const * addClearableOutputStorageImage( ImageViewIdArray views , uint32_t binding , ClearValue clearValue = ClearValue{} ); /** *\brief + * Creates a storage image multi-pass attachment. + */ + template< typename EnumT > + Attachment const * addClearableOutputStorageImageT( ImageViewIdArray views + , EnumT binding + , ClearValue clearValue = ClearValue{} ) + { + return addClearableOutputStorageImage( std::move( views ) + , uint32_t( binding ) + , std::move( clearValue ) ); + } + /** + *\brief * Creates a storage image single-pass attachment. */ Attachment const * addClearableOutputStorageImage( ImageViewId view @@ -219,6 +413,19 @@ namespace crg , binding , std::move( clearValue ) ); } + /** + *\brief + * Creates a storage image single-pass attachment. + */ + template< typename EnumT > + Attachment const * addClearableOutputStorageImageT( ImageViewId view + , EnumT binding + , ClearValue clearValue = ClearValue{} ) + { + return addClearableOutputStorageImageT( ImageViewIdArray{ view } + , binding + , std::move( clearValue ) ); + } /**@}*/ # pragma endregion # pragma region Transfer @@ -511,27 +718,64 @@ namespace crg return m_ownAttaches.cend(); } - FramePassGroup const & group; - FrameGraph & graph; - uint32_t id; - struct SampledAttachment + FramePassGroup const & getGroup()const noexcept { - SampledAttachment( Attachment const * attach, SamplerDesc sampler )noexcept - : attach{ attach } - , sampler{ std::move( sampler ) } - { - } + return m_group; + } - Attachment const * attach; - SamplerDesc sampler; - }; - std::map< uint32_t, Attachment const * > uniforms; - std::map< uint32_t, SampledAttachment > sampled; - std::map< uint32_t, Attachment const * > inputs; - std::map< uint32_t, Attachment const * > inouts; - std::map< uint32_t, Attachment const * > outputs; - std::vector< Attachment const * > targets; - RunnablePassCreator runnableCreator; + FrameGraph const & getGraph()const noexcept + { + return m_graph; + } + + uint32_t getId()const noexcept + { + return m_id; + } + + std::map< uint32_t, Attachment const * > const & getUniforms()const noexcept + { + return m_uniforms; + } + + std::map< uint32_t, SampledAttachment > const & getSampled()const noexcept + { + return m_sampled; + } + + std::map< uint32_t, Attachment const * > const & getInputs()const noexcept + { + return m_inputs; + } + + std::map< uint32_t, Attachment const * > const & getInouts()const noexcept + { + return m_inouts; + } + + std::map< uint32_t, Attachment const * > const & getOutputs()const noexcept + { + return m_outputs; + } + + std::vector< Attachment const * > const & getTargets()const noexcept + { + return m_targets; + } + + protected: + friend struct FramePassGroup; + /** + *\name + * Construction. + */ + /**@{*/ + CRG_API FramePass( FramePassGroup const & group + , FrameGraph & graph + , uint32_t id + , std::string const & name + , RunnablePassCreator runnableCreator ); + /**@}*/ private: CRG_API Attachment const * addColourTarget( std::string const & name @@ -590,6 +834,16 @@ namespace crg , Attachment const * parent ); private: + FramePassGroup const & m_group; + FrameGraph & m_graph; + uint32_t m_id; + std::map< uint32_t, Attachment const * > m_uniforms; + std::map< uint32_t, SampledAttachment > m_sampled; + std::map< uint32_t, Attachment const * > m_inputs; + std::map< uint32_t, Attachment const * > m_inouts; + std::map< uint32_t, Attachment const * > m_outputs; + std::vector< Attachment const * > m_targets; + RunnablePassCreator m_runnableCreator; std::string m_name; struct OwnAttachment { diff --git a/include/RenderGraph/FramePassGroup.hpp b/include/RenderGraph/FramePassGroup.hpp index a6de1b8..f758d23 100644 --- a/include/RenderGraph/FramePassGroup.hpp +++ b/include/RenderGraph/FramePassGroup.hpp @@ -126,18 +126,36 @@ namespace crg CRG_API std::string getFullName()const; - std::string const & getName()const + std::string const & getName()const noexcept { return m_name; } - public: - uint32_t id; - FramePassPtrArray passes; - FramePassGroupPtrArray groups; - FramePassGroup * parent{}; + FramePassGroupPtrArray const & getGroups()const noexcept + { + return m_groups; + } + + FramePassPtrArray const & getPasses()const noexcept + { + return m_passes; + } + + FramePassGroup const * getParent()const noexcept + { + return m_parent; + } + + uint32_t getId()const noexcept + { + return m_id; + } private: + uint32_t m_id; + FramePassPtrArray m_passes; + FramePassGroupPtrArray m_groups; + FramePassGroup * m_parent{}; std::string m_name; FrameGraph & m_graph; std::unordered_set< uint32_t > m_inputs; diff --git a/include/RenderGraph/GraphNode.hpp b/include/RenderGraph/GraphNode.hpp index 3d1b6cb..73b823f 100644 --- a/include/RenderGraph/GraphNode.hpp +++ b/include/RenderGraph/GraphNode.hpp @@ -28,9 +28,8 @@ namespace crg GraphNode( GraphNode const & ) = delete; GraphNode & operator=( GraphNode const & ) = delete; - GraphNode & operator=( GraphNode && rhs )noexcept = delete; + CRG_API GraphNode & operator=( GraphNode && rhs )noexcept = default; CRG_API virtual ~GraphNode()noexcept = default; - CRG_API GraphNode( GraphNode && rhs )noexcept; CRG_API void attachNode( GraphNode & child ); @@ -68,7 +67,7 @@ namespace crg FramePassGroup const & getGroup()const noexcept { - return group; + return *group; } uint32_t getId()const noexcept @@ -106,7 +105,7 @@ namespace crg Kind kind{}; uint32_t id{}; std::string name{}; - FramePassGroup const & group; + FramePassGroup const * group; GraphAdjacentNodeArray prev{}; AttachmentTransitions m_transitions{}; }; diff --git a/include/RenderGraph/RecordContext.hpp b/include/RenderGraph/RecordContext.hpp index e2eb94f..26fff42 100644 --- a/include/RenderGraph/RecordContext.hpp +++ b/include/RenderGraph/RecordContext.hpp @@ -72,10 +72,10 @@ namespace crg CRG_API void registerImplicitTransition( RunnablePass const & pass , crg::ImageViewId view - , ImplicitAction action = []( RecordContext &, VkCommandBuffer, uint32_t ){} ); + , ImplicitAction action = []( RecordContext const &, VkCommandBuffer, uint32_t ){} ); CRG_API void registerImplicitTransition( RunnablePass const & pass , crg::BufferViewId view - , ImplicitAction action = []( RecordContext &, VkCommandBuffer, uint32_t ){} ); + , ImplicitAction action = []( RecordContext const &, VkCommandBuffer, uint32_t ){} ); CRG_API void registerImplicitTransition( ImplicitImageTransition transition ); CRG_API void registerImplicitTransition( ImplicitBufferTransition transition ); CRG_API void runImplicitTransition( VkCommandBuffer commandBuffer diff --git a/include/RenderGraph/ResourceHandler.hpp b/include/RenderGraph/ResourceHandler.hpp index cb222db..3b5396e 100644 --- a/include/RenderGraph/ResourceHandler.hpp +++ b/include/RenderGraph/ResourceHandler.hpp @@ -131,7 +131,7 @@ namespace crg return &m_context; } - operator GraphContext & ()const noexcept + GraphContext & getContext()const noexcept { return m_context; } diff --git a/include/RenderGraph/RunnableGraph.hpp b/include/RenderGraph/RunnableGraph.hpp index 0b4afd5..2b4997e 100644 --- a/include/RenderGraph/RunnableGraph.hpp +++ b/include/RenderGraph/RunnableGraph.hpp @@ -87,7 +87,19 @@ namespace crg CRG_API WriteDescriptorSet getDescriptorWrite( Attachment const & attach, uint32_t binding, uint32_t index = 0u ); CRG_API WriteDescriptorSet getDescriptorWrite( Attachment const & attach, SamplerDesc const & samplerDesc, uint32_t binding, uint32_t index = 0u ); - ConstGraphAdjacentNode getGraph()const noexcept + template< typename EnumT > + WriteDescriptorSet getDescriptorWriteT( Attachment const & attach, EnumT binding, uint32_t index = 0u ) + { + return getDescriptorWrite( attach, uint32_t( binding ), index ); + } + + template< typename EnumT > + WriteDescriptorSet getDescriptorWriteT( Attachment const & attach, SamplerDesc const & samplerDesc, EnumT binding, uint32_t index = 0u ) + { + return getDescriptorWrite( attach, samplerDesc, uint32_t( binding ), index ); + } + + ConstGraphAdjacentNode getNodeGraph()const noexcept { return &m_rootNode; } diff --git a/include/RenderGraph/RunnablePass.hpp b/include/RenderGraph/RunnablePass.hpp index 71e85a6..0f7ea48 100644 --- a/include/RenderGraph/RunnablePass.hpp +++ b/include/RenderGraph/RunnablePass.hpp @@ -23,6 +23,10 @@ namespace crg { using CallbackT = std::function< ValueT() >; + GetValueCallbackT( GetValueCallbackT && )noexcept = default; + GetValueCallbackT & operator=( GetValueCallbackT && )noexcept = default; + GetValueCallbackT( GetValueCallbackT const & ) = default; + GetValueCallbackT & operator=( GetValueCallbackT const & ) = default; explicit GetValueCallbackT( CallbackT callback = {} ) : m_callback{ std::move( callback ) } { @@ -59,7 +63,7 @@ namespace crg CRG_API void reset(); CRG_API VkResult wait( uint64_t timeout ); - operator VkFence()const + VkFence getInternal()const noexcept { return m_fence; } @@ -271,6 +275,11 @@ namespace crg return m_pass; } + RunnableGraph & getGraph()const + { + return m_graph; + } + FramePassTimer const & getTimer()const { return m_timer; @@ -353,7 +362,7 @@ namespace crg bool initialised{}; }; - protected: + private: FramePass const & m_pass; GraphContext & m_context; RunnableGraph & m_graph; diff --git a/include/RenderGraph/RunnablePasses/ComputePass.hpp b/include/RenderGraph/RunnablePasses/ComputePass.hpp index 2fcbb68..0cced02 100644 --- a/include/RenderGraph/RunnablePasses/ComputePass.hpp +++ b/include/RenderGraph/RunnablePasses/ComputePass.hpp @@ -23,54 +23,72 @@ namespace crg *\param[in] config * The pipeline program. */ - auto & program( VkPipelineShaderStageCreateInfoArray config ) + auto & program( VkPipelineShaderStageCreateInfoArray const & config ) { - m_baseConfig.program( std::move( config ) ); + m_baseConfig.program( config ); return *this; } /** *\param[in] config * The pipeline programs. */ - auto & programs( std::vector< VkPipelineShaderStageCreateInfoArray > config ) + auto & programs( std::vector< VkPipelineShaderStageCreateInfoArray > const & config ) { - m_baseConfig.programs( std::move( config ) ); + m_baseConfig.programs( config ); return *this; } /** *\param[in] config * The pipeline program creator. */ - auto & programCreator( ProgramCreator config ) + auto & programCreator( ProgramCreator const & config ) { - m_baseConfig.programCreator( std::move( config ) ); + m_baseConfig.programCreator( config ); return *this; } /** *\param[in] config * The descriptor set layout. */ - auto & layout( VkDescriptorSetLayout config ) + auto & layout( VkDescriptorSetLayout const & config ) { - m_baseConfig.layout( std::move( config ) ); + m_baseConfig.layout( config ); return *this; } /** *\param[in] config * The descriptor set layouts. */ - auto & layouts( std::vector< VkDescriptorSetLayout > config ) + auto & layouts( std::vector< VkDescriptorSetLayout > const & config ) { - m_baseConfig.layouts( std::move( config ) ); + m_baseConfig.layouts( config ); + return *this; + } + /** + *\param[in] config + * The push constants range. + */ + auto & pushConstants( VkPushConstantRange const & config ) + { + m_baseConfig.pushConstants( config ); + return *this; + } + /** + *\param[in] config + * The push constants range. + */ + auto & pushConstants( VkPushConstantRangeArray const & config ) + { + m_baseConfig.pushConstants( config ); return *this; } /** *\param[in] config * Tells if disabled pass should record render pass begin/end. */ - auto & baseConfig( pp::Config config ) + auto & baseConfig( pp::Config const & config ) { - m_baseConfig = std::move( config ); + m_baseConfig = config; return *this; } /** @@ -98,45 +116,45 @@ namespace crg *\param[in] config * The pass index callback. */ - auto & getPassIndex( RunnablePass::GetPassIndexCallback config ) + auto & getPassIndex( RunnablePass::GetPassIndexCallback const & config ) { - m_getPassIndex = std::move( config ); + m_getPassIndex = config; return *this; } /** *\param[in] config * The callback checking the enable status of the pass. */ - auto & isEnabled( RunnablePass::IsEnabledCallback config ) + auto & isEnabled( RunnablePass::IsEnabledCallback const & config ) { - m_isEnabled = std::move( config ); + m_isEnabled = config; return *this; } /** *\param[in] config * The callback recording the pass. */ - auto & recordInto( RunnablePass::RecordCallback config ) + auto & recordInto( RunnablePass::RecordCallback const & config ) { - m_recordInto = std::move( config ); + m_recordInto = config; return *this; } /** *\param[in] config * The callback initialising the pass. */ - auto & initialise( RunnablePass::InitialiseCallback config ) + auto & initialise( RunnablePass::InitialiseCallback const & config ) { - m_initialise = std::move( config ); + m_initialise = config; return *this; } /** *\param[in] config * The callback ending the pass. */ - auto & end( RunnablePass::RecordCallback config ) + auto & end( RunnablePass::RecordCallback const & config ) { - m_end = std::move( config ); + m_end = config; return *this; } /** @@ -170,54 +188,36 @@ namespace crg *\param[in] config * The callback to retrieve the X dispatch groups count. */ - auto & getGroupCountX( GetGroupCountCallback config ) + auto & getGroupCountX( GetGroupCountCallback const & config ) { - m_getGroupCountX = std::move( config ); + m_getGroupCountX = config; return *this; } /** *\param[in] config * The callback to retrieve the Y dispatch groups count. */ - auto & getGroupCountY( GetGroupCountCallback config ) + auto & getGroupCountY( GetGroupCountCallback const & config ) { - m_getGroupCountY = std::move( config ); + m_getGroupCountY = config; return *this; } /** *\param[in] config * The callback to retrieve the Z dispatch groups count. */ - auto & getGroupCountZ( GetGroupCountCallback config ) + auto & getGroupCountZ( GetGroupCountCallback const & config ) { - m_getGroupCountZ = std::move( config ); + m_getGroupCountZ = config; return *this; } /** *\param[in] config * The buffer used during indirect compute. */ - auto & indirectBuffer( IndirectBuffer config ) - { - m_indirectBuffer = std::move( config ); - return *this; - } - /** - *\param[in] config - * The push constants range. - */ - auto & pushConstants( VkPushConstantRange config ) - { - m_baseConfig.pushConstants( std::move( config ) ); - return *this; - } - /** - *\param[in] config - * The push constants range. - */ - auto & pushConstants( VkPushConstantRangeArray config ) + auto & indirectBuffer( IndirectBuffer const & config ) { - m_baseConfig.m_pushConstants( std::move( config ) ); + m_indirectBuffer = config; return *this; } diff --git a/include/RenderGraph/RunnablePasses/GenerateMipmaps.hpp b/include/RenderGraph/RunnablePasses/GenerateMipmaps.hpp index 3ad0a6a..6020cd3 100644 --- a/include/RenderGraph/RunnablePasses/GenerateMipmaps.hpp +++ b/include/RenderGraph/RunnablePasses/GenerateMipmaps.hpp @@ -22,10 +22,10 @@ namespace crg private: void doRecordInto( RecordContext & context , VkCommandBuffer commandBuffer - , uint32_t index ); + , uint32_t index )const; void doProcessImageView( RecordContext & context , VkCommandBuffer commandBuffer - , ImageViewId viewId ); + , ImageViewId viewId )const; private: LayoutState m_outputLayout; diff --git a/include/RenderGraph/RunnablePasses/ImageBlit.hpp b/include/RenderGraph/RunnablePasses/ImageBlit.hpp index e8195d8..bd01067 100644 --- a/include/RenderGraph/RunnablePasses/ImageBlit.hpp +++ b/include/RenderGraph/RunnablePasses/ImageBlit.hpp @@ -24,7 +24,7 @@ namespace crg private: void doRecordInto( RecordContext const & context , VkCommandBuffer commandBuffer - , uint32_t index ); + , uint32_t index )const; private: VkOffset3D m_srcOffset; diff --git a/include/RenderGraph/RunnablePasses/ImageCopy.hpp b/include/RenderGraph/RunnablePasses/ImageCopy.hpp index 9dcc68f..b9dd859 100644 --- a/include/RenderGraph/RunnablePasses/ImageCopy.hpp +++ b/include/RenderGraph/RunnablePasses/ImageCopy.hpp @@ -30,16 +30,16 @@ namespace crg private: void doRecordInto( RecordContext & context , VkCommandBuffer commandBuffer - , uint32_t index ); + , uint32_t index )const; void doRecordMultiToMulti( RecordContext & context , VkCommandBuffer commandBuffer - , uint32_t index ); + , uint32_t index )const; void doRecordMultiToSingle( RecordContext & context , VkCommandBuffer commandBuffer - , uint32_t index ); + , uint32_t index )const; void doRecordSingleToMulti( RecordContext & context , VkCommandBuffer commandBuffer - , uint32_t index ); + , uint32_t index )const; private: VkExtent3D m_copySize; diff --git a/include/RenderGraph/RunnablePasses/ImageToBufferCopy.hpp b/include/RenderGraph/RunnablePasses/ImageToBufferCopy.hpp index f6ce5b7..0b2479a 100644 --- a/include/RenderGraph/RunnablePasses/ImageToBufferCopy.hpp +++ b/include/RenderGraph/RunnablePasses/ImageToBufferCopy.hpp @@ -23,7 +23,7 @@ namespace crg private: void doRecordInto( RecordContext const & context , VkCommandBuffer commandBuffer - , uint32_t index ); + , uint32_t index )const; private: VkOffset3D m_copyOffset; diff --git a/include/RenderGraph/RunnablePasses/PipelineConfig.hpp b/include/RenderGraph/RunnablePasses/PipelineConfig.hpp index 2b2110a..67e4c13 100644 --- a/include/RenderGraph/RunnablePasses/PipelineConfig.hpp +++ b/include/RenderGraph/RunnablePasses/PipelineConfig.hpp @@ -131,6 +131,10 @@ namespace crg template< template< typename ValueT > typename WrapperT > struct ConfigT { + ConfigT( ConfigT && )noexcept = default; + ConfigT & operator=( ConfigT && )noexcept = default; + ConfigT( ConfigT const & ) = default; + ConfigT & operator=( ConfigT const & ) = default; explicit ConfigT( WrapperT< std::vector< VkPipelineShaderStageCreateInfoArray > > programs = {} , WrapperT< ProgramCreator > programCreator = {} , WrapperT< std::vector< VkDescriptorSetLayout > > layouts = {} @@ -145,63 +149,63 @@ namespace crg *\param[in] config * The pipeline program. */ - auto & program( VkPipelineShaderStageCreateInfoArray config ) + auto & program( VkPipelineShaderStageCreateInfoArray const & config ) { - m_programs = { std::move( config ) }; + m_programs = { config }; return *this; } /** *\param[in] config * The pipeline programs. */ - auto & programs( std::vector< VkPipelineShaderStageCreateInfoArray > config ) + auto & programs( std::vector< VkPipelineShaderStageCreateInfoArray > const & config ) { - m_programs = std::move( config ); + m_programs = config; return *this; } /** *\param[in] config * The pipeline program creator. */ - auto & programCreator( ProgramCreator config ) + auto & programCreator( ProgramCreator const & config ) { - m_programCreator = std::move( config ); + m_programCreator = config; return *this; } /** *\param[in] config * The descriptor set layout. */ - auto & layout( VkDescriptorSetLayout config ) + auto & layout( VkDescriptorSetLayout const & config ) { - m_layouts = { std::move( config ) }; + m_layouts = { config }; return *this; } /** *\param[in] config * The descriptor set layouts. */ - auto & layouts( std::vector< VkDescriptorSetLayout > config ) + auto & layouts( std::vector< VkDescriptorSetLayout > const & config ) { - m_layouts = std::move( config ); + m_layouts = config; return *this; } /** *\param[in] config * The push constants range. */ - auto & pushConstants( VkPushConstantRange config ) + auto & pushConstants( VkPushConstantRange const & config ) { - pushConstants( VkPushConstantRangeArray{ std::move( config ) } ); + pushConstants( VkPushConstantRangeArray{ config } ); return *this; } /** *\param[in] config * The push constants range. */ - auto & pushConstants( VkPushConstantRangeArray config ) + auto & pushConstants( VkPushConstantRangeArray const & config ) { - m_pushConstants = std::move( config ); + m_pushConstants = config; return *this; } diff --git a/include/RenderGraph/RunnablePasses/PipelineHolder.hpp b/include/RenderGraph/RunnablePasses/PipelineHolder.hpp index 4863385..ea628b8 100644 --- a/include/RenderGraph/RunnablePasses/PipelineHolder.hpp +++ b/include/RenderGraph/RunnablePasses/PipelineHolder.hpp @@ -71,25 +71,23 @@ namespace crg void doCreateDescriptorPool(); protected: + struct DescriptorSet + { + WriteDescriptorSetArray writes{}; + VkDescriptorSet set{}; + }; + + private: FramePass const & m_pass; GraphContext & m_context; RunnableGraph & m_graph; - - protected: pp::ConfigData m_baseConfig; VkPipelineBindPoint m_bindingPoint; VkDescriptorSetLayoutBindingArray m_descriptorBindings; VkDescriptorSetLayout m_descriptorSetLayout{}; VkPipelineLayout m_pipelineLayout{}; VkDescriptorPool m_descriptorSetPool{}; - struct DescriptorSet - { - WriteDescriptorSetArray writes{}; - VkDescriptorSet set{}; - }; std::vector< DescriptorSet > m_descriptorSets; - - private: std::vector< VkPipeline > m_pipelines{}; }; @@ -101,40 +99,40 @@ namespace crg *\param[in] config * The pipeline program. */ - BuilderT & program( VkPipelineShaderStageCreateInfoArray config ) + BuilderT & program( VkPipelineShaderStageCreateInfoArray const & config ) { - m_baseConfig.programs( { std::move( config ) } ); + m_baseConfig.programs( { config } ); return static_cast< BuilderT & >( *this ); } /** *\param[in] config * The pipeline programs. */ - BuilderT & programs( std::vector< VkPipelineShaderStageCreateInfoArray > config ) + BuilderT & programs( std::vector< VkPipelineShaderStageCreateInfoArray > const & config ) { - m_baseConfig.programs( std::move( config ) ); + m_baseConfig.programs( config ); return static_cast< BuilderT & >( *this ); } /** *\param[in] config * The pipeline program creator. */ - BuilderT & programCreator( ProgramCreator config ) + BuilderT & programCreator( ProgramCreator const & config ) { - m_baseConfig.programCreator( std::move( config ) ); + m_baseConfig.programCreator( config ); return static_cast< BuilderT & >( *this ); } /** *\param[in] config * The push constants range for the pipeline. */ - auto & pushConstants( VkPushConstantRange config ) + auto & pushConstants( VkPushConstantRange const & config ) { - m_baseConfig.pushConstants( std::move( config ) ); + m_baseConfig.pushConstants( config ); return static_cast< BuilderT & >( *this ); } - protected: + private: pp::Config m_baseConfig; }; diff --git a/include/RenderGraph/RunnablePasses/RenderMeshConfig.hpp b/include/RenderGraph/RunnablePasses/RenderMeshConfig.hpp index 33f2fd6..d163542 100644 --- a/include/RenderGraph/RunnablePasses/RenderMeshConfig.hpp +++ b/include/RenderGraph/RunnablePasses/RenderMeshConfig.hpp @@ -36,180 +36,180 @@ namespace crg *\param[in] config * The pipeline program. */ - auto & program( VkPipelineShaderStageCreateInfoArray config ) + auto & program( VkPipelineShaderStageCreateInfoArray const & config ) { - m_baseConfig.program( std::move( config ) ); + m_baseConfig.program( config ); return *this; } /** *\param[in] config * The pipeline programs. */ - auto & programs( std::vector< VkPipelineShaderStageCreateInfoArray > config ) + auto & programs( std::vector< VkPipelineShaderStageCreateInfoArray > const & config ) { - m_baseConfig.programs( std::move( config ) ); + m_baseConfig.programs( config ); return *this; } /** *\param[in] config * The pipeline program creator. */ - auto & programCreator( ProgramCreator config ) + auto & programCreator( ProgramCreator const & config ) { - m_baseConfig.programCreator( std::move( config ) ); + m_baseConfig.programCreator( config ); return *this; } /** *\param[in] config * The descriptor set layout. */ - auto & layout( VkDescriptorSetLayout config ) + auto & layout( VkDescriptorSetLayout const & config ) { - m_baseConfig.layout( std::move( config ) ); + m_baseConfig.layout( config ); return *this; } /** *\param[in] config * The descriptor set layouts. */ - auto & layouts( std::vector< VkDescriptorSetLayout > config ) + auto & layouts( std::vector< VkDescriptorSetLayout > const & config ) { - m_baseConfig.layouts( std::move( config ) ); + m_baseConfig.layouts( config ); return *this; } /** *\param[in] config * Tells if disabled pass should record render pass begin/end. */ - auto & baseConfig( pp::Config config ) + auto & baseConfig( pp::Config const & config ) { - m_baseConfig = std::move( config ); + m_baseConfig = config; return *this; } /** *\param[in] config * The render area size. */ - auto & renderSize( Extent2D config ) + auto & renderSize( Extent2D const & config ) { - m_renderSize = std::move( config ); + m_renderSize = config; return *this; } /** *\param[in] config * The render position. */ - auto & renderPosition( Offset2D config ) + auto & renderPosition( Offset2D const & config ) { - m_renderPosition = std::move( config ); + m_renderPosition = config; return *this; } /** *\param[in] config * The depth stencil state. */ - auto & depthStencilState( VkPipelineDepthStencilStateCreateInfo config ) + auto & depthStencilState( VkPipelineDepthStencilStateCreateInfo const & config ) { - m_depthStencilState = std::move( config ); + m_depthStencilState = config; return *this; } /** *\param[in] config * The pass index callback. */ - auto & getPassIndex( RunnablePass::GetPassIndexCallback config ) + auto & getPassIndex( RunnablePass::GetPassIndexCallback const & config ) { - m_getPassIndex = std::move( config ); + m_getPassIndex = config; return *this; } /** *\param[in] config * The callback checking the enable status of the pass. */ - auto & isEnabled( RunnablePass::IsEnabledCallback config ) + auto & isEnabled( RunnablePass::IsEnabledCallback const & config ) { - m_isEnabled = std::move( config ); + m_isEnabled = config; return *this; } /** *\param[in] config * The callback recording the pass. */ - auto & recordInto( RunnablePass::RecordCallback config ) + auto & recordInto( RunnablePass::RecordCallback const & config ) { - m_recordInto = std::move( config ); + m_recordInto = config; return *this; } /** *\param[in] config * The callback ending the pass. */ - auto & end( RunnablePass::RecordCallback config ) + auto & end( RunnablePass::RecordCallback const & config ) { - m_end = std::move( config ); + m_end = config; return *this; } /** *\param[in] config * The vertex buffer. */ - auto & vertexBuffer( VertexBuffer config ) + auto & vertexBuffer( VertexBuffer const & config ) { - m_vertexBuffer = std::move( config ); + m_vertexBuffer = config; return *this; } /** *\param[in] config * The index buffer. */ - auto & indexBuffer( IndexBuffer config ) + auto & indexBuffer( IndexBuffer const & config ) { - m_indexBuffer = std::move( config ); + m_indexBuffer = config; return *this; } /** *\param[in] config * The indirect buffer. */ - auto & indirectBuffer( IndirectBuffer config ) + auto & indirectBuffer( IndirectBuffer const & config ) { - m_indirectBuffer = std::move( config ); + m_indirectBuffer = config; return *this; } /** *\param[in] config * The primitive count retrieval callback. */ - auto & getPrimitiveCount( GetPrimitiveCountCallback config ) + auto & getPrimitiveCount( GetPrimitiveCountCallback const & config ) { - m_getPrimitiveCount = std::move( config ); + m_getPrimitiveCount = config; return *this; } /** *\param[in] config * The vertex count retrieval callback. */ - auto & getVertexCount( GetVertexCountCallback config ) + auto & getVertexCount( GetVertexCountCallback const & config ) { - m_getVertexCount = std::move( config ); + m_getVertexCount = config; return *this; } /** *\param[in] config * The index type retrieval callback. */ - auto & getIndexType( GetIndexTypeCallback config ) + auto & getIndexType( GetIndexTypeCallback const & config ) { - m_getIndexType = std::move( config ); + m_getIndexType = config; return *this; } /** *\param[in] config * The rasterizer cull mode. */ - auto & getCullMode( GetCullModeCallback config ) + auto & getCullMode( GetCullModeCallback const & config ) { - m_getCullMode = std::move( config ); + m_getCullMode = config; return *this; } diff --git a/include/RenderGraph/RunnablePasses/RenderPass.hpp b/include/RenderGraph/RunnablePasses/RenderPass.hpp index 937e532..a7fc0d3 100644 --- a/include/RenderGraph/RunnablePasses/RenderPass.hpp +++ b/include/RenderGraph/RunnablePasses/RenderPass.hpp @@ -18,7 +18,7 @@ namespace crg for ( auto const & element : input ) { - result.emplace_back( element ); + result.emplace_back( static_cast< VkType const & >( element ) ); } return result; diff --git a/include/RenderGraph/RunnablePasses/RenderPassHolder.hpp b/include/RenderGraph/RunnablePasses/RenderPassHolder.hpp index e219943..d5f7231 100644 --- a/include/RenderGraph/RunnablePasses/RenderPassHolder.hpp +++ b/include/RenderGraph/RunnablePasses/RenderPassHolder.hpp @@ -12,6 +12,15 @@ namespace crg public: struct Entry { + Entry( crg::ImageViewId pview + , LayoutState pinput + , LayoutState poutput ) + : view{ std::move( pview ) } + , input{ std::move( pinput ) } + , output{ std::move( poutput ) } + { + } + crg::ImageViewId view; LayoutState input; LayoutState output; diff --git a/include/RenderGraph/RunnablePasses/RenderQuad.hpp b/include/RenderGraph/RunnablePasses/RenderQuad.hpp index 43d82f1..11dc2ba 100644 --- a/include/RenderGraph/RunnablePasses/RenderQuad.hpp +++ b/include/RenderGraph/RunnablePasses/RenderQuad.hpp @@ -154,7 +154,7 @@ namespace crg , m_config ); } - protected: + private: ConfigT m_config; }; diff --git a/include/RenderGraph/RunnablePasses/RenderQuadConfig.hpp b/include/RenderGraph/RunnablePasses/RenderQuadConfig.hpp index 27bd9ea..a65e0ea 100644 --- a/include/RenderGraph/RunnablePasses/RenderQuadConfig.hpp +++ b/include/RenderGraph/RunnablePasses/RenderQuadConfig.hpp @@ -19,90 +19,90 @@ namespace crg *\param[in] config * The pipeline program. */ - auto & program( VkPipelineShaderStageCreateInfoArray config ) + auto & program( VkPipelineShaderStageCreateInfoArray const & config ) { - m_baseConfig.program( std::move( config ) ); + m_baseConfig.program( config ); return *this; } /** *\param[in] config * The pipeline programs. */ - auto & programs( std::vector< VkPipelineShaderStageCreateInfoArray > config ) + auto & programs( std::vector< VkPipelineShaderStageCreateInfoArray > const & config ) { - m_baseConfig.programs( std::move( config ) ); + m_baseConfig.programs( config ); return *this; } /** *\param[in] config * The pipeline program creator. */ - auto & programCreator( ProgramCreator config ) + auto & programCreator( ProgramCreator const & config ) { - m_baseConfig.programCreator( std::move( config ) ); + m_baseConfig.programCreator( config ); return *this; } /** *\param[in] config * The descriptor set layout. */ - auto & layout( VkDescriptorSetLayout config ) + auto & layout( VkDescriptorSetLayout const & config ) { - m_baseConfig.layout( std::move( config ) ); + m_baseConfig.layout( config ); return *this; } /** *\param[in] config * The descriptor set layouts. */ - auto & layouts( std::vector< VkDescriptorSetLayout > config ) + auto & layouts( std::vector< VkDescriptorSetLayout > const & config ) { - m_baseConfig.layouts( std::move( config ) ); + m_baseConfig.layouts( config ); return *this; } /** *\param[in] config * Tells if disabled pass should record render pass begin/end. */ - auto & baseConfig( pp::Config config ) + auto & baseConfig( pp::Config const & config ) { - m_baseConfig = std::move( config ); + m_baseConfig = config; return *this; } /** *\param[in] config * The texture coordinates configuration. */ - auto & texcoordConfig( Texcoord config ) + auto & texcoordConfig( Texcoord const & config ) { - m_texcoordConfig = std::move( config ); + m_texcoordConfig = config; return *this; } /** *\param[in] config * The render area size. */ - auto & renderSize( Extent2D config ) + auto & renderSize( Extent2D const & config ) { - m_renderSize = std::move( config ); + m_renderSize = config; return *this; } /** *\param[in] config * The render position. */ - auto & renderPosition( Offset2D config ) + auto & renderPosition( Offset2D const & config ) { - m_renderPosition = std::move( config ); + m_renderPosition = config; return *this; } /** *\param[in] config * The depth stencil state. */ - auto & depthStencilState( VkPipelineDepthStencilStateCreateInfo config ) + auto & depthStencilState( VkPipelineDepthStencilStateCreateInfo const & config ) { - m_depthStencilState = std::move( config ); + m_depthStencilState = config; return *this; } /** @@ -127,27 +127,27 @@ namespace crg *\param[in] config * The callback checking the enable status of the pass. */ - auto & isEnabled( RunnablePass::IsEnabledCallback config ) + auto & isEnabled( RunnablePass::IsEnabledCallback const & config ) { - m_isEnabled = std::move( config ); + m_isEnabled = config; return *this; } /** *\param[in] config * The callback recording the pass. */ - auto & recordInto( RunnablePass::RecordCallback config ) + auto & recordInto( RunnablePass::RecordCallback const & config ) { - m_recordInto = std::move( config ); + m_recordInto = config; return *this; } /** *\param[in] config * The callback ending the pass. */ - auto & end( RunnablePass::RecordCallback config ) + auto & end( RunnablePass::RecordCallback const & config ) { - m_end = std::move( config ); + m_end = config; return *this; } /** @@ -163,9 +163,9 @@ namespace crg *\param[in] config * The indirect buffer. */ - auto & indirectBuffer( IndirectBuffer config ) + auto & indirectBuffer( IndirectBuffer const & config ) { - m_indirectBuffer = std::move( config ); + m_indirectBuffer = config; return *this; } diff --git a/include/RenderGraph/Signal.hpp b/include/RenderGraph/Signal.hpp index 3e4d3ca..a6974de 100644 --- a/include/RenderGraph/Signal.hpp +++ b/include/RenderGraph/Signal.hpp @@ -92,27 +92,17 @@ namespace crg static void swap( SignalConnection & lhs, SignalConnection & rhs ) { if ( lhs.m_signal ) - { lhs.m_signal->remConnection( lhs ); - } - if ( rhs.m_signal ) - { rhs.m_signal->remConnection( rhs ); - } std::swap( lhs.m_signal, rhs.m_signal ); std::swap( lhs.m_connection, rhs.m_connection ); if ( lhs.m_signal ) - { lhs.m_signal->addConnection( lhs ); - } - if ( rhs.m_signal ) - { rhs.m_signal->addConnection( rhs ); - } } private: diff --git a/include/RenderGraph/WriteDescriptorSet.hpp b/include/RenderGraph/WriteDescriptorSet.hpp index e5562a9..ba2ffc6 100644 --- a/include/RenderGraph/WriteDescriptorSet.hpp +++ b/include/RenderGraph/WriteDescriptorSet.hpp @@ -52,7 +52,7 @@ namespace crg { } - void update( VkDescriptorSet descriptorSet )const + void update( VkDescriptorSet descriptorSet )const noexcept { if ( needsUpdate ) { @@ -63,17 +63,17 @@ namespace crg } } - operator VkWriteDescriptorSet const & ()const + explicit operator VkWriteDescriptorSet const & ()const noexcept { return vk; } - inline VkWriteDescriptorSet const * operator->()const + VkWriteDescriptorSet const * operator->()const noexcept { return &vk; } - inline VkWriteDescriptorSet * operator->() + VkWriteDescriptorSet * operator->()noexcept { return &vk; } diff --git a/source/RenderGraph/DotExport.cpp b/source/RenderGraph/DotExport.cpp index d7d7843..7985f33 100644 --- a/source/RenderGraph/DotExport.cpp +++ b/source/RenderGraph/DotExport.cpp @@ -127,6 +127,7 @@ namespace crg::dot } catch ( ... ) { + // What to do here ? } } @@ -185,16 +186,6 @@ namespace crg::dot inline void addIndent( std::ios_base & ios, long val ); - struct Indent - { - explicit Indent( long i ) - : indent( i ) - { - } - - long indent; - }; - inline long & indentValue( std::ios_base & ios ) { static int indentIndex = std::ios_base::xalloc(); @@ -230,21 +221,32 @@ namespace crg::dot } } - template< typename CharType > - inline std::basic_ostream< CharType > & operator<<( std::basic_ostream< CharType > & stream, Indent const & ind ) + struct Indent { - auto sbuf = dynamic_cast< BasicIndentBuffer< CharType > * >( stream.rdbuf() ); - - if ( !sbuf ) + explicit Indent( long i ) + : indent( i ) { - sbuf = installIndentBuffer( stream ); - stream.register_callback( callback< CharType >, 0 ); } - addIndent( stream, ind.indent ); - sbuf->indent( ind.indent ); - return stream; - } + long indent; + + private: + template< typename CharType > + friend std::basic_ostream< CharType > & operator<<( std::basic_ostream< CharType > & stream, Indent const & ind ) + { + auto sbuf = dynamic_cast< BasicIndentBuffer< CharType > * >( stream.rdbuf() ); + + if ( !sbuf ) + { + sbuf = installIndentBuffer( stream ); + stream.register_callback( callback< CharType >, 0 ); + } + + addIndent( stream, ind.indent ); + sbuf->indent( ind.indent ); + return stream; + } + }; static std::string_view constexpr imgColour{ "#8b008b" }; static std::string_view constexpr bufColour{ "#458b00" }; @@ -272,14 +274,14 @@ namespace crg::dot assert( group != nullptr ); - if ( group->parent == m_group ) + if ( group->getParent() == m_group ) { m_children.emplace_back( std::make_unique< FramePassGroupStreams >( m_config, this, group ) ); streams = m_children.back().get(); } else { - streams = emplace( group->parent ).first; + streams = emplace( group->getParent() ).first; streams = streams->emplace( group ).first; } @@ -306,94 +308,104 @@ namespace crg::dot : result; } - void write( DisplayResult & streams - , std::stringstream const & global = std::stringstream{} )const + void doWriteSplitted( DisplayResult & streams )const { - if ( m_config.splitGroups ) + if ( m_group ) { - if ( m_group ) - { - auto & stream = streams.try_emplace( m_group->getName() ).first->second; - stream << "digraph \"" << m_group->getName() << "\" {\n"; - stream << m_stream.str(); - stream << "}\n"; - } + auto & stream = streams.try_emplace( m_group->getName() ).first->second; + stream << "digraph \"" << m_group->getName() << "\" {\n"; + stream << m_stream.str(); + stream << "}\n"; + } + + for ( auto & group : m_children ) + group->write( streams ); + } + + void doWriteUnsplittedWithGroups( DisplayResult & streams + , std::stringstream const & global )const + { + auto & stream = streams.try_emplace( m_group ? m_group->getName() : std::string{} ).first->second; - for ( auto & group : m_children ) + if ( m_group ) + { + stream << "subgraph cluster_" << m_group->getId() << " {\n"; + stream << " label=\"" << m_group->getName() << "\";\n"; + + if ( m_config.withColours ) { - group->write( streams ); + static std::vector< std::string_view > colours + { + { "#FFFFFF" }, + { "#EEEEEE" }, + { "#DDDDDD" }, + { "#CCCCCC" }, + { "#BBBBBB" }, + { "#AAAAAA" }, + { "#999999" }, + { "#888888" }, + }; + stream << " style=filled;\n"; + stream << " fillcolor=\"" << colours[std::min( size_t( getLevel() ), colours.size() - 1u )] << "\";\n"; + stream << " color=black;\n"; } } else { - auto & stream = streams.try_emplace( m_group ? m_group->getName() : std::string{} ).first->second; + stream << "digraph {\n"; + } - if ( m_group ) - { - if ( m_config.withGroups ) - { - static std::vector< std::string_view > colours - { - { "#FFFFFF" }, - { "#EEEEEE" }, - { "#DDDDDD" }, - { "#CCCCCC" }, - { "#BBBBBB" }, - { "#AAAAAA" }, - { "#999999" }, - { "#888888" }, - }; - stream << "subgraph cluster_" << m_group->id << " {\n"; - stream << " label=\"" << m_group->getName() << "\";\n"; - - if ( m_config.withColours ) - { - stream << " style=filled;\n"; - stream << " fillcolor=\"" << colours[std::min( size_t( getLevel() ), colours.size() - 1u )] << "\";\n"; - stream << " color=black;\n"; - } - } - } - else - { - stream << "digraph {\n"; - } + stream << Indent{ 2 }; - if ( m_config.withGroups ) - { - stream << Indent{ 2 }; - } + for ( auto & group : m_children ) + { + group->write( streams ); + stream << streams.find( group->getName() )->second.str(); + } - for ( auto & group : m_children ) - { - group->write( streams ); - stream << streams.find( group->getName() )->second.str(); - } + auto & stream2 = streams.try_emplace( m_group ? m_group->getName() : std::string{} ).first->second; + stream2 << Indent{ -2 }; + stream2 << m_stream.str(); + if ( !m_group ) + stream2 << global.str(); + stream2 << "}\n"; + } + + void doWriteUnsplitted( DisplayResult & streams + , std::stringstream const & global )const + { + auto & stream = streams.try_emplace( m_group ? m_group->getName() : std::string{} ).first->second; - auto & stream2 = streams.try_emplace( m_group ? m_group->getName() : std::string{} ).first->second; + if ( !m_group ) + stream << "digraph {\n"; - if ( m_config.withGroups ) - { - stream2 << Indent{ -2 }; - } + for ( auto & group : m_children ) + { + group->write( streams ); + stream << streams.find( group->getName() )->second.str(); + } - stream2 << m_stream.str(); + auto & stream2 = streams.try_emplace( m_group ? m_group->getName() : std::string{} ).first->second; + stream2 << m_stream.str(); - if ( !m_group ) - { - stream2 << global.str(); - stream2 << "}\n"; - } - else - { - if ( m_config.withGroups ) - { - stream2 << "}\n"; - } - } + if ( !m_group ) + { + stream2 << global.str(); + stream2 << "}\n"; } } + void write( DisplayResult & streams + , std::stringstream const & global = std::stringstream{} )const + { + if ( m_config.splitGroups ) + doWriteSplitted( streams ); + else if ( m_config.withGroups ) + doWriteUnsplittedWithGroups( streams, global ); + else + doWriteUnsplitted( streams, global ); + } + std::string const & getName()const { static std::string const dummy; @@ -412,11 +424,11 @@ namespace crg::dot uint32_t getLevel()const { - return ( m_parent - ? ( m_parent->m_parent + if ( m_parent ) + return ( m_parent->m_parent ? 1u + m_parent->getLevel() - : m_parent->getLevel() ) - : 0u ); + : m_parent->getLevel() ); + return 0u; } std::stringstream & getStream()const @@ -528,9 +540,9 @@ namespace crg::dot if ( attach.pass ) { - nodeId = attach.pass->id; + nodeId = attach.pass->getId(); node = attach.pass->getGroupName(); - group = &attach.pass->group; + group = &attach.pass->getGroup(); colour = passColour; } @@ -585,13 +597,13 @@ namespace crg::dot if ( transition.outputAttach.pass ) { srcNode = transition.outputAttach.pass->getGroupName(); - srcStream = groups.find( &transition.outputAttach.pass->group ); + srcStream = groups.find( &transition.outputAttach.pass->getGroup() ); } if ( transition.inputAttach.pass ) { dstNode = transition.inputAttach.pass->getGroupName(); - dstStream = groups.find( &transition.inputAttach.pass->group ); + dstStream = groups.find( &transition.inputAttach.pass->getGroup() ); } std::string name{ "Transition to\\n" + dstName }; @@ -742,7 +754,7 @@ namespace crg::dot , Config const & config ) { DisplayResult result; - dotexp::DotTransitionsVisitor::submit( result, value.getGraph(), config ); + dotexp::DotTransitionsVisitor::submit( result, value.getNodeGraph(), config ); return result; } diff --git a/source/RenderGraph/FrameGraph.cpp b/source/RenderGraph/FrameGraph.cpp index 5500603..49075a4 100644 --- a/source/RenderGraph/FrameGraph.cpp +++ b/source/RenderGraph/FrameGraph.cpp @@ -232,26 +232,15 @@ namespace crg if ( checkFlag( data.image.data->info.flags, ImageCreateFlags::eCubeCompatible ) && ( data.info.subresourceRange.layerCount % 6u ) == 0u && data.info.subresourceRange.baseArrayLayer == 0u ) - { - if ( data.info.subresourceRange.layerCount > 6u ) - { - data.info.viewType = ImageViewType::eCubeArray; - } - else - { - data.info.viewType = ImageViewType::eCube; - } - } + data.info.viewType = ( data.info.subresourceRange.layerCount > 6u ) + ? ImageViewType::eCubeArray + : ImageViewType::eCube; else - { data.info.viewType = ImageViewType::e2DArray; - } break; case ImageViewType::eCube: if ( data.info.subresourceRange.layerCount > 6u ) - { data.info.viewType = ImageViewType::eCubeArray; - } break; default: break; diff --git a/source/RenderGraph/FrameGraphPrerequisites.cpp b/source/RenderGraph/FrameGraphPrerequisites.cpp index c18156d..a5be77e 100644 --- a/source/RenderGraph/FrameGraphPrerequisites.cpp +++ b/source/RenderGraph/FrameGraphPrerequisites.cpp @@ -741,6 +741,29 @@ namespace crg return newLayout; } + static void gatherSubresourceRangeLayoutMips( ImageSubresourceRange const & range + , MipLayoutStates const & layers + , std::map< ImageLayout, LayoutState > & states ) + { + for ( uint32_t levelIdx = 0u; levelIdx < range.levelCount; ++levelIdx ) + { + if ( auto it = layers.find( range.baseMipLevel + levelIdx ); + it != layers.end() ) + { + auto state = it->second; + auto [rit, res] = states.emplace( state.layout, state ); + + if ( !res ) + { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnull-dereference" + rit->second.state.access |= state.state.access; +#pragma GCC diagnostic pop + } + } + } + } + LayoutState getSubresourceRangeLayout( LayerLayoutStates const & ranges , ImageSubresourceRange const & range ) { @@ -752,24 +775,7 @@ namespace crg layerIt != ranges.end() ) { auto & layers = layerIt->second; - - for ( uint32_t levelIdx = 0u; levelIdx < range.levelCount; ++levelIdx ) - { - if ( auto it = layers.find( range.baseMipLevel + levelIdx ); - it != layers.end() ) - { - auto state = it->second; - auto [rit, res] = states.emplace( state.layout, state ); - - if ( !res ) - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnull-dereference" - rit->second.state.access |= state.state.access; -#pragma GCC diagnostic pop - } - } - } + gatherSubresourceRangeLayoutMips( range, layers, states ); } } diff --git a/source/RenderGraph/FramePass.cpp b/source/RenderGraph/FramePass.cpp index e8431be..64b76e7 100644 --- a/source/RenderGraph/FramePass.cpp +++ b/source/RenderGraph/FramePass.cpp @@ -31,16 +31,16 @@ namespace crg } } - FramePass::FramePass( FramePassGroup const & pgroup - , FrameGraph & pgraph - , uint32_t pid - , std::string const & pname - , RunnablePassCreator prunnableCreator ) - : group{ pgroup } - , graph{ pgraph } - , id{ pid } - , runnableCreator{ std::move( prunnableCreator ) } - , m_name{ pname } + FramePass::FramePass( FramePassGroup const & group + , FrameGraph & graph + , uint32_t id + , std::string const & name + , RunnablePassCreator runnableCreator ) + : m_group{ group } + , m_graph{ graph } + , m_id{ id } + , m_runnableCreator{ std::move( runnableCreator ) } + , m_name{ name } { } @@ -62,7 +62,7 @@ namespace crg , BufferAttachment::FlagKind( BufferAttachment::Flag::Uniform ) , AccessState{} , nullptr ); - uniforms.try_emplace( binding, attach ); + m_uniforms.try_emplace( binding, attach ); } void FramePass::addInputSampledImage( ImageViewIdArray views @@ -80,7 +80,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eShaderReadOnly , nullptr ); - sampled.try_emplace( binding, attach, std::move( samplerDesc ) ); + m_sampled.try_emplace( binding, attach, std::move( samplerDesc ) ); } void FramePass::addInputUniform( Attachment const & attachment @@ -93,7 +93,7 @@ namespace crg , BufferAttachment::FlagKind( BufferAttachment::Flag::Uniform ) , AccessState{} , &attachment ); - uniforms.try_emplace( binding, attach ); + m_uniforms.try_emplace( binding, attach ); } void FramePass::addInputSampled( Attachment const & attachment @@ -111,7 +111,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eShaderReadOnly , &attachment ); - sampled.try_emplace( binding, attach, std::move( samplerDesc ) ); + m_sampled.try_emplace( binding, attach, std::move( samplerDesc ) ); } void FramePass::addInputStorageBuffer( BufferViewIdArray buffers @@ -124,7 +124,7 @@ namespace crg , BufferAttachment::FlagKind( BufferAttachment::Flag::Storage ) , AccessState{} , nullptr ); - inputs.try_emplace( binding, attach ); + m_inputs.try_emplace( binding, attach ); } void FramePass::addInputStorageImage( ImageViewIdArray views @@ -141,7 +141,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eGeneral , nullptr ); - inputs.try_emplace( binding, attach ); + m_inputs.try_emplace( binding, attach ); } void FramePass::addInputStorage( Attachment const & attachment @@ -160,7 +160,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eGeneral , &attachment ); - inputs.try_emplace( binding, attach ); + m_inputs.try_emplace( binding, attach ); } else { @@ -171,7 +171,7 @@ namespace crg , BufferAttachment::FlagKind( BufferAttachment::Flag::Storage ) , AccessState{} , &attachment ); - inputs.try_emplace( binding, attach ); + m_inputs.try_emplace( binding, attach ); } } @@ -193,7 +193,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eGeneral , &attachment ); - inouts.try_emplace( binding, result ); + m_inouts.try_emplace( binding, result ); } else { @@ -204,7 +204,7 @@ namespace crg , BufferAttachment::FlagKind( BufferAttachment::Flag::Storage ) , AccessState{} , &attachment ); - inouts.try_emplace( binding, result ); + m_inouts.try_emplace( binding, result ); } return result; @@ -220,7 +220,7 @@ namespace crg , BufferAttachment::FlagKind( BufferAttachment::Flag::Storage ) , AccessState{} , nullptr ); - outputs.try_emplace( binding, result ); + m_outputs.try_emplace( binding, result ); return result; } @@ -234,7 +234,7 @@ namespace crg , BufferAttachment::FlagKind( BufferAttachment::Flag::Storage ) , AccessState{} , nullptr ); - outputs.try_emplace( binding, result ); + m_outputs.try_emplace( binding, result ); return result; } @@ -252,7 +252,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eGeneral , nullptr ); - outputs.try_emplace( binding, result ); + m_outputs.try_emplace( binding, result ); return result; } @@ -271,7 +271,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eGeneral , nullptr ); - outputs.try_emplace( binding, result ); + m_outputs.try_emplace( binding, result ); return result; } @@ -284,7 +284,7 @@ namespace crg , BufferAttachment::FlagKind( BufferAttachment::Flag::Transfer ) , AccessState{} , nullptr ); - inputs.try_emplace( TransferOffset + uint32_t( inputs.size() ), attach ); + m_inputs.try_emplace( TransferOffset + uint32_t( m_inputs.size() ), attach ); } void FramePass::addInputTransferImage( ImageViewIdArray views ) @@ -300,7 +300,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eTransferSrc , nullptr ); - inputs.try_emplace( TransferOffset + uint32_t( inputs.size() ), attach ); + m_inputs.try_emplace( TransferOffset + uint32_t( m_inputs.size() ), attach ); } void FramePass::addInputTransfer( Attachment const & attachment ) @@ -318,7 +318,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eTransferSrc , & attachment ); - inputs.try_emplace( TransferOffset + uint32_t( inputs.size() ), attach ); + m_inputs.try_emplace( TransferOffset + uint32_t( m_inputs.size() ), attach ); } else { @@ -329,7 +329,7 @@ namespace crg , BufferAttachment::FlagKind( BufferAttachment::Flag::Transfer ) , AccessState{} , &attachment ); - inputs.try_emplace( TransferOffset + uint32_t( inputs.size() ), attach ); + m_inputs.try_emplace( TransferOffset + uint32_t( m_inputs.size() ), attach ); } } @@ -351,7 +351,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eTransferSrc , &attachment ); - inouts.try_emplace( TransferOffset + uint32_t( inouts.size() ), result ); + m_inouts.try_emplace( TransferOffset + uint32_t( m_inouts.size() ), result ); } else { @@ -362,7 +362,7 @@ namespace crg , BufferAttachment::FlagKind( BufferAttachment::Flag::Transfer ) , AccessState{} , &attachment ); - inouts.try_emplace( TransferOffset + uint32_t( inouts.size() ), result ); + m_inouts.try_emplace( TransferOffset + uint32_t( m_inouts.size() ), result ); } return result; @@ -377,7 +377,7 @@ namespace crg , BufferAttachment::FlagKind( BufferAttachment::Flag::Transfer ) , AccessState{} , nullptr ); - outputs.try_emplace( TransferOffset + uint32_t( outputs.size() ), result ); + m_outputs.try_emplace( TransferOffset + uint32_t( m_outputs.size() ), result ); return result; } @@ -394,7 +394,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eTransferDst , nullptr ); - outputs.try_emplace( TransferOffset + uint32_t( outputs.size() ), result ); + m_outputs.try_emplace( TransferOffset + uint32_t( m_outputs.size() ), result ); return result; } @@ -411,7 +411,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eColorAttachment , nullptr ); - targets.emplace_back( result ); + m_targets.emplace_back( result ); } void FramePass::addInputDepthTargetImage( ImageViewIdArray views ) @@ -427,7 +427,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eDepthStencilAttachment , nullptr ); - targets.emplace_back( result ); + m_targets.emplace_back( result ); } void FramePass::addInputStencilTargetImage( ImageViewIdArray views ) @@ -443,7 +443,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eDepthStencilAttachment , nullptr ); - targets.emplace_back( result ); + m_targets.emplace_back( result ); } void FramePass::addInputDepthStencilTargetImage( ImageViewIdArray views ) @@ -459,7 +459,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eDepthStencilAttachment , nullptr ); - targets.emplace_back( result ); + m_targets.emplace_back( result ); } void FramePass::addInputColourTarget( Attachment const & attachment ) @@ -475,7 +475,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eColorAttachment , &attachment ); - targets.emplace_back( result ); + m_targets.emplace_back( result ); } void FramePass::addInputDepthTarget( Attachment const & attachment ) @@ -491,7 +491,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eDepthStencilAttachment , &attachment ); - targets.emplace_back( attach ); + m_targets.emplace_back( attach ); } void FramePass::addInputStencilTarget( Attachment const & attachment ) @@ -507,7 +507,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eDepthStencilAttachment , &attachment ); - targets.emplace_back( attach ); + m_targets.emplace_back( attach ); } void FramePass::addInputDepthStencilTarget( Attachment const & attachment ) @@ -523,7 +523,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eDepthStencilAttachment , &attachment ); - targets.emplace_back( attach ); + m_targets.emplace_back( attach ); } Attachment const * FramePass::addInOutColourTarget( Attachment const & attachment @@ -540,7 +540,7 @@ namespace crg , std::move( blendState ) , ImageLayout::eColorAttachment , &attachment ); - targets.emplace_back( result ); + m_targets.emplace_back( result ); return result; } @@ -557,7 +557,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eDepthStencilAttachment , &attachment ); - targets.emplace_back( result ); + m_targets.emplace_back( result ); return result; } @@ -574,7 +574,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eDepthStencilAttachment , &attachment ); - targets.emplace_back( result ); + m_targets.emplace_back( result ); return result; } @@ -591,7 +591,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eDepthStencilAttachment , &attachment ); - targets.emplace_back( result ); + m_targets.emplace_back( result ); return result; } @@ -609,7 +609,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eColorAttachment , nullptr ); - targets.emplace_back( result ); + m_targets.emplace_back( result ); return result; } @@ -627,7 +627,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eDepthAttachment , nullptr ); - targets.emplace( targets.begin(), result ); + m_targets.emplace( m_targets.begin(), result ); return result; } @@ -645,7 +645,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eStencilAttachment , nullptr ); - targets.emplace( targets.begin(), result ); + m_targets.emplace( m_targets.begin(), result ); return result; } @@ -663,7 +663,7 @@ namespace crg , PipelineColorBlendAttachmentState{} , ImageLayout::eDepthStencilAttachment , nullptr ); - targets.emplace( targets.begin(), result ); + m_targets.emplace( m_targets.begin(), result ); return result; } @@ -677,7 +677,7 @@ namespace crg , BufferAttachment::FlagKind( BufferAttachment::FlagKind( BufferAttachment::Flag::Transition ) | attachment.bufferAttach.getFormatFlags() ) , std::move( wantedAccess ) , &attachment ); - inputs.try_emplace( ImplicitOffset + uint32_t( inputs.size() ), attach ); + m_inputs.try_emplace( ImplicitOffset + uint32_t( m_inputs.size() ), attach ); } void FramePass::addImplicit( Attachment const & attachment @@ -694,23 +694,23 @@ namespace crg , PipelineColorBlendAttachmentState{} , wantedLayout , &attachment ); - inputs.try_emplace( ImplicitOffset + uint32_t( inputs.size() ), attach ); + m_inputs.try_emplace( ImplicitOffset + uint32_t( m_inputs.size() ), attach ); } RunnablePassPtr FramePass::createRunnable( GraphContext & context , RunnableGraph & pgraph )const { - return runnableCreator( *this, context, pgraph ); + return m_runnableCreator( *this, context, pgraph ); } std::string FramePass::getFullName()const { - return group.getFullName() + "/" + getName(); + return m_group.getFullName() + "/" + getName(); } std::string FramePass::getGroupName()const { - return group.getName() + "/" + getName(); + return m_group.getName() + "/" + getName(); } Attachment const * FramePass::addOwnAttach( ImageViewIdArray views, std::string attachName diff --git a/source/RenderGraph/FramePassGroup.cpp b/source/RenderGraph/FramePassGroup.cpp index 5375edd..649c618 100644 --- a/source/RenderGraph/FramePassGroup.cpp +++ b/source/RenderGraph/FramePassGroup.cpp @@ -17,16 +17,16 @@ namespace crg { static FramePassGroup const * getOutermost( FramePassGroup const * group ) { - while ( group && group->parent ) - group = group->parent; + while ( group && group->getParent() ) + group = group->getParent(); return group; } static uint32_t countPasses( FramePassGroup const * group ) { - return std::accumulate( group->groups.begin() - , group->groups.end() - , uint32_t( group->passes.size() ) + return std::accumulate( group->getGroups().begin() + , group->getGroups().end() + , uint32_t( group->getPasses().size() ) , []( uint32_t val, FramePassGroupPtr const & lookup ) { return val + countPasses( lookup.get() ); @@ -35,9 +35,9 @@ namespace crg static uint32_t countGroups( FramePassGroup const * group ) { - return std::accumulate( group->groups.begin() - , group->groups.end() - , uint32_t( group->groups.size() ) + return std::accumulate( group->getGroups().begin() + , group->getGroups().end() + , uint32_t( group->getGroups().size() ) , []( uint32_t val, FramePassGroupPtr const & lookup ) { return val + countGroups( lookup.get() ); @@ -49,7 +49,7 @@ namespace crg , uint32_t pid , std::string const & name , Token ) - : id{ pid } + : m_id{ pid } , m_name{ name } , m_graph{ graph } { @@ -59,10 +59,10 @@ namespace crg , uint32_t pid , std::string const & name , Token ) - : id{ pid } - , parent{ &pparent } + : m_id{ pid } + , m_parent{ &pparent } , m_name{ name } - , m_graph{ parent->m_graph } + , m_graph{ m_parent->m_graph } { } @@ -76,28 +76,28 @@ namespace crg } auto count = group::countPasses( group::getOutermost( this ) ); - passes.emplace_back( new FramePass{ *this + m_passes.emplace_back( new FramePass{ *this , m_graph , count + 1u , passName , std::move( runnableCreator ) } ); - return *passes.back(); + return *m_passes.back(); } FramePassGroup & FramePassGroup::createPassGroup( std::string const & groupName ) { - auto it = std::find_if( groups.begin() - , groups.end() + auto it = std::find_if( m_groups.begin() + , m_groups.end() , [&groupName]( FramePassGroupPtr const & lookup ) { return lookup->getName() == groupName; } ); - if ( it == groups.end() ) + if ( it == m_groups.end() ) { auto count = group::countGroups( group::getOutermost( this ) ); - groups.emplace_back( std::make_unique< FramePassGroup >( *this, count + 1u, groupName, Token{} ) ); - it = std::next( groups.begin(), ptrdiff_t( groups.size() - 1u ) ); + m_groups.emplace_back( std::make_unique< FramePassGroup >( *this, count + 1u, groupName, Token{} ) ); + it = std::next( m_groups.begin(), ptrdiff_t( m_groups.size() - 1u ) ); } return **it; @@ -105,8 +105,8 @@ namespace crg bool FramePassGroup::hasPass( std::string const & passName )const { - return passes.end() != std::find_if( passes.begin() - , passes.end() + return m_passes.end() != std::find_if( m_passes.begin() + , m_passes.end() , [&passName]( FramePassPtr const & lookup ) { return lookup->getName() == passName; @@ -115,12 +115,12 @@ namespace crg void FramePassGroup::listPasses( FramePassArray & result )const { - for ( auto & pass : passes ) + for ( auto & pass : m_passes ) { result.push_back( pass.get() ); } - for ( auto & group : groups ) + for ( auto & group : m_groups ) { group->listPasses( result ); } @@ -206,7 +206,7 @@ namespace crg { return ( &m_graph.getDefaultGroup() == this ) ? m_graph.getName() - : parent->getFullName() + "/" + getName(); + : m_parent->getFullName() + "/" + getName(); } ImageViewId FramePassGroup::mergeViews( ImageViewIdArray const & views diff --git a/source/RenderGraph/GraphBuilder.cpp b/source/RenderGraph/GraphBuilder.cpp index ed6a08d..401dad9 100644 --- a/source/RenderGraph/GraphBuilder.cpp +++ b/source/RenderGraph/GraphBuilder.cpp @@ -30,11 +30,11 @@ namespace crg::builder { for ( auto pass : passes ) { - for ( auto & [binding, attach] : pass->inouts ) + for ( auto & [binding, attach] : pass->getInouts() ) addAttach( *attach, result ); - for ( auto & [binding, attach] : pass->outputs ) + for ( auto & [binding, attach] : pass->getOutputs() ) addAttach( *attach, result ); - for ( auto & attach : pass->targets ) + for ( auto & attach : pass->getTargets() ) if ( attach->isOutput() ) addAttach( *attach, result ); } @@ -146,11 +146,11 @@ namespace crg::builder static bool hasOutput( FramePass const & pass ) { - auto result = ( !pass.outputs.empty() || !pass.inouts.empty() ); + auto result = ( !pass.getOutputs().empty() || !pass.getInouts().empty() ); if ( !result ) { - for ( auto & attach : pass.targets ) + for ( auto & attach : pass.getTargets() ) result = result || attach->isOutput(); } @@ -160,13 +160,13 @@ namespace crg::builder static void addPassInputs( FramePass const & pass , AttachmentArray & result ) { - for ( auto & [_, attach] : pass.inputs ) + for ( auto & [_, attach] : pass.getInputs() ) addAttach( *attach, result ); - for ( auto & [_, attach] : pass.uniforms ) + for ( auto & [_, attach] : pass.getUniforms() ) addAttach( *attach, result ); - for ( auto & [_, attach] : pass.sampled ) + for ( auto & [_, attach] : pass.getSampled() ) result.push_back( attach.attach ); - for ( auto & attach : pass.targets ) + for ( auto & attach : pass.getTargets() ) if ( attach->isInput() ) addAttach( *attach, result ); } @@ -184,11 +184,11 @@ namespace crg::builder static AttachmentArray listPassOutputs( FramePass const & pass ) { AttachmentArray result; - for ( auto & [_, attach] : pass.outputs ) + for ( auto & [_, attach] : pass.getOutputs() ) addAttach( *attach, result ); - for ( auto & [_, attach] : pass.inouts ) + for ( auto & [_, attach] : pass.getInouts() ) addAttach( *attach, result ); - for ( auto & attach : pass.targets ) + for ( auto & attach : pass.getTargets() ) if ( attach->isOutput() ) addAttach( *attach, result ); return result; @@ -408,12 +408,12 @@ namespace crg::builder { auto & node = static_cast< FramePassNode & >( *nodes.emplace_back( std::make_unique< FramePassNode >( *pass ) ) ); AttachmentTransitions transitions; - traversePassAttach( node, pass->targets, Attachment::Flag::InOut, transitions, nodes ); - traversePassAttach( node, pass->inouts, transitions, nodes ); - traversePassAttach( node, pass->uniforms, transitions, nodes ); - traversePassAttach( node, pass->sampled, transitions, nodes ); - traversePassAttach( node, pass->inputs, transitions, nodes ); - traversePassAttach( node, pass->targets, Attachment::Flag::Input, transitions, nodes ); + traversePassAttach( node, pass->getTargets(), Attachment::Flag::InOut, transitions, nodes ); + traversePassAttach( node, pass->getInouts(), transitions, nodes ); + traversePassAttach( node, pass->getUniforms(), transitions, nodes ); + traversePassAttach( node, pass->getSampled(), transitions, nodes ); + traversePassAttach( node, pass->getInputs(), transitions, nodes ); + traversePassAttach( node, pass->getTargets(), Attachment::Flag::Input, transitions, nodes ); node.setTransitions( mergeIdenticalTransitions( std::move( transitions ) ) ); parent.attachNode( node ); } @@ -495,7 +495,7 @@ namespace crg::builder auto it = std::find_if( sourceGraph.begin(), sourceGraph.end() , [&node]( GraphNodePtr const & lookup ) { - return &node == lookup.get(); + return &node == lookup.get(); } ); if ( sourceGraph.end() != it ) { diff --git a/source/RenderGraph/GraphContext.cpp b/source/RenderGraph/GraphContext.cpp index 251d11a..dd73c18 100644 --- a/source/RenderGraph/GraphContext.cpp +++ b/source/RenderGraph/GraphContext.cpp @@ -152,11 +152,9 @@ namespace crg #if VK_EXT_debug_utils || VK_EXT_debug_marker for ( auto const & [_, alloc] : m_allocated ) { - fprintf( stderr - , "Leaked [%.20s](%.90s), allocation stack:\n%.900s" - , alloc.type.c_str() - , alloc.name.c_str() - , alloc.callstack.c_str() ); + std::stringstream stream; + stream << "Leaked [" << alloc.type << "](" << alloc.name << "), allocation stack:\n" << alloc.callstack; + Logger::logError( stream.str() ); } #endif } diff --git a/source/RenderGraph/GraphNode.cpp b/source/RenderGraph/GraphNode.cpp index dfda7e6..b78d472 100644 --- a/source/RenderGraph/GraphNode.cpp +++ b/source/RenderGraph/GraphNode.cpp @@ -30,7 +30,7 @@ namespace crg : kind{ pkind } , id{ pid } , name{ std::move( pname ) } - , group{ pgroup } + , group{ &pgroup } { } @@ -43,7 +43,7 @@ namespace crg //********************************************************************************************* FramePassNode::FramePassNode( FramePass const & pass ) - : GraphNode{ MyKind, pass.id, pass.getGroupName(), pass.group } + : GraphNode{ MyKind, pass.getId(), pass.getGroupName(), pass.getGroup() } , pass{ &pass } { } diff --git a/source/RenderGraph/RecordContext.cpp b/source/RenderGraph/RecordContext.cpp index f645093..b626ed4 100644 --- a/source/RenderGraph/RecordContext.cpp +++ b/source/RenderGraph/RecordContext.cpp @@ -274,7 +274,7 @@ namespace crg , LayoutState const & wantedState , bool force ) { - auto range = recctx::adaptRange( *m_resources + auto range = recctx::adaptRange( m_resources->getContext() , image.data->info.imageType , image.data->info.format , subresourceRange ); @@ -450,7 +450,7 @@ namespace crg GraphContext & RecordContext::getContext()const { - return getResources(); + return getResources().getContext(); } ContextResourcesCache & RecordContext::getResources()const diff --git a/source/RenderGraph/ResourceHandler.cpp b/source/RenderGraph/ResourceHandler.cpp index 96d0fec..f12d998 100644 --- a/source/RenderGraph/ResourceHandler.cpp +++ b/source/RenderGraph/ResourceHandler.cpp @@ -92,36 +92,39 @@ namespace crg ResourceHandler::~ResourceHandler()noexcept { - std::array< char, 1024u > buffer; - for ( auto const & [data, _] : m_bufferViews ) { - snprintf( buffer.data(), buffer.size(), "Leaked [VkBufferView](%.900s)", data.data->name.c_str() ); - Logger::logError( buffer.data() ); + std::stringstream stream; + stream << "Leaked [VkBufferView](" << data.data->name << ")"; + Logger::logError( stream.str() ); } for ( auto const & [data, _] : m_buffers ) { - snprintf( buffer.data(), buffer.size(), "Leaked [VkBuffer](%.900s)", data.data->name.c_str() ); - Logger::logError( buffer.data() ); + std::stringstream stream; + stream << "Leaked [VkBuffer](" << data.data->name << ")"; + Logger::logError( stream.str() ); } for ( auto const & [data, _] : m_imageViews ) { - snprintf( buffer.data(), buffer.size(), "Leaked [VkImageView](%.900s)", data.data->name.c_str() ); - Logger::logError( buffer.data() ); + std::stringstream stream; + stream << "Leaked [VkImageView](" << data.data->name << ")"; + Logger::logError( stream.str() ); } for ( auto const & [data, _] : m_images ) { - snprintf( buffer.data(), buffer.size(), "Leaked [VkImage](%.900s)", data.data->name.c_str() ); - Logger::logError( buffer.data() ); + std::stringstream stream; + stream << "Leaked [VkImage](" << data.data->name << ")"; + Logger::logError( stream.str() ); } for ( auto const & [_, data] : m_samplers ) { - snprintf( buffer.data(), buffer.size(), "Leaked [VkSampler](%.900s)", data.name.c_str() ); - Logger::logError( buffer.data() ); + std::stringstream stream; + stream << "Leaked [VkSampler](" << data.name << ")"; + Logger::logError( stream.str() ); } } @@ -460,9 +463,9 @@ namespace crg auto realMinV = float( config.invertV ? maxV : minV ); auto realMaxV = float( config.invertV ? minV : maxV ); std::array vertexData - { reshdl::Quad::Vertex{ reshdl::Quad::Data{ -1.0f, -3.0f }, reshdl::Quad::Data{ realMinU, realMinV } } + { reshdl::Quad::Vertex{ reshdl::Quad::Data{ -1.0f, -3.0f }, reshdl::Quad::Data{ realMinU, realMinV } } , reshdl::Quad::Vertex{ reshdl::Quad::Data{ -1.0f, +1.0f }, reshdl::Quad::Data{ realMinU, realMaxV } } - , reshdl::Quad::Vertex{ reshdl::Quad::Data{ +3.0f, +1.0f }, reshdl::Quad::Data{ realMaxU, realMaxV } } }; + , reshdl::Quad::Vertex{ reshdl::Quad::Data{ +3.0f, +1.0f }, reshdl::Quad::Data{ realMaxU, realMaxV } } }; std::copy( vertexData.begin(), vertexData.end(), buffer ); VkMappedMemoryRange memoryRange{ VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE diff --git a/source/RenderGraph/RunnableGraph.cpp b/source/RenderGraph/RunnableGraph.cpp index 1d8cc66..3e128c3 100644 --- a/source/RenderGraph/RunnableGraph.cpp +++ b/source/RenderGraph/RunnableGraph.cpp @@ -47,7 +47,26 @@ namespace crg return result; } - static LayerLayoutStates mergeRanges( LayerLayoutStatesMap nextLayouts + static void mergeMipRanges( LayerLayoutStates const & nextLayout + , uint32_t currentLayout + , MipLayoutStates const & curStates + , LayerLayoutStates & result ) + { + if ( auto nextLayerIt = nextLayout.find( currentLayout ); + nextLayerIt != nextLayout.end() ) + { + auto resLayerIt = result.try_emplace( currentLayout ).first; + + for ( auto & [curLevel, _] : curStates ) + { + if ( auto nextLevelIt = nextLayerIt->second.find( curLevel ); + nextLevelIt != nextLayerIt->second.end() ) + resLayerIt->second.emplace( *nextLevelIt ); + } + } + } + + static LayerLayoutStates mergeRanges( LayerLayoutStatesMap const & nextLayouts , LayerLayoutStatesMap::value_type const & currentLayout ) { LayerLayoutStates result; @@ -58,22 +77,7 @@ namespace crg auto & nxtLayout = nextIt->second; for ( auto & [curLayout, curStates] : currentLayout.second ) - { - if ( auto nxtLayerIt = nxtLayout.find( curLayout ); - nxtLayerIt != nxtLayout.end() ) - { - auto resLayerIt = result.try_emplace( curLayout ).first; - - for ( auto & [curLevel, _] : curStates ) - { - if ( auto nxtLevelIt = nxtLayerIt->second.find( curLevel ); - nxtLevelIt != nxtLayerIt->second.end() ) - { - resLayerIt->second.emplace( *nxtLevelIt ); - } - } - } - } + mergeMipRanges( nxtLayout, curLayout, curStates, result ); } return result; @@ -453,7 +457,7 @@ namespace crg m_context.vkQueueSubmit( queue , 1u , &submitInfo - , m_fence ); + , m_fence.getInternal() ); return { SemaphoreWait{ m_semaphore , m_graph.getFinalStates().getCurrPipelineState().pipelineStage } }; } diff --git a/source/RenderGraph/RunnablePass.cpp b/source/RenderGraph/RunnablePass.cpp index f3b418a..695a6ba 100644 --- a/source/RenderGraph/RunnablePass.cpp +++ b/source/RenderGraph/RunnablePass.cpp @@ -74,26 +74,26 @@ namespace crg , AccessStateMap & bufferAccesses ) { bool isComputePass = callbacks.isComputePass(); - for ( auto & [binding, attach] : pass.uniforms ) + for ( auto & [binding, attach] : pass.getUniforms() ) registerBuffer( *attach, isComputePass, bufferAccesses ); - for ( auto & [binding, attach] : pass.sampled ) + for ( auto & [binding, attach] : pass.getSampled() ) registerImage( *attach.attach, isComputePass, graphContext.separateDepthStencilLayouts, imageLayouts ); - for ( auto & [binding, attach] : pass.inputs ) + for ( auto & [binding, attach] : pass.getInputs() ) if ( attach->isImage() ) registerImage( *attach, isComputePass, graphContext.separateDepthStencilLayouts, imageLayouts ); else registerBuffer( *attach, isComputePass, bufferAccesses ); - for ( auto & [binding, attach] : pass.inouts ) + for ( auto & [binding, attach] : pass.getInouts() ) if ( attach->isImage() ) registerImage( *attach, isComputePass, graphContext.separateDepthStencilLayouts, imageLayouts ); else registerBuffer( *attach, isComputePass, bufferAccesses ); - for ( auto & [binding, attach] : pass.outputs ) + for ( auto & [binding, attach] : pass.getOutputs() ) if ( attach->isImage() ) registerImage( *attach, isComputePass, graphContext.separateDepthStencilLayouts, imageLayouts ); else registerBuffer( *attach, isComputePass, bufferAccesses ); - for ( auto attach : pass.targets ) + for ( auto attach : pass.getTargets() ) registerImage( *attach, isComputePass, graphContext.separateDepthStencilLayouts, imageLayouts ); } @@ -206,28 +206,28 @@ namespace crg , RunnableGraph & graph , FramePass const & pass , RunnablePass::Callbacks const & callbacks - , GraphContext & graphContext ) + , GraphContext const & graphContext ) { - for ( auto & [binding, attach] : pass.sampled ) + for ( auto & [binding, attach] : pass.getSampled() ) prepareImage( commandBuffer, index, *attach.attach, graphContext.separateDepthStencilLayouts, graph, recordContext ); - for ( auto & [binding, attach] : pass.uniforms ) + for ( auto & [binding, attach] : pass.getUniforms() ) prepareBuffer( commandBuffer, index, *attach, callbacks.isComputePass(), graph, recordContext ); - for ( auto & [binding, attach] : pass.inputs ) + for ( auto & [binding, attach] : pass.getInputs() ) if ( attach->isImage() ) prepareImage( commandBuffer, index, *attach, graphContext.separateDepthStencilLayouts, graph, recordContext ); else prepareBuffer( commandBuffer, index, *attach, callbacks.isComputePass(), graph, recordContext ); - for ( auto & [binding, attach] : pass.inouts ) + for ( auto & [binding, attach] : pass.getInouts() ) if ( attach->isImage() ) prepareImage( commandBuffer, index, *attach, graphContext.separateDepthStencilLayouts, graph, recordContext ); else prepareBuffer( commandBuffer, index, *attach, callbacks.isComputePass(), graph, recordContext ); - for ( auto & [binding, attach] : pass.outputs ) + for ( auto & [binding, attach] : pass.getOutputs() ) if ( attach->isImage() ) prepareImage( commandBuffer, index, *attach, graphContext.separateDepthStencilLayouts, graph, recordContext ); else prepareBuffer( commandBuffer, index, *attach, callbacks.isComputePass(), graph, recordContext ); - for ( auto & attach : pass.targets ) + for ( auto & attach : pass.getTargets() ) prepareImage( commandBuffer, index, *attach, graphContext.separateDepthStencilLayouts, graph, recordContext ); } } @@ -554,7 +554,7 @@ namespace crg #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wrestrict" m_context.vkCmdBeginDebugBlock( commandBuffer - , { "[" + std::to_string( m_pass.id ) + "] " + m_pass.getGroupName() + , { "[" + std::to_string( m_pass.getId() ) + "] " + m_pass.getGroupName() , m_context.getNextRainbowColour() } ); #pragma GCC diagnostic pop m_timer.beginPass( commandBuffer ); diff --git a/source/RenderGraph/RunnablePasses/BufferCopy.cpp b/source/RenderGraph/RunnablePasses/BufferCopy.cpp index aef2b6d..0c6e810 100644 --- a/source/RenderGraph/RunnablePasses/BufferCopy.cpp +++ b/source/RenderGraph/RunnablePasses/BufferCopy.cpp @@ -31,25 +31,25 @@ namespace crg , m_copyOffset{ copyOffset } , m_copyRange{ copyRange } { - assert( m_pass.inputs.size() == m_pass.outputs.size() ); + assert( getPass().getInputs().size() == getPass().getOutputs().size() ); } void BufferCopy::doRecordInto( RecordContext & context , VkCommandBuffer commandBuffer , uint32_t index )const { - auto srcIt = m_pass.inputs.begin(); - auto dstIt = m_pass.outputs.begin(); + auto srcIt = getPass().getInputs().begin(); + auto dstIt = getPass().getOutputs().begin(); - while ( srcIt != m_pass.inputs.end() - && dstIt != m_pass.outputs.end() ) + while ( srcIt != getPass().getInputs().end() + && dstIt != getPass().getOutputs().end() ) { auto srcView{ srcIt->second->buffer( index ) }; auto dstView{ dstIt->second->buffer( index ) }; auto srcBufferRange{ getSubresourceRange( srcView ) }; auto dstBufferRange{ getSubresourceRange( dstView ) }; - auto srcBuffer{ m_graph.createBuffer( srcView.data->buffer ) }; - auto dstBuffer{ m_graph.createBuffer( dstView.data->buffer ) }; + auto srcBuffer{ getGraph().createBuffer( srcView.data->buffer ) }; + auto dstBuffer{ getGraph().createBuffer( dstView.data->buffer ) }; // Copy source to target. VkBufferCopy copyRegion{ srcBufferRange.offset + m_copyOffset , dstBufferRange.offset + m_copyOffset diff --git a/source/RenderGraph/RunnablePasses/BufferToImageCopy.cpp b/source/RenderGraph/RunnablePasses/BufferToImageCopy.cpp index 62d894c..c8800d0 100644 --- a/source/RenderGraph/RunnablePasses/BufferToImageCopy.cpp +++ b/source/RenderGraph/RunnablePasses/BufferToImageCopy.cpp @@ -31,23 +31,23 @@ namespace crg , m_copyOffset{ convert( copyOffset ) } , m_copySize{ convert( copySize ) } { - assert( m_pass.inputs.size() == m_pass.outputs.size() ); + assert( getPass().getInputs().size() == getPass().getOutputs().size() ); } void BufferToImageCopy::doRecordInto( RecordContext const & context , VkCommandBuffer commandBuffer , uint32_t index )const { - auto srcIt = m_pass.inputs.begin(); - auto dstIt = m_pass.outputs.begin(); + auto srcIt = getPass().getInputs().begin(); + auto dstIt = getPass().getOutputs().begin(); - while ( srcIt != m_pass.inputs.end() - && dstIt != m_pass.outputs.end() ) + while ( srcIt != getPass().getInputs().end() + && dstIt != getPass().getOutputs().end() ) { auto srcAttach{ srcIt->second->buffer( index ) }; auto dstAttach{ dstIt->second->view( index ) }; - auto srcBuffer{ m_graph.createBuffer( srcAttach.data->buffer ) }; - auto dstImage{ m_graph.createImage( dstAttach.data->image ) }; + auto srcBuffer{ getGraph().createBuffer( srcAttach.data->buffer ) }; + auto dstImage{ getGraph().createImage( dstAttach.data->image ) }; // Copy source to target. auto range = getSubresourceLayers( getSubresourceRange( dstAttach ) ); VkBufferImageCopy copyRegion{ 0ULL diff --git a/source/RenderGraph/RunnablePasses/ComputePass.cpp b/source/RenderGraph/RunnablePasses/ComputePass.cpp index 4d5ad44..1ea4664 100644 --- a/source/RenderGraph/RunnablePasses/ComputePass.cpp +++ b/source/RenderGraph/RunnablePasses/ComputePass.cpp @@ -97,7 +97,7 @@ namespace crg if ( m_cpConfig.indirectBuffer != defaultV< IndirectBuffer > ) { - auto indirectBuffer = m_graph.createBuffer( m_cpConfig.indirectBuffer.buffer.data->buffer ); + auto indirectBuffer = getGraph().createBuffer( m_cpConfig.indirectBuffer.buffer.data->buffer ); context->vkCmdDispatchIndirect( commandBuffer, indirectBuffer, getSubresourceRange( m_cpConfig.indirectBuffer.buffer ).offset ); } else diff --git a/source/RenderGraph/RunnablePasses/GenerateMipmaps.cpp b/source/RenderGraph/RunnablePasses/GenerateMipmaps.cpp index a868454..6e3f47f 100644 --- a/source/RenderGraph/RunnablePasses/GenerateMipmaps.cpp +++ b/source/RenderGraph/RunnablePasses/GenerateMipmaps.cpp @@ -42,24 +42,24 @@ namespace crg void GenerateMipmaps::doRecordInto( RecordContext & context , VkCommandBuffer commandBuffer - , uint32_t index ) + , uint32_t index )const { - for ( auto [_, view] : m_pass.inouts ) + for ( auto const & [_, view] : getPass().getInouts() ) doProcessImageView( context, commandBuffer, view->view( index ) ); } void GenerateMipmaps::doProcessImageView( RecordContext & context , VkCommandBuffer commandBuffer - , ImageViewId viewId ) + , ImageViewId viewId )const { auto imageId{ viewId.data->image }; - auto image{ m_graph.createImage( imageId ) }; + auto image{ getGraph().createImage( imageId ) }; auto extent = getExtent( imageId ); auto format = getFormat( imageId ); auto baseArrayLayer = getSubresourceRange( viewId ).baseArrayLayer; auto layerCount = getSubresourceRange( viewId ).layerCount; auto mipLevels = imageId.data->info.mipLevels; - auto nextLayoutState = m_graph.getNextLayoutState( context + auto nextLayoutState = getGraph().getNextLayoutState( context , *this , viewId ); @@ -89,7 +89,7 @@ namespace crg imageBlit.dstOffsets[1].z = genMips::getSubresourceDimension( depth, mipSubRange.baseMipLevel ); // Transition first mip level to transfer source for read in next iteration - auto firstLayoutState = m_graph.getCurrentLayoutState( context + auto firstLayoutState = getGraph().getCurrentLayoutState( context , imageId , viewId.data->info.viewType , mipSubRange ); @@ -121,7 +121,7 @@ namespace crg , makeLayoutState( ImageLayout::eTransferDst ) ); // Perform blit - m_context.vkCmdBlitImage( commandBuffer + context->vkCmdBlitImage( commandBuffer , image , VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL , image diff --git a/source/RenderGraph/RunnablePasses/ImageBlit.cpp b/source/RenderGraph/RunnablePasses/ImageBlit.cpp index 6ea06d7..885a73d 100644 --- a/source/RenderGraph/RunnablePasses/ImageBlit.cpp +++ b/source/RenderGraph/RunnablePasses/ImageBlit.cpp @@ -35,23 +35,23 @@ namespace crg , m_dstSize{ convert( blitDst.extent ) } , m_filter{ filter } { - assert( m_pass.inputs.size() == m_pass.outputs.size() ); + assert( getPass().getInputs().size() == getPass().getOutputs().size() ); } void ImageBlit::doRecordInto( RecordContext const & context , VkCommandBuffer commandBuffer - , uint32_t index ) + , uint32_t index )const { - auto srcIt = m_pass.inputs.begin(); - auto dstIt = m_pass.outputs.begin(); + auto srcIt = getPass().getInputs().begin(); + auto dstIt = getPass().getOutputs().begin(); - while ( srcIt != m_pass.inputs.end() - && dstIt != m_pass.outputs.end() ) + while ( srcIt != getPass().getInputs().end() + && dstIt != getPass().getOutputs().end() ) { auto srcAttach{ srcIt->second->view( index ) }; auto dstAttach{ dstIt->second->view( index ) }; - auto srcImage{ m_graph.createImage( srcAttach.data->image ) }; - auto dstImage{ m_graph.createImage( dstAttach.data->image ) }; + auto srcImage{ getGraph().createImage( srcAttach.data->image ) }; + auto dstImage{ getGraph().createImage( dstAttach.data->image ) }; VkImageBlit blitRegion{ getSubresourceLayers( getSubresourceRange( srcAttach ) ) , { m_srcOffset, VkOffset3D{ int32_t( m_srcSize.width ), int32_t( m_srcSize.height ), int32_t( m_srcSize.depth ) } } , getSubresourceLayers( getSubresourceRange( dstAttach ) ) diff --git a/source/RenderGraph/RunnablePasses/ImageCopy.cpp b/source/RenderGraph/RunnablePasses/ImageCopy.cpp index 0ff9159..fa28c7f 100644 --- a/source/RenderGraph/RunnablePasses/ImageCopy.cpp +++ b/source/RenderGraph/RunnablePasses/ImageCopy.cpp @@ -31,7 +31,9 @@ namespace crg , m_copySize{ convert( copySize ) } , m_finalOutputLayout{ finalOutputLayout } { - assert( m_pass.inputs.size() == m_pass.outputs.size() || m_pass.inputs.size() == 1u || m_pass.outputs.size() == 1u ); + assert( getPass().getInputs().size() == getPass().getOutputs().size() + || getPass().getInputs().size() == 1u + || getPass().getOutputs().size() == 1u ); } ImageCopy::ImageCopy( FramePass const & pass @@ -50,41 +52,37 @@ namespace crg , std::move( passIndex ) , std::move( isEnabled ) } { - assert( m_pass.inputs.size() == m_pass.outputs.size() || m_pass.inputs.size() == 1u || m_pass.outputs.size() == 1u ); + assert( getPass().getInputs().size() == getPass().getOutputs().size() + || getPass().getInputs().size() == 1u + || getPass().getOutputs().size() == 1u ); } void ImageCopy::doRecordInto( RecordContext & context , VkCommandBuffer commandBuffer - , uint32_t index ) + , uint32_t index )const { - if ( m_pass.inputs.size() == m_pass.outputs.size() ) - { + if ( getPass().getInputs().size() == getPass().getOutputs().size() ) doRecordMultiToMulti( context, commandBuffer, index ); - } - else if ( m_pass.outputs.size() == 1u ) - { + else if ( getPass().getOutputs().size() == 1u ) doRecordMultiToSingle( context, commandBuffer, index ); - } - else if ( m_pass.inputs.size() == 1u ) - { + else if ( getPass().getInputs().size() == 1u ) doRecordSingleToMulti( context, commandBuffer, index ); - } } void ImageCopy::doRecordMultiToMulti( RecordContext & context , VkCommandBuffer commandBuffer - , uint32_t index ) + , uint32_t index )const { - auto srcIt = m_pass.inputs.begin(); - auto dstIt = m_pass.outputs.begin(); + auto srcIt = getPass().getInputs().begin(); + auto dstIt = getPass().getOutputs().begin(); - while ( srcIt != m_pass.inputs.end() - && dstIt != m_pass.outputs.end() ) + while ( srcIt != getPass().getInputs().end() + && dstIt != getPass().getOutputs().end() ) { auto srcAttach{ srcIt->second->view( index ) }; auto dstAttach{ dstIt->second->view( index ) }; - auto srcImage{ m_graph.createImage( srcAttach.data->image ) }; - auto dstImage{ m_graph.createImage( dstAttach.data->image ) }; + auto srcImage{ getGraph().createImage( srcAttach.data->image ) }; + auto dstImage{ getGraph().createImage( dstAttach.data->image ) }; // Copy source to target. VkImageCopy copyRegion{ getSubresourceLayers( getSubresourceRange( srcAttach ) ) , {} @@ -113,20 +111,20 @@ namespace crg void ImageCopy::doRecordMultiToSingle( RecordContext & context , VkCommandBuffer commandBuffer - , uint32_t index ) + , uint32_t index )const { std::vector< VkImageCopy > copyRegions; - auto dstIt = m_pass.outputs.begin(); + auto dstIt = getPass().getOutputs().begin(); auto dstAttach{ dstIt->second->view( index ) }; - auto dstImage{ m_graph.createImage( dstAttach.data->image ) }; + auto dstImage{ getGraph().createImage( dstAttach.data->image ) }; auto dstSubresourceRange = getSubresourceLayers( getSubresourceRange( dstAttach ) ); - auto prvSrcImage{ m_graph.createImage( m_pass.inputs.begin()->second->view( index ).data->image ) }; + auto prvSrcImage{ getGraph().createImage( getPass().getInputs().begin()->second->view( index ).data->image ) }; - for ( auto const & [_, attach] : m_pass.inputs ) + for ( auto const & [_, attach] : getPass().getInputs() ) { auto srcAttach{ attach->view( index ) }; - if ( auto srcImage{ m_graph.createImage( srcAttach.data->image ) }; + if ( auto srcImage{ getGraph().createImage( srcAttach.data->image ) }; srcImage != prvSrcImage ) { context->vkCmdCopyImage( commandBuffer @@ -168,20 +166,20 @@ namespace crg void ImageCopy::doRecordSingleToMulti( RecordContext & context , VkCommandBuffer commandBuffer - , uint32_t index ) + , uint32_t index )const { std::vector< VkImageCopy > copyRegions; - auto srcIt = m_pass.inputs.begin(); + auto srcIt = getPass().getInputs().begin(); auto srcAttach{ srcIt->second->view( index ) }; - auto srcImage{ m_graph.createImage( srcAttach.data->image ) }; + auto srcImage{ getGraph().createImage( srcAttach.data->image ) }; auto srcSubresourceRange = getSubresourceLayers( getSubresourceRange( srcAttach ) ); - auto prvDstImage{ m_graph.createImage( m_pass.outputs.begin()->second->view( index ).data->image ) }; + auto prvDstImage{ getGraph().createImage( getPass().getOutputs().begin()->second->view( index ).data->image ) }; - for ( auto const & [_, attach] : m_pass.outputs ) + for ( auto const & [_, attach] : getPass().getOutputs() ) { auto dstAttach{ attach->view( index ) }; - if ( auto dstImage{ m_graph.createImage( dstAttach.data->image ) }; + if ( auto dstImage{ getGraph().createImage( dstAttach.data->image ) }; dstImage != prvDstImage ) { context->vkCmdCopyImage( commandBuffer @@ -215,7 +213,7 @@ namespace crg if ( m_finalOutputLayout != ImageLayout::eUndefined ) { - for ( auto const & [_, attach] : m_pass.outputs ) + for ( auto const & [_, attach] : getPass().getOutputs() ) { auto dstAttach{ attach->view( index ) }; context.memoryBarrier( commandBuffer diff --git a/source/RenderGraph/RunnablePasses/ImageToBufferCopy.cpp b/source/RenderGraph/RunnablePasses/ImageToBufferCopy.cpp index 5feb9ef..a79a7c9 100644 --- a/source/RenderGraph/RunnablePasses/ImageToBufferCopy.cpp +++ b/source/RenderGraph/RunnablePasses/ImageToBufferCopy.cpp @@ -35,18 +35,18 @@ namespace crg void ImageToBufferCopy::doRecordInto( RecordContext const & context , VkCommandBuffer commandBuffer - , uint32_t index ) + , uint32_t index )const { - auto srcIt = m_pass.inputs.begin(); - auto dstIt = m_pass.outputs.begin(); + auto srcIt = getPass().getInputs().begin(); + auto dstIt = getPass().getOutputs().begin(); - while ( srcIt != m_pass.inputs.end() - && dstIt != m_pass.outputs.end() ) + while ( srcIt != getPass().getInputs().end() + && dstIt != getPass().getOutputs().end() ) { auto srcAttach{ srcIt->second->view( index ) }; auto dstAttach{ dstIt->second->buffer( index ) }; - auto srcImage{ m_graph.createImage( srcAttach.data->image ) }; - auto dstBuffer{ m_graph.createBuffer( dstAttach.data->buffer ) }; + auto srcImage{ getGraph().createImage( srcAttach.data->image ) }; + auto dstBuffer{ getGraph().createBuffer( dstAttach.data->buffer ) }; // Copy source to target. auto range = getSubresourceLayers( getSubresourceRange( srcAttach ) ); VkBufferImageCopy copyRegion{ 0ULL diff --git a/source/RenderGraph/RunnablePasses/PipelineHolder.cpp b/source/RenderGraph/RunnablePasses/PipelineHolder.cpp index 0fa4124..f7ec08b 100644 --- a/source/RenderGraph/RunnablePasses/PipelineHolder.cpp +++ b/source/RenderGraph/RunnablePasses/PipelineHolder.cpp @@ -297,11 +297,11 @@ namespace crg return; } - pphdr::createDescriptorWrites( m_pass.uniforms, index, m_graph, descriptorSet.writes ); - pphdr::createDescriptorWrites( m_pass.sampled, index, m_graph, descriptorSet.writes ); - pphdr::createDescriptorWrites( m_pass.inputs, index, m_graph, descriptorSet.writes ); - pphdr::createDescriptorWrites( m_pass.inouts, index, m_graph, descriptorSet.writes ); - pphdr::createDescriptorWrites( m_pass.outputs, index, m_graph, descriptorSet.writes ); + pphdr::createDescriptorWrites( m_pass.getUniforms(), index, m_graph, descriptorSet.writes ); + pphdr::createDescriptorWrites( m_pass.getSampled(), index, m_graph, descriptorSet.writes ); + pphdr::createDescriptorWrites( m_pass.getInputs(), index, m_graph, descriptorSet.writes ); + pphdr::createDescriptorWrites( m_pass.getInouts(), index, m_graph, descriptorSet.writes ); + pphdr::createDescriptorWrites( m_pass.getOutputs(), index, m_graph, descriptorSet.writes ); VkDescriptorSetAllocateInfo allocateInfo{ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO , nullptr @@ -338,11 +338,11 @@ namespace crg | VK_SHADER_STAGE_GEOMETRY_BIT | VK_SHADER_STAGE_FRAGMENT_BIT ) ); - pphdr::createDescriptorBindings( m_pass.uniforms, shaderStage, m_graph, m_descriptorBindings ); - pphdr::createDescriptorBindings( m_pass.sampled, shaderStage, m_graph, m_descriptorBindings ); - pphdr::createDescriptorBindings( m_pass.inputs, shaderStage, m_graph, m_descriptorBindings ); - pphdr::createDescriptorBindings( m_pass.inouts, shaderStage, m_graph, m_descriptorBindings ); - pphdr::createDescriptorBindings( m_pass.outputs, shaderStage, m_graph, m_descriptorBindings ); + pphdr::createDescriptorBindings( m_pass.getUniforms(), shaderStage, m_graph, m_descriptorBindings ); + pphdr::createDescriptorBindings( m_pass.getSampled(), shaderStage, m_graph, m_descriptorBindings ); + pphdr::createDescriptorBindings( m_pass.getInputs(), shaderStage, m_graph, m_descriptorBindings ); + pphdr::createDescriptorBindings( m_pass.getInouts(), shaderStage, m_graph, m_descriptorBindings ); + pphdr::createDescriptorBindings( m_pass.getOutputs(), shaderStage, m_graph, m_descriptorBindings ); } void PipelineHolder::doCreateDescriptorSetLayout() diff --git a/source/RenderGraph/RunnablePasses/RenderPassHolder.cpp b/source/RenderGraph/RunnablePasses/RenderPassHolder.cpp index afe076a..3e9ba58 100644 --- a/source/RenderGraph/RunnablePasses/RenderPassHolder.cpp +++ b/source/RenderGraph/RunnablePasses/RenderPassHolder.cpp @@ -39,7 +39,7 @@ namespace crg , convert( attach.getStencilStoreOp() ) , convert( initialLayout.layout ) , convert( finalLayout.layout ) } ); - viewAttaches.push_back( { view, initialLayout, finalLayout } ); + viewAttaches.emplace_back( view, initialLayout, finalLayout ); clearValues.push_back( convert( attach.getClearValue() ) ); if ( view.data->source.empty() ) @@ -235,7 +235,7 @@ namespace crg auto & data = m_passes[passIndex]; m_blendAttachs.clear(); - for ( auto attach : m_pass.targets ) + for ( auto attach : m_pass.getTargets() ) { auto view = attach->view( passIndex ); auto resolved = resolveView( view, passIndex ); @@ -341,7 +341,7 @@ namespace crg m_passes[index].attachments.clear(); m_layers = 1u; - for ( auto attach : m_pass.targets ) + for ( auto attach : m_pass.getTargets() ) { auto view = attach->view(); m_passes[index].attachments.push_back( attach ); diff --git a/test/BaseTest.cpp b/test/BaseTest.cpp index 378cdd7..480a1ea 100644 --- a/test/BaseTest.cpp +++ b/test/BaseTest.cpp @@ -14,6 +14,8 @@ # include #endif +#include + #include #include #include @@ -45,7 +47,7 @@ namespace test LogStreambuf( LogStreambuf && ) = delete; LogStreambuf & operator=( LogStreambuf && ) = delete; - explicit inline LogStreambuf( std::string const & name + explicit LogStreambuf( std::string const & name , std::ostream & stream ) : m_stream{ stream } , m_fstream{ getExecutableDirectory() + name + ".log" } @@ -53,12 +55,19 @@ namespace test m_old = m_stream.rdbuf( this ); } - inline ~LogStreambuf()override + ~LogStreambuf()noexcept override { - m_stream.rdbuf( m_old ); + try + { + m_stream.rdbuf( m_old ); + } + catch ( ... ) + { + // What to do here ? + } } - inline int_type overflow( int_type c = traits_type::eof() )override + int_type overflow( int_type c = traits_type::eof() )override { if ( traits_type::eq_int_type( c, traits_type::eof() ) ) { @@ -81,14 +90,14 @@ namespace test return c; } - inline int do_sync() + int do_sync() { LogStreambufTraits::log( m_fstream, m_buffer ); m_buffer.clear(); return 0; } - inline int do_sync_no_nl() + int do_sync_no_nl() { LogStreambufTraits::logNoNL( m_fstream, m_buffer ); m_buffer.clear(); @@ -104,69 +113,69 @@ namespace test struct DebugLogStreambufTraits { - static inline void log( std::ostream & stream + static void log( std::ostream & stream , std::string const & text ) { stream << "DEBUG: " << text << std::endl; - printf( "%s\n", text.c_str() ); + fmt::print( "{}\n", text ); } - static inline void logNoNL( std::ostream & stream + static void logNoNL( std::ostream & stream , std::string const & text ) { stream << "DEBUG: " << text; - printf( "%s", text.c_str() ); + fmt::print( "{}\n", text ); } }; struct InfoLogStreambufTraits { - static inline void log( std::ostream & stream + static void log( std::ostream & stream , std::string const & text ) { stream << text << std::endl; - printf( "%s\n", text.c_str() ); + fmt::print( "{}\n", text ); } - static inline void logNoNL( std::ostream & stream + static void logNoNL( std::ostream & stream , std::string const & text ) { stream << text; - printf( "%s", text.c_str() ); + fmt::print( "{}\n", text ); } }; struct ErrorLogStreambufTraits { - static inline void log( std::ostream & stream + static void log( std::ostream & stream , std::string const & text ) { stream << "ERROR: " << text << std::endl; - printf( "%s\n", text.c_str() ); + fmt::print( "{}\n", text ); } - static inline void logNoNL( std::ostream & stream + static void logNoNL( std::ostream & stream , std::string const & text ) { stream << "ERROR: " << text; - printf( "%s", text.c_str() ); + fmt::print( "{}\n", text ); } }; #if defined( _WIN32 ) - static char constexpr PathSeparator = '\\'; + char constexpr PathSeparator = '\\'; #else - static char constexpr PathSeparator = '/'; + char constexpr PathSeparator = '/'; #endif - std::string getPath( std::string const & path ) + std::string getPath( std::string_view path ) { - return path.substr( 0, path.find_last_of( PathSeparator ) ); + return std::string{ path.substr( 0, path.find_last_of( PathSeparator ) ) }; } std::string findMissing( StringArray const & lhsLines , StringArray const & rhsLines - , std::string const & op ) + , std::string_view const & op ) { std::string result; @@ -176,7 +185,7 @@ namespace test , rhsLines.end() , lhsLine ) ) { - result += op + lhsLine + "\n"; + result += std::string{ op } + lhsLine + "\n"; } } @@ -192,11 +201,10 @@ namespace test { std::string result; std::array< char, FILENAME_MAX > path{}; - DWORD res = ::GetModuleFileNameA( nullptr - , path.data() - , sizeof( path ) ); - if ( res != 0 ) + if ( DWORD res = ::GetModuleFileNameA( nullptr + , path.data() + , sizeof( path ) ) ) { result = path.data(); } @@ -320,15 +328,15 @@ namespace test { std::locale::global( std::locale{ "C" } ); testing::InitGoogleTest( &argc, argv ); - auto suite = new test::TestSuite{ std::string{ testSuiteName } }; - testing::AddGlobalTestEnvironment( suite ); + auto suite = std::make_unique< test::TestSuite >( std::string{ testSuiteName } ); + testing::AddGlobalTestEnvironment( suite.release() ); return RUN_ALL_TESTS(); } std::string sortLines( std::string const & value ) { std::stringstream stream{ value }; - std::multiset< std::string > sorted; + std::multiset< std::string, std::less<> > sorted; std::string line; while ( std::getline( stream, line ) ) diff --git a/test/BaseTest.hpp b/test/BaseTest.hpp index ba3a979..e6876da 100644 --- a/test/BaseTest.hpp +++ b/test/BaseTest.hpp @@ -20,7 +20,7 @@ namespace test { } - std::string diffLines( std::string const & check + static std::string diffLines( std::string const & check , std::string const & ref ); std::string testName; @@ -37,7 +37,7 @@ namespace test : public ::testing::Environment { public: - TestSuite( std::string const & name ); + explicit TestSuite( std::string const & name ); private: std::unique_ptr< std::streambuf > tclog; @@ -86,7 +86,7 @@ namespace test #define checkEqualSortedLines( x, y )\ try\ {\ - auto diff = testCounts.diffLines( test::sortLines( x ), test::sortLines( y ) );\ + auto diff = test::TestCounts::diffLines( test::sortLines( x ), test::sortLines( y ) );\ if ( !diff.empty() )\ {\ throw test::Exception{ "LHS(\n" + std::string{ x } + " )\nRHS(\n" + std::string{ y } + " )\nDIFF(\n" + diff + " )" };\ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index dd6d171..aaf84ad 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,6 +2,7 @@ enable_testing() set( GTest_DIR ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/gtest ) find_package( GTest CONFIG REQUIRED GTest::gtest GTest::gtest_main ) +find_package( fmt CONFIG REQUIRED ) set( TEST_NAME TestCommon ) @@ -31,6 +32,7 @@ target_link_libraries( ${TEST_NAME} PUBLIC crg::RenderGraph GTest::gtest + fmt::fmt ) target_include_directories( ${TEST_NAME} PUBLIC diff --git a/test/Common.cpp b/test/Common.cpp index 1ebe083..d6487d3 100644 --- a/test/Common.cpp +++ b/test/Common.cpp @@ -17,27 +17,6 @@ namespace test { namespace { - std::ostream & operator<<( std::ostream & stream - , std::vector< crg::ImageViewId > const & values ) - { - std::string sep; - - for ( auto & value : values ) - { - stream << sep << value.id; - sep = ", "; - } - - return stream; - } - - std::ostream & operator<<( std::ostream & stream - , crg::FramePass const & value ) - { - stream << value.getName(); - return stream; - } - void displayTransitions( TestCounts const & testCounts , std::ostream & stream , crg::RunnableGraph const & value @@ -241,16 +220,16 @@ namespace test }(); static VkPhysicalDeviceProperties const Properties = []() { - std::string_view name{ "Test" }; + std::string name{ "Test" }; VkPhysicalDeviceProperties result{}; #if defined( _MSC_VER ) strncpy_s( result.deviceName - , name.data() + , name.c_str() , std::min( name.size() + 1u, size_t( VK_MAX_PHYSICAL_DEVICE_NAME_SIZE - 1u ) ) ); #else strncpy( result.deviceName - , name.data() + , name.c_str() , std::min( name.size() + 1u, size_t( VK_MAX_PHYSICAL_DEVICE_NAME_SIZE - 1u ) ) ); #endif result.deviceID = 0u; @@ -635,7 +614,7 @@ namespace test return context; } - std::string checkRunnable( TestCounts & testCounts + std::string checkRunnable( TestCounts const & testCounts , crg::RunnableGraph * runnable ) { std::stringstream result; @@ -773,92 +752,92 @@ namespace test , VkCommandBuffer commandBuffer , uint32_t index ) { - for ( auto & [binding, attach] : m_pass.uniforms ) + for ( auto & [binding, attach] : getPass().getUniforms() ) { auto buffer = crg::resolveView( attach->buffer( index ), index ); context.setAccessState( buffer - , { attach->getAccessMask(), attach->getPipelineStageFlags( m_pipelineStageFlags == crg::PipelineStageFlags::eComputeShader ) } ); + , { attach->getAccessMask(), attach->getPipelineStageFlags( checkFlag( m_pipelineStageFlags, crg::PipelineStageFlags::eComputeShader ) ) } ); } - for ( auto & [binding, attach] : m_pass.sampled ) + for ( auto & [binding, attach] : getPass().getSampled() ) { auto view = attach.attach->view( index ); context.runImplicitTransition( commandBuffer, index, view ); context.setLayoutState( crg::resolveView( view, index ) - , crg::makeLayoutState( attach.attach->getImageLayout( m_context.separateDepthStencilLayouts ) ) ); + , crg::makeLayoutState( attach.attach->getImageLayout( context->separateDepthStencilLayouts ) ) ); } - for ( auto & [binding, attach] : m_pass.inputs ) + for ( auto & [binding, attach] : getPass().getInputs() ) { if ( attach->isImage() ) { auto view = attach->view( index ); context.runImplicitTransition( commandBuffer, index, view ); context.setLayoutState( crg::resolveView( view, index ) - , crg::makeLayoutState( attach->getImageLayout( m_context.separateDepthStencilLayouts ) ) ); + , crg::makeLayoutState( attach->getImageLayout( context->separateDepthStencilLayouts ) ) ); } else { auto buffer = crg::resolveView( attach->buffer( index ), index ); context.setAccessState( buffer - , { attach->getAccessMask(), attach->getPipelineStageFlags( m_pipelineStageFlags == crg::PipelineStageFlags::eComputeShader ) } ); + , { attach->getAccessMask(), attach->getPipelineStageFlags( checkFlag( m_pipelineStageFlags, crg::PipelineStageFlags::eComputeShader ) ) } ); } } - for ( auto & [binding, attach] : m_pass.inouts ) + for ( auto & [binding, attach] : getPass().getInouts() ) { if ( attach->isImage() ) { auto view = attach->view( index ); context.runImplicitTransition( commandBuffer, index, view ); context.setLayoutState( crg::resolveView( view, index ) - , crg::makeLayoutState( attach->getImageLayout( m_context.separateDepthStencilLayouts ) ) ); + , crg::makeLayoutState( attach->getImageLayout( context->separateDepthStencilLayouts ) ) ); } else { auto buffer = crg::resolveView( attach->buffer( index ), index ); context.setAccessState( buffer - , { attach->getAccessMask(), attach->getPipelineStageFlags( m_pipelineStageFlags == crg::PipelineStageFlags::eComputeShader ) } ); + , { attach->getAccessMask(), attach->getPipelineStageFlags( checkFlag( m_pipelineStageFlags, crg::PipelineStageFlags::eComputeShader ) ) } ); } } - for ( auto & [binding, attach] : m_pass.outputs ) + for ( auto & [binding, attach] : getPass().getOutputs() ) { if ( attach->isImage() ) { auto view = attach->view( index ); context.runImplicitTransition( commandBuffer, index, view ); context.setLayoutState( crg::resolveView( view, index ) - , crg::makeLayoutState( attach->getImageLayout( m_context.separateDepthStencilLayouts ) ) ); + , crg::makeLayoutState( attach->getImageLayout( context->separateDepthStencilLayouts ) ) ); } else { auto buffer = crg::resolveView( attach->buffer( index ), index ); context.setAccessState( buffer - , { attach->getAccessMask(), attach->getPipelineStageFlags( m_pipelineStageFlags == crg::PipelineStageFlags::eComputeShader ) } ); + , { attach->getAccessMask(), attach->getPipelineStageFlags( checkFlag( m_pipelineStageFlags, crg::PipelineStageFlags::eComputeShader ) ) } ); } } - for ( auto attach : m_pass.targets ) + for ( auto attach : getPass().getTargets() ) { auto view = attach->view( index ); context.runImplicitTransition( commandBuffer, index, view ); context.setLayoutState( crg::resolveView( view, index ) - , crg::makeLayoutState( attach->getImageLayout( m_context.separateDepthStencilLayouts ) ) ); + , crg::makeLayoutState( attach->getImageLayout( context->separateDepthStencilLayouts ) ) ); } m_checkViews( m_testCounts - , m_pass - , m_graph + , getPass() + , getGraph() , context , index ); } void doRecordTargetsInto( crg::RecordContext & context , VkCommandBuffer commandBuffer - , uint32_t index ) + , uint32_t index )const { - for ( auto attach : m_pass.targets ) + for ( auto attach : getPass().getTargets() ) { auto view = attach->view( index ); context.runImplicitTransition( commandBuffer, index, view ); context.setLayoutState( crg::resolveView( view, index ) - , crg::makeLayoutState( attach->getImageLayout( m_context.separateDepthStencilLayouts ) ) ); + , crg::makeLayoutState( attach->getImageLayout( context->separateDepthStencilLayouts ) ) ); } } @@ -974,7 +953,7 @@ namespace test , std::move( config ) ); } - void checkDummy( [[maybe_unused]] test::TestCounts & testCounts + void checkDummy( [[maybe_unused]] test::TestCounts const & testCounts , [[maybe_unused]] crg::FramePass const & framePass , [[maybe_unused]] crg::RunnableGraph const & graph , [[maybe_unused]] crg::RecordContext const & context diff --git a/test/Common.hpp b/test/Common.hpp index dde44e0..ea823ef 100644 --- a/test/Common.hpp +++ b/test/Common.hpp @@ -47,10 +47,10 @@ namespace test , uint32_t baseArrayLayer = 0u , uint32_t layerCount = 1u ); crg::GraphContext & getDummyContext(); - std::string checkRunnable( TestCounts & testCounts + std::string checkRunnable( TestCounts const & testCounts , crg::RunnableGraph * runnable ); - inline std::string checkRunnable( TestCounts & testCounts + inline std::string checkRunnable( TestCounts const & testCounts , crg::RunnableGraphPtr const & runnable ) { return checkRunnable( testCounts, runnable.get() ); @@ -69,7 +69,7 @@ namespace test , bool withGroups = {} ); template< typename TypeT > - crg::Id< TypeT > makeId( TypeT const & data ) + crg::Id< TypeT > makeId( [[maybe_unused]] TypeT const & data ) { return { 0u, nullptr }; } @@ -115,7 +115,7 @@ namespace test , crg::RunnableGraph & runGraph , crg::PipelineStageFlags pipelineStageFlags , crg::ru::Config config = {} ); - void checkDummy( test::TestCounts & testCounts + void checkDummy( test::TestCounts const & testCounts , crg::FramePass const & framePass , crg::RunnableGraph const & graph , crg::RecordContext const & context diff --git a/test/TestAttachment.cpp b/test/TestAttachment.cpp index d1f9321..d1db1e4 100644 --- a/test/TestAttachment.cpp +++ b/test/TestAttachment.cpp @@ -9,6 +9,13 @@ namespace { constexpr crg::SamplerDesc defaultSamplerDesc{}; + enum class Binding + { + eUniform, + eSampled, + eStorage, + }; + TEST( Attachment, SampledAttachment ) { testBegin( "testSampledAttachment" ) @@ -23,8 +30,8 @@ namespace tmpAttach1 = tmpAttach2; auto viewAttach = std::move( tmpAttach2 ); pass.addInputSampled( viewAttach, 1u ); - require( pass.sampled.size() == 1u ) - auto attachIt = pass.sampled.begin(); + require( pass.getSampled().size() == 1u ) + auto attachIt = pass.getSampled().begin(); auto const & attachment = attachIt->second; check( attachment.attach->isImage() ) check( attachment.attach->isInput() ) @@ -50,6 +57,47 @@ namespace testEnd() } + TEST( Attachment, SampledAttachmentT ) + { + testBegin( "testSampledAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + auto image = graph.createImage( test::createImage( "Test", crg::PixelFormat::eR32G32B32A32_SFLOAT ) ); + auto view = graph.createView( test::createView( "Test", image ) ); + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + auto tmpAttach1 = crg::Attachment::createDefault( view ); + auto tmpAttach2 = crg::Attachment::createDefault( view ); + tmpAttach2 = std::move( tmpAttach1 ); + tmpAttach1 = tmpAttach2; + auto viewAttach = std::move( tmpAttach2 ); + pass.addInputSampledT( viewAttach, Binding::eSampled ); + require( pass.getSampled().size() == 1u ) + auto attachIt = pass.getSampled().begin(); + auto const & attachment = attachIt->second; + check( attachment.attach->isImage() ) + check( attachment.attach->isInput() ) + check( !attachment.attach->isOutput() ) + check( !attachment.attach->isClearable() ) + check( !attachment.attach->isTransitionImageView() ) + check( !attachment.attach->isTransferImageView() ) + check( !attachment.attach->imageAttach.isDepthStencilTarget() ) + check( !attachment.attach->imageAttach.isDepthTarget() ) + check( !attachment.attach->imageAttach.isStencilTarget() ) + check( !attachment.attach->imageAttach.isStencilInputTarget() ) + check( !attachment.attach->imageAttach.isStencilOutputTarget() ) + check( attachment.attach->name == pass.getGroupName() + "/" + view.data->name + "/Spl" ) + checkEqual( attachment.attach->getLoadOp(), crg::AttachmentLoadOp::eDontCare ) + checkEqual( attachment.attach->getStoreOp(), crg::AttachmentStoreOp::eDontCare ) + checkEqual( attachment.attach->getStencilLoadOp(), crg::AttachmentLoadOp::eDontCare ) + checkEqual( attachment.attach->getStencilStoreOp(), crg::AttachmentStoreOp::eDontCare ) + check( attachment.attach->view() == view ) + check( attachIt->first == uint32_t( Binding::eSampled ) ) + check( attachment.sampler == defaultSamplerDesc ) + checkEqual( attachment.attach->getImageLayout( false ), crg::ImageLayout::eShaderReadOnly ) + checkEqual( attachment.attach->getImageLayout( true ), crg::ImageLayout::eShaderReadOnly ) + testEnd() + } + TEST( Attachment, SampledImage ) { testBegin( "testSampledImage" ) @@ -59,8 +107,8 @@ namespace auto view = graph.createView( test::createView( "Test", image ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addInputSampledImage( view, 1u ); - require( pass.sampled.size() == 1u ) - auto attachIt = pass.sampled.begin(); + require( pass.getSampled().size() == 1u ) + auto attachIt = pass.getSampled().begin(); auto const & attachment = attachIt->second; check( attachment.attach->isImage() ) check( attachment.attach->isInput() ) @@ -86,6 +134,42 @@ namespace testEnd() } + TEST( Attachment, SampledImageT ) + { + testBegin( "testSampledImageT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + auto image = graph.createImage( test::createImage( "Test", crg::PixelFormat::eR32G32B32A32_SFLOAT ) ); + auto view = graph.createView( test::createView( "Test", image ) ); + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + pass.addInputSampledImageT( view, Binding::eSampled ); + require( pass.getSampled().size() == 1u ) + auto attachIt = pass.getSampled().begin(); + auto const & attachment = attachIt->second; + check( attachment.attach->isImage() ) + check( attachment.attach->isInput() ) + check( !attachment.attach->isOutput() ) + check( !attachment.attach->isClearable() ) + check( !attachment.attach->isTransitionImageView() ) + check( !attachment.attach->isTransferImageView() ) + check( !attachment.attach->imageAttach.isDepthStencilTarget() ) + check( !attachment.attach->imageAttach.isDepthTarget() ) + check( !attachment.attach->imageAttach.isStencilTarget() ) + check( !attachment.attach->imageAttach.isStencilInputTarget() ) + check( !attachment.attach->imageAttach.isStencilOutputTarget() ) + check( attachment.attach->name == pass.getGroupName() + "/" + view.data->name + "/Spl" ) + checkEqual( attachment.attach->getLoadOp(), crg::AttachmentLoadOp::eDontCare ) + checkEqual( attachment.attach->getStoreOp(), crg::AttachmentStoreOp::eDontCare ) + checkEqual( attachment.attach->getStencilLoadOp(), crg::AttachmentLoadOp::eDontCare ) + checkEqual( attachment.attach->getStencilStoreOp(), crg::AttachmentStoreOp::eDontCare ) + check( attachment.attach->view() == view ) + check( attachIt->first == uint32_t( Binding::eSampled ) ) + check( attachment.sampler == defaultSamplerDesc ) + checkEqual( attachment.attach->getImageLayout( false ), crg::ImageLayout::eShaderReadOnly ) + checkEqual( attachment.attach->getImageLayout( true ), crg::ImageLayout::eShaderReadOnly ) + testEnd() + } + TEST( Attachment, ImplicitColourAttachment ) { testBegin( "testImplicitColourAttachment" ) @@ -99,8 +183,8 @@ namespace auto viewAttach = crg::Attachment::createDefault( view ); auto imageLayout = crg::ImageLayout::eShaderReadOnly; pass.addImplicit( viewAttach, imageLayout ); - require( pass.inputs.size() == 1u ) - auto attachIt = pass.inputs.begin(); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); auto const & attachment = attachIt->second; check( attachment->isImage() ) check( attachment->isInput() ) @@ -135,8 +219,8 @@ namespace auto viewAttach = crg::Attachment::createDefault( view ); auto imageLayout = crg::ImageLayout::ePreinitialized; pass.addImplicit( viewAttach, imageLayout ); - require( pass.inputs.size() == 1u ) - auto attachIt = pass.inputs.begin(); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); auto const & attachment = attachIt->second; check( attachment->isImage() ) check( attachment->isInput() ) @@ -171,8 +255,8 @@ namespace auto viewAttach = crg::Attachment::createDefault( view ); auto imageLayout = crg::ImageLayout::eShaderReadOnly; pass.addImplicit( viewAttach, imageLayout ); - require( pass.inputs.size() == 1u ) - auto attachIt = pass.inputs.begin(); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); auto const & attachment = attachIt->second; check( attachment->isImage() ) check( attachment->isInput() ) @@ -206,8 +290,8 @@ namespace crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); auto viewAttach = crg::Attachment::createDefault( view ); pass.addInputStorage( viewAttach, 1u ); - require( pass.inputs.size() == 1u ) - auto attachIt = pass.inputs.begin(); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); auto const & attachment = attachIt->second; check( attachment->isImage() ) check( attachment->isInput() ) @@ -232,6 +316,42 @@ namespace testEnd() } + TEST( Attachment, InStorageAttachmentT ) + { + testBegin( "testInStorageAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + auto image = graph.createImage( test::createImage( "Test", crg::PixelFormat::eR32G32B32A32_SFLOAT ) ); + auto view = graph.createView( test::createView( "Test", image ) ); + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + auto viewAttach = crg::Attachment::createDefault( view ); + pass.addInputStorageT( viewAttach, Binding::eStorage ); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); + auto const & attachment = attachIt->second; + check( attachment->isImage() ) + check( attachment->isInput() ) + check( !attachment->isOutput() ) + check( !attachment->isClearable() ) + check( !attachment->isTransitionImageView() ) + check( !attachment->isTransferImageView() ) + check( !attachment->imageAttach.isDepthStencilTarget() ) + check( !attachment->imageAttach.isDepthTarget() ) + check( !attachment->imageAttach.isStencilTarget() ) + check( !attachment->imageAttach.isStencilInputTarget() ) + check( !attachment->imageAttach.isStencilOutputTarget() ) + checkEqual( attachment->name, pass.getGroupName() + "/" + view.data->name + "/IStr" ) + checkEqual( attachment->getLoadOp(), crg::AttachmentLoadOp::eDontCare ) + checkEqual( attachment->getStoreOp(), crg::AttachmentStoreOp::eDontCare ) + checkEqual( attachment->getStencilLoadOp(), crg::AttachmentLoadOp::eDontCare ) + checkEqual( attachment->getStencilStoreOp(), crg::AttachmentStoreOp::eDontCare ) + check( attachment->view() == view ) + check( attachIt->first == uint32_t( Binding::eStorage ) ) + checkEqual( attachment->getImageLayout( false ), crg::ImageLayout::eGeneral ) + checkEqual( attachment->getImageLayout( true ), crg::ImageLayout::eGeneral ) + testEnd() + } + TEST( Attachment, InStorageImage ) { testBegin( "testInStorageImage" ) @@ -241,8 +361,8 @@ namespace auto view = graph.createView( test::createView( "Test", image ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addInputStorageImage( view, 1u ); - require( pass.inputs.size() == 1u ) - auto attachIt = pass.inputs.begin(); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); auto const & attachment = attachIt->second; check( attachment->isImage() ) check( attachment->isInput() ) @@ -267,6 +387,41 @@ namespace testEnd() } + TEST( Attachment, InStorageImageT ) + { + testBegin( "testInStorageImageT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + auto image = graph.createImage( test::createImage( "Test", crg::PixelFormat::eR32G32B32A32_SFLOAT ) ); + auto view = graph.createView( test::createView( "Test", image ) ); + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + pass.addInputStorageImageT( view, Binding::eStorage ); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); + auto const & attachment = attachIt->second; + check( attachment->isImage() ) + check( attachment->isInput() ) + check( !attachment->isOutput() ) + check( !attachment->isClearable() ) + check( !attachment->isTransitionImageView() ) + check( !attachment->isTransferImageView() ) + check( !attachment->imageAttach.isDepthStencilTarget() ) + check( !attachment->imageAttach.isDepthTarget() ) + check( !attachment->imageAttach.isStencilTarget() ) + check( !attachment->imageAttach.isStencilInputTarget() ) + check( !attachment->imageAttach.isStencilOutputTarget() ) + checkEqual( attachment->name, pass.getGroupName() + "/" + view.data->name + "/IStr" ) + checkEqual( attachment->getLoadOp(), crg::AttachmentLoadOp::eDontCare ) + checkEqual( attachment->getStoreOp(), crg::AttachmentStoreOp::eDontCare ) + checkEqual( attachment->getStencilLoadOp(), crg::AttachmentLoadOp::eDontCare ) + checkEqual( attachment->getStencilStoreOp(), crg::AttachmentStoreOp::eDontCare ) + check( attachment->view() == view ) + check( attachIt->first == uint32_t( Binding::eStorage ) ) + checkEqual( attachment->getImageLayout( false ), crg::ImageLayout::eGeneral ) + checkEqual( attachment->getImageLayout( true ), crg::ImageLayout::eGeneral ) + testEnd() + } + TEST( Attachment, InStorageBuffer ) { testBegin( "testInStorageBuffer" ) @@ -276,8 +431,34 @@ namespace auto view = graph.createView( test::createView( "Test", buffer ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addInputStorageBuffer( view, 1u ); - require( pass.inputs.size() == 1u ) - auto attachIt = pass.inputs.begin(); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); + auto const & attachment = attachIt->second; + check( attachment->isBuffer() ) + check( attachment->isInput() ) + check( !attachment->isOutput() ) + check( !attachment->isClearable() ) + check( !attachment->isTransitionImageView() ) + check( !attachment->isTransferImageView() ) + check( attachment->isStorageBuffer() ) + check( attachment->bufferAttach.isStorage() ) + checkEqual( attachment->name, pass.getGroupName() + "/" + view.data->name + "/SB" ) + check( attachment->buffer() == view ) + check( attachIt->first == 1u ) + testEnd() + } + + TEST( Attachment, InStorageBufferT ) + { + testBegin( "testInStorageBufferT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); + auto view = graph.createView( test::createView( "Test", buffer ) ); + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + pass.addInputStorageBufferT( view, Binding::eStorage ); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( attachment->isInput() ) @@ -289,10 +470,75 @@ namespace check( attachment->bufferAttach.isStorage() ) checkEqual( attachment->name, pass.getGroupName() + "/" + view.data->name + "/SB" ) check( attachment->buffer() == view ) + check( attachIt->first == uint32_t( Binding::eStorage ) ) + testEnd() + } + + TEST( Attachment, UniformAttachment ) + { + testBegin( "testUniformAttachment" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); + auto view = graph.createView( test::createView( "Test", buffer ) ); + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + check( &pass.getGraph() == &graph ) + auto tmpAttach1 = crg::Attachment::createDefault( view ); + auto tmpAttach2 = crg::Attachment::createDefault( view ); + tmpAttach2 = std::move( tmpAttach1 ); + tmpAttach1 = tmpAttach2; + auto viewAttach = std::move( tmpAttach2 ); + pass.addInputUniform( viewAttach, 1u ); + require( pass.getUniforms().size() == 1u ) + auto attachIt = pass.getUniforms().begin(); + auto const & attachment = attachIt->second; + check( attachment->isBuffer() ) + check( attachment->isInput() ) + check( !attachment->isOutput() ) + check( !attachment->isClearable() ) + check( !attachment->isTransitionImageView() ) + check( !attachment->isTransferImageView() ) + check( !attachment->isStorageBuffer() ) + check( attachment->isUniformBuffer() ) + check( !attachment->bufferAttach.isStorage() ) + check( attachment->bufferAttach.isUniform() ) + check( attachment->name == pass.getGroupName() + "/" + view.data->name + "/UB" ) check( attachIt->first == 1u ) testEnd() } + TEST( Attachment, UniformAttachmentT ) + { + testBegin( "testUniformAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); + auto view = graph.createView( test::createView( "Test", buffer ) ); + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + auto tmpAttach1 = crg::Attachment::createDefault( view ); + auto tmpAttach2 = crg::Attachment::createDefault( view ); + tmpAttach2 = std::move( tmpAttach1 ); + tmpAttach1 = tmpAttach2; + auto viewAttach = std::move( tmpAttach2 ); + pass.addInputUniformT( viewAttach, Binding::eUniform ); + require( pass.getUniforms().size() == 1u ) + auto attachIt = pass.getUniforms().begin(); + auto const & attachment = attachIt->second; + check( attachment->isBuffer() ) + check( attachment->isInput() ) + check( !attachment->isOutput() ) + check( !attachment->isClearable() ) + check( !attachment->isTransitionImageView() ) + check( !attachment->isTransferImageView() ) + check( !attachment->isStorageBuffer() ) + check( attachment->isUniformBuffer() ) + check( !attachment->bufferAttach.isStorage() ) + check( attachment->bufferAttach.isUniform() ) + check( attachment->name == pass.getGroupName() + "/" + view.data->name + "/UB" ) + check( attachIt->first == uint32_t( Binding::eUniform ) ) + testEnd() + } + TEST( Attachment, OutStorageAttachment ) { testBegin( "testOutStorageAttachment" ) @@ -302,8 +548,8 @@ namespace auto view = graph.createView( test::createView( "Test", image ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addOutputStorageImage( view, 1u ); - require( pass.outputs.size() == 1u ) - auto attachIt = pass.outputs.begin(); + require( pass.getOutputs().size() == 1u ) + auto attachIt = pass.getOutputs().begin(); auto const & attachment = attachIt->second; check( attachment->isImage() ) check( !attachment->isInput() ) @@ -328,6 +574,41 @@ namespace testEnd() } + TEST( Attachment, OutStorageAttachmentT ) + { + testBegin( "testOutStorageAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + auto image = graph.createImage( test::createImage( "Test", crg::PixelFormat::eR32G32B32A32_SFLOAT ) ); + auto view = graph.createView( test::createView( "Test", image ) ); + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + pass.addOutputStorageImageT( view, Binding::eStorage ); + require( pass.getOutputs().size() == 1u ) + auto attachIt = pass.getOutputs().begin(); + auto const & attachment = attachIt->second; + check( attachment->isImage() ) + check( !attachment->isInput() ) + check( attachment->isOutput() ) + check( !attachment->isClearable() ) + check( !attachment->isTransitionImageView() ) + check( !attachment->isTransferImageView() ) + check( !attachment->imageAttach.isDepthStencilTarget() ) + check( !attachment->imageAttach.isDepthTarget() ) + check( !attachment->imageAttach.isStencilTarget() ) + check( !attachment->imageAttach.isStencilInputTarget() ) + check( !attachment->imageAttach.isStencilOutputTarget() ) + checkEqual( attachment->name, pass.getGroupName() + "/" + view.data->name + "/OStr" ) + checkEqual( attachment->getLoadOp(), crg::AttachmentLoadOp::eDontCare ) + checkEqual( attachment->getStoreOp(), crg::AttachmentStoreOp::eDontCare ) + checkEqual( attachment->getStencilLoadOp(), crg::AttachmentLoadOp::eDontCare ) + checkEqual( attachment->getStencilStoreOp(), crg::AttachmentStoreOp::eDontCare ) + check( attachment->view() == view ) + check( attachIt->first == uint32_t( Binding::eStorage ) ) + checkEqual( attachment->getImageLayout( false ), crg::ImageLayout::eGeneral ) + checkEqual( attachment->getImageLayout( true ), crg::ImageLayout::eGeneral ) + testEnd() + } + TEST( Attachment, ClearOutStorageAttachment ) { testBegin( "testClearOutStorageAttachment" ) @@ -337,8 +618,8 @@ namespace auto view = graph.createView( test::createView( "Test", image ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addClearableOutputStorageImage( view, 1u ); - require( pass.outputs.size() == 1u ) - auto attachIt = pass.outputs.begin(); + require( pass.getOutputs().size() == 1u ) + auto attachIt = pass.getOutputs().begin(); auto const & attachment = attachIt->second; check( attachment->isImage() ) check( !attachment->isInput() ) @@ -363,6 +644,41 @@ namespace testEnd() } + TEST( Attachment, ClearOutStorageAttachmentT ) + { + testBegin( "testClearOutStorageAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + auto image = graph.createImage( test::createImage( "Test", crg::PixelFormat::eR32G32B32A32_SFLOAT ) ); + auto view = graph.createView( test::createView( "Test", image ) ); + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + pass.addClearableOutputStorageImageT( view, Binding::eStorage ); + require( pass.getOutputs().size() == 1u ) + auto attachIt = pass.getOutputs().begin(); + auto const & attachment = attachIt->second; + check( attachment->isImage() ) + check( !attachment->isInput() ) + check( attachment->isOutput() ) + check( attachment->isClearable() ) + check( !attachment->isTransitionImageView() ) + check( !attachment->isTransferImageView() ) + check( !attachment->imageAttach.isDepthStencilTarget() ) + check( !attachment->imageAttach.isDepthTarget() ) + check( !attachment->imageAttach.isStencilTarget() ) + check( !attachment->imageAttach.isStencilInputTarget() ) + check( !attachment->imageAttach.isStencilOutputTarget() ) + checkEqual( attachment->name, pass.getGroupName() + "/" + view.data->name + "/COStr" ) + checkEqual( attachment->getLoadOp(), crg::AttachmentLoadOp::eDontCare ) + checkEqual( attachment->getStoreOp(), crg::AttachmentStoreOp::eDontCare ) + checkEqual( attachment->getStencilLoadOp(), crg::AttachmentLoadOp::eDontCare ) + checkEqual( attachment->getStencilStoreOp(), crg::AttachmentStoreOp::eDontCare ) + check( attachment->view() == view ) + check( attachIt->first == uint32_t( Binding::eStorage ) ) + checkEqual( attachment->getImageLayout( false ), crg::ImageLayout::eGeneral ) + checkEqual( attachment->getImageLayout( true ), crg::ImageLayout::eGeneral ) + testEnd() + } + TEST( Attachment, InOutStorageAttachment ) { testBegin( "testInOutStorageAttachment" ) @@ -373,8 +689,44 @@ namespace crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); auto viewAttach = crg::Attachment::createDefault( view ); pass.addInOutStorage( viewAttach, 1u ); - require( pass.inouts.size() == 1u ) - auto attachIt = pass.inouts.begin(); + require( pass.getInouts().size() == 1u ) + auto attachIt = pass.getInouts().begin(); + auto const & attachment = attachIt->second; + check( attachment->isImage() ) + check( attachment->isInput() ) + check( attachment->isOutput() ) + check( !attachment->isClearable() ) + check( !attachment->isTransitionImageView() ) + check( !attachment->isTransferImageView() ) + check( !attachment->imageAttach.isDepthStencilTarget() ) + check( !attachment->imageAttach.isDepthTarget() ) + check( !attachment->imageAttach.isStencilTarget() ) + check( !attachment->imageAttach.isStencilInputTarget() ) + check( !attachment->imageAttach.isStencilOutputTarget() ) + checkEqual( attachment->name, pass.getGroupName() + "/" + view.data->name + "/IOStr" ) + checkEqual( attachment->getLoadOp(), crg::AttachmentLoadOp::eDontCare ) + checkEqual( attachment->getStoreOp(), crg::AttachmentStoreOp::eDontCare ) + checkEqual( attachment->getStencilLoadOp(), crg::AttachmentLoadOp::eDontCare ) + checkEqual( attachment->getStencilStoreOp(), crg::AttachmentStoreOp::eDontCare ) + check( attachment->view() == view ) + check( attachIt->first == 1u ) + checkEqual( attachment->getImageLayout( false ), crg::ImageLayout::eGeneral ) + checkEqual( attachment->getImageLayout( true ), crg::ImageLayout::eGeneral ) + testEnd() + } + + TEST( Attachment, InOutStorageAttachmentT ) + { + testBegin( "testInOutStorageAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + auto image = graph.createImage( test::createImage( "Test", crg::PixelFormat::eR32G32B32A32_SFLOAT ) ); + auto view = graph.createView( test::createView( "Test", image ) ); + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + auto viewAttach = crg::Attachment::createDefault( view ); + pass.addInOutStorageT( viewAttach, Binding::eStorage ); + require( pass.getInouts().size() == 1u ) + auto attachIt = pass.getInouts().begin(); auto const & attachment = attachIt->second; check( attachment->isImage() ) check( attachment->isInput() ) @@ -393,7 +745,7 @@ namespace checkEqual( attachment->getStencilLoadOp(), crg::AttachmentLoadOp::eDontCare ) checkEqual( attachment->getStencilStoreOp(), crg::AttachmentStoreOp::eDontCare ) check( attachment->view() == view ) - check( attachIt->first == 1u ) + check( attachIt->first == uint32_t( Binding::eStorage ) ) checkEqual( attachment->getImageLayout( false ), crg::ImageLayout::eGeneral ) checkEqual( attachment->getImageLayout( true ), crg::ImageLayout::eGeneral ) testEnd() @@ -409,8 +761,8 @@ namespace crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); auto viewAttach = crg::Attachment::createDefault( view ); pass.addInputTransfer( viewAttach ); - require( pass.inputs.size() == 1u ) - auto attachIt = pass.inputs.begin(); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); auto const & attachment = attachIt->second; check( attachment->isImage() ) check( attachment->isInput() ) @@ -443,8 +795,8 @@ namespace auto view = graph.createView( test::createView( "Test", image ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addInputTransferImage( view ); - require( pass.inputs.size() == 1u ) - auto attachIt = pass.inputs.begin(); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); auto const & attachment = attachIt->second; check( attachment->isImage() ) check( attachment->isInput() ) @@ -477,8 +829,8 @@ namespace auto view = graph.createView( test::createView( "Test", buffer ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addInputTransferBuffer( view ); - require( pass.inputs.size() == 1u ) - auto attachIt = pass.inputs.begin(); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( attachment->isInput() ) @@ -501,8 +853,8 @@ namespace auto view = graph.createView( test::createView( "Test", image ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addOutputTransferImage( view ); - require( pass.outputs.size() == 1u ) - auto attachIt = pass.outputs.begin(); + require( pass.getOutputs().size() == 1u ) + auto attachIt = pass.getOutputs().begin(); auto const & attachment = attachIt->second; check( attachment->isImage() ) check( !attachment->isInput() ) @@ -536,8 +888,8 @@ namespace crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); auto viewAttach = crg::Attachment::createDefault( view ); pass.addInOutTransfer( viewAttach ); - require( pass.inouts.size() == 1u ) - auto attachIt = pass.inouts.begin(); + require( pass.getInouts().size() == 1u ) + auto attachIt = pass.getInouts().begin(); auto const & attachment = attachIt->second; check( attachment->isImage() ) check( attachment->isInput() ) @@ -571,8 +923,8 @@ namespace crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); auto viewAttach = crg::Attachment::createDefault( view ); pass.addInputColourTarget( viewAttach ); - require( pass.targets.size() == 1u ) - auto const & attachment = pass.targets[0]; + require( pass.getTargets().size() == 1u ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( attachment->isInput() ) check( !attachment->isOutput() ) @@ -609,8 +961,8 @@ namespace auto view = graph.createView( test::createView( "Test", image ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addInputColourTargetImage( view ); - require( pass.targets.size() == 1u ) - auto const & attachment = pass.targets[0]; + require( pass.getTargets().size() == 1u ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( attachment->isInput() ) check( !attachment->isOutput() ) @@ -647,8 +999,8 @@ namespace auto view = graph.createView( test::createView( "Test", image ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addOutputColourTarget( view ); - require( pass.targets.size() == 1u ) - auto const & attachment = pass.targets[0]; + require( pass.getTargets().size() == 1u ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( !attachment->isInput() ) check( attachment->isOutput() ) @@ -686,8 +1038,8 @@ namespace crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); auto viewAttach = crg::Attachment::createDefault( view ); pass.addInOutColourTarget( viewAttach ); - require( pass.targets.size() == 1u ) - auto const & attachment = pass.targets[0]; + require( pass.getTargets().size() == 1u ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( attachment->isInput() ) check( attachment->isOutput() ) @@ -725,8 +1077,8 @@ namespace crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); auto viewAttach = crg::Attachment::createDefault( view ); pass.addInputDepthTarget( viewAttach ); - require( !pass.targets.empty() ) - auto const & attachment = pass.targets[0]; + require( !pass.getTargets().empty() ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( attachment->isInput() ) check( !attachment->isOutput() ) @@ -763,8 +1115,8 @@ namespace auto view = graph.createView( test::createView( "Test", image ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addInputDepthTargetImage( view ); - require( !pass.targets.empty() ) - auto const & attachment = pass.targets[0]; + require( !pass.getTargets().empty() ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( attachment->isInput() ) check( !attachment->isOutput() ) @@ -801,8 +1153,8 @@ namespace auto view = graph.createView( test::createView( "Test", image ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addOutputDepthTarget( view ); - require( !pass.targets.empty() ) - auto const & attachment = pass.targets[0]; + require( !pass.getTargets().empty() ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( !attachment->isInput() ) check( attachment->isOutput() ) @@ -840,8 +1192,8 @@ namespace crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); auto viewAttach = crg::Attachment::createDefault( view ); pass.addInOutDepthTarget( viewAttach ); - require( !pass.targets.empty() ) - auto const & attachment = pass.targets[0]; + require( !pass.getTargets().empty() ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( attachment->isInput() ) check( attachment->isOutput() ) @@ -879,8 +1231,8 @@ namespace crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); auto viewAttach = crg::Attachment::createDefault( view ); pass.addInputDepthStencilTarget( viewAttach ); - require( !pass.targets.empty() ) - auto const & attachment = pass.targets[0]; + require( !pass.getTargets().empty() ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( attachment->isInput() ) check( !attachment->isOutput() ) @@ -917,8 +1269,8 @@ namespace auto view = graph.createView( test::createView( "Test", image ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addInputDepthStencilTargetImage( view ); - require( !pass.targets.empty() ) - auto const & attachment = pass.targets[0]; + require( !pass.getTargets().empty() ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( attachment->isInput() ) check( !attachment->isOutput() ) @@ -955,8 +1307,8 @@ namespace auto view = graph.createView( test::createView( "Test", image ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addOutputDepthStencilTarget( view ); - require( !pass.targets.empty() ) - auto const & attachment = pass.targets[0]; + require( !pass.getTargets().empty() ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( !attachment->isInput() ) check( attachment->isOutput() ) @@ -994,8 +1346,8 @@ namespace crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); auto viewAttach = crg::Attachment::createDefault( view ); pass.addInOutDepthStencilTarget( viewAttach ); - require( !pass.targets.empty() ) - auto const & attachment = pass.targets[0]; + require( !pass.getTargets().empty() ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( attachment->isInput() ) check( attachment->isOutput() ) @@ -1033,8 +1385,8 @@ namespace crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); auto viewAttach = crg::Attachment::createDefault( view ); pass.addInputStencilTarget( viewAttach ); - require( !pass.targets.empty() ) - auto const & attachment = pass.targets[0]; + require( !pass.getTargets().empty() ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( attachment->isInput() ) check( !attachment->isOutput() ) @@ -1071,8 +1423,8 @@ namespace auto view = graph.createView( test::createView( "Test", image ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addInputStencilTargetImage( view ); - require( !pass.targets.empty() ) - auto const & attachment = pass.targets[0]; + require( !pass.getTargets().empty() ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( attachment->isInput() ) check( !attachment->isOutput() ) @@ -1109,8 +1461,8 @@ namespace auto view = graph.createView( test::createView( "Test", image ) ); crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); pass.addOutputStencilTarget( view ); - require( !pass.targets.empty() ) - auto const & attachment = pass.targets[0]; + require( !pass.getTargets().empty() ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( !attachment->isInput() ) check( attachment->isOutput() ) @@ -1148,8 +1500,8 @@ namespace crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); auto viewAttach = crg::Attachment::createDefault( view ); pass.addInOutStencilTarget( viewAttach ); - require( !pass.targets.empty() ) - auto const & attachment = pass.targets[0]; + require( !pass.getTargets().empty() ) + auto const & attachment = pass.getTargets()[0]; check( attachment->isImage() ) check( attachment->isInput() ) check( attachment->isOutput() ) @@ -1222,8 +1574,8 @@ namespace auto bufferAttach = crg::Attachment::createDefault( bufferv ); crg::AccessState accessState{}; pass.addImplicit( bufferAttach, accessState ); - require( pass.inputs.size() == 1u ) - auto attachIt = pass.inputs.begin(); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); auto const & attachment = attachIt->second; checkEqual( getSize( buffer ), 1024u ) checkEqual( getSize( bufferv ), 1024u ) @@ -1256,8 +1608,8 @@ namespace auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); auto bufferv = graph.createView( test::createView( "Test", buffer ) ); pass.addInputUniformBuffer( bufferv, 1u ); - require( pass.uniforms.size() == 1u ) - auto attachIt = pass.uniforms.begin(); + require( pass.getUniforms().size() == 1u ) + auto attachIt = pass.getUniforms().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( attachment->isInput() ) @@ -1278,6 +1630,37 @@ namespace testEnd() } + TEST( Attachment, UniformBufferAttachmentT ) + { + testBegin( "testUniformBufferAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); + auto bufferv = graph.createView( test::createView( "Test", buffer ) ); + pass.addInputUniformBufferT( bufferv, Binding::eUniform ); + require( pass.getUniforms().size() == 1u ) + auto attachIt = pass.getUniforms().begin(); + auto const & attachment = attachIt->second; + check( attachment->isBuffer() ) + check( attachment->isInput() ) + check( !attachment->isOutput() ) + check( !attachment->isBufferView() ) + check( !attachment->isTransferBuffer() ) + check( !attachment->isClearableBuffer() ) + check( !attachment->isStorageBuffer() ) + check( !attachment->isStorageBufferView() ) + check( attachment->isUniformBuffer() ) + check( !attachment->isUniformBufferView() ) + check( !attachment->isTransitionBuffer() ) + check( !attachment->isTransitionBufferView() ) + check( attachIt->first == uint32_t( Binding::eUniform ) ) + checkEqual( attachment->name, pass.getGroupName() + "/" + buffer.data->name + "/UB" ) + check( attachment->buffer() == bufferv ) + check( attachment->bufferAttach.buffer() == bufferv ) + testEnd() + } + TEST( Attachment, InputStorageBufferAttachment ) { testBegin( "testInputStorageBufferAttachment" ) @@ -1288,8 +1671,8 @@ namespace auto bufferv = graph.createView( test::createView( "Test", buffer ) ); auto bufferAttach = crg::Attachment::createDefault( bufferv ); pass.addInputStorage( bufferAttach, 1u ); - require( pass.inputs.size() == 1u ) - auto attachIt = pass.inputs.begin(); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( attachment->isInput() ) @@ -1310,6 +1693,38 @@ namespace testEnd() } + TEST( Attachment, InputStorageBufferAttachmentT ) + { + testBegin( "testInputStorageBufferAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); + auto bufferv = graph.createView( test::createView( "Test", buffer ) ); + auto bufferAttach = crg::Attachment::createDefault( bufferv ); + pass.addInputStorageT( bufferAttach, Binding::eStorage ); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); + auto const & attachment = attachIt->second; + check( attachment->isBuffer() ) + check( attachment->isInput() ) + check( !attachment->isOutput() ) + check( !attachment->isBufferView() ) + check( !attachment->isTransferBuffer() ) + check( !attachment->isClearableBuffer() ) + check( attachment->isStorageBuffer() ) + check( !attachment->isStorageBufferView() ) + check( !attachment->isUniformBuffer() ) + check( !attachment->isUniformBufferView() ) + check( !attachment->isTransitionBuffer() ) + check( !attachment->isTransitionBufferView() ) + check( attachIt->first == uint32_t( Binding::eStorage ) ) + checkEqual( attachment->name, pass.getGroupName() + "/" + buffer.data->name + "/IStr" ) + check( attachment->buffer() == bufferv ) + check( attachment->bufferAttach.buffer() == bufferv ) + testEnd() + } + TEST( Attachment, OutputStorageBufferAttachment ) { testBegin( "testOutputStorageBufferAttachment" ) @@ -1319,8 +1734,8 @@ namespace auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); auto bufferv = graph.createView( test::createView( "Test", buffer ) ); pass.addOutputStorageBuffer( bufferv, 1u ); - require( pass.outputs.size() == 1u ) - auto attachIt = pass.outputs.begin(); + require( pass.getOutputs().size() == 1u ) + auto attachIt = pass.getOutputs().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( !attachment->isInput() ) @@ -1341,6 +1756,37 @@ namespace testEnd() } + TEST( Attachment, OutputStorageBufferAttachmentT ) + { + testBegin( "testOutputStorageBufferAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); + auto bufferv = graph.createView( test::createView( "Test", buffer ) ); + pass.addOutputStorageBufferT( bufferv, Binding::eStorage ); + require( pass.getOutputs().size() == 1u ) + auto attachIt = pass.getOutputs().begin(); + auto const & attachment = attachIt->second; + check( attachment->isBuffer() ) + check( !attachment->isInput() ) + check( attachment->isOutput() ) + check( !attachment->isBufferView() ) + check( !attachment->isTransferBuffer() ) + check( !attachment->isClearableBuffer() ) + check( attachment->isStorageBuffer() ) + check( !attachment->isStorageBufferView() ) + check( !attachment->isUniformBuffer() ) + check( !attachment->isUniformBufferView() ) + check( !attachment->isTransitionBuffer() ) + check( !attachment->isTransitionBufferView() ) + check( attachIt->first == uint32_t( Binding::eStorage ) ) + checkEqual( attachment->name, pass.getGroupName() + "/" + buffer.data->name + "/OSB" ) + check( attachment->buffer() == bufferv ) + check( attachment->bufferAttach.buffer() == bufferv ) + testEnd() + } + TEST( Attachment, ClearableOutputStorageBufferAttachment ) { testBegin( "testClearableOutputStorageBufferAttachment" ) @@ -1350,8 +1796,8 @@ namespace auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); auto bufferv = graph.createView( test::createView( "Test", buffer ) ); pass.addClearableOutputStorageBuffer( bufferv, 1u ); - require( pass.outputs.size() == 1u ) - auto attachIt = pass.outputs.begin(); + require( pass.getOutputs().size() == 1u ) + auto attachIt = pass.getOutputs().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( !attachment->isInput() ) @@ -1372,6 +1818,37 @@ namespace testEnd() } + TEST( Attachment, ClearableOutputStorageBufferAttachmentT ) + { + testBegin( "testClearableOutputStorageBufferAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); + auto bufferv = graph.createView( test::createView( "Test", buffer ) ); + pass.addClearableOutputStorageBufferT( bufferv, Binding::eStorage ); + require( pass.getOutputs().size() == 1u ) + auto attachIt = pass.getOutputs().begin(); + auto const & attachment = attachIt->second; + check( attachment->isBuffer() ) + check( !attachment->isInput() ) + check( attachment->isOutput() ) + check( !attachment->isBufferView() ) + check( !attachment->isTransferBuffer() ) + check( attachment->isClearableBuffer() ) + check( attachment->isStorageBuffer() ) + check( !attachment->isStorageBufferView() ) + check( !attachment->isUniformBuffer() ) + check( !attachment->isUniformBufferView() ) + check( !attachment->isTransitionBuffer() ) + check( !attachment->isTransitionBufferView() ) + check( attachIt->first == uint32_t( Binding::eStorage ) ) + checkEqual( attachment->name, pass.getGroupName() + "/" + buffer.data->name + "/OSB" ) + check( attachment->buffer() == bufferv ) + check( attachment->bufferAttach.buffer() == bufferv ) + testEnd() + } + TEST( Attachment, InOutStorageBufferAttachment ) { testBegin( "testInOutStorageBufferAttachment" ) @@ -1382,8 +1859,8 @@ namespace auto bufferv = graph.createView( test::createView( "Test", buffer ) ); auto bufferAttach = crg::Attachment::createDefault( bufferv ); pass.addInOutStorage( bufferAttach, 1u ); - require( pass.inouts.size() == 1u ) - auto attachIt = pass.inouts.begin(); + require( pass.getInouts().size() == 1u ) + auto attachIt = pass.getInouts().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( attachment->isInput() ) @@ -1404,6 +1881,38 @@ namespace testEnd() } + TEST( Attachment, InOutStorageBufferAttachmentT ) + { + testBegin( "testInOutStorageBufferAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); + auto bufferv = graph.createView( test::createView( "Test", buffer ) ); + auto bufferAttach = crg::Attachment::createDefault( bufferv ); + pass.addInOutStorageT( bufferAttach, Binding::eStorage ); + require( pass.getInouts().size() == 1u ) + auto attachIt = pass.getInouts().begin(); + auto const & attachment = attachIt->second; + check( attachment->isBuffer() ) + check( attachment->isInput() ) + check( attachment->isOutput() ) + check( !attachment->isBufferView() ) + check( !attachment->isTransferBuffer() ) + check( !attachment->isClearableBuffer() ) + check( attachment->isStorageBuffer() ) + check( !attachment->isStorageBufferView() ) + check( !attachment->isUniformBuffer() ) + check( !attachment->isUniformBufferView() ) + check( !attachment->isTransitionBuffer() ) + check( !attachment->isTransitionBufferView() ) + check( attachIt->first == uint32_t( Binding::eStorage ) ) + checkEqual( attachment->name, pass.getGroupName() + "/" + buffer.data->name + "/IOStr" ) + check( attachment->buffer() == bufferv ) + check( attachment->bufferAttach.buffer() == bufferv ) + testEnd() + } + TEST( Attachment, ImplicitBufferViewAttachment ) { testBegin( "testImplicitBufferViewAttachment" ) @@ -1414,8 +1923,8 @@ namespace auto bufferv = graph.createView( test::createView( "Test", buffer, crg::PixelFormat::eR16G16B16A16_SFLOAT ) ); auto bufferAttach = crg::Attachment::createDefault( bufferv ); pass.addImplicit( bufferAttach, crg::AccessState{} ); - require( pass.inputs.size() == 1u ) - auto attachIt = pass.inputs.begin(); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( attachment->isInput() ) @@ -1444,8 +1953,8 @@ namespace auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); auto bufferv = graph.createView( test::createView( "Test", buffer, crg::PixelFormat::eR16G16B16A16_SFLOAT ) ); pass.addInputUniformBuffer( bufferv, 1u ); - require( !pass.uniforms.empty() ) - auto attachIt = pass.uniforms.begin(); + require( !pass.getUniforms().empty() ) + auto attachIt = pass.getUniforms().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( attachment->isInput() ) @@ -1466,6 +1975,37 @@ namespace testEnd() } + TEST( Attachment, UniformBufferViewAttachmentT ) + { + testBegin( "testUniformBufferViewAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); + auto bufferv = graph.createView( test::createView( "Test", buffer, crg::PixelFormat::eR16G16B16A16_SFLOAT ) ); + pass.addInputUniformBufferT( bufferv, Binding::eUniform ); + require( !pass.getUniforms().empty() ) + auto attachIt = pass.getUniforms().begin(); + auto const & attachment = attachIt->second; + check( attachment->isBuffer() ) + check( attachment->isInput() ) + check( !attachment->isOutput() ) + check( attachment->isBufferView() ) + check( !attachment->isTransferBuffer() ) + check( !attachment->isClearableBuffer() ) + check( !attachment->isStorageBuffer() ) + check( !attachment->isStorageBufferView() ) + check( attachment->isUniformBuffer() ) + check( attachment->isUniformBufferView() ) + check( !attachment->isTransitionBuffer() ) + check( !attachment->isTransitionBufferView() ) + check( attachIt->first == uint32_t( Binding::eUniform ) ) + checkEqual( attachment->name, pass.getGroupName() + "/" + buffer.data->name + "/UB" ) + check( attachment->buffer() == bufferv ) + check( attachment->bufferAttach.buffer() == bufferv ) + testEnd() + } + TEST( Attachment, InputStorageBufferViewAttachment ) { testBegin( "testInputStorageBufferViewAttachment" ) @@ -1476,8 +2016,8 @@ namespace auto bufferv = graph.createView( test::createView( "Test", buffer, crg::PixelFormat::eR16G16B16A16_SFLOAT ) ); auto bufferAttach = crg::Attachment::createDefault( bufferv ); pass.addInputStorage( bufferAttach, 1u ); - require( pass.inputs.size() == 1u ) - auto attachIt = pass.inputs.begin(); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( attachment->isInput() ) @@ -1498,6 +2038,38 @@ namespace testEnd() } + TEST( Attachment, InputStorageBufferViewAttachmentT ) + { + testBegin( "testInputStorageBufferViewAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); + auto bufferv = graph.createView( test::createView( "Test", buffer, crg::PixelFormat::eR16G16B16A16_SFLOAT ) ); + auto bufferAttach = crg::Attachment::createDefault( bufferv ); + pass.addInputStorageT( bufferAttach, Binding::eStorage ); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); + auto const & attachment = attachIt->second; + check( attachment->isBuffer() ) + check( attachment->isInput() ) + check( !attachment->isOutput() ) + check( attachment->isBufferView() ) + check( !attachment->isTransferBuffer() ) + check( !attachment->isClearableBuffer() ) + check( attachment->isStorageBuffer() ) + check( attachment->isStorageBufferView() ) + check( !attachment->isUniformBuffer() ) + check( !attachment->isUniformBufferView() ) + check( !attachment->isTransitionBuffer() ) + check( !attachment->isTransitionBufferView() ) + check( attachIt->first == uint32_t( Binding::eStorage ) ) + checkEqual( attachment->name, pass.getGroupName() + "/" + buffer.data->name + "/IStr" ) + check( attachment->buffer() == bufferv ) + check( attachment->bufferAttach.buffer() == bufferv ) + testEnd() + } + TEST( Attachment, OutputStorageBufferViewAttachment ) { testBegin( "testOutputStorageBufferViewAttachment" ) @@ -1507,8 +2079,8 @@ namespace auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); auto bufferv = graph.createView( test::createView( "Test", buffer, crg::PixelFormat::eR16G16B16A16_SFLOAT ) ); pass.addOutputStorageBuffer( bufferv, 1u ); - require( pass.outputs.size() == 1u ) - auto attachIt = pass.outputs.begin(); + require( pass.getOutputs().size() == 1u ) + auto attachIt = pass.getOutputs().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( !attachment->isInput() ) @@ -1529,6 +2101,37 @@ namespace testEnd() } + TEST( Attachment, OutputStorageBufferViewAttachmentT ) + { + testBegin( "testOutputStorageBufferViewAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); + auto bufferv = graph.createView( test::createView( "Test", buffer, crg::PixelFormat::eR16G16B16A16_SFLOAT ) ); + pass.addOutputStorageBufferT( bufferv, Binding::eStorage ); + require( pass.getOutputs().size() == 1u ) + auto attachIt = pass.getOutputs().begin(); + auto const & attachment = attachIt->second; + check( attachment->isBuffer() ) + check( !attachment->isInput() ) + check( attachment->isOutput() ) + check( attachment->isBufferView() ) + check( !attachment->isTransferBuffer() ) + check( !attachment->isClearableBuffer() ) + check( attachment->isStorageBuffer() ) + check( attachment->isStorageBufferView() ) + check( !attachment->isUniformBuffer() ) + check( !attachment->isUniformBufferView() ) + check( !attachment->isTransitionBuffer() ) + check( !attachment->isTransitionBufferView() ) + check( attachIt->first == uint32_t( Binding::eStorage ) ) + checkEqual( attachment->name, pass.getGroupName() + "/" + buffer.data->name + "/OSB" ) + check( attachment->buffer() == bufferv ) + check( attachment->bufferAttach.buffer() == bufferv ) + testEnd() + } + TEST( Attachment, ClearableOutputStorageBufferViewAttachment ) { testBegin( "testClearableOutputStorageBufferViewAttachment" ) @@ -1538,8 +2141,8 @@ namespace auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); auto bufferv = graph.createView( test::createView( "Test", buffer, crg::PixelFormat::eR16G16B16A16_SFLOAT ) ); pass.addClearableOutputStorageBuffer( bufferv, 1u ); - require( pass.outputs.size() == 1u ) - auto attachIt = pass.outputs.begin(); + require( pass.getOutputs().size() == 1u ) + auto attachIt = pass.getOutputs().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( !attachment->isInput() ) @@ -1560,6 +2163,37 @@ namespace testEnd() } + TEST( Attachment, ClearableOutputStorageBufferViewAttachmentT ) + { + testBegin( "testClearableOutputStorageBufferViewAttachmentT" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); + auto bufferv = graph.createView( test::createView( "Test", buffer, crg::PixelFormat::eR16G16B16A16_SFLOAT ) ); + pass.addClearableOutputStorageBufferT( bufferv, Binding::eStorage ); + require( pass.getOutputs().size() == 1u ) + auto attachIt = pass.getOutputs().begin(); + auto const & attachment = attachIt->second; + check( attachment->isBuffer() ) + check( !attachment->isInput() ) + check( attachment->isOutput() ) + check( attachment->isBufferView() ) + check( !attachment->isTransferBuffer() ) + check( attachment->isClearableBuffer() ) + check( attachment->isStorageBuffer() ) + check( attachment->isStorageBufferView() ) + check( !attachment->isUniformBuffer() ) + check( !attachment->isUniformBufferView() ) + check( !attachment->isTransitionBuffer() ) + check( !attachment->isTransitionBufferView() ) + check( attachIt->first == uint32_t( Binding::eStorage ) ) + checkEqual( attachment->name, pass.getGroupName() + "/" + buffer.data->name + "/OSB" ) + check( attachment->buffer() == bufferv ) + check( attachment->bufferAttach.buffer() == bufferv ) + testEnd() + } + TEST( Attachment, InOutStorageBufferViewAttachment ) { testBegin( "testInOutStorageBufferViewAttachment" ) @@ -1570,8 +2204,8 @@ namespace auto bufferv = graph.createView( test::createView( "Test", buffer, crg::PixelFormat::eR16G16B16A16_SFLOAT ) ); auto bufferAttach = crg::Attachment::createDefault( bufferv ); pass.addInOutStorage( bufferAttach, 1u ); - require( pass.inouts.size() == 1u ) - auto attachIt = pass.inouts.begin(); + require( pass.getInouts().size() == 1u ) + auto attachIt = pass.getInouts().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( attachment->isInput() ) @@ -1592,6 +2226,38 @@ namespace testEnd() } + TEST( Attachment, InOutStorageBufferViewAttachmentT ) + { + testBegin( "testInOutStorageBufferViewAttachment" ) + crg::ResourceHandler handler; + crg::FrameGraph graph{ handler, testCounts.testName }; + crg::FramePass & pass = graph.createPass( "test", crg::RunnablePassCreator{} ); + auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); + auto bufferv = graph.createView( test::createView( "Test", buffer, crg::PixelFormat::eR16G16B16A16_SFLOAT ) ); + auto bufferAttach = crg::Attachment::createDefault( bufferv ); + pass.addInOutStorageT( bufferAttach, Binding::eStorage ); + require( pass.getInouts().size() == 1u ) + auto attachIt = pass.getInouts().begin(); + auto const & attachment = attachIt->second; + check( attachment->isBuffer() ) + check( attachment->isInput() ) + check( attachment->isOutput() ) + check( attachment->isBufferView() ) + check( !attachment->isTransferBuffer() ) + check( !attachment->isClearableBuffer() ) + check( attachment->isStorageBuffer() ) + check( attachment->isStorageBufferView() ) + check( !attachment->isUniformBuffer() ) + check( !attachment->isUniformBufferView() ) + check( !attachment->isTransitionBuffer() ) + check( !attachment->isTransitionBufferView() ) + check( attachIt->first == uint32_t( Binding::eStorage ) ) + checkEqual( attachment->name, pass.getGroupName() + "/" + buffer.data->name + "/IOStr" ) + check( attachment->buffer() == bufferv ) + check( attachment->bufferAttach.buffer() == bufferv ) + testEnd() + } + TEST( Attachment, InputTransferBufferAttachment ) { testBegin( "testInputTransferBufferAttachment" ) @@ -1602,8 +2268,8 @@ namespace auto bufferv = graph.createView( test::createView( "Test", buffer ) ); auto bufferAttach = crg::Attachment::createDefault( bufferv ); pass.addInputTransfer( bufferAttach ); - require( pass.inputs.size() == 1u ) - auto attachIt = pass.inputs.begin(); + require( pass.getInputs().size() == 1u ) + auto attachIt = pass.getInputs().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( attachment->isInput() ) @@ -1632,8 +2298,8 @@ namespace auto buffer = graph.createBuffer( test::createBuffer( "Test" ) ); auto bufferv = graph.createView( test::createView( "Test", buffer ) ); pass.addOutputTransferBuffer( bufferv ); - require( pass.outputs.size() == 1u ) - auto attachIt = pass.outputs.begin(); + require( pass.getOutputs().size() == 1u ) + auto attachIt = pass.getOutputs().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( !attachment->isInput() ) @@ -1663,8 +2329,8 @@ namespace auto bufferv = graph.createView( test::createView( "Test", buffer ) ); auto bufferAttach = crg::Attachment::createDefault( bufferv ); pass.addInOutTransfer( bufferAttach ); - require( pass.inouts.size() == 1u ) - auto attachIt = pass.inouts.begin(); + require( pass.getInouts().size() == 1u ) + auto attachIt = pass.getInouts().begin(); auto const & attachment = attachIt->second; check( attachment->isBuffer() ) check( attachment->isInput() ) @@ -1727,20 +2393,20 @@ namespace { // Single buffer attachment in list auto attachment = crg::Attachment::createDefault( buffer1v ); - checkThrow( attachment.getSource( 1u ), crg::Exception ); - check( attachment.getSource( 0u ) == &attachment ); - check( graph.mergeAttachments( { &attachment } ) == &attachment ); + checkThrow( attachment.getSource( 1u ), crg::Exception ) + check( attachment.getSource( 0u ) == &attachment ) + check( graph.mergeAttachments( { &attachment } ) == &attachment ) } { // Single image attachment in list auto attachment = crg::Attachment::createDefault( image1v ); - check( graph.mergeAttachments( { &attachment } ) == &attachment ); + check( graph.mergeAttachments( { &attachment } ) == &attachment ) } { // Mixed attachments in list auto attachment1 = crg::Attachment::createDefault( image1v ); auto attachment2 = crg::Attachment::createDefault( buffer1v ); - checkThrow( graph.mergeAttachments( { &attachment1, &attachment2 } ), crg::Exception ); + checkThrow( graph.mergeAttachments( { &attachment1, &attachment2 } ), crg::Exception ) } { // Empty image attachments in list @@ -1748,7 +2414,7 @@ namespace attachment1.imageAttach.views.clear(); auto attachment2 = crg::Attachment::createDefault( image2v ); attachment2.imageAttach.views.clear(); - checkThrow( graph.mergeAttachments( { &attachment1, &attachment2 } ), crg::Exception ); + checkThrow( graph.mergeAttachments( { &attachment1, &attachment2 } ), crg::Exception ) } { // Empty buffer attachments in list @@ -1756,27 +2422,27 @@ namespace attachment1.bufferAttach.buffers.clear(); auto attachment2 = crg::Attachment::createDefault( buffer2v ); attachment2.bufferAttach.buffers.clear(); - checkThrow( graph.mergeAttachments( { &attachment1, &attachment2 } ), crg::Exception ); + checkThrow( graph.mergeAttachments( { &attachment1, &attachment2 } ), crg::Exception ) } { // Image attachments with different pass count auto attachment1 = crg::Attachment::createDefault( image1v ); auto attachment2 = crg::Attachment::createDefault( image2v ); attachment2.imageAttach.views.clear(); - checkThrow( graph.mergeAttachments( { &attachment1, &attachment2 } ), crg::Exception ); + checkThrow( graph.mergeAttachments( { &attachment1, &attachment2 } ), crg::Exception ) } { // Buffer attachments with different pass count auto attachment1 = crg::Attachment::createDefault( buffer1v ); auto attachment2 = crg::Attachment::createDefault( buffer2v ); attachment2.bufferAttach.buffers.clear(); - checkThrow( graph.mergeAttachments( { &attachment1, &attachment2 } ), crg::Exception ); + checkThrow( graph.mergeAttachments( { &attachment1, &attachment2 } ), crg::Exception ) } { // Image attachments auto attachment1 = crg::Attachment::createDefault( image1v ); auto attachment2 = crg::Attachment::createDefault( image2v ); - checkNoThrow( graph.mergeAttachments( { &attachment1, &attachment2 } ) ); + checkNoThrow( graph.mergeAttachments( { &attachment1, &attachment2 } ) ) auto & attachment = *graph.mergeAttachments( { &attachment1, &attachment2 } ); check( attachment.isImage() ) check( !attachment.isInput() ) @@ -1809,7 +2475,7 @@ namespace // Buffer attachments auto attachment1 = crg::Attachment::createDefault( buffer1v ); auto attachment2 = crg::Attachment::createDefault( buffer2v ); - checkNoThrow( graph.mergeAttachments( { &attachment1, &attachment2 } ) ); + checkNoThrow( graph.mergeAttachments( { &attachment1, &attachment2 } ) ) auto & attachment = *graph.mergeAttachments( { &attachment1, &attachment2 } ); check( attachment.isBuffer() ) check( !attachment.isInput() ) diff --git a/test/TestBases.cpp b/test/TestBases.cpp index 51b6276..0659b06 100644 --- a/test/TestBases.cpp +++ b/test/TestBases.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -76,21 +77,25 @@ TEST( Bases, BaseFuncs ) check( crg::getStageMask( crg::ImageLayout::eTransferDst ) == crg::PipelineStageFlags::eTransfer ) for ( uint32_t i = 0; i <= uint32_t( crg::PixelFormat::eASTC_12x12_SRGB_BLOCK ); ++i ) - checkNoThrow( getName( crg::PixelFormat( i ) ) ); + checkNoThrow( getName( crg::PixelFormat( i ) ) ) for ( uint32_t i = 0; i <= uint32_t( crg::FilterMode::eLinear ); ++i ) - checkNoThrow( getName( crg::FilterMode( i ) ) ); + checkNoThrow( getName( crg::FilterMode( i ) ) ) for ( uint32_t i = 0; i <= uint32_t( crg::MipmapMode::eLinear ); ++i ) - checkNoThrow( getName( crg::MipmapMode( i ) ) ); + checkNoThrow( getName( crg::MipmapMode( i ) ) ) for ( uint32_t i = 0; i <= uint32_t( crg::WrapMode::eMirrorClampToEdge ); ++i ) - checkNoThrow( getName( crg::WrapMode( i ) ) ); + checkNoThrow( getName( crg::WrapMode( i ) ) ) auto vb1 = crg::VertexBuffer{ handler.createViewId( test::createView( "vtx1", handler.createBufferId( test::createBuffer( "vtx1" ) ) ) ) }; auto vb2 = crg::VertexBuffer{ handler.createViewId( test::createView( "vtx2", handler.createBufferId( test::createBuffer( "vtx2" ) ) ) ) }; vb2 = std::move( vb1 ); + crg::GetPrimitiveCountCallback cb0; + crg::GetPrimitiveCountCallback cb1; + cb1 = cb0; + testEnd() } @@ -102,64 +107,64 @@ TEST( Bases, ClearValues ) crg::ClearColorValue clearColorFloat32{ std::array< float, 4u >{ 1.0f, 2.0f, 3.0f, 4.0f } }; crg::ClearDepthStencilValue clearDepthStencil{ 1.0f, 255u }; - checkNoThrow( getClearDepthStencilValue( crg::ClearValue{ clearColorFloat32 } ) ); - checkNoThrow( getClearColorValue( crg::ClearValue{ clearDepthStencil } ) ); - checkNoThrow( getClearColorValue( crg::ClearValue{ clearColorFloat32 } ) ); - checkNoThrow( getClearDepthStencilValue( crg::ClearValue{ clearDepthStencil } ) ); - checkNoThrow( convert( crg::ClearValue{ clearColorFloat32 } ) ); - checkNoThrow( convert( crg::ClearValue{ clearDepthStencil } ) ); - check( clearColorFloat32.isFloat32() ); - check( !clearColorFloat32.isInt32() ); - check( !clearColorFloat32.isUInt32() ); - check( !clearColorUInt32.isFloat32() ); - check( !clearColorUInt32.isInt32() ); - check( clearColorUInt32.isUInt32() ); - check( !clearColorInt32.isFloat32() ); - check( clearColorInt32.isInt32() ); - check( !clearColorInt32.isUInt32() ); - check( crg::ClearValue{ clearColorFloat32 }.isColor() ); - check( !crg::ClearValue{ clearColorFloat32 }.isDepthStencil() ); - check( !crg::ClearValue{ clearDepthStencil }.isColor() ); - check( crg::ClearValue{ clearDepthStencil }.isDepthStencil() ); + checkNoThrow( getClearDepthStencilValue( crg::ClearValue{ clearColorFloat32 } ) ) + checkNoThrow( getClearColorValue( crg::ClearValue{ clearDepthStencil } ) ) + checkNoThrow( getClearColorValue( crg::ClearValue{ clearColorFloat32 } ) ) + checkNoThrow( getClearDepthStencilValue( crg::ClearValue{ clearDepthStencil } ) ) + checkNoThrow( convert( crg::ClearValue{ clearColorFloat32 } ) ) + checkNoThrow( convert( crg::ClearValue{ clearDepthStencil } ) ) + check( clearColorFloat32.isFloat32() ) + check( !clearColorFloat32.isInt32() ) + check( !clearColorFloat32.isUInt32() ) + check( !clearColorUInt32.isFloat32() ) + check( !clearColorUInt32.isInt32() ) + check( clearColorUInt32.isUInt32() ) + check( !clearColorInt32.isFloat32() ) + check( clearColorInt32.isInt32() ) + check( !clearColorInt32.isUInt32() ) + check( crg::ClearValue{ clearColorFloat32 }.isColor() ) + check( !crg::ClearValue{ clearColorFloat32 }.isDepthStencil() ) + check( !crg::ClearValue{ clearDepthStencil }.isColor() ) + check( crg::ClearValue{ clearDepthStencil }.isDepthStencil() ) { auto vkClearColorFloat32 = crg::convert( clearColorFloat32 ); for ( uint32_t i = 0; i < 4u; ++i ) - check( vkClearColorFloat32.float32[i] == clearColorFloat32.float32()[i] ); + check( vkClearColorFloat32.float32[i] == clearColorFloat32.float32()[i] ) } { auto vkClearColorFloat32 = crg::convert( crg::ClearValue{ clearColorFloat32 } ); for ( uint32_t i = 0; i < 4u; ++i ) - check( vkClearColorFloat32.color.float32[i] == clearColorFloat32.float32()[i] ); + check( vkClearColorFloat32.color.float32[i] == clearColorFloat32.float32()[i] ) } { auto vkClearColorInt32 = crg::convert( clearColorInt32 ); for ( uint32_t i = 0; i < 4u; ++i ) - check( vkClearColorInt32.int32[i] == clearColorInt32.int32()[i] ); + check( vkClearColorInt32.int32[i] == clearColorInt32.int32()[i] ) } { auto vkClearColorInt32 = crg::convert( crg::ClearValue{ clearColorInt32 } ); for ( uint32_t i = 0; i < 4u; ++i ) - check( vkClearColorInt32.color.int32[i] == clearColorInt32.int32()[i] ); + check( vkClearColorInt32.color.int32[i] == clearColorInt32.int32()[i] ) } { auto vkClearColorUInt32 = crg::convert( clearColorUInt32 ); for ( uint32_t i = 0; i < 4u; ++i ) - check( vkClearColorUInt32.uint32[i] == clearColorUInt32.uint32()[i] ); + check( vkClearColorUInt32.uint32[i] == clearColorUInt32.uint32()[i] ) } { auto vkClearColorUInt32 = crg::convert( crg::ClearValue{ clearColorUInt32 } ); for ( uint32_t i = 0; i < 4u; ++i ) - check( vkClearColorUInt32.color.uint32[i] == clearColorUInt32.uint32()[i] ); + check( vkClearColorUInt32.color.uint32[i] == clearColorUInt32.uint32()[i] ) } { auto vkClearDepthStencil = crg::convert( clearDepthStencil ); - check( vkClearDepthStencil.depth == clearDepthStencil.depth ); - check( vkClearDepthStencil.stencil == clearDepthStencil.stencil ); + check( vkClearDepthStencil.depth == clearDepthStencil.depth ) + check( vkClearDepthStencil.stencil == clearDepthStencil.stencil ) } { auto vkClearDepthStencil = crg::convert( crg::ClearValue{ clearDepthStencil } ); - check( vkClearDepthStencil.depthStencil.depth == clearDepthStencil.depth ); - check( vkClearDepthStencil.depthStencil.stencil == clearDepthStencil.stencil ); + check( vkClearDepthStencil.depthStencil.depth == clearDepthStencil.depth ) + check( vkClearDepthStencil.depthStencil.stencil == clearDepthStencil.stencil ) } testEnd() @@ -243,7 +248,6 @@ TEST( Bases, Signal ) TEST( Bases, Exception ) { testBegin( "testException" ) - auto & context = getContext(); try { CRG_Exception( "Coin !!" ); @@ -287,6 +291,11 @@ TEST( Bases, FramePassTimer ) return res; } ); testPass.addClearableOutputStorageBuffer( bufferv, 1u ); + + crg::FramePassNode node1{ testPass }; + crg::FramePassNode node2{ testPass }; + node2 = std::move( node1 ); + checkThrow( crg::checkVkResult( VK_ERROR_VALIDATION_FAILED_EXT, std::string{ "Test" } ), crg::Exception ) auto runnable = graph.compile( getContext() ); test::checkRunnable( testCounts, runnable ); @@ -300,10 +309,10 @@ TEST( Bases, FramePassTimer ) timer.retrieveGpuTime(); auto end = timer.getCpuTime(); auto total = ( end - save ) + timer.getGpuTime(); - check( total >= std::chrono::milliseconds{ 10u } ); + check( total >= std::chrono::milliseconds{ 10u } ) timer.reset(); - check( timer.getCpuTime() >= std::chrono::milliseconds{ 0u } ); - check( timer.getGpuTime() >= std::chrono::milliseconds{ 0u } ); + check( timer.getCpuTime() >= std::chrono::milliseconds{ 0u } ) + check( timer.getGpuTime() >= std::chrono::milliseconds{ 0u } ) } { crg::FramePassTimer timer{ getContext(), "test", crg::TimerScope::eUpdate }; @@ -316,10 +325,10 @@ TEST( Bases, FramePassTimer ) timer.retrieveGpuTime(); auto end = timer.getCpuTime(); auto total = ( end - save ) + timer.getGpuTime(); - check( total >= std::chrono::milliseconds{ 10u } ); + check( total >= std::chrono::milliseconds{ 10u } ) timer.reset(); - check( timer.getCpuTime() >= std::chrono::milliseconds{ 0u } ); - check( timer.getGpuTime() >= std::chrono::milliseconds{ 0u } ); + check( timer.getCpuTime() >= std::chrono::milliseconds{ 0u } ) + check( timer.getGpuTime() >= std::chrono::milliseconds{ 0u } ) } { auto timer = std::make_unique< crg::FramePassTimer >( getContext(), "test", crg::TimerScope::eUpdate ); @@ -365,7 +374,7 @@ TEST( Bases, ImplicitActions ) , crg::GraphContext & context , crg::RunnableGraph & runGraph ) { - auto depthIt = framePass.targets.begin(); + auto depthIt = framePass.getTargets().begin(); auto colourIt = std::next( depthIt ); auto extent3D = getExtent( colour2v ); auto extent2D = crg::Extent2D{ extent3D.width, extent3D.height }; @@ -444,7 +453,7 @@ TEST( Bases, PrePassActions ) , crg::GraphContext & context , crg::RunnableGraph & runGraph ) { - auto depthIt = framePass.targets.begin(); + auto depthIt = framePass.getTargets().begin(); auto colourIt = std::next( depthIt ); auto extent3D = getExtent( colour2v ); auto extent2D = crg::Extent2D{ extent3D.width, extent3D.height }; @@ -511,7 +520,7 @@ TEST( Bases, PostPassActions ) , crg::GraphContext & context , crg::RunnableGraph & runGraph ) { - auto depthIt = framePass.targets.begin(); + auto depthIt = framePass.getTargets().begin(); auto colourIt = std::next( depthIt ); auto extent3D = getExtent( colour2v ); auto extent2D = crg::Extent2D{ extent3D.width, extent3D.height }; @@ -578,7 +587,7 @@ TEST( Bases, GraphDeps ) } ); auto coloura = testPass1.addOutputColourTarget( colourv ); auto iocoloura = testPass1.addOutputColourTarget( iocolourv ); - auto bufferAttach = testPass1.addOutputStorageBuffer( bufferv, 0u ); + testPass1.addOutputStorageBuffer( bufferv, 0u ); graph1.addOutput( colourv, crg::makeLayoutState( crg::ImageLayout::eShaderReadOnly ) ); graph1.addOutput( iocolourv, crg::makeLayoutState( crg::ImageLayout::eColorAttachment ) ); check( graph1.getOutputLayoutState( colourv ).layout == crg::ImageLayout::eShaderReadOnly ) @@ -843,7 +852,7 @@ TEST( Bases, GraphNodes ) crg::RootNode root{ graph }; check( getFramePass( root ) == nullptr ) - auto & testPass = graph.createPass( "testPass" + auto const & testPass = graph.createPass( "testPass" , [&testCounts]( crg::FramePass const & framePass , crg::GraphContext & context , crg::RunnableGraph & runGraph ) diff --git a/test/TestRenderGraph.cpp b/test/TestRenderGraph.cpp index c8a68ea..a516909 100644 --- a/test/TestRenderGraph.cpp +++ b/test/TestRenderGraph.cpp @@ -22,7 +22,7 @@ namespace , crg::RecordContext const & context , uint32_t index ) { - for ( auto attach : framePass.targets ) + for ( auto attach : framePass.getTargets() ) { auto view = attach->view( index ); @@ -43,7 +43,7 @@ namespace , crg::RecordContext const & context , uint32_t index ) { - for ( auto & [binding, attach] : framePass.sampled ) + for ( auto & [binding, attach] : framePass.getSampled() ) { auto view = attach.attach->view( index ); checkEqual( context.getLayoutState( crg::resolveView( view, index ) ).layout, crg::ImageLayout::eShaderReadOnly ) @@ -346,7 +346,7 @@ TEST( RenderGraph, SharedDependencies ) return createDummy( testCounts , framePass, context, runGraph, crg::PipelineStageFlags::eFragmentShader ); } ); - pass0.addOutputStorageBuffer( bufv1, 0 ); + auto attach = pass0.addOutputStorageBuffer( bufv1, 0 ); pass0.addOutputDepthTarget( dstv1 ); auto d0a = pass0.addOutputColourTarget( d0v ); @@ -383,6 +383,23 @@ TEST( RenderGraph, SharedDependencies ) auto runnable = graph.compile( getContext() ); auto stream = test::checkRunnable( testCounts, runnable ); + runnable->getDescriptorWriteT( *attach, 0u ); + runnable->getContext(); + { + crg::RunnableGraph const & rn = *runnable; + auto const & fence = rn.getFence(); + fence.getInternal(); + auto const & timer = rn.getTimer(); + timer.getName(); + } + { + crg::RunnableGraph & rn = *runnable; + auto & fence = rn.getFence(); + fence.reset(); + auto & timer = rn.getTimer(); + timer.reset(); + } + check( runnable->getName() == graph.getName() ) std::string ref = R"(digraph { "pass2" [ shape=ellipse ]; "pass1" [ shape=ellipse ]; @@ -1222,7 +1239,7 @@ TYPED_TEST( RenderGraphT, Render ) auto d = graph.createImage( test::createImage( "d", crg::PixelFormat::eD32_SFLOAT_S8_UINT ) ); auto dtv = graph.createView( test::createView( "dtv", d, crg::PixelFormat::eD32_SFLOAT_S8_UINT ) ); auto ld = graph.createImage( test::createImage( "ld", crg::PixelFormat::eR32_SFLOAT ) ); - auto ldv = graph.createView( test::createView( "ldv", d, crg::PixelFormat::eR32_SFLOAT ) ); + auto ldv = graph.createView( test::createView( "ldv", ld, crg::PixelFormat::eR32_SFLOAT ) ); crg::Attachment const * dta{}; crg::Attachment const * lda{}; @@ -2173,12 +2190,15 @@ TEST( RenderGraph, EnvironmentMap ) mipsGen.addInputTransfer( *graph.mergeAttachments( colourViews ) ); mipsGen.addInputTransfer( *graph.mergeAttachments( cubeViews ) ); mipsGen.addInputTransfer( *graph.mergeAttachments( cubesViews ) ); - mipsGen.addOutputTransferImage( colourv ); + auto attach = mipsGen.addOutputTransferImage( colourv ); mipsGen.addOutputTransferImage( cubev ); mipsGen.addOutputTransferImage( cubesv ); auto runnable = graph.compile( getContext() ); test::checkRunnable( testCounts, runnable ); + + runnable->getDescriptorWriteT( *attach, crg::SamplerDesc{}, 0u, 0u ); + testEnd() } diff --git a/test/TestRenderPass.cpp b/test/TestRenderPass.cpp index 3c72563..6a4b448 100644 --- a/test/TestRenderPass.cpp +++ b/test/TestRenderPass.cpp @@ -7,6 +7,8 @@ #include #include +#include + namespace { TEST( FramePass, Log ) @@ -15,9 +17,9 @@ namespace auto callback = []( std::string_view msg, bool newLine )noexcept { if ( newLine ) - printf( "%s Callback\n", msg.data() ); + fmt::print( "{} Callback\n", msg.data() ); else - printf( "%s Callback ", msg.data() ); + fmt::print( "{} Callback ", msg.data() ); }; crg::Logger::setTraceCallback( callback ); @@ -68,8 +70,8 @@ namespace pass.addOutputColourTarget( rtv ); check( pass.getName() == "1C" ) - check( pass.targets.size() == 1u ) - check( pass.targets[0]->view() == rtv ) + check( pass.getTargets().size() == 1u ) + check( pass.getTargets()[0]->view() == rtv ) testEnd() } @@ -88,9 +90,9 @@ namespace pass.addOutputColourTarget( rtv2 ); check( pass.getName() == "2C" ) - check( pass.targets.size() == 2u ) - check( pass.targets[0]->view() == rtv1 ) - check( pass.targets[1]->view() == rtv2 ) + check( pass.getTargets().size() == 2u ) + check( pass.getTargets()[0]->view() == rtv1 ) + check( pass.getTargets()[1]->view() == rtv2 ) testEnd() } @@ -106,8 +108,8 @@ namespace pass.addInputSampled( attach, 1u ); check( pass.getName() == "0C_1I" ) - check( pass.sampled.size() == 1u ) - check( pass.sampled.begin()->second.attach->view() == inv ) + check( pass.getSampled().size() == 1u ) + check( pass.getSampled().begin()->second.attach->view() == inv ) testEnd() } @@ -128,9 +130,9 @@ namespace pass.addInputSampled( attach2, 2u ); check( pass.getName() == "0C_2I" ) - check( pass.sampled.size() == 2u ) - check( pass.sampled.begin()->second.attach->view() == inv1 ) - check( pass.sampled.rbegin()->second.attach->view() == inv2 ) + check( pass.getSampled().size() == 2u ) + check( pass.getSampled().begin()->second.attach->view() == inv1 ) + check( pass.getSampled().rbegin()->second.attach->view() == inv2 ) testEnd() } @@ -150,10 +152,10 @@ namespace pass.addInputSampled( attach, 1u ); check( pass.getName() == "1C_1I" ) - check( pass.targets.size() == 1u ) - check( pass.targets[0]->view() == rtv ) - check( pass.sampled.size() == 1u ) - check( pass.sampled.begin()->second.attach->view() == inv ) + check( pass.getTargets().size() == 1u ) + check( pass.getTargets()[0]->view() == rtv ) + check( pass.getSampled().size() == 1u ) + check( pass.getSampled().begin()->second.attach->view() == inv ) testEnd() } @@ -178,11 +180,11 @@ namespace pass.addInputSampled( attach2, 2u ); check( pass.getName() == "1C_2I" ) - check( pass.targets.size() == 1u ) - check( pass.targets[0]->view() == rtv ) - check( pass.sampled.size() == 2u ) - check( pass.sampled.begin()->second.attach->view() == inv1 ) - check( pass.sampled.rbegin()->second.attach->view() == inv2 ) + check( pass.getTargets().size() == 1u ) + check( pass.getTargets()[0]->view() == rtv ) + check( pass.getSampled().size() == 2u ) + check( pass.getSampled().begin()->second.attach->view() == inv1 ) + check( pass.getSampled().rbegin()->second.attach->view() == inv2 ) testEnd() } @@ -206,11 +208,11 @@ namespace pass.addInputSampled( attach, 1u ); check( pass.getName() == "2C_1I" ) - check( pass.targets.size() == 2u ) - check( pass.targets[0]->view() == rtv1 ) - check( pass.targets[1]->view() == rtv2 ) - check( pass.sampled.size() == 1u ) - check( pass.sampled.begin()->second.attach->view() == inv ) + check( pass.getTargets().size() == 2u ) + check( pass.getTargets()[0]->view() == rtv1 ) + check( pass.getTargets()[1]->view() == rtv2 ) + check( pass.getSampled().size() == 1u ) + check( pass.getSampled().begin()->second.attach->view() == inv ) testEnd() } @@ -239,12 +241,12 @@ namespace pass.addInputSampled( attach2, 2u ); check( pass.getName() == "2C_2I" ) - check( pass.targets.size() == 2u ) - check( pass.targets[0]->view() == rtv1 ) - check( pass.targets[1]->view() == rtv2 ) - check( pass.sampled.size() == 2u ) - check( pass.sampled.begin()->second.attach->view() == inv1 ) - check( pass.sampled.rbegin()->second.attach->view() == inv2 ) + check( pass.getTargets().size() == 2u ) + check( pass.getTargets()[0]->view() == rtv1 ) + check( pass.getTargets()[1]->view() == rtv2 ) + check( pass.getSampled().size() == 2u ) + check( pass.getSampled().begin()->second.attach->view() == inv1 ) + check( pass.getSampled().rbegin()->second.attach->view() == inv2 ) testEnd() } @@ -259,8 +261,8 @@ namespace pass.addOutputDepthStencilTarget( dsv ); check( pass.getName() == "0C_DS" ) - check( pass.targets.size() == 1u ) - check( pass.targets[0]->view() == dsv ) + check( pass.getTargets().size() == 1u ) + check( pass.getTargets()[0]->view() == dsv ) testEnd() } @@ -279,9 +281,9 @@ namespace pass.addOutputDepthStencilTarget( dsv ); check( pass.getName() == "1C_DS" ) - check( pass.targets.size() == 2u ) - check( pass.targets[0]->view() == dsv ) - check( pass.targets[1]->view() == rtv ) + check( pass.getTargets().size() == 2u ) + check( pass.getTargets()[0]->view() == dsv ) + check( pass.getTargets()[1]->view() == rtv ) testEnd() } @@ -304,10 +306,10 @@ namespace pass.addOutputDepthStencilTarget( dsv ); check( pass.getName() == "2C_DS" ) - check( pass.targets.size() == 3u ) - check( pass.targets[0]->view() == dsv ) - check( pass.targets[1]->view() == rtv1 ) - check( pass.targets[2]->view() == rtv2 ) + check( pass.getTargets().size() == 3u ) + check( pass.getTargets()[0]->view() == dsv ) + check( pass.getTargets()[1]->view() == rtv1 ) + check( pass.getTargets()[2]->view() == rtv2 ) testEnd() } @@ -327,10 +329,10 @@ namespace pass.addOutputDepthStencilTarget( dsv ); check( pass.getName() == "0C_1I_DS" ) - check( pass.targets.size() == 1u ) - check( pass.targets[0]->view() == dsv ) - check( pass.sampled.size() == 1u ) - check( pass.sampled.begin()->second.attach->view() == inv ) + check( pass.getTargets().size() == 1u ) + check( pass.getTargets()[0]->view() == dsv ) + check( pass.getSampled().size() == 1u ) + check( pass.getSampled().begin()->second.attach->view() == inv ) testEnd() } @@ -355,11 +357,11 @@ namespace pass.addOutputDepthStencilTarget( dsv ); check( pass.getName() == "0C_2I_DS" ) - check( pass.targets.size() == 1u ) - check( pass.targets[0]->view() == dsv ) - check( pass.sampled.size() == 2u ) - check( pass.sampled.begin()->second.attach->view() == inv1 ) - check( pass.sampled.rbegin()->second.attach->view() == inv2 ) + check( pass.getTargets().size() == 1u ) + check( pass.getTargets()[0]->view() == dsv ) + check( pass.getSampled().size() == 2u ) + check( pass.getSampled().begin()->second.attach->view() == inv1 ) + check( pass.getSampled().rbegin()->second.attach->view() == inv2 ) testEnd() } @@ -383,11 +385,11 @@ namespace pass.addOutputDepthStencilTarget( dsv ); check( pass.getName() == "1C_1I_DS" ) - check( pass.targets.size() == 2u ) - check( pass.targets[0]->view() == dsv ) - check( pass.targets[1]->view() == rtv ) - check( pass.sampled.size() == 1u ) - check( pass.sampled.begin()->second.attach->view() == inv ) + check( pass.getTargets().size() == 2u ) + check( pass.getTargets()[0]->view() == dsv ) + check( pass.getTargets()[1]->view() == rtv ) + check( pass.getSampled().size() == 1u ) + check( pass.getSampled().begin()->second.attach->view() == inv ) testEnd() } @@ -416,12 +418,12 @@ namespace pass.addOutputDepthStencilTarget( dsv ); check( pass.getName() == "1C_2I_DS" ) - check( pass.targets.size() == 2u ) - check( pass.targets[0]->view() == dsv ) - check( pass.targets[1]->view() == rtv ) - check( pass.sampled.size() == 2u ) - check( pass.sampled.begin()->second.attach->view() == inv1 ) - check( pass.sampled.rbegin()->second.attach->view() == inv2 ) + check( pass.getTargets().size() == 2u ) + check( pass.getTargets()[0]->view() == dsv ) + check( pass.getTargets()[1]->view() == rtv ) + check( pass.getSampled().size() == 2u ) + check( pass.getSampled().begin()->second.attach->view() == inv1 ) + check( pass.getSampled().rbegin()->second.attach->view() == inv2 ) testEnd() } @@ -449,12 +451,12 @@ namespace pass.addOutputDepthStencilTarget( dsv ); check( pass.getName() == "2C_1I_DS" ) - check( pass.targets.size() == 3u ) - check( pass.targets[0]->view() == dsv ) - check( pass.targets[1]->view() == rtv1 ) - check( pass.targets[2]->view() == rtv2 ) - check( pass.sampled.size() == 1u ) - check( pass.sampled.begin()->second.attach->view() == inv ) + check( pass.getTargets().size() == 3u ) + check( pass.getTargets()[0]->view() == dsv ) + check( pass.getTargets()[1]->view() == rtv1 ) + check( pass.getTargets()[2]->view() == rtv2 ) + check( pass.getSampled().size() == 1u ) + check( pass.getSampled().begin()->second.attach->view() == inv ) testEnd() } @@ -487,13 +489,13 @@ namespace pass.addOutputDepthStencilTarget( dsv ); check( pass.getName() == "2C_2I_DS" ) - check( pass.targets.size() == 3u ) - check( pass.targets[0]->view() == dsv ) - check( pass.targets[1]->view() == rtv1 ) - check( pass.targets[2]->view() == rtv2 ) - check( pass.sampled.size() == 2u ) - check( pass.sampled.begin()->second.attach->view() == inv1 ) - check( pass.sampled.rbegin()->second.attach->view() == inv2 ) + check( pass.getTargets().size() == 3u ) + check( pass.getTargets()[0]->view() == dsv ) + check( pass.getTargets()[1]->view() == rtv1 ) + check( pass.getTargets()[2]->view() == rtv2 ) + check( pass.getSampled().size() == 2u ) + check( pass.getSampled().begin()->second.attach->view() == inv1 ) + check( pass.getSampled().rbegin()->second.attach->view() == inv2 ) testEnd() } } diff --git a/vcpkg.json b/vcpkg.json index a85716c..39220a8 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -10,6 +10,7 @@ "tests": { "description": "Unit tests.", "dependencies": [ + "fmt", "gtest" ] }