Graphics/FrameGraph: Add support for pass name (as debug sections)

This commit is contained in:
Jérôme Leclercq 2021-05-14 01:45:45 +02:00
parent ee690072f8
commit 9376cfefd2
6 changed files with 24 additions and 3 deletions

View File

@ -69,6 +69,7 @@ namespace Nz
CommandBufferPtr commandBuffer;
std::shared_ptr<Framebuffer> framebuffer;
std::shared_ptr<RenderPass> renderPass;
std::string name;
std::vector<std::size_t> outputTextureIndices;
std::vector<SubpassData> subpasses;
std::vector<TextureTransition> transitions;

View File

@ -71,6 +71,7 @@ namespace Nz
std::size_t passIndex;
};
std::string name;
std::vector<TextureTransition> textureTransitions;
std::vector<Subpass> passes;
};

View File

@ -50,6 +50,7 @@ namespace Nz
inline std::size_t GetDepthStencilOutput() const;
inline const ExecutionCallback& GetExecutionCallback() const;
inline const std::vector<Input>& GetInputs() const;
inline const std::string& GetName() const;
inline const std::vector<Output>& GetOutputs() const;
inline std::size_t GetPassId() const;

View File

@ -69,6 +69,11 @@ namespace Nz
return m_inputs;
}
inline const std::string& FramePass::GetName() const
{
return m_name;
}
inline auto FramePass::GetOutputs() const -> const std::vector<Output>&
{
return m_outputs;

View File

@ -54,6 +54,9 @@ namespace Nz
builder.TextureBarrier(textureTransition.srcStageMask, textureTransition.dstStageMask, textureTransition.srcAccessMask, textureTransition.dstAccessMask, textureTransition.oldLayout, textureTransition.newLayout, *texture);
}
if (!passData.name.empty())
builder.BeginDebugRegion(passData.name, Nz::Color::Green);
builder.BeginRenderPass(*passData.framebuffer, *passData.renderPass, passData.renderRect);
bool first = true;
@ -68,6 +71,9 @@ namespace Nz
}
builder.EndRenderPass();
if (!passData.name.empty())
builder.EndDebugRegion();
});
}

View File

@ -75,6 +75,7 @@ namespace Nz
for (auto& physicalPass : m_pending.physicalPasses)
{
auto& bakedPass = bakedPasses.emplace_back();
bakedPass.name = std::move(physicalPass.name);
bakedPass.renderPass = std::move(m_pending.renderPasses[renderPassIndex++]);
bakedPass.transitions = std::move(physicalPass.textureTransitions);
@ -140,13 +141,19 @@ namespace Nz
std::size_t physPassIndex = m_pending.physicalPasses.size();
PhysicalPassData& currentPass = m_pending.physicalPasses.emplace_back();
auto begin = m_pending.passList.begin() + passIndex;
auto it = m_pending.passList.begin() + passIndex;
auto end = m_pending.passList.begin() + mergeEnd;
for (; begin < end; ++begin)
for (; it < end; ++it)
{
const FramePass& pass = m_framePasses[*it];
if (currentPass.name.empty())
currentPass.name = pass.GetName();
else
currentPass.name += " + " + pass.GetName();
auto& subpass = currentPass.passes.emplace_back();
subpass.passIndex = *begin;
subpass.passIndex = *it;
m_pending.passIdToPhysicalPassIndex.emplace(subpass.passIndex, physPassIndex);
}