ShaderNode fixes

This commit is contained in:
Jérôme Leclercq 2021-04-17 14:44:24 +02:00
parent 3a7f5c2630
commit e7a9fd95ea
3 changed files with 8 additions and 4 deletions

View File

@ -31,7 +31,7 @@ Nz::ShaderAst::NodePtr CastVec<ToComponentCount>::BuildNode(Nz::ShaderAst::Expre
std::size_t overflowComponentCount = ToComponentCount - fromComponentCount;
std::vector<Nz::ShaderAst::ExpressionPtr> params;
params.emplace_back(std::move(params[0]));
params.emplace_back(std::move(expressions[0]));
for (std::size_t i = 0; i < overflowComponentCount; ++i)
params.emplace_back(Nz::ShaderBuilder::Constant(m_overflowComponents[i]));

View File

@ -21,7 +21,7 @@ Nz::ShaderAst::NodePtr PositionOutputValue::BuildNode(Nz::ShaderAst::ExpressionP
assert(count == 1);
assert(outputIndex == 0);
auto output = Nz::ShaderBuilder::AccessMember(Nz::ShaderBuilder::Identifier("OutputData"), { "position" });
auto output = Nz::ShaderBuilder::AccessMember(Nz::ShaderBuilder::Identifier("output"), { "position" });
return ShaderBuilder::Assign(ShaderAst::AssignType::Simple, std::move(output), std::move(expressions[0]));
}

View File

@ -488,7 +488,7 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() const
auto& extVar = external->externalVars.emplace_back();
extVar.bindingIndex = buffer.bindingIndex;
extVar.name = buffer.name;
extVar.type = Nz::ShaderAst::IdentifierType{ structInfo.name };
extVar.type = Nz::ShaderAst::UniformType{ Nz::ShaderAst::IdentifierType{ structInfo.name } };
}
for (const auto& texture : m_textures)
@ -536,6 +536,7 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() const
if (m_type == ShaderType::Vertex)
{
auto& position = structDesc.members.emplace_back();
position.builtin = Nz::ShaderAst::BuiltinEntry::VertexPosition;
position.name = "position";
position.type = Nz::ShaderAst::VectorType{ 4, Nz::ShaderAst::PrimitiveType::Float32 };
}
@ -802,7 +803,7 @@ std::unique_ptr<Nz::ShaderAst::DeclareFunctionStatement> ShaderGraph::ToFunction
parameters.push_back({
"input",
Nz::ShaderAst::IdentifierType{ "InputData" }
});
});
}
Nz::ShaderAst::ExpressionType returnType;
@ -944,5 +945,8 @@ std::unique_ptr<Nz::ShaderAst::DeclareFunctionStatement> ShaderGraph::ToFunction
statements.emplace_back(static_unique_pointer_cast<Nz::ShaderAst::Statement>(std::move(astNode)));
}
if (!m_outputs.empty())
statements.push_back(Nz::ShaderBuilder::Return(Nz::ShaderBuilder::Identifier("output")));
return Nz::ShaderBuilder::DeclareFunction(ToShaderStageType(m_type), "main", std::move(parameters), std::move(statements), std::move(returnType));
}