Misc: Un-namespace Timer
This commit is contained in:
parent
ae18db9271
commit
aafc029682
|
@ -923,7 +923,7 @@ std::FILE* FileSystem::OpenExistingOrCreateCFile(const char* path, s32 retry_ms,
|
||||||
// if there's a sharing violation, keep retrying
|
// if there's a sharing violation, keep retrying
|
||||||
if (file == INVALID_HANDLE_VALUE && GetLastError() == ERROR_SHARING_VIOLATION && retry_ms >= 0)
|
if (file == INVALID_HANDLE_VALUE && GetLastError() == ERROR_SHARING_VIOLATION && retry_ms >= 0)
|
||||||
{
|
{
|
||||||
Common::Timer timer;
|
Timer timer;
|
||||||
while (retry_ms == 0 || timer.GetTimeMilliseconds() <= retry_ms)
|
while (retry_ms == 0 || timer.GetTimeMilliseconds() <= retry_ms)
|
||||||
{
|
{
|
||||||
Sleep(1);
|
Sleep(1);
|
||||||
|
|
|
@ -81,7 +81,7 @@ struct State
|
||||||
std::vector<RegisteredCallback> callbacks;
|
std::vector<RegisteredCallback> callbacks;
|
||||||
std::mutex callbacks_mutex;
|
std::mutex callbacks_mutex;
|
||||||
|
|
||||||
Common::Timer::Value start_timestamp = Common::Timer::GetCurrentValue();
|
Timer::Value start_timestamp = Timer::GetCurrentValue();
|
||||||
|
|
||||||
FileSystem::ManagedCFilePtr file_handle;
|
FileSystem::ManagedCFilePtr file_handle;
|
||||||
|
|
||||||
|
@ -146,8 +146,7 @@ const std::array<const char*, static_cast<size_t>(Log::Channel::MaxCount)>& Log:
|
||||||
|
|
||||||
float Log::GetCurrentMessageTime()
|
float Log::GetCurrentMessageTime()
|
||||||
{
|
{
|
||||||
return static_cast<float>(
|
return static_cast<float>(Timer::ConvertValueToSeconds(Timer::GetCurrentValue() - s_state.start_timestamp));
|
||||||
Common::Timer::ConvertValueToSeconds(Common::Timer::GetCurrentValue() - s_state.start_timestamp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Log::AreTimestampsEnabled()
|
bool Log::AreTimestampsEnabled()
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
static double s_counter_frequency;
|
static double s_counter_frequency;
|
||||||
|
@ -399,5 +397,3 @@ void Timer::NanoSleep(std::uint64_t ns)
|
||||||
nanosleep(&ts, nullptr);
|
nanosleep(&ts, nullptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Common
|
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
class Timer
|
class Timer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -47,5 +45,3 @@ public:
|
||||||
private:
|
private:
|
||||||
Value m_tvStartValue;
|
Value m_tvStartValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Common
|
|
|
@ -103,7 +103,7 @@ struct LeaderboardTrackerIndicator
|
||||||
{
|
{
|
||||||
u32 tracker_id;
|
u32 tracker_id;
|
||||||
std::string text;
|
std::string text;
|
||||||
Common::Timer show_hide_time;
|
Timer show_hide_time;
|
||||||
bool active;
|
bool active;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ struct AchievementChallengeIndicator
|
||||||
{
|
{
|
||||||
const rc_client_achievement_t* achievement;
|
const rc_client_achievement_t* achievement;
|
||||||
std::string badge_path;
|
std::string badge_path;
|
||||||
Common::Timer show_hide_time;
|
Timer show_hide_time;
|
||||||
bool active;
|
bool active;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ struct AchievementProgressIndicator
|
||||||
{
|
{
|
||||||
const rc_client_achievement_t* achievement;
|
const rc_client_achievement_t* achievement;
|
||||||
std::string badge_path;
|
std::string badge_path;
|
||||||
Common::Timer show_hide_time;
|
Timer show_hide_time;
|
||||||
bool active;
|
bool active;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -219,7 +219,7 @@ static bool s_has_achievements = false;
|
||||||
static bool s_has_leaderboards = false;
|
static bool s_has_leaderboards = false;
|
||||||
static bool s_has_rich_presence = false;
|
static bool s_has_rich_presence = false;
|
||||||
static std::string s_rich_presence_string;
|
static std::string s_rich_presence_string;
|
||||||
static Common::Timer s_rich_presence_poll_time;
|
static Timer s_rich_presence_poll_time;
|
||||||
|
|
||||||
static rc_client_async_handle_t* s_login_request;
|
static rc_client_async_handle_t* s_login_request;
|
||||||
static rc_client_async_handle_t* s_load_game_request;
|
static rc_client_async_handle_t* s_load_game_request;
|
||||||
|
|
|
@ -187,7 +187,7 @@ bool CDROMAsyncReader::WaitForReadToComplete()
|
||||||
return m_buffers[m_buffer_front.load()].result;
|
return m_buffers[m_buffer_front.load()].result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Timer wait_timer;
|
Timer wait_timer;
|
||||||
DEBUG_LOG("Sector read pending, waiting");
|
DEBUG_LOG("Sector read pending, waiting");
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
@ -226,7 +226,7 @@ void CDROMAsyncReader::EmptyBuffers()
|
||||||
|
|
||||||
bool CDROMAsyncReader::ReadSectorIntoBuffer(std::unique_lock<std::mutex>& lock)
|
bool CDROMAsyncReader::ReadSectorIntoBuffer(std::unique_lock<std::mutex>& lock)
|
||||||
{
|
{
|
||||||
Common::Timer timer;
|
Timer timer;
|
||||||
|
|
||||||
const u32 slot = m_buffer_back.load();
|
const u32 slot = m_buffer_back.load();
|
||||||
m_buffer_back.store((slot + 1) % static_cast<u32>(m_buffers.size()));
|
m_buffer_back.store((slot + 1) % static_cast<u32>(m_buffers.size()));
|
||||||
|
@ -259,7 +259,7 @@ bool CDROMAsyncReader::ReadSectorIntoBuffer(std::unique_lock<std::mutex>& lock)
|
||||||
|
|
||||||
void CDROMAsyncReader::ReadSectorNonThreaded(CDImage::LBA lba)
|
void CDROMAsyncReader::ReadSectorNonThreaded(CDImage::LBA lba)
|
||||||
{
|
{
|
||||||
Common::Timer timer;
|
Timer timer;
|
||||||
|
|
||||||
m_buffers.resize(1);
|
m_buffers.resize(1);
|
||||||
m_seek_error.store(false);
|
m_seek_error.store(false);
|
||||||
|
|
|
@ -422,7 +422,7 @@ static std::string s_input_binding_key;
|
||||||
static std::string s_input_binding_display_name;
|
static std::string s_input_binding_display_name;
|
||||||
static std::vector<InputBindingKey> s_input_binding_new_bindings;
|
static std::vector<InputBindingKey> s_input_binding_new_bindings;
|
||||||
static std::vector<std::pair<InputBindingKey, std::pair<float, float>>> s_input_binding_value_ranges;
|
static std::vector<std::pair<InputBindingKey, std::pair<float, float>>> s_input_binding_value_ranges;
|
||||||
static Common::Timer s_input_binding_timer;
|
static Timer s_input_binding_timer;
|
||||||
static bool s_controller_macro_expanded[NUM_CONTROLLER_AND_CARD_PORTS][InputManager::NUM_MACRO_BUTTONS_PER_CONTROLLER] =
|
static bool s_controller_macro_expanded[NUM_CONTROLLER_AND_CARD_PORTS][InputManager::NUM_MACRO_BUTTONS_PER_CONTROLLER] =
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
@ -4323,7 +4323,8 @@ void FullscreenUI::DrawGraphicsSettingsPage()
|
||||||
DrawEnumSetting(bsi, FSUI_ICONSTR(ICON_FA_CROP_ALT, "Crop Mode"),
|
DrawEnumSetting(bsi, FSUI_ICONSTR(ICON_FA_CROP_ALT, "Crop Mode"),
|
||||||
FSUI_CSTR("Determines how much of the area typically not visible on a consumer TV set to crop/hide."),
|
FSUI_CSTR("Determines how much of the area typically not visible on a consumer TV set to crop/hide."),
|
||||||
"Display", "CropMode", Settings::DEFAULT_DISPLAY_CROP_MODE, &Settings::ParseDisplayCropMode,
|
"Display", "CropMode", Settings::DEFAULT_DISPLAY_CROP_MODE, &Settings::ParseDisplayCropMode,
|
||||||
&Settings::GetDisplayCropModeName, &Settings::GetDisplayCropModeDisplayName, DisplayCropMode::MaxCount);
|
&Settings::GetDisplayCropModeName, &Settings::GetDisplayCropModeDisplayName,
|
||||||
|
DisplayCropMode::MaxCount);
|
||||||
|
|
||||||
DrawEnumSetting(
|
DrawEnumSetting(
|
||||||
bsi, FSUI_ICONSTR(ICON_FA_EXPAND, "Scaling"),
|
bsi, FSUI_ICONSTR(ICON_FA_EXPAND, "Scaling"),
|
||||||
|
|
|
@ -163,7 +163,7 @@ void GameDatabase::EnsureLoaded()
|
||||||
if (s_loaded)
|
if (s_loaded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Common::Timer timer;
|
Timer timer;
|
||||||
|
|
||||||
s_loaded = true;
|
s_loaded = true;
|
||||||
|
|
||||||
|
@ -1417,7 +1417,7 @@ void GameDatabase::EnsureTrackHashesMapLoaded()
|
||||||
|
|
||||||
bool GameDatabase::LoadTrackHashes()
|
bool GameDatabase::LoadTrackHashes()
|
||||||
{
|
{
|
||||||
Common::Timer load_timer;
|
Timer load_timer;
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
std::optional<std::string> gamedb_data(Host::ReadResourceFileToString(DISCDB_YAML_FILENAME, false, &error));
|
std::optional<std::string> gamedb_data(Host::ReadResourceFileToString(DISCDB_YAML_FILENAME, false, &error));
|
||||||
|
|
|
@ -1690,7 +1690,7 @@ FileSystem::ManagedCFilePtr GameList::OpenMemoryCardTimestampCache(bool for_writ
|
||||||
if (errno != EACCES)
|
if (errno != EACCES)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
Common::Timer timer;
|
Timer timer;
|
||||||
while (timer.GetTimeMilliseconds() <= 100.0f)
|
while (timer.GetTimeMilliseconds() <= 100.0f)
|
||||||
{
|
{
|
||||||
fp = FileSystem::OpenManagedSharedCFile(filename.c_str(), mode, share_mode, nullptr);
|
fp = FileSystem::OpenManagedSharedCFile(filename.c_str(), mode, share_mode, nullptr);
|
||||||
|
|
|
@ -217,7 +217,7 @@ void GPUBackend::Sync(bool allow_sleep)
|
||||||
void GPUBackend::RunGPULoop()
|
void GPUBackend::RunGPULoop()
|
||||||
{
|
{
|
||||||
static constexpr double SPIN_TIME_NS = 1 * 1000000;
|
static constexpr double SPIN_TIME_NS = 1 * 1000000;
|
||||||
Common::Timer::Value last_command_time = 0;
|
Timer::Value last_command_time = 0;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -225,8 +225,8 @@ void GPUBackend::RunGPULoop()
|
||||||
u32 read_ptr = m_command_fifo_read_ptr.load();
|
u32 read_ptr = m_command_fifo_read_ptr.load();
|
||||||
if (read_ptr == write_ptr)
|
if (read_ptr == write_ptr)
|
||||||
{
|
{
|
||||||
const Common::Timer::Value current_time = Common::Timer::GetCurrentValue();
|
const Timer::Value current_time = Timer::GetCurrentValue();
|
||||||
if (Common::Timer::ConvertValueToNanoseconds(current_time - last_command_time) < SPIN_TIME_NS)
|
if (Timer::ConvertValueToNanoseconds(current_time - last_command_time) < SPIN_TIME_NS)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(m_sync_mutex);
|
std::unique_lock<std::mutex> lock(m_sync_mutex);
|
||||||
|
@ -273,7 +273,7 @@ void GPUBackend::RunGPULoop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
last_command_time = allow_sleep ? 0 : Common::Timer::GetCurrentValue();
|
last_command_time = allow_sleep ? 0 : Timer::GetCurrentValue();
|
||||||
m_command_fifo_read_ptr.store(read_ptr);
|
m_command_fifo_read_ptr.store(read_ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,7 +320,7 @@ std::unique_ptr<GPUDump::Player> GPUDump::Player::Open(std::string path, Error*
|
||||||
{
|
{
|
||||||
std::unique_ptr<Player> ret;
|
std::unique_ptr<Player> ret;
|
||||||
|
|
||||||
Common::Timer timer;
|
Timer timer;
|
||||||
|
|
||||||
std::optional<DynamicHeapArray<u8>> data;
|
std::optional<DynamicHeapArray<u8>> data;
|
||||||
if (StringUtil::EndsWithNoCase(path, ".psxgpu.zst") || StringUtil::EndsWithNoCase(path, ".psxgpu.xz"))
|
if (StringUtil::EndsWithNoCase(path, ".psxgpu.zst") || StringUtil::EndsWithNoCase(path, ".psxgpu.xz"))
|
||||||
|
|
|
@ -152,8 +152,8 @@ class ShaderCompileProgressTracker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ShaderCompileProgressTracker(std::string title, u32 total)
|
ShaderCompileProgressTracker(std::string title, u32 total)
|
||||||
: m_title(std::move(title)), m_min_time(Common::Timer::ConvertSecondsToValue(1.0)),
|
: m_title(std::move(title)), m_min_time(Timer::ConvertSecondsToValue(1.0)),
|
||||||
m_update_interval(Common::Timer::ConvertSecondsToValue(0.1)), m_start_time(Common::Timer::GetCurrentValue()),
|
m_update_interval(Timer::ConvertSecondsToValue(0.1)), m_start_time(Timer::GetCurrentValue()),
|
||||||
m_last_update_time(0), m_progress(0), m_total(total)
|
m_last_update_time(0), m_progress(0), m_total(total)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -161,14 +161,14 @@ public:
|
||||||
|
|
||||||
double GetElapsedMilliseconds() const
|
double GetElapsedMilliseconds() const
|
||||||
{
|
{
|
||||||
return Common::Timer::ConvertValueToMilliseconds(Common::Timer::GetCurrentValue() - m_start_time);
|
return Timer::ConvertValueToMilliseconds(Timer::GetCurrentValue() - m_start_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Increment(u32 progress = 1)
|
void Increment(u32 progress = 1)
|
||||||
{
|
{
|
||||||
m_progress += progress;
|
m_progress += progress;
|
||||||
|
|
||||||
const u64 tv = Common::Timer::GetCurrentValue();
|
const u64 tv = Timer::GetCurrentValue();
|
||||||
if ((tv - m_start_time) >= m_min_time && (tv - m_last_update_time) >= m_update_interval)
|
if ((tv - m_start_time) >= m_min_time && (tv - m_last_update_time) >= m_update_interval)
|
||||||
{
|
{
|
||||||
Host::DisplayLoadingScreen(m_title.c_str(), 0, static_cast<int>(m_total), static_cast<int>(m_progress));
|
Host::DisplayLoadingScreen(m_title.c_str(), 0, static_cast<int>(m_total), static_cast<int>(m_progress));
|
||||||
|
@ -178,10 +178,10 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_title;
|
std::string m_title;
|
||||||
Common::Timer::Value m_min_time;
|
Timer::Value m_min_time;
|
||||||
Common::Timer::Value m_update_interval;
|
Timer::Value m_update_interval;
|
||||||
Common::Timer::Value m_start_time;
|
Timer::Value m_start_time;
|
||||||
Common::Timer::Value m_last_update_time;
|
Timer::Value m_last_update_time;
|
||||||
u32 m_progress;
|
u32 m_progress;
|
||||||
u32 m_total;
|
u32 m_total;
|
||||||
};
|
};
|
||||||
|
@ -1612,7 +1612,7 @@ bool GPU_HW::CompilePipelines(Error* error)
|
||||||
|
|
||||||
bool GPU_HW::CompileResolutionDependentPipelines(Error* error)
|
bool GPU_HW::CompileResolutionDependentPipelines(Error* error)
|
||||||
{
|
{
|
||||||
Common::Timer timer;
|
Timer timer;
|
||||||
|
|
||||||
m_vram_readback_pipeline.reset();
|
m_vram_readback_pipeline.reset();
|
||||||
for (std::unique_ptr<GPUPipeline>& p : m_vram_extract_pipeline)
|
for (std::unique_ptr<GPUPipeline>& p : m_vram_extract_pipeline)
|
||||||
|
|
|
@ -3100,7 +3100,7 @@ void GPUTextureCache::PreloadReplacementTextures()
|
||||||
{
|
{
|
||||||
static constexpr float UPDATE_INTERVAL = 1.0f;
|
static constexpr float UPDATE_INTERVAL = 1.0f;
|
||||||
|
|
||||||
Common::Timer last_update_time;
|
Timer last_update_time;
|
||||||
u32 num_textures_loaded = 0;
|
u32 num_textures_loaded = 0;
|
||||||
const size_t total_textures = s_state.vram_replacements.size() + s_state.vram_write_texture_replacements.size() +
|
const size_t total_textures = s_state.vram_replacements.size() + s_state.vram_write_texture_replacements.size() +
|
||||||
s_state.texture_page_texture_replacements.size();
|
s_state.texture_page_texture_replacements.size();
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void Redraw(bool force);
|
void Redraw(bool force);
|
||||||
|
|
||||||
Common::Timer m_open_time;
|
Timer m_open_time;
|
||||||
float m_open_delay = 1.0f;
|
float m_open_delay = 1.0f;
|
||||||
int m_last_progress_percent = -1;
|
int m_last_progress_percent = -1;
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,8 +22,8 @@ namespace {
|
||||||
|
|
||||||
struct State
|
struct State
|
||||||
{
|
{
|
||||||
Common::Timer::Value last_update_time;
|
Timer::Value last_update_time;
|
||||||
Common::Timer::Value last_frame_time;
|
Timer::Value last_frame_time;
|
||||||
|
|
||||||
u32 last_frame_number;
|
u32 last_frame_number;
|
||||||
u32 last_internal_frame_number;
|
u32 last_internal_frame_number;
|
||||||
|
@ -142,7 +142,7 @@ void PerformanceCounters::Clear()
|
||||||
|
|
||||||
void PerformanceCounters::Reset()
|
void PerformanceCounters::Reset()
|
||||||
{
|
{
|
||||||
const Common::Timer::Value now_ticks = Common::Timer::GetCurrentValue();
|
const Timer::Value now_ticks = Timer::GetCurrentValue();
|
||||||
|
|
||||||
s_state.last_frame_time = now_ticks;
|
s_state.last_frame_time = now_ticks;
|
||||||
s_state.last_update_time = now_ticks;
|
s_state.last_update_time = now_ticks;
|
||||||
|
@ -162,10 +162,10 @@ void PerformanceCounters::Reset()
|
||||||
|
|
||||||
void PerformanceCounters::Update(u32 frame_number, u32 internal_frame_number)
|
void PerformanceCounters::Update(u32 frame_number, u32 internal_frame_number)
|
||||||
{
|
{
|
||||||
const Common::Timer::Value now_ticks = Common::Timer::GetCurrentValue();
|
const Timer::Value now_ticks = Timer::GetCurrentValue();
|
||||||
|
|
||||||
const float frame_time = static_cast<float>(
|
const float frame_time = static_cast<float>(
|
||||||
Common::Timer::ConvertValueToMilliseconds(now_ticks - std::exchange(s_state.last_frame_time, now_ticks)));
|
Timer::ConvertValueToMilliseconds(now_ticks - std::exchange(s_state.last_frame_time, now_ticks)));
|
||||||
s_state.minimum_frame_time_accumulator = (s_state.minimum_frame_time_accumulator == 0.0f) ?
|
s_state.minimum_frame_time_accumulator = (s_state.minimum_frame_time_accumulator == 0.0f) ?
|
||||||
frame_time :
|
frame_time :
|
||||||
std::min(s_state.minimum_frame_time_accumulator, frame_time);
|
std::min(s_state.minimum_frame_time_accumulator, frame_time);
|
||||||
|
@ -175,8 +175,8 @@ void PerformanceCounters::Update(u32 frame_number, u32 internal_frame_number)
|
||||||
s_state.frame_time_history_pos = (s_state.frame_time_history_pos + 1) % NUM_FRAME_TIME_SAMPLES;
|
s_state.frame_time_history_pos = (s_state.frame_time_history_pos + 1) % NUM_FRAME_TIME_SAMPLES;
|
||||||
|
|
||||||
// update fps counter
|
// update fps counter
|
||||||
const Common::Timer::Value ticks_diff = now_ticks - s_state.last_update_time;
|
const Timer::Value ticks_diff = now_ticks - s_state.last_update_time;
|
||||||
const float time = static_cast<float>(Common::Timer::ConvertValueToSeconds(ticks_diff));
|
const float time = static_cast<float>(Timer::ConvertValueToSeconds(ticks_diff));
|
||||||
if (time < PERFORMANCE_COUNTER_UPDATE_INTERVAL)
|
if (time < PERFORMANCE_COUNTER_UPDATE_INTERVAL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ void PerformanceCounters::Update(u32 frame_number, u32 internal_frame_number)
|
||||||
// TODO: Make the math here less rubbish
|
// TODO: Make the math here less rubbish
|
||||||
const double pct_divider =
|
const double pct_divider =
|
||||||
100.0 * (1.0 / ((static_cast<double>(ticks_diff) * static_cast<double>(Threading::GetThreadTicksPerSecond())) /
|
100.0 * (1.0 / ((static_cast<double>(ticks_diff) * static_cast<double>(Threading::GetThreadTicksPerSecond())) /
|
||||||
Common::Timer::GetFrequency() / 1000000000.0));
|
Timer::GetFrequency() / 1000000000.0));
|
||||||
const double time_divider = 1000.0 * (1.0 / static_cast<double>(Threading::GetThreadTicksPerSecond())) *
|
const double time_divider = 1000.0 * (1.0 / static_cast<double>(Threading::GetThreadTicksPerSecond())) *
|
||||||
(1.0 / static_cast<double>(frames_runf));
|
(1.0 / static_cast<double>(frames_runf));
|
||||||
|
|
||||||
|
@ -230,8 +230,8 @@ void PerformanceCounters::Update(u32 frame_number, u32 internal_frame_number)
|
||||||
if (g_settings.display_show_gpu_stats)
|
if (g_settings.display_show_gpu_stats)
|
||||||
g_gpu->UpdateStatistics(frames_run);
|
g_gpu->UpdateStatistics(frames_run);
|
||||||
|
|
||||||
VERBOSE_LOG("FPS: {:.2f} VPS: {:.2f} CPU: {:.2f} GPU: {:.2f} Avg: {:.2f}ms Min: {:.2f}ms Max: {:.2f}ms",
|
VERBOSE_LOG("FPS: {:.2f} VPS: {:.2f} CPU: {:.2f} GPU: {:.2f} Avg: {:.2f}ms Min: {:.2f}ms Max: {:.2f}ms", s_state.fps,
|
||||||
s_state.fps, s_state.vps, s_state.cpu_thread_usage, s_state.gpu_usage, s_state.average_frame_time,
|
s_state.vps, s_state.cpu_thread_usage, s_state.gpu_usage, s_state.average_frame_time,
|
||||||
s_state.minimum_frame_time, s_state.maximum_frame_time);
|
s_state.minimum_frame_time, s_state.maximum_frame_time);
|
||||||
|
|
||||||
Host::OnPerformanceCountersUpdated();
|
Host::OnPerformanceCountersUpdated();
|
||||||
|
|
|
@ -181,8 +181,8 @@ static void UpdateThrottlePeriod();
|
||||||
static void ResetThrottler();
|
static void ResetThrottler();
|
||||||
|
|
||||||
/// Throttles the system, i.e. sleeps until it's time to execute the next frame.
|
/// Throttles the system, i.e. sleeps until it's time to execute the next frame.
|
||||||
static void Throttle(Common::Timer::Value current_time);
|
static void Throttle(Timer::Value current_time);
|
||||||
static void AccumulatePreFrameSleepTime(Common::Timer::Value current_time);
|
static void AccumulatePreFrameSleepTime(Timer::Value current_time);
|
||||||
static void UpdateDisplayVSync();
|
static void UpdateDisplayVSync();
|
||||||
|
|
||||||
static bool UpdateGameSettingsLayer();
|
static bool UpdateGameSettingsLayer();
|
||||||
|
@ -270,14 +270,14 @@ struct ALIGN_TO_CACHE_LINE StateVars
|
||||||
float video_frame_rate = 0.0f;
|
float video_frame_rate = 0.0f;
|
||||||
float target_speed = 0.0f;
|
float target_speed = 0.0f;
|
||||||
|
|
||||||
Common::Timer::Value frame_period = 0;
|
Timer::Value frame_period = 0;
|
||||||
Common::Timer::Value next_frame_time = 0;
|
Timer::Value next_frame_time = 0;
|
||||||
|
|
||||||
Common::Timer::Value frame_start_time = 0;
|
Timer::Value frame_start_time = 0;
|
||||||
Common::Timer::Value last_active_frame_time = 0;
|
Timer::Value last_active_frame_time = 0;
|
||||||
Common::Timer::Value pre_frame_sleep_time = 0;
|
Timer::Value pre_frame_sleep_time = 0;
|
||||||
Common::Timer::Value max_active_frame_time = 0;
|
Timer::Value max_active_frame_time = 0;
|
||||||
Common::Timer::Value last_pre_frame_sleep_update_time = 0;
|
Timer::Value last_pre_frame_sleep_update_time = 0;
|
||||||
|
|
||||||
std::unique_ptr<MediaCapture> media_capture;
|
std::unique_ptr<MediaCapture> media_capture;
|
||||||
std::unique_ptr<GPUDump::Player> gpu_dump_player;
|
std::unique_ptr<GPUDump::Player> gpu_dump_player;
|
||||||
|
@ -468,7 +468,7 @@ void System::LogStartupInformation()
|
||||||
|
|
||||||
bool System::ProcessStartup(Error* error)
|
bool System::ProcessStartup(Error* error)
|
||||||
{
|
{
|
||||||
Common::Timer timer;
|
Timer timer;
|
||||||
|
|
||||||
// Allocate JIT memory as soon as possible.
|
// Allocate JIT memory as soon as possible.
|
||||||
if (!CPU::CodeCache::ProcessStartup(error))
|
if (!CPU::CodeCache::ProcessStartup(error))
|
||||||
|
@ -1243,15 +1243,15 @@ bool System::RecreateGPU(GPURenderer renderer, bool force_recreate_device, bool
|
||||||
|
|
||||||
void System::HandleHostGPUDeviceLost()
|
void System::HandleHostGPUDeviceLost()
|
||||||
{
|
{
|
||||||
static Common::Timer::Value s_last_gpu_reset_time = 0;
|
static Timer::Value s_last_gpu_reset_time = 0;
|
||||||
static constexpr float MIN_TIME_BETWEEN_RESETS = 15.0f;
|
static constexpr float MIN_TIME_BETWEEN_RESETS = 15.0f;
|
||||||
|
|
||||||
// If we're constantly crashing on something in particular, we don't want to end up in an
|
// If we're constantly crashing on something in particular, we don't want to end up in an
|
||||||
// endless reset loop.. that'd probably end up leaking memory and/or crashing us for other
|
// endless reset loop.. that'd probably end up leaking memory and/or crashing us for other
|
||||||
// reasons. So just abort in such case.
|
// reasons. So just abort in such case.
|
||||||
const Common::Timer::Value current_time = Common::Timer::GetCurrentValue();
|
const Timer::Value current_time = Timer::GetCurrentValue();
|
||||||
if (s_last_gpu_reset_time != 0 &&
|
if (s_last_gpu_reset_time != 0 &&
|
||||||
Common::Timer::ConvertValueToSeconds(current_time - s_last_gpu_reset_time) < MIN_TIME_BETWEEN_RESETS)
|
Timer::ConvertValueToSeconds(current_time - s_last_gpu_reset_time) < MIN_TIME_BETWEEN_RESETS)
|
||||||
{
|
{
|
||||||
Panic("Host GPU lost too many times, device is probably completely wedged.");
|
Panic("Host GPU lost too many times, device is probably completely wedged.");
|
||||||
}
|
}
|
||||||
|
@ -2197,10 +2197,10 @@ void System::FrameDone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Timer::Value current_time = Common::Timer::GetCurrentValue();
|
Timer::Value current_time = Timer::GetCurrentValue();
|
||||||
|
|
||||||
// pre-frame sleep accounting (input lag reduction)
|
// pre-frame sleep accounting (input lag reduction)
|
||||||
const Common::Timer::Value pre_frame_sleep_until = s_state.next_frame_time + s_state.pre_frame_sleep_time;
|
const Timer::Value pre_frame_sleep_until = s_state.next_frame_time + s_state.pre_frame_sleep_time;
|
||||||
s_state.last_active_frame_time = current_time - s_state.frame_start_time;
|
s_state.last_active_frame_time = current_time - s_state.frame_start_time;
|
||||||
if (s_state.pre_frame_sleep)
|
if (s_state.pre_frame_sleep)
|
||||||
AccumulatePreFrameSleepTime(current_time);
|
AccumulatePreFrameSleepTime(current_time);
|
||||||
|
@ -2255,15 +2255,15 @@ void System::FrameDone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// pre-frame sleep (input lag reduction)
|
// pre-frame sleep (input lag reduction)
|
||||||
current_time = Common::Timer::GetCurrentValue();
|
current_time = Timer::GetCurrentValue();
|
||||||
if (s_state.pre_frame_sleep)
|
if (s_state.pre_frame_sleep)
|
||||||
{
|
{
|
||||||
// don't sleep if it's under 1ms, because we're just going to overshoot (or spin).
|
// don't sleep if it's under 1ms, because we're just going to overshoot (or spin).
|
||||||
if (pre_frame_sleep_until > current_time &&
|
if (pre_frame_sleep_until > current_time &&
|
||||||
Common::Timer::ConvertValueToMilliseconds(pre_frame_sleep_until - current_time) >= 1)
|
Timer::ConvertValueToMilliseconds(pre_frame_sleep_until - current_time) >= 1)
|
||||||
{
|
{
|
||||||
Common::Timer::SleepUntil(pre_frame_sleep_until, true);
|
Timer::SleepUntil(pre_frame_sleep_until, true);
|
||||||
current_time = Common::Timer::GetCurrentValue();
|
current_time = Timer::GetCurrentValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2306,7 +2306,7 @@ void System::UpdateThrottlePeriod()
|
||||||
const double target_speed =
|
const double target_speed =
|
||||||
std::max(static_cast<double>(s_state.target_speed), std::numeric_limits<double>::epsilon());
|
std::max(static_cast<double>(s_state.target_speed), std::numeric_limits<double>::epsilon());
|
||||||
s_state.frame_period =
|
s_state.frame_period =
|
||||||
Common::Timer::ConvertSecondsToValue(1.0 / (static_cast<double>(s_state.video_frame_rate) * target_speed));
|
Timer::ConvertSecondsToValue(1.0 / (static_cast<double>(s_state.video_frame_rate) * target_speed));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2318,18 +2318,18 @@ void System::UpdateThrottlePeriod()
|
||||||
|
|
||||||
void System::ResetThrottler()
|
void System::ResetThrottler()
|
||||||
{
|
{
|
||||||
s_state.next_frame_time = Common::Timer::GetCurrentValue() + s_state.frame_period;
|
s_state.next_frame_time = Timer::GetCurrentValue() + s_state.frame_period;
|
||||||
s_state.pre_frame_sleep_time = 0;
|
s_state.pre_frame_sleep_time = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::Throttle(Common::Timer::Value current_time)
|
void System::Throttle(Timer::Value current_time)
|
||||||
{
|
{
|
||||||
// If we're running too slow, advance the next frame time based on the time we lost. Effectively skips
|
// If we're running too slow, advance the next frame time based on the time we lost. Effectively skips
|
||||||
// running those frames at the intended time, because otherwise if we pause in the debugger, we'll run
|
// running those frames at the intended time, because otherwise if we pause in the debugger, we'll run
|
||||||
// hundreds of frames when we resume.
|
// hundreds of frames when we resume.
|
||||||
if (current_time > s_state.next_frame_time)
|
if (current_time > s_state.next_frame_time)
|
||||||
{
|
{
|
||||||
const Common::Timer::Value diff = static_cast<s64>(current_time) - static_cast<s64>(s_state.next_frame_time);
|
const Timer::Value diff = static_cast<s64>(current_time) - static_cast<s64>(s_state.next_frame_time);
|
||||||
s_state.next_frame_time += (diff / s_state.frame_period) * s_state.frame_period + s_state.frame_period;
|
s_state.next_frame_time += (diff / s_state.frame_period) * s_state.frame_period + s_state.frame_period;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2339,13 +2339,13 @@ void System::Throttle(Common::Timer::Value current_time)
|
||||||
// That way in a query->response->query->response chain, we don't process only one message per frame.
|
// That way in a query->response->query->response chain, we don't process only one message per frame.
|
||||||
if (s_state.socket_multiplexer && s_state.socket_multiplexer->HasAnyClientSockets())
|
if (s_state.socket_multiplexer && s_state.socket_multiplexer->HasAnyClientSockets())
|
||||||
{
|
{
|
||||||
Common::Timer::Value poll_start_time = current_time;
|
Timer::Value poll_start_time = current_time;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
const u32 sleep_ms =
|
const u32 sleep_ms =
|
||||||
static_cast<u32>(Common::Timer::ConvertValueToMilliseconds(s_state.next_frame_time - poll_start_time));
|
static_cast<u32>(Timer::ConvertValueToMilliseconds(s_state.next_frame_time - poll_start_time));
|
||||||
s_state.socket_multiplexer->PollEventsWithTimeout(sleep_ms);
|
s_state.socket_multiplexer->PollEventsWithTimeout(sleep_ms);
|
||||||
poll_start_time = Common::Timer::GetCurrentValue();
|
poll_start_time = Timer::GetCurrentValue();
|
||||||
if (poll_start_time >= s_state.next_frame_time || (!g_settings.display_optimal_frame_pacing && sleep_ms == 0))
|
if (poll_start_time >= s_state.next_frame_time || (!g_settings.display_optimal_frame_pacing && sleep_ms == 0))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2355,25 +2355,25 @@ void System::Throttle(Common::Timer::Value current_time)
|
||||||
// Use a spinwait if we undersleep for all platforms except android.. don't want to burn battery.
|
// Use a spinwait if we undersleep for all platforms except android.. don't want to burn battery.
|
||||||
// Linux also seems to do a much better job of waking up at the requested time.
|
// Linux also seems to do a much better job of waking up at the requested time.
|
||||||
#if !defined(__linux__)
|
#if !defined(__linux__)
|
||||||
Common::Timer::SleepUntil(s_state.next_frame_time, g_settings.display_optimal_frame_pacing);
|
Timer::SleepUntil(s_state.next_frame_time, g_settings.display_optimal_frame_pacing);
|
||||||
#else
|
#else
|
||||||
Common::Timer::SleepUntil(s_state.next_frame_time, false);
|
Timer::SleepUntil(s_state.next_frame_time, false);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// No spinwait on Android, see above.
|
// No spinwait on Android, see above.
|
||||||
Common::Timer::SleepUntil(s_state.next_frame_time, false);
|
Timer::SleepUntil(s_state.next_frame_time, false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
const Common::Timer::Value time_after_sleep = Common::Timer::GetCurrentValue();
|
const Timer::Value time_after_sleep = Timer::GetCurrentValue();
|
||||||
DEV_LOG("Asked for {:.2f} ms, slept for {:.2f} ms, {:.2f} ms {}",
|
DEV_LOG("Asked for {:.2f} ms, slept for {:.2f} ms, {:.2f} ms {}",
|
||||||
Common::Timer::ConvertValueToMilliseconds(s_next_frame_time - current_time),
|
Timer::ConvertValueToMilliseconds(s_state.next_frame_time - current_time),
|
||||||
Common::Timer::ConvertValueToMilliseconds(time_after_sleep - current_time),
|
Timer::ConvertValueToMilliseconds(time_after_sleep - current_time),
|
||||||
Common::Timer::ConvertValueToMilliseconds((time_after_sleep < s_next_frame_time) ?
|
Timer::ConvertValueToMilliseconds((time_after_sleep < s_state.next_frame_time) ?
|
||||||
(s_next_frame_time - time_after_sleep) :
|
(s_state.next_frame_time - time_after_sleep) :
|
||||||
(time_after_sleep - s_next_frame_time)),
|
(time_after_sleep - s_state.next_frame_time)),
|
||||||
(time_after_sleep < s_next_frame_time) ? "early" : "late");
|
(time_after_sleep < s_state.next_frame_time) ? "early" : "late");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s_state.next_frame_time += s_state.frame_period;
|
s_state.next_frame_time += s_state.frame_period;
|
||||||
|
@ -2726,7 +2726,7 @@ bool System::LoadState(const char* path, Error* error, bool save_undo_state)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Timer load_timer;
|
Timer load_timer;
|
||||||
|
|
||||||
auto fp = FileSystem::OpenManagedCFile(path, "rb", error);
|
auto fp = FileSystem::OpenManagedCFile(path, "rb", error);
|
||||||
if (!fp)
|
if (!fp)
|
||||||
|
@ -3026,7 +3026,7 @@ bool System::SaveState(const char* path, Error* error, bool backup_existing_save
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Timer save_timer;
|
Timer save_timer;
|
||||||
|
|
||||||
SaveStateBuffer buffer;
|
SaveStateBuffer buffer;
|
||||||
if (!SaveStateToBuffer(&buffer, error, 256))
|
if (!SaveStateToBuffer(&buffer, error, 256))
|
||||||
|
@ -3301,38 +3301,37 @@ float System::GetAudioNominalRate()
|
||||||
return (s_state.throttler_enabled || s_state.syncing_to_host_with_vsync) ? s_state.target_speed : 1.0f;
|
return (s_state.throttler_enabled || s_state.syncing_to_host_with_vsync) ? s_state.target_speed : 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::AccumulatePreFrameSleepTime(Common::Timer::Value current_time)
|
void System::AccumulatePreFrameSleepTime(Timer::Value current_time)
|
||||||
{
|
{
|
||||||
DebugAssert(s_state.pre_frame_sleep);
|
DebugAssert(s_state.pre_frame_sleep);
|
||||||
|
|
||||||
s_state.max_active_frame_time = std::max(s_state.max_active_frame_time, s_state.last_active_frame_time);
|
s_state.max_active_frame_time = std::max(s_state.max_active_frame_time, s_state.last_active_frame_time);
|
||||||
|
|
||||||
// in case one frame runs over, adjust to compensate
|
// in case one frame runs over, adjust to compensate
|
||||||
const Common::Timer::Value max_sleep_time_for_this_frame =
|
const Timer::Value max_sleep_time_for_this_frame =
|
||||||
s_state.frame_period - std::min(s_state.last_active_frame_time, s_state.frame_period);
|
s_state.frame_period - std::min(s_state.last_active_frame_time, s_state.frame_period);
|
||||||
if (max_sleep_time_for_this_frame < s_state.pre_frame_sleep_time)
|
if (max_sleep_time_for_this_frame < s_state.pre_frame_sleep_time)
|
||||||
{
|
{
|
||||||
s_state.pre_frame_sleep_time = Common::AlignDown(
|
s_state.pre_frame_sleep_time =
|
||||||
max_sleep_time_for_this_frame, static_cast<unsigned int>(Common::Timer::ConvertMillisecondsToValue(1)));
|
Common::AlignDown(max_sleep_time_for_this_frame, static_cast<unsigned int>(Timer::ConvertMillisecondsToValue(1)));
|
||||||
DEV_LOG("Adjust pre-frame time to {} ms due to overrun of {} ms",
|
DEV_LOG("Adjust pre-frame time to {} ms due to overrun of {} ms",
|
||||||
Common::Timer::ConvertValueToMilliseconds(s_state.pre_frame_sleep_time),
|
Timer::ConvertValueToMilliseconds(s_state.pre_frame_sleep_time),
|
||||||
Common::Timer::ConvertValueToMilliseconds(s_state.last_active_frame_time));
|
Timer::ConvertValueToMilliseconds(s_state.last_active_frame_time));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Common::Timer::ConvertValueToSeconds(current_time - s_state.last_pre_frame_sleep_update_time) >=
|
if (Timer::ConvertValueToSeconds(current_time - s_state.last_pre_frame_sleep_update_time) >=
|
||||||
PRE_FRAME_SLEEP_UPDATE_INTERVAL)
|
PRE_FRAME_SLEEP_UPDATE_INTERVAL)
|
||||||
{
|
{
|
||||||
s_state.last_pre_frame_sleep_update_time = current_time;
|
s_state.last_pre_frame_sleep_update_time = current_time;
|
||||||
|
|
||||||
const Common::Timer::Value expected_frame_time =
|
const Timer::Value expected_frame_time =
|
||||||
s_state.max_active_frame_time +
|
s_state.max_active_frame_time + Timer::ConvertMillisecondsToValue(g_settings.display_pre_frame_sleep_buffer);
|
||||||
Common::Timer::ConvertMillisecondsToValue(g_settings.display_pre_frame_sleep_buffer);
|
|
||||||
s_state.pre_frame_sleep_time =
|
s_state.pre_frame_sleep_time =
|
||||||
Common::AlignDown(s_state.frame_period - std::min(expected_frame_time, s_state.frame_period),
|
Common::AlignDown(s_state.frame_period - std::min(expected_frame_time, s_state.frame_period),
|
||||||
static_cast<unsigned int>(Common::Timer::ConvertMillisecondsToValue(1)));
|
static_cast<unsigned int>(Timer::ConvertMillisecondsToValue(1)));
|
||||||
DEV_LOG("Set pre-frame time to {} ms (expected frame time of {} ms)",
|
DEV_LOG("Set pre-frame time to {} ms (expected frame time of {} ms)",
|
||||||
Common::Timer::ConvertValueToMilliseconds(s_state.pre_frame_sleep_time),
|
Timer::ConvertValueToMilliseconds(s_state.pre_frame_sleep_time),
|
||||||
Common::Timer::ConvertValueToMilliseconds(expected_frame_time));
|
Timer::ConvertValueToMilliseconds(expected_frame_time));
|
||||||
|
|
||||||
s_state.max_active_frame_time = 0;
|
s_state.max_active_frame_time = 0;
|
||||||
}
|
}
|
||||||
|
@ -3344,12 +3343,11 @@ void System::FormatLatencyStats(SmallStringBase& str)
|
||||||
const u32 audio_latency =
|
const u32 audio_latency =
|
||||||
AudioStream::GetMSForBufferSize(audio_stream->GetSampleRate(), audio_stream->GetBufferedFramesRelaxed());
|
AudioStream::GetMSForBufferSize(audio_stream->GetSampleRate(), audio_stream->GetBufferedFramesRelaxed());
|
||||||
|
|
||||||
const double active_frame_time = std::ceil(Common::Timer::ConvertValueToMilliseconds(s_state.last_active_frame_time));
|
const double active_frame_time = std::ceil(Timer::ConvertValueToMilliseconds(s_state.last_active_frame_time));
|
||||||
const double pre_frame_time = std::ceil(Common::Timer::ConvertValueToMilliseconds(s_state.pre_frame_sleep_time));
|
const double pre_frame_time = std::ceil(Timer::ConvertValueToMilliseconds(s_state.pre_frame_sleep_time));
|
||||||
const double input_latency =
|
const double input_latency = std::ceil(
|
||||||
std::ceil(Common::Timer::ConvertValueToMilliseconds(s_state.frame_period - s_state.pre_frame_sleep_time) -
|
Timer::ConvertValueToMilliseconds(s_state.frame_period - s_state.pre_frame_sleep_time) -
|
||||||
Common::Timer::ConvertValueToMilliseconds(static_cast<Common::Timer::Value>(s_state.runahead_frames) *
|
Timer::ConvertValueToMilliseconds(static_cast<Timer::Value>(s_state.runahead_frames) * s_state.frame_period));
|
||||||
s_state.frame_period));
|
|
||||||
|
|
||||||
str.format("AF: {:.0f}ms | PF: {:.0f}ms | IL: {:.0f}ms | AL: {}ms", active_frame_time, pre_frame_time, input_latency,
|
str.format("AF: {:.0f}ms | PF: {:.0f}ms | IL: {:.0f}ms | AL: {}ms", active_frame_time, pre_frame_time, input_latency,
|
||||||
audio_latency);
|
audio_latency);
|
||||||
|
@ -4859,7 +4857,7 @@ bool System::SaveMemoryState(MemorySaveState* mss)
|
||||||
bool System::SaveRewindState()
|
bool System::SaveRewindState()
|
||||||
{
|
{
|
||||||
#ifdef PROFILE_MEMORY_SAVE_STATES
|
#ifdef PROFILE_MEMORY_SAVE_STATES
|
||||||
Common::Timer save_timer;
|
Timer save_timer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// try to reuse the frontmost slot
|
// try to reuse the frontmost slot
|
||||||
|
@ -4897,7 +4895,7 @@ bool System::LoadRewindState(u32 skip_saves /*= 0*/, bool consume_state /*=true
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef PROFILE_MEMORY_SAVE_STATES
|
#ifdef PROFILE_MEMORY_SAVE_STATES
|
||||||
Common::Timer load_timer;
|
Timer load_timer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!LoadMemoryState(s_state.rewind_states.back()))
|
if (!LoadMemoryState(s_state.rewind_states.back()))
|
||||||
|
@ -4961,7 +4959,7 @@ void System::DoRewind()
|
||||||
Host::PumpMessagesOnCPUThread();
|
Host::PumpMessagesOnCPUThread();
|
||||||
IdlePollUpdate();
|
IdlePollUpdate();
|
||||||
|
|
||||||
Throttle(Common::Timer::GetCurrentValue());
|
Throttle(Timer::GetCurrentValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::SaveRunaheadState()
|
void System::SaveRunaheadState()
|
||||||
|
@ -4986,7 +4984,7 @@ void System::SaveRunaheadState()
|
||||||
bool System::DoRunahead()
|
bool System::DoRunahead()
|
||||||
{
|
{
|
||||||
#ifdef PROFILE_MEMORY_SAVE_STATES
|
#ifdef PROFILE_MEMORY_SAVE_STATES
|
||||||
static Common::Timer replay_timer;
|
static Timer replay_timer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (s_state.runahead_replay_pending)
|
if (s_state.runahead_replay_pending)
|
||||||
|
@ -5839,12 +5837,12 @@ bool System::ChangeGPUDump(std::string new_path)
|
||||||
|
|
||||||
void System::UpdateSessionTime(const std::string& prev_serial)
|
void System::UpdateSessionTime(const std::string& prev_serial)
|
||||||
{
|
{
|
||||||
const u64 ctime = Common::Timer::GetCurrentValue();
|
const Timer::Value ctime = Timer::GetCurrentValue();
|
||||||
if (!prev_serial.empty() && GameList::IsGameListLoaded())
|
if (!prev_serial.empty() && GameList::IsGameListLoaded())
|
||||||
{
|
{
|
||||||
// round up to seconds
|
// round up to seconds
|
||||||
const std::time_t etime =
|
const std::time_t etime =
|
||||||
static_cast<std::time_t>(std::round(Common::Timer::ConvertValueToSeconds(ctime - s_state.session_start_time)));
|
static_cast<std::time_t>(std::round(Timer::ConvertValueToSeconds(ctime - s_state.session_start_time)));
|
||||||
const std::time_t wtime = std::time(nullptr);
|
const std::time_t wtime = std::time(nullptr);
|
||||||
GameList::AddPlayedTimeForSerial(prev_serial, wtime, etime);
|
GameList::AddPlayedTimeForSerial(prev_serial, wtime, etime);
|
||||||
}
|
}
|
||||||
|
@ -5854,8 +5852,8 @@ void System::UpdateSessionTime(const std::string& prev_serial)
|
||||||
|
|
||||||
u64 System::GetSessionPlayedTime()
|
u64 System::GetSessionPlayedTime()
|
||||||
{
|
{
|
||||||
const u64 ctime = Common::Timer::GetCurrentValue();
|
const Timer::Value ctime = Timer::GetCurrentValue();
|
||||||
return static_cast<u64>(std::round(Common::Timer::ConvertValueToSeconds(ctime - s_state.session_start_time)));
|
return static_cast<u64>(std::round(Timer::ConvertValueToSeconds(ctime - s_state.session_start_time)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::QueueTaskOnThread(std::function<void()> task)
|
void System::QueueTaskOnThread(std::function<void()> task)
|
||||||
|
|
|
@ -53,5 +53,5 @@ private:
|
||||||
|
|
||||||
Ui::CoverDownloadDialog m_ui;
|
Ui::CoverDownloadDialog m_ui;
|
||||||
std::unique_ptr<CoverDownloadThread> m_thread;
|
std::unique_ptr<CoverDownloadThread> m_thread;
|
||||||
Common::Timer m_last_refresh_time;
|
Timer m_last_refresh_time;
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,7 +35,7 @@ private:
|
||||||
void fireUpdate();
|
void fireUpdate();
|
||||||
|
|
||||||
GameListRefreshThread* m_parent;
|
GameListRefreshThread* m_parent;
|
||||||
Common::Timer m_start_time;
|
Timer m_start_time;
|
||||||
QString m_status_text;
|
QString m_status_text;
|
||||||
int m_last_range = 1;
|
int m_last_range = 1;
|
||||||
int m_last_value = 0;
|
int m_last_value = 0;
|
||||||
|
|
|
@ -42,7 +42,7 @@ private:
|
||||||
void checkForDelayedShow();
|
void checkForDelayedShow();
|
||||||
|
|
||||||
QProgressDialog m_dialog;
|
QProgressDialog m_dialog;
|
||||||
Common::Timer m_show_timer;
|
Timer m_show_timer;
|
||||||
float m_show_delay;
|
float m_show_delay;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -788,12 +788,12 @@ int main(int argc, char* argv[])
|
||||||
s_frames_remaining = s_frames_to_run;
|
s_frames_remaining = s_frames_to_run;
|
||||||
|
|
||||||
{
|
{
|
||||||
const Common::Timer::Value start_time = Common::Timer::GetCurrentValue();
|
const Timer::Value start_time = Timer::GetCurrentValue();
|
||||||
|
|
||||||
System::Execute();
|
System::Execute();
|
||||||
|
|
||||||
const Common::Timer::Value elapsed_time = Common::Timer::GetCurrentValue() - start_time;
|
const Timer::Value elapsed_time = Timer::GetCurrentValue() - start_time;
|
||||||
const double elapsed_time_ms = Common::Timer::ConvertValueToMilliseconds(elapsed_time);
|
const double elapsed_time_ms = Timer::ConvertValueToMilliseconds(elapsed_time);
|
||||||
INFO_LOG("Total execution time: {:.2f}ms, average frame time {:.2f}ms, {:.2f} FPS", elapsed_time_ms,
|
INFO_LOG("Total execution time: {:.2f}ms, average frame time {:.2f}ms, {:.2f} FPS", elapsed_time_ms,
|
||||||
elapsed_time_ms / static_cast<double>(s_frames_to_run),
|
elapsed_time_ms / static_cast<double>(s_frames_to_run),
|
||||||
static_cast<double>(s_frames_to_run) / elapsed_time_ms * 1000.0);
|
static_cast<double>(s_frames_to_run) / elapsed_time_ms * 1000.0);
|
||||||
|
|
|
@ -788,9 +788,9 @@ void AudioStream::UpdateStretchTempo()
|
||||||
static int iterations = 0;
|
static int iterations = 0;
|
||||||
static u64 last_log_time = 0;
|
static u64 last_log_time = 0;
|
||||||
|
|
||||||
const u64 now = Common::Timer::GetCurrentValue();
|
const u64 now = Timer::GetCurrentValue();
|
||||||
|
|
||||||
if (Common::Timer::ConvertValueToSeconds(now - last_log_time) > 1.0f)
|
if (Timer::ConvertValueToSeconds(now - last_log_time) > 1.0f)
|
||||||
{
|
{
|
||||||
VERBOSE_LOG("buffers: {:4d} ms ({:3.0f}%), tempo: {}, comp: {:2.3f}, iters: {}, reset:{}",
|
VERBOSE_LOG("buffers: {:4d} ms ({:3.0f}%), tempo: {}, comp: {:2.3f}, iters: {}, reset:{}",
|
||||||
(ibuffer_usage * 1000u) / m_sample_rate, 100.0f * buffer_usage / base_target_usage, tempo,
|
(ibuffer_usage * 1000u) / m_sample_rate, 100.0f * buffer_usage / base_target_usage, tempo,
|
||||||
|
|
|
@ -242,8 +242,8 @@ bool GPUSwapChain::ShouldSkipPresentingFrame()
|
||||||
const float throttle_rate = (m_window_info.surface_refresh_rate > 0.0f) ? m_window_info.surface_refresh_rate : 60.0f;
|
const float throttle_rate = (m_window_info.surface_refresh_rate > 0.0f) ? m_window_info.surface_refresh_rate : 60.0f;
|
||||||
const float throttle_period = 1.0f / throttle_rate;
|
const float throttle_period = 1.0f / throttle_rate;
|
||||||
|
|
||||||
const u64 now = Common::Timer::GetCurrentValue();
|
const u64 now = Timer::GetCurrentValue();
|
||||||
const double diff = Common::Timer::ConvertValueToSeconds(now - m_last_frame_displayed_time);
|
const double diff = Timer::ConvertValueToSeconds(now - m_last_frame_displayed_time);
|
||||||
if (diff < throttle_period)
|
if (diff < throttle_period)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -255,8 +255,8 @@ void GPUSwapChain::ThrottlePresentation()
|
||||||
{
|
{
|
||||||
const float throttle_rate = (m_window_info.surface_refresh_rate > 0.0f) ? m_window_info.surface_refresh_rate : 60.0f;
|
const float throttle_rate = (m_window_info.surface_refresh_rate > 0.0f) ? m_window_info.surface_refresh_rate : 60.0f;
|
||||||
|
|
||||||
const u64 sleep_period = Common::Timer::ConvertNanosecondsToValue(1e+9f / static_cast<double>(throttle_rate));
|
const u64 sleep_period = Timer::ConvertNanosecondsToValue(1e+9f / static_cast<double>(throttle_rate));
|
||||||
const u64 current_ts = Common::Timer::GetCurrentValue();
|
const u64 current_ts = Timer::GetCurrentValue();
|
||||||
|
|
||||||
// Allow it to fall behind/run ahead up to 2*period. Sleep isn't that precise, plus we need to
|
// Allow it to fall behind/run ahead up to 2*period. Sleep isn't that precise, plus we need to
|
||||||
// allow time for the actual rendering.
|
// allow time for the actual rendering.
|
||||||
|
@ -266,7 +266,7 @@ void GPUSwapChain::ThrottlePresentation()
|
||||||
else
|
else
|
||||||
m_last_frame_displayed_time += sleep_period;
|
m_last_frame_displayed_time += sleep_period;
|
||||||
|
|
||||||
Common::Timer::SleepUntil(m_last_frame_displayed_time, false);
|
Timer::SleepUntil(m_last_frame_displayed_time, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUDevice::GPUDevice()
|
GPUDevice::GPUDevice()
|
||||||
|
|
|
@ -43,7 +43,7 @@ void HTTPDownloader::CreateRequest(std::string url, Request::Callback callback,
|
||||||
req->url = std::move(url);
|
req->url = std::move(url);
|
||||||
req->callback = std::move(callback);
|
req->callback = std::move(callback);
|
||||||
req->progress = progress;
|
req->progress = progress;
|
||||||
req->start_time = Common::Timer::GetCurrentValue();
|
req->start_time = Timer::GetCurrentValue();
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(m_pending_http_request_lock);
|
std::unique_lock<std::mutex> lock(m_pending_http_request_lock);
|
||||||
if (LockedGetActiveRequestCount() < m_max_active_requests)
|
if (LockedGetActiveRequestCount() < m_max_active_requests)
|
||||||
|
@ -65,7 +65,7 @@ void HTTPDownloader::CreatePostRequest(std::string url, std::string post_data, R
|
||||||
req->post_data = std::move(post_data);
|
req->post_data = std::move(post_data);
|
||||||
req->callback = std::move(callback);
|
req->callback = std::move(callback);
|
||||||
req->progress = progress;
|
req->progress = progress;
|
||||||
req->start_time = Common::Timer::GetCurrentValue();
|
req->start_time = Timer::GetCurrentValue();
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(m_pending_http_request_lock);
|
std::unique_lock<std::mutex> lock(m_pending_http_request_lock);
|
||||||
if (LockedGetActiveRequestCount() < m_max_active_requests)
|
if (LockedGetActiveRequestCount() < m_max_active_requests)
|
||||||
|
@ -84,7 +84,7 @@ void HTTPDownloader::LockedPollRequests(std::unique_lock<std::mutex>& lock)
|
||||||
|
|
||||||
InternalPollRequests();
|
InternalPollRequests();
|
||||||
|
|
||||||
const Common::Timer::Value current_time = Common::Timer::GetCurrentValue();
|
const Timer::Value current_time = Timer::GetCurrentValue();
|
||||||
u32 active_requests = 0;
|
u32 active_requests = 0;
|
||||||
u32 unstarted_requests = 0;
|
u32 unstarted_requests = 0;
|
||||||
|
|
||||||
|
@ -99,8 +99,7 @@ void HTTPDownloader::LockedPollRequests(std::unique_lock<std::mutex>& lock)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((req->state == Request::State::Started || req->state == Request::State::Receiving) &&
|
if ((req->state == Request::State::Started || req->state == Request::State::Receiving) &&
|
||||||
current_time >= req->start_time &&
|
current_time >= req->start_time && Timer::ConvertValueToSeconds(current_time - req->start_time) >= m_timeout)
|
||||||
Common::Timer::ConvertValueToSeconds(current_time - req->start_time) >= m_timeout)
|
|
||||||
{
|
{
|
||||||
// request timed out
|
// request timed out
|
||||||
ERROR_LOG("Request for '{}' timed out", req->url);
|
ERROR_LOG("Request for '{}' timed out", req->url);
|
||||||
|
@ -207,7 +206,7 @@ void HTTPDownloader::WaitForAllRequests()
|
||||||
while (!m_pending_http_requests.empty())
|
while (!m_pending_http_requests.empty())
|
||||||
{
|
{
|
||||||
// Don't burn too much CPU.
|
// Don't burn too much CPU.
|
||||||
Common::Timer::NanoSleep(1000000);
|
Timer::NanoSleep(1000000);
|
||||||
LockedPollRequests(lock);
|
LockedPollRequests(lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ size_t HTTPDownloaderCurl::WriteCallback(char* ptr, size_t size, size_t nmemb, v
|
||||||
const size_t transfer_size = size * nmemb;
|
const size_t transfer_size = size * nmemb;
|
||||||
const size_t new_size = current_size + transfer_size;
|
const size_t new_size = current_size + transfer_size;
|
||||||
req->data.resize(new_size);
|
req->data.resize(new_size);
|
||||||
req->start_time = Common::Timer::GetCurrentValue();
|
req->start_time = Timer::GetCurrentValue();
|
||||||
std::memcpy(&req->data[current_size], ptr, transfer_size);
|
std::memcpy(&req->data[current_size], ptr, transfer_size);
|
||||||
|
|
||||||
if (req->content_length == 0)
|
if (req->content_length == 0)
|
||||||
|
@ -211,7 +211,7 @@ bool HTTPDownloaderCurl::StartRequest(HTTPDownloader::Request* request)
|
||||||
|
|
||||||
DEV_LOG("Started HTTP request for '{}'", req->url);
|
DEV_LOG("Started HTTP request for '{}'", req->url);
|
||||||
req->state.store(Request::State::Started, std::memory_order_release);
|
req->state.store(Request::State::Started, std::memory_order_release);
|
||||||
req->start_time = Common::Timer::GetCurrentValue();
|
req->start_time = Timer::GetCurrentValue();
|
||||||
|
|
||||||
const CURLMcode err = curl_multi_add_handle(m_multi_handle, req->handle);
|
const CURLMcode err = curl_multi_add_handle(m_multi_handle, req->handle);
|
||||||
if (err != CURLM_OK)
|
if (err != CURLM_OK)
|
||||||
|
|
|
@ -237,7 +237,7 @@ void CALLBACK HTTPDownloaderWinHttp::HTTPStatusCallback(HINTERNET hRequest, DWOR
|
||||||
const u32 new_size = req->io_position + dwStatusInformationLength;
|
const u32 new_size = req->io_position + dwStatusInformationLength;
|
||||||
Assert(new_size <= req->data.size());
|
Assert(new_size <= req->data.size());
|
||||||
req->data.resize(new_size);
|
req->data.resize(new_size);
|
||||||
req->start_time = Common::Timer::GetCurrentValue();
|
req->start_time = Timer::GetCurrentValue();
|
||||||
|
|
||||||
if (!WinHttpQueryDataAvailable(hRequest, nullptr) && GetLastError() != ERROR_IO_PENDING)
|
if (!WinHttpQueryDataAvailable(hRequest, nullptr) && GetLastError() != ERROR_IO_PENDING)
|
||||||
{
|
{
|
||||||
|
@ -345,7 +345,7 @@ bool HTTPDownloaderWinHttp::StartRequest(HTTPDownloader::Request* request)
|
||||||
|
|
||||||
DEV_LOG("Started HTTP request for '{}'", req->url);
|
DEV_LOG("Started HTTP request for '{}'", req->url);
|
||||||
req->state = Request::State::Started;
|
req->state = Request::State::Started;
|
||||||
req->start_time = Common::Timer::GetCurrentValue();
|
req->start_time = Timer::GetCurrentValue();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,8 +175,8 @@ struct Notification
|
||||||
std::string title;
|
std::string title;
|
||||||
std::string text;
|
std::string text;
|
||||||
std::string badge_path;
|
std::string badge_path;
|
||||||
Common::Timer::Value start_time;
|
Timer::Value start_time;
|
||||||
Common::Timer::Value move_time;
|
Timer::Value move_time;
|
||||||
float duration;
|
float duration;
|
||||||
float target_y;
|
float target_y;
|
||||||
float last_y;
|
float last_y;
|
||||||
|
@ -187,7 +187,7 @@ static std::vector<Notification> s_notifications;
|
||||||
|
|
||||||
static std::string s_toast_title;
|
static std::string s_toast_title;
|
||||||
static std::string s_toast_message;
|
static std::string s_toast_message;
|
||||||
static Common::Timer::Value s_toast_start_time;
|
static Timer::Value s_toast_start_time;
|
||||||
static float s_toast_duration;
|
static float s_toast_duration;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -357,7 +357,8 @@ std::optional<Image> ImGuiFullscreen::LoadTextureImage(std::string_view path, u3
|
||||||
std::shared_ptr<GPUTexture> ImGuiFullscreen::UploadTexture(std::string_view path, const Image& image)
|
std::shared_ptr<GPUTexture> ImGuiFullscreen::UploadTexture(std::string_view path, const Image& image)
|
||||||
{
|
{
|
||||||
Error error;
|
Error error;
|
||||||
std::unique_ptr<GPUTexture> texture = g_gpu_device->FetchAndUploadTextureImage(image, GPUTexture::Flags::None, &error);
|
std::unique_ptr<GPUTexture> texture =
|
||||||
|
g_gpu_device->FetchAndUploadTextureImage(image, GPUTexture::Flags::None, &error);
|
||||||
if (!texture)
|
if (!texture)
|
||||||
{
|
{
|
||||||
ERROR_LOG("Failed to upload texture '{}': {}", Path::GetFileTitle(path), error.GetDescription());
|
ERROR_LOG("Failed to upload texture '{}': {}", Path::GetFileTitle(path), error.GetDescription());
|
||||||
|
@ -2937,7 +2938,7 @@ void ImGuiFullscreen::DrawBackgroundProgressDialogs(ImVec2& position, float spac
|
||||||
void ImGuiFullscreen::AddNotification(std::string key, float duration, std::string title, std::string text,
|
void ImGuiFullscreen::AddNotification(std::string key, float duration, std::string title, std::string text,
|
||||||
std::string image_path)
|
std::string image_path)
|
||||||
{
|
{
|
||||||
const Common::Timer::Value current_time = Common::Timer::GetCurrentValue();
|
const Timer::Value current_time = Timer::GetCurrentValue();
|
||||||
|
|
||||||
if (!key.empty())
|
if (!key.empty())
|
||||||
{
|
{
|
||||||
|
@ -2951,10 +2952,8 @@ void ImGuiFullscreen::AddNotification(std::string key, float duration, std::stri
|
||||||
it->badge_path = std::move(image_path);
|
it->badge_path = std::move(image_path);
|
||||||
|
|
||||||
// Don't fade it in again
|
// Don't fade it in again
|
||||||
const float time_passed =
|
const float time_passed = static_cast<float>(Timer::ConvertValueToSeconds(current_time - it->start_time));
|
||||||
static_cast<float>(Common::Timer::ConvertValueToSeconds(current_time - it->start_time));
|
it->start_time = current_time - Timer::ConvertSecondsToValue(std::min(time_passed, NOTIFICATION_FADE_IN_TIME));
|
||||||
it->start_time =
|
|
||||||
current_time - Common::Timer::ConvertSecondsToValue(std::min(time_passed, NOTIFICATION_FADE_IN_TIME));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2984,7 +2983,7 @@ void ImGuiFullscreen::DrawNotifications(ImVec2& position, float spacing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static constexpr float MOVE_DURATION = 0.5f;
|
static constexpr float MOVE_DURATION = 0.5f;
|
||||||
const Common::Timer::Value current_time = Common::Timer::GetCurrentValue();
|
const Timer::Value current_time = Timer::GetCurrentValue();
|
||||||
|
|
||||||
const float horizontal_padding = ImGuiFullscreen::LayoutScale(20.0f);
|
const float horizontal_padding = ImGuiFullscreen::LayoutScale(20.0f);
|
||||||
const float vertical_padding = ImGuiFullscreen::LayoutScale(10.0f);
|
const float vertical_padding = ImGuiFullscreen::LayoutScale(10.0f);
|
||||||
|
@ -3009,7 +3008,7 @@ void ImGuiFullscreen::DrawNotifications(ImVec2& position, float spacing)
|
||||||
for (u32 index = 0; index < static_cast<u32>(s_notifications.size());)
|
for (u32 index = 0; index < static_cast<u32>(s_notifications.size());)
|
||||||
{
|
{
|
||||||
Notification& notif = s_notifications[index];
|
Notification& notif = s_notifications[index];
|
||||||
const float time_passed = static_cast<float>(Common::Timer::ConvertValueToSeconds(current_time - notif.start_time));
|
const float time_passed = static_cast<float>(Timer::ConvertValueToSeconds(current_time - notif.start_time));
|
||||||
if (time_passed >= notif.duration)
|
if (time_passed >= notif.duration)
|
||||||
{
|
{
|
||||||
s_notifications.erase(s_notifications.begin() + index);
|
s_notifications.erase(s_notifications.begin() + index);
|
||||||
|
@ -3047,8 +3046,7 @@ void ImGuiFullscreen::DrawNotifications(ImVec2& position, float spacing)
|
||||||
}
|
}
|
||||||
else if (actual_y != expected_y)
|
else if (actual_y != expected_y)
|
||||||
{
|
{
|
||||||
const float time_since_move =
|
const float time_since_move = static_cast<float>(Timer::ConvertValueToSeconds(current_time - notif.move_time));
|
||||||
static_cast<float>(Common::Timer::ConvertValueToSeconds(current_time - notif.move_time));
|
|
||||||
if (time_since_move >= MOVE_DURATION)
|
if (time_since_move >= MOVE_DURATION)
|
||||||
{
|
{
|
||||||
notif.move_time = current_time;
|
notif.move_time = current_time;
|
||||||
|
@ -3108,7 +3106,7 @@ void ImGuiFullscreen::ShowToast(std::string title, std::string message, float du
|
||||||
{
|
{
|
||||||
s_toast_title = std::move(title);
|
s_toast_title = std::move(title);
|
||||||
s_toast_message = std::move(message);
|
s_toast_message = std::move(message);
|
||||||
s_toast_start_time = Common::Timer::GetCurrentValue();
|
s_toast_start_time = Timer::GetCurrentValue();
|
||||||
s_toast_duration = duration;
|
s_toast_duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3125,8 +3123,7 @@ void ImGuiFullscreen::DrawToast()
|
||||||
if (s_toast_title.empty() && s_toast_message.empty())
|
if (s_toast_title.empty() && s_toast_message.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const float elapsed =
|
const float elapsed = static_cast<float>(Timer::ConvertValueToSeconds(Timer::GetCurrentValue() - s_toast_start_time));
|
||||||
static_cast<float>(Common::Timer::ConvertValueToSeconds(Common::Timer::GetCurrentValue() - s_toast_start_time));
|
|
||||||
if (elapsed >= s_toast_duration)
|
if (elapsed >= s_toast_duration)
|
||||||
{
|
{
|
||||||
ClearToast();
|
ClearToast();
|
||||||
|
|
|
@ -54,8 +54,8 @@ struct OSDMessage
|
||||||
{
|
{
|
||||||
std::string key;
|
std::string key;
|
||||||
std::string text;
|
std::string text;
|
||||||
Common::Timer::Value start_time;
|
Timer::Value start_time;
|
||||||
Common::Timer::Value move_time;
|
Timer::Value move_time;
|
||||||
float duration;
|
float duration;
|
||||||
float target_y;
|
float target_y;
|
||||||
float last_y;
|
float last_y;
|
||||||
|
@ -82,8 +82,8 @@ static void SetClipboardTextImpl(void* userdata, const char* text);
|
||||||
static void AddOSDMessage(std::string key, std::string message, float duration, bool is_warning);
|
static void AddOSDMessage(std::string key, std::string message, float duration, bool is_warning);
|
||||||
static void RemoveKeyedOSDMessage(std::string key, bool is_warning);
|
static void RemoveKeyedOSDMessage(std::string key, bool is_warning);
|
||||||
static void ClearOSDMessages(bool clear_warnings);
|
static void ClearOSDMessages(bool clear_warnings);
|
||||||
static void AcquirePendingOSDMessages(Common::Timer::Value current_time);
|
static void AcquirePendingOSDMessages(Timer::Value current_time);
|
||||||
static void DrawOSDMessages(Common::Timer::Value current_time);
|
static void DrawOSDMessages(Timer::Value current_time);
|
||||||
static void CreateSoftwareCursorTextures();
|
static void CreateSoftwareCursorTextures();
|
||||||
static void UpdateSoftwareCursorTexture(u32 index);
|
static void UpdateSoftwareCursorTexture(u32 index);
|
||||||
static void DestroySoftwareCursorTextures();
|
static void DestroySoftwareCursorTextures();
|
||||||
|
@ -114,7 +114,7 @@ static DynamicHeapArray<u8> s_emoji_font_data;
|
||||||
|
|
||||||
static float s_window_width;
|
static float s_window_width;
|
||||||
static float s_window_height;
|
static float s_window_height;
|
||||||
static Common::Timer s_last_render_time;
|
static Timer s_last_render_time;
|
||||||
|
|
||||||
// cached copies of WantCaptureKeyboard/Mouse, used to know when to dispatch events
|
// cached copies of WantCaptureKeyboard/Mouse, used to know when to dispatch events
|
||||||
static std::atomic_bool s_imgui_wants_keyboard{false};
|
static std::atomic_bool s_imgui_wants_keyboard{false};
|
||||||
|
@ -781,7 +781,7 @@ void ImGuiManager::AddOSDMessage(std::string key, std::string message, float dur
|
||||||
if (!s_show_osd_messages && !is_warning)
|
if (!s_show_osd_messages && !is_warning)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const Common::Timer::Value current_time = Common::Timer::GetCurrentValue();
|
const Timer::Value current_time = Timer::GetCurrentValue();
|
||||||
|
|
||||||
OSDMessage msg;
|
OSDMessage msg;
|
||||||
msg.key = std::move(key);
|
msg.key = std::move(key);
|
||||||
|
@ -847,7 +847,7 @@ void ImGuiManager::ClearOSDMessages(bool clear_warnings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiManager::AcquirePendingOSDMessages(Common::Timer::Value current_time)
|
void ImGuiManager::AcquirePendingOSDMessages(Timer::Value current_time)
|
||||||
{
|
{
|
||||||
std::atomic_thread_fence(std::memory_order_consume);
|
std::atomic_thread_fence(std::memory_order_consume);
|
||||||
if (s_osd_posted_messages.empty())
|
if (s_osd_posted_messages.empty())
|
||||||
|
@ -870,9 +870,8 @@ void ImGuiManager::AcquirePendingOSDMessages(Common::Timer::Value current_time)
|
||||||
iter->duration = new_msg.duration;
|
iter->duration = new_msg.duration;
|
||||||
|
|
||||||
// Don't fade it in again
|
// Don't fade it in again
|
||||||
const float time_passed =
|
const float time_passed = static_cast<float>(Timer::ConvertValueToSeconds(current_time - iter->start_time));
|
||||||
static_cast<float>(Common::Timer::ConvertValueToSeconds(current_time - iter->start_time));
|
iter->start_time = current_time - Timer::ConvertSecondsToValue(std::min(time_passed, OSD_FADE_IN_TIME));
|
||||||
iter->start_time = current_time - Common::Timer::ConvertSecondsToValue(std::min(time_passed, OSD_FADE_IN_TIME));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -887,7 +886,7 @@ void ImGuiManager::AcquirePendingOSDMessages(Common::Timer::Value current_time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiManager::DrawOSDMessages(Common::Timer::Value current_time)
|
void ImGuiManager::DrawOSDMessages(Timer::Value current_time)
|
||||||
{
|
{
|
||||||
static constexpr float MOVE_DURATION = 0.5f;
|
static constexpr float MOVE_DURATION = 0.5f;
|
||||||
|
|
||||||
|
@ -905,7 +904,7 @@ void ImGuiManager::DrawOSDMessages(Common::Timer::Value current_time)
|
||||||
while (iter != s_osd_active_messages.end())
|
while (iter != s_osd_active_messages.end())
|
||||||
{
|
{
|
||||||
OSDMessage& msg = *iter;
|
OSDMessage& msg = *iter;
|
||||||
const float time_passed = static_cast<float>(Common::Timer::ConvertValueToSeconds(current_time - msg.start_time));
|
const float time_passed = static_cast<float>(Timer::ConvertValueToSeconds(current_time - msg.start_time));
|
||||||
if (time_passed >= msg.duration)
|
if (time_passed >= msg.duration)
|
||||||
{
|
{
|
||||||
iter = s_osd_active_messages.erase(iter);
|
iter = s_osd_active_messages.erase(iter);
|
||||||
|
@ -934,8 +933,7 @@ void ImGuiManager::DrawOSDMessages(Common::Timer::Value current_time)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We got repositioned, probably due to another message above getting removed.
|
// We got repositioned, probably due to another message above getting removed.
|
||||||
const float time_since_move =
|
const float time_since_move = static_cast<float>(Timer::ConvertValueToSeconds(current_time - msg.move_time));
|
||||||
static_cast<float>(Common::Timer::ConvertValueToSeconds(current_time - msg.move_time));
|
|
||||||
const float frac = Easing::OutExpo(time_since_move / MOVE_DURATION);
|
const float frac = Easing::OutExpo(time_since_move / MOVE_DURATION);
|
||||||
msg.last_y = std::floor(msg.last_y - ((msg.last_y - msg.target_y) * frac));
|
msg.last_y = std::floor(msg.last_y - ((msg.last_y - msg.target_y) * frac));
|
||||||
}
|
}
|
||||||
|
@ -946,8 +944,7 @@ void ImGuiManager::DrawOSDMessages(Common::Timer::Value current_time)
|
||||||
}
|
}
|
||||||
else if (actual_y != expected_y)
|
else if (actual_y != expected_y)
|
||||||
{
|
{
|
||||||
const float time_since_move =
|
const float time_since_move = static_cast<float>(Timer::ConvertValueToSeconds(current_time - msg.move_time));
|
||||||
static_cast<float>(Common::Timer::ConvertValueToSeconds(current_time - msg.move_time));
|
|
||||||
if (time_since_move >= MOVE_DURATION)
|
if (time_since_move >= MOVE_DURATION)
|
||||||
{
|
{
|
||||||
msg.move_time = current_time;
|
msg.move_time = current_time;
|
||||||
|
@ -981,7 +978,7 @@ void ImGuiManager::DrawOSDMessages(Common::Timer::Value current_time)
|
||||||
|
|
||||||
void ImGuiManager::RenderOSDMessages()
|
void ImGuiManager::RenderOSDMessages()
|
||||||
{
|
{
|
||||||
const Common::Timer::Value current_time = Common::Timer::GetCurrentValue();
|
const Timer::Value current_time = Timer::GetCurrentValue();
|
||||||
AcquirePendingOSDMessages(current_time);
|
AcquirePendingOSDMessages(current_time);
|
||||||
DrawOSDMessages(current_time);
|
DrawOSDMessages(current_time);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ struct PadVibrationBinding
|
||||||
struct Motor
|
struct Motor
|
||||||
{
|
{
|
||||||
InputBindingKey binding;
|
InputBindingKey binding;
|
||||||
u64 last_update_time;
|
Timer::Value last_update_time;
|
||||||
InputSource* source;
|
InputSource* source;
|
||||||
float last_intensity;
|
float last_intensity;
|
||||||
};
|
};
|
||||||
|
@ -1607,14 +1607,14 @@ void InputManager::SetPadVibrationIntensity(u32 pad_index, float large_or_single
|
||||||
const float report_intensity = std::max(large_or_single_motor_intensity, small_motor_intensity);
|
const float report_intensity = std::max(large_or_single_motor_intensity, small_motor_intensity);
|
||||||
if (large_motor.source)
|
if (large_motor.source)
|
||||||
{
|
{
|
||||||
large_motor.last_update_time = Common::Timer::GetCurrentValue();
|
large_motor.last_update_time = Timer::GetCurrentValue();
|
||||||
large_motor.source->UpdateMotorState(large_motor.binding, report_intensity);
|
large_motor.source->UpdateMotorState(large_motor.binding, report_intensity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (large_motor.source == small_motor.source)
|
else if (large_motor.source == small_motor.source)
|
||||||
{
|
{
|
||||||
// both motors are bound to the same source, do an optimal update
|
// both motors are bound to the same source, do an optimal update
|
||||||
large_motor.last_update_time = Common::Timer::GetCurrentValue();
|
large_motor.last_update_time = Timer::GetCurrentValue();
|
||||||
large_motor.source->UpdateMotorState(large_motor.binding, small_motor.binding, large_or_single_motor_intensity,
|
large_motor.source->UpdateMotorState(large_motor.binding, small_motor.binding, large_or_single_motor_intensity,
|
||||||
small_motor_intensity);
|
small_motor_intensity);
|
||||||
}
|
}
|
||||||
|
@ -1623,12 +1623,12 @@ void InputManager::SetPadVibrationIntensity(u32 pad_index, float large_or_single
|
||||||
// update motors independently
|
// update motors independently
|
||||||
if (large_motor.source && large_motor.last_intensity != large_or_single_motor_intensity)
|
if (large_motor.source && large_motor.last_intensity != large_or_single_motor_intensity)
|
||||||
{
|
{
|
||||||
large_motor.last_update_time = Common::Timer::GetCurrentValue();
|
large_motor.last_update_time = Timer::GetCurrentValue();
|
||||||
large_motor.source->UpdateMotorState(large_motor.binding, large_or_single_motor_intensity);
|
large_motor.source->UpdateMotorState(large_motor.binding, large_or_single_motor_intensity);
|
||||||
}
|
}
|
||||||
if (small_motor.source && small_motor.last_intensity != small_motor_intensity)
|
if (small_motor.source && small_motor.last_intensity != small_motor_intensity)
|
||||||
{
|
{
|
||||||
small_motor.last_update_time = Common::Timer::GetCurrentValue();
|
small_motor.last_update_time = Timer::GetCurrentValue();
|
||||||
small_motor.source->UpdateMotorState(small_motor.binding, small_motor_intensity);
|
small_motor.source->UpdateMotorState(small_motor.binding, small_motor_intensity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1658,7 +1658,7 @@ void InputManager::PauseVibration()
|
||||||
void InputManager::UpdateContinuedVibration()
|
void InputManager::UpdateContinuedVibration()
|
||||||
{
|
{
|
||||||
// update vibration intensities, so if the game does a long effect, it continues
|
// update vibration intensities, so if the game does a long effect, it continues
|
||||||
const u64 current_time = Common::Timer::GetCurrentValue();
|
const u64 current_time = Timer::GetCurrentValue();
|
||||||
for (PadVibrationBinding& pad : s_pad_vibration_array)
|
for (PadVibrationBinding& pad : s_pad_vibration_array)
|
||||||
{
|
{
|
||||||
if (pad.AreMotorsCombined())
|
if (pad.AreMotorsCombined())
|
||||||
|
@ -1669,7 +1669,7 @@ void InputManager::UpdateContinuedVibration()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// so only check the first one
|
// so only check the first one
|
||||||
const double dt = Common::Timer::ConvertValueToSeconds(current_time - large_motor.last_update_time);
|
const double dt = Timer::ConvertValueToSeconds(current_time - large_motor.last_update_time);
|
||||||
if (dt < VIBRATION_UPDATE_INTERVAL_SECONDS)
|
if (dt < VIBRATION_UPDATE_INTERVAL_SECONDS)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1690,7 +1690,7 @@ void InputManager::UpdateContinuedVibration()
|
||||||
if (!motor.source || motor.last_intensity == 0.0f)
|
if (!motor.source || motor.last_intensity == 0.0f)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const double dt = Common::Timer::ConvertValueToSeconds(current_time - motor.last_update_time);
|
const double dt = Timer::ConvertValueToSeconds(current_time - motor.last_update_time);
|
||||||
if (dt < VIBRATION_UPDATE_INTERVAL_SECONDS)
|
if (dt < VIBRATION_UPDATE_INTERVAL_SECONDS)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -2593,8 +2593,8 @@ void MetalDevice::EndPresent(GPUSwapChain* swap_chain, bool explicit_present, u6
|
||||||
DebugAssert(m_num_current_render_targets == 0 && !m_current_depth_target);
|
DebugAssert(m_num_current_render_targets == 0 && !m_current_depth_target);
|
||||||
EndAnyEncoding();
|
EndAnyEncoding();
|
||||||
|
|
||||||
Common::Timer::Value current_time;
|
Timer::Value current_time;
|
||||||
if (present_time != 0 && (current_time = Common::Timer::GetCurrentValue()) < present_time)
|
if (present_time != 0 && (current_time = Timer::GetCurrentValue()) < present_time)
|
||||||
{
|
{
|
||||||
// Need to convert to mach absolute time. Time values should already be in nanoseconds.
|
// Need to convert to mach absolute time. Time values should already be in nanoseconds.
|
||||||
const u64 mach_time_nanoseconds = CocoaTools::ConvertMachTimeBaseToNanoseconds(mach_absolute_time());
|
const u64 mach_time_nanoseconds = CocoaTools::ConvertMachTimeBaseToNanoseconds(mach_absolute_time());
|
||||||
|
|
|
@ -53,7 +53,7 @@ ALWAYS_INLINE void ForAllChains(const T& F)
|
||||||
Chain DisplayChain(Config::DISPLAY_CHAIN_SECTION);
|
Chain DisplayChain(Config::DISPLAY_CHAIN_SECTION);
|
||||||
Chain InternalChain(Config::INTERNAL_CHAIN_SECTION);
|
Chain InternalChain(Config::INTERNAL_CHAIN_SECTION);
|
||||||
|
|
||||||
static Common::Timer s_timer;
|
static Timer s_timer;
|
||||||
|
|
||||||
static std::unordered_map<u64, std::unique_ptr<GPUSampler>> s_samplers;
|
static std::unordered_map<u64, std::unique_ptr<GPUSampler>> s_samplers;
|
||||||
static std::unique_ptr<GPUTexture> s_dummy_texture;
|
static std::unique_ptr<GPUTexture> s_dummy_texture;
|
||||||
|
@ -782,7 +782,7 @@ SettingsInterface& PostProcessing::GetLoadSettingsInterface(const char* section)
|
||||||
return *Host::Internal::GetBaseSettingsLayer();
|
return *Host::Internal::GetBaseSettingsLayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Common::Timer& PostProcessing::GetTimer()
|
const Timer& PostProcessing::GetTimer()
|
||||||
{
|
{
|
||||||
return s_timer;
|
return s_timer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,7 @@
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
class Timer;
|
class Timer;
|
||||||
}
|
|
||||||
|
|
||||||
class GPUSampler;
|
class GPUSampler;
|
||||||
class GPUTexture;
|
class GPUTexture;
|
||||||
|
@ -171,7 +169,7 @@ void Shutdown();
|
||||||
GPUSampler* GetSampler(const GPUSampler::Config& config);
|
GPUSampler* GetSampler(const GPUSampler::Config& config);
|
||||||
GPUTexture* GetDummyTexture();
|
GPUTexture* GetDummyTexture();
|
||||||
|
|
||||||
const Common::Timer& GetTimer();
|
const Timer& GetTimer();
|
||||||
|
|
||||||
extern Chain DisplayChain;
|
extern Chain DisplayChain;
|
||||||
extern Chain InternalChain;
|
extern Chain InternalChain;
|
||||||
|
|
|
@ -144,7 +144,7 @@ private:
|
||||||
bool m_valid = false;
|
bool m_valid = false;
|
||||||
bool m_wants_depth_buffer = false;
|
bool m_wants_depth_buffer = false;
|
||||||
|
|
||||||
Common::Timer m_frame_timer;
|
Timer m_frame_timer;
|
||||||
u32 m_frame_count = 0;
|
u32 m_frame_count = 0;
|
||||||
|
|
||||||
// Specifically using a fixed seed, so that it's consistent from run-to-run.
|
// Specifically using a fixed seed, so that it's consistent from run-to-run.
|
||||||
|
|
Loading…
Reference in New Issue