diff options
Diffstat (limited to '')
-rw-r--r-- | src/common/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/common/assert.cpp | 14 | ||||
-rw-r--r-- | src/common/assert.h | 14 | ||||
-rw-r--r-- | src/common/common_sizes.h | 43 | ||||
-rw-r--r-- | src/common/logging/backend.cpp | 28 | ||||
-rw-r--r-- | src/common/logging/backend.h | 4 | ||||
-rw-r--r-- | src/common/logging/filter.cpp | 4 | ||||
-rw-r--r-- | src/common/logging/filter.h | 4 | ||||
-rw-r--r-- | src/common/logging/log.h | 35 | ||||
-rw-r--r-- | src/common/logging/text_formatter.cpp | 4 | ||||
-rw-r--r-- | src/common/logging/text_formatter.h | 4 | ||||
-rw-r--r-- | src/common/nvidia_flags.h | 2 | ||||
-rw-r--r-- | src/common/settings.cpp (renamed from src/core/settings.cpp) | 15 | ||||
-rw-r--r-- | src/common/settings.h (renamed from src/core/settings.h) | 17 | ||||
-rw-r--r-- | src/common/settings_input.cpp (renamed from src/input_common/settings.cpp) | 2 | ||||
-rw-r--r-- | src/common/settings_input.h (renamed from src/input_common/settings.h) | 1 | ||||
-rw-r--r-- | src/common/threadsafe_queue.h | 10 |
17 files changed, 141 insertions, 66 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 788516ded..88644eeb6 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -97,6 +97,7 @@ add_custom_command(OUTPUT scm_rev.cpp add_library(common STATIC algorithm.h alignment.h + assert.cpp assert.h atomic_ops.h detached_tasks.cpp @@ -109,6 +110,7 @@ add_library(common STATIC cityhash.h common_funcs.h common_paths.h + common_sizes.h common_types.h concepts.h div_ceil.h @@ -150,6 +152,10 @@ add_library(common STATIC scm_rev.cpp scm_rev.h scope_exit.h + settings.cpp + settings.h + settings_input.cpp + settings_input.h spin_lock.cpp spin_lock.h stream.cpp diff --git a/src/common/assert.cpp b/src/common/assert.cpp new file mode 100644 index 000000000..72f1121aa --- /dev/null +++ b/src/common/assert.cpp @@ -0,0 +1,14 @@ +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "common/assert.h" +#include "common/common_funcs.h" + +#include "common/settings.h" + +void assert_handle_failure() { + if (Settings::values.use_debug_asserts) { + Crash(); + } +} diff --git a/src/common/assert.h b/src/common/assert.h index 06d7b5612..b3ba35c0f 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -4,10 +4,13 @@ #pragma once -#include <cstdlib> -#include "common/common_funcs.h" #include "common/logging/log.h" +// Sometimes we want to try to continue even after hitting an assert. +// However touching this file yields a global recompilation as this header is included almost +// everywhere. So let's just move the handling of the failed assert to a single cpp file. +void assert_handle_failure(); + // For asserts we'd like to keep all the junk executed when an assert happens away from the // important code in the function. One way of doing this is to put all the relevant code inside a // lambda and force the compiler to not inline it. Unfortunately, MSVC seems to have no syntax to @@ -17,15 +20,14 @@ // enough for our purposes. template <typename Fn> #if defined(_MSC_VER) -[[msvc::noinline, noreturn]] +[[msvc::noinline]] #elif defined(__GNUC__) -[[gnu::cold, gnu::noinline, noreturn]] +[[gnu::cold, gnu::noinline]] #endif static void assert_noinline_call(const Fn& fn) { fn(); - Crash(); - exit(1); // Keeps GCC's mouth shut about this actually returning + assert_handle_failure(); } #define ASSERT(_a_) \ diff --git a/src/common/common_sizes.h b/src/common/common_sizes.h new file mode 100644 index 000000000..7e9fd968b --- /dev/null +++ b/src/common/common_sizes.h @@ -0,0 +1,43 @@ +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <limits> + +#include "common/common_types.h" + +namespace Common { + +enum : u64 { + Size_1_KB = 0x400ULL, + Size_64_KB = 64ULL * Size_1_KB, + Size_128_KB = 128ULL * Size_1_KB, + Size_1_MB = 0x100000ULL, + Size_2_MB = 2ULL * Size_1_MB, + Size_4_MB = 4ULL * Size_1_MB, + Size_5_MB = 5ULL * Size_1_MB, + Size_14_MB = 14ULL * Size_1_MB, + Size_32_MB = 32ULL * Size_1_MB, + Size_33_MB = 33ULL * Size_1_MB, + Size_128_MB = 128ULL * Size_1_MB, + Size_448_MB = 448ULL * Size_1_MB, + Size_507_MB = 507ULL * Size_1_MB, + Size_562_MB = 562ULL * Size_1_MB, + Size_1554_MB = 1554ULL * Size_1_MB, + Size_2048_MB = 2048ULL * Size_1_MB, + Size_2193_MB = 2193ULL * Size_1_MB, + Size_3285_MB = 3285ULL * Size_1_MB, + Size_4916_MB = 4916ULL * Size_1_MB, + Size_1_GB = 0x40000000ULL, + Size_2_GB = 2ULL * Size_1_GB, + Size_4_GB = 4ULL * Size_1_GB, + Size_6_GB = 6ULL * Size_1_GB, + Size_8_GB = 8ULL * Size_1_GB, + Size_64_GB = 64ULL * Size_1_GB, + Size_512_GB = 512ULL * Size_1_GB, + Size_Invalid = std::numeric_limits<u64>::max(), +}; + +} // namespace Common diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 2d4d2e9e7..bc82905c0 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -21,11 +21,11 @@ #include "common/logging/backend.h" #include "common/logging/log.h" #include "common/logging/text_formatter.h" +#include "common/settings.h" #include "common/string_util.h" #include "common/threadsafe_queue.h" -#include "core/settings.h" -namespace Log { +namespace Common::Log { /** * Static state as a singleton. @@ -37,8 +37,11 @@ public: return backend; } - Impl(Impl const&) = delete; - const Impl& operator=(Impl const&) = delete; + Impl(const Impl&) = delete; + Impl& operator=(const Impl&) = delete; + + Impl(Impl&&) = delete; + Impl& operator=(Impl&&) = delete; void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num, const char* function, std::string message) { @@ -132,7 +135,7 @@ private: std::mutex writing_mutex; std::thread backend_thread; std::vector<std::unique_ptr<Backend>> backends; - Common::MPSCQueue<Log::Entry> message_queue; + MPSCQueue<Entry> message_queue; Filter filter; std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()}; }; @@ -146,16 +149,16 @@ void ColorConsoleBackend::Write(const Entry& entry) { } FileBackend::FileBackend(const std::string& filename) : bytes_written(0) { - if (Common::FS::Exists(filename + ".old.txt")) { - Common::FS::Delete(filename + ".old.txt"); + if (FS::Exists(filename + ".old.txt")) { + FS::Delete(filename + ".old.txt"); } - if (Common::FS::Exists(filename)) { - Common::FS::Rename(filename, filename + ".old.txt"); + if (FS::Exists(filename)) { + FS::Rename(filename, filename + ".old.txt"); } // _SH_DENYWR allows read only access to the file for other programs. // It is #defined to 0 on other platforms - file = Common::FS::IOFile(filename, "w", _SH_DENYWR); + file = FS::IOFile(filename, "w", _SH_DENYWR); } void FileBackend::Write(const Entry& entry) { @@ -182,7 +185,7 @@ void FileBackend::Write(const Entry& entry) { void DebuggerBackend::Write(const Entry& entry) { #ifdef _WIN32 - ::OutputDebugStringW(Common::UTF8ToUTF16W(FormatLogMessage(entry).append(1, '\n')).c_str()); + ::OutputDebugStringW(UTF8ToUTF16W(FormatLogMessage(entry).append(1, '\n')).c_str()); #endif } @@ -212,6 +215,7 @@ void DebuggerBackend::Write(const Entry& entry) { SUB(Service, ARP) \ SUB(Service, BCAT) \ SUB(Service, BPC) \ + SUB(Service, BGTC) \ SUB(Service, BTDRV) \ SUB(Service, BTM) \ SUB(Service, Capture) \ @@ -341,4 +345,4 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, instance.PushEntry(log_class, log_level, filename, line_num, function, fmt::vformat(format, args)); } -} // namespace Log +} // namespace Common::Log diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h index da1c2f185..84a544ea4 100644 --- a/src/common/logging/backend.h +++ b/src/common/logging/backend.h @@ -11,7 +11,7 @@ #include "common/logging/filter.h" #include "common/logging/log.h" -namespace Log { +namespace Common::Log { class Filter; @@ -135,4 +135,4 @@ const char* GetLevelName(Level log_level); * never get the message */ void SetGlobalFilter(const Filter& filter); -} // namespace Log
\ No newline at end of file +} // namespace Common::Log
\ No newline at end of file diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index 2eccbcd8d..20a2dd106 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -7,7 +7,7 @@ #include "common/logging/filter.h" #include "common/string_util.h" -namespace Log { +namespace Common::Log { namespace { template <typename It> Level GetLevelByName(const It begin, const It end) { @@ -103,4 +103,4 @@ bool Filter::IsDebug() const { }); } -} // namespace Log +} // namespace Common::Log diff --git a/src/common/logging/filter.h b/src/common/logging/filter.h index 773df6f2c..f5673a9f6 100644 --- a/src/common/logging/filter.h +++ b/src/common/logging/filter.h @@ -9,7 +9,7 @@ #include <string_view> #include "common/logging/log.h" -namespace Log { +namespace Common::Log { /** * Implements a log message filter which allows different log classes to have different minimum @@ -51,4 +51,4 @@ public: private: std::array<Level, static_cast<std::size_t>(Class::Count)> class_levels; }; -} // namespace Log +} // namespace Common::Log diff --git a/src/common/logging/log.h b/src/common/logging/log.h index 835894918..1f0f8db52 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -7,7 +7,7 @@ #include <fmt/format.h> #include "common/common_types.h" -namespace Log { +namespace Common::Log { // trims up to and including the last of ../, ..\, src/, src\ in a string constexpr const char* TrimSourcePath(std::string_view source) { @@ -66,6 +66,7 @@ enum class Class : ClassType { Service_ARP, ///< The ARP service Service_Audio, ///< The Audio (Audio control) service Service_BCAT, ///< The BCAT service + Service_BGTC, ///< The BGTC (Background Task Controller) service Service_BPC, ///< The BPC service Service_BTDRV, ///< The Bluetooth driver service Service_BTM, ///< The BTM service @@ -147,28 +148,34 @@ void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsig fmt::make_format_args(args...)); } -} // namespace Log +} // namespace Common::Log #ifdef _DEBUG #define LOG_TRACE(log_class, ...) \ - ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Trace, \ - ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Trace, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) #else #define LOG_TRACE(log_class, fmt, ...) (void(0)) #endif #define LOG_DEBUG(log_class, ...) \ - ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Debug, \ - ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Debug, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) #define LOG_INFO(log_class, ...) \ - ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Info, \ - ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Info, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) #define LOG_WARNING(log_class, ...) \ - ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Warning, \ - ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Warning, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) #define LOG_ERROR(log_class, ...) \ - ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Error, \ - ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Error, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) #define LOG_CRITICAL(log_class, ...) \ - ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Critical, \ - ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Critical, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp index 6a0605c63..80ee2cca1 100644 --- a/src/common/logging/text_formatter.cpp +++ b/src/common/logging/text_formatter.cpp @@ -16,7 +16,7 @@ #include "common/logging/text_formatter.h" #include "common/string_util.h" -namespace Log { +namespace Common::Log { std::string FormatLogMessage(const Entry& entry) { unsigned int time_seconds = static_cast<unsigned int>(entry.timestamp.count() / 1000000); @@ -108,4 +108,4 @@ void PrintColoredMessage(const Entry& entry) { #undef ESC #endif } -} // namespace Log +} // namespace Common::Log diff --git a/src/common/logging/text_formatter.h b/src/common/logging/text_formatter.h index b6d9e57c8..171e74cfe 100644 --- a/src/common/logging/text_formatter.h +++ b/src/common/logging/text_formatter.h @@ -7,7 +7,7 @@ #include <cstddef> #include <string> -namespace Log { +namespace Common::Log { struct Entry; @@ -17,4 +17,4 @@ std::string FormatLogMessage(const Entry& entry); void PrintMessage(const Entry& entry); /// Prints the same message as `PrintMessage`, but colored according to the severity level. void PrintColoredMessage(const Entry& entry); -} // namespace Log +} // namespace Common::Log diff --git a/src/common/nvidia_flags.h b/src/common/nvidia_flags.h index 75a0233ac..8930efcec 100644 --- a/src/common/nvidia_flags.h +++ b/src/common/nvidia_flags.h @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#pragma once + namespace Common { /// Configure platform specific flags for Nvidia's driver diff --git a/src/core/settings.cpp b/src/common/settings.cpp index 2ae5196e0..702b6598d 100644 --- a/src/core/settings.cpp +++ b/src/common/settings.cpp @@ -1,4 +1,4 @@ -// Copyright 2014 Citra Emulator Project +// Copyright 2021 yuzu Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -7,10 +7,7 @@ #include "common/assert.h" #include "common/file_util.h" #include "common/logging/log.h" -#include "core/core.h" -#include "core/hle/service/hid/hid.h" -#include "core/settings.h" -#include "video_core/renderer_base.h" +#include "common/settings.h" namespace Settings { @@ -32,14 +29,6 @@ std::string GetTimeZoneString() { return timezones[time_zone_index]; } -void Apply(Core::System& system) { - if (system.IsPoweredOn()) { - system.Renderer().RefreshBaseSettings(); - } - - Service::HID::ReloadInputDevices(); -} - void LogSettings() { const auto log_setting = [](std::string_view name, const auto& value) { LOG_INFO(Config, "{}: {}", name, value); diff --git a/src/core/settings.h b/src/common/settings.h index d849dded3..d39b4aa45 100644 --- a/src/core/settings.h +++ b/src/common/settings.h @@ -1,4 +1,4 @@ -// Copyright 2014 Citra Emulator Project +// Copyright 2021 yuzu Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -11,16 +11,13 @@ #include <optional> #include <string> #include <vector> -#include "common/common_types.h" -#include "input_common/settings.h" -namespace Core { -class System; -} +#include "common/common_types.h" +#include "common/settings_input.h" namespace Settings { -enum class RendererBackend { +enum class RendererBackend : u32 { OpenGL = 0, Vulkan = 1, }; @@ -31,7 +28,7 @@ enum class GPUAccuracy : u32 { Extreme = 2, }; -enum class CPUAccuracy { +enum class CPUAccuracy : u32 { Accurate = 0, Unsafe = 1, DebugMode = 2, @@ -139,6 +136,7 @@ struct Values { Setting<int> vulkan_device; Setting<u16> resolution_factor{1}; + Setting<int> fullscreen_mode; Setting<int> aspect_ratio; Setting<int> max_anisotropy; Setting<bool> use_frame_limit; @@ -222,6 +220,8 @@ struct Values { bool quest_flag; bool disable_macro_jit; bool extended_logging; + bool use_debug_asserts; + bool use_auto_stub; // Miscellaneous std::string log_filter; @@ -253,7 +253,6 @@ float Volume(); std::string GetTimeZoneString(); -void Apply(Core::System& system); void LogSettings(); // Restore the global state of all applicable settings in the Values struct diff --git a/src/input_common/settings.cpp b/src/common/settings_input.cpp index 557e7a9a0..bea2b837b 100644 --- a/src/input_common/settings.cpp +++ b/src/common/settings_input.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "input_common/settings.h" +#include "common/settings_input.h" namespace Settings { namespace NativeButton { diff --git a/src/input_common/settings.h b/src/common/settings_input.h index a59f5d461..609600582 100644 --- a/src/input_common/settings.h +++ b/src/common/settings_input.h @@ -6,6 +6,7 @@ #include <array> #include <string> + #include "common/common_types.h" namespace Settings { diff --git a/src/common/threadsafe_queue.h b/src/common/threadsafe_queue.h index a4647314a..ad04df8ca 100644 --- a/src/common/threadsafe_queue.h +++ b/src/common/threadsafe_queue.h @@ -83,11 +83,15 @@ public: return true; } - T PopWait() { + void Wait() { if (Empty()) { std::unique_lock lock{cv_mutex}; cv.wait(lock, [this]() { return !Empty(); }); } + } + + T PopWait() { + Wait(); T t; Pop(t); return t; @@ -156,6 +160,10 @@ public: return spsc_queue.Pop(t); } + void Wait() { + spsc_queue.Wait(); + } + T PopWait() { return spsc_queue.PopWait(); } |