From 67893fb8f827ff1f4ba471103ad2fd5e4153ff62 Mon Sep 17 00:00:00 2001 From: Elad Ashkenazi <18193363+elad335@users.noreply.github.com> Date: Thu, 30 May 2024 09:42:44 +0300 Subject: [PATCH] PPU Progress Hint: Show it as long as it needs --- .../Overlays/overlay_compile_notification.cpp | 10 ++++++--- .../Overlays/overlay_compile_notification.h | 5 ++++- rpcs3/Emu/RSX/Overlays/overlay_message.cpp | 11 ++++++++++ rpcs3/Emu/RSX/Overlays/overlay_message.h | 1 + rpcs3/Emu/system_progress.cpp | 22 ++++++++++++++++--- 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_compile_notification.cpp b/rpcs3/Emu/RSX/Overlays/overlay_compile_notification.cpp index e92079d448..f7827c9155 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_compile_notification.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_compile_notification.cpp @@ -27,7 +27,7 @@ namespace rsx true); } - void show_ppu_compile_notification() + std::shared_ptr> show_ppu_compile_notification() { if (!s_ppu_loading_icon24) { @@ -35,13 +35,17 @@ namespace rsx s_ppu_loading_icon24 = std::make_shared(); } + std::shared_ptr> refs = std::make_shared>(1); + queue_message( localized_string_id::RSX_OVERLAYS_COMPILING_PPU_MODULES, - 5'000'000, - {}, + 20'000'000, + refs, message_pin_location::bottom, s_ppu_loading_icon24, true); + + return refs; } } } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_compile_notification.h b/rpcs3/Emu/RSX/Overlays/overlay_compile_notification.h index 412b442171..026770b7a4 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_compile_notification.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_compile_notification.h @@ -1,10 +1,13 @@ #pragma once +#include "util/types.hpp" +#include "util/atomic.hpp" + namespace rsx { namespace overlays { void show_shader_compile_notification(); - void show_ppu_compile_notification(); + std::shared_ptr> show_ppu_compile_notification(); } } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message.cpp b/rpcs3/Emu/RSX/Overlays/overlay_message.cpp index fe3497ad0f..25a331d0df 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_message.cpp @@ -66,6 +66,15 @@ namespace rsx return m_refs && *m_refs == 0 ? 0 : m_expiration_time; } + void message_item::ensure_expired() + { + // If reference counting is enabled and reached 0 consider it expired + if (m_refs) + { + *m_refs = 0; + } + } + bool message_item::text_matches(const std::u32string& text) const { return m_text.text == text; @@ -165,6 +174,8 @@ namespace rsx { if (it->get_expiration() < cur_time) { + // Enusre reference counter is updated on timeout + it->ensure_expired(); it = vis_set.erase(it); } else diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message.h b/rpcs3/Emu/RSX/Overlays/overlay_message.h index 348407d9f3..cd3474aa0f 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_message.h @@ -25,6 +25,7 @@ namespace rsx void reset_expiration(); u64 get_expiration() const; + void ensure_expired(); compiled_resource& get_compiled() override; bool text_matches(const std::u32string& text) const; diff --git a/rpcs3/Emu/system_progress.cpp b/rpcs3/Emu/system_progress.cpp index 6d7f9e2b3b..231f594a75 100644 --- a/rpcs3/Emu/system_progress.cpp +++ b/rpcs3/Emu/system_progress.cpp @@ -167,7 +167,9 @@ void progress_dialog_server::operator()() const char* text1 = nullptr; const u64 start_time = get_system_time(); - u64 wait_no_update_count = 0; + u64 wait_no_update_count = 0; + + std::shared_ptr> ppu_cue_refs; // Update progress while (!g_system_progress_stopping && thread_ctrl::state() != thread_state::aborting) @@ -208,9 +210,18 @@ void progress_dialog_server::operator()() const u64 remaining_usec = pdone ? utils::rational_mul(passed_usec, static_cast(ptotal) - pdone, pdone) : (passed_usec * ptotal); // Only show compile notification if we estimate at least 100ms - if (remaining_usec >= 100'000ULL) + if (remaining_usec >= 100'000ULL && (!ppu_cue_refs || !*ppu_cue_refs)) { - rsx::overlays::show_ppu_compile_notification(); + ppu_cue_refs = rsx::overlays::show_ppu_compile_notification(); + } + } + + if (pdone >= ptotal) + { + if (ppu_cue_refs) + { + *ppu_cue_refs = 0; + ppu_cue_refs.reset(); } } @@ -321,6 +332,11 @@ void progress_dialog_server::operator()() wait_no_update_count++; } + if (ppu_cue_refs) + { + *ppu_cue_refs = 0; + } + if (g_system_progress_stopping || thread_ctrl::state() == thread_state::aborting) { break;