HostDisplay: Add an option to decouple display fps from emulator fps
Makes Android so much faster...
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
#include "common/file_system.h"
|
||||
#include "common/log.h"
|
||||
#include "common/string_util.h"
|
||||
#include "common/timer.h"
|
||||
#include "stb_image.h"
|
||||
#include "stb_image_resize.h"
|
||||
#include "stb_image_write.h"
|
||||
@ -14,6 +15,25 @@ HostDisplayTexture::~HostDisplayTexture() = default;
|
||||
|
||||
HostDisplay::~HostDisplay() = default;
|
||||
|
||||
void HostDisplay::SetDisplayMaxFPS(float max_fps)
|
||||
{
|
||||
m_display_frame_interval = (max_fps > 0.0f) ? (1.0f / max_fps) : 0.0f;
|
||||
}
|
||||
|
||||
bool HostDisplay::ShouldSkipDisplayingFrame()
|
||||
{
|
||||
if (m_display_frame_interval == 0.0f)
|
||||
return false;
|
||||
|
||||
const u64 now = Common::Timer::GetValue();
|
||||
const double diff = Common::Timer::ConvertValueToSeconds(now - m_last_frame_displayed_time);
|
||||
if (diff < m_display_frame_interval)
|
||||
return true;
|
||||
|
||||
m_last_frame_displayed_time = now;
|
||||
return false;
|
||||
}
|
||||
|
||||
void HostDisplay::SetSoftwareCursor(std::unique_ptr<HostDisplayTexture> texture, float scale /*= 1.0f*/)
|
||||
{
|
||||
m_cursor_texture = std::move(texture);
|
||||
|
||||
@ -94,6 +94,9 @@ public:
|
||||
const s32 GetDisplayTopMargin() const { return m_display_top_margin; }
|
||||
const float GetDisplayAspectRatio() const { return m_display_aspect_ratio; }
|
||||
|
||||
void SetDisplayMaxFPS(float max_fps);
|
||||
bool ShouldSkipDisplayingFrame();
|
||||
|
||||
void ClearDisplayTexture()
|
||||
{
|
||||
m_display_texture_handle = nullptr;
|
||||
@ -181,6 +184,8 @@ protected:
|
||||
|
||||
WindowInfo m_window_info;
|
||||
|
||||
u64 m_last_frame_displayed_time = 0;
|
||||
|
||||
s32 m_mouse_position_x = 0;
|
||||
s32 m_mouse_position_y = 0;
|
||||
|
||||
@ -191,6 +196,7 @@ protected:
|
||||
s32 m_display_active_width = 0;
|
||||
s32 m_display_active_height = 0;
|
||||
float m_display_aspect_ratio = 1.0f;
|
||||
float m_display_frame_interval = 0.0f;
|
||||
|
||||
void* m_display_texture_handle = nullptr;
|
||||
s32 m_display_texture_width = 0;
|
||||
|
||||
@ -463,6 +463,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
|
||||
si.SetBoolValue("Display", "Fullscreen", false);
|
||||
si.SetBoolValue("Display", "VSync", true);
|
||||
si.SetStringValue("Display", "PostProcessChain", "");
|
||||
si.SetFloatValue("Display", "MaxFPS", 0.0f);
|
||||
|
||||
si.SetBoolValue("CDROM", "ReadThread", true);
|
||||
si.SetBoolValue("CDROM", "RegionCheck", true);
|
||||
|
||||
@ -177,6 +177,7 @@ void Settings::Load(SettingsInterface& si)
|
||||
display_show_resolution = si.GetBoolValue("Display", "ShowResolution", false);
|
||||
video_sync_enabled = si.GetBoolValue("Display", "VSync", true);
|
||||
display_post_process_chain = si.GetStringValue("Display", "PostProcessChain", "");
|
||||
display_max_fps = si.GetFloatValue("Display", "MaxFPS", 0.0f);
|
||||
|
||||
cdrom_read_thread = si.GetBoolValue("CDROM", "ReadThread", true);
|
||||
cdrom_region_check = si.GetBoolValue("CDROM", "RegionCheck", true);
|
||||
@ -304,6 +305,7 @@ void Settings::Save(SettingsInterface& si) const
|
||||
si.DeleteValue("Display", "PostProcessChain");
|
||||
else
|
||||
si.SetStringValue("Display", "PostProcessChain", display_post_process_chain.c_str());
|
||||
si.SetFloatValue("Display", "MaxFPS", display_max_fps);
|
||||
|
||||
si.SetBoolValue("CDROM", "ReadThread", cdrom_read_thread);
|
||||
si.SetBoolValue("CDROM", "RegionCheck", cdrom_region_check);
|
||||
|
||||
@ -123,6 +123,7 @@ struct Settings
|
||||
bool display_show_speed = false;
|
||||
bool display_show_resolution = false;
|
||||
bool video_sync_enabled = true;
|
||||
float display_max_fps = 0.0f;
|
||||
|
||||
bool cdrom_read_thread = true;
|
||||
bool cdrom_region_check = true;
|
||||
|
||||
Reference in New Issue
Block a user