Rebase fix
This commit is contained in:
parent
6bd9f1a9e4
commit
56c6eff7f8
|
|
@ -731,14 +731,14 @@ namespace Nz::ShaderAst
|
||||||
|
|
||||||
ModulePtr AstConstantPropagationVisitor::Process(const Module& shaderModule)
|
ModulePtr AstConstantPropagationVisitor::Process(const Module& shaderModule)
|
||||||
{
|
{
|
||||||
auto rootnode = static_unique_pointer_cast<MultiStatement>(Process(*shaderModule.rootNode));
|
auto rootnode = StaticUniquePointerCast<MultiStatement>(Process(*shaderModule.rootNode));
|
||||||
|
|
||||||
return std::make_shared<Module>(shaderModule.metadata, std::move(rootnode), shaderModule.importedModules);
|
return std::make_shared<Module>(shaderModule.metadata, std::move(rootnode), shaderModule.importedModules);
|
||||||
}
|
}
|
||||||
|
|
||||||
ModulePtr AstConstantPropagationVisitor::Process(const Module& shaderModule, const Options& options)
|
ModulePtr AstConstantPropagationVisitor::Process(const Module& shaderModule, const Options& options)
|
||||||
{
|
{
|
||||||
auto rootNode = static_unique_pointer_cast<MultiStatement>(Process(*shaderModule.rootNode, options));
|
auto rootNode = StaticUniquePointerCast<MultiStatement>(Process(*shaderModule.rootNode, options));
|
||||||
|
|
||||||
return std::make_shared<Module>(shaderModule.metadata, std::move(rootNode), shaderModule.importedModules);
|
return std::make_shared<Module>(shaderModule.metadata, std::move(rootNode), shaderModule.importedModules);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,6 @@
|
||||||
|
|
||||||
namespace Nz::ShaderAst
|
namespace Nz::ShaderAst
|
||||||
{
|
{
|
||||||
namespace
|
|
||||||
{
|
|
||||||
template<typename T, typename U>
|
|
||||||
std::unique_ptr<T> static_unique_pointer_cast(std::unique_ptr<U>&& ptr)
|
|
||||||
{
|
|
||||||
return std::unique_ptr<T>(static_cast<T*>(ptr.release()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct EliminateUnusedPassVisitor::Context
|
struct EliminateUnusedPassVisitor::Context
|
||||||
{
|
{
|
||||||
const DependencyCheckerVisitor::UsageSet& usageSet;
|
const DependencyCheckerVisitor::UsageSet& usageSet;
|
||||||
|
|
@ -25,7 +16,7 @@ namespace Nz::ShaderAst
|
||||||
|
|
||||||
ModulePtr EliminateUnusedPassVisitor::Process(const Module& shaderModule, const DependencyCheckerVisitor::UsageSet& usageSet)
|
ModulePtr EliminateUnusedPassVisitor::Process(const Module& shaderModule, const DependencyCheckerVisitor::UsageSet& usageSet)
|
||||||
{
|
{
|
||||||
auto rootNode = static_unique_pointer_cast<MultiStatement>(Process(*shaderModule.rootNode, usageSet));
|
auto rootNode = StaticUniquePointerCast<MultiStatement>(Process(*shaderModule.rootNode, usageSet));
|
||||||
|
|
||||||
return std::make_shared<Module>(shaderModule.metadata, std::move(rootNode), shaderModule.importedModules);
|
return std::make_shared<Module>(shaderModule.metadata, std::move(rootNode), shaderModule.importedModules);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -458,7 +458,7 @@ namespace Nz::ShaderAst
|
||||||
aliasType.targetType = std::make_unique<ContainedType>();
|
aliasType.targetType = std::make_unique<ContainedType>();
|
||||||
aliasType.targetType->type = *targetExpr->cachedExpressionType;
|
aliasType.targetType->type = *targetExpr->cachedExpressionType;
|
||||||
|
|
||||||
auto clone = static_unique_pointer_cast<AliasValueExpression>(AstCloner::Clone(node));
|
auto clone = StaticUniquePointerCast<AliasValueExpression>(AstCloner::Clone(node));
|
||||||
clone->cachedExpressionType = std::move(aliasType);
|
clone->cachedExpressionType = std::move(aliasType);
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
|
|
@ -709,7 +709,7 @@ namespace Nz::ShaderAst
|
||||||
|
|
||||||
ExpressionPtr SanitizeVisitor::Clone(IntrinsicExpression& node)
|
ExpressionPtr SanitizeVisitor::Clone(IntrinsicExpression& node)
|
||||||
{
|
{
|
||||||
auto clone = static_unique_pointer_cast<IntrinsicExpression>(AstCloner::Clone(node));
|
auto clone = StaticUniquePointerCast<IntrinsicExpression>(AstCloner::Clone(node));
|
||||||
Validate(*clone);
|
Validate(*clone);
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
|
|
@ -867,7 +867,7 @@ namespace Nz::ShaderAst
|
||||||
|
|
||||||
StatementPtr SanitizeVisitor::Clone(DeclareAliasStatement& node)
|
StatementPtr SanitizeVisitor::Clone(DeclareAliasStatement& node)
|
||||||
{
|
{
|
||||||
auto clone = static_unique_pointer_cast<DeclareAliasStatement>(AstCloner::Clone(node));
|
auto clone = StaticUniquePointerCast<DeclareAliasStatement>(AstCloner::Clone(node));
|
||||||
Validate(*clone);
|
Validate(*clone);
|
||||||
|
|
||||||
if (m_context->options.removeAliases)
|
if (m_context->options.removeAliases)
|
||||||
|
|
@ -1452,7 +1452,7 @@ namespace Nz::ShaderAst
|
||||||
StatementPtr SanitizeVisitor::Clone(ImportStatement& node)
|
StatementPtr SanitizeVisitor::Clone(ImportStatement& node)
|
||||||
{
|
{
|
||||||
if (!m_context->options.moduleResolver)
|
if (!m_context->options.moduleResolver)
|
||||||
return static_unique_pointer_cast<ImportStatement>(AstCloner::Clone(node));
|
return StaticUniquePointerCast<ImportStatement>(AstCloner::Clone(node));
|
||||||
|
|
||||||
ModulePtr targetModule = m_context->options.moduleResolver->Resolve(node.moduleName);
|
ModulePtr targetModule = m_context->options.moduleResolver->Resolve(node.moduleName);
|
||||||
if (!targetModule)
|
if (!targetModule)
|
||||||
|
|
@ -2439,7 +2439,7 @@ namespace Nz::ShaderAst
|
||||||
// First pass, evaluate everything except function code
|
// First pass, evaluate everything except function code
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
output = static_unique_pointer_cast<MultiStatement>(AstCloner::Clone(rootNode));
|
output = StaticUniquePointerCast<MultiStatement>(AstCloner::Clone(rootNode));
|
||||||
}
|
}
|
||||||
catch (const AstError& err)
|
catch (const AstError& err)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include <ShaderNode/ShaderGraph.hpp>
|
#include <ShaderNode/ShaderGraph.hpp>
|
||||||
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Core/StackArray.hpp>
|
#include <Nazara/Core/StackArray.hpp>
|
||||||
#include <Nazara/Shader/Ast/AstCloner.hpp>
|
#include <Nazara/Shader/Ast/AstCloner.hpp>
|
||||||
#include <Nazara/Shader/Ast/AstUtils.hpp>
|
#include <Nazara/Shader/Ast/AstUtils.hpp>
|
||||||
|
|
@ -47,12 +48,6 @@ namespace
|
||||||
auto creator = [&] { return std::make_unique<T>(graph); };
|
auto creator = [&] { return std::make_unique<T>(graph); };
|
||||||
registry->registerModel<T>(category, std::move(creator));
|
registry->registerModel<T>(category, std::move(creator));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename U>
|
|
||||||
std::unique_ptr<T> static_unique_pointer_cast(std::unique_ptr<U>&& ptr)
|
|
||||||
{
|
|
||||||
return std::unique_ptr<T>(static_cast<T*>(ptr.release()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderGraph::ShaderGraph() :
|
ShaderGraph::ShaderGraph() :
|
||||||
|
|
@ -897,7 +892,7 @@ std::unique_ptr<Nz::ShaderAst::DeclareFunctionStatement> ShaderGraph::ToFunction
|
||||||
if (!Nz::ShaderAst::IsExpression(inputNode->GetType()))
|
if (!Nz::ShaderAst::IsExpression(inputNode->GetType()))
|
||||||
throw std::runtime_error("unexpected statement");
|
throw std::runtime_error("unexpected statement");
|
||||||
|
|
||||||
expressions[i] = static_unique_pointer_cast<Nz::ShaderAst::Expression>(std::move(inputNode));
|
expressions[i] = Nz::StaticUniquePointerCast<Nz::ShaderAst::Expression>(std::move(inputNode));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -906,7 +901,7 @@ std::unique_ptr<Nz::ShaderAst::DeclareFunctionStatement> ShaderGraph::ToFunction
|
||||||
if (!Nz::ShaderAst::IsExpression(astNode->GetType()))
|
if (!Nz::ShaderAst::IsExpression(astNode->GetType()))
|
||||||
return astNode;
|
return astNode;
|
||||||
|
|
||||||
Nz::ShaderAst::ExpressionPtr expression = static_unique_pointer_cast<Nz::ShaderAst::Expression>(std::move(astNode));
|
Nz::ShaderAst::ExpressionPtr expression = Nz::StaticUniquePointerCast<Nz::ShaderAst::Expression>(std::move(astNode));
|
||||||
|
|
||||||
const std::string& variableName = shaderNode->GetVariableName();
|
const std::string& variableName = shaderNode->GetVariableName();
|
||||||
if (it->second > 1 || !variableName.empty())
|
if (it->second > 1 || !variableName.empty())
|
||||||
|
|
@ -952,9 +947,9 @@ std::unique_ptr<Nz::ShaderAst::DeclareFunctionStatement> ShaderGraph::ToFunction
|
||||||
{
|
{
|
||||||
auto astNode = HandleNode(node, 0);
|
auto astNode = HandleNode(node, 0);
|
||||||
if (!Nz::ShaderAst::IsStatement(astNode->GetType()))
|
if (!Nz::ShaderAst::IsStatement(astNode->GetType()))
|
||||||
statements.emplace_back(Nz::ShaderBuilder::ExpressionStatement(static_unique_pointer_cast<Nz::ShaderAst::Expression>(std::move(astNode))));
|
statements.emplace_back(Nz::ShaderBuilder::ExpressionStatement(Nz::StaticUniquePointerCast<Nz::ShaderAst::Expression>(std::move(astNode))));
|
||||||
else
|
else
|
||||||
statements.emplace_back(static_unique_pointer_cast<Nz::ShaderAst::Statement>(std::move(astNode)));
|
statements.emplace_back(Nz::StaticUniquePointerCast<Nz::ShaderAst::Statement>(std::move(astNode)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_outputs.empty())
|
if (!m_outputs.empty())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue