Merge pull request #11177 from Lobsterzelda/simplify-device-save-state

IOS: Simplify IOS::HLE::Device savestate method
This commit is contained in:
Léo Lam 2022-10-18 08:36:50 +02:00 committed by GitHub
commit ee5a93c6b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 10 additions and 14 deletions

View File

@ -53,7 +53,7 @@ DIDevice::DIDevice(Kernel& ios, const std::string& device_name) : Device(ios, de
void DIDevice::DoState(PointerWrap& p)
{
DoStateShared(p);
Device::DoState(p);
p.Do(m_commands_to_execute);
p.Do(m_executing_command);
p.Do(m_current_partition);

View File

@ -147,12 +147,6 @@ Device::Device(Kernel& ios, const std::string& device_name, const DeviceType typ
}
void Device::DoState(PointerWrap& p)
{
DoStateShared(p);
p.Do(m_is_active);
}
void Device::DoStateShared(PointerWrap& p)
{
p.Do(m_name);
p.Do(m_device_type);

View File

@ -181,7 +181,6 @@ public:
virtual ~Device() = default;
virtual void DoState(PointerWrap& p);
void DoStateShared(PointerWrap& p);
const std::string& GetDeviceName() const { return m_name; }
// Replies to Open and Close requests are sent by the IPC request handler (HandleCommand),

View File

@ -93,6 +93,7 @@ FSDevice::FSDevice(Kernel& ios, const std::string& device_name) : Device(ios, de
void FSDevice::DoState(PointerWrap& p)
{
Device::DoState(p);
p.Do(m_dirty_cache);
p.Do(m_cache_chain_index);
p.Do(m_cache_fd);

View File

@ -75,7 +75,7 @@ NetIPTopDevice::NetIPTopDevice(Kernel& ios, const std::string& device_name)
void NetIPTopDevice::DoState(PointerWrap& p)
{
DoStateShared(p);
Device::DoState(p);
WiiSockMan::GetInstance().DoState(p);
}

View File

@ -56,7 +56,7 @@ void SDIOSlot0Device::RefreshConfig()
void SDIOSlot0Device::DoState(PointerWrap& p)
{
DoStateShared(p);
Device::DoState(p);
if (p.IsReadMode())
{
OpenInternal();

View File

@ -81,13 +81,13 @@ std::optional<IPCReply> STMEventHookDevice::IOCtl(const IOCtlRequest& request)
void STMEventHookDevice::DoState(PointerWrap& p)
{
Device::DoState(p);
u32 address = s_event_hook_request ? s_event_hook_request->address : 0;
p.Do(address);
if (address != 0)
s_event_hook_request = std::make_unique<IOCtlRequest>(address);
else
s_event_hook_request.reset();
Device::DoState(p);
}
bool STMEventHookDevice::HasHookInstalled() const

View File

@ -102,7 +102,7 @@ void BluetoothEmuDevice::DoState(PointerWrap& p)
return;
}
p.Do(m_is_active);
Device::DoState(p);
p.Do(m_controller_bd);
DoStateForMessage(m_ios, p, m_hci_endpoint);
DoStateForMessage(m_ios, p, m_acl_endpoint);

View File

@ -323,6 +323,7 @@ void BluetoothRealDevice::DoState(PointerWrap& p)
return;
}
Device::DoState(p);
// Prevent the transfer callbacks from messing with m_current_transfers after we have started
// writing a savestate. We cannot use a scoped lock here because DoState is called twice and
// we would lose the lock between the two calls.

View File

@ -55,6 +55,7 @@ void USBHost::UpdateWantDeterminism(const bool new_want_determinism)
void USBHost::DoState(PointerWrap& p)
{
Device::DoState(p);
if (IsOpened() && p.IsReadMode())
{
// After a state has loaded, there may be insertion hooks for devices that were

View File

@ -44,7 +44,7 @@ OH0Device::OH0Device(Kernel& ios, const std::string& name) : Device(ios, name, D
void OH0Device::DoState(PointerWrap& p)
{
m_oh0 = std::static_pointer_cast<OH0>(GetIOS()->GetDeviceByName("/dev/usb/oh0"));
p.Do(m_name);
Device::DoState(p);
p.Do(m_vid);
p.Do(m_pid);
p.Do(m_device_id);

View File

@ -94,7 +94,7 @@ static size_t s_state_writes_in_queue;
static std::condition_variable s_state_write_queue_is_empty;
// Don't forget to increase this after doing changes on the savestate system
constexpr u32 STATE_VERSION = 153; // Last changed in PR 11137
constexpr u32 STATE_VERSION = 154; // Last changed in PR 11177
// Maps savestate versions to Dolphin versions.
// Versions after 42 don't need to be added to this list,