Shader: Fix index remapping when importing a text shader in a precompiled shader
This commit is contained in:
@@ -42,12 +42,12 @@ namespace Nz::ShaderAst
|
||||
std::function<void(const DeclareStructStatement& structDecl)> onStructDeclaration;
|
||||
std::function<void(const DeclareVariableStatement& variableDecl)> onVariableDeclaration;
|
||||
|
||||
std::function<void(const std::string& name, std::size_t aliasIndex, const ShaderLang::SourceLocation& sourceLocation)> onAliasIndex;
|
||||
std::function<void(const std::string& name, std::size_t constIndex, const ShaderLang::SourceLocation& sourceLocation)> onConstIndex;
|
||||
std::function<void(const std::string& name, std::size_t funcIndex, const ShaderLang::SourceLocation& sourceLocation)> onFunctionIndex;
|
||||
std::function<void(const std::string& name, std::size_t optIndex, const ShaderLang::SourceLocation& sourceLocation)> onOptionIndex;
|
||||
std::function<void(const std::string& name, std::size_t aliasIndex, const ShaderLang::SourceLocation& sourceLocation)> onAliasIndex;
|
||||
std::function<void(const std::string& name, std::size_t constIndex, const ShaderLang::SourceLocation& sourceLocation)> onConstIndex;
|
||||
std::function<void(const std::string& name, std::size_t funcIndex, const ShaderLang::SourceLocation& sourceLocation)> onFunctionIndex;
|
||||
std::function<void(const std::string& name, std::size_t optIndex, const ShaderLang::SourceLocation& sourceLocation)> onOptionIndex;
|
||||
std::function<void(const std::string& name, std::size_t structIndex, const ShaderLang::SourceLocation& sourceLocation)> onStructIndex;
|
||||
std::function<void(const std::string& name, std::size_t varIndex, const ShaderLang::SourceLocation& sourceLocation)> onVariableIndex;
|
||||
std::function<void(const std::string& name, std::size_t varIndex, const ShaderLang::SourceLocation& sourceLocation)> onVariableIndex;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
@@ -17,19 +17,19 @@ namespace Nz::ShaderAst
|
||||
class NAZARA_SHADER_API IndexRemapperVisitor : public AstCloner
|
||||
{
|
||||
public:
|
||||
struct Callbacks;
|
||||
struct Options;
|
||||
|
||||
IndexRemapperVisitor() = default;
|
||||
IndexRemapperVisitor(const IndexRemapperVisitor&) = delete;
|
||||
IndexRemapperVisitor(IndexRemapperVisitor&&) = delete;
|
||||
~IndexRemapperVisitor() = default;
|
||||
|
||||
StatementPtr Clone(Statement& statement, const Callbacks& callbacks);
|
||||
StatementPtr Clone(Statement& statement, const Options& options);
|
||||
|
||||
IndexRemapperVisitor& operator=(const IndexRemapperVisitor&) = delete;
|
||||
IndexRemapperVisitor& operator=(IndexRemapperVisitor&&) = delete;
|
||||
|
||||
struct Callbacks
|
||||
struct Options
|
||||
{
|
||||
std::function<std::size_t(std::size_t previousIndex)> aliasIndexGenerator;
|
||||
std::function<std::size_t(std::size_t previousIndex)> constIndexGenerator;
|
||||
@@ -37,6 +37,7 @@ namespace Nz::ShaderAst
|
||||
std::function<std::size_t(std::size_t previousIndex) > structIndexGenerator;
|
||||
//std::function<std::size_t()> typeIndexGenerator;
|
||||
std::function<std::size_t(std::size_t previousIndex)> varIndexGenerator;
|
||||
bool forceIndexGeneration = false;
|
||||
};
|
||||
|
||||
private:
|
||||
@@ -60,7 +61,7 @@ namespace Nz::ShaderAst
|
||||
Context* m_context;
|
||||
};
|
||||
|
||||
inline StatementPtr RemapIndices(Statement& statement, const IndexRemapperVisitor::Callbacks& callbacks);
|
||||
inline StatementPtr RemapIndices(Statement& statement, const IndexRemapperVisitor::Options& options);
|
||||
}
|
||||
|
||||
#include <Nazara/Shader/Ast/IndexRemapperVisitor.inl>
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
namespace Nz::ShaderAst
|
||||
{
|
||||
StatementPtr RemapIndices(Statement& statement, const IndexRemapperVisitor::Callbacks& callbacks)
|
||||
StatementPtr RemapIndices(Statement& statement, const IndexRemapperVisitor::Options& options)
|
||||
{
|
||||
IndexRemapperVisitor visitor;
|
||||
return visitor.Clone(statement, callbacks);
|
||||
return visitor.Clone(statement, options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user