diff --git a/Utilities/File.cpp b/Utilities/File.cpp index f1f52ae81..9ea37fbad 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -1715,7 +1715,7 @@ u64 fs::get_dir_size(const std::string& path, u64 rounding_alignment) if (!root_dir) { - return static_cast(umax); + return -1; } for (const auto& entry : root_dir) diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index 488508a86..4420e76d7 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -236,6 +236,12 @@ void fmt_class_string::format(std::string& out, u64 arg) out += arg ? "true" : "false"; } +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + out += get_object(arg) ? "true" : "false"; +} + template <> void fmt_class_string::format(std::string& out, u64 arg) { diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 599b0f86d..551344aac 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -64,17 +64,6 @@ struct fmt_unveil::value && sizeof } }; -template <> -struct fmt_unveil -{ - using type = f16; - - static inline u64 get(const f16& arg) - { - return fmt_unveil::get(arg.operator float()); - } -}; - template struct fmt_unveil::value>> { @@ -108,17 +97,6 @@ struct fmt_unveil } }; -template <> -struct fmt_unveil -{ - using type = bool; - - static inline u64 get(const b8& value) - { - return fmt_unveil::get(value); - } -}; - template struct fmt_unveil, void> { diff --git a/Utilities/sync.h b/Utilities/sync.h index 8370369c0..96b610ddb 100644 --- a/Utilities/sync.h +++ b/Utilities/sync.h @@ -71,7 +71,7 @@ inline int futex(volatile void* uaddr, int futex_op, uint val, const timespec* t }; std::mutex mutex; - std::unordered_multimap> map; + std::unordered_multimap map; int operator()(volatile void* uaddr, int futex_op, uint val, const timespec* timeout, uint mask) { diff --git a/rpcs3/Emu/Cell/Modules/libmixer.cpp b/rpcs3/Emu/Cell/Modules/libmixer.cpp index ec3b3dba6..813a12765 100644 --- a/rpcs3/Emu/Cell/Modules/libmixer.cpp +++ b/rpcs3/Emu/Cell/Modules/libmixer.cpp @@ -433,7 +433,7 @@ struct surmixer_thread : ppu_thread g_surmx.mixdata[i * 8 + 1] += right; } if ((p.m_position == p.m_samples && p.m_speed > 0.0f) || - (p.m_position = umax && p.m_speed < 0.0f)) // loop or stop + (p.m_position == umax && p.m_speed < 0.0f)) // loop or stop { if (p.m_loop_mode == CELL_SSPLAYER_LOOP_ON) { diff --git a/rpcs3/Emu/Io/KeyboardHandler.h b/rpcs3/Emu/Io/KeyboardHandler.h index 33c948f34..53ff9dfa6 100644 --- a/rpcs3/Emu/Io/KeyboardHandler.h +++ b/rpcs3/Emu/Io/KeyboardHandler.h @@ -3,6 +3,7 @@ #include "Keyboard.h" #include +#include #include "util/init_mutex.hpp" diff --git a/rpcs3/Emu/Io/MouseHandler.h b/rpcs3/Emu/Io/MouseHandler.h index dc312900c..e836c8c89 100644 --- a/rpcs3/Emu/Io/MouseHandler.h +++ b/rpcs3/Emu/Io/MouseHandler.h @@ -2,6 +2,7 @@ #include #include +#include #include "Utilities/mutex.h" #include "util/init_mutex.hpp" diff --git a/rpcs3/Emu/Io/PadHandler.h b/rpcs3/Emu/Io/PadHandler.h index 0de911141..887123fdd 100644 --- a/rpcs3/Emu/Io/PadHandler.h +++ b/rpcs3/Emu/Io/PadHandler.h @@ -1,11 +1,17 @@ #pragma once -#include #include "pad_types.h" #include "pad_config.h" #include "pad_config_types.h" #include "util/types.hpp" +#include +#include +#include +#include +#include +#include + struct PadDevice { pad_config* config{ nullptr }; diff --git a/rpcs3/Emu/NP/np_handler.h b/rpcs3/Emu/NP/np_handler.h index 190895da5..002e2f3f4 100644 --- a/rpcs3/Emu/NP/np_handler.h +++ b/rpcs3/Emu/NP/np_handler.h @@ -2,6 +2,7 @@ #include #include +#include #include "Emu/Memory/vm_ptr.h" #include "Emu/Cell/Modules/sceNp.h" diff --git a/rpcs3/Emu/RSX/Capture/rsx_replay.h b/rpcs3/Emu/RSX/Capture/rsx_replay.h index 2c2a7519e..ff3422f2d 100644 --- a/rpcs3/Emu/RSX/Capture/rsx_replay.h +++ b/rpcs3/Emu/RSX/Capture/rsx_replay.h @@ -2,6 +2,7 @@ #include "Emu/CPU/CPUThread.h" #include "Emu/RSX/rsx_methods.h" +#include #include #include diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.h b/rpcs3/Emu/RSX/Common/ProgramStateCache.h index fcfda0b81..0c83bdccb 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.h +++ b/rpcs3/Emu/RSX/Common/ProgramStateCache.h @@ -9,6 +9,7 @@ #include "Utilities/span.h" #include +#include enum class SHADER_TYPE { diff --git a/rpcs3/Emu/RSX/Common/ShaderParam.h b/rpcs3/Emu/RSX/Common/ShaderParam.h index 5ff5d4653..1a2d0f929 100644 --- a/rpcs3/Emu/RSX/Common/ShaderParam.h +++ b/rpcs3/Emu/RSX/Common/ShaderParam.h @@ -6,6 +6,8 @@ #include "Utilities/StrUtil.h" #include "util/types.hpp" +#include + enum class FUNCTION { FUNCTION_DP2, diff --git a/rpcs3/Emu/RSX/Common/surface_store.h b/rpcs3/Emu/RSX/Common/surface_store.h index 90fde1bd3..266110347 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.h +++ b/rpcs3/Emu/RSX/Common/surface_store.h @@ -7,6 +7,8 @@ #include "util/asm.hpp" +#include + namespace rsx { namespace utility diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 7809e6b30..cf0994975 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -4,6 +4,8 @@ #include "texture_cache_predictor.h" #include "texture_cache_helpers.h" +#include + extern u64 get_system_time(); #define RSX_GCM_FORMAT_IGNORED 0 diff --git a/rpcs3/Emu/RSX/Common/texture_cache_predictor.h b/rpcs3/Emu/RSX/Common/texture_cache_predictor.h index 8f33cf722..133e98088 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache_predictor.h +++ b/rpcs3/Emu/RSX/Common/texture_cache_predictor.h @@ -4,6 +4,8 @@ #include "../rsx_utils.h" #include "TextureUtils.h" +#include + namespace rsx { /** diff --git a/rpcs3/Emu/RSX/GL/GLCompute.h b/rpcs3/Emu/RSX/GL/GLCompute.h index 9ccfd21d6..3a7c394f0 100644 --- a/rpcs3/Emu/RSX/GL/GLCompute.h +++ b/rpcs3/Emu/RSX/GL/GLCompute.h @@ -5,6 +5,7 @@ #include "GLHelpers.h" #include "util/asm.hpp" +#include namespace gl { diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.h b/rpcs3/Emu/RSX/GL/GLGSRender.h index 17420a417..c56bd9cee 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.h +++ b/rpcs3/Emu/RSX/GL/GLGSRender.h @@ -10,6 +10,7 @@ #include "GLShaderInterpreter.h" #include +#include #ifdef _WIN32 #pragma comment(lib, "opengl32.lib") diff --git a/rpcs3/Emu/RSX/GL/GLHelpers.cpp b/rpcs3/Emu/RSX/GL/GLHelpers.cpp index c346d61c0..d20dfebcb 100644 --- a/rpcs3/Emu/RSX/GL/GLHelpers.cpp +++ b/rpcs3/Emu/RSX/GL/GLHelpers.cpp @@ -4,6 +4,8 @@ #include "GLCompute.h" #include "util/logs.hpp" +#include + namespace gl { std::unordered_map> g_compute_tasks; diff --git a/rpcs3/Emu/RSX/GL/GLOverlays.h b/rpcs3/Emu/RSX/GL/GLOverlays.h index 52b9f6052..d5c93420b 100644 --- a/rpcs3/Emu/RSX/GL/GLOverlays.h +++ b/rpcs3/Emu/RSX/GL/GLOverlays.h @@ -4,6 +4,7 @@ #include "GLHelpers.h" #include "../Overlays/overlays.h" #include +#include extern u64 get_system_time(); diff --git a/rpcs3/Emu/RSX/GL/GLShaderInterpreter.h b/rpcs3/Emu/RSX/GL/GLShaderInterpreter.h index cad5c8ab8..25102cd1d 100644 --- a/rpcs3/Emu/RSX/GL/GLShaderInterpreter.h +++ b/rpcs3/Emu/RSX/GL/GLShaderInterpreter.h @@ -3,6 +3,8 @@ #include "../Common/ProgramStateCache.h" #include "../Common/TextureUtils.h" +#include + namespace gl { using namespace ::glsl; diff --git a/rpcs3/Emu/RSX/GL/GLTextOut.h b/rpcs3/Emu/RSX/GL/GLTextOut.h index 9c8a5021b..52e5ab1b3 100644 --- a/rpcs3/Emu/RSX/GL/GLTextOut.h +++ b/rpcs3/Emu/RSX/GL/GLTextOut.h @@ -5,6 +5,7 @@ #include "../Common/TextGlyphs.h" #include #include +#include namespace gl { diff --git a/rpcs3/Emu/RSX/GL/GLTexture.h b/rpcs3/Emu/RSX/GL/GLTexture.h index 19a51eddd..cecc13b90 100644 --- a/rpcs3/Emu/RSX/GL/GLTexture.h +++ b/rpcs3/Emu/RSX/GL/GLTexture.h @@ -5,6 +5,8 @@ #include "../Common/TextureUtils.h" #include "GLHelpers.h" +#include + namespace rsx { class vertex_texture; diff --git a/rpcs3/Emu/RSX/GL/GLVertexProgram.h b/rpcs3/Emu/RSX/GL/GLVertexProgram.h index bf3b11ab4..bf95df95e 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexProgram.h +++ b/rpcs3/Emu/RSX/GL/GLVertexProgram.h @@ -3,6 +3,8 @@ #include "Emu/RSX/RSXVertexProgram.h" #include "GLHelpers.h" +#include + enum { GL_VP_FORCE_ATTRIB_SCALING = 1, //Scale vertex read result diff --git a/rpcs3/Emu/RSX/Overlays/overlay_utils.cpp b/rpcs3/Emu/RSX/Overlays/overlay_utils.cpp index 0db4b3440..4be5d07c7 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_utils.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_utils.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "overlay_utils.h" +#include + LOG_CHANNEL(overlays); static auto s_ascii_lowering_map = []() diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index 9477337fb..dec6dba0b 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "GCM.h" #include "rsx_cache.h" diff --git a/rpcs3/Emu/RSX/VK/VKCompute.h b/rpcs3/Emu/RSX/VK/VKCompute.h index b09a91f3f..d3d044cae 100644 --- a/rpcs3/Emu/RSX/VK/VKCompute.h +++ b/rpcs3/Emu/RSX/VK/VKCompute.h @@ -6,6 +6,7 @@ #include "Emu/IdManager.h" #include "util/asm.hpp" +#include #define VK_MAX_COMPUTE_TASKS 4096 // Max number of jobs per frame diff --git a/rpcs3/Emu/RSX/VK/VKDMA.cpp b/rpcs3/Emu/RSX/VK/VKDMA.cpp index 81437cef2..1c9e82445 100644 --- a/rpcs3/Emu/RSX/VK/VKDMA.cpp +++ b/rpcs3/Emu/RSX/VK/VKDMA.cpp @@ -4,6 +4,7 @@ #include "VKDMA.h" #include "util/asm.hpp" +#include namespace vk { diff --git a/rpcs3/Emu/RSX/VK/VKFramebuffer.cpp b/rpcs3/Emu/RSX/VK/VKFramebuffer.cpp index 39dfe54c1..3a3f286fd 100644 --- a/rpcs3/Emu/RSX/VK/VKFramebuffer.cpp +++ b/rpcs3/Emu/RSX/VK/VKFramebuffer.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "VKFramebuffer.h" +#include namespace vk { diff --git a/rpcs3/Emu/RSX/VK/VKHelpers.cpp b/rpcs3/Emu/RSX/VK/VKHelpers.cpp index 673a54b53..e68157318 100644 --- a/rpcs3/Emu/RSX/VK/VKHelpers.cpp +++ b/rpcs3/Emu/RSX/VK/VKHelpers.cpp @@ -13,6 +13,7 @@ #include "Emu/RSX/rsx_methods.h" #include "Utilities/mutex.h" #include "Utilities/lockless.h" +#include namespace vk { diff --git a/rpcs3/Emu/RSX/VK/VKOverlays.h b/rpcs3/Emu/RSX/VK/VKOverlays.h index a337094e4..19e4fb09f 100644 --- a/rpcs3/Emu/RSX/VK/VKOverlays.h +++ b/rpcs3/Emu/RSX/VK/VKOverlays.h @@ -11,6 +11,7 @@ #include "../Overlays/overlays.h" #include "Utilities/hash.h" +#include #define VK_OVERLAY_MAX_DRAW_CALLS 1024 diff --git a/rpcs3/Emu/RSX/VK/VKResourceManager.h b/rpcs3/Emu/RSX/VK/VKResourceManager.h index b56319807..3110cd680 100644 --- a/rpcs3/Emu/RSX/VK/VKResourceManager.h +++ b/rpcs3/Emu/RSX/VK/VKResourceManager.h @@ -1,6 +1,10 @@ #pragma once #include "VKHelpers.h" +#include +#include +#include + namespace vk { u64 get_event_id(); diff --git a/rpcs3/Emu/RSX/VK/VKShaderInterpreter.h b/rpcs3/Emu/RSX/VK/VKShaderInterpreter.h index c62e7cdc6..f06daab34 100644 --- a/rpcs3/Emu/RSX/VK/VKShaderInterpreter.h +++ b/rpcs3/Emu/RSX/VK/VKShaderInterpreter.h @@ -1,5 +1,6 @@ #pragma once #include "VKProgramBuffer.h" +#include namespace vk { diff --git a/rpcs3/Emu/RSX/VK/VKTextOut.h b/rpcs3/Emu/RSX/VK/VKTextOut.h index aecfe26d9..165a17790 100644 --- a/rpcs3/Emu/RSX/VK/VKTextOut.h +++ b/rpcs3/Emu/RSX/VK/VKTextOut.h @@ -5,6 +5,7 @@ #include "VKRenderPass.h" #include "VKPipelineCompiler.h" #include "../Common/TextGlyphs.h" +#include namespace vk { diff --git a/rpcs3/Emu/RSX/rsx_cache.h b/rpcs3/Emu/RSX/rsx_cache.h index df25937f0..6fedcf575 100644 --- a/rpcs3/Emu/RSX/rsx_cache.h +++ b/rpcs3/Emu/RSX/rsx_cache.h @@ -13,7 +13,7 @@ #include "rsx_utils.h" #include #include - +#include #include "util/vm.hpp" diff --git a/rpcs3/Input/ds3_pad_handler.h b/rpcs3/Input/ds3_pad_handler.h index 52a10d217..a727fe661 100644 --- a/rpcs3/Input/ds3_pad_handler.h +++ b/rpcs3/Input/ds3_pad_handler.h @@ -4,6 +4,8 @@ #include "hidapi.h" +#include + class ds3_pad_handler final : public PadHandlerBase { enum DS3KeyCodes diff --git a/rpcs3/Input/ds4_pad_handler.h b/rpcs3/Input/ds4_pad_handler.h index f47f25d9b..06d557df6 100644 --- a/rpcs3/Input/ds4_pad_handler.h +++ b/rpcs3/Input/ds4_pad_handler.h @@ -4,6 +4,8 @@ #include "Utilities/CRC.h" #include "hidapi.h" +#include + class ds4_pad_handler final : public PadHandlerBase { // These are all the possible buttons on a standard DS4 controller diff --git a/rpcs3/Input/dualsense_pad_handler.h b/rpcs3/Input/dualsense_pad_handler.h index f25404716..e3fd60eb6 100644 --- a/rpcs3/Input/dualsense_pad_handler.h +++ b/rpcs3/Input/dualsense_pad_handler.h @@ -4,6 +4,8 @@ #include "Utilities/CRC.h" #include "hidapi.h" +#include + class dualsense_pad_handler final : public PadHandlerBase { enum DualSenseKeyCodes diff --git a/rpcs3/Input/xinput_pad_handler.h b/rpcs3/Input/xinput_pad_handler.h index 686a4094d..8ca0c8268 100644 --- a/rpcs3/Input/xinput_pad_handler.h +++ b/rpcs3/Input/xinput_pad_handler.h @@ -1,6 +1,9 @@ #pragma once #include "Emu/Io/PadHandler.h" + +#include + #ifndef NOMINMAX #define NOMINMAX #endif diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index c35a2f979..5e7ae6701 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include diff --git a/rpcs3/rpcs3qt/patch_manager_dialog.h b/rpcs3/rpcs3qt/patch_manager_dialog.h index b77923539..13a0bcb82 100644 --- a/rpcs3/rpcs3qt/patch_manager_dialog.h +++ b/rpcs3/rpcs3qt/patch_manager_dialog.h @@ -6,6 +6,7 @@ #include #include "Utilities/bin_patch.h" +#include namespace Ui { diff --git a/rpcs3/rpcs3qt/rsx_debugger.cpp b/rpcs3/rpcs3qt/rsx_debugger.cpp index 8cd7440f8..8435e0c0d 100644 --- a/rpcs3/rpcs3qt/rsx_debugger.cpp +++ b/rpcs3/rpcs3qt/rsx_debugger.cpp @@ -401,6 +401,19 @@ void Buffer::ShowWindowed() namespace { + f32 f16_to_f32(f16 val) + { + // See http://stackoverflow.com/a/26779139 + // The conversion doesn't handle NaN/Inf + + const u16 _u16 = static_cast(val); + const u32 raw = ((_u16 & 0x8000) << 16) | // Sign (just moved) + (((_u16 & 0x7c00) + 0x1C000) << 13) | // Exponent ( exp - 15 + 127) + ((_u16 & 0x03FF) << 13); // Mantissa + + return std::bit_cast(raw); + } + std::array get_value(gsl::span orig_buffer, rsx::surface_color_format format, usz idx) { switch (format) @@ -438,9 +451,9 @@ namespace const f16 h0 = f16(ptr[4 * idx]); const f16 h1 = f16(ptr[4 * idx + 1]); const f16 h2 = f16(ptr[4 * idx + 2]); - const f32 f0 = float(h0); - const f32 f1 = float(h1); - const f32 f2 = float(h2); + const f32 f0 = f16_to_f32(h0); + const f32 f1 = f16_to_f32(h1); + const f32 f2 = f16_to_f32(h2); const u8 val0 = f0 * 255.; const u8 val1 = f1 * 255.; diff --git a/rpcs3/util/types.hpp b/rpcs3/util/types.hpp index e4bd3bf7f..ae0e8b7d2 100644 --- a/rpcs3/util/types.hpp +++ b/rpcs3/util/types.hpp @@ -48,9 +48,7 @@ using namespace std::literals; #define AUDIT(...) (static_cast(0)) #endif -#if __cpp_lib_bit_cast >= 201806L -#include -#else +#if __cpp_lib_bit_cast < 201806L namespace std { template > @@ -64,7 +62,7 @@ namespace std } To result{}; - std::memcpy(&result, &from, sizeof(From)); + __builtin_memcpy(&result, &from, sizeof(From)); return result; } } @@ -152,36 +150,29 @@ template <> struct get_int_impl { using utype = u8; - using stype = s8; }; template <> struct get_int_impl { using utype = u16; - using stype = s16; }; template <> struct get_int_impl { using utype = u32; - using stype = s32; }; template <> struct get_int_impl { using utype = u64; - using stype = s64; }; template using get_uint_t = typename get_int_impl::utype; -template -using get_sint_t = typename get_int_impl::stype; - template std::remove_cvref_t as_rvalue(T&& obj) { @@ -529,12 +520,6 @@ constexpr inline struct umax_helper { constexpr umax_helper() noexcept = default; - template , typename = std::enable_if_t>> - explicit constexpr operator T() const - { - return static_cast(-1); - } - template , typename = std::enable_if_t>> constexpr bool operator==(const T& rhs) const { @@ -566,30 +551,11 @@ constexpr inline struct umax_helper #endif } umax; +enum class f16 : u16{}; + using f32 = float; using f64 = double; -struct f16 -{ - u16 _u16; - - explicit f16(u16 raw) - { - _u16 = raw; - } - - explicit operator f32() const - { - // See http://stackoverflow.com/a/26779139 - // The conversion doesn't handle NaN/Inf - u32 raw = ((_u16 & 0x8000) << 16) | // Sign (just moved) - (((_u16 & 0x7c00) + 0x1C000) << 13) | // Exponent ( exp - 15 + 127) - ((_u16 & 0x03FF) << 13); // Mantissa - - return std::bit_cast(raw); - } -}; - template inline u32 offset32(T T2::*const mptr) { @@ -855,16 +821,7 @@ template return static_cast(Size); } -// Simplified hash algorithm for pointers. May be used in std::unordered_(map|set). -template -struct pointer_hash -{ - usz operator()(T* ptr) const - { - return reinterpret_cast(ptr) / Align; - } -}; - +// Simplified hash algorithm. May be used in std::unordered_(map|set). template struct value_hash {