diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/fs/file.h | 5 | ||||
| -rw-r--r-- | src/common/settings.h | 1 | ||||
| -rw-r--r-- | src/common/wall_clock.cpp | 16 | ||||
| -rw-r--r-- | src/common/wall_clock.h | 8 | ||||
| -rw-r--r-- | src/common/x64/native_clock.cpp | 6 | ||||
| -rw-r--r-- | src/common/x64/xbyak_abi.h | 16 |
6 files changed, 31 insertions, 21 deletions
diff --git a/src/common/fs/file.h b/src/common/fs/file.h index 2c4ab4332..a4f7944cd 100644 --- a/src/common/fs/file.h +++ b/src/common/fs/file.h | |||
| @@ -188,9 +188,8 @@ public: | |||
| 188 | 188 | ||
| 189 | #ifdef _WIN32 | 189 | #ifdef _WIN32 |
| 190 | template <typename Path> | 190 | template <typename Path> |
| 191 | [[nodiscard]] void Open(const Path& path, FileAccessMode mode, | 191 | void Open(const Path& path, FileAccessMode mode, FileType type = FileType::BinaryFile, |
| 192 | FileType type = FileType::BinaryFile, | 192 | FileShareFlag flag = FileShareFlag::ShareReadOnly) { |
| 193 | FileShareFlag flag = FileShareFlag::ShareReadOnly) { | ||
| 194 | using ValueType = typename Path::value_type; | 193 | using ValueType = typename Path::value_type; |
| 195 | if constexpr (IsChar<ValueType>) { | 194 | if constexpr (IsChar<ValueType>) { |
| 196 | Open(ToU8String(path), mode, type, flag); | 195 | Open(ToU8String(path), mode, type, flag); |
diff --git a/src/common/settings.h b/src/common/settings.h index d01c0448c..9bee6e10f 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -554,6 +554,7 @@ struct Values { | |||
| 554 | Setting<bool> use_docked_mode{true, "use_docked_mode"}; | 554 | Setting<bool> use_docked_mode{true, "use_docked_mode"}; |
| 555 | 555 | ||
| 556 | BasicSetting<bool> enable_raw_input{false, "enable_raw_input"}; | 556 | BasicSetting<bool> enable_raw_input{false, "enable_raw_input"}; |
| 557 | BasicSetting<bool> controller_navigation{true, "controller_navigation"}; | ||
| 557 | 558 | ||
| 558 | Setting<bool> vibration_enabled{true, "vibration_enabled"}; | 559 | Setting<bool> vibration_enabled{true, "vibration_enabled"}; |
| 559 | Setting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"}; | 560 | Setting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"}; |
diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp index 49830b8ab..9acf7551e 100644 --- a/src/common/wall_clock.cpp +++ b/src/common/wall_clock.cpp | |||
| @@ -65,14 +65,20 @@ private: | |||
| 65 | 65 | ||
| 66 | #ifdef ARCHITECTURE_x86_64 | 66 | #ifdef ARCHITECTURE_x86_64 |
| 67 | 67 | ||
| 68 | std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, | 68 | std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency, |
| 69 | u32 emulated_clock_frequency) { | 69 | u64 emulated_clock_frequency) { |
| 70 | const auto& caps = GetCPUCaps(); | 70 | const auto& caps = GetCPUCaps(); |
| 71 | u64 rtsc_frequency = 0; | 71 | u64 rtsc_frequency = 0; |
| 72 | if (caps.invariant_tsc) { | 72 | if (caps.invariant_tsc) { |
| 73 | rtsc_frequency = EstimateRDTSCFrequency(); | 73 | rtsc_frequency = EstimateRDTSCFrequency(); |
| 74 | } | 74 | } |
| 75 | if (rtsc_frequency == 0) { | 75 | |
| 76 | // Fallback to StandardWallClock if the hardware TSC does not have the precision greater than: | ||
| 77 | // - A nanosecond | ||
| 78 | // - The emulated CPU frequency | ||
| 79 | // - The emulated clock counter frequency (CNTFRQ) | ||
| 80 | if (rtsc_frequency <= WallClock::NS_RATIO || rtsc_frequency <= emulated_cpu_frequency || | ||
| 81 | rtsc_frequency <= emulated_clock_frequency) { | ||
| 76 | return std::make_unique<StandardWallClock>(emulated_cpu_frequency, | 82 | return std::make_unique<StandardWallClock>(emulated_cpu_frequency, |
| 77 | emulated_clock_frequency); | 83 | emulated_clock_frequency); |
| 78 | } else { | 84 | } else { |
| @@ -83,8 +89,8 @@ std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, | |||
| 83 | 89 | ||
| 84 | #else | 90 | #else |
| 85 | 91 | ||
| 86 | std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, | 92 | std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency, |
| 87 | u32 emulated_clock_frequency) { | 93 | u64 emulated_clock_frequency) { |
| 88 | return std::make_unique<StandardWallClock>(emulated_cpu_frequency, emulated_clock_frequency); | 94 | return std::make_unique<StandardWallClock>(emulated_cpu_frequency, emulated_clock_frequency); |
| 89 | } | 95 | } |
| 90 | 96 | ||
diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h index cef3e9499..874448c27 100644 --- a/src/common/wall_clock.h +++ b/src/common/wall_clock.h | |||
| @@ -13,6 +13,10 @@ namespace Common { | |||
| 13 | 13 | ||
| 14 | class WallClock { | 14 | class WallClock { |
| 15 | public: | 15 | public: |
| 16 | static constexpr u64 NS_RATIO = 1'000'000'000; | ||
| 17 | static constexpr u64 US_RATIO = 1'000'000; | ||
| 18 | static constexpr u64 MS_RATIO = 1'000; | ||
| 19 | |||
| 16 | virtual ~WallClock() = default; | 20 | virtual ~WallClock() = default; |
| 17 | 21 | ||
| 18 | /// Returns current wall time in nanoseconds | 22 | /// Returns current wall time in nanoseconds |
| @@ -49,7 +53,7 @@ private: | |||
| 49 | bool is_native; | 53 | bool is_native; |
| 50 | }; | 54 | }; |
| 51 | 55 | ||
| 52 | [[nodiscard]] std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, | 56 | [[nodiscard]] std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency, |
| 53 | u32 emulated_clock_frequency); | 57 | u64 emulated_clock_frequency); |
| 54 | 58 | ||
| 55 | } // namespace Common | 59 | } // namespace Common |
diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index 82ee2c8a1..91b842829 100644 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp | |||
| @@ -47,9 +47,9 @@ NativeClock::NativeClock(u64 emulated_cpu_frequency_, u64 emulated_clock_frequen | |||
| 47 | _mm_mfence(); | 47 | _mm_mfence(); |
| 48 | time_point.inner.last_measure = __rdtsc(); | 48 | time_point.inner.last_measure = __rdtsc(); |
| 49 | time_point.inner.accumulated_ticks = 0U; | 49 | time_point.inner.accumulated_ticks = 0U; |
| 50 | ns_rtsc_factor = GetFixedPoint64Factor(1000000000, rtsc_frequency); | 50 | ns_rtsc_factor = GetFixedPoint64Factor(NS_RATIO, rtsc_frequency); |
| 51 | us_rtsc_factor = GetFixedPoint64Factor(1000000, rtsc_frequency); | 51 | us_rtsc_factor = GetFixedPoint64Factor(US_RATIO, rtsc_frequency); |
| 52 | ms_rtsc_factor = GetFixedPoint64Factor(1000, rtsc_frequency); | 52 | ms_rtsc_factor = GetFixedPoint64Factor(MS_RATIO, rtsc_frequency); |
| 53 | clock_rtsc_factor = GetFixedPoint64Factor(emulated_clock_frequency, rtsc_frequency); | 53 | clock_rtsc_factor = GetFixedPoint64Factor(emulated_clock_frequency, rtsc_frequency); |
| 54 | cpu_rtsc_factor = GetFixedPoint64Factor(emulated_cpu_frequency, rtsc_frequency); | 54 | cpu_rtsc_factor = GetFixedPoint64Factor(emulated_cpu_frequency, rtsc_frequency); |
| 55 | } | 55 | } |
diff --git a/src/common/x64/xbyak_abi.h b/src/common/x64/xbyak_abi.h index 0ddf9b83e..87b3d63a4 100644 --- a/src/common/x64/xbyak_abi.h +++ b/src/common/x64/xbyak_abi.h | |||
| @@ -37,12 +37,12 @@ constexpr Xbyak::Reg IndexToReg(size_t reg_index) { | |||
| 37 | } | 37 | } |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | inline std::bitset<32> BuildRegSet(std::initializer_list<Xbyak::Reg> regs) { | 40 | constexpr std::bitset<32> BuildRegSet(std::initializer_list<Xbyak::Reg> regs) { |
| 41 | std::bitset<32> bits; | 41 | size_t bits = 0; |
| 42 | for (const Xbyak::Reg& reg : regs) { | 42 | for (const Xbyak::Reg& reg : regs) { |
| 43 | bits[RegToIndex(reg)] = true; | 43 | bits |= size_t{1} << RegToIndex(reg); |
| 44 | } | 44 | } |
| 45 | return bits; | 45 | return {bits}; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | constexpr inline std::bitset<32> ABI_ALL_GPRS(0x0000FFFF); | 48 | constexpr inline std::bitset<32> ABI_ALL_GPRS(0x0000FFFF); |
| @@ -57,7 +57,7 @@ constexpr inline Xbyak::Reg ABI_PARAM2 = Xbyak::util::rdx; | |||
| 57 | constexpr inline Xbyak::Reg ABI_PARAM3 = Xbyak::util::r8; | 57 | constexpr inline Xbyak::Reg ABI_PARAM3 = Xbyak::util::r8; |
| 58 | constexpr inline Xbyak::Reg ABI_PARAM4 = Xbyak::util::r9; | 58 | constexpr inline Xbyak::Reg ABI_PARAM4 = Xbyak::util::r9; |
| 59 | 59 | ||
| 60 | const std::bitset<32> ABI_ALL_CALLER_SAVED = BuildRegSet({ | 60 | constexpr inline std::bitset<32> ABI_ALL_CALLER_SAVED = BuildRegSet({ |
| 61 | // GPRs | 61 | // GPRs |
| 62 | Xbyak::util::rcx, | 62 | Xbyak::util::rcx, |
| 63 | Xbyak::util::rdx, | 63 | Xbyak::util::rdx, |
| @@ -74,7 +74,7 @@ const std::bitset<32> ABI_ALL_CALLER_SAVED = BuildRegSet({ | |||
| 74 | Xbyak::util::xmm5, | 74 | Xbyak::util::xmm5, |
| 75 | }); | 75 | }); |
| 76 | 76 | ||
| 77 | const std::bitset<32> ABI_ALL_CALLEE_SAVED = BuildRegSet({ | 77 | constexpr inline std::bitset<32> ABI_ALL_CALLEE_SAVED = BuildRegSet({ |
| 78 | // GPRs | 78 | // GPRs |
| 79 | Xbyak::util::rbx, | 79 | Xbyak::util::rbx, |
| 80 | Xbyak::util::rsi, | 80 | Xbyak::util::rsi, |
| @@ -108,7 +108,7 @@ constexpr inline Xbyak::Reg ABI_PARAM2 = Xbyak::util::rsi; | |||
| 108 | constexpr inline Xbyak::Reg ABI_PARAM3 = Xbyak::util::rdx; | 108 | constexpr inline Xbyak::Reg ABI_PARAM3 = Xbyak::util::rdx; |
| 109 | constexpr inline Xbyak::Reg ABI_PARAM4 = Xbyak::util::rcx; | 109 | constexpr inline Xbyak::Reg ABI_PARAM4 = Xbyak::util::rcx; |
| 110 | 110 | ||
| 111 | const std::bitset<32> ABI_ALL_CALLER_SAVED = BuildRegSet({ | 111 | constexpr inline std::bitset<32> ABI_ALL_CALLER_SAVED = BuildRegSet({ |
| 112 | // GPRs | 112 | // GPRs |
| 113 | Xbyak::util::rcx, | 113 | Xbyak::util::rcx, |
| 114 | Xbyak::util::rdx, | 114 | Xbyak::util::rdx, |
| @@ -137,7 +137,7 @@ const std::bitset<32> ABI_ALL_CALLER_SAVED = BuildRegSet({ | |||
| 137 | Xbyak::util::xmm15, | 137 | Xbyak::util::xmm15, |
| 138 | }); | 138 | }); |
| 139 | 139 | ||
| 140 | const std::bitset<32> ABI_ALL_CALLEE_SAVED = BuildRegSet({ | 140 | constexpr inline std::bitset<32> ABI_ALL_CALLEE_SAVED = BuildRegSet({ |
| 141 | // GPRs | 141 | // GPRs |
| 142 | Xbyak::util::rbx, | 142 | Xbyak::util::rbx, |
| 143 | Xbyak::util::rbp, | 143 | Xbyak::util::rbp, |