Shader/GlslWriter: Accepts mono-functions shader without specifying entry points

This commit is contained in:
Jérôme Leclercq
2021-05-24 21:08:18 +02:00
parent 7140e322c1
commit ac57b3fbf4
2 changed files with 17 additions and 18 deletions

View File

@@ -58,7 +58,9 @@ namespace Nz
}
else
{
assert(!entryPoint);
if (entryPoint)
throw std::runtime_error("multiple entry point functions found, this is not allowed in GLSL, please select one");
entryPoint = &node;
}
}
@@ -148,9 +150,16 @@ namespace Nz
targetAst->Visit(previsitor);
if (!previsitor.entryPoint)
throw std::runtime_error("missing entry point");
{
if (previsitor.forwardFunctionDeclarations.empty())
throw std::runtime_error("no function found");
state.entryFunc = previsitor.forwardFunctionDeclarations.front();
previsitor.forwardFunctionDeclarations.erase(previsitor.forwardFunctionDeclarations.begin());
}
else
state.entryFunc = previsitor.entryPoint;
state.entryFunc = previsitor.entryPoint;
state.functionNames = std::move(previsitor.functionNames);
AppendHeader(previsitor.forwardFunctionDeclarations);