mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 22:11:26 +12:00
overlays: fix some warnings, simplify code, use move and references
This commit is contained in:
parent
4794869bd8
commit
d8af3ea855
13 changed files with 65 additions and 71 deletions
|
@ -2494,7 +2494,7 @@ std::pair<std::shared_ptr<lv2_overlay>, CellError> ppu_load_overlay(const ppu_ex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto ovlm = std::make_shared<lv2_overlay>();
|
std::shared_ptr<lv2_overlay> ovlm = std::make_shared<lv2_overlay>();
|
||||||
|
|
||||||
// Set path (TODO)
|
// Set path (TODO)
|
||||||
ovlm->name = path.substr(path.find_last_of('/') + 1);
|
ovlm->name = path.substr(path.find_last_of('/') + 1);
|
||||||
|
|
|
@ -3751,7 +3751,7 @@ extern void ppu_precompile(std::vector<std::string>& dir_queue, std::vector<ppu_
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto [path, offset] = std::as_const(file_queue)[func_i];
|
auto& [path, offset] = file_queue[func_i];
|
||||||
|
|
||||||
ppu_log.notice("Trying to load: %s", path);
|
ppu_log.notice("Trying to load: %s", path);
|
||||||
|
|
||||||
|
@ -3802,7 +3802,7 @@ extern void ppu_precompile(std::vector<std::string>& dir_queue, std::vector<ppu_
|
||||||
{
|
{
|
||||||
while (ovl_err == elf_error::ok)
|
while (ovl_err == elf_error::ok)
|
||||||
{
|
{
|
||||||
auto [ovlm, error] = ppu_load_overlay(obj, true, path, offset);
|
const auto [ovlm, error] = ppu_load_overlay(obj, true, path, offset);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
|
@ -4627,7 +4627,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only)
|
||||||
*progr = "Linking PPU modules...";
|
*progr = "Linking PPU modules...";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto [obj_name, is_compiled] : link_workload)
|
for (const auto& [obj_name, is_compiled] : link_workload)
|
||||||
{
|
{
|
||||||
if (cpu ? cpu->state.all_of(cpu_flag::exit) : Emu.IsStopped())
|
if (cpu ? cpu->state.all_of(cpu_flag::exit) : Emu.IsStopped())
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace rsx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_loading_dialog::update_msg(u32 index, const std::string& msg)
|
void shader_loading_dialog::update_msg(u32 index, std::string msg)
|
||||||
{
|
{
|
||||||
if (!dlg)
|
if (!dlg)
|
||||||
{
|
{
|
||||||
|
@ -49,9 +49,9 @@ namespace rsx
|
||||||
|
|
||||||
ref_cnt++;
|
ref_cnt++;
|
||||||
|
|
||||||
Emu.CallFromMainThread([&, index, msg]()
|
Emu.CallFromMainThread([&, index, message = std::move(msg)]()
|
||||||
{
|
{
|
||||||
dlg->ProgressBarSetMsg(index, msg);
|
dlg->ProgressBarSetMsg(index, message);
|
||||||
ref_cnt--;
|
ref_cnt--;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace rsx
|
||||||
|
|
||||||
virtual ~shader_loading_dialog() = default;
|
virtual ~shader_loading_dialog() = default;
|
||||||
virtual void create(const std::string& msg, const std::string& title);
|
virtual void create(const std::string& msg, const std::string& title);
|
||||||
virtual void update_msg(u32 index, const std::string& msg);
|
virtual void update_msg(u32 index, std::string msg);
|
||||||
virtual void inc_value(u32 index, u32 value);
|
virtual void inc_value(u32 index, u32 value);
|
||||||
virtual void set_value(u32 index, u32 value);
|
virtual void set_value(u32 index, u32 value);
|
||||||
virtual void set_limit(u32 index, u32 limit);
|
virtual void set_limit(u32 index, u32 limit);
|
||||||
|
|
|
@ -31,9 +31,9 @@ namespace rsx
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_loading_dialog_native::update_msg(u32 index, const std::string& msg)
|
void shader_loading_dialog_native::update_msg(u32 index, std::string msg)
|
||||||
{
|
{
|
||||||
dlg->progress_bar_set_message(index, msg);
|
dlg->progress_bar_set_message(index, std::move(msg));
|
||||||
owner->flip({});
|
owner->flip({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace rsx
|
||||||
shader_loading_dialog_native(GSRender* ptr);
|
shader_loading_dialog_native(GSRender* ptr);
|
||||||
|
|
||||||
void create(const std::string& msg, const std::string&/* title*/) override;
|
void create(const std::string& msg, const std::string&/* title*/) override;
|
||||||
void update_msg(u32 index, const std::string& msg) override;
|
void update_msg(u32 index, std::string msg) override;
|
||||||
void inc_value(u32 index, u32 value) override;
|
void inc_value(u32 index, u32 value) override;
|
||||||
void set_value(u32 index, u32 value) override;
|
void set_value(u32 index, u32 value) override;
|
||||||
void set_limit(u32 index, u32 limit) override;
|
void set_limit(u32 index, u32 limit) override;
|
||||||
|
|
|
@ -342,9 +342,9 @@ namespace rsx
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void message_dialog::set_text(const std::string& text)
|
void message_dialog::set_text(std::string text)
|
||||||
{
|
{
|
||||||
text_guard.set_text(text);
|
text_guard.set_text(std::move(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
void message_dialog::update_custom_background()
|
void message_dialog::update_custom_background()
|
||||||
|
@ -411,12 +411,12 @@ namespace rsx
|
||||||
taskbar_index = index;
|
taskbar_index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code message_dialog::progress_bar_set_message(u32 index, const std::string& msg)
|
error_code message_dialog::progress_bar_set_message(u32 index, std::string msg)
|
||||||
{
|
{
|
||||||
if (index >= num_progress_bars)
|
if (index >= num_progress_bars)
|
||||||
return CELL_MSGDIALOG_ERROR_PARAM;
|
return CELL_MSGDIALOG_ERROR_PARAM;
|
||||||
|
|
||||||
::at32(bar_text_guard, index).set_text(msg);
|
::at32(bar_text_guard, index).set_text(std::move(msg));
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,12 +72,12 @@ namespace rsx
|
||||||
|
|
||||||
error_code show(bool is_blocking, const std::string& text, const MsgDialogType& type, std::function<void(s32 status)> on_close);
|
error_code show(bool is_blocking, const std::string& text, const MsgDialogType& type, std::function<void(s32 status)> on_close);
|
||||||
|
|
||||||
void set_text(const std::string& text);
|
void set_text(std::string text);
|
||||||
void update_custom_background();
|
void update_custom_background();
|
||||||
|
|
||||||
u32 progress_bar_count() const;
|
u32 progress_bar_count() const;
|
||||||
void progress_bar_set_taskbar_index(s32 index);
|
void progress_bar_set_taskbar_index(s32 index);
|
||||||
error_code progress_bar_set_message(u32 index, const std::string& msg);
|
error_code progress_bar_set_message(u32 index, std::string msg);
|
||||||
error_code progress_bar_increment(u32 index, f32 value);
|
error_code progress_bar_increment(u32 index, f32 value);
|
||||||
error_code progress_bar_set_value(u32 index, f32 value);
|
error_code progress_bar_set_value(u32 index, f32 value);
|
||||||
error_code progress_bar_reset(u32 index);
|
error_code progress_bar_reset(u32 index);
|
||||||
|
|
|
@ -60,10 +60,10 @@ static auto s_ascii_lowering_map = []()
|
||||||
}();
|
}();
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
void process_multibyte(const std::string s, F&& func)
|
void process_multibyte(const std::string& s, F&& func)
|
||||||
{
|
{
|
||||||
const auto end = s.length();
|
const usz end = s.length();
|
||||||
for (u32 index = 0; index < end; ++index)
|
for (usz index = 0; index < end; ++index)
|
||||||
{
|
{
|
||||||
const u8 code = static_cast<u8>(s[index]);
|
const u8 code = static_cast<u8>(s[index]);
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ void process_multibyte(const std::string s, F&& func)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto extra_bytes = (code <= 0xDF) ? 1u : (code <= 0xEF) ? 2u : 3u;
|
const u32 extra_bytes = (code <= 0xDF) ? 1u : (code <= 0xEF) ? 2u : 3u;
|
||||||
if ((index + extra_bytes) > end)
|
if ((index + extra_bytes) > end)
|
||||||
{
|
{
|
||||||
// Malformed string, abort
|
// Malformed string, abort
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace rsx
|
||||||
{
|
{
|
||||||
thread_local DECLARE(user_interface::g_thread_bit) = 0;
|
thread_local DECLARE(user_interface::g_thread_bit) = 0;
|
||||||
|
|
||||||
u64 user_interface::alloc_thread_bit()
|
u32 user_interface::alloc_thread_bit()
|
||||||
{
|
{
|
||||||
auto [_old, ok] = this->thread_bits.fetch_op([](u32& bits)
|
auto [_old, ok] = this->thread_bits.fetch_op([](u32& bits)
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ namespace rsx
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const u64 r = u64{1} << std::countr_one(_old);
|
const u32 r = u32{1} << std::countr_one(_old);
|
||||||
::overlays.trace("Bit allocated (%u)", r);
|
::overlays.trace("Bit allocated (%u)", r);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,9 +90,9 @@ namespace rsx
|
||||||
bool m_keyboard_pad_handler_active = true; // Initialized as true to prevent keyboard input until proven otherwise.
|
bool m_keyboard_pad_handler_active = true; // Initialized as true to prevent keyboard input until proven otherwise.
|
||||||
bool m_allow_input_on_pause = false;
|
bool m_allow_input_on_pause = false;
|
||||||
|
|
||||||
static thread_local u64 g_thread_bit;
|
static thread_local u32 g_thread_bit;
|
||||||
|
|
||||||
u64 alloc_thread_bit();
|
u32 alloc_thread_bit();
|
||||||
|
|
||||||
std::function<void(s32 status)> on_close = nullptr;
|
std::function<void(s32 status)> on_close = nullptr;
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ namespace rsx
|
||||||
|
|
||||||
private:
|
private:
|
||||||
user_interface* m_parent;
|
user_interface* m_parent;
|
||||||
u64 m_thread_bit;
|
u32 m_thread_bit;
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
s32 return_code = 0; // CELL_OK
|
s32 return_code = 0; // CELL_OK
|
||||||
|
|
|
@ -37,6 +37,26 @@ void progress_dialog_server::operator()()
|
||||||
std::shared_ptr<rsx::overlays::progress_dialog> native_dlg;
|
std::shared_ptr<rsx::overlays::progress_dialog> native_dlg;
|
||||||
g_system_progress_stopping = false;
|
g_system_progress_stopping = false;
|
||||||
|
|
||||||
|
const auto get_state = []()
|
||||||
|
{
|
||||||
|
auto whole_state = std::make_tuple(+g_progr.load(), +g_progr_ftotal, +g_progr_fdone, +g_progr_ptotal, +g_progr_pdone);
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
auto new_state = std::make_tuple(+g_progr.load(), +g_progr_ftotal, +g_progr_fdone, +g_progr_ptotal, +g_progr_pdone);
|
||||||
|
|
||||||
|
if (new_state == whole_state)
|
||||||
|
{
|
||||||
|
// Only leave while it has a complete (atomic) state
|
||||||
|
return whole_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
whole_state = std::move(new_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
return whole_state;
|
||||||
|
};
|
||||||
|
|
||||||
while (!g_system_progress_stopping && thread_ctrl::state() != thread_state::aborting)
|
while (!g_system_progress_stopping && thread_ctrl::state() != thread_state::aborting)
|
||||||
{
|
{
|
||||||
// Wait for the start condition
|
// Wait for the start condition
|
||||||
|
@ -51,29 +71,15 @@ void progress_dialog_server::operator()()
|
||||||
|
|
||||||
if (g_progr_ftotal || g_progr_fdone || g_progr_ptotal || g_progr_pdone)
|
if (g_progr_ftotal || g_progr_fdone || g_progr_ptotal || g_progr_pdone)
|
||||||
{
|
{
|
||||||
auto whole_state = std::make_tuple(+g_progr.load(), +g_progr_ftotal, +g_progr_fdone, +g_progr_ptotal, +g_progr_pdone);
|
const auto& [text_new, ftotal, fdone, ptotal, pdone] = get_state();
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
const auto new_state = std::make_tuple(+g_progr.load(), +g_progr_ftotal, +g_progr_fdone, +g_progr_ptotal, +g_progr_pdone);
|
|
||||||
|
|
||||||
if (new_state == whole_state)
|
|
||||||
{
|
|
||||||
// Only leave while it has a complete (atomic) state
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
whole_state = new_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto [text_new, ftotal, fdone, ptotal, pdone] = whole_state;
|
|
||||||
|
|
||||||
if (text_new)
|
if (text_new)
|
||||||
{
|
{
|
||||||
text0 = text_new;
|
text0 = text_new;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ((ftotal || ptotal) && ftotal == fdone && ptotal == pdone)
|
|
||||||
|
if ((ftotal || ptotal) && ftotal == fdone && ptotal == pdone)
|
||||||
{
|
{
|
||||||
// Cleanup (missed message but do not cry over spilt milk)
|
// Cleanup (missed message but do not cry over spilt milk)
|
||||||
g_progr_fdone -= fdone;
|
g_progr_fdone -= fdone;
|
||||||
|
@ -157,22 +163,7 @@ void progress_dialog_server::operator()()
|
||||||
// Update progress
|
// Update progress
|
||||||
while (!g_system_progress_stopping && thread_ctrl::state() != thread_state::aborting)
|
while (!g_system_progress_stopping && thread_ctrl::state() != thread_state::aborting)
|
||||||
{
|
{
|
||||||
auto whole_state = std::make_tuple(+g_progr.load(), +g_progr_ftotal, +g_progr_fdone, +g_progr_ptotal, +g_progr_pdone);
|
const auto& [text_new, ftotal_new, fdone_new, ptotal_new, pdone_new] = get_state();
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
const auto new_state = std::make_tuple(+g_progr.load(), +g_progr_ftotal, +g_progr_fdone, +g_progr_ptotal, +g_progr_pdone);
|
|
||||||
|
|
||||||
if (new_state == whole_state)
|
|
||||||
{
|
|
||||||
// Only leave while it has a complete (atomic) state
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
whole_state = new_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto [text_new, ftotal_new, fdone_new, ptotal_new, pdone_new] = whole_state;
|
|
||||||
|
|
||||||
if (ftotal != ftotal_new || fdone != fdone_new || ptotal != ptotal_new || pdone != pdone_new || text_new != text1)
|
if (ftotal != ftotal_new || fdone != fdone_new || ptotal != ptotal_new || pdone != pdone_new || text_new != text1)
|
||||||
{
|
{
|
||||||
|
@ -191,12 +182,17 @@ void progress_dialog_server::operator()()
|
||||||
if (show_overlay_message)
|
if (show_overlay_message)
|
||||||
{
|
{
|
||||||
// Show a message instead (if compilation period is estimated to be lengthy)
|
// Show a message instead (if compilation period is estimated to be lengthy)
|
||||||
const u64 passed = (get_system_time() - start_time);
|
if (pdone < ptotal && g_cfg.misc.show_ppu_compilation_hint)
|
||||||
|
{
|
||||||
|
const u64 passed_usec = (get_system_time() - start_time);
|
||||||
|
const u64 remaining_usec = passed_usec * (pdone ? ((static_cast<u64>(ptotal) - pdone) / pdone) : ptotal);
|
||||||
|
|
||||||
if (pdone < ptotal && g_cfg.misc.show_ppu_compilation_hint && (pdone ? (passed * (ptotal - pdone) / pdone) : (passed * (ptotal + 1))) >= 100'000)
|
// Only show compile notification if we estimate at least 100ms
|
||||||
|
if (remaining_usec >= 100'000ULL)
|
||||||
{
|
{
|
||||||
rsx::overlays::show_ppu_compile_notification();
|
rsx::overlays::show_ppu_compile_notification();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
thread_ctrl::wait_for(10000);
|
thread_ctrl::wait_for(10000);
|
||||||
continue;
|
continue;
|
||||||
|
@ -219,7 +215,7 @@ void progress_dialog_server::operator()()
|
||||||
if (native_dlg)
|
if (native_dlg)
|
||||||
{
|
{
|
||||||
native_dlg->set_text(text_new);
|
native_dlg->set_text(text_new);
|
||||||
native_dlg->progress_bar_set_message(0, progr);
|
native_dlg->progress_bar_set_message(0, std::move(progr));
|
||||||
native_dlg->progress_bar_set_value(0, std::floor(value));
|
native_dlg->progress_bar_set_value(0, std::floor(value));
|
||||||
}
|
}
|
||||||
else if (dlg)
|
else if (dlg)
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
|
|
||||||
constexpr auto qstr = QString::fromStdString;
|
|
||||||
|
|
||||||
void msg_dialog_frame::Create(const std::string& msg, const std::string& title)
|
void msg_dialog_frame::Create(const std::string& msg, const std::string& title)
|
||||||
{
|
{
|
||||||
state = MsgDialogState::Open;
|
state = MsgDialogState::Open;
|
||||||
|
@ -16,10 +14,10 @@ void msg_dialog_frame::Create(const std::string& msg, const std::string& title)
|
||||||
Close(true);
|
Close(true);
|
||||||
|
|
||||||
m_dialog = new custom_dialog(type.disable_cancel);
|
m_dialog = new custom_dialog(type.disable_cancel);
|
||||||
m_dialog->setWindowTitle(title.empty() ? (type.se_normal ? tr("Normal dialog") : tr("Error dialog")) : qstr(title));
|
m_dialog->setWindowTitle(title.empty() ? (type.se_normal ? tr("Normal dialog") : tr("Error dialog")) : QString::fromStdString(title));
|
||||||
m_dialog->setWindowOpacity(type.bg_invisible ? 1. : 0.75);
|
m_dialog->setWindowOpacity(type.bg_invisible ? 1. : 0.75);
|
||||||
|
|
||||||
m_text = new QLabel(qstr(msg));
|
m_text = new QLabel(QString::fromStdString(msg));
|
||||||
m_text->setAlignment(Qt::AlignCenter);
|
m_text->setAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
// Layout
|
// Layout
|
||||||
|
@ -159,7 +157,7 @@ void msg_dialog_frame::SetMsg(const std::string& msg)
|
||||||
{
|
{
|
||||||
if (m_dialog)
|
if (m_dialog)
|
||||||
{
|
{
|
||||||
m_text->setText(qstr(msg));
|
m_text->setText(QString::fromStdString(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,14 +169,14 @@ void msg_dialog_frame::ProgressBarSetMsg(u32 index, const std::string& msg)
|
||||||
{
|
{
|
||||||
if (m_text1)
|
if (m_text1)
|
||||||
{
|
{
|
||||||
m_text1->setText(qstr(msg));
|
m_text1->setText(QString::fromStdString(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (index == 1)
|
else if (index == 1)
|
||||||
{
|
{
|
||||||
if (m_text2)
|
if (m_text2)
|
||||||
{
|
{
|
||||||
m_text2->setText(qstr(msg));
|
m_text2->setText(QString::fromStdString(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue