Shader: Fix import of already compiled module
This commit is contained in:
parent
993f4e7c78
commit
36e5356c22
|
|
@ -1752,8 +1752,17 @@ namespace Nz::ShaderAst
|
|||
|
||||
ModulePtr sanitizedModule = std::make_shared<Module>(targetModule->metadata);
|
||||
|
||||
// Remap already used indices
|
||||
IndexRemapperVisitor::Callbacks indexCallbacks;
|
||||
indexCallbacks.constIndexGenerator = [this](std::size_t /*previousIndex*/) { return m_context->constantValues.RegisterNewIndex(true); };
|
||||
indexCallbacks.funcIndexGenerator = [this](std::size_t /*previousIndex*/) { return m_context->functions.RegisterNewIndex(true); };
|
||||
indexCallbacks.structIndexGenerator = [this](std::size_t /*previousIndex*/) { return m_context->structs.RegisterNewIndex(true); };
|
||||
indexCallbacks.varIndexGenerator = [this](std::size_t /*previousIndex*/) { return m_context->variableTypes.RegisterNewIndex(true); };
|
||||
|
||||
sanitizedModule->rootNode = StaticUniquePointerCast<MultiStatement>(RemapIndices(*targetModule->rootNode, indexCallbacks));
|
||||
|
||||
std::string error;
|
||||
sanitizedModule->rootNode = SanitizeInternal(*targetModule->rootNode, &error);
|
||||
sanitizedModule->rootNode = SanitizeInternal(*sanitizedModule->rootNode, &error);
|
||||
if (!sanitizedModule->rootNode)
|
||||
throw ShaderLang::CompilerModuleCompilationFailedError{ node.sourceLocation, node.moduleName, error };
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue