From 2dfd24d52ebfabddccc2e302107e417be553c86a Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Wed, 23 Oct 2024 00:56:37 -0700 Subject: [PATCH] refactor: unify shadercache clearing Move feature clearing into shadercache. This includes deferred clearing. --- src/Menu.cpp | 13 +------------ src/ShaderCache.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Menu.cpp b/src/Menu.cpp index bafc080b8..2dadfc8bf 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -276,12 +276,7 @@ void Menu::DrawSettings() ImGui::TableNextColumn(); if (ImGui::Button("Clear Shader Cache", { -1, 0 })) { shaderCache.Clear(); - Deferred::GetSingleton()->ClearShaderCache(); - for (auto* feature : Feature::GetFeatureList()) { - if (feature->loaded) { - feature->ClearShaderCache(); - } - } + // any features should be added to shadercache's clear. } if (auto _tt = Util::HoverTooltipWrapper()) { ImGui::Text( @@ -772,12 +767,6 @@ void Menu::DrawAdvancedSettings() ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_KeypadEnter))))) { State::GetSingleton()->SetDefines(shaderDefines); shaderCache.Clear(); - Deferred::GetSingleton()->ClearShaderCache(); - for (auto* feature : Feature::GetFeatureList()) { - if (feature->loaded) { - feature->ClearShaderCache(); - } - } } if (auto _tt = Util::HoverTooltipWrapper()) { ImGui::Text("Defines for Shader Compiler. Semicolon \";\" separated. Clear with space. Rebuild shaders after making change. Compute Shaders require a restart to recompile."); diff --git a/src/ShaderCache.cpp b/src/ShaderCache.cpp index 2eba44231..4fe1141ad 100644 --- a/src/ShaderCache.cpp +++ b/src/ShaderCache.cpp @@ -1854,6 +1854,12 @@ namespace SIE hlslToShaderMap.clear(); } compilationSet.Clear(); + Deferred::GetSingleton()->ClearShaderCache(); + for (auto* feature : Feature::GetFeatureList()) { + if (feature->loaded) { + feature->ClearShaderCache(); + } + } } template