Merge pull request #4282 from zhaowenlan1779/frame-advance
core, citra_qt: add frame advancing to framelimiter
This commit is contained in:
commit
0df32275a7
4 changed files with 90 additions and 0 deletions
|
@ -74,6 +74,13 @@ double PerfStats::GetLastFrameTimeScale() {
|
|||
}
|
||||
|
||||
void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) {
|
||||
if (frame_advancing_enabled) {
|
||||
// Frame advancing is enabled: wait on event instead of doing framelimiting
|
||||
frame_advance_event.Wait();
|
||||
frame_advance_event.Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Settings::values.use_frame_limit) {
|
||||
return;
|
||||
}
|
||||
|
@ -104,4 +111,20 @@ void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) {
|
|||
previous_walltime = now;
|
||||
}
|
||||
|
||||
void FrameLimiter::SetFrameAdvancing(bool value) {
|
||||
const bool was_enabled = frame_advancing_enabled.exchange(value);
|
||||
if (was_enabled && !value) {
|
||||
// Set the event to let emulation continue
|
||||
frame_advance_event.Set();
|
||||
}
|
||||
}
|
||||
|
||||
void FrameLimiter::AdvanceFrame() {
|
||||
if (!frame_advancing_enabled) {
|
||||
// Start frame advancing
|
||||
frame_advancing_enabled = true;
|
||||
}
|
||||
frame_advance_event.Set();
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include "common/common_types.h"
|
||||
#include "common/thread.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
|
@ -70,6 +72,14 @@ public:
|
|||
|
||||
void DoFrameLimiting(std::chrono::microseconds current_system_time_us);
|
||||
|
||||
/**
|
||||
* Sets whether frame advancing is enabled or not.
|
||||
* Note: The frontend must cancel frame advancing before shutting down in order
|
||||
* to resume the emu_thread.
|
||||
*/
|
||||
void SetFrameAdvancing(bool value);
|
||||
void AdvanceFrame();
|
||||
|
||||
private:
|
||||
/// Emulated system time (in microseconds) at the last limiter invocation
|
||||
std::chrono::microseconds previous_system_time_us{0};
|
||||
|
@ -78,6 +88,12 @@ private:
|
|||
|
||||
/// Accumulated difference between walltime and emulated time
|
||||
std::chrono::microseconds frame_limiting_delta_err{0};
|
||||
|
||||
/// Whether to use frame advancing (i.e. frame by frame)
|
||||
std::atomic_bool frame_advancing_enabled;
|
||||
|
||||
/// Event to advance the frame when frame advancing is enabled
|
||||
Common::Event frame_advance_event;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue