From 261985978660edde9245e4fbfd808ec7efb86737 Mon Sep 17 00:00:00 2001 From: Cody Glassman Date: Tue, 1 Jul 2025 13:57:49 -0700 Subject: [PATCH] fix invalid deletion for shaders --- apps/openmw/mwgui/postprocessorhud.cpp | 5 +---- apps/openmw/mwrender/postprocessor.cpp | 20 +++++++++----------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwgui/postprocessorhud.cpp b/apps/openmw/mwgui/postprocessorhud.cpp index 8f5b20ba98..7712594c54 100644 --- a/apps/openmw/mwgui/postprocessorhud.cpp +++ b/apps/openmw/mwgui/postprocessorhud.cpp @@ -301,7 +301,7 @@ namespace MWGui auto technique = processor->loadTechnique(name); - if (!technique || technique->getStatus() == fx::Technique::Status::File_Not_exists) + if (technique->getStatus() == fx::Technique::Status::File_Not_exists) return; while (mConfigArea->getChildCount() > 0) @@ -432,9 +432,6 @@ namespace MWGui { auto technique = processor->loadTechnique(name); - if (!technique) - continue; - if (!technique->getHidden() && !processor->isTechniqueEnabled(technique)) { std::string lowerName = Utf8Stream::lowerCaseUtf8(name); diff --git a/apps/openmw/mwrender/postprocessor.cpp b/apps/openmw/mwrender/postprocessor.cpp index 8b835a4d47..be7306777e 100644 --- a/apps/openmw/mwrender/postprocessor.cpp +++ b/apps/openmw/mwrender/postprocessor.cpp @@ -348,7 +348,7 @@ namespace MWRender for (auto& technique : mTechniques) { - if (!technique || technique->getStatus() == fx::Technique::Status::File_Not_exists) + if (technique->getStatus() == fx::Technique::Status::File_Not_exists) continue; const auto lastWriteTime = std::filesystem::last_write_time(mTechniqueFileMap[technique->getName()]); @@ -570,7 +570,7 @@ namespace MWRender for (const auto& technique : mTechniques) { - if (!technique || !technique->isValid()) + if (!technique->isValid()) continue; if (technique->getGLSLVersion() > mGLSLVersion) @@ -712,7 +712,7 @@ namespace MWRender PostProcessor::Status PostProcessor::enableTechnique( std::shared_ptr technique, std::optional location) { - if (!technique || technique->getLocked() || (location.has_value() && location.value() < 0)) + if (technique->getLocked() || (location.has_value() && location.value() < 0)) return Status_Error; disableTechnique(technique, false); @@ -727,7 +727,7 @@ namespace MWRender PostProcessor::Status PostProcessor::disableTechnique(std::shared_ptr technique, bool dirty) { - if (!technique || technique->getLocked()) + if (technique->getLocked()) return Status_Error; auto it = std::find(mTechniques.begin(), mTechniques.end(), technique); @@ -743,9 +743,6 @@ namespace MWRender bool PostProcessor::isTechniqueEnabled(const std::shared_ptr& technique) const { - if (!technique) - return false; - if (auto it = std::find(mTechniques.begin(), mTechniques.end(), technique); it == mTechniques.end()) return false; @@ -812,7 +809,7 @@ namespace MWRender for (const auto& technique : mTechniques) { - if (!technique || technique->getDynamic() || technique->getInternal()) + if (technique->getDynamic() || technique->getInternal()) continue; chain.push_back(technique->getName()); } @@ -830,9 +827,10 @@ namespace MWRender void PostProcessor::disableDynamicShaders() { - for (auto& technique : mTechniques) - if (technique && technique->getDynamic()) - disableTechnique(technique); + auto erased = std::erase_if(mTechniques, [](const auto& technique) { return technique->getDynamic(); }); + + if (erased) + dirtyTechniques(); } int PostProcessor::renderWidth() const