mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-07-23 10:55:45 +00:00
Common: Implement WallClock Interface and implement a native clock for x64
This commit is contained in:
parent
ab76c0e296
commit
ee32067b10
10 changed files with 378 additions and 40 deletions
40
src/common/wall_clock.h
Normal file
40
src/common/wall_clock.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2020 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Common {
|
||||
|
||||
class WallClock {
|
||||
public:
|
||||
virtual std::chrono::nanoseconds GetTimeNS() = 0;
|
||||
virtual std::chrono::microseconds GetTimeUS() = 0;
|
||||
virtual std::chrono::milliseconds GetTimeMS() = 0;
|
||||
virtual u64 GetClockCycles() = 0;
|
||||
virtual u64 GetCPUCycles() = 0;
|
||||
|
||||
/// Tells if the wall clock, uses the host CPU's hardware clock
|
||||
bool IsNative() const {
|
||||
return is_native;
|
||||
}
|
||||
|
||||
protected:
|
||||
WallClock(u64 emulated_cpu_frequency, u64 emulated_clock_frequency, bool is_native)
|
||||
: emulated_cpu_frequency{emulated_cpu_frequency},
|
||||
emulated_clock_frequency{emulated_clock_frequency}, is_native{is_native} {}
|
||||
|
||||
u64 emulated_cpu_frequency;
|
||||
u64 emulated_clock_frequency;
|
||||
|
||||
private:
|
||||
bool is_native;
|
||||
};
|
||||
|
||||
WallClock* CreateBestMatchingClock(u32 emulated_cpu_frequency, u32 emulated_clock_frequency);
|
||||
|
||||
} // namespace Common
|
Loading…
Add table
Add a link
Reference in a new issue