Shader: Minor fixes
This commit is contained in:
parent
85ce6a4f43
commit
3e704b9ea6
|
|
@ -59,6 +59,7 @@ namespace Nz::ShaderBuilder
|
|||
|
||||
struct DeclareFunction
|
||||
{
|
||||
inline std::unique_ptr<ShaderAst::DeclareFunctionStatement> operator()(std::string name, ShaderAst::StatementPtr statement) const;
|
||||
inline std::unique_ptr<ShaderAst::DeclareFunctionStatement> operator()(std::string name, std::vector<ShaderAst::DeclareFunctionStatement::Parameter> parameters, std::vector<ShaderAst::StatementPtr> statements, ShaderAst::ExpressionType returnType = ShaderAst::NoType{}) const;
|
||||
inline std::unique_ptr<ShaderAst::DeclareFunctionStatement> operator()(std::optional<ShaderStageType> entryStage, std::string name, std::vector<ShaderAst::DeclareFunctionStatement::Parameter> parameters, std::vector<ShaderAst::StatementPtr> statements, ShaderAst::ExpressionType returnType = ShaderAst::NoType{}) const;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -97,6 +97,15 @@ namespace Nz::ShaderBuilder
|
|||
return constantNode;
|
||||
}
|
||||
|
||||
inline std::unique_ptr<ShaderAst::DeclareFunctionStatement> Impl::DeclareFunction::operator()(std::string name, ShaderAst::StatementPtr statement) const
|
||||
{
|
||||
auto declareFunctionNode = std::make_unique<ShaderAst::DeclareFunctionStatement>();
|
||||
declareFunctionNode->name = std::move(name);
|
||||
declareFunctionNode->statements.push_back(std::move(statement));
|
||||
|
||||
return declareFunctionNode;
|
||||
}
|
||||
|
||||
inline std::unique_ptr<ShaderAst::DeclareFunctionStatement> Impl::DeclareFunction::operator()(std::string name, std::vector<ShaderAst::DeclareFunctionStatement::Parameter> parameters, std::vector<ShaderAst::StatementPtr> statements, ShaderAst::ExpressionType returnType) const
|
||||
{
|
||||
auto declareFunctionNode = std::make_unique<ShaderAst::DeclareFunctionStatement>();
|
||||
|
|
@ -200,7 +209,8 @@ namespace Nz::ShaderBuilder
|
|||
swizzleNode->expression = std::move(expression);
|
||||
|
||||
assert(swizzleComponents.size() <= swizzleNode->components.size());
|
||||
for (std::size_t i = 0; i < swizzleComponents.size(); ++i)
|
||||
swizzleNode->componentCount = swizzleComponents.size();
|
||||
for (std::size_t i = 0; i < swizzleNode->componentCount; ++i)
|
||||
swizzleNode->components[i] = swizzleComponents[i];
|
||||
|
||||
return swizzleNode;
|
||||
|
|
|
|||
|
|
@ -203,14 +203,14 @@ namespace Nz
|
|||
m_currentState->stream << std::string(m_currentState->resultOffset, ' ');
|
||||
|
||||
m_currentState->stream << instructionStream.str();
|
||||
|
||||
assert(GetCurrentPtr() == startPtr + wordCount - 1);
|
||||
}
|
||||
else
|
||||
m_currentState->stream << instruction.name;
|
||||
|
||||
m_currentState->stream << "\n";
|
||||
|
||||
assert(GetCurrentPtr() == startPtr + wordCount - 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue