Graphics/FrameGraph: Reuse textures if possible
This commit is contained in:
@@ -45,6 +45,7 @@ namespace Nz
|
||||
using BarrierList = std::vector<PassBarriers>;
|
||||
using PassList = std::vector<std::size_t /*PassIndex*/>;
|
||||
using AttachmentIdToPassMap = std::unordered_map<std::size_t /*resourceIndex*/, PassList /*passIndexes*/>;
|
||||
using AttachmentIdToPassId = std::unordered_map<std::size_t /*attachmentId*/, std::size_t /*passId*/>;
|
||||
using AttachmentIdToTextureId = std::unordered_map<std::size_t /*attachmentId*/, std::size_t /*textureId*/>;
|
||||
using PassIdToPhysicalPassIndex = std::unordered_map<std::size_t /*passId*/, std::size_t /*physicalPassId*/>;
|
||||
using TextureTransition = BakedFrameGraph::TextureTransition;
|
||||
@@ -88,6 +89,7 @@ namespace Nz
|
||||
std::vector<std::shared_ptr<RenderPass>> renderPasses;
|
||||
std::vector<PhysicalPassData> physicalPasses;
|
||||
std::vector<TextureData> textures;
|
||||
AttachmentIdToPassId attachmentLastUse;
|
||||
AttachmentIdToPassMap attachmentReadList;
|
||||
AttachmentIdToPassMap attachmentWriteList;
|
||||
AttachmentIdToTextureId attachmentToTextures;
|
||||
|
||||
@@ -46,6 +46,8 @@ namespace Nz
|
||||
inline std::size_t AddInput(std::size_t attachmentId);
|
||||
inline std::size_t AddOutput(std::size_t attachmentId);
|
||||
|
||||
template<typename F> void ForEachAttachment(F&& func) const;
|
||||
|
||||
inline const CommandCallback& GetCommandCallback() const;
|
||||
inline const std::optional<DepthStencilClear>& GetDepthStencilClear() const;
|
||||
inline std::size_t GetDepthStencilInput() const;
|
||||
|
||||
@@ -38,6 +38,25 @@ namespace Nz
|
||||
|
||||
return outputIndex;
|
||||
}
|
||||
template<typename F>
|
||||
void FramePass::ForEachAttachment(F&& func) const
|
||||
{
|
||||
for (const auto& input : m_inputs)
|
||||
func(input.attachmentId);
|
||||
|
||||
for (const auto& output : m_outputs)
|
||||
func(output.attachmentId);
|
||||
|
||||
if (m_depthStencilInput != FramePass::InvalidAttachmentId)
|
||||
{
|
||||
func(m_depthStencilInput);
|
||||
|
||||
if (m_depthStencilOutput != FramePass::InvalidAttachmentId && m_depthStencilOutput != m_depthStencilInput)
|
||||
func(m_depthStencilOutput);
|
||||
}
|
||||
else if (m_depthStencilOutput != FramePass::InvalidAttachmentId)
|
||||
func(m_depthStencilOutput);
|
||||
}
|
||||
|
||||
inline auto FramePass::GetCommandCallback() const -> const CommandCallback&
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user