Skip to content

Commit

Permalink
chore: use progress bar instead of text
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed Sep 15, 2023
1 parent 5792521 commit 1bfe1b0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,18 +571,23 @@ void Menu::DrawOverlay()
compiledShaders = shaderCache.GetCompletedTasks();
totalShaders = shaderCache.GetTotalTasks();

auto state = State::GetSingleton();

auto failed = shaderCache.GetFailedTasks();
auto hide = shaderCache.IsHideErrors();
auto stats = shaderCache.GetShaderStatsString();
auto progressTitle = state->IsDeveloperMode() ? fmt::format("Compiling Shaders: {}", stats) : fmt::format("Compiling Shaders: {}", shaderCache.GetShaderStatsString(true).c_str());
auto percent = (float)compiledShaders / (float)totalShaders;
auto progressOverlay = fmt::format("{}/{} ({:2.1f}%)", compiledShaders, totalShaders, 100 * percent);
if (shaderCache.IsCompiling()) {
ImGui::SetNextWindowBgAlpha(1);
ImGui::SetNextWindowPos(ImVec2(10, 10));
if (!ImGui::Begin("ShaderCompilationInfo", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings)) {
ImGui::End();
return;
}

ImGui::Text(fmt::format("Compiling Shaders: {}", stats).c_str());
ImGui::TextUnformatted(progressTitle.c_str());
ImGui::ProgressBar(percent, ImVec2(0.0f, 0.0f), progressOverlay.c_str());

ImGui::End();
} else if (failed && !hide) {
Expand Down
10 changes: 7 additions & 3 deletions src/ShaderCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1449,9 +1449,9 @@ namespace SIE
return ShaderCompilationTask::Status::Pending;
}

std::string ShaderCache::GetShaderStatsString()
std::string ShaderCache::GetShaderStatsString(bool a_timeOnly)
{
return compilationSet.GetStatsString();
return compilationSet.GetStatsString(a_timeOnly);
}

bool ShaderCache::IsCompiling()
Expand Down Expand Up @@ -1767,8 +1767,12 @@ namespace SIE
return remaining / rate;
}

std::string CompilationSet::GetStatsString()
std::string CompilationSet::GetStatsString(bool a_timeOnly)
{
if (a_timeOnly)
return fmt::format("{}/{}",
GetHumanTime(totalMs),
GetHumanTime(GetEta() + totalMs));
return fmt::format("{}/{} (successful/total)\tfailed: {}\tcachehits: {}\nElapsed/Estimated Time: {}/{}",
(std::uint64_t)completedTasks,
(std::uint64_t)totalTasks,
Expand Down
4 changes: 2 additions & 2 deletions src/ShaderCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace SIE
void Clear();
std::string GetHumanTime(double a_totalms);
double GetEta();
std::string GetStatsString();
std::string GetStatsString(bool a_timeOnly = false);
std::atomic<uint64_t> completedTasks = 0;
std::atomic<uint64_t> totalTasks = 0;
std::atomic<uint64_t> failedTasks = 0;
Expand Down Expand Up @@ -132,7 +132,7 @@ namespace SIE
ID3DBlob* GetCompletedShader(const SIE::ShaderCompilationTask& a_task);
ID3DBlob* GetCompletedShader(ShaderClass shaderClass, const RE::BSShader& shader, uint32_t descriptor);
ShaderCompilationTask::Status GetShaderStatus(const std::string a_key);
std::string GetShaderStatsString();
std::string GetShaderStatsString(bool a_timeOnly = false);

RE::BSGraphics::VertexShader* GetVertexShader(const RE::BSShader& shader, uint32_t descriptor);
RE::BSGraphics::PixelShader* GetPixelShader(const RE::BSShader& shader,
Expand Down

0 comments on commit 1bfe1b0

Please sign in to comment.