Allow non-existent techniques to exist

This commit is contained in:
Evil Eye 2025-07-03 17:21:50 +02:00
parent 206d38f3d7
commit dbc732231f
3 changed files with 30 additions and 9 deletions

View File

@ -748,7 +748,7 @@ namespace MWRender
return technique->isValid(); return technique->isValid();
} }
std::shared_ptr<fx::Technique> PostProcessor::loadTechnique(const std::string& name, bool loadNextFrame) std::shared_ptr<fx::Technique> PostProcessor::loadTechnique(std::string_view name, bool loadNextFrame)
{ {
VFS::Path::Normalized path = fx::Technique::makeFileName(name); VFS::Path::Normalized path = fx::Technique::makeFileName(name);
return loadTechnique(VFS::Path::NormalizedView(path), loadNextFrame); return loadTechnique(VFS::Path::NormalizedView(path), loadNextFrame);
@ -764,11 +764,14 @@ namespace MWRender
if (technique->getFileName() == path) if (technique->getFileName() == path)
return technique; return technique;
if (!mTechniqueFiles.contains(path)) std::string name;
return {}; if (mTechniqueFiles.contains(path))
name = mVFS->getStem(path);
else
name = path.stem();
auto technique = std::make_shared<fx::Technique>(*mVFS, *mRendering.getResourceSystem()->getImageManager(), auto technique = std::make_shared<fx::Technique>(*mVFS, *mRendering.getResourceSystem()->getImageManager(),
path, mVFS->getStem(path), renderWidth(), renderHeight(), mUBO, mNormalsSupported); path, std::move(name), renderWidth(), renderHeight(), mUBO, mNormalsSupported);
technique->compile(); technique->compile();
@ -805,10 +808,7 @@ namespace MWRender
if (techniqueName.empty()) if (techniqueName.empty())
continue; continue;
auto technique = loadTechnique(techniqueName); mTechniques.push_back(loadTechnique(techniqueName));
if (!technique)
continue;
mTechniques.push_back(std::move(technique));
} }
dirtyTechniques(); dirtyTechniques();
@ -831,7 +831,11 @@ namespace MWRender
void PostProcessor::toggleMode() void PostProcessor::toggleMode()
{ {
for (auto& technique : mTemplates) for (auto& technique : mTemplates)
{
if (technique->getStatus() == fx::Technique::Status::File_Not_exists)
continue;
technique->compile(); technique->compile();
}
dirtyTechniques(true); dirtyTechniques(true);
} }

View File

@ -177,7 +177,7 @@ namespace MWRender
void toggleMode(); void toggleMode();
std::shared_ptr<fx::Technique> loadTechnique(VFS::Path::NormalizedView path, bool loadNextFrame = false); std::shared_ptr<fx::Technique> loadTechnique(VFS::Path::NormalizedView path, bool loadNextFrame = false);
std::shared_ptr<fx::Technique> loadTechnique(const std::string& name, bool loadNextFrame = false); std::shared_ptr<fx::Technique> loadTechnique(std::string_view name, bool loadNextFrame = false);
TechniqueList getChain(); TechniqueList getChain();

View File

@ -136,6 +136,18 @@ namespace VFS::Path
return p; return p;
} }
std::string_view stem() const
{
std::string_view stem = mValue;
std::size_t pos = stem.find_last_of(separator);
if (pos != std::string_view::npos)
stem = stem.substr(pos + 1);
pos = stem.find_first_of(extensionSeparator);
if (pos != std::string_view::npos)
stem = stem.substr(0, pos);
return stem;
}
private: private:
std::string_view mValue; std::string_view mValue;
}; };
@ -273,6 +285,11 @@ namespace VFS::Path
return NormalizedView(*this).parent(); return NormalizedView(*this).parent();
} }
std::string_view stem() const
{
return NormalizedView(*this).stem();
}
private: private:
std::string mValue; std::string mValue;
}; };