2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

core/core_timing_utils: Simplify overload set

Removes unused overloads, simplifying the overall interface,
deduplicating some code.
This commit is contained in:
Lioncash 2019-06-04 19:41:48 -04:00
parent 55f8111543
commit 79189c7e3e
2 changed files with 2 additions and 49 deletions

View file

@ -26,15 +26,7 @@ s64 usToCycles(s64 us) {
} }
s64 usToCycles(u64 us) { s64 usToCycles(u64 us) {
if (us / 1000000 > MAX_VALUE_TO_MULTIPLY) { return usToCycles(static_cast<s64>(us));
LOG_ERROR(Core_Timing, "Integer overflow, use max value");
return std::numeric_limits<s64>::max();
}
if (us > MAX_VALUE_TO_MULTIPLY) {
LOG_DEBUG(Core_Timing, "Time very big, do rounding");
return BASE_CLOCK_RATE * static_cast<s64>(us / 1000000);
}
return (BASE_CLOCK_RATE * static_cast<s64>(us)) / 1000000;
} }
s64 nsToCycles(s64 ns) { s64 nsToCycles(s64 ns) {
@ -50,15 +42,7 @@ s64 nsToCycles(s64 ns) {
} }
s64 nsToCycles(u64 ns) { s64 nsToCycles(u64 ns) {
if (ns / 1000000000 > MAX_VALUE_TO_MULTIPLY) { return nsToCycles(static_cast<s64>(ns));
LOG_ERROR(Core_Timing, "Integer overflow, use max value");
return std::numeric_limits<s64>::max();
}
if (ns > MAX_VALUE_TO_MULTIPLY) {
LOG_DEBUG(Core_Timing, "Time very big, do rounding");
return BASE_CLOCK_RATE * (static_cast<s64>(ns) / 1000000000);
}
return (BASE_CLOCK_RATE * static_cast<s64>(ns)) / 1000000000;
} }
u64 CpuCyclesToClockCycles(u64 ticks) { u64 CpuCyclesToClockCycles(u64 ticks) {

View file

@ -13,41 +13,10 @@ namespace Core::Timing {
constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch clock speed is 1020MHz un/docked constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch clock speed is 1020MHz un/docked
constexpr u64 CNTFREQ = 19200000; // Value from fusee. constexpr u64 CNTFREQ = 19200000; // Value from fusee.
inline s64 msToCycles(int ms) {
// since ms is int there is no way to overflow
return BASE_CLOCK_RATE * static_cast<s64>(ms) / 1000;
}
inline s64 msToCycles(float ms) {
return static_cast<s64>(BASE_CLOCK_RATE * (0.001f) * ms);
}
inline s64 msToCycles(double ms) {
return static_cast<s64>(BASE_CLOCK_RATE * (0.001) * ms);
}
inline s64 usToCycles(float us) {
return static_cast<s64>(BASE_CLOCK_RATE * (0.000001f) * us);
}
inline s64 usToCycles(int us) {
return (BASE_CLOCK_RATE * static_cast<s64>(us) / 1000000);
}
s64 usToCycles(s64 us); s64 usToCycles(s64 us);
s64 usToCycles(u64 us); s64 usToCycles(u64 us);
inline s64 nsToCycles(float ns) {
return static_cast<s64>(BASE_CLOCK_RATE * (0.000000001f) * ns);
}
inline s64 nsToCycles(int ns) {
return BASE_CLOCK_RATE * static_cast<s64>(ns) / 1000000000;
}
s64 nsToCycles(s64 ns); s64 nsToCycles(s64 ns);
s64 nsToCycles(u64 ns); s64 nsToCycles(u64 ns);
inline u64 cyclesToNs(s64 cycles) { inline u64 cyclesToNs(s64 cycles) {