From 78588ce79dceef745c6931a12ad1e59677346227 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 28 Nov 2018 23:36:39 +1000 Subject: [PATCH] ShaderCache: Use imgui for shader compilation dialog --- .../Core/VideoCommon/AsyncShaderCompiler.cpp | 2 +- Source/Core/VideoCommon/ShaderCache.cpp | 26 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Source/Core/VideoCommon/AsyncShaderCompiler.cpp b/Source/Core/VideoCommon/AsyncShaderCompiler.cpp index 755f105942..942f293f1b 100644 --- a/Source/Core/VideoCommon/AsyncShaderCompiler.cpp +++ b/Source/Core/VideoCommon/AsyncShaderCompiler.cpp @@ -77,7 +77,7 @@ void AsyncShaderCompiler::WaitUntilCompletion( // Wait a second before opening a progress dialog. // This way, if the operation completes quickly, we don't annoy the user. - constexpr u32 CHECK_INTERVAL_MS = 50; + constexpr u32 CHECK_INTERVAL_MS = 1000 / 30; constexpr auto CHECK_INTERVAL = std::chrono::milliseconds(CHECK_INTERVAL_MS); for (u32 i = 0; i < (1000 / CHECK_INTERVAL_MS); i++) { diff --git a/Source/Core/VideoCommon/ShaderCache.cpp b/Source/Core/VideoCommon/ShaderCache.cpp index 299b0d1bca..3b0c110f96 100644 --- a/Source/Core/VideoCommon/ShaderCache.cpp +++ b/Source/Core/VideoCommon/ShaderCache.cpp @@ -8,7 +8,6 @@ #include "Common/FileUtil.h" #include "Common/MsgHandler.h" #include "Core/ConfigManager.h" -#include "Core/Host.h" #include "VideoCommon/FramebufferManagerBase.h" #include "VideoCommon/RenderBase.h" @@ -16,6 +15,8 @@ #include "VideoCommon/VertexLoaderManager.h" #include "VideoCommon/VertexManagerBase.h" +#include "imgui.h" + std::unique_ptr g_shader_cache; namespace VideoCommon @@ -153,12 +154,29 @@ void ShaderCache::WaitForAsyncCompiler() while (m_async_shader_compiler->HasPendingWork() || m_async_shader_compiler->HasCompletedWork()) { m_async_shader_compiler->WaitUntilCompletion([](size_t completed, size_t total) { - Host_UpdateProgressDialog(GetStringT("Compiling shaders...").c_str(), - static_cast(completed), static_cast(total)); + g_renderer->BeginUIFrame(); + + const float scale = ImGui::GetIO().DisplayFramebufferScale.x; + + ImGui::SetNextWindowSize(ImVec2(400.0f * scale, 50.0f * scale), ImGuiCond_Always); + ImGui::SetNextWindowPosCenter(ImGuiCond_Always); + if (ImGui::Begin(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(completed) / + static_cast(std::max(total, static_cast(1))), + ImVec2(-1.0f, 0.0f), ""); + } + ImGui::End(); + + g_renderer->EndUIFrame(); }); m_async_shader_compiler->RetrieveWorkItems(); } - Host_UpdateProgressDialog("", -1, -1); } template