2018-07-24 03:03:24 -07:00
|
|
|
// Copyright 2008 Dolphin Emulator Project / 2017 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-06-04 16:52:42 -07:00
|
|
|
#include <chrono>
|
2018-07-24 03:03:24 -07:00
|
|
|
#include "common/common_types.h"
|
2020-02-11 15:56:24 -08:00
|
|
|
#include "core/hardware_properties.h"
|
2018-07-24 03:03:24 -07:00
|
|
|
|
2019-02-12 09:32:15 -08:00
|
|
|
namespace Core::Timing {
|
2018-07-24 03:03:24 -07:00
|
|
|
|
2019-06-04 16:52:42 -07:00
|
|
|
s64 msToCycles(std::chrono::milliseconds ms);
|
|
|
|
s64 usToCycles(std::chrono::microseconds us);
|
|
|
|
s64 nsToCycles(std::chrono::nanoseconds ns);
|
2020-02-05 15:12:27 -08:00
|
|
|
u64 nsToClockCycles(std::chrono::nanoseconds ns);
|
2018-07-24 03:03:24 -07:00
|
|
|
|
2019-06-04 17:11:04 -07:00
|
|
|
inline std::chrono::milliseconds CyclesToMs(s64 cycles) {
|
2020-02-11 15:56:24 -08:00
|
|
|
return std::chrono::milliseconds(cycles * 1000 / Hardware::BASE_CLOCK_RATE);
|
2018-07-24 03:03:24 -07:00
|
|
|
}
|
|
|
|
|
2019-06-04 17:11:04 -07:00
|
|
|
inline std::chrono::nanoseconds CyclesToNs(s64 cycles) {
|
2020-02-11 15:56:24 -08:00
|
|
|
return std::chrono::nanoseconds(cycles * 1000000000 / Hardware::BASE_CLOCK_RATE);
|
2018-07-24 03:03:24 -07:00
|
|
|
}
|
|
|
|
|
2019-06-04 17:11:04 -07:00
|
|
|
inline std::chrono::microseconds CyclesToUs(s64 cycles) {
|
2020-02-11 15:56:24 -08:00
|
|
|
return std::chrono::microseconds(cycles * 1000000 / Hardware::BASE_CLOCK_RATE);
|
2018-07-24 03:03:24 -07:00
|
|
|
}
|
|
|
|
|
2019-02-15 09:15:28 -08:00
|
|
|
u64 CpuCyclesToClockCycles(u64 ticks);
|
|
|
|
|
2019-02-12 09:32:15 -08:00
|
|
|
} // namespace Core::Timing
|