From e504c4a98218a37142d179f3f2478e8ee1b749d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 18 Feb 2022 19:37:37 +0100 Subject: [PATCH] Minor fixes --- examples/PhysicsDemo/main.cpp | 2 +- src/Nazara/Shader/Ast/SanitizeVisitor.cpp | 9 +++++---- src/ShaderNode/ShaderGraph.cpp | 9 ++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/PhysicsDemo/main.cpp b/examples/PhysicsDemo/main.cpp index d8f123bc3..c39a2da5c 100644 --- a/examples/PhysicsDemo/main.cpp +++ b/examples/PhysicsDemo/main.cpp @@ -78,7 +78,7 @@ int main() materialPass->EnableDepthClamp(true); materialPass->EnableFaceCulling(true); - //material->AddPass("DepthPass", depthPass); + material->AddPass("DepthPass", depthPass); material->AddPass("ForwardPass", materialPass); Nz::TextureSamplerInfo samplerInfo; diff --git a/src/Nazara/Shader/Ast/SanitizeVisitor.cpp b/src/Nazara/Shader/Ast/SanitizeVisitor.cpp index eb9b14bd1..9c54ddefd 100644 --- a/src/Nazara/Shader/Ast/SanitizeVisitor.cpp +++ b/src/Nazara/Shader/Ast/SanitizeVisitor.cpp @@ -849,9 +849,6 @@ namespace Nz::ShaderAst pendingFunc.cloneNode = clone.get(); pendingFunc.node = &node; - for (auto& parameter : clone->parameters) - parameter.type = ResolveType(parameter.type); - if (clone->earlyFragmentTests.HasValue() && clone->earlyFragmentTests.GetResultingValue()) { //TODO: warning and disable early fragment tests @@ -2265,10 +2262,14 @@ namespace Nz::ShaderAst if (!node.initialExpression) throw AstError{ "variable must either have a type or an initial value" }; - resolvedType = ResolveType(GetExpressionType(*node.initialExpression)); + resolvedType = GetExpressionType(*node.initialExpression); } else + { resolvedType = ResolveType(node.varType); + if (node.initialExpression) + TypeMustMatch(resolvedType, GetExpressionType(*node.initialExpression)); + } if (m_context->options.makeVariableNameUnique && FindIdentifier(node.varName) != nullptr) { diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 86db5af26..6e7b3940e 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -816,16 +816,15 @@ std::unique_ptr ShaderGraph::ToFunction { parameters.push_back({ "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()) { - returnType = Nz::ShaderAst::IdentifierType{ "OutputData" }; - - statements.push_back(Nz::ShaderBuilder::DeclareVariable("output", returnType)); + returnType = Nz::ShaderBuilder::Identifier("OutputData"); + statements.push_back(Nz::ShaderBuilder::DeclareVariable("output", Nz::ShaderAst::Clone(*returnType), nullptr)); } using Key = QPair;