Shader: Add sanitization of identifiers (fixes GLSL generation)

This commit is contained in:
Jérôme Leclercq
2021-04-17 15:19:28 +02:00
parent 8359d46711
commit 1a8599ba29
3 changed files with 34 additions and 1 deletions

View File

@@ -10,6 +10,7 @@
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Shader/Config.hpp>
#include <Nazara/Shader/Ast/AstCloner.hpp>
#include <unordered_set>
#include <vector>
namespace Nz::ShaderAst
@@ -32,6 +33,7 @@ namespace Nz::ShaderAst
struct Options
{
std::unordered_set<std::string> reservedIdentifiers;
bool removeOptionDeclaration = true;
};
@@ -84,6 +86,8 @@ namespace Nz::ShaderAst
std::size_t ResolveStruct(const UniformType& uniformType);
ExpressionType ResolveType(const ExpressionType& exprType);
void SanitizeIdentifier(std::string& identifier);
struct Alias
{
std::variant<ExpressionType> value;