diff --git a/Utilities/BEType.h b/Utilities/BEType.h index 4476106a3a..56b8ba30ad 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -298,10 +298,6 @@ union alignas(16) v128 _u64[0] = 0; _u64[1] = 0; } - - std::string to_hex() const; - - std::string to_xyzw() const; }; inline v128 operator |(const v128& left, const v128& right) @@ -950,11 +946,13 @@ template using atomic_le_t = atomic_t>; // Formatting for BE/LE data template -struct unveil, void> +struct fmt_unveil, void> { - static inline auto get(const se_t& arg) + using type = typename fmt_unveil::type; + + static inline u64 get(const se_t& arg) { - return unveil::get(arg); + return fmt_unveil::get(arg); } }; diff --git a/Utilities/BitField.h b/Utilities/BitField.h index ef03e0ab8a..9a0d096cb1 100644 --- a/Utilities/BitField.h +++ b/Utilities/BitField.h @@ -242,3 +242,36 @@ struct ff_t : bf_base return V; } }; + +template +struct fmt_unveil, void> +{ + using type = typename fmt_unveil>::type; + + static inline u64 get(const bf_t& bf) + { + return fmt_unveil::get(bf); + } +}; + +template +struct fmt_unveil, void> +{ + using type = typename fmt_unveil>::type; + + static inline u64 get(const cf_t& cf) + { + return fmt_unveil::get(cf); + } +}; + +template +struct fmt_unveil, void> +{ + using type = typename fmt_unveil>::type; + + static inline u64 get(const ff_t& ff) + { + return fmt_unveil::get(ff); + } +}; diff --git a/Utilities/BitSet.h b/Utilities/BitSet.h index 40356be5c0..0e207f0b40 100644 --- a/Utilities/BitSet.h +++ b/Utilities/BitSet.h @@ -256,3 +256,14 @@ struct atomic_test_and_complement, T, std::enable_if_t +struct fmt_unveil, void> +{ + using type = typename bitset_t::raw_type; + + static inline u64 get(const bitset_t& value) + { + return fmt_unveil::get(static_cast(value._value())); + } +}; diff --git a/Utilities/Config.cpp b/Utilities/Config.cpp index 32330188ee..dd84f8dff6 100644 --- a/Utilities/Config.cpp +++ b/Utilities/Config.cpp @@ -85,6 +85,62 @@ bool cfg::try_to_int64(s64* out, const std::string& value, s64 min, s64 max) return true; } +bool cfg::try_to_enum_value(u64* out, decltype(&fmt_class_string::format) func, const std::string& value) +{ + for (u64 i = 0;; i++) + { + std::string var; + func(var, i); + + if (var == value) + { + if (out) *out = i; + return true; + } + + std::string hex; + fmt_class_string::format(hex, i); + if (var == hex) + { + break; + } + } + + try + { + const auto val = std::stoull(value, nullptr, 0); + + if (out) *out = val; + return true; + } + catch (...) + { + return false; + } +} + +std::vector cfg::try_to_enum_list(decltype(&fmt_class_string::format) func) +{ + std::vector result; + + for (u64 i = 0;; i++) + { + std::string var; + func(var, i); + + std::string hex; + fmt_class_string::format(hex, i); + if (var == hex) + { + break; + } + + result.emplace_back(std::move(var)); + } + + return result; +} + void cfg::encode(YAML::Emitter& out, const cfg::entry_base& rhs) { switch (rhs.get_type()) diff --git a/Utilities/Config.h b/Utilities/Config.h index 2463321e7c..ec3cb118fc 100644 --- a/Utilities/Config.h +++ b/Utilities/Config.h @@ -2,6 +2,7 @@ #include "Utilities/types.h" #include "Utilities/Atomic.h" +#include "Utilities/StrFmt.h" #include #include @@ -18,6 +19,12 @@ namespace cfg // Convert string to signed integer bool try_to_int64(s64* out, const std::string& value, s64 min, s64 max); + // Internal hack + bool try_to_enum_value(u64* out, decltype(&fmt_class_string::format) func, const std::string&); + + // Internal hack + std::vector try_to_enum_list(decltype(&fmt_class_string::format) func); + // Config tree entry type. enum class type : uint { @@ -296,26 +303,26 @@ namespace cfg std::string to_string() const override { - for (std::size_t i = 0; i < sizeof(bijective::map) / sizeof(bijective_pair); i++) - { - if (bijective::map[i].v1 == m_value) - { - return bijective::map[i].v2; - } - } - - return{}; // TODO: ??? + std::string result; + fmt_class_string::format(result, fmt_unveil::get(m_value)); + return result; // TODO: ??? } bool from_string(const std::string& value) override { - for (std::size_t i = 0; i < sizeof(bijective::map) / sizeof(bijective_pair); i++) + u64 result; + + if (try_to_enum_value(&result, &fmt_class_string::format, value)) { - if (bijective::map[i].v2 == value) + const auto val = static_cast>(result); + + if (static_cast(val) != result) { - m_value = bijective::map[i].v1; - return true; + return false; } + + m_value = static_cast(val); + return true; } return false; @@ -323,14 +330,7 @@ namespace cfg std::vector to_list() const override { - std::vector result; - - for (std::size_t i = 0; i < sizeof(bijective::map) / sizeof(bijective_pair); i++) - { - result.emplace_back(bijective::map[i].v2); - } - - return result; + return try_to_enum_list(&fmt_class_string::format); } }; diff --git a/Utilities/File.cpp b/Utilities/File.cpp index e41d1a0c43..0ecac5b390 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -1333,3 +1333,37 @@ u64 fs::get_dir_size(const std::string& path) return result; } + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto arg) + { + switch (arg) + { + STR_CASE(fs::seek_mode::seek_set); + STR_CASE(fs::seek_mode::seek_cur); + STR_CASE(fs::seek_mode::seek_end); + } + + return unknown; + }); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto arg) + { + switch (arg) + { + case fs::error::ok: return "OK"; + + case fs::error::inval: return "Invalid arguments"; + case fs::error::noent: return "Not found"; + case fs::error::exist: return "Already exists"; + } + + return unknown; + }); +} diff --git a/Utilities/File.h b/Utilities/File.h index 0f86a810e7..25ebe364b2 100644 --- a/Utilities/File.h +++ b/Utilities/File.h @@ -463,21 +463,3 @@ namespace fs // Error code returned extern thread_local error g_tls_error; } - -template<> -struct unveil -{ - static inline const char* get(fs::error error) - { - switch (error) - { - case fs::error::ok: return "OK"; - - case fs::error::inval: return "Invalid arguments"; - case fs::error::noent: return "Not found"; - case fs::error::exist: return "Already exists"; - - default: throw error; - } - } -}; diff --git a/Utilities/Log.cpp b/Utilities/Log.cpp index b1f7faaae1..62a5b5a293 100644 --- a/Utilities/Log.cpp +++ b/Utilities/Log.cpp @@ -3,15 +3,31 @@ #include "StrFmt.h" #include "rpcs3_version.h" -#include #include // Thread-specific log prefix provider thread_local std::string(*g_tls_log_prefix)() = nullptr; -#ifndef _MSC_VER -constexpr DECLARE(bijective::map); -#endif +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto lev) + { + switch (lev) + { + case logs::level::always: return "Nothing"; + case logs::level::fatal: return "Fatal"; + case logs::level::error: return "Error"; + case logs::level::todo: return "TODO"; + case logs::level::success: return "Success"; + case logs::level::warning: return "Warning"; + case logs::level::notice: return "Notice"; + case logs::level::trace: return "Trace"; + } + + return unknown; + }); +} namespace logs { @@ -72,13 +88,10 @@ void logs::listener::add(logs::listener* _new) } } -void logs::channel::broadcast(const logs::channel& ch, logs::level sev, const char* fmt...) +void logs::channel::broadcast(const logs::channel& ch, logs::level sev, const char* fmt, const fmt::supplementary_info* sup, const u64* args) { - va_list args; - va_start(args, fmt); - std::string&& text = fmt::unsafe_vformat(fmt, args); - std::string&& prefix = g_tls_log_prefix ? g_tls_log_prefix() : ""; - va_end(args); + std::string text; fmt::raw_append(text, fmt, sup, args); + std::string prefix(g_tls_log_prefix ? g_tls_log_prefix() : ""); // Prepare message information message msg; diff --git a/Utilities/Log.h b/Utilities/Log.h index 1bc78e8f1d..b3ad9501e4 100644 --- a/Utilities/Log.h +++ b/Utilities/Log.h @@ -1,7 +1,9 @@ #pragma once #include "types.h" +#include "Platform.h" #include "Atomic.h" +#include "StrFmt.h" namespace logs { @@ -67,19 +69,17 @@ namespace logs // Formatting function template - void format(level sev, const char* fmt, const Args&... args) const + SAFE_BUFFERS void format(level sev, const char* fmt, const Args&... args) const { -#ifdef _MSC_VER - if (sev <= enabled) -#else - if (__builtin_expect(sev <= enabled, 0)) -#endif - broadcast(*this, sev, fmt, ::unveil::get(args)...); + if (UNLIKELY(sev <= enabled)) + { + broadcast(*this, sev, fmt, fmt::arg_type_info::get::type...>(), fmt::args_t{::fmt_unveil::get(args)...}); + } } #define GEN_LOG_METHOD(_sev)\ template\ - void _sev(const char* fmt, const Args&... args) const\ + SAFE_BUFFERS void _sev(const char* fmt, const Args&... args) const\ {\ return format(level::_sev, fmt, args...);\ } @@ -95,7 +95,7 @@ namespace logs #undef GEN_LOG_METHOD private: // Send log message to global logger instance - static void broadcast(const channel& ch, level sev, const char* fmt...); + static void broadcast(const channel& ch, level sev, const char*, const fmt::supplementary_info*, const u64*); }; /* Small set of predefined channels */ @@ -110,22 +110,6 @@ namespace logs extern channel ARMv7; } -template<> -struct bijective -{ - static constexpr bijective_pair map[] - { - { logs::level::always, "Nothing" }, - { logs::level::fatal, "Fatal" }, - { logs::level::error, "Error" }, - { logs::level::todo, "TODO" }, - { logs::level::success, "Success" }, - { logs::level::warning, "Warning" }, - { logs::level::notice, "Notice" }, - { logs::level::trace, "Trace" }, - }; -}; - // Legacy: #define LOG_SUCCESS(ch, fmt, ...) logs::ch.success(fmt, ##__VA_ARGS__) diff --git a/Utilities/MTProgressDialog.h b/Utilities/MTProgressDialog.h index 9942ffb7df..60002aac86 100644 --- a/Utilities/MTProgressDialog.h +++ b/Utilities/MTProgressDialog.h @@ -61,7 +61,7 @@ public: Show(); } - force_inline void Update(const u8 thread_id, const u64 value, const wxString& msg) + void Update(const u8 thread_id, const u64 value, const wxString& msg) { if(thread_id > m_cores) return; diff --git a/Utilities/Platform.h b/Utilities/Platform.h index c554c07dea..a1cfa7a544 100644 --- a/Utilities/Platform.h +++ b/Utilities/Platform.h @@ -29,15 +29,21 @@ #endif #ifdef _MSC_VER -#define never_inline __declspec(noinline) +#define SAFE_BUFFERS __declspec(safebuffers) #else -#define never_inline __attribute__((noinline)) +#define SAFE_BUFFERS #endif #ifdef _MSC_VER -#define force_inline __forceinline +#define NEVER_INLINE __declspec(noinline) #else -#define force_inline __attribute__((always_inline)) inline +#define NEVER_INLINE __attribute__((noinline)) +#endif + +#ifdef _MSC_VER +#define FORCE_INLINE __forceinline +#else +#define FORCE_INLINE __attribute__((always_inline)) inline #endif #if defined(__GNUG__) diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index 274ca09f19..4d01f2eabf 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -1,73 +1,178 @@ #include "StrFmt.h" #include "BEType.h" #include "StrUtil.h" +#include "cfmt.h" -#include -#include -#include #include -std::string v128::to_hex() const +void fmt_class_string::format(std::string& out, u64 arg) { - return fmt::format("%016llx%016llx", _u64[1], _u64[0]); + fmt::append(out, "%p", reinterpret_cast(static_cast(arg))); } -std::string v128::to_xyzw() const +void fmt_class_string::format(std::string& out, u64 arg) { - return fmt::format("x: %g y: %g z: %g w: %g", _f[3], _f[2], _f[1], _f[0]); + out += reinterpret_cast(static_cast(arg)); } -std::string fmt::unsafe_vformat(const char* fmt, va_list _args) noexcept +template<> +void fmt_class_string::format(std::string& out, u64 arg) { - // Fixed stack buffer for the first attempt - std::array fixed_buf; + out += get_object(arg).c_str(); // TODO? +} - // Possibly dynamically allocated buffer for the second attempt - std::unique_ptr buf; +template<> +void fmt_class_string>::format(std::string& out, u64 arg) +{ + const std::vector& obj = get_object(arg); + out.append(obj.cbegin(), obj.cend()); +} - // Pointer to the current buffer - char* buf_addr = fixed_buf.data(); +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + fmt::append(out, "0x%hhx", static_cast(arg)); +} - for (std::size_t buf_size = fixed_buf.size();;) +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + fmt::append(out, "0x%hhx", static_cast(arg)); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + fmt::append(out, "0x%hhx", static_cast(arg)); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + fmt::append(out, "0x%hx", static_cast(arg)); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + fmt::append(out, "0x%hx", static_cast(arg)); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + fmt::append(out, "0x%x", static_cast(arg)); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + fmt::append(out, "0x%x", static_cast(arg)); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + fmt::append(out, "0x%lx", static_cast(arg)); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + fmt::append(out, "0x%lx", static_cast(arg)); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + fmt::append(out, "0x%llx", static_cast(arg)); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + fmt::append(out, "0x%llx", static_cast(arg)); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + fmt::append(out, "%f", static_cast(reinterpret_cast(arg))); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + fmt::append(out, "%f", reinterpret_cast(arg)); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + out += arg ? "true" : "false"; // TODO? +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + const v128& vec = get_object(arg); + fmt::append(out, "0x%016llx%016llx", vec._u64[1], vec._u64[0]); +} + +namespace fmt +{ + struct cfmt_src; +} + +// Temporary implementation +struct fmt::cfmt_src +{ + const fmt::supplementary_info* sup; + const u64* args; + + bool test(std::size_t index = 0) { - va_list args; - va_copy(args, _args); - -#ifndef _MSC_VER -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-security" -#endif - const std::size_t len = std::vsnprintf(buf_addr, buf_size, fmt, args); -#ifndef _MSC_VER -#pragma GCC diagnostic pop -#endif - va_end(args); - - assert(len <= INT_MAX); - - if (len < buf_size) + for (std::size_t i = 0; i <= index; i++) { - return{ buf_addr, len }; + if (!sup[i].fmt_string) + { + return false; + } } - buf.reset(buf_addr = new char[buf_size = len + 1]); + return true; } + + template + T get(std::size_t index = 0) + { + return reinterpret_cast(args[index]); + } + + void skip(std::size_t extra) + { + ++sup += extra; + ++args += extra; + } + + std::size_t fmt_string(std::string& out) + { + const std::size_t start = out.size(); + sup->fmt_string(out, args[0]); + return out.size() - start; + } +}; + +void fmt::raw_append(std::string& out, const char* fmt, const fmt::supplementary_info* sup, const u64* args) noexcept +{ + cfmt_append(out, fmt, cfmt_src{sup, args}); } -std::string fmt::unsafe_format(const char* fmt...) noexcept +char* fmt::alloc_format(const char* fmt, const fmt::supplementary_info* sup, const u64* args) noexcept { - va_list args; - va_start(args, fmt); - auto result = unsafe_vformat(fmt, args); - va_end(args); - - return result; -} - -fmt::exception_base::exception_base(const char* fmt...) - : std::runtime_error((va_start(m_args, fmt), unsafe_vformat(fmt, m_args))) -{ - va_end(m_args); + std::string str; + raw_append(str, fmt, sup, args); + return static_cast(std::memcpy(std::malloc(str.size() + 1), str.data(), str.size() + 1)); } std::string fmt::replace_first(const std::string& src, const std::string& from, const std::string& to) diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 124222b799..85e9ec37ce 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include @@ -9,44 +8,224 @@ namespace fmt { - std::string unsafe_format(const char* fmt...) noexcept; - std::string unsafe_vformat(const char*, va_list) noexcept; - - // Formatting function template - inline std::string format(const char* fmt, const Args&... args) + static std::string format(const char*, const Args&...); +} + +template +struct fmt_unveil +{ + static_assert(sizeof(T) > 0, "fmt_unveil<>: cannot pass forward-declared object"); + + using type = T; + + static inline u64 get(const T& arg) { - return unsafe_format(fmt, ::unveil::get(args)...); + return reinterpret_cast(&arg); + } +}; + +template +struct fmt_unveil::value && sizeof(T) <= 8 && alignof(T) <= 8>> +{ + using type = T; + + static inline u64 get(T arg) + { + return static_cast(arg); + } +}; + +template +struct fmt_unveil::value && sizeof(T) <= 8 && alignof(T) <= 8>> +{ + using type = T; + + // Convert FP to f64 and reinterpret (TODO?) + static inline u64 get(f64 arg) + { + return reinterpret_cast(arg); + } +}; + +template +struct fmt_unveil::value>> +{ + using type = T; + + static inline u64 get(T arg) + { + return static_cast>(arg); + } +}; + +template +struct fmt_unveil +{ + using type = const T*; + + static inline u64 get(const T* arg) + { + return reinterpret_cast(arg); + } +}; + +template +struct fmt_unveil +{ + using type = const T*; + + static inline u64 get(const T* arg) + { + return reinterpret_cast(arg); + } +}; + +template<> +struct fmt_unveil +{ + using type = bool; + + static inline u64 get(const b8& value) + { + return fmt_unveil::get(value); + } +}; + +// String type format provider, also type classifier (format() called if an argument is formatted as "%s") +template +struct fmt_class_string +{ + // Formatting function (must be explicitly specialized) + static void format(std::string& out, u64 arg); + + // Helper typedef (visible in format()) + using type = T; + + // Helper function (converts arg to object reference) + static SAFE_BUFFERS FORCE_INLINE const T& get_object(u64 arg) + { + return *reinterpret_cast(static_cast(arg)); } - // Helper class - class exception_base : public std::runtime_error + // Helper function (safely converts arg to enum value) + static SAFE_BUFFERS FORCE_INLINE void format_enum(std::string& out, u64 arg, const char*(*get)(T value)) { - // Helper (there is no other room) - va_list m_args; + const auto value = static_cast>(arg); - protected: - // Internal formatting constructor - exception_base(const char* fmt...); - }; - - // Exception type derived from std::runtime_error with formatting constructor - class exception : public exception_base - { - public: - template - exception(const char* fmt, const Args&... args) - : exception_base(fmt, ::unveil::get(args)...) + // Check narrowing + if (static_cast(value) == arg) { + if (const char* str = get(static_cast(value))) + { + out += str; + return; + } + } + + // Fallback to underlying type formatting + fmt_class_string>::format(out, static_cast(value)); + } + + // Helper constant (may be used in format_enum as lambda return value) + static constexpr const char* unknown = nullptr; +}; + +template<> +struct fmt_class_string +{ + static void format(std::string& out, u64 arg); +}; + +template +struct fmt_class_string : fmt_class_string +{ + // Classify all pointers as const void* +}; + +template<> +struct fmt_class_string +{ + static void format(std::string& out, u64 arg); +}; + +template<> +struct fmt_class_string : fmt_class_string +{ + // Classify char* as const char* +}; + +namespace fmt +{ + // Argument array type (each element generated via fmt_unveil<>) + template + using args_t = const u64(&&)[sizeof...(Args) + 1]; + + using supplementary_info = const struct arg_type_info; + + struct arg_type_info + { + decltype(&fmt_class_string::format) fmt_string; + + template + static constexpr arg_type_info make() + { + return arg_type_info + { + &fmt_class_string::format, + }; + } + + template + static inline const supplementary_info* get() + { + // Constantly initialized null-terminated list of type-specific information + static constexpr arg_type_info result[sizeof...(Args) + 1] + { + make()... + }; + + return result; } }; - // Narrow cast (similar to gsl::narrow) with exception message formatting - template - inline auto narrow(const char* format_str, const From& value, const Args&... args) -> decltype(static_cast(static_cast(std::declval()))) + // Internal formatting function + void raw_append(std::string& out, const char*, const supplementary_info*, const u64*) noexcept; + + // Formatting function + template + static SAFE_BUFFERS void append(std::string& out, const char* fmt, const Args&... args) { - const auto result = static_cast(value); - if (static_cast(result) != value) throw fmt::exception(format_str, value, args...); + raw_append(out, fmt, arg_type_info::get::type...>(), args_t{::fmt_unveil::get(args)...}); + } + + // Formatting function + template + static SAFE_BUFFERS std::string format(const char* fmt, const Args&... args) + { + std::string result; + append(result, fmt, args...); return result; } + + // Internal helper function + char* alloc_format(const char*, const supplementary_info*, const u64*) noexcept; + + // Exception type with formatting constructor + template + class exception_t : public Base + { + using base = Base; + + public: + template + SAFE_BUFFERS exception_t(const char* fmt, const Args&... args) + : base((fmt = alloc_format(fmt, arg_type_info::get::type...>(), args_t{::fmt_unveil::get(args)...}))) + { + std::free(const_cast(fmt)); + } + }; + + // Exception type derived from std::runtime_error with formatting constructor + using exception = exception_t; } diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 2bcde23bd7..c2643f244d 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -863,7 +863,7 @@ bool get_x64_reg_value(x64_context* context, x64_reg_t reg, size_t d_size, size_ return true; } - LOG_ERROR(MEMORY, "get_x64_reg_value(): invalid arguments (reg=%d, d_size=%lld, i_size=%lld)", reg, d_size, i_size); + LOG_ERROR(MEMORY, "get_x64_reg_value(): invalid arguments (reg=%d, d_size=%lld, i_size=%lld)", (u32)reg, d_size, i_size); return false; } @@ -882,7 +882,7 @@ bool put_x64_reg_value(x64_context* context, x64_reg_t reg, size_t d_size, u64 v } } - LOG_ERROR(MEMORY, "put_x64_reg_value(): invalid destination (reg=%d, d_size=%lld, value=0x%llx)", reg, d_size, value); + LOG_ERROR(MEMORY, "put_x64_reg_value(): invalid destination (reg=%d, d_size=%lld, value=0x%llx)", (u32)reg, d_size, value); return false; } @@ -1062,7 +1062,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) if (a_size != 4 || !d_size || !i_size) { - LOG_ERROR(MEMORY, "Invalid or unsupported instruction (op=%d, reg=%d, d_size=%lld, a_size=0x%llx, i_size=%lld)", op, reg, d_size, a_size, i_size); + LOG_ERROR(MEMORY, "Invalid or unsupported instruction (op=%d, reg=%d, d_size=%lld, a_size=0x%llx, i_size=%lld)", (u32)op, (u32)reg, d_size, a_size, i_size); report_opcode(); return false; } @@ -1134,7 +1134,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) case X64OP_STOS: default: { - LOG_ERROR(MEMORY, "Invalid or unsupported operation (op=%d, reg=%d, d_size=%lld, i_size=%lld)", op, reg, d_size, i_size); + LOG_ERROR(MEMORY, "Invalid or unsupported operation (op=%d, reg=%d, d_size=%lld, i_size=%lld)", (u32)op, (u32)reg, d_size, i_size); report_opcode(); return false; } @@ -1151,7 +1151,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) // write memory using "privileged" access to avoid breaking reservation if (!d_size || !i_size) { - LOG_ERROR(MEMORY, "Invalid or unsupported instruction (op=%d, reg=%d, d_size=%lld, a_size=0x%llx, i_size=%lld)", op, reg, d_size, a_size, i_size); + LOG_ERROR(MEMORY, "Invalid or unsupported instruction (op=%d, reg=%d, d_size=%lld, a_size=0x%llx, i_size=%lld)", (u32)op, (u32)reg, d_size, a_size, i_size); report_opcode(); return false; } @@ -1165,7 +1165,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) { if (reg - X64R_XMM0 >= 16) { - LOG_ERROR(MEMORY, "X64OP_STORE: d_size=16, reg=%d", reg); + LOG_ERROR(MEMORY, "X64OP_STORE: d_size=16, reg=%d", (u32)reg); return false; } @@ -1577,7 +1577,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) } default: { - LOG_ERROR(MEMORY, "Invalid or unsupported operation (op=%d, reg=%d, d_size=%lld, a_size=0x%llx, i_size=%lld)", op, reg, d_size, a_size, i_size); + LOG_ERROR(MEMORY, "Invalid or unsupported operation (op=%d, reg=%d, d_size=%lld, a_size=0x%llx, i_size=%lld)", (u32)op, (u32)reg, d_size, a_size, i_size); report_opcode(); return false; } diff --git a/Utilities/cfmt.h b/Utilities/cfmt.h new file mode 100644 index 0000000000..492c70190e --- /dev/null +++ b/Utilities/cfmt.h @@ -0,0 +1,431 @@ +#pragma once + +#include "types.h" +#include +#include + +/* +C-style format parser. Appends formatted string to `out`, returns number of characters written. +Arguments are provided via `src`. TODO +*/ +template +Size cfmt_append(std::string& out, const char* fmt, Src&& src) +{ + const std::size_t old_size = out.size(); + + out.reserve(old_size + 992); + + struct cfmt_context + { + std::size_t size; // Size of current format sequence + + u8 args; // Number of extra args used + u8 type; // Integral type bytesize + bool dot; // Precision enabled + bool left; + bool sign; + bool space; + bool alter; + bool zeros; + + uint width; + uint prec; + }; + + cfmt_context ctx{0}; + + // Error handling: print untouched sequence, stop further formatting + const auto drop_sequence = [&] + { + out.append(fmt - ctx.size, ctx.size); + ctx.size = -1; + }; + + // TODO: check overflow + const auto read_decimal = [&](uint result) -> uint + { + while (fmt[0] >= '0' && fmt[0] <= '9') + { + result = result * 10 + (fmt[0] - '0'); + fmt++, ctx.size++; + } + + return result; + }; + + // TODO: remove this + const auto fallback = [&]() + { + const std::string _fmt(fmt - ctx.size, fmt); + + const u64 arg0 = src.template get(); + const int arg1 = ctx.args >= 1 ? src.template get(1) : 0; + const int arg2 = ctx.args >= 2 ? src.template get(2) : 0; + + if (const std::size_t _size = std::snprintf(0, 0, _fmt.c_str(), arg0, arg1, arg2)) + { + out.resize(out.size() + _size); + std::snprintf(&out.front() + out.size() - _size, _size + 1, _fmt.c_str(), arg0, arg1, arg2); + } + }; + + // Single pass over fmt string (null-terminated), TODO: check correct order + while (const char ch = *fmt++) if (ctx.size == 0) + { + if (ch == '%') + { + ctx.size = 1; + } + else + { + out += ch; + } + } + else if (ctx.size == 1 && ch == '%') + { + ctx = {0}; + out += ch; + } + else if (ctx.size == -1) + { + out += ch; + } + else switch (ctx.size++, ch) + { + case '-': ctx.left = true; break; + case '+': ctx.sign = true; break; + case ' ': ctx.space = true; break; + case '#': ctx.alter = true; break; + case '0': ctx.zeros = true; break; + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + ctx.width = read_decimal(ch - '0'); + break; + } + + case '*': + { + if (!src.test(++ctx.args)) + { + drop_sequence(); + break; + } + + const int warg = src.template get(ctx.args); + ctx.width = std::abs(warg); + ctx.left |= warg < 0; + break; + } + + case '.': + { + if (*fmt >= '0' && *fmt <= '9') // TODO: does it allow '0'? + { + ctx.prec = read_decimal(0); + ctx.dot = true; + } + else if (*fmt == '*') + { + if (!src.test(++ctx.args)) + { + drop_sequence(); + break; + } + + fmt++, ctx.size++; + const int parg = src.template get(ctx.args); + ctx.prec = parg; + ctx.dot = parg >= 0; + } + else + { + ctx.prec = 0; + ctx.dot = true; + } + + break; + } + + case 'h': + { + if (ctx.type) + { + drop_sequence(); + } + else if (fmt[0] == 'h') + { + fmt++, ctx.size++; + ctx.type = sizeof(char); + } + else + { + ctx.type = sizeof(short); + } + + break; + } + + case 'l': + { + if (ctx.type) + { + drop_sequence(); + } + else if (fmt[0] == 'l') + { + fmt++, ctx.size++; + ctx.type = sizeof(llong); + } + else + { + ctx.type = sizeof(long); + } + + break; + } + + case 'z': + { + if (ctx.type) + { + drop_sequence(); + } + else + { + ctx.type = sizeof(std::size_t); + } + + break; + } + + case 'j': + { + if (ctx.type) + { + drop_sequence(); + } + else + { + ctx.type = sizeof(std::intmax_t); + } + + break; + } + + case 't': + { + if (ctx.type) + { + drop_sequence(); + } + else + { + ctx.type = sizeof(std::ptrdiff_t); + } + + break; + } + + case 'c': + { + if (ctx.type || !src.test()) + { + drop_sequence(); + break; + } + + const std::size_t start = out.size(); + out += src.template get(0); + + if (1 < ctx.width) + { + // Add spaces if necessary + out.insert(start + ctx.left, ctx.width - 1, ' '); + } + + src.skip(ctx.args); + ctx = {0}; + break; + } + + case 's': + { + if (ctx.type || !src.test()) + { + drop_sequence(); + break; + } + + const std::size_t start = out.size(); + const std::size_t size1 = src.fmt_string(out); + + if (ctx.dot && size1 > ctx.prec) + { + // Shrink if necessary + out.resize(start + ctx.prec); + } + + // TODO: how it works if precision and width specified simultaneously? + const std::size_t size2 = out.size() - start; + + if (size2 < ctx.width) + { + // Add spaces if necessary + out.insert(ctx.left ? out.size() : start, ctx.width - size2, ' '); + } + + src.skip(ctx.args); + ctx = {0}; + break; + } + + case 'd': + case 'i': + { + if (!src.test()) + { + drop_sequence(); + break; + } + + if (!ctx.type) + { + ctx.type = sizeof(int); + } + + fallback(); // TODO + src.skip(ctx.args); + ctx = {0}; + break; + } + + case 'o': + { + if (!src.test()) + { + drop_sequence(); + break; + } + + if (!ctx.type) + { + ctx.type = sizeof(int); + } + + fallback(); // TODO + src.skip(ctx.args); + ctx = {0}; + break; + } + + case 'x': + case 'X': + { + if (!src.test()) + { + drop_sequence(); + break; + } + + if (!ctx.type) + { + ctx.type = sizeof(int); + } + + fallback(); // TODO + src.skip(ctx.args); + ctx = {0}; + break; + } + + case 'u': + { + if (!src.test()) + { + drop_sequence(); + break; + } + + if (!ctx.type) + { + ctx.type = sizeof(int); + } + + fallback(); // TODO + src.skip(ctx.args); + ctx = {0}; + break; + } + + case 'p': + { + if (!src.test()) + { + drop_sequence(); + break; + } + + if (ctx.type) + { + drop_sequence(); + break; + } + + fallback(); // TODO + src.skip(ctx.args); + ctx = {0}; + break; + } + + case 'f': + case 'F': + case 'e': + case 'E': + case 'a': + case 'A': + case 'g': + case 'G': + { + if (!src.test()) + { + drop_sequence(); + break; + } + + if (ctx.type) + { + drop_sequence(); + break; + } + + fallback(); // TODO + src.skip(ctx.args); + ctx = {0}; + break; + } + + case 'L': // long double, not supported + case 'n': // writeback, not supported + default: + { + drop_sequence(); + } + } + + // Handle unfinished sequence + if (ctx.size && ctx.size != -1) + { + fmt--, drop_sequence(); + } + + return static_cast(out.size() - old_size); +} diff --git a/Utilities/types.h b/Utilities/types.h index 8483e1b698..1d9c05ba38 100644 --- a/Utilities/types.h +++ b/Utilities/types.h @@ -27,12 +27,13 @@ namespace gsl enum class byte : u8; } -template -struct bijective_pair +namespace fmt { - T1 v1; - T2 v2; -}; +} + +// Formatting helper, type-specific preprocessing for improving safety and functionality +template +struct fmt_unveil; template struct se_storage; @@ -40,10 +41,6 @@ struct se_storage; template class se_t; -// Specialization with static constexpr bijective_pair map[] member expected -template -struct bijective; - template struct atomic_storage; @@ -501,40 +498,6 @@ struct multicast } }; -template -T2 bijective_find(const T& left, const DT& def = {}) -{ - for (std::size_t i = 0; i < sizeof(bijective::map) / sizeof(bijective_pair); i++) - { - if (bijective::map[i].v1 == left) - { - return bijective::map[i].v2; - } - } - - return def; -} - -// Formatting helper, type-specific preprocessing for improving safety and functionality -template -struct unveil -{ - // TODO - static inline const T& get(const T& arg) - { - return arg; - } -}; - -template -struct unveil().c_str())>> -{ - static inline const char* get(const T& arg) - { - return arg.c_str(); - } -}; - // Tagged ID type template class id_value @@ -560,3 +523,14 @@ public: return m_value; } }; + +template +struct fmt_unveil> +{ + using type = typename fmt_unveil::type; + + static inline u64 get(const id_value& value) + { + return fmt_unveil::get(value); + } +}; diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index c911e6eb7a..79974224af 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -7,86 +7,86 @@ // TODO: Still reliant on wxWidgets for zlib functions. Alternative solutions? #include -force_inline u8 Read8(const fs::file& f) +inline u8 Read8(const fs::file& f) { u8 ret; f.read(&ret, sizeof(ret)); return ret; } -force_inline u16 Read16(const fs::file& f) +inline u16 Read16(const fs::file& f) { be_t ret; f.read(&ret, sizeof(ret)); return ret; } -force_inline u32 Read32(const fs::file& f) +inline u32 Read32(const fs::file& f) { be_t ret; f.read(&ret, sizeof(ret)); return ret; } -force_inline u64 Read64(const fs::file& f) +inline u64 Read64(const fs::file& f) { be_t ret; f.read(&ret, sizeof(ret)); return ret; } -force_inline u16 Read16LE(const fs::file& f) +inline u16 Read16LE(const fs::file& f) { u16 ret; f.read(&ret, sizeof(ret)); return ret; } -force_inline u32 Read32LE(const fs::file& f) +inline u32 Read32LE(const fs::file& f) { u32 ret; f.read(&ret, sizeof(ret)); return ret; } -force_inline u64 Read64LE(const fs::file& f) +inline u64 Read64LE(const fs::file& f) { u64 ret; f.read(&ret, sizeof(ret)); return ret; } -force_inline void Write8(const fs::file& f, const u8 data) +inline void Write8(const fs::file& f, const u8 data) { f.write(&data, sizeof(data)); } -force_inline void Write16LE(const fs::file& f, const u16 data) +inline void Write16LE(const fs::file& f, const u16 data) { f.write(&data, sizeof(data)); } -force_inline void Write32LE(const fs::file& f, const u32 data) +inline void Write32LE(const fs::file& f, const u32 data) { f.write(&data, sizeof(data)); } -force_inline void Write64LE(const fs::file& f, const u64 data) +inline void Write64LE(const fs::file& f, const u64 data) { f.write(&data, sizeof(data)); } -force_inline void Write16(const fs::file& f, const be_t data) +inline void Write16(const fs::file& f, const be_t data) { f.write(&data, sizeof(data)); } -force_inline void Write32(const fs::file& f, const be_t data) +inline void Write32(const fs::file& f, const be_t data) { f.write(&data, sizeof(data)); } -force_inline void Write64(const fs::file& f, const be_t data) +inline void Write64(const fs::file& f, const be_t data) { f.write(&data, sizeof(data)); } diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index 39dda7a011..5b826a04e5 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -4,6 +4,28 @@ #include +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto arg) + { + switch (arg) + { + STR_CASE(cpu_type::ppu); + STR_CASE(cpu_type::spu); + STR_CASE(cpu_type::arm); + } + + return unknown; + }); +} + +template<> +void fmt_class_string::raw_type>::format(std::string& out, u64 arg) +{ + out += "[UNIMPLEMENTED]"; +} + thread_local cpu_thread* g_tls_current_cpu_thread = nullptr; void cpu_thread::on_task() diff --git a/rpcs3/Emu/Cell/Modules/cellAdec.cpp b/rpcs3/Emu/Cell/Modules/cellAdec.cpp index 24d26a2ad5..c2ad292319 100644 --- a/rpcs3/Emu/Cell/Modules/cellAdec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAdec.cpp @@ -390,7 +390,7 @@ public: default: { - throw EXCEPTION("Unknown task(%d)", task.type); + throw EXCEPTION("Unknown task(%d)", (u32)task.type); } } } @@ -476,7 +476,7 @@ next: default: { - cellAdec.error("adecRawRead(): unknown task (%d)", task.type); + cellAdec.error("adecRawRead(): unknown task (%d)", (u32)task.type); Emu.Pause(); return -1; } diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.cpp b/rpcs3/Emu/Cell/Modules/cellAudio.cpp index a6364a6ed0..152a713c36 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAudio.cpp @@ -461,7 +461,7 @@ s32 cellAudioGetPortConfig(u32 portNum, vm::ptr portConfig) case audio_port_state::closed: portConfig->status = CELL_AUDIO_STATUS_CLOSE; break; case audio_port_state::opened: portConfig->status = CELL_AUDIO_STATUS_READY; break; case audio_port_state::started: portConfig->status = CELL_AUDIO_STATUS_RUN; break; - default: throw fmt::exception("Invalid port state (%d: %d)", portNum, state); + default: throw fmt::exception("Invalid port state (%d: %d)", portNum, (u32)state); } portConfig->nChannel = port.channel; @@ -492,7 +492,7 @@ s32 cellAudioPortStart(u32 portNum) case audio_port_state::closed: return CELL_AUDIO_ERROR_PORT_NOT_OPEN; case audio_port_state::started: return CELL_AUDIO_ERROR_PORT_ALREADY_RUN; case audio_port_state::opened: return CELL_OK; - default: throw fmt::exception("Invalid port state (%d: %d)", portNum, state); + default: throw fmt::exception("Invalid port state (%d: %d)", portNum, (u32)state); } } @@ -517,7 +517,7 @@ s32 cellAudioPortClose(u32 portNum) case audio_port_state::closed: return CELL_AUDIO_ERROR_PORT_NOT_OPEN; case audio_port_state::started: return CELL_OK; case audio_port_state::opened: return CELL_OK; - default: throw fmt::exception("Invalid port state (%d: %d)", portNum, state); + default: throw fmt::exception("Invalid port state (%d: %d)", portNum, (u32)state); } } @@ -542,7 +542,7 @@ s32 cellAudioPortStop(u32 portNum) case audio_port_state::closed: return CELL_AUDIO_ERROR_PORT_NOT_RUN; case audio_port_state::started: return CELL_OK; case audio_port_state::opened: return CELL_AUDIO_ERROR_PORT_NOT_RUN; - default: throw fmt::exception("Invalid port state (%d: %d)", portNum, state); + default: throw fmt::exception("Invalid port state (%d: %d)", portNum, (u32)state); } } diff --git a/rpcs3/Emu/Cell/Modules/cellDmux.cpp b/rpcs3/Emu/Cell/Modules/cellDmux.cpp index 6ec135e98c..c67e3abf98 100644 --- a/rpcs3/Emu/Cell/Modules/cellDmux.cpp +++ b/rpcs3/Emu/Cell/Modules/cellDmux.cpp @@ -648,7 +648,7 @@ public: default: { - throw EXCEPTION("Demuxer thread error: unknown task (0x%x)", task.type); + throw EXCEPTION("Demuxer thread error: unknown task (0x%x)", (u32)task.type); } } } diff --git a/rpcs3/Emu/Cell/Modules/cellPamf.h b/rpcs3/Emu/Cell/Modules/cellPamf.h index 8f80f5fd12..9135c73424 100644 --- a/rpcs3/Emu/Cell/Modules/cellPamf.h +++ b/rpcs3/Emu/Cell/Modules/cellPamf.h @@ -509,12 +509,12 @@ public: return push(data, [do_exit]() { return do_exit && *do_exit; }); } - force_inline bool push(const T& data) + bool push(const T& data) { return push(data, SQUEUE_NEVER_EXIT); } - force_inline bool try_push(const T& data) + bool try_push(const T& data) { return push(data, SQUEUE_ALWAYS_EXIT); } @@ -577,12 +577,12 @@ public: return pop(data, [do_exit]() { return do_exit && *do_exit; }); } - force_inline bool pop(T& data) + bool pop(T& data) { return pop(data, SQUEUE_NEVER_EXIT); } - force_inline bool try_pop(T& data) + bool try_pop(T& data) { return pop(data, SQUEUE_ALWAYS_EXIT); } @@ -639,12 +639,12 @@ public: return peek(data, start_pos, [do_exit]() { return do_exit && *do_exit; }); } - force_inline bool peek(T& data, u32 start_pos = 0) + bool peek(T& data, u32 start_pos = 0) { return peek(data, start_pos, SQUEUE_NEVER_EXIT); } - force_inline bool try_peek(T& data, u32 start_pos = 0) + bool try_peek(T& data, u32 start_pos = 0) { return peek(data, start_pos, SQUEUE_ALWAYS_EXIT); } diff --git a/rpcs3/Emu/Cell/Modules/cellResc.cpp b/rpcs3/Emu/Cell/Modules/cellResc.cpp index 14df3537e5..31fb864f10 100644 --- a/rpcs3/Emu/Cell/Modules/cellResc.cpp +++ b/rpcs3/Emu/Cell/Modules/cellResc.cpp @@ -147,7 +147,7 @@ void cellRescSetVBlankHandler(vm::ptr handler) s32 cellRescCreateInterlaceTable(u32 ea_addr, f32 srcH, CellRescTableElement depth, s32 length) { - cellResc.todo("cellRescCreateInterlaceTable(ea_addr=0x%x, srcH=%f, depth=%d, length=%d)", ea_addr, srcH, depth, length); + cellResc.todo("cellRescCreateInterlaceTable(ea_addr=0x%x, srcH=%f, depth=%d, length=%d)", ea_addr, srcH, (s32)depth, length); return CELL_OK; } diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index 6388e65150..bef14daea6 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -37,7 +37,7 @@ enum : u32 std::mutex g_savedata_mutex; -static never_inline s32 savedata_op(ppu_thread& ppu, u32 operation, u32 version, vm::cptr dirName, +static NEVER_INLINE s32 savedata_op(ppu_thread& ppu, u32 operation, u32 version, vm::cptr dirName, u32 errDialog, PSetList setList, PSetBuf setBuf, PFuncList funcList, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, u32 unknown, vm::ptr userdata, u32 userId, PFuncDone funcDone) { diff --git a/rpcs3/Emu/Cell/Modules/cellSpurs.h b/rpcs3/Emu/Cell/Modules/cellSpurs.h index b82f239201..6a8a7bc46d 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpurs.h +++ b/rpcs3/Emu/Cell/Modules/cellSpurs.h @@ -562,7 +562,7 @@ struct alignas(128) CellSpurs _sub_str4 wklH2[0x10]; // 0x1A00 u8 unknown_[0x2000 - 0x1B00]; - force_inline atomic_t& wklState(const u32 wid) + atomic_t& wklState(const u32 wid) { if (wid & 0x10) { diff --git a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp index 910c9eaa18..ead621394d 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp @@ -74,25 +74,15 @@ cfg::map_entry g_cfg_sys_language(cfg::root.sys, "Language", { "English (UK)", CELL_SYSUTIL_LANG_ENGLISH_GB }, }); -enum class systemparam_id_name : s32 {}; +// For test +enum systemparam_id_name : s32 {}; template<> -struct unveil +void fmt_class_string::format(std::string& out, u64 arg) { - struct temp + format_enum(out, arg, [](auto value) { - s32 value; - char buf[12]; - - temp(systemparam_id_name value) - : value(s32(value)) - { - } - }; - - static inline const char* get(temp&& in) - { - switch (in.value) + switch (value) { case CELL_SYSUTIL_SYSTEMPARAM_ID_LANG: return "ID_LANG"; case CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN: return "ID_ENTER_BUTTON_ASSIGN"; @@ -113,14 +103,13 @@ struct unveil case CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USERNAME: return "ID_CURRENT_USERNAME"; } - std::snprintf(in.buf, sizeof(in.buf), "!0x%04X", in.value); - return in.buf; - } -}; + return unknown; + }); +} -s32 cellSysutilGetSystemParamInt(s32 id, vm::ptr value) +s32 cellSysutilGetSystemParamInt(systemparam_id_name id, vm::ptr value) { - cellSysutil.warning("cellSysutilGetSystemParamInt(id=%s, value=*0x%x)", systemparam_id_name(id), value); + cellSysutil.warning("cellSysutilGetSystemParamInt(id=0x%x(%s), value=*0x%x)", id, id, value); // TODO: load this information from config (preferably "sys/" group) @@ -193,9 +182,9 @@ s32 cellSysutilGetSystemParamInt(s32 id, vm::ptr value) return CELL_OK; } -s32 cellSysutilGetSystemParamString(s32 id, vm::ptr buf, u32 bufsize) +s32 cellSysutilGetSystemParamString(systemparam_id_name id, vm::ptr buf, u32 bufsize) { - cellSysutil.trace("cellSysutilGetSystemParamString(id=0x%x(%s), buf=*0x%x, bufsize=%d)", id, systemparam_id_name(id), buf, bufsize); + cellSysutil.trace("cellSysutilGetSystemParamString(id=0x%x(%s), buf=*0x%x, bufsize=%d)", id, id, buf, bufsize); memset(buf.get_ptr(), 0, bufsize); diff --git a/rpcs3/Emu/Cell/Modules/cellVdec.cpp b/rpcs3/Emu/Cell/Modules/cellVdec.cpp index 75986b2426..d15054eb81 100644 --- a/rpcs3/Emu/Cell/Modules/cellVdec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVdec.cpp @@ -223,7 +223,7 @@ struct vdec_thread : ppu_thread if (decode < 0) { - throw fmt::exception("vdecDecodeAu: AU decoding error(0x%x)" HERE, decode); + throw fmt::exception("AU decoding error(0x%x)" HERE, decode); } if (got_picture == 0) @@ -233,7 +233,7 @@ struct vdec_thread : ppu_thread if (decode != packet.size) { - cellVdec.error("vdecDecodeAu: incorrect AU size (0x%x, decoded 0x%x)", packet.size, decode); + cellVdec.error("Incorrect AU size (0x%x, decoded 0x%x)", packet.size, decode); } if (got_picture) @@ -322,7 +322,7 @@ struct vdec_thread : ppu_thread frame.dts = last_dts = frame->pkt_dts != AV_NOPTS_VALUE ? frame->pkt_dts : last_dts; frame.userdata = au_usrd; - cellVdec.trace("got picture (pts=0x%llx, dts=0x%llx)", frame.pts, frame.dts); + cellVdec.trace("Got picture (pts=0x%llx, dts=0x%llx)", frame.pts, frame.dts); thread_lock{*this}, out.push(std::move(frame)); @@ -355,7 +355,7 @@ struct vdec_thread : ppu_thread default: { - throw fmt::exception("Unknown command (0x%x)" HERE, vcmd); + throw fmt::exception("Unknown command (0x%x)" HERE, (u32)vcmd); } } } @@ -476,7 +476,7 @@ s32 cellVdecEndSeq(u32 handle) s32 cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, vm::cptr auInfo) { - cellVdec.trace("cellVdecDecodeAu(handle=0x%x, mode=%d, auInfo=*0x%x)", handle, mode, auInfo); + cellVdec.trace("cellVdecDecodeAu(handle=0x%x, mode=%d, auInfo=*0x%x)", handle, (s32)mode, auInfo); const auto vdec = idm::get(handle); @@ -487,7 +487,7 @@ s32 cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, vm::cptr picItem) avc->horizontalSize = frame->width; avc->verticalSize = frame->height; - switch (frame->pict_type) + switch (s32 pct = frame->pict_type) { case AV_PICTURE_TYPE_I: avc->pictureType[0] = CELL_VDEC_AVC_PCT_I; break; case AV_PICTURE_TYPE_P: avc->pictureType[0] = CELL_VDEC_AVC_PCT_P; break; case AV_PICTURE_TYPE_B: avc->pictureType[0] = CELL_VDEC_AVC_PCT_B; break; - default: cellVdec.error("cellVdecGetPicItem(AVC): unknown pict_type value (0x%x)", frame->pict_type); + default: cellVdec.error("cellVdecGetPicItem(AVC): unknown pict_type value (0x%x)", pct); } avc->pictureType[1] = CELL_VDEC_AVC_PCT_UNKNOWN; // ??? @@ -742,12 +742,12 @@ s32 cellVdecGetPicItem(u32 handle, vm::pptr picItem) { const vm::ptr dvx = vm::cast(info.addr() + SIZE_32(CellVdecPicItem)); - switch (frame->pict_type) + switch (s32 pct = frame->pict_type) { case AV_PICTURE_TYPE_I: dvx->pictureType = CELL_VDEC_DIVX_VCT_I; break; case AV_PICTURE_TYPE_P: dvx->pictureType = CELL_VDEC_DIVX_VCT_P; break; case AV_PICTURE_TYPE_B: dvx->pictureType = CELL_VDEC_DIVX_VCT_B; break; - default: cellVdec.error("cellVdecGetPicItem(DivX): unknown pict_type value (0x%x)", frame->pict_type); + default: cellVdec.error("cellVdecGetPicItem(DivX): unknown pict_type value (0x%x)", pct); } dvx->horizontalSize = frame->width; @@ -801,12 +801,12 @@ s32 cellVdecGetPicItem(u32 handle, vm::pptr picItem) mp2->video_format = CELL_VDEC_MPEG2_VF_UNSPECIFIED; // ??? mp2->colour_description = false; // ??? - switch (frame->pict_type) + switch (s32 pct = frame->pict_type) { case AV_PICTURE_TYPE_I: mp2->picture_coding_type[0] = CELL_VDEC_MPEG2_PCT_I; break; case AV_PICTURE_TYPE_P: mp2->picture_coding_type[0] = CELL_VDEC_MPEG2_PCT_P; break; case AV_PICTURE_TYPE_B: mp2->picture_coding_type[0] = CELL_VDEC_MPEG2_PCT_B; break; - default: cellVdec.error("cellVdecGetPicItem(MPEG2): unknown pict_type value (0x%x)", frame->pict_type); + default: cellVdec.error("cellVdecGetPicItem(MPEG2): unknown pict_type value (0x%x)", pct); } mp2->picture_coding_type[1] = CELL_VDEC_MPEG2_PCT_FORBIDDEN; // ??? @@ -822,7 +822,7 @@ s32 cellVdecGetPicItem(u32 handle, vm::pptr picItem) s32 cellVdecSetFrameRate(u32 handle, CellVdecFrameRate frc) { - cellVdec.trace("cellVdecSetFrameRate(handle=0x%x, frc=0x%x)", handle, frc); + cellVdec.trace("cellVdecSetFrameRate(handle=0x%x, frc=0x%x)", handle, (s32)frc); const auto vdec = idm::get(handle); diff --git a/rpcs3/Emu/Cell/Modules/sys_net.cpp b/rpcs3/Emu/Cell/Modules/sys_net.cpp index 23272d49ff..9cf524147f 100644 --- a/rpcs3/Emu/Cell/Modules/sys_net.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_net.cpp @@ -147,7 +147,7 @@ namespace sys_net // TODO thread_local vm::ptr<_tls_data_t> g_tls_net_data{}; - static never_inline void initialize_tls() + static NEVER_INLINE void initialize_tls() { // allocate if not initialized if (!g_tls_net_data) diff --git a/rpcs3/Emu/Cell/PPUAnalyser.cpp b/rpcs3/Emu/Cell/PPUAnalyser.cpp index 5759921c1a..130b3acaa9 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.cpp +++ b/rpcs3/Emu/Cell/PPUAnalyser.cpp @@ -10,6 +10,12 @@ const ppu_decoder s_ppu_itype; const ppu_decoder s_ppu_iname; +template<> +void fmt_class_string::raw_type>::format(std::string& out, u64 arg) +{ + out += "[UNIMPLEMENTED]"; +} + void ppu_validate(const std::string& fname, const std::vector& funcs, u32 reloc) { // Load custom PRX configuration if available diff --git a/rpcs3/Emu/Cell/PPUCallback.h b/rpcs3/Emu/Cell/PPUCallback.h index 1797556b27..a08e51ee56 100644 --- a/rpcs3/Emu/Cell/PPUCallback.h +++ b/rpcs3/Emu/Cell/PPUCallback.h @@ -73,20 +73,20 @@ namespace ppu_cb_detail { static_assert(std::is_same::value, "Invalid callback argument type for ARG_CONTEXT"); - force_inline static void set_value(ppu_thread& CPU, const T& arg) + FORCE_INLINE static void set_value(ppu_thread& CPU, const T& arg) { } }; template - force_inline static bool _bind_func_args(ppu_thread& CPU) + FORCE_INLINE static bool _bind_func_args(ppu_thread& CPU) { // terminator return false; } template - force_inline static bool _bind_func_args(ppu_thread& CPU, T1 arg1, T... args) + FORCE_INLINE static bool _bind_func_args(ppu_thread& CPU, T1 arg1, T... args) { const bool is_float = std::is_floating_point::value; const bool is_vector = std::is_same::value; @@ -116,7 +116,7 @@ namespace ppu_cb_detail static_assert(type == ARG_GENERAL, "Unknown callback result type"); static_assert(sizeof(T) <= 8, "Invalid callback result type for ARG_GENERAL"); - force_inline static T get_value(const ppu_thread& CPU) + FORCE_INLINE static T get_value(const ppu_thread& CPU) { return ppu_gpr_cast(CPU.gpr[3]); } @@ -127,7 +127,7 @@ namespace ppu_cb_detail { static_assert(sizeof(T) <= 8, "Invalid callback result type for ARG_FLOAT"); - force_inline static T get_value(const ppu_thread& CPU) + FORCE_INLINE static T get_value(const ppu_thread& CPU) { return static_cast(CPU.fpr[1]); } @@ -138,7 +138,7 @@ namespace ppu_cb_detail { static_assert(std::is_same::value, "Invalid callback result type for ARG_VECTOR"); - force_inline static T get_value(const ppu_thread& CPU) + FORCE_INLINE static T get_value(const ppu_thread& CPU) { return CPU.vr[2]; } @@ -147,7 +147,7 @@ namespace ppu_cb_detail template struct _func_caller { - force_inline static RT call(ppu_thread& CPU, u32 pc, u32 rtoc, T... args) + FORCE_INLINE static RT call(ppu_thread& CPU, u32 pc, u32 rtoc, T... args) { _func_caller::call(CPU, pc, rtoc, args...); @@ -164,7 +164,7 @@ namespace ppu_cb_detail template struct _func_caller { - force_inline static void call(ppu_thread& CPU, u32 pc, u32 rtoc, T... args) + FORCE_INLINE static void call(ppu_thread& CPU, u32 pc, u32 rtoc, T... args) { const bool stack = _bind_func_args<0, 0, 0, T...>(CPU, args...); CPU.gpr[1] -= stack ? FIXED_STACK_FRAME_SIZE : 0x30; // create reserved area @@ -177,7 +177,7 @@ namespace ppu_cb_detail namespace vm { template - force_inline RT _ptr_base::operator()(ppu_thread& CPU, T... args) const + FORCE_INLINE RT _ptr_base::operator()(ppu_thread& CPU, T... args) const { const auto data = vm::ps3::_ptr(vm::cast(m_addr, HERE)); const u32 pc = data[0]; diff --git a/rpcs3/Emu/Cell/PPUFunction.h b/rpcs3/Emu/Cell/PPUFunction.h index b69910da07..a2fbe81328 100644 --- a/rpcs3/Emu/Cell/PPUFunction.h +++ b/rpcs3/Emu/Cell/PPUFunction.h @@ -66,7 +66,7 @@ namespace ppu_func_detail { static_assert(std::is_same::value, "Invalid function argument type for ARG_VECTOR"); - static force_inline T get_arg(ppu_thread& ppu) + static FORCE_INLINE T get_arg(ppu_thread& ppu) { return ppu.vr[v_count + 1]; } @@ -77,7 +77,7 @@ namespace ppu_func_detail { static_assert(alignof(T) <= 16, "Unsupported type alignment for ARG_STACK"); - static force_inline T get_arg(ppu_thread& ppu) + static FORCE_INLINE T get_arg(ppu_thread& ppu) { return ppu_gpr_cast(*ppu.get_stack_arg(g_count, alignof(T))); // TODO } @@ -88,7 +88,7 @@ namespace ppu_func_detail { static_assert(std::is_same::value, "Invalid function argument type for ARG_CONTEXT"); - static force_inline ppu_thread& get_arg(ppu_thread& ppu) + static FORCE_INLINE ppu_thread& get_arg(ppu_thread& ppu) { return ppu; } @@ -99,7 +99,7 @@ namespace ppu_func_detail { static_assert(std::is_same::value, "Invalid function argument type for ARG_VARIADIC"); - static force_inline ppu_va_args_t get_arg(ppu_thread& ppu) + static FORCE_INLINE ppu_va_args_t get_arg(ppu_thread& ppu) { return{ g_count }; } @@ -111,7 +111,7 @@ namespace ppu_func_detail static_assert(type == ARG_GENERAL, "Unknown function result type"); static_assert(sizeof(T) <= 8, "Invalid function result type for ARG_GENERAL"); - static force_inline void put_result(ppu_thread& ppu, const T& result) + static FORCE_INLINE void put_result(ppu_thread& ppu, const T& result) { ppu.gpr[3] = ppu_gpr_cast(result); } @@ -122,7 +122,7 @@ namespace ppu_func_detail { static_assert(sizeof(T) <= 8, "Invalid function result type for ARG_FLOAT"); - static force_inline void put_result(ppu_thread& ppu, const T& result) + static FORCE_INLINE void put_result(ppu_thread& ppu, const T& result) { ppu.fpr[1] = static_cast(result); } @@ -133,7 +133,7 @@ namespace ppu_func_detail { static_assert(std::is_same::value, "Invalid function result type for ARG_VECTOR"); - static force_inline void put_result(ppu_thread& ppu, const T& result) + static FORCE_INLINE void put_result(ppu_thread& ppu, const T& result) { ppu.vr[2] = result; } @@ -160,21 +160,21 @@ namespace ppu_func_detail // argument type + g/f/v_count unpacker template struct bind_arg_packed { - static force_inline T get_arg(ppu_thread& ppu) + static FORCE_INLINE T get_arg(ppu_thread& ppu) { return bind_arg(type_pack & 0xff), (type_pack >> 8) & 0xff, (type_pack >> 16) & 0xff, (type_pack >> 24)>::get_arg(ppu); } }; template - force_inline RT call(ppu_thread& ppu, RT(*func)(Args...), arg_info_pack_t) + FORCE_INLINE RT call(ppu_thread& ppu, RT(*func)(Args...), arg_info_pack_t) { // do the actual function call when all arguments are prepared (simultaneous unpacking of Args... and Info...) return func(bind_arg_packed::get_arg(ppu)...); } template - force_inline RT call(ppu_thread& ppu, RT(*func)(Args...), arg_info_pack_t info) + FORCE_INLINE RT call(ppu_thread& ppu, RT(*func)(Args...), arg_info_pack_t info) { // unpack previous type counts (0/0/0 for the first time) const u32 g_count = (info.last_value >> 8) & 0xff; @@ -220,7 +220,7 @@ namespace ppu_func_detail { using func_t = void(*)(T...); - static force_inline void do_call(ppu_thread& ppu, func_t func) + static FORCE_INLINE void do_call(ppu_thread& ppu, func_t func) { call(ppu, func, arg_info_pack_t<>{}); } @@ -231,14 +231,14 @@ namespace ppu_func_detail { using func_t = RT(*)(T...); - static force_inline void do_call(ppu_thread& ppu, func_t func) + static FORCE_INLINE void do_call(ppu_thread& ppu, func_t func) { bind_result::value>::put_result(ppu, call(ppu, func, arg_info_pack_t<>{})); } }; template - force_inline void do_call(ppu_thread& ppu, RT(*func)(T...)) + FORCE_INLINE void do_call(ppu_thread& ppu, RT(*func)(T...)) { func_binder::do_call(ppu, func); } diff --git a/rpcs3/Emu/Cell/PPUInterpreter.cpp b/rpcs3/Emu/Cell/PPUInterpreter.cpp index 33a14448e3..92ba076da7 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.cpp +++ b/rpcs3/Emu/Cell/PPUInterpreter.cpp @@ -283,7 +283,7 @@ public: } } - force_inline __m128 operator [] (s32 scale) const + FORCE_INLINE __m128 operator [] (s32 scale) const { return m_data[scale + 31]; } diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index dda1c48914..57944fa6c4 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -748,9 +748,9 @@ std::shared_ptr ppu_load_prx(const ppu_prx_object& elf) { if (prog.p_memsz) { - const u32 mem_size = fmt::narrow("Invalid p_memsz (0x%llx)" HERE, prog.p_memsz); - const u32 file_size = fmt::narrow("Invalid p_filesz (0x%llx)" HERE, prog.p_filesz); - const u32 init_addr = fmt::narrow("Invalid p_vaddr (0x%llx)" HERE, prog.p_vaddr); + const u32 mem_size = ::narrow(prog.p_memsz, "p_memsz" HERE); + const u32 file_size = ::narrow(prog.p_filesz, "p_filesz" HERE); + const u32 init_addr = ::narrow(prog.p_vaddr, "p_vaddr" HERE); // Alloc segment memory const u32 addr = vm::alloc(mem_size, vm::main); @@ -965,7 +965,7 @@ void ppu_load_exec(const ppu_exec_object& elf) LOG_NOTICE(LOADER, "** Segment: p_type=0x%x, p_vaddr=0x%llx, p_filesz=0x%llx, p_memsz=0x%llx, flags=0x%x", prog.p_type, prog.p_vaddr, prog.p_filesz, prog.p_memsz, prog.p_flags); const u32 addr = vm::cast(prog.p_vaddr, HERE); - const u32 size = fmt::narrow("Invalid p_memsz: 0x%llx" HERE, prog.p_memsz); + const u32 size = ::narrow(prog.p_memsz, "p_memsz" HERE); if (prog.p_type == 0x1 /* LOAD */ && prog.p_memsz) { @@ -1004,8 +1004,8 @@ void ppu_load_exec(const ppu_exec_object& elf) case 0x00000007: // TLS { tls_vaddr = vm::cast(prog.p_vaddr, HERE); - tls_fsize = fmt::narrow("Invalid p_filesz (0x%llx)" HERE, prog.p_filesz); - tls_vsize = fmt::narrow("Invalid p_memsz (0x%llx)" HERE, prog.p_memsz); + tls_fsize = ::narrow(prog.p_filesz, "p_filesz" HERE); + tls_vsize = ::narrow(prog.p_memsz, "p_memsz" HERE); break; } diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 8f3c909c44..263f1d2eb8 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -87,7 +87,7 @@ std::string ppu_thread::dump() const ret += "\nRegisters:\n=========\n"; for (uint i = 0; i < 32; ++i) ret += fmt::format("GPR[%d] = 0x%llx\n", i, gpr[i]); for (uint i = 0; i < 32; ++i) ret += fmt::format("FPR[%d] = %.6G\n", i, fpr[i]); - for (uint i = 0; i < 32; ++i) ret += fmt::format("VR[%d] = 0x%s [%s]\n", i, vr[i].to_hex().c_str(), vr[i].to_xyzw().c_str()); + for (uint i = 0; i < 32; ++i) ret += fmt::format("VR[%d] = %s [x: %g y: %g z: %g w: %g]\n", i, vr[i], vr[i]._f[3], vr[i]._f[2], vr[i]._f[1], vr[i]._f[0]); if (g_cfg_ppu_decoder.get() != ppu_decoder_type::llvm) { diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 73c1880e84..95b10ca827 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -130,7 +130,7 @@ std::string SPUThread::dump() const { std::string ret = "Registers:\n=========\n"; - for (uint i = 0; i<128; ++i) ret += fmt::format("GPR[%d] = 0x%s\n", i, gpr[i].to_hex().c_str()); + for (uint i = 0; i<128; ++i) ret += fmt::format("GPR[%d] = %s\n", i, gpr[i]); return ret; } @@ -1254,7 +1254,7 @@ bool SPUThread::stop_and_signal(u32 code) } else { - throw EXCEPTION("Unexpected SPU Thread Group state (%d)", group->state); + throw EXCEPTION("Unexpected SPU Thread Group state (%d)", (u32)group->state); } if (queue->events()) @@ -1294,7 +1294,7 @@ bool SPUThread::stop_and_signal(u32 code) } else { - throw EXCEPTION("Unexpected SPU Thread Group state (%d)", group->state); + throw EXCEPTION("Unexpected SPU Thread Group state (%d)", (u32)group->state); } for (auto& thread : group->threads) diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index def1d0472e..07581f3183 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -377,7 +377,7 @@ struct spu_imm_table_t public: scale_table_t(); - force_inline __m128 operator [] (s32 scale) const + FORCE_INLINE __m128 operator [] (s32 scale) const { return m_data[scale + 155]; } diff --git a/rpcs3/Emu/Cell/lv2/sys_event.cpp b/rpcs3/Emu/Cell/lv2/sys_event.cpp index da82fc9a2e..ccdfb8a91e 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_event.cpp @@ -80,7 +80,7 @@ void lv2_event_queue_t::push(lv2_lock_t, u64 source, u64 data1, u64 data2, u64 d } else { - throw fmt::exception("Unexpected (queue.type=%d, thread.type=%d)" HERE, type, thread->type); + throw fmt::exception("Unexpected (queue type=%d, thread type=%d)" HERE, type, (s32)thread->type); } VERIFY(!thread->state.test_and_set(cpu_state::signal)); diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index 9914ed024e..580a2ad60c 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -490,7 +490,7 @@ namespace vm if (!block) { - throw EXCEPTION("Invalid memory location (%d)", location); + throw fmt::exception("Invalid memory location (%u)" HERE, (uint)location); } return block->alloc(size, align, sup); @@ -502,7 +502,7 @@ namespace vm if (!block) { - throw EXCEPTION("Invalid memory location (%d, addr=0x%x)", location, addr); + throw fmt::exception("Invalid memory location (%u, addr=0x%x)" HERE, (uint)location, addr); } return block->falloc(addr, size, sup); @@ -514,7 +514,7 @@ namespace vm if (!block) { - throw EXCEPTION("Invalid memory location (%d, addr=0x%x)", location, addr); + throw fmt::exception("Invalid memory location (%u, addr=0x%x)" HERE, (uint)location, addr); } return block->dealloc(addr, sup_out); @@ -526,7 +526,7 @@ namespace vm if (!block) { - LOG_ERROR(MEMORY, "vm::dealloc(): invalid memory location (%d, addr=0x%x)\n", location, addr); + LOG_ERROR(MEMORY, "vm::dealloc(): invalid memory location (%u, addr=0x%x)\n", (uint)location, addr); return; } diff --git a/rpcs3/Emu/Memory/vm.h b/rpcs3/Emu/Memory/vm.h index a83823b301..3cc5b009e4 100644 --- a/rpcs3/Emu/Memory/vm.h +++ b/rpcs3/Emu/Memory/vm.h @@ -182,12 +182,12 @@ namespace vm { static vm::addr_t cast(u64 addr, const char* loc) { - return static_cast(fmt::narrow("Memory address out of range: 0x%llx%s", addr, loc)); + return static_cast(static_cast(addr)); } static vm::addr_t cast(u64 addr) { - return static_cast(fmt::narrow("Memory address out of range: 0x%llx", addr)); + return static_cast(static_cast(addr)); } }; diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index 36f7f8adac..a64feb981a 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -492,10 +492,12 @@ struct to_se, Se> // Format pointer template -struct unveil, void> +struct fmt_unveil, void> { - static inline auto get(const vm::_ptr_base& arg) + using type = typename fmt_unveil::type; + + static inline u64 get(const vm::_ptr_base& arg) { - return unveil::get(arg.addr()); + return fmt_unveil::get(arg.addr()); } }; diff --git a/rpcs3/Emu/Memory/vm_ref.h b/rpcs3/Emu/Memory/vm_ref.h index 1d39be5362..a46aa2f5ba 100644 --- a/rpcs3/Emu/Memory/vm_ref.h +++ b/rpcs3/Emu/Memory/vm_ref.h @@ -191,7 +191,7 @@ struct to_se, Se> // Forbid formatting template -struct unveil, void> +struct fmt_unveil, void> { static_assert(!sizeof(T), "vm::_ref_base<>: ambiguous format argument"); }; diff --git a/rpcs3/Emu/PSP2/ARMv7Callback.h b/rpcs3/Emu/PSP2/ARMv7Callback.h index 4455284084..001692da69 100644 --- a/rpcs3/Emu/PSP2/ARMv7Callback.h +++ b/rpcs3/Emu/PSP2/ARMv7Callback.h @@ -5,7 +5,7 @@ namespace vm { template - force_inline RT _ptr_base::operator()(ARMv7Thread& cpu, T... args) const + FORCE_INLINE RT _ptr_base::operator()(ARMv7Thread& cpu, T... args) const { return arm_func_detail::func_caller::call(cpu, vm::cast(this->addr(), HERE), args...); } diff --git a/rpcs3/Emu/PSP2/ARMv7Function.h b/rpcs3/Emu/PSP2/ARMv7Function.h index eb9e418cf7..e5fad8dd54 100644 --- a/rpcs3/Emu/PSP2/ARMv7Function.h +++ b/rpcs3/Emu/PSP2/ARMv7Function.h @@ -39,12 +39,12 @@ namespace arm_func_detail static_assert(!std::is_reference::value, "Invalid function argument type (reference)"); static_assert(sizeof(T) <= 4, "Invalid function argument type for ARG_GENERAL"); - force_inline static T get_arg(ARMv7Thread& cpu) + FORCE_INLINE static T get_arg(ARMv7Thread& cpu) { return arm_gpr_cast(cpu.GPR[g_count - 1]); } - force_inline static void put_arg(ARMv7Thread& cpu, const T& arg) + FORCE_INLINE static void put_arg(ARMv7Thread& cpu, const T& arg) { cpu.GPR[g_count - 1] = arm_gpr_cast(arg); } @@ -56,12 +56,12 @@ namespace arm_func_detail // first u64 argument is passed in r0-r1, second one is passed in r2-r3 (if g_count = 3) static_assert(g_count == 2 || g_count == 4, "Wrong u64 argument position"); - force_inline static u64 get_arg(ARMv7Thread& cpu) + FORCE_INLINE static u64 get_arg(ARMv7Thread& cpu) { return cpu.GPR_D[(g_count - 1) >> 1]; } - force_inline static void put_arg(ARMv7Thread& cpu, u64 arg) + FORCE_INLINE static void put_arg(ARMv7Thread& cpu, u64 arg) { cpu.GPR_D[(g_count - 1) >> 1] = arg; } @@ -72,12 +72,12 @@ namespace arm_func_detail { static_assert(g_count == 2 || g_count == 4, "Wrong s64 argument position"); - force_inline static s64 get_arg(ARMv7Thread& cpu) + FORCE_INLINE static s64 get_arg(ARMv7Thread& cpu) { return cpu.GPR_D[(g_count - 1) >> 1]; } - force_inline static void put_arg(ARMv7Thread& cpu, s64 arg) + FORCE_INLINE static void put_arg(ARMv7Thread& cpu, s64 arg) { cpu.GPR_D[(g_count - 1) >> 1] = arg; } @@ -89,11 +89,11 @@ namespace arm_func_detail static_assert(f_count <= 0, "TODO: Unsupported argument type (float)"); static_assert(sizeof(T) <= 8, "Invalid function argument type for ARG_FLOAT"); - force_inline static T get_arg(ARMv7Thread& cpu) + FORCE_INLINE static T get_arg(ARMv7Thread& cpu) { } - force_inline static void put_arg(ARMv7Thread& cpu, const T& arg) + FORCE_INLINE static void put_arg(ARMv7Thread& cpu, const T& arg) { } }; @@ -104,11 +104,11 @@ namespace arm_func_detail static_assert(v_count <= 0, "TODO: Unsupported argument type (vector)"); static_assert(std::is_same::value, "Invalid function argument type for ARG_VECTOR"); - force_inline static T get_arg(ARMv7Thread& cpu) + FORCE_INLINE static T get_arg(ARMv7Thread& cpu) { } - force_inline static void put_arg(ARMv7Thread& cpu, const T& arg) + FORCE_INLINE static void put_arg(ARMv7Thread& cpu, const T& arg) { } }; @@ -120,13 +120,13 @@ namespace arm_func_detail static_assert(v_count <= 0, "TODO: Unsupported stack argument type (vector)"); static_assert(sizeof(T) <= 4, "Invalid function argument type for ARG_STACK"); - force_inline static T get_arg(ARMv7Thread& cpu) + FORCE_INLINE static T get_arg(ARMv7Thread& cpu) { // TODO: check return arm_gpr_cast(vm::psv::read32(cpu.SP + sizeof(u32) * (g_count - 5))); } - force_inline static void put_arg(ARMv7Thread& cpu, const T& arg) + FORCE_INLINE static void put_arg(ARMv7Thread& cpu, const T& arg) { // TODO: check const int stack_pos = (g_count - 5) * 4 - FIXED_STACK_FRAME_SIZE; @@ -139,13 +139,13 @@ namespace arm_func_detail template struct bind_arg { - force_inline static u64 get_arg(ARMv7Thread& cpu) + FORCE_INLINE static u64 get_arg(ARMv7Thread& cpu) { // TODO: check return vm::psv::read64(cpu.SP + sizeof(u32) * (g_count - 6)); } - force_inline static void put_arg(ARMv7Thread& cpu, u64 arg) + FORCE_INLINE static void put_arg(ARMv7Thread& cpu, u64 arg) { // TODO: check const int stack_pos = (g_count - 6) * 4 - FIXED_STACK_FRAME_SIZE; @@ -158,13 +158,13 @@ namespace arm_func_detail template struct bind_arg { - force_inline static s64 get_arg(ARMv7Thread& cpu) + FORCE_INLINE static s64 get_arg(ARMv7Thread& cpu) { // TODO: check return vm::psv::read64(cpu.SP + sizeof(u32) * (g_count - 6)); } - force_inline static void put_arg(ARMv7Thread& cpu, s64 arg) + FORCE_INLINE static void put_arg(ARMv7Thread& cpu, s64 arg) { // TODO: check const int stack_pos = (g_count - 6) * 4 - FIXED_STACK_FRAME_SIZE; @@ -179,12 +179,12 @@ namespace arm_func_detail { static_assert(std::is_same::value, "Invalid function argument type for ARG_CONTEXT"); - force_inline static ARMv7Thread& get_arg(ARMv7Thread& cpu) + FORCE_INLINE static ARMv7Thread& get_arg(ARMv7Thread& cpu) { return cpu; } - force_inline static void put_arg(ARMv7Thread& cpu, ARMv7Thread& arg) + FORCE_INLINE static void put_arg(ARMv7Thread& cpu, ARMv7Thread& arg) { } }; @@ -194,7 +194,7 @@ namespace arm_func_detail { static_assert(std::is_same::value, "Invalid function argument type for ARG_VARIADIC"); - force_inline static arm_va_args_t get_arg(ARMv7Thread& cpu) + FORCE_INLINE static arm_va_args_t get_arg(ARMv7Thread& cpu) { return{ g_count }; } @@ -208,12 +208,12 @@ namespace arm_func_detail static_assert(type == ARG_GENERAL, "Wrong use of bind_result template"); static_assert(sizeof(T) <= 4, "Invalid function result type for ARG_GENERAL"); - force_inline static T get_result(ARMv7Thread& cpu) + FORCE_INLINE static T get_result(ARMv7Thread& cpu) { return arm_gpr_cast(cpu.GPR[0]); } - force_inline static void put_result(ARMv7Thread& cpu, const T& result) + FORCE_INLINE static void put_result(ARMv7Thread& cpu, const T& result) { cpu.GPR[0] = arm_gpr_cast(result); } @@ -222,12 +222,12 @@ namespace arm_func_detail template<> struct bind_result { - force_inline static u64 get_result(ARMv7Thread& cpu) + FORCE_INLINE static u64 get_result(ARMv7Thread& cpu) { return cpu.GPR_D[0]; } - force_inline static void put_result(ARMv7Thread& cpu, u64 result) + FORCE_INLINE static void put_result(ARMv7Thread& cpu, u64 result) { cpu.GPR_D[0] = result; } @@ -236,12 +236,12 @@ namespace arm_func_detail template<> struct bind_result { - force_inline static s64 get_result(ARMv7Thread& cpu) + FORCE_INLINE static s64 get_result(ARMv7Thread& cpu) { return cpu.GPR_D[0]; } - force_inline static void put_result(ARMv7Thread& cpu, s64 result) + FORCE_INLINE static void put_result(ARMv7Thread& cpu, s64 result) { cpu.GPR_D[0] = result; } @@ -252,7 +252,7 @@ namespace arm_func_detail //{ // static_assert(sizeof(T) <= 8, "Invalid function result type for ARG_FLOAT"); - // static force_inline void put_result(ARMv7Thread& cpu, const T& result) + // static FORCE_INLINE void put_result(ARMv7Thread& cpu, const T& result) // { // } //}; @@ -262,7 +262,7 @@ namespace arm_func_detail //{ // static_assert(std::is_same, v128>::value, "Invalid function result type for ARG_VECTOR"); - // static force_inline void put_result(ARMv7Thread& cpu, const T& result) + // static FORCE_INLINE void put_result(ARMv7Thread& cpu, const T& result) // { // } //}; @@ -322,21 +322,21 @@ namespace arm_func_detail // argument type + g/f/v_count unpacker template struct bind_arg_packed { - force_inline static T get_arg(ARMv7Thread& cpu) + FORCE_INLINE static T get_arg(ARMv7Thread& cpu) { return bind_arg(type_pack & 0xff), (type_pack >> 8) & 0xff, (type_pack >> 16) & 0xff, (type_pack >> 24)>::get_arg(cpu); } }; template - force_inline RT call(ARMv7Thread& cpu, RT(*func)(Args...), arg_info_pack_t info) + FORCE_INLINE RT call(ARMv7Thread& cpu, RT(*func)(Args...), arg_info_pack_t info) { // do the actual function call when all arguments are prepared (simultaneous unpacking of Args... and Info...) return func(bind_arg_packed::get_arg(cpu)...); } template - force_inline RT call(ARMv7Thread& cpu, RT(*func)(Args...), arg_info_pack_t info) + FORCE_INLINE RT call(ARMv7Thread& cpu, RT(*func)(Args...), arg_info_pack_t info) { // unpack previous type counts (0/0/0 for the first time) const u32 g_count = (info.last_value >> 8) & 0xff; @@ -353,14 +353,14 @@ namespace arm_func_detail } template - force_inline static bool put_func_args(ARMv7Thread& cpu) + FORCE_INLINE static bool put_func_args(ARMv7Thread& cpu) { // terminator return false; } template - force_inline static bool put_func_args(ARMv7Thread& cpu, T1 arg, T... args) + FORCE_INLINE static bool put_func_args(ARMv7Thread& cpu, T1 arg, T... args) { using type = arg_type; const arg_class t = type::value; @@ -402,7 +402,7 @@ namespace arm_func_detail template struct func_caller { - force_inline static RT call(ARMv7Thread& cpu, u32 addr, T... args) + FORCE_INLINE static RT call(ARMv7Thread& cpu, u32 addr, T... args) { func_caller::call(cpu, addr, args...); @@ -413,7 +413,7 @@ namespace arm_func_detail template struct func_caller { - force_inline static void call(ARMv7Thread& cpu, u32 addr, T... args) + FORCE_INLINE static void call(ARMv7Thread& cpu, u32 addr, T... args) { if (put_func_args<0, 0, 0, T...>(cpu, args...)) { @@ -428,7 +428,7 @@ namespace arm_func_detail } }; - template force_inline void do_call(ARMv7Thread& cpu, RT(*func)(T...)) + template FORCE_INLINE void do_call(ARMv7Thread& cpu, RT(*func)(T...)) { func_binder::do_call(cpu, func); } diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp index f7306bd769..1432ed2917 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp @@ -20,7 +20,7 @@ D3D12_BLEND_OP get_blend_op(rsx::blend_equation op) case rsx::blend_equation::reverse_substract_signed: break; } - throw EXCEPTION("Invalid or unsupported blend op (0x%x)", op); + throw EXCEPTION("Invalid or unsupported blend op (0x%x)", (u32)op); } D3D12_BLEND get_blend_factor(rsx::blend_factor factor) @@ -45,7 +45,7 @@ D3D12_BLEND get_blend_factor(rsx::blend_factor factor) case rsx::blend_factor::one_minus_constant_alpha: return D3D12_BLEND_INV_BLEND_FACTOR; } - throw EXCEPTION("Invalid blend factor (0x%x)", factor); + throw EXCEPTION("Invalid blend factor (0x%x)", (u32)factor); } D3D12_BLEND get_blend_factor_alpha(rsx::blend_factor factor) @@ -70,7 +70,7 @@ D3D12_BLEND get_blend_factor_alpha(rsx::blend_factor factor) case rsx::blend_factor::one_minus_constant_alpha: return D3D12_BLEND_INV_BLEND_FACTOR; } - throw EXCEPTION("Invalid blend alpha factor (0x%x)", factor); + throw EXCEPTION("Invalid blend alpha factor (0x%x)", (u32)factor); } /** @@ -96,7 +96,7 @@ D3D12_LOGIC_OP get_logic_op(rsx::logic_op op) case rsx::logic_op::logic_or_inverted: return D3D12_LOGIC_OP_OR_INVERTED; case rsx::logic_op::logic_nand: return D3D12_LOGIC_OP_NAND; } - throw EXCEPTION("Invalid logic op (0x%x)", op); + throw EXCEPTION("Invalid logic op (0x%x)", (u32)op); } /** @@ -115,7 +115,7 @@ D3D12_STENCIL_OP get_stencil_op(rsx::stencil_op op) case rsx::stencil_op::incr_wrap: return D3D12_STENCIL_OP_INCR; case rsx::stencil_op::decr_wrap: return D3D12_STENCIL_OP_DECR; } - throw EXCEPTION("Invalid stencil op (0x%x)", op); + throw EXCEPTION("Invalid stencil op (0x%x)", (u32)op); } D3D12_COMPARISON_FUNC get_compare_func(rsx::comparison_function op) @@ -131,7 +131,7 @@ D3D12_COMPARISON_FUNC get_compare_func(rsx::comparison_function op) case rsx::comparison_function::greater_or_equal: return D3D12_COMPARISON_FUNC_GREATER_EQUAL; case rsx::comparison_function::always: return D3D12_COMPARISON_FUNC_ALWAYS; } - throw EXCEPTION("Invalid or unsupported compare func (0x%x)", op); + throw EXCEPTION("Invalid or unsupported compare func (0x%x)", (u32)op); } DXGI_FORMAT get_texture_format(u8 format) @@ -169,7 +169,7 @@ DXGI_FORMAT get_texture_format(u8 format) case ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN) & CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8: return DXGI_FORMAT_R8G8_B8G8_UNORM; break; } - throw EXCEPTION("Invalid or unsupported texture format (0x%x)", format); + throw EXCEPTION("Invalid or unsupported texture format (0x%x)", (u32)format); } UINT get_texture_max_aniso(rsx::texture_max_anisotropy aniso) @@ -185,7 +185,7 @@ UINT get_texture_max_aniso(rsx::texture_max_anisotropy aniso) case rsx::texture_max_anisotropy::x12: return 12; case rsx::texture_max_anisotropy::x16: return 16; } - throw EXCEPTION("Invalid texture max aniso (0x%x)", aniso); + throw EXCEPTION("Invalid texture max aniso (0x%x)", (u32)aniso); } D3D12_TEXTURE_ADDRESS_MODE get_texture_wrap_mode(rsx::texture_wrap_mode wrap) @@ -201,7 +201,7 @@ D3D12_TEXTURE_ADDRESS_MODE get_texture_wrap_mode(rsx::texture_wrap_mode wrap) case rsx::texture_wrap_mode::mirror_once_border: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE; case rsx::texture_wrap_mode::mirror_once_clamp: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE; } - throw EXCEPTION("Invalid texture wrap mode (0x%x)", wrap); + throw EXCEPTION("Invalid texture wrap mode (0x%x)", (u32)wrap); } namespace @@ -277,7 +277,7 @@ D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(rsx::primitive_type draw_mode) case rsx::primitive_type::quad_strip: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; case rsx::primitive_type::polygon: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; } - throw EXCEPTION("Invalid draw mode (0x%x)", draw_mode); + throw EXCEPTION("Invalid draw mode (0x%x)", (u32)draw_mode); } D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(rsx::primitive_type draw_mode) @@ -295,7 +295,7 @@ D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(rsx::primitive_type dr case rsx::primitive_type::polygon: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; case rsx::primitive_type::line_loop: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; } - throw EXCEPTION("Invalid or unsupported draw mode (0x%x)", draw_mode); + throw EXCEPTION("Invalid or unsupported draw mode (0x%x)", (u32)draw_mode); } DXGI_FORMAT get_color_surface_format(rsx::surface_color_format format) @@ -316,7 +316,7 @@ DXGI_FORMAT get_color_surface_format(rsx::surface_color_format format) case rsx::surface_color_format::w32z32y32x32: return DXGI_FORMAT_R32G32B32A32_FLOAT; case rsx::surface_color_format::x32: return DXGI_FORMAT_R32_FLOAT; } - throw EXCEPTION("Invalid format (0x%x)", format); + throw EXCEPTION("Invalid format (0x%x)", (u32)format); } DXGI_FORMAT get_depth_stencil_surface_format(rsx::surface_depth_format format) @@ -326,7 +326,7 @@ DXGI_FORMAT get_depth_stencil_surface_format(rsx::surface_depth_format format) case rsx::surface_depth_format::z16: return DXGI_FORMAT_D16_UNORM; case rsx::surface_depth_format::z24s8: return DXGI_FORMAT_D24_UNORM_S8_UINT; } - throw EXCEPTION("Invalid format (0x%x)", format); + throw EXCEPTION("Invalid format (0x%x)", (u32)format); } DXGI_FORMAT get_depth_stencil_surface_clear_format(rsx::surface_depth_format format) @@ -336,7 +336,7 @@ DXGI_FORMAT get_depth_stencil_surface_clear_format(rsx::surface_depth_format for case rsx::surface_depth_format::z16: return DXGI_FORMAT_D16_UNORM; case rsx::surface_depth_format::z24s8: return DXGI_FORMAT_D24_UNORM_S8_UINT; } - throw EXCEPTION("Invalid format (0x%x)", format); + throw EXCEPTION("Invalid format (0x%x)", (u32)format); } DXGI_FORMAT get_depth_stencil_typeless_surface_format(rsx::surface_depth_format format) @@ -346,7 +346,7 @@ DXGI_FORMAT get_depth_stencil_typeless_surface_format(rsx::surface_depth_format case rsx::surface_depth_format::z16: return DXGI_FORMAT_R16_TYPELESS; case rsx::surface_depth_format::z24s8: return DXGI_FORMAT_R24G8_TYPELESS; } - throw EXCEPTION("Invalid format (0x%x)", format); + throw EXCEPTION("Invalid format (0x%x)", (u32)format); } DXGI_FORMAT get_depth_samplable_surface_format(rsx::surface_depth_format format) @@ -356,7 +356,7 @@ DXGI_FORMAT get_depth_samplable_surface_format(rsx::surface_depth_format format) case rsx::surface_depth_format::z16: return DXGI_FORMAT_R16_UNORM; case rsx::surface_depth_format::z24s8: return DXGI_FORMAT_R24_UNORM_X8_TYPELESS; } - throw EXCEPTION("Invalid format (0x%x)", format); + throw EXCEPTION("Invalid format (0x%x)", (u32)format); } BOOL get_front_face_ccw(rsx::front_face ffv) @@ -366,7 +366,7 @@ BOOL get_front_face_ccw(rsx::front_face ffv) case rsx::front_face::cw: return FALSE; case rsx::front_face::ccw: return TRUE; } - throw EXCEPTION("Invalid front face value (0x%x)", ffv); + throw EXCEPTION("Invalid front face value (0x%x)", (u32)ffv); } D3D12_CULL_MODE get_cull_face(rsx::cull_face cfv) @@ -377,7 +377,7 @@ D3D12_CULL_MODE get_cull_face(rsx::cull_face cfv) case rsx::cull_face::back: return D3D12_CULL_MODE_BACK; case rsx::cull_face::front_and_back: return D3D12_CULL_MODE_NONE; } - throw EXCEPTION("Invalid cull face value (0x%x)", cfv); + throw EXCEPTION("Invalid cull face value (0x%x)", (u32)cfv); } DXGI_FORMAT get_index_type(rsx::index_array_type index_type) @@ -387,7 +387,7 @@ DXGI_FORMAT get_index_type(rsx::index_array_type index_type) case rsx::index_array_type::u16: return DXGI_FORMAT_R16_UINT; case rsx::index_array_type::u32: return DXGI_FORMAT_R32_UINT; } - throw EXCEPTION("Invalid index_type (0x%x)", index_type); + throw EXCEPTION("Invalid index_type (0x%x)", (u32)index_type); } DXGI_FORMAT get_vertex_attribute_format(rsx::vertex_base_type type, u8 size) @@ -473,7 +473,7 @@ DXGI_FORMAT get_vertex_attribute_format(rsx::vertex_base_type type, u8 size) } } - throw EXCEPTION("Invalid or unsupported type or size (type=0x%x, size=0x%x)", type, size); + throw EXCEPTION("Invalid or unsupported type or size (type=0x%x, size=0x%x)", (u32)type, size); } D3D12_RECT get_scissor(u16 clip_origin_x, u16 clip_origin_y, u16 clip_w, u16 clip_h) diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index fccb074bef..877ecd95ea 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -363,7 +363,7 @@ void GLGSRender::end() switch (control) { default: - LOG_ERROR(RSX, "bad clip plane control (0x%x)", control); + LOG_ERROR(RSX, "bad clip plane control (0x%x)", (u32)control); case rsx::user_clip_plane_op::disable: value = 0; @@ -1019,7 +1019,7 @@ void GLGSRender::flip(int buffer) std::string message = "draw_calls: " + std::to_string(m_draw_calls) + ", " + "draw_call_setup: " + std::to_string(m_begin_time) + "us, " + "vertex_upload_time: " + std::to_string(m_vertex_upload_time) + "us, " + "draw_call_execution: " + std::to_string(m_draw_time) + "us"; - LOG_ERROR(RSX, message.c_str()); + LOG_ERROR(RSX, "%s", message); } } diff --git a/rpcs3/Emu/RSX/GL/gl_render_targets.cpp b/rpcs3/Emu/RSX/GL/gl_render_targets.cpp index 73d711fd18..563b07dda2 100644 --- a/rpcs3/Emu/RSX/GL/gl_render_targets.cpp +++ b/rpcs3/Emu/RSX/GL/gl_render_targets.cpp @@ -46,7 +46,7 @@ color_format rsx::internals::surface_color_format_to_gl(rsx::surface_color_forma case rsx::surface_color_format::a8b8g8r8: default: - LOG_ERROR(RSX, "Surface color buffer: Unsupported surface color format (0x%x)", color_format); + LOG_ERROR(RSX, "Surface color buffer: Unsupported surface color format (0x%x)", (u32)color_format); return{ ::gl::texture::type::uint_8_8_8_8, ::gl::texture::format::bgra, false, 4, 1 }; } } @@ -59,7 +59,7 @@ depth_format rsx::internals::surface_depth_format_to_gl(rsx::surface_depth_forma return{ ::gl::texture::type::ushort, ::gl::texture::format::depth, ::gl::texture::internal_format::depth16 }; default: - LOG_ERROR(RSX, "Surface depth buffer: Unsupported surface depth format (0x%x)", depth_format); + LOG_ERROR(RSX, "Surface depth buffer: Unsupported surface depth format (0x%x)", (u32)depth_format); case rsx::surface_depth_format::z24s8: return{ ::gl::texture::type::uint_24_8, ::gl::texture::format::depth_stencil, ::gl::texture::internal_format::depth24_stencil8 }; } diff --git a/rpcs3/Emu/RSX/GL/rsx_gl_texture.cpp b/rpcs3/Emu/RSX/GL/rsx_gl_texture.cpp index 969717b0dd..0bee4c08bb 100644 --- a/rpcs3/Emu/RSX/GL/rsx_gl_texture.cpp +++ b/rpcs3/Emu/RSX/GL/rsx_gl_texture.cpp @@ -37,7 +37,7 @@ namespace case CELL_GCM_TEXTURE_COMPRESSED_DXT23: return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; case CELL_GCM_TEXTURE_COMPRESSED_DXT45: return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; } - throw EXCEPTION("Compressed or unknown texture format %x", texture_format); + throw EXCEPTION("Compressed or unknown texture format 0x%x", texture_format); } @@ -66,7 +66,7 @@ namespace case CELL_GCM_TEXTURE_D8R8G8B8: return std::make_tuple(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8); case CELL_GCM_TEXTURE_Y16_X16_FLOAT: return std::make_tuple(GL_RG, GL_HALF_FLOAT); } - throw EXCEPTION("Compressed or unknown texture format %x", texture_format); + throw EXCEPTION("Compressed or unknown texture format 0x%x", texture_format); } bool is_compressed_format(u32 texture_format) @@ -99,7 +99,7 @@ namespace case CELL_GCM_TEXTURE_COMPRESSED_DXT45: return true; } - throw EXCEPTION("Unknown format %x", texture_format); + throw EXCEPTION("Unknown format 0x%x", texture_format); } bool requires_unpack_byte(u32 texture_format) @@ -178,7 +178,7 @@ namespace return { GL_ZERO, GL_GREEN, GL_BLUE, GL_RED }; } - throw EXCEPTION("Unknown format %x", texture_format); + throw EXCEPTION("Unknown format 0x%x", texture_format); } } @@ -248,7 +248,7 @@ namespace rsx case rsx::texture_wrap_mode::mirror_once_clamp: return GL_MIRROR_CLAMP_EXT; } - LOG_ERROR(RSX, "Texture wrap error: bad wrap (%d).", wrap); + LOG_ERROR(RSX, "Texture wrap error: bad wrap (%d)", (u32)wrap); return GL_REPEAT; } @@ -266,7 +266,7 @@ namespace rsx case rsx::texture_max_anisotropy::x16: return 16.0f; } - LOG_ERROR(RSX, "Texture anisotropy error: bad max aniso (%d).", aniso); + LOG_ERROR(RSX, "Texture anisotropy error: bad max aniso (%d)", (u32)aniso); return 1.0f; } @@ -526,7 +526,7 @@ namespace rsx { if (tex.get_exact_mipmap_count() <= 1 || m_target == GL_TEXTURE_RECTANGLE) { - LOG_WARNING(RSX, "Texture %d, target 0x%X, requesting mipmap filtering without any mipmaps set!", m_id, m_target); + LOG_WARNING(RSX, "Texture %d, target 0x%x, requesting mipmap filtering without any mipmaps set!", m_id, m_target); min_filter = GL_LINEAR; } } @@ -631,7 +631,7 @@ namespace rsx { if (tex.get_exact_mipmap_count() <= 1 || m_target == GL_TEXTURE_RECTANGLE) { - LOG_WARNING(RSX, "Texture %d, target 0x%X, requesting mipmap filtering without any mipmaps set!", m_id, m_target); + LOG_WARNING(RSX, "Texture %d, target 0x%x, requesting mipmap filtering without any mipmaps set!", m_id, m_target); min_filter = GL_LINEAR; } } diff --git a/rpcs3/Emu/RSX/GL/vertex_buffer.cpp b/rpcs3/Emu/RSX/GL/vertex_buffer.cpp index 0f6c5f83b5..84a6ccdd38 100644 --- a/rpcs3/Emu/RSX/GL/vertex_buffer.cpp +++ b/rpcs3/Emu/RSX/GL/vertex_buffer.cpp @@ -20,7 +20,7 @@ namespace const u32* vec_selectors[] = { 0, vec1_types, vec2_types, vec3_types, vec4_types }; if (type > rsx::vertex_base_type::ub256) - throw EXCEPTION("OpenGL error: unknown vertex base type 0x%X.", (u32)type); + throw EXCEPTION("OpenGL error: unknown vertex base type 0x%x", (u32)type); return vec_selectors[size][(int)type]; } @@ -131,7 +131,7 @@ namespace std::tuple get_index_array_for_emulated_non_indexed_draw(const std::vector> &first_count_commands, rsx::primitive_type primitive_mode, gl::ring_buffer &dst) { u32 vertex_draw_count = 0; - assert(!gl::is_primitive_native(primitive_mode)); + EXPECTS(gl::is_primitive_native(primitive_mode)); for (const auto &pair : first_count_commands) { @@ -411,7 +411,7 @@ u32 GLGSRender::set_vertex_buffer() break; } default: - LOG_ERROR(RSX, "bad non array vertex data format (type = %d, size = %d)", vertex_info.type, vertex_info.size); + LOG_ERROR(RSX, "bad non array vertex data format (type=%d, size=%d)", (u32)vertex_info.type, vertex_info.size); break; } } diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 2f5bd2d49e..1cecca8660 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -44,7 +44,7 @@ namespace rsx void old_shaders_cache::shaders_cache::load(const std::string &path, shader_language lang) { - const std::string lang_name(::unveil::get(lang)); + const std::string lang_name(lang == shader_language::glsl ? "glsl" : "hlsl"); auto extract_hash = [](const std::string &string) { @@ -180,7 +180,7 @@ namespace rsx case vertex_base_type::cmp: return sizeof(u16) * 4; case vertex_base_type::ub256: EXPECTS(size == 4); return sizeof(u8) * 4; } - throw EXCEPTION("RSXVertexData::GetTypeSize: Bad vertex data type (%d)!", type); + throw EXCEPTION("RSXVertexData::GetTypeSize: Bad vertex data type (%d)!", (u8)type); } void tiled_region::write(const void *src, u32 width, u32 height, u32 pitch) diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index 6bdedfca24..c137512b6c 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -34,21 +34,6 @@ namespace rsx } } -template<> -struct unveil -{ - static inline const char* get(rsx::old_shaders_cache::shader_language in) - { - switch (in) - { - case rsx::old_shaders_cache::shader_language::glsl: return "glsl"; - case rsx::old_shaders_cache::shader_language::hlsl: return "hlsl"; - } - - return ""; - } -}; - namespace rsx { namespace limits diff --git a/rpcs3/Emu/RSX/VK/VKFormats.cpp b/rpcs3/Emu/RSX/VK/VKFormats.cpp index f49bdf9b66..71471d3b6e 100644 --- a/rpcs3/Emu/RSX/VK/VKFormats.cpp +++ b/rpcs3/Emu/RSX/VK/VKFormats.cpp @@ -36,7 +36,7 @@ VkFormat get_compatible_depth_surface_format(const gpu_formats_support &support, throw EXCEPTION("No hardware support for z24s8"); } } - throw EXCEPTION("Invalid format (0x%x)", format); + throw EXCEPTION("Invalid format (0x%x)", (u32)format); } std::tuple get_min_filter_and_mip(rsx::texture_minify_filter min_filter) @@ -62,7 +62,7 @@ VkFilter get_mag_filter(rsx::texture_magnify_filter mag_filter) case rsx::texture_magnify_filter::linear: return VK_FILTER_LINEAR; case rsx::texture_magnify_filter::convolution_mag: return VK_FILTER_LINEAR; } - throw EXCEPTION("Invalid mag filter (0x%x)", mag_filter); + throw EXCEPTION("Invalid mag filter (0x%x)", (u32)mag_filter); } VkBorderColor get_border_color(u8 color) @@ -105,7 +105,7 @@ float max_aniso(rsx::texture_max_anisotropy gcm_aniso) case rsx::texture_max_anisotropy::x16: return 16.0f; } - throw EXCEPTION("Texture anisotropy error: bad max aniso (%d).", gcm_aniso); + throw EXCEPTION("Texture anisotropy error: bad max aniso (%d)", (u32)gcm_aniso); } diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index a8a3c7334d..c7c3c4631e 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -44,7 +44,7 @@ namespace vk case rsx::comparison_function::not_equal: return VK_COMPARE_OP_NOT_EQUAL; case rsx::comparison_function::always: return VK_COMPARE_OP_ALWAYS; default: - throw EXCEPTION("Unknown compare op: 0x%X", op); + throw EXCEPTION("Unknown compare op: 0x%x", (u32)op); } } @@ -91,7 +91,7 @@ namespace vk return std::make_pair(VK_FORMAT_R32_SFLOAT, vk::default_component_map()); default: - LOG_ERROR(RSX, "Surface color buffer: Unsupported surface color format (0x%x)", color_format); + LOG_ERROR(RSX, "Surface color buffer: Unsupported surface color format (0x%x)", (u32)color_format); return std::make_pair(VK_FORMAT_B8G8R8A8_UNORM, vk::default_component_map()); } } @@ -170,7 +170,7 @@ namespace vk case rsx::surface_target::surfaces_a_b_c_d: return{ 0, 1, 2, 3 }; default: - LOG_ERROR(RSX, "Bad surface color target: %d", fmt); + LOG_ERROR(RSX, "Bad surface color target: %d", (u32)fmt); return{}; } } @@ -195,7 +195,7 @@ namespace vk case rsx::logic_op::logic_or_inverted: return VK_LOGIC_OP_OR_INVERTED; case rsx::logic_op::logic_nand: return VK_LOGIC_OP_NAND; default: - throw EXCEPTION("Unknown logic op 0x%X", op); + throw EXCEPTION("Unknown logic op 0x%x", (u32)op); } } @@ -218,7 +218,7 @@ namespace vk case rsx::blend_factor::one_minus_constant_alpha: return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA; case rsx::blend_factor::one_minus_constant_color: return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR; default: - throw EXCEPTION("Unknown blend factor 0x%X", factor); + throw EXCEPTION("Unknown blend factor 0x%x", (u32)factor); } }; @@ -232,7 +232,7 @@ namespace vk case rsx::blend_equation::min: return VK_BLEND_OP_MIN; case rsx::blend_equation::max: return VK_BLEND_OP_MAX; default: - throw EXCEPTION("Unknown blend op: 0x%X", op); + throw EXCEPTION("Unknown blend op: 0x%x", (u32)op); } } @@ -250,7 +250,7 @@ namespace vk case rsx::stencil_op::incr_wrap: return VK_STENCIL_OP_INCREMENT_AND_WRAP; case rsx::stencil_op::decr_wrap: return VK_STENCIL_OP_DECREMENT_AND_WRAP; default: - throw EXCEPTION("Unknown stencil op: 0x%X", op); + throw EXCEPTION("Unknown stencil op: 0x%x", (u32)op); } } @@ -261,7 +261,7 @@ namespace vk case rsx::front_face::cw: return VK_FRONT_FACE_CLOCKWISE; case rsx::front_face::ccw: return VK_FRONT_FACE_COUNTER_CLOCKWISE; default: - throw EXCEPTION("Unknown front face value: 0x%X", ffv); + throw EXCEPTION("Unknown front face value: 0x%x", (u32)ffv); } } @@ -274,7 +274,7 @@ namespace vk case CELL_GCM_FRONT_AND_BACK: return VK_CULL_MODE_FRONT_AND_BACK; default: return VK_CULL_MODE_NONE; } - throw EXCEPTION("Unknown cull face value: 0x%X", cfv); + throw EXCEPTION("Unknown cull face value: 0x%x", (u32)cfv); } } @@ -861,7 +861,7 @@ bool VKGSRender::load_program() if (rsx::method_registers.restart_index() != 0xFFFF && rsx::method_registers.restart_index() != 0xFFFFFFFF) { - LOG_ERROR(RSX, "Custom primitive restart index 0x%X. Should rewrite index buffer with proper value!", rsx::method_registers.restart_index()); + LOG_ERROR(RSX, "Custom primitive restart index 0x%x should rewrite index buffer with proper value!", rsx::method_registers.restart_index()); } properties.ia.primitiveRestartEnable = VK_TRUE; } diff --git a/rpcs3/Emu/RSX/VK/VKHelpers.h b/rpcs3/Emu/RSX/VK/VKHelpers.h index 20f317b0dc..2ad7df1e96 100644 --- a/rpcs3/Emu/RSX/VK/VKHelpers.h +++ b/rpcs3/Emu/RSX/VK/VKHelpers.h @@ -24,7 +24,7 @@ namespace rsx namespace vk { -#define CHECK_RESULT(expr) { VkResult __res = expr; if(__res != VK_SUCCESS) throw EXCEPTION("Assertion failed! Result is %Xh", __res); } +#define CHECK_RESULT(expr) do { VkResult _res = (expr); if (_res != VK_SUCCESS) throw fmt::exception("Assertion failed! Result is %Xh", (s32)_res); } while (0) VKAPI_ATTR void *VKAPI_CALL mem_realloc(void *pUserData, void *pOriginal, size_t size, size_t alignment, VkSystemAllocationScope allocationScope); VKAPI_ATTR void *VKAPI_CALL mem_alloc(void *pUserData, size_t size, size_t alignment, VkSystemAllocationScope allocationScope); diff --git a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp index 2e851f43d7..84752f89c2 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp @@ -49,7 +49,7 @@ namespace vk const VkFormat* vec_selectors[] = { 0, vec1_types, vec2_types, vec3_types, vec4_types }; if (type > rsx::vertex_base_type::ub256) - throw EXCEPTION("VKGS error: unknown vertex base type 0x%X.", (u32)type); + throw EXCEPTION("VKGS error: unknown vertex base type 0x%x", (u32)type); return vec_selectors[size][(int)type]; } @@ -425,7 +425,7 @@ VKGSRender::upload_vertex_data() vk::copy_inlined_data_to_buffer(src, dst, vertex_draw_count, vertex_info.type, vertex_info.size, opt_size, element_size, stride); break; default: - throw EXCEPTION("Unknown base type %d", vertex_info.type); + throw EXCEPTION("Unknown base type %d", (u32)vertex_info.type); } m_attrib_ring_info.unmap(); @@ -545,7 +545,7 @@ VKGSRender::upload_vertex_data() break; } default: - LOG_ERROR(RSX, "bad non array vertex data format (type = %d, size = %d)", vertex_info.type, vertex_info.size); + LOG_ERROR(RSX, "bad non array vertex data format (type=%d, size=%d)", (u32)vertex_info.type, vertex_info.size); break; } } diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index 6a2728e692..68800e7aac 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -298,7 +298,7 @@ namespace rsx case blit_engine::context_dma::to_memory_get_report: location = CELL_GCM_LOCATION_LOCAL; break; case blit_engine::context_dma::report_location_main: location = CELL_GCM_LOCATION_MAIN; break; default: - LOG_WARNING(RSX, "nv4097::get_report: bad report dma: 0x%x", report_dma); + LOG_WARNING(RSX, "nv4097::get_report: bad report dma: 0x%x", (u8)report_dma); return; } @@ -406,12 +406,12 @@ namespace rsx if (in_origin != blit_engine::transfer_origin::corner) { - LOG_ERROR(RSX, "NV3089_IMAGE_IN_SIZE: unknown origin (%d)", in_origin); + LOG_ERROR(RSX, "NV3089_IMAGE_IN_SIZE: unknown origin (%d)", (u8)in_origin); } if (operation != rsx::blit_engine::transfer_operation::srccopy) { - LOG_ERROR(RSX, "NV3089_IMAGE_IN_SIZE: unknown operation (%d)", operation); + LOG_ERROR(RSX, "NV3089_IMAGE_IN_SIZE: unknown operation (%d)", (u8)operation); } const u32 src_offset = method_registers.blit_engine_input_offset(); @@ -440,7 +440,7 @@ namespace rsx break; default: - LOG_ERROR(RSX, "NV3089_IMAGE_IN_SIZE: unknown m_context_surface (0x%x)", method_registers.blit_engine_context_surface()); + LOG_ERROR(RSX, "NV3089_IMAGE_IN_SIZE: unknown m_context_surface (0x%x)", (u8)method_registers.blit_engine_context_surface()); return; } @@ -512,13 +512,13 @@ namespace rsx if (dst_color_format != rsx::blit_engine::transfer_destination_format::r5g6b5 && dst_color_format != rsx::blit_engine::transfer_destination_format::a8r8g8b8) { - LOG_ERROR(RSX, "NV3089_IMAGE_IN_SIZE: unknown dst_color_format (%d)", dst_color_format); + LOG_ERROR(RSX, "NV3089_IMAGE_IN_SIZE: unknown dst_color_format (%d)", (u8)dst_color_format); } if (src_color_format != rsx::blit_engine::transfer_source_format::r5g6b5 && src_color_format != rsx::blit_engine::transfer_source_format::a8r8g8b8) { - LOG_ERROR(RSX, "NV3089_IMAGE_IN_SIZE: unknown src_color_format (%d)", src_color_format); + LOG_ERROR(RSX, "NV3089_IMAGE_IN_SIZE: unknown src_color_format (%d)", (u8)src_color_format); } //LOG_WARNING(RSX, "NV3089_IMAGE_IN_SIZE: SIZE=0x%08x, pitch=0x%x, offset=0x%x, scaleX=%f, scaleY=%f, CLIP_SIZE=0x%08x, OUT_SIZE=0x%08x", diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index f5fc00bf19..f7ad3c12d4 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -121,10 +121,10 @@ public: void Resume(); void Stop(); - force_inline bool IsRunning() const { return m_status == Running; } - force_inline bool IsPaused() const { return m_status == Paused; } - force_inline bool IsStopped() const { return m_status == Stopped; } - force_inline bool IsReady() const { return m_status == Ready; } + bool IsRunning() const { return m_status == Running; } + bool IsPaused() const { return m_status == Paused; } + bool IsStopped() const { return m_status == Stopped; } + bool IsReady() const { return m_status == Ready; } }; extern Emulator Emu; diff --git a/rpcs3/Gui/SettingsDialog.cpp b/rpcs3/Gui/SettingsDialog.cpp index 4c7ef0cbc9..c61beade72 100644 --- a/rpcs3/Gui/SettingsDialog.cpp +++ b/rpcs3/Gui/SettingsDialog.cpp @@ -27,14 +27,14 @@ static YAML::Node loaded; static YAML::Node saved; // Emit sorted YAML -static never_inline void emit(YAML::Emitter& out, const YAML::Node& node) +static NEVER_INLINE void emit(YAML::Emitter& out, const YAML::Node& node) { // TODO out << node; } // Incrementally load YAML -static never_inline void operator +=(YAML::Node& left, const YAML::Node& node) +static NEVER_INLINE void operator +=(YAML::Node& left, const YAML::Node& node) { if (node && !node.IsNull()) { diff --git a/rpcs3/Loader/ELF.cpp b/rpcs3/Loader/ELF.cpp new file mode 100644 index 0000000000..8ace3d128b --- /dev/null +++ b/rpcs3/Loader/ELF.cpp @@ -0,0 +1,31 @@ +#include "stdafx.h" +#include "ELF.h" + +// ELF loading error information +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](elf_error error) + { + switch (error) + { + case elf_error::ok: return "OK"; + + case elf_error::stream: return "Invalid stream"; + case elf_error::stream_header: return "Failed to read ELF header"; + case elf_error::stream_phdrs: return "Failed to read ELF program headers"; + case elf_error::stream_shdrs: return "Failed to read ELF section headers"; + case elf_error::stream_data: return "Failed to read ELF program data"; + + case elf_error::header_magic: return "Not an ELF"; + case elf_error::header_version: return "Invalid or unsupported ELF format"; + case elf_error::header_class: return "Invalid ELF class"; + case elf_error::header_machine: return "Invalid ELF machine"; + case elf_error::header_endianness: return "Invalid ELF data (endianness)"; + case elf_error::header_type: return "Invalid ELF type"; + case elf_error::header_os: return "Invalid ELF OS ABI"; + } + + return unknown; + }); +} diff --git a/rpcs3/Loader/ELF.h b/rpcs3/Loader/ELF.h index e46d21afb9..6843890606 100644 --- a/rpcs3/Loader/ELF.h +++ b/rpcs3/Loader/ELF.h @@ -153,35 +153,6 @@ enum class elf_error header_os, }; -// ELF loading error information -template<> -struct unveil -{ - static inline const char* get(elf_error error) - { - switch (error) - { - case elf_error::ok: return "OK"; - - case elf_error::stream: return "Invalid stream"; - case elf_error::stream_header: return "Failed to read ELF header"; - case elf_error::stream_phdrs: return "Failed to read ELF program headers"; - case elf_error::stream_shdrs: return "Failed to read ELF section headers"; - case elf_error::stream_data: return "Failed to read ELF program data"; - - case elf_error::header_magic: return "Not an ELF"; - case elf_error::header_version: return "Invalid or unsupported ELF format"; - case elf_error::header_class: return "Invalid ELF class"; - case elf_error::header_machine: return "Invalid ELF machine"; - case elf_error::header_endianness: return "Invalid ELF data (endianness)"; - case elf_error::header_type: return "Invalid ELF type"; - case elf_error::header_os: return "Invalid ELF OS ABI"; - - default: throw error; - } - } -}; - // ELF object with specified parameters. // en_t: endianness (specify le_t or be_t) // sz_t: size (specify u32 for ELF32, u64 for ELF64) diff --git a/rpcs3/Loader/PSF.cpp b/rpcs3/Loader/PSF.cpp index 5d7da0130b..7dd269b756 100644 --- a/rpcs3/Loader/PSF.cpp +++ b/rpcs3/Loader/PSF.cpp @@ -1,6 +1,22 @@ #include "stdafx.h" #include "PSF.h" +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto fmt) + { + switch (fmt) + { + STR_CASE(psf::format::array); + STR_CASE(psf::format::string); + STR_CASE(psf::format::integer); + } + + return unknown; + }); +} + namespace psf { logs::channel log("PSF", logs::level::notice); diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index c84f9591aa..3221b190d6 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -367,6 +367,7 @@ + @@ -386,6 +387,7 @@ + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index d37e5f47cf..30ae6212e6 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -884,6 +884,9 @@ Emu\GPU\RSX + + Loader + @@ -1702,5 +1705,8 @@ Emu\GPU\RSX + + Utilities + \ No newline at end of file diff --git a/rpcs3/rpcs3.cpp b/rpcs3/rpcs3.cpp index f6754ae5af..ffa9a4f6d6 100644 --- a/rpcs3/rpcs3.cpp +++ b/rpcs3/rpcs3.cpp @@ -175,7 +175,7 @@ bool Rpcs3App::OnInit() case frame_type::Vulkan: return std::make_unique("Vulkan", w, h); } - throw EXCEPTION("Invalid Frame Type (0x%x)", type); + throw fmt::exception("Invalid frame type (0x%x)" HERE, (int)type); }; callbacks.get_gs_render = PURE_EXPR(g_cfg_gs_render.get()());