mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 21:41:26 +12:00
Savestates: Rename DeferDeserialization, add some asserts
This commit is contained in:
parent
f5d39ef7f2
commit
ce5f7bd4ff
9 changed files with 35 additions and 16 deletions
|
@ -46,7 +46,7 @@ KeyboardHandlerBase::KeyboardHandlerBase(utils::serial* ar)
|
||||||
|
|
||||||
if (m_info.max_connect)
|
if (m_info.max_connect)
|
||||||
{
|
{
|
||||||
Emu.DeferDeserialization([this]()
|
Emu.PostponeInitCode([this]()
|
||||||
{
|
{
|
||||||
Init(m_info.max_connect);
|
Init(m_info.max_connect);
|
||||||
auto lk = init.init();
|
auto lk = init.init();
|
||||||
|
|
|
@ -46,7 +46,7 @@ MouseHandlerBase::MouseHandlerBase(utils::serial* ar)
|
||||||
|
|
||||||
if (m_info.max_connect)
|
if (m_info.max_connect)
|
||||||
{
|
{
|
||||||
Emu.DeferDeserialization([this]()
|
Emu.PostponeInitCode([this]()
|
||||||
{
|
{
|
||||||
Init(m_info.max_connect);
|
Init(m_info.max_connect);
|
||||||
auto lk = init.init();
|
auto lk = init.init();
|
||||||
|
|
|
@ -45,7 +45,7 @@ CellError lv2_cond::on_id_create()
|
||||||
|
|
||||||
ensure(!!Emu.DeserialManager());
|
ensure(!!Emu.DeserialManager());
|
||||||
|
|
||||||
Emu.DeferDeserialization([this]()
|
Emu.PostponeInitCode([this]()
|
||||||
{
|
{
|
||||||
if (!mutex)
|
if (!mutex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,7 +77,7 @@ std::shared_ptr<lv2_event_queue> lv2_event_queue::load_ptr(utils::serial& ar, st
|
||||||
fmt::throw_exception("Failed in event queue pointer deserialization (invalid ID): location: %s, id=0x%x", msg, id);
|
fmt::throw_exception("Failed in event queue pointer deserialization (invalid ID): location: %s, id=0x%x", msg, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Emu.DeferDeserialization([id, &queue, msg_str = std::string{msg}]()
|
Emu.PostponeInitCode([id, &queue, msg_str = std::string{msg}]()
|
||||||
{
|
{
|
||||||
// Defer resolving
|
// Defer resolving
|
||||||
queue = idm::get_unlocked<lv2_obj, lv2_event_queue>(id);
|
queue = idm::get_unlocked<lv2_obj, lv2_event_queue>(id);
|
||||||
|
|
|
@ -28,7 +28,7 @@ lv2_int_tag::lv2_int_tag(utils::serial& ar) noexcept
|
||||||
|
|
||||||
if (!ptr && id)
|
if (!ptr && id)
|
||||||
{
|
{
|
||||||
Emu.DeferDeserialization([id, &handler = this->handler]()
|
Emu.PostponeInitCode([id, &handler = this->handler]()
|
||||||
{
|
{
|
||||||
handler = ensure(idm::get_unlocked<lv2_obj, lv2_int_serv>(id));
|
handler = ensure(idm::get_unlocked<lv2_obj, lv2_int_serv>(id));
|
||||||
});
|
});
|
||||||
|
|
|
@ -105,7 +105,7 @@ u64 lv2_timer::check_unlocked(u64 _now) noexcept
|
||||||
|
|
||||||
lv2_timer_thread::lv2_timer_thread()
|
lv2_timer_thread::lv2_timer_thread()
|
||||||
{
|
{
|
||||||
Emu.DeferDeserialization([this]()
|
Emu.PostponeInitCode([this]()
|
||||||
{
|
{
|
||||||
idm::select<lv2_obj, lv2_timer>([&](u32 id, lv2_timer&)
|
idm::select<lv2_obj, lv2_timer>([&](u32 id, lv2_timer&)
|
||||||
{
|
{
|
||||||
|
|
|
@ -202,22 +202,36 @@ void init_fxo_for_exec(utils::serial* ar, bool full = false)
|
||||||
|
|
||||||
Emu.ConfigurePPUCache();
|
Emu.ConfigurePPUCache();
|
||||||
|
|
||||||
g_fxo->init(false, ar);
|
g_fxo->init(false, ar, [](){ Emu.ExecPostponedInitCode(); });
|
||||||
|
|
||||||
Emu.GetCallbacks().init_gs_render(ar);
|
Emu.GetCallbacks().init_gs_render(ar);
|
||||||
Emu.GetCallbacks().init_pad_handler(Emu.GetTitleID());
|
Emu.GetCallbacks().init_pad_handler(Emu.GetTitleID());
|
||||||
Emu.GetCallbacks().init_kb_handler();
|
Emu.GetCallbacks().init_kb_handler();
|
||||||
Emu.GetCallbacks().init_mouse_handler();
|
Emu.GetCallbacks().init_mouse_handler();
|
||||||
|
|
||||||
|
usz pos = 0;
|
||||||
|
|
||||||
if (ar)
|
if (ar)
|
||||||
{
|
{
|
||||||
Emu.ExecDeserializationRemnants();
|
pos = ar->pos;
|
||||||
|
}
|
||||||
|
|
||||||
[[maybe_unused]] auto flags = (*ar)(Emu.m_savestate_extension_flags1);
|
// TODO: Remove second call when possible
|
||||||
|
Emu.ExecPostponedInitCode();
|
||||||
|
|
||||||
|
if (ar)
|
||||||
|
{
|
||||||
|
ensure(pos == ar->pos);
|
||||||
|
|
||||||
|
(*ar)(Emu.m_savestate_extension_flags1);
|
||||||
|
|
||||||
const usz advance = (Emu.m_savestate_extension_flags1 & Emulator::SaveStateExtentionFlags1::SupportsMenuOpenResume ? 32 : 31);
|
const usz advance = (Emu.m_savestate_extension_flags1 & Emulator::SaveStateExtentionFlags1::SupportsMenuOpenResume ? 32 : 31);
|
||||||
|
|
||||||
load_and_check_reserved(*ar, advance); // Reserved area
|
// Reserved area
|
||||||
|
if (!load_and_check_reserved(*ar, advance))
|
||||||
|
{
|
||||||
|
sys_log.error("Potential failure to load savestate: padding buyes are not 0. %s", *ar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,11 +145,11 @@ class Emulator final
|
||||||
|
|
||||||
std::vector<std::shared_ptr<atomic_t<u32>>> m_pause_msgs_refs;
|
std::vector<std::shared_ptr<atomic_t<u32>>> m_pause_msgs_refs;
|
||||||
|
|
||||||
std::vector<std::function<void()>> deferred_deserialization;
|
std::vector<std::function<void()>> m_postponed_init_code;
|
||||||
|
|
||||||
void ExecDeserializationRemnants()
|
void ExecPostponedInitCode()
|
||||||
{
|
{
|
||||||
for (auto&& func : ::as_rvalue(std::move(deferred_deserialization)))
|
for (auto&& func : ::as_rvalue(std::move(m_postponed_init_code)))
|
||||||
{
|
{
|
||||||
func();
|
func();
|
||||||
}
|
}
|
||||||
|
@ -200,9 +200,9 @@ public:
|
||||||
CallFromMainThread(std::move(func), nullptr, true, static_cast<u64>(counter));
|
CallFromMainThread(std::move(func), nullptr, true, static_cast<u64>(counter));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferDeserialization(std::function<void()>&& func)
|
void PostponeInitCode(std::function<void()>&& func)
|
||||||
{
|
{
|
||||||
deferred_deserialization.emplace_back(std::move(func));
|
m_postponed_init_code.emplace_back(std::move(func));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set emulator mode to running unconditionnaly.
|
/** Set emulator mode to running unconditionnaly.
|
||||||
|
|
|
@ -242,7 +242,7 @@ namespace stx
|
||||||
*m_info++ = nullptr;
|
*m_info++ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(bool reset = true, utils::serial* ar = nullptr)
|
void init(bool reset = true, utils::serial* ar = nullptr, std::function<void()> func = {})
|
||||||
{
|
{
|
||||||
if (reset)
|
if (reset)
|
||||||
{
|
{
|
||||||
|
@ -297,6 +297,11 @@ namespace stx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (func)
|
||||||
|
{
|
||||||
|
func();
|
||||||
|
}
|
||||||
|
|
||||||
// Launch threads
|
// Launch threads
|
||||||
for (auto it = m_info; it != info_before; it--)
|
for (auto it = m_info; it != info_before; it--)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue