mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Common::Timer: use chrono::steady_clock internally
This commit is contained in:
@ -16,7 +16,7 @@ static constexpr u64 FPS_REFRESH_INTERVAL_US = 250000;
|
||||
|
||||
FPSCounter::FPSCounter()
|
||||
{
|
||||
m_last_time = Common::Timer::GetTimeUs();
|
||||
m_last_time = Common::Timer::NowUs();
|
||||
|
||||
m_on_state_changed_handle = Core::AddOnStateChangedCallback([this](Core::State state) {
|
||||
if (state == Core::State::Paused)
|
||||
@ -44,7 +44,7 @@ void FPSCounter::LogRenderTimeToFile(u64 val)
|
||||
|
||||
void FPSCounter::Update()
|
||||
{
|
||||
const u64 time = Common::Timer::GetTimeUs();
|
||||
const u64 time = Common::Timer::NowUs();
|
||||
const u64 diff = time - m_last_time;
|
||||
m_time_diff_secs = static_cast<double>(diff / 1000000.0);
|
||||
if (g_ActiveConfig.bLogRenderTimeToFile)
|
||||
@ -66,11 +66,11 @@ void FPSCounter::SetPaused(bool paused)
|
||||
{
|
||||
if (paused)
|
||||
{
|
||||
m_last_time_pause = Common::Timer::GetTimeUs();
|
||||
m_last_time_pause = Common::Timer::NowUs();
|
||||
}
|
||||
else
|
||||
{
|
||||
const u64 time = Common::Timer::GetTimeUs();
|
||||
const u64 time = Common::Timer::NowUs();
|
||||
const u64 diff = time - m_last_time_pause;
|
||||
m_last_time += diff;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ void HiresTexture::Prefetch()
|
||||
const size_t max_mem =
|
||||
(sys_mem / 2 < recommended_min_mem) ? (sys_mem / 2) : (sys_mem - recommended_min_mem);
|
||||
|
||||
const u32 start_time = Common::Timer::GetTimeMs();
|
||||
const u64 start_time = Common::Timer::NowMs();
|
||||
for (const auto& entry : s_textureMap)
|
||||
{
|
||||
const std::string& base_filename = entry.first;
|
||||
@ -207,7 +207,7 @@ void HiresTexture::Prefetch()
|
||||
}
|
||||
}
|
||||
|
||||
const u32 stop_time = Common::Timer::GetTimeMs();
|
||||
const u64 stop_time = Common::Timer::NowMs();
|
||||
OSD::AddMessage(fmt::format("Custom Textures loaded, {:.1f} MB in {:.1f}s",
|
||||
size_sum / (1024.0 * 1024.0), (stop_time - start_time) / 1000.0),
|
||||
10000);
|
||||
|
@ -32,12 +32,12 @@ static std::atomic<int> s_obscured_pixels_top = 0;
|
||||
struct Message
|
||||
{
|
||||
Message() = default;
|
||||
Message(std::string text_, u32 timestamp_, u32 duration_, u32 color_)
|
||||
Message(std::string text_, u64 timestamp_, u32 duration_, u32 color_)
|
||||
: text(std::move(text_)), timestamp(timestamp_), duration(duration_), color(color_)
|
||||
{
|
||||
}
|
||||
std::string text;
|
||||
u32 timestamp = 0;
|
||||
u64 timestamp = 0;
|
||||
u32 duration = 0;
|
||||
bool ever_drawn = false;
|
||||
u32 color = 0;
|
||||
@ -93,20 +93,20 @@ void AddTypedMessage(MessageType type, std::string message, u32 ms, u32 argb)
|
||||
{
|
||||
std::lock_guard lock{s_messages_mutex};
|
||||
s_messages.erase(type);
|
||||
s_messages.emplace(type, Message(std::move(message), Common::Timer::GetTimeMs() + ms, ms, argb));
|
||||
s_messages.emplace(type, Message(std::move(message), Common::Timer::NowMs() + ms, ms, argb));
|
||||
}
|
||||
|
||||
void AddMessage(std::string message, u32 ms, u32 argb)
|
||||
{
|
||||
std::lock_guard lock{s_messages_mutex};
|
||||
s_messages.emplace(MessageType::Typeless,
|
||||
Message(std::move(message), Common::Timer::GetTimeMs() + ms, ms, argb));
|
||||
Message(std::move(message), Common::Timer::NowMs() + ms, ms, argb));
|
||||
}
|
||||
|
||||
void DrawMessages()
|
||||
{
|
||||
const bool draw_messages = Config::Get(Config::MAIN_OSD_MESSAGES);
|
||||
const u32 now = Common::Timer::GetTimeMs();
|
||||
const u64 now = Common::Timer::NowMs();
|
||||
const float current_x =
|
||||
LEFT_MARGIN * ImGui::GetIO().DisplayFramebufferScale.x + s_obscured_pixels_left;
|
||||
float current_y = TOP_MARGIN * ImGui::GetIO().DisplayFramebufferScale.y + s_obscured_pixels_top;
|
||||
|
@ -640,7 +640,7 @@ void PostProcessing::FillUniformBuffer(const MathUtil::Rectangle<int>& src,
|
||||
static_cast<float>(src.GetWidth()) * rcp_src_width,
|
||||
static_cast<float>(src.GetHeight()) * rcp_src_height},
|
||||
static_cast<s32>(src_layer),
|
||||
static_cast<u32>(m_timer.GetTimeElapsed()),
|
||||
static_cast<u32>(m_timer.ElapsedMs()),
|
||||
};
|
||||
|
||||
u8* buf = m_uniform_staging_buffer.data();
|
||||
|
@ -1066,7 +1066,7 @@ bool Renderer::InitializeImGui()
|
||||
if (!RecompileImGuiPipeline())
|
||||
return false;
|
||||
|
||||
m_imgui_last_frame_time = Common::Timer::GetTimeUs();
|
||||
m_imgui_last_frame_time = Common::Timer::NowUs();
|
||||
BeginImGuiFrame();
|
||||
return true;
|
||||
}
|
||||
@ -1139,7 +1139,7 @@ void Renderer::BeginImGuiFrame()
|
||||
{
|
||||
std::unique_lock<std::mutex> imgui_lock(m_imgui_mutex);
|
||||
|
||||
const u64 current_time_us = Common::Timer::GetTimeUs();
|
||||
const u64 current_time_us = Common::Timer::NowUs();
|
||||
const u64 time_diff_us = current_time_us - m_imgui_last_frame_time;
|
||||
const float time_diff_secs = static_cast<float>(time_diff_us / 1000000.0);
|
||||
m_imgui_last_frame_time = current_time_us;
|
||||
|
Reference in New Issue
Block a user