mirror of
https://github.com/patchzyy/wiicompiled
synced 2026-10-20 13:36:47 -04:00
Shader wait screen
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <limits>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@@ -162,6 +163,11 @@ uint64_t g_presentedFrame = 0;
|
||||
std::atomic_bool g_strapInputAccepted = false;
|
||||
std::atomic_uint64_t g_startupDismissFrame = UINT64_MAX;
|
||||
constexpr uint64_t kStrapTransitionCoverFrames = 60;
|
||||
std::atomic_bool g_bootShadersReady = false;
|
||||
bool g_bootShaderNotice = false;
|
||||
Clock::time_point g_bootShaderWaitStart{};
|
||||
constexpr uint32_t kBootShaderNoticeThreshold = 100;
|
||||
constexpr auto kBootShaderWaitLimit = std::chrono::minutes(3);
|
||||
|
||||
constexpr std::array<ResolutionItem, 8> kResolutions = {{
|
||||
{"Auto (window size)", 0.0f}, {"Native (1x)", 1.0f}, {"1.5x", 1.5f}, {"2x", 2.0f},
|
||||
@@ -1193,12 +1199,36 @@ void DrawStartupScreen() {
|
||||
const float startY = std::max(0.0f, (viewport->Size.y - titleSize.y) * 0.5f);
|
||||
ImGui::SetCursorPos(ImVec2(titleX, startY));
|
||||
ImGui::TextUnformatted(kTitle);
|
||||
if (g_bootShaderNotice && !g_bootShadersReady.load(std::memory_order_relaxed)) {
|
||||
ImGui::SetWindowFontScale(0.9f);
|
||||
char line[96];
|
||||
std::snprintf(line, sizeof(line), "Compiling shaders, please hold on: %u remaining",
|
||||
aurora_get_queued_pipeline_count());
|
||||
const float lineX = std::max(0.0f, (viewport->Size.x - ImGui::CalcTextSize(line).x) * 0.5f);
|
||||
ImGui::SetCursorPos(ImVec2(lineX, startY + titleSize.y * 1.8f));
|
||||
ImGui::TextUnformatted(line);
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
void UpdateBootShaderState() {
|
||||
if (g_bootShadersReady.load(std::memory_order_relaxed)) {
|
||||
return;
|
||||
}
|
||||
const auto now = Clock::now();
|
||||
if (g_bootShaderWaitStart == Clock::time_point{}) {
|
||||
g_bootShaderWaitStart = now;
|
||||
}
|
||||
const uint32_t queued = aurora_get_queued_pipeline_count();
|
||||
g_bootShaderNotice |= queued > kBootShaderNoticeThreshold;
|
||||
if (queued == 0 || now - g_bootShaderWaitStart > kBootShaderWaitLimit) {
|
||||
g_bootShadersReady.store(true, std::memory_order_release);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawExitPrompt() {
|
||||
constexpr const char* kTitle = "Exit";
|
||||
if (g_exitPromptOpen && !ImGui::IsPopupOpen(kTitle)) ImGui::OpenPopup(kTitle);
|
||||
@@ -1348,7 +1378,7 @@ void PersistDisplayModeIfChanged() {
|
||||
|
||||
void ApplyInputBlockState() {
|
||||
const bool blocked = controller_mapping_wizard::IsActive() || g_rebind.active ||
|
||||
g_exitPromptOpen || g_topBarVisible;
|
||||
g_exitPromptOpen || g_topBarVisible || StartupScreenVisible();
|
||||
PADBlockInput(blocked);
|
||||
InputBindings::SetInputBlocked(blocked);
|
||||
}
|
||||
@@ -1376,6 +1406,9 @@ void InitializeRuntimeSettings() noexcept {
|
||||
aurora_set_skip_unready_pipelines(g_skipUnreadyPipelines);
|
||||
g_strapInputAccepted.store(false, std::memory_order_relaxed);
|
||||
g_startupDismissFrame.store(UINT64_MAX, std::memory_order_relaxed);
|
||||
g_bootShadersReady.store(false, std::memory_order_relaxed);
|
||||
g_bootShaderNotice = false;
|
||||
g_bootShaderWaitStart = {};
|
||||
PADBlockInput(false);
|
||||
InputBindings::SetInputBlocked(false);
|
||||
}
|
||||
@@ -1456,6 +1489,7 @@ void Draw() noexcept {
|
||||
ApplyConfiguredMappings();
|
||||
PersistDisplayModeIfChanged();
|
||||
UpdateCursorAutoHide();
|
||||
UpdateBootShaderState();
|
||||
if (!StartupScreenVisible()) {
|
||||
DrawShaderCompilationStatus();
|
||||
}
|
||||
@@ -1469,6 +1503,7 @@ void Draw() noexcept {
|
||||
|
||||
bool StartupScreenVisible() noexcept {
|
||||
return !g_strapInputAccepted.load(std::memory_order_acquire) ||
|
||||
!g_bootShadersReady.load(std::memory_order_acquire) ||
|
||||
g_presentedFrame < g_startupDismissFrame.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user