diff --git a/apps/openmw/mwrender/postprocessor.cpp b/apps/openmw/mwrender/postprocessor.cpp index 3a2d5218d5..379b71bc66 100644 --- a/apps/openmw/mwrender/postprocessor.cpp +++ b/apps/openmw/mwrender/postprocessor.cpp @@ -748,7 +748,7 @@ namespace MWRender return technique->isValid(); } - std::shared_ptr PostProcessor::loadTechnique(const std::string& name, bool loadNextFrame) + std::shared_ptr PostProcessor::loadTechnique(std::string_view name, bool loadNextFrame) { VFS::Path::Normalized path = fx::Technique::makeFileName(name); return loadTechnique(VFS::Path::NormalizedView(path), loadNextFrame); @@ -764,11 +764,14 @@ namespace MWRender if (technique->getFileName() == path) return technique; - if (!mTechniqueFiles.contains(path)) - return {}; + std::string name; + if (mTechniqueFiles.contains(path)) + name = mVFS->getStem(path); + else + name = path.stem(); auto technique = std::make_shared(*mVFS, *mRendering.getResourceSystem()->getImageManager(), - path, mVFS->getStem(path), renderWidth(), renderHeight(), mUBO, mNormalsSupported); + path, std::move(name), renderWidth(), renderHeight(), mUBO, mNormalsSupported); technique->compile(); @@ -805,10 +808,7 @@ namespace MWRender if (techniqueName.empty()) continue; - auto technique = loadTechnique(techniqueName); - if (!technique) - continue; - mTechniques.push_back(std::move(technique)); + mTechniques.push_back(loadTechnique(techniqueName)); } dirtyTechniques(); @@ -831,7 +831,11 @@ namespace MWRender void PostProcessor::toggleMode() { for (auto& technique : mTemplates) + { + if (technique->getStatus() == fx::Technique::Status::File_Not_exists) + continue; technique->compile(); + } dirtyTechniques(true); } diff --git a/apps/openmw/mwrender/postprocessor.hpp b/apps/openmw/mwrender/postprocessor.hpp index 4b854cbc9c..eb9bc6347c 100644 --- a/apps/openmw/mwrender/postprocessor.hpp +++ b/apps/openmw/mwrender/postprocessor.hpp @@ -177,7 +177,7 @@ namespace MWRender void toggleMode(); std::shared_ptr loadTechnique(VFS::Path::NormalizedView path, bool loadNextFrame = false); - std::shared_ptr loadTechnique(const std::string& name, bool loadNextFrame = false); + std::shared_ptr loadTechnique(std::string_view name, bool loadNextFrame = false); TechniqueList getChain(); diff --git a/components/vfs/pathutil.hpp b/components/vfs/pathutil.hpp index b4b4f6e278..a890be8a54 100644 --- a/components/vfs/pathutil.hpp +++ b/components/vfs/pathutil.hpp @@ -136,6 +136,18 @@ namespace VFS::Path 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: std::string_view mValue; }; @@ -273,6 +285,11 @@ namespace VFS::Path return NormalizedView(*this).parent(); } + std::string_view stem() const + { + return NormalizedView(*this).stem(); + } + private: std::string mValue; };