diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2022-07-02 13:08:37 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-02 13:08:37 +0200 |
| commit | 3bcd7aced92206d24ded30e0a595d2d87875e9f0 (patch) | |
| tree | 1b582773b15ee262c1c8650d2ba6adcb40f9c73b /Source/Core/VideoCommon/ShaderCache.cpp | |
| parent | 2f228310affd10297d4e7d61ad2aa2c910b69eac (diff) | |
| parent | 7faf5ea170f23de3b4a7b9362926490c5b7a97bc (diff) | |
Merge pull request #8467 from CookiePLMonster/interruptable-shader-precompile
Make shader precompilation interruptable
Diffstat (limited to 'Source/Core/VideoCommon/ShaderCache.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/ShaderCache.cpp | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/Source/Core/VideoCommon/ShaderCache.cpp b/Source/Core/VideoCommon/ShaderCache.cpp index 81aa4cd8a6..8bc14d28ed 100644 --- a/Source/Core/VideoCommon/ShaderCache.cpp +++ b/Source/Core/VideoCommon/ShaderCache.cpp @@ -157,34 +157,44 @@ const AbstractPipeline* ShaderCache::GetUberPipelineForUid(const GXUberPipelineU void ShaderCache::WaitForAsyncCompiler() { - while (m_async_shader_compiler->HasPendingWork() || m_async_shader_compiler->HasCompletedWork()) + bool running = true; + + constexpr auto update_ui_progress = [](size_t completed, size_t total) { + g_renderer->BeginUIFrame(); + + const float center_x = ImGui::GetIO().DisplaySize.x * 0.5f; + const float center_y = ImGui::GetIO().DisplaySize.y * 0.5f; + const float scale = ImGui::GetIO().DisplayFramebufferScale.x; + + ImGui::SetNextWindowSize(ImVec2(400.0f * scale, 50.0f * scale), ImGuiCond_Always); + ImGui::SetNextWindowPos(ImVec2(center_x, center_y), ImGuiCond_Always, ImVec2(0.5f, 0.5f)); + if (ImGui::Begin(Common::GetStringT("Compiling Shaders").c_str(), nullptr, + ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | + ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | + ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNav | + ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing)) + { + ImGui::Text("Compiling shaders: %zu/%zu", completed, total); + ImGui::ProgressBar(static_cast<float>(completed) / + static_cast<float>(std::max(total, static_cast<size_t>(1))), + ImVec2(-1.0f, 0.0f), ""); + } + ImGui::End(); + + g_renderer->EndUIFrame(); + }; + + while (running && + (m_async_shader_compiler->HasPendingWork() || m_async_shader_compiler->HasCompletedWork())) { - m_async_shader_compiler->WaitUntilCompletion([](size_t completed, size_t total) { - g_renderer->BeginUIFrame(); - - const float center_x = ImGui::GetIO().DisplaySize.x * 0.5f; - const float center_y = ImGui::GetIO().DisplaySize.y * 0.5f; - const float scale = ImGui::GetIO().DisplayFramebufferScale.x; - - ImGui::SetNextWindowSize(ImVec2(400.0f * scale, 50.0f * scale), ImGuiCond_Always); - ImGui::SetNextWindowPos(ImVec2(center_x, center_y), ImGuiCond_Always, ImVec2(0.5f, 0.5f)); - if (ImGui::Begin(Common::GetStringT("Compiling Shaders").c_str(), nullptr, - ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | - ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | - ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNav | - ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing)) - { - ImGui::Text("Compiling shaders: %zu/%zu", completed, total); - ImGui::ProgressBar(static_cast<float>(completed) / - static_cast<float>(std::max(total, static_cast<size_t>(1))), - ImVec2(-1.0f, 0.0f), ""); - } - ImGui::End(); + running = m_async_shader_compiler->WaitUntilCompletion(update_ui_progress); - g_renderer->EndUIFrame(); - }); m_async_shader_compiler->RetrieveWorkItems(); } + + // Just render nothing to clear the screen + g_renderer->BeginUIFrame(); + g_renderer->EndUIFrame(); } template <typename SerializedUidType, typename UidType> |
