Renderer/GlslWriter: Move variables to the function scope

This commit is contained in:
Lynix
2017-01-04 11:39:57 +01:00
parent 5c6df52fbf
commit 5c3e67bb26
2 changed files with 30 additions and 5 deletions

View File

@@ -44,7 +44,7 @@ namespace Nz
void Append(ShaderAst::ExpressionType type);
void Append(const String& txt);
void AppendFunction(const Function& func);
void AppendFunction(Function& func);
void AppendLine(const Nz::String& txt = Nz::String());
void EnterScope();
@@ -52,6 +52,7 @@ namespace Nz
struct Function
{
std::set<std::pair<ShaderAst::ExpressionType, String>> variables;
std::vector<ShaderAst::VariablePtr> parameters;
ShaderAst::ExpressionType retType;
ShaderAst::StatementPtr node;
@@ -60,12 +61,13 @@ namespace Nz
struct State
{
std::set<std::pair<ShaderAst::ExpressionType, String>> m_variables;
std::set<std::pair<ShaderAst::ExpressionType, String>> m_uniforms;
StringStream stream;
unsigned int indentLevel = 0;
};
std::unordered_map<String, Function> m_functions;
Function* m_currentFunction;
State* m_currentState;
};
}