Minor fixes

This commit is contained in:
Jérôme Leclercq 2022-02-18 19:37:37 +01:00
parent 24a2f96fd3
commit e504c4a982
3 changed files with 10 additions and 10 deletions

View File

@ -78,7 +78,7 @@ int main()
materialPass->EnableDepthClamp(true); materialPass->EnableDepthClamp(true);
materialPass->EnableFaceCulling(true); materialPass->EnableFaceCulling(true);
//material->AddPass("DepthPass", depthPass); material->AddPass("DepthPass", depthPass);
material->AddPass("ForwardPass", materialPass); material->AddPass("ForwardPass", materialPass);
Nz::TextureSamplerInfo samplerInfo; Nz::TextureSamplerInfo samplerInfo;

View File

@ -849,9 +849,6 @@ namespace Nz::ShaderAst
pendingFunc.cloneNode = clone.get(); pendingFunc.cloneNode = clone.get();
pendingFunc.node = &node; pendingFunc.node = &node;
for (auto& parameter : clone->parameters)
parameter.type = ResolveType(parameter.type);
if (clone->earlyFragmentTests.HasValue() && clone->earlyFragmentTests.GetResultingValue()) if (clone->earlyFragmentTests.HasValue() && clone->earlyFragmentTests.GetResultingValue())
{ {
//TODO: warning and disable early fragment tests //TODO: warning and disable early fragment tests
@ -2265,10 +2262,14 @@ namespace Nz::ShaderAst
if (!node.initialExpression) if (!node.initialExpression)
throw AstError{ "variable must either have a type or an initial value" }; throw AstError{ "variable must either have a type or an initial value" };
resolvedType = ResolveType(GetExpressionType(*node.initialExpression)); resolvedType = GetExpressionType(*node.initialExpression);
} }
else else
{
resolvedType = ResolveType(node.varType); resolvedType = ResolveType(node.varType);
if (node.initialExpression)
TypeMustMatch(resolvedType, GetExpressionType(*node.initialExpression));
}
if (m_context->options.makeVariableNameUnique && FindIdentifier(node.varName) != nullptr) if (m_context->options.makeVariableNameUnique && FindIdentifier(node.varName) != nullptr)
{ {

View File

@ -816,16 +816,15 @@ std::unique_ptr<Nz::ShaderAst::DeclareFunctionStatement> ShaderGraph::ToFunction
{ {
parameters.push_back({ parameters.push_back({
"input", "input",
Nz::ShaderAst::ExpressionType{ Nz::ShaderAst::IdentifierType{ "InputData" } } Nz::ShaderAst::ExpressionPtr{ Nz::ShaderBuilder::Identifier("InputData") }
}); });
} }
Nz::ShaderAst::ExpressionType returnType; Nz::ShaderAst::ExpressionPtr returnType;
if (!m_outputs.empty()) if (!m_outputs.empty())
{ {
returnType = Nz::ShaderAst::IdentifierType{ "OutputData" }; returnType = Nz::ShaderBuilder::Identifier("OutputData");
statements.push_back(Nz::ShaderBuilder::DeclareVariable("output", Nz::ShaderAst::Clone(*returnType), nullptr));
statements.push_back(Nz::ShaderBuilder::DeclareVariable("output", returnType));
} }
using Key = QPair<QUuid, std::size_t>; using Key = QPair<QUuid, std::size_t>;