diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/common_funcs.h | 23 | ||||
-rw-r--r-- | src/common/intrusive_red_black_tree.h | 1 | ||||
-rw-r--r-- | src/common/parent_of_member.h | 11 | ||||
-rw-r--r-- | src/common/settings.cpp | 9 | ||||
-rw-r--r-- | src/common/settings.h | 10 | ||||
-rw-r--r-- | src/common/tree.h | 2 |
6 files changed, 42 insertions, 14 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 4ace2cd33..17d1ee86b 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -108,6 +108,14 @@ __declspec(dllimport) void __stdcall DebugBreak(void); } \ } +#define YUZU_NON_COPYABLE(cls) \ + cls(const cls&) = delete; \ + cls& operator=(const cls&) = delete + +#define YUZU_NON_MOVEABLE(cls) \ + cls(cls&&) = delete; \ + cls& operator=(cls&&) = delete + #define R_SUCCEEDED(res) (res.IsSuccess()) /// Evaluates an expression that returns a result, and returns the result if it would fail. @@ -128,4 +136,19 @@ namespace Common { return u32(a) | u32(b) << 8 | u32(c) << 16 | u32(d) << 24; } +// std::size() does not support zero-size C arrays. We're fixing that. +template <class C> +constexpr auto Size(const C& c) -> decltype(c.size()) { + return std::size(c); +} + +template <class C> +constexpr std::size_t Size(const C& c) { + if constexpr (sizeof(C) == 0) { + return 0; + } else { + return std::size(c); + } +} + } // namespace Common diff --git a/src/common/intrusive_red_black_tree.h b/src/common/intrusive_red_black_tree.h index c0bbcd457..1f696fe80 100644 --- a/src/common/intrusive_red_black_tree.h +++ b/src/common/intrusive_red_black_tree.h @@ -509,7 +509,6 @@ private: private: static constexpr TypedStorage<Derived> DerivedStorage = {}; - static_assert(GetParent(GetNode(GetPointer(DerivedStorage))) == GetPointer(DerivedStorage)); }; template <auto T, class Derived = impl::GetParentType<T>> diff --git a/src/common/parent_of_member.h b/src/common/parent_of_member.h index d9a14529d..58c70b0e7 100644 --- a/src/common/parent_of_member.h +++ b/src/common/parent_of_member.h @@ -109,7 +109,8 @@ struct OffsetOfCalculator { } } - return (next - start) * sizeof(MemberType) + Offset; + return static_cast<ptrdiff_t>(static_cast<size_t>(next - start) * sizeof(MemberType) + + Offset); } static constexpr std::ptrdiff_t OffsetOf(MemberType ParentType::*member) { @@ -133,27 +134,27 @@ template <auto MemberPtr> using GetMemberType = typename GetMemberPointerTraits<decltype(MemberPtr)>::Member; template <auto MemberPtr, typename RealParentType = GetParentType<MemberPtr>> -static inline std::ptrdiff_t OffsetOf = [] { +constexpr std::ptrdiff_t OffsetOf() { using DeducedParentType = GetParentType<MemberPtr>; using MemberType = GetMemberType<MemberPtr>; static_assert(std::is_base_of<DeducedParentType, RealParentType>::value || std::is_same<RealParentType, DeducedParentType>::value); return OffsetOfCalculator<RealParentType, MemberType>::OffsetOf(MemberPtr); -}(); +}; } // namespace impl template <auto MemberPtr, typename RealParentType = impl::GetParentType<MemberPtr>> constexpr RealParentType& GetParentReference(impl::GetMemberType<MemberPtr>* member) { - std::ptrdiff_t Offset = impl::OffsetOf<MemberPtr, RealParentType>; + std::ptrdiff_t Offset = impl::OffsetOf<MemberPtr, RealParentType>(); return *static_cast<RealParentType*>( static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(member)) - Offset)); } template <auto MemberPtr, typename RealParentType = impl::GetParentType<MemberPtr>> constexpr RealParentType const& GetParentReference(impl::GetMemberType<MemberPtr> const* member) { - std::ptrdiff_t Offset = impl::OffsetOf<MemberPtr, RealParentType>; + std::ptrdiff_t Offset = impl::OffsetOf<MemberPtr, RealParentType>(); return *static_cast<const RealParentType*>(static_cast<const void*>( static_cast<const uint8_t*>(static_cast<const void*>(member)) - Offset)); } diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 702b6598d..e29cbf506 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -42,7 +42,7 @@ void LogSettings() { log_setting("System_RegionIndex", values.region_index.GetValue()); log_setting("System_TimeZoneIndex", values.time_zone_index.GetValue()); log_setting("Core_UseMultiCore", values.use_multi_core.GetValue()); - log_setting("CPU_Accuracy", values.cpu_accuracy); + log_setting("CPU_Accuracy", values.cpu_accuracy.GetValue()); log_setting("Renderer_UseResolutionFactor", values.resolution_factor.GetValue()); log_setting("Renderer_UseFrameLimit", values.use_frame_limit.GetValue()); log_setting("Renderer_FrameLimit", values.frame_limit.GetValue()); @@ -106,6 +106,12 @@ void RestoreGlobalState(bool is_powered_on) { // Core values.use_multi_core.SetGlobal(true); + // CPU + values.cpu_accuracy.SetGlobal(true); + values.cpuopt_unsafe_unfuse_fma.SetGlobal(true); + values.cpuopt_unsafe_reduce_fp_error.SetGlobal(true); + values.cpuopt_unsafe_inaccurate_nan.SetGlobal(true); + // Renderer values.renderer_backend.SetGlobal(true); values.vulkan_device.SetGlobal(true); @@ -130,7 +136,6 @@ void RestoreGlobalState(bool is_powered_on) { values.region_index.SetGlobal(true); values.time_zone_index.SetGlobal(true); values.rng_seed.SetGlobal(true); - values.custom_rtc.SetGlobal(true); values.sound_index.SetGlobal(true); // Controls diff --git a/src/common/settings.h b/src/common/settings.h index d39b4aa45..48085b9a9 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -115,7 +115,7 @@ struct Values { Setting<bool> use_multi_core; // Cpu - CPUAccuracy cpu_accuracy; + Setting<CPUAccuracy> cpu_accuracy; bool cpuopt_page_tables; bool cpuopt_block_linking; @@ -126,9 +126,9 @@ struct Values { bool cpuopt_misc_ir; bool cpuopt_reduce_misalign_checks; - bool cpuopt_unsafe_unfuse_fma; - bool cpuopt_unsafe_reduce_fp_error; - bool cpuopt_unsafe_inaccurate_nan; + Setting<bool> cpuopt_unsafe_unfuse_fma; + Setting<bool> cpuopt_unsafe_reduce_fp_error; + Setting<bool> cpuopt_unsafe_inaccurate_nan; // Renderer Setting<RendererBackend> renderer_backend; @@ -157,7 +157,7 @@ struct Values { // System Setting<std::optional<u32>> rng_seed; // Measured in seconds since epoch - Setting<std::optional<std::chrono::seconds>> custom_rtc; + std::optional<std::chrono::seconds> custom_rtc; // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` std::chrono::seconds custom_rtc_differential; diff --git a/src/common/tree.h b/src/common/tree.h index 3da49e422..9d2d0df4e 100644 --- a/src/common/tree.h +++ b/src/common/tree.h @@ -322,7 +322,7 @@ void RB_INSERT_COLOR(RBHead<Node>* head, Node* elm) { template <typename Node> void RB_REMOVE_COLOR(RBHead<Node>* head, Node* parent, Node* elm) { Node* tmp; - while ((elm == nullptr || RB_IS_BLACK(elm)) && elm != head->Root()) { + while ((elm == nullptr || RB_IS_BLACK(elm)) && elm != head->Root() && parent != nullptr) { if (RB_LEFT(parent) == elm) { tmp = RB_RIGHT(parent); if (RB_IS_RED(tmp)) { |