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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 45 additions & 46 deletions include/RenderGraph/Attachment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ namespace crg
ClearValue clearValue{};
PipelineColorBlendAttachmentState blendState = DefaultBlendState;
ImageLayout wantedLayout{};
FlagKind flags{};

private:
CRG_API ImageAttachment() = default;
Expand All @@ -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
Expand Down Expand Up @@ -304,6 +303,8 @@ namespace crg

public:
BufferViewIdArray buffers;
FlagKind flags{};
AccessState wantedAccess{};

private:
CRG_API BufferAttachment() = default;
Expand All @@ -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;
Expand All @@ -327,6 +326,9 @@ namespace crg
*/
struct Attachment
{
friend struct FramePass;
friend class FrameGraph;

class Token
{
friend struct Attachment;
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -746,11 +748,8 @@ namespace crg
, Token token );

private:

void initSources();

FlagKind flags{};

friend bool operator==( Attachment const & lhs
, Attachment const & rhs )
{
Expand Down
78 changes: 49 additions & 29 deletions include/RenderGraph/FrameGraphStructs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -168,40 +188,40 @@ 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:
std::variant< std::array< float, 4u >
, 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
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading