Graphics/PipelinePassList: Add support for attachment proxy
This commit is contained in:
committed by
Jérôme Leclercq
parent
578240cd6f
commit
db58921cc4
@@ -34,6 +34,27 @@ namespace Nz::Loaders
|
||||
std::string kw = ReadKeyword();
|
||||
if (kw == "attachment")
|
||||
HandleAttachment();
|
||||
else if (kw == "attachmentproxy")
|
||||
{
|
||||
std::string proxyName = ReadString();
|
||||
std::string targetName = ReadString();
|
||||
|
||||
auto it = m_current->attachmentsByName.find(targetName);
|
||||
if (it == m_current->attachmentsByName.end())
|
||||
{
|
||||
NazaraErrorFmt("unknown attachment {}", targetName);
|
||||
throw ResourceLoadingError::DecodingError;
|
||||
}
|
||||
|
||||
if (m_current->attachmentsByName.find(proxyName) != m_current->attachmentsByName.end())
|
||||
{
|
||||
NazaraErrorFmt("attachment {} already exists", proxyName);
|
||||
throw ResourceLoadingError::DecodingError;
|
||||
}
|
||||
|
||||
std::size_t proxyId = m_current->passList->AddAttachmentProxy(proxyName, it->second);
|
||||
m_current->attachmentsByName.emplace(std::move(proxyName), proxyId);
|
||||
}
|
||||
else if (kw == "pass")
|
||||
HandlePass();
|
||||
else if (kw == "output")
|
||||
|
||||
@@ -32,9 +32,6 @@ namespace Nz
|
||||
NazaraAssert(m_passes.size() == passes.size(), "pass vector size doesn't match passlist size");
|
||||
|
||||
StackArray<std::size_t> attachmentIndices = NazaraStackArrayNoInit(std::size_t, m_attachments.size());
|
||||
for (std::size_t i = 0; i < m_attachments.size(); ++i)
|
||||
attachmentIndices[i] = frameGraph.AddAttachment(m_attachments[i]);
|
||||
|
||||
auto GetAttachmentIndex = [&](std::size_t attachmentIndex)
|
||||
{
|
||||
if (attachmentIndex == NoAttachment)
|
||||
@@ -44,6 +41,21 @@ namespace Nz
|
||||
return attachmentIndices[attachmentIndex];
|
||||
};
|
||||
|
||||
for (std::size_t i = 0; i < m_attachments.size(); ++i)
|
||||
{
|
||||
attachmentIndices[i] = std::visit([&](auto&& arg)
|
||||
{
|
||||
using T = std::decay_t<decltype(arg)>;
|
||||
if constexpr (std::is_same_v<T, FramePassAttachment>)
|
||||
return frameGraph.AddAttachment(arg);
|
||||
else if constexpr (std::is_same_v<T, AttachmentProxy>)
|
||||
return frameGraph.AddAttachmentProxy(arg.name, GetAttachmentIndex(arg.attachmentIndex));
|
||||
else
|
||||
static_assert(AlwaysFalse<T>(), "unhandled case");
|
||||
|
||||
}, m_attachments[i]);
|
||||
}
|
||||
|
||||
for (std::size_t passIndex = 0; passIndex < passes.size(); ++passIndex)
|
||||
{
|
||||
const Pass& passData = m_passes[passIndex];
|
||||
|
||||
Reference in New Issue
Block a user