summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/common_types.h10
-rw-r--r--src/common/fs/file.h5
-rw-r--r--src/common/input.h2
-rw-r--r--src/common/telemetry.h26
-rw-r--r--src/common/wall_clock.cpp16
-rw-r--r--src/common/wall_clock.h8
-rw-r--r--src/common/x64/native_clock.cpp6
7 files changed, 40 insertions, 33 deletions
diff --git a/src/common/common_types.h b/src/common/common_types.h
index 4cec89fbd..99bffc460 100644
--- a/src/common/common_types.h
+++ b/src/common/common_types.h
@@ -46,13 +46,3 @@ using GPUVAddr = u64; ///< Represents a pointer in the GPU virtual address space
using u128 = std::array<std::uint64_t, 2>;
static_assert(sizeof(u128) == 16, "u128 must be 128 bits wide");
-
-// An inheritable class to disallow the copy constructor and operator= functions
-class NonCopyable {
-protected:
- constexpr NonCopyable() = default;
- ~NonCopyable() = default;
-
- NonCopyable(const NonCopyable&) = delete;
- NonCopyable& operator=(const NonCopyable&) = delete;
-};
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:
#ifdef _WIN32
template <typename Path>
- [[nodiscard]] void Open(const Path& path, FileAccessMode mode,
- FileType type = FileType::BinaryFile,
- FileShareFlag flag = FileShareFlag::ShareReadOnly) {
+ void Open(const Path& path, FileAccessMode mode, FileType type = FileType::BinaryFile,
+ FileShareFlag flag = FileShareFlag::ShareReadOnly) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
Open(ToU8String(path), mode, type, flag);
diff --git a/src/common/input.h b/src/common/input.h
index f4f9eb30a..54fcb24b0 100644
--- a/src/common/input.h
+++ b/src/common/input.h
@@ -209,6 +209,8 @@ enum class ButtonNames {
Triangle,
Share,
Options,
+ Home,
+ Touch,
// Mouse buttons
ButtonMouseWheel,
diff --git a/src/common/telemetry.h b/src/common/telemetry.h
index 49186e848..d38aeac99 100644
--- a/src/common/telemetry.h
+++ b/src/common/telemetry.h
@@ -8,6 +8,7 @@
#include <map>
#include <memory>
#include <string>
+#include "common/common_funcs.h"
#include "common/common_types.h"
namespace Common::Telemetry {
@@ -28,7 +29,7 @@ struct VisitorInterface;
/**
* Interface class for telemetry data fields.
*/
-class FieldInterface : NonCopyable {
+class FieldInterface {
public:
virtual ~FieldInterface() = default;
@@ -52,14 +53,15 @@ public:
template <typename T>
class Field : public FieldInterface {
public:
+ YUZU_NON_COPYABLE(Field);
+
Field(FieldType type_, std::string name_, T value_)
: name(std::move(name_)), type(type_), value(std::move(value_)) {}
- Field(const Field&) = default;
- Field& operator=(const Field&) = default;
+ ~Field() override = default;
- Field(Field&&) = default;
- Field& operator=(Field&& other) = default;
+ Field(Field&&) noexcept = default;
+ Field& operator=(Field&& other) noexcept = default;
void Accept(VisitorInterface& visitor) const override;
@@ -98,9 +100,15 @@ private:
/**
* Collection of data fields that have been logged.
*/
-class FieldCollection final : NonCopyable {
+class FieldCollection final {
public:
+ YUZU_NON_COPYABLE(FieldCollection);
+
FieldCollection() = default;
+ ~FieldCollection() = default;
+
+ FieldCollection(FieldCollection&&) noexcept = default;
+ FieldCollection& operator=(FieldCollection&&) noexcept = default;
/**
* Accept method for the visitor pattern, visits each field in the collection.
@@ -133,7 +141,7 @@ private:
* Telemetry fields visitor interface class. A backend to log to a web service should implement
* this interface.
*/
-struct VisitorInterface : NonCopyable {
+struct VisitorInterface {
virtual ~VisitorInterface() = default;
virtual void Visit(const Field<bool>& field) = 0;
@@ -160,8 +168,8 @@ struct VisitorInterface : NonCopyable {
* Empty implementation of VisitorInterface that drops all fields. Used when a functional
* backend implementation is not available.
*/
-struct NullVisitor : public VisitorInterface {
- ~NullVisitor() = default;
+struct NullVisitor final : public VisitorInterface {
+ YUZU_NON_COPYABLE(NullVisitor);
void Visit(const Field<bool>& /*field*/) override {}
void Visit(const Field<double>& /*field*/) override {}
diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp
index ffa282e88..9acf7551e 100644
--- a/src/common/wall_clock.cpp
+++ b/src/common/wall_clock.cpp
@@ -65,16 +65,20 @@ private:
#ifdef ARCHITECTURE_x86_64
-std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
- u32 emulated_clock_frequency) {
+std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency,
+ u64 emulated_clock_frequency) {
const auto& caps = GetCPUCaps();
u64 rtsc_frequency = 0;
if (caps.invariant_tsc) {
rtsc_frequency = EstimateRDTSCFrequency();
}
- // Fallback to StandardWallClock if rtsc period is higher than a nano second
- if (rtsc_frequency <= 1000000000) {
+ // Fallback to StandardWallClock if the hardware TSC does not have the precision greater than:
+ // - A nanosecond
+ // - The emulated CPU frequency
+ // - The emulated clock counter frequency (CNTFRQ)
+ if (rtsc_frequency <= WallClock::NS_RATIO || rtsc_frequency <= emulated_cpu_frequency ||
+ rtsc_frequency <= emulated_clock_frequency) {
return std::make_unique<StandardWallClock>(emulated_cpu_frequency,
emulated_clock_frequency);
} else {
@@ -85,8 +89,8 @@ std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
#else
-std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
- u32 emulated_clock_frequency) {
+std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency,
+ u64 emulated_clock_frequency) {
return std::make_unique<StandardWallClock>(emulated_cpu_frequency, emulated_clock_frequency);
}
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 {
class WallClock {
public:
+ static constexpr u64 NS_RATIO = 1'000'000'000;
+ static constexpr u64 US_RATIO = 1'000'000;
+ static constexpr u64 MS_RATIO = 1'000;
+
virtual ~WallClock() = default;
/// Returns current wall time in nanoseconds
@@ -49,7 +53,7 @@ private:
bool is_native;
};
-[[nodiscard]] std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
- u32 emulated_clock_frequency);
+[[nodiscard]] std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency,
+ u64 emulated_clock_frequency);
} // 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
_mm_mfence();
time_point.inner.last_measure = __rdtsc();
time_point.inner.accumulated_ticks = 0U;
- ns_rtsc_factor = GetFixedPoint64Factor(1000000000, rtsc_frequency);
- us_rtsc_factor = GetFixedPoint64Factor(1000000, rtsc_frequency);
- ms_rtsc_factor = GetFixedPoint64Factor(1000, rtsc_frequency);
+ ns_rtsc_factor = GetFixedPoint64Factor(NS_RATIO, rtsc_frequency);
+ us_rtsc_factor = GetFixedPoint64Factor(US_RATIO, rtsc_frequency);
+ ms_rtsc_factor = GetFixedPoint64Factor(MS_RATIO, rtsc_frequency);
clock_rtsc_factor = GetFixedPoint64Factor(emulated_clock_frequency, rtsc_frequency);
cpu_rtsc_factor = GetFixedPoint64Factor(emulated_cpu_frequency, rtsc_frequency);
}