mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-12-28 06:06:55 +00:00
Attempt to improve save/load during frame advance
This commit is contained in:
parent
19872b599b
commit
77c4b26e6c
|
@ -706,6 +706,7 @@ void GMainWindow::ConnectMenuEvents() {
|
||||||
if (emulation_running) {
|
if (emulation_running) {
|
||||||
ui.action_Enable_Frame_Advancing->setChecked(true);
|
ui.action_Enable_Frame_Advancing->setChecked(true);
|
||||||
ui.action_Advance_Frame->setEnabled(true);
|
ui.action_Advance_Frame->setEnabled(true);
|
||||||
|
Core::System::GetInstance().frame_limiter.SetFrameAdvancing(true);
|
||||||
Core::System::GetInstance().frame_limiter.AdvanceFrame();
|
Core::System::GetInstance().frame_limiter.AdvanceFrame();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1640,6 +1641,7 @@ void GMainWindow::OnSaveState() {
|
||||||
assert(action);
|
assert(action);
|
||||||
|
|
||||||
Core::System::GetInstance().SendSignal(Core::System::Signal::Save, action->data().toUInt());
|
Core::System::GetInstance().SendSignal(Core::System::Signal::Save, action->data().toUInt());
|
||||||
|
Core::System::GetInstance().frame_limiter.AdvanceFrame();
|
||||||
newest_slot = action->data().toUInt();
|
newest_slot = action->data().toUInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1648,6 +1650,7 @@ void GMainWindow::OnLoadState() {
|
||||||
assert(action);
|
assert(action);
|
||||||
|
|
||||||
Core::System::GetInstance().SendSignal(Core::System::Signal::Load, action->data().toUInt());
|
Core::System::GetInstance().SendSignal(Core::System::Signal::Load, action->data().toUInt());
|
||||||
|
Core::System::GetInstance().frame_limiter.AdvanceFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnConfigure() {
|
void GMainWindow::OnConfigure() {
|
||||||
|
|
|
@ -89,6 +89,40 @@ System::ResultStatus System::RunLoop(bool tight_loop) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Signal signal{Signal::None};
|
||||||
|
u32 param{};
|
||||||
|
{
|
||||||
|
std::lock_guard lock{signal_mutex};
|
||||||
|
if (current_signal != Signal::None) {
|
||||||
|
signal = current_signal;
|
||||||
|
param = signal_param;
|
||||||
|
current_signal = Signal::None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (signal) {
|
||||||
|
case Signal::Reset:
|
||||||
|
Reset();
|
||||||
|
return ResultStatus::Success;
|
||||||
|
case Signal::Shutdown:
|
||||||
|
return ResultStatus::ShutdownRequested;
|
||||||
|
case Signal::Load: {
|
||||||
|
LOG_INFO(Core, "Begin load");
|
||||||
|
System::LoadState(param);
|
||||||
|
LOG_INFO(Core, "Load completed");
|
||||||
|
frame_limiter.WaitOnce();
|
||||||
|
return ResultStatus::Success;
|
||||||
|
}
|
||||||
|
case Signal::Save: {
|
||||||
|
LOG_INFO(Core, "Begin save");
|
||||||
|
System::SaveState(param);
|
||||||
|
LOG_INFO(Core, "Save completed");
|
||||||
|
frame_limiter.WaitOnce();
|
||||||
|
return ResultStatus::Success;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// All cores should have executed the same amount of ticks. If this is not the case an event was
|
// All cores should have executed the same amount of ticks. If this is not the case an event was
|
||||||
// scheduled with a cycles_into_future smaller then the current downcount.
|
// scheduled with a cycles_into_future smaller then the current downcount.
|
||||||
// So we have to get those cores to the same global time first
|
// So we have to get those cores to the same global time first
|
||||||
|
@ -163,39 +197,6 @@ System::ResultStatus System::RunLoop(bool tight_loop) {
|
||||||
HW::Update();
|
HW::Update();
|
||||||
Reschedule();
|
Reschedule();
|
||||||
|
|
||||||
Signal signal{Signal::None};
|
|
||||||
u32 param{};
|
|
||||||
{
|
|
||||||
std::lock_guard lock{signal_mutex};
|
|
||||||
if (current_signal != Signal::None) {
|
|
||||||
signal = current_signal;
|
|
||||||
param = signal_param;
|
|
||||||
current_signal = Signal::None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch (signal) {
|
|
||||||
case Signal::Reset:
|
|
||||||
Reset();
|
|
||||||
break;
|
|
||||||
case Signal::Shutdown:
|
|
||||||
return ResultStatus::ShutdownRequested;
|
|
||||||
break;
|
|
||||||
case Signal::Load: {
|
|
||||||
LOG_INFO(Core, "Begin load");
|
|
||||||
System::LoadState(param);
|
|
||||||
LOG_INFO(Core, "Load completed");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Signal::Save: {
|
|
||||||
LOG_INFO(Core, "Begin save");
|
|
||||||
System::SaveState(param);
|
|
||||||
LOG_INFO(Core, "Save completed");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,14 @@ double PerfStats::GetLastFrameTimeScale() {
|
||||||
return duration_cast<DoubleSecs>(previous_frame_length).count() / FRAME_LENGTH;
|
return duration_cast<DoubleSecs>(previous_frame_length).count() / FRAME_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FrameLimiter::WaitOnce() {
|
||||||
|
if (frame_advancing_enabled) {
|
||||||
|
// Frame advancing is enabled: wait on event instead of doing framelimiting
|
||||||
|
frame_advance_event.Wait();
|
||||||
|
frame_advance_event.Reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) {
|
void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) {
|
||||||
if (frame_advancing_enabled) {
|
if (frame_advancing_enabled) {
|
||||||
// Frame advancing is enabled: wait on event instead of doing framelimiting
|
// Frame advancing is enabled: wait on event instead of doing framelimiting
|
||||||
|
@ -164,10 +172,6 @@ void FrameLimiter::SetFrameAdvancing(bool value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameLimiter::AdvanceFrame() {
|
void FrameLimiter::AdvanceFrame() {
|
||||||
if (!frame_advancing_enabled) {
|
|
||||||
// Start frame advancing
|
|
||||||
frame_advancing_enabled = true;
|
|
||||||
}
|
|
||||||
frame_advance_event.Set();
|
frame_advance_event.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void SetFrameAdvancing(bool value);
|
void SetFrameAdvancing(bool value);
|
||||||
void AdvanceFrame();
|
void AdvanceFrame();
|
||||||
|
void WaitOnce();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Emulated system time (in microseconds) at the last limiter invocation
|
/// Emulated system time (in microseconds) at the last limiter invocation
|
||||||
|
|
Loading…
Reference in a new issue