Skip to content

Commit

Permalink
refactor: unify shadercache clearing
Browse files Browse the repository at this point in the history
Move feature clearing into shadercache. This includes deferred clearing.
  • Loading branch information
alandtse committed Oct 24, 2024
1 parent e0f4c98 commit 2dfd24d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
13 changes: 1 addition & 12 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.");
Expand Down
6 changes: 6 additions & 0 deletions src/ShaderCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,12 @@ namespace SIE
hlslToShaderMap.clear();
}
compilationSet.Clear();
Deferred::GetSingleton()->ClearShaderCache();
for (auto* feature : Feature::GetFeatureList()) {
if (feature->loaded) {
feature->ClearShaderCache();
}
}
}

template <typename ShaderType, typename MutexType>
Expand Down

0 comments on commit 2dfd24d

Please sign in to comment.