From fb29933d3d1aaa5ee62dc57ac4e70f227a0e0b00 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 18 Dec 2020 10:39:54 +0300 Subject: [PATCH] Add usz alias for std::size_t --- Utilities/CPUStats.h | 4 +- Utilities/File.cpp | 20 ++++----- Utilities/File.h | 8 ++-- Utilities/JIT.cpp | 16 +++---- Utilities/JIT.h | 2 +- Utilities/StrFmt.cpp | 42 ++++++++--------- Utilities/StrFmt.h | 18 ++++---- Utilities/StrUtil.h | 18 ++++---- Utilities/Thread.cpp | 32 ++++++------- Utilities/Thread.h | 2 +- Utilities/address_range.h | 16 +++---- Utilities/bin_patch.cpp | 18 ++++---- Utilities/bin_patch.h | 8 ++-- Utilities/bit_set.h | 4 +- Utilities/cfmt.h | 42 ++++++++--------- Utilities/hash.h | 12 ++--- Utilities/lockless.h | 10 ++--- Utilities/sysinfo.cpp | 8 ++-- Utilities/typemap.h | 38 ++++++++-------- Utilities/version.cpp | 2 +- rpcs3/Crypto/unedat.cpp | 4 +- rpcs3/Crypto/unpkg.cpp | 4 +- rpcs3/Crypto/unpkg.h | 10 ++--- rpcs3/Crypto/unself.cpp | 10 ++--- rpcs3/Emu/CPU/CPUDisAsm.h | 2 +- rpcs3/Emu/CPU/CPUTranslator.h | 4 +- rpcs3/Emu/Cell/Modules/StaticHLE.cpp | 2 +- rpcs3/Emu/Cell/Modules/StaticHLE.h | 2 +- rpcs3/Emu/Cell/Modules/cellAudio.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellCelp8Enc.h | 2 +- rpcs3/Emu/Cell/Modules/cellCelpEnc.h | 2 +- rpcs3/Emu/Cell/Modules/cellDmux.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellGcmSys.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellImeJp.cpp | 8 ++-- rpcs3/Emu/Cell/Modules/cellImeJp.h | 4 +- rpcs3/Emu/Cell/Modules/cellJpgDec.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellL10n.cpp | 10 ++--- rpcs3/Emu/Cell/Modules/cellMic.h | 4 +- rpcs3/Emu/Cell/Modules/cellPngDec.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellPngDec.h | 4 +- rpcs3/Emu/Cell/Modules/cellPngEnc.h | 12 ++--- rpcs3/Emu/Cell/Modules/cellResc.h | 2 +- rpcs3/Emu/Cell/Modules/cellSaveData.cpp | 2 +- rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp | 4 +- rpcs3/Emu/Cell/Modules/sceNpTus.cpp | 4 +- rpcs3/Emu/Cell/Modules/sys_libc_.cpp | 32 ++++++------- rpcs3/Emu/Cell/PPUAnalyser.cpp | 4 +- rpcs3/Emu/Cell/PPUAnalyser.h | 8 ++-- rpcs3/Emu/Cell/PPUModule.cpp | 6 +-- rpcs3/Emu/Cell/PPUThread.cpp | 8 ++-- rpcs3/Emu/Cell/PPUThread.h | 2 +- rpcs3/Emu/Cell/PPUTranslator.cpp | 2 +- rpcs3/Emu/Cell/PPUTranslator.h | 8 ++-- rpcs3/Emu/Cell/SPURecompiler.cpp | 12 ++--- rpcs3/Emu/Cell/lv2/lv2.cpp | 8 ++-- rpcs3/Emu/Cell/lv2/sys_config.h | 8 ++-- rpcs3/Emu/Cell/lv2/sys_fs.cpp | 6 +-- rpcs3/Emu/Cell/lv2/sys_net.cpp | 6 +-- rpcs3/Emu/Cell/lv2/sys_net.h | 4 +- rpcs3/Emu/Cell/lv2/sys_overlay.h | 2 +- rpcs3/Emu/Cell/lv2/sys_process.cpp | 2 +- rpcs3/Emu/Cell/lv2/sys_rsx.cpp | 6 +-- rpcs3/Emu/Cell/lv2/sys_tty.cpp | 8 ++-- rpcs3/Emu/GDB.cpp | 10 ++--- rpcs3/Emu/Io/PadHandler.cpp | 4 +- rpcs3/Emu/Io/PadHandler.h | 4 +- rpcs3/Emu/Memory/vm.cpp | 2 +- rpcs3/Emu/NP/fb_helpers.cpp | 10 ++--- rpcs3/Emu/NP/np_handler.cpp | 6 +-- rpcs3/Emu/NP/np_handler.h | 2 +- rpcs3/Emu/NP/rpcn_client.cpp | 22 ++++----- rpcs3/Emu/NP/rpcn_client.h | 8 ++-- rpcs3/Emu/RSX/Capture/rsx_capture.cpp | 8 ++-- rpcs3/Emu/RSX/Capture/rsx_replay.cpp | 2 +- rpcs3/Emu/RSX/CgBinaryProgram.h | 8 ++-- .../RSX/Common/FragmentProgramDecompiler.h | 8 ++-- rpcs3/Emu/RSX/Common/GLSLCommon.h | 4 +- rpcs3/Emu/RSX/Common/ProgramStateCache.cpp | 28 ++++++------ rpcs3/Emu/RSX/Common/ProgramStateCache.h | 22 ++++----- rpcs3/Emu/RSX/Common/ShaderParam.h | 2 +- rpcs3/Emu/RSX/Common/TextGlyphs.h | 4 +- rpcs3/Emu/RSX/Common/TextureUtils.cpp | 42 ++++++++--------- rpcs3/Emu/RSX/Common/TextureUtils.h | 12 ++--- .../Emu/RSX/Common/VertexProgramDecompiler.h | 10 ++--- rpcs3/Emu/RSX/Common/ring_buffer_helper.h | 36 +++++++-------- rpcs3/Emu/RSX/Common/surface_store.cpp | 4 +- rpcs3/Emu/RSX/Common/surface_store.h | 10 ++--- rpcs3/Emu/RSX/Common/surface_utils.h | 2 +- rpcs3/Emu/RSX/Common/texture_cache.h | 12 ++--- rpcs3/Emu/RSX/Common/texture_cache_checker.h | 10 ++--- .../Emu/RSX/Common/texture_cache_predictor.h | 10 ++--- rpcs3/Emu/RSX/Common/texture_cache_utils.h | 6 +-- rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp | 6 +-- rpcs3/Emu/RSX/GL/GLFragmentProgram.h | 6 +-- rpcs3/Emu/RSX/GL/GLHelpers.cpp | 4 +- rpcs3/Emu/RSX/GL/GLHelpers.h | 4 +- rpcs3/Emu/RSX/GL/GLProgramBuffer.h | 4 +- rpcs3/Emu/RSX/GL/GLRenderTargets.h | 14 +++--- rpcs3/Emu/RSX/GL/GLTextOut.h | 4 +- rpcs3/Emu/RSX/GL/GLTexture.cpp | 2 +- rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp | 4 +- rpcs3/Emu/RSX/GL/GLVertexProgram.cpp | 4 +- rpcs3/Emu/RSX/GL/GLVertexProgram.h | 4 +- rpcs3/Emu/RSX/Overlays/overlay_controls.h | 6 +-- rpcs3/Emu/RSX/Overlays/overlay_edit_text.cpp | 26 +++++------ rpcs3/Emu/RSX/Overlays/overlay_fonts.cpp | 2 +- rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp | 2 +- rpcs3/Emu/RSX/Overlays/overlay_osk.cpp | 8 ++-- rpcs3/Emu/RSX/Overlays/overlay_osk.h | 2 +- rpcs3/Emu/RSX/VK/VKDMA.cpp | 8 ++-- rpcs3/Emu/RSX/VK/VKDMA.h | 6 +-- rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp | 6 +-- rpcs3/Emu/RSX/VK/VKFragmentProgram.h | 6 +-- rpcs3/Emu/RSX/VK/VKGSRender.cpp | 14 +++--- rpcs3/Emu/RSX/VK/VKHelpers.cpp | 14 +++--- rpcs3/Emu/RSX/VK/VKHelpers.h | 20 ++++----- rpcs3/Emu/RSX/VK/VKPipelineCompiler.h | 4 +- rpcs3/Emu/RSX/VK/VKPresent.cpp | 2 +- rpcs3/Emu/RSX/VK/VKProgramBuffer.h | 4 +- rpcs3/Emu/RSX/VK/VKRenderTargets.h | 14 +++--- rpcs3/Emu/RSX/VK/VKShaderInterpreter.h | 4 +- rpcs3/Emu/RSX/VK/VKTextOut.h | 6 +-- rpcs3/Emu/RSX/VK/VKTexture.cpp | 2 +- rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp | 12 ++--- rpcs3/Emu/RSX/VK/VKVertexProgram.cpp | 4 +- rpcs3/Emu/RSX/VK/VKVertexProgram.h | 4 +- rpcs3/Emu/RSX/gcm_printing.cpp | 20 ++++----- rpcs3/Emu/RSX/rsx_decode.h | 6 +-- rpcs3/Emu/RSX/rsx_methods.cpp | 6 +-- rpcs3/Emu/RSX/rsx_methods.h | 2 +- rpcs3/Emu/RSX/rsx_utils.h | 2 +- rpcs3/Emu/System.cpp | 16 +++---- rpcs3/Emu/VFS.cpp | 8 ++-- rpcs3/Emu/perf_meter.hpp | 2 +- rpcs3/Emu/title.cpp | 2 +- rpcs3/Input/ds3_pad_handler.cpp | 6 +-- rpcs3/Input/ds4_pad_handler.cpp | 4 +- rpcs3/Input/dualsense_pad_handler.cpp | 12 ++--- rpcs3/Input/xinput_pad_handler.cpp | 6 +-- rpcs3/Loader/PSF.cpp | 4 +- rpcs3/Loader/PUP.cpp | 2 +- rpcs3/Loader/TAR.cpp | 2 +- rpcs3/Loader/TAR.h | 2 +- rpcs3/Loader/TROPUSR.cpp | 4 +- rpcs3/main.cpp | 4 +- rpcs3/rpcs3qt/auto_pause_settings_dialog.cpp | 6 +-- rpcs3/rpcs3qt/cheat_manager.cpp | 4 +- rpcs3/rpcs3qt/downloader.cpp | 8 ++-- rpcs3/rpcs3qt/downloader.h | 4 +- rpcs3/rpcs3qt/gs_frame.cpp | 6 +-- rpcs3/rpcs3qt/input_dialog.cpp | 2 +- rpcs3/rpcs3qt/kernel_explorer.cpp | 2 +- rpcs3/rpcs3qt/kernel_explorer.h | 2 +- rpcs3/rpcs3qt/main_window.cpp | 6 +-- rpcs3/rpcs3qt/pad_settings_dialog.cpp | 8 ++-- rpcs3/rpcs3qt/patch_manager_dialog.cpp | 4 +- rpcs3/rpcs3qt/render_creator.cpp | 2 +- rpcs3/rpcs3qt/rsx_debugger.cpp | 8 ++-- rpcs3/rpcs3qt/save_manager_dialog.cpp | 2 +- rpcs3/rpcs3qt/trophy_manager_dialog.cpp | 2 +- rpcs3/rpcs3qt/update_manager.cpp | 14 +++--- rpcs3/util/asm.hpp | 2 +- rpcs3/util/atomic.cpp | 2 +- rpcs3/util/atomic.hpp | 14 +++--- rpcs3/util/endian.hpp | 12 ++--- rpcs3/util/logs.cpp | 6 +-- rpcs3/util/logs.hpp | 2 +- rpcs3/util/shared_ptr.hpp | 18 ++++---- rpcs3/util/to_endian.hpp | 2 +- rpcs3/util/types.hpp | 45 ++++++++++--------- rpcs3/util/v128.hpp | 16 +++---- rpcs3/util/vm.hpp | 14 +++--- rpcs3/util/vm_native.cpp | 14 +++--- 173 files changed, 718 insertions(+), 717 deletions(-) diff --git a/Utilities/CPUStats.h b/Utilities/CPUStats.h index dde51bf323..3190bee02e 100644 --- a/Utilities/CPUStats.h +++ b/Utilities/CPUStats.h @@ -176,7 +176,7 @@ public: }; u_int miblen = std::size(mib); struct kinfo_proc info; - size_t size = sizeof(info); + usz size = sizeof(info); if (sysctl(mib, miblen, &info, &size, NULL, 0)) { return 0; @@ -194,7 +194,7 @@ public: u_int miblen = std::size(mib); // get number of structs - size_t size; + usz size; if (sysctl(mib, miblen, NULL, &size, NULL, 0)) { return 0; diff --git a/Utilities/File.cpp b/Utilities/File.cpp index 92ddcb82ce..141251b5c0 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -20,7 +20,7 @@ using namespace std::literals::string_literals; static std::unique_ptr to_wchar(const std::string& source) { // String size + null terminator - const std::size_t buf_size = source.size() + 1; + const usz buf_size = source.size() + 1; // Safe size const int size = narrow(buf_size); @@ -51,7 +51,7 @@ static std::unique_ptr to_wchar(const std::string& source) static void to_utf8(std::string& out, const wchar_t* source) { // String size - const std::size_t length = std::wcslen(source); + const usz length = std::wcslen(source); // Safe buffer size for max possible output length (including null terminator) const int buf_size = narrow(length * 3 + 1); @@ -181,7 +181,7 @@ static std::string path_append(std::string_view path, std::string_view more) { std::string result; - if (const size_t src_slash_pos = path.find_last_not_of('/'); src_slash_pos != path.npos) + if (const usz src_slash_pos = path.find_last_not_of('/'); src_slash_pos != path.npos) { path.remove_suffix(path.length() - src_slash_pos - 1); result = path; @@ -189,7 +189,7 @@ static std::string path_append(std::string_view path, std::string_view more) result.push_back('/'); - if (const size_t dst_slash_pos = more.find_first_not_of('/'); dst_slash_pos != more.npos) + if (const usz dst_slash_pos = more.find_first_not_of('/'); dst_slash_pos != more.npos) { more.remove_prefix(dst_slash_pos); result.append(more); @@ -505,7 +505,7 @@ bool fs::statfs(const std::string& path, fs::device_stat& info) // Keep cutting path from right until it's short enough while (str.size() > 256) { - if (std::size_t x = str.find_last_of('\\') + 1) + if (usz x = str.find_last_of('\\') + 1) str.resize(x - 1); else break; @@ -1240,7 +1240,7 @@ fs::file::file(const std::string& path, bs_t mode) #endif } -fs::file::file(const void* ptr, std::size_t size) +fs::file::file(const void* ptr, usz size) { class memory_stream : public file_base { @@ -1355,7 +1355,7 @@ bool fs::dir::open(const std::string& path) class windows_dir final : public dir_base { std::vector m_entries; - std::size_t m_pos = 0; + usz m_pos = 0; void add_entry(const WIN32_FIND_DATAW& found) { @@ -1605,13 +1605,13 @@ std::string fs::escape_path(std::string_view path) { std::string real; real.resize(path.size()); - auto get_char = [&](std::size_t& from, std::size_t& to, std::size_t count) + auto get_char = [&](usz& from, usz& to, usz count) { std::memcpy(&real[to], &path[from], count); from += count, to += count; }; - std::size_t i = 0, j = -1, pos_nondelim = 0, after_delim = 0; + usz i = 0, j = -1, pos_nondelim = 0, after_delim = 0; if (i < path.size()) { @@ -1648,7 +1648,7 @@ std::string fs::escape_path(std::string_view path) case '.': { bool remove_element = true; - std::size_t k = 1; + usz k = 1; for (; k + i != path.size(); k++) { diff --git a/Utilities/File.h b/Utilities/File.h index 19479c5fe0..74db5ff8f2 100644 --- a/Utilities/File.h +++ b/Utilities/File.h @@ -73,7 +73,7 @@ namespace fs struct iovec_clone { const void* iov_base; - std::size_t iov_len; + usz iov_len; }; // File handle base @@ -200,7 +200,7 @@ namespace fs explicit file(const std::string& path, bs_t mode = ::fs::read); // Open memory for read - explicit file(const void* ptr, std::size_t size); + explicit file(const void* ptr, usz size); // Open file with specified args (forward to constructor) template @@ -370,7 +370,7 @@ namespace fs // Read std::basic_string template - std::enable_if_t && !std::is_pointer_v, bool> read(std::basic_string& str, std::size_t size, + std::enable_if_t && !std::is_pointer_v, bool> read(std::basic_string& str, usz size, const char* file = __builtin_FILE(), const char* func = __builtin_FUNCTION(), u32 line = __builtin_LINE(), @@ -405,7 +405,7 @@ namespace fs // Read POD std::vector template - std::enable_if_t && !std::is_pointer_v, bool> read(std::vector& vec, std::size_t size, + std::enable_if_t && !std::is_pointer_v, bool> read(std::vector& vec, usz size, const char* file = __builtin_FILE(), const char* func = __builtin_FUNCTION(), u32 line = __builtin_LINE(), diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp index 6ef91c9817..f1c56aca06 100644 --- a/Utilities/JIT.cpp +++ b/Utilities/JIT.cpp @@ -36,7 +36,7 @@ static atomic_t s_code_pos{0}, s_data_pos{0}; static std::vector s_code_init, s_data_init; template & Ctr, uint Off, utils::protection Prot> -static u8* add_jit_memory(std::size_t size, uint align) +static u8* add_jit_memory(usz size, uint align) { // Select subrange u8* pointer = get_jit_memory() + Off; @@ -112,7 +112,7 @@ jit_runtime::~jit_runtime() asmjit::Error jit_runtime::_add(void** dst, asmjit::CodeHolder* code) noexcept { - std::size_t codeSize = code->getCodeSize(); + usz codeSize = code->getCodeSize(); if (!codeSize) [[unlikely]] { *dst = nullptr; @@ -126,7 +126,7 @@ asmjit::Error jit_runtime::_add(void** dst, asmjit::CodeHolder* code) noexcept return asmjit::kErrorNoVirtualMemory; } - std::size_t relocSize = code->relocate(p); + usz relocSize = code->relocate(p); if (!relocSize) [[unlikely]] { *dst = nullptr; @@ -144,7 +144,7 @@ asmjit::Error jit_runtime::_release(void* ptr) noexcept return asmjit::kErrorOk; } -u8* jit_runtime::alloc(std::size_t size, uint align, bool exec) noexcept +u8* jit_runtime::alloc(usz size, uint align, bool exec) noexcept { if (exec) { @@ -216,7 +216,7 @@ asmjit::Runtime& asmjit::get_global_runtime() asmjit::Error _add(void** dst, asmjit::CodeHolder* code) noexcept override { - std::size_t codeSize = code->getCodeSize(); + usz codeSize = code->getCodeSize(); if (!codeSize) [[unlikely]] { *dst = nullptr; @@ -230,7 +230,7 @@ asmjit::Runtime& asmjit::get_global_runtime() return asmjit::kErrorNoVirtualMemory; } - std::size_t relocSize = code->relocate(p); + usz relocSize = code->relocate(p); if (!relocSize) [[unlikely]] { *dst = nullptr; @@ -389,7 +389,7 @@ struct MemoryManager1 : llvm::RTDyldMemoryManager return false; } - void registerEHFrames(u8* addr, u64 load_addr, std::size_t size) override + void registerEHFrames(u8* addr, u64 load_addr, usz size) override { } @@ -422,7 +422,7 @@ struct MemoryManager2 : llvm::RTDyldMemoryManager return false; } - void registerEHFrames(u8* addr, u64 load_addr, std::size_t size) override + void registerEHFrames(u8* addr, u64 load_addr, usz size) override { } diff --git a/Utilities/JIT.h b/Utilities/JIT.h index 6570261f1e..69ade93296 100644 --- a/Utilities/JIT.h +++ b/Utilities/JIT.h @@ -41,7 +41,7 @@ struct jit_runtime final : asmjit::HostRuntime asmjit::Error _release(void* p) noexcept override; // Allocate memory - static u8* alloc(std::size_t size, uint align, bool exec = true) noexcept; + static u8* alloc(usz size, uint align, bool exec = true) noexcept; // Should be called at least once after global initialization static void initialize(); diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index 8ef606f7c7..7ba0092d2f 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -79,14 +79,14 @@ void fmt_class_string::format(std::string& out, u64 arg) static constexpr u8 s_tail[8] = {0, 2, 3, 5, 6, 7, 9, 10}; // Get full output size - const std::size_t out_size = _arg.size / 8 * 11 + s_tail[_arg.size % 8]; + const usz out_size = _arg.size / 8 * 11 + s_tail[_arg.size % 8]; out.resize(out.size() + out_size); const auto ptr = &out.front() + (out.size() - out_size); // Each 8 bytes of input data produce 11 bytes of base57 output - for (std::size_t i = 0, p = 0; i < _arg.size; i += 8, p += 11) + for (usz i = 0, p = 0; i < _arg.size; i += 8, p += 11) { // Load up to 8 bytes be_t be_value; @@ -321,7 +321,7 @@ struct fmt::cfmt_src const fmt_type_info* sup; const u64* args; - bool test(std::size_t index) const + bool test(usz index) const { if (!sup[index].fmt_string) { @@ -332,26 +332,26 @@ struct fmt::cfmt_src } template - T get(std::size_t index) const + T get(usz index) const { return *reinterpret_cast(reinterpret_cast(args + index)); } - void skip(std::size_t extra) + void skip(usz extra) { sup += extra + 1; args += extra + 1; } - std::size_t fmt_string(std::string& out, std::size_t extra) const + usz fmt_string(std::string& out, usz extra) const { - const std::size_t start = out.size(); + const usz start = out.size(); sup[extra].fmt_string(out, args[extra]); return out.size() - start; } // Returns type size (0 if unknown, pointer, unsigned, assumed max) - std::size_t type(std::size_t extra) const + usz type(usz extra) const { // Hack: use known function pointers to determine type #define TYPE(type) \ @@ -369,14 +369,14 @@ struct fmt::cfmt_src return 0; } - static constexpr std::size_t size_char = 1; - static constexpr std::size_t size_short = 2; - static constexpr std::size_t size_int = 0; - static constexpr std::size_t size_long = sizeof(ulong); - static constexpr std::size_t size_llong = sizeof(ullong); - static constexpr std::size_t size_size = sizeof(std::size_t); - static constexpr std::size_t size_max = sizeof(std::uintmax_t); - static constexpr std::size_t size_diff = sizeof(std::ptrdiff_t); + static constexpr usz size_char = 1; + static constexpr usz size_short = 2; + static constexpr usz size_int = 0; + static constexpr usz size_long = sizeof(ulong); + static constexpr usz size_llong = sizeof(ullong); + static constexpr usz size_size = sizeof(usz); + static constexpr usz size_max = sizeof(std::uintmax_t); + static constexpr usz size_diff = sizeof(std::ptrdiff_t); }; void fmt::raw_append(std::string& out, const char* fmt, const fmt_type_info* sup, const u64* args) noexcept @@ -412,9 +412,9 @@ std::vector fmt::split(const std::string& source, std::initializer_ { std::vector result; - size_t cursor_begin = 0; + usz cursor_begin = 0; - for (size_t cursor_end = 0; cursor_end < source.length(); ++cursor_end) + for (usz cursor_end = 0; cursor_end < source.length(); ++cursor_end) { for (auto& separator : separators) { @@ -441,7 +441,7 @@ std::vector fmt::split(const std::string& source, std::initializer_ std::string fmt::trim(const std::string& source, const std::string& values) { - std::size_t begin = source.find_first_not_of(values); + usz begin = source.find_first_not_of(values); if (begin == source.npos) return {}; @@ -467,7 +467,7 @@ std::string fmt::to_lower(const std::string& string) bool fmt::match(const std::string& source, const std::string& mask) { - std::size_t source_position = 0, mask_position = 0; + usz source_position = 0, mask_position = 0; for (; source_position < source.size() && mask_position < mask.size(); ++mask_position, ++source_position) { @@ -476,7 +476,7 @@ bool fmt::match(const std::string& source, const std::string& mask) case '?': break; case '*': - for (std::size_t test_source_position = source_position; test_source_position < source.size(); ++test_source_position) + for (usz test_source_position = source_position; test_source_position < source.size(); ++test_source_position) { if (match(source.substr(test_source_position), mask.substr(mask_position + 1))) { diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 0fbf2b6316..5726d54dfc 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -6,7 +6,7 @@ namespace fmt { - template + template static std::string format(const CharT(&)[N], const Args&...); } @@ -97,7 +97,7 @@ struct fmt_unveil } }; -template +template struct fmt_unveil { using type = std::add_const_t*; @@ -119,7 +119,7 @@ struct fmt_unveil } }; -template +template struct fmt_unveil, void> { using type = typename fmt_unveil::type; @@ -251,7 +251,7 @@ namespace fmt struct base57 { const uchar* data; - std::size_t size; + usz size; template base57(const T& arg) @@ -260,7 +260,7 @@ namespace fmt { } - base57(const uchar* data, std::size_t size) + base57(const uchar* data, usz size) : data(data) , size(size) { @@ -283,7 +283,7 @@ namespace fmt void raw_append(std::string& out, const char*, const fmt_type_info*, const u64*) noexcept; // Formatting function - template + template SAFE_BUFFERS FORCE_INLINE void append(std::string& out, const CharT(&fmt)[N], const Args&... args) { static constexpr fmt_type_info type_list[sizeof...(Args) + 1]{fmt_type_info::make>()...}; @@ -291,7 +291,7 @@ namespace fmt } // Formatting function - template + template SAFE_BUFFERS FORCE_INLINE std::string format(const CharT(&fmt)[N], const Args&... args) { std::string result; @@ -303,7 +303,7 @@ namespace fmt [[noreturn]] void raw_throw_exception(const src_loc&, const char*, const fmt_type_info*, const u64*); // Throw exception with formatting - template + template struct throw_exception { [[noreturn]] SAFE_BUFFERS FORCE_INLINE throw_exception(const CharT(&fmt)[N], const Args&... args, @@ -317,6 +317,6 @@ namespace fmt } }; - template + template throw_exception(const CharT(&)[N], const Args&...) -> throw_exception; } diff --git a/Utilities/StrUtil.h b/Utilities/StrUtil.h index 6f038194bf..77703a46bf 100644 --- a/Utilities/StrUtil.h +++ b/Utilities/StrUtil.h @@ -17,7 +17,7 @@ std::string utf8_path_to_ansi_path(const std::string& src); template inline void strcpy_trunc(D& dst, const T& src) { - const std::size_t count = std::size(src) >= std::size(dst) ? std::size(dst) - 1 : std::size(src); + const usz count = std::size(src) >= std::size(dst) ? std::size(dst) - 1 : std::size(src); std::memcpy(std::data(dst), std::data(src), count); std::memset(std::data(dst) + count, 0, std::size(dst) - count); } @@ -27,14 +27,14 @@ namespace fmt std::string replace_first(const std::string& src, const std::string& from, const std::string& to); std::string replace_all(const std::string& src, const std::string& from, const std::string& to); - template + template std::string replace_all(std::string src, const std::pair (&list)[list_size]) { - for (size_t pos = 0; pos < src.length(); ++pos) + for (usz pos = 0; pos < src.length(); ++pos) { - for (size_t i = 0; i < list_size; ++i) + for (usz i = 0; i < list_size; ++i) { - const size_t comp_length = list[i].first.length(); + const usz comp_length = list[i].first.length(); if (src.length() - pos < comp_length) continue; @@ -51,14 +51,14 @@ namespace fmt return src; } - template + template std::string replace_all(std::string src, const std::pair> (&list)[list_size]) { - for (size_t pos = 0; pos < src.length(); ++pos) + for (usz pos = 0; pos < src.length(); ++pos) { - for (size_t i = 0; i < list_size; ++i) + for (usz i = 0; i < list_size; ++i) { - const size_t comp_length = list[i].first.length(); + const usz comp_length = list[i].first.length(); if (src.length() - pos < comp_length) continue; diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index d7e565b98d..c17d466d6a 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -118,7 +118,7 @@ bool IsDebuggerPresent() }; u_int miblen = std::size(mib); struct kinfo_proc info; - size_t size = sizeof(info); + usz size = sizeof(info); if (sysctl(mib, miblen, &info, &size, NULL, 0)) { @@ -259,7 +259,7 @@ enum x64_op_t : u32 X64OP_SBB, // lock sbb [mem], ... }; -void decode_x64_reg_op(const u8* code, x64_op_t& out_op, x64_reg_t& out_reg, size_t& out_size, size_t& out_length) +void decode_x64_reg_op(const u8* code, x64_op_t& out_op, x64_reg_t& out_reg, usz& out_size, usz& out_length) { // simple analysis of x64 code allows to reinterpret MOV or other instructions in any desired way out_length = 0; @@ -385,12 +385,12 @@ void decode_x64_reg_op(const u8* code, x64_op_t& out_op, x64_reg_t& out_reg, siz return x64_reg_t{((*code & 0x38) >> 3) + X64R_AL}; }; - auto get_op_size = [](const u8 rex, const bool oso) -> size_t + auto get_op_size = [](const u8 rex, const bool oso) -> usz { return rex & 8 ? 8 : (oso ? 2 : 4); }; - auto get_modRM_size = [](const u8* code) -> size_t + auto get_modRM_size = [](const u8* code) -> usz { switch (*code >> 6) // check Mod { @@ -976,7 +976,7 @@ static const int reg_table[] = #define RDI(c) (*X64REG((c), 7)) #define RIP(c) (*X64REG((c), 16)) -bool get_x64_reg_value(x64_context* context, x64_reg_t reg, size_t d_size, size_t i_size, u64& out_value) +bool get_x64_reg_value(x64_context* context, x64_reg_t reg, usz d_size, usz i_size, u64& out_value) { // get x64 reg value (for store operations) if (reg - X64R_RAX < 16) @@ -1067,7 +1067,7 @@ bool get_x64_reg_value(x64_context* context, x64_reg_t reg, size_t d_size, size_ return false; } -bool put_x64_reg_value(x64_context* context, x64_reg_t reg, size_t d_size, u64 value) +bool put_x64_reg_value(x64_context* context, x64_reg_t reg, usz d_size, u64 value) { // save x64 reg value (for load operations) if (reg - X64R_RAX < 16) @@ -1086,7 +1086,7 @@ bool put_x64_reg_value(x64_context* context, x64_reg_t reg, size_t d_size, u64 v return false; } -bool set_x64_cmp_flags(x64_context* context, size_t d_size, u64 x, u64 y, bool carry = true) +bool set_x64_cmp_flags(x64_context* context, usz d_size, u64 x, u64 y, bool carry = true) { switch (d_size) { @@ -1162,7 +1162,7 @@ bool set_x64_cmp_flags(x64_context* context, size_t d_size, u64 x, u64 y, bool c return true; } -size_t get_x64_access_size(x64_context* context, x64_op_t op, x64_reg_t reg, size_t d_size, size_t i_size) +usz get_x64_access_size(x64_context* context, x64_op_t op, x64_reg_t reg, usz d_size, usz i_size) { if (op == X64OP_MOVS || op == X64OP_STOS) { @@ -1227,8 +1227,8 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no x64_op_t op; x64_reg_t reg; - size_t d_size; - size_t i_size; + usz d_size; + usz i_size; // decode single x64 instruction that causes memory access decode_x64_reg_op(code, op, reg, d_size, i_size); @@ -1249,7 +1249,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no } // get length of data being accessed - size_t a_size = get_x64_access_size(context, op, reg, d_size, i_size); + usz a_size = get_x64_access_size(context, op, reg, d_size, i_size); if (0x1'0000'0000ull - addr < a_size) { @@ -1954,14 +1954,14 @@ void thread_base::set_name(std::string name) #endif #if defined(__APPLE__) - name.resize(std::min(15, name.size())); + name.resize(std::min(15, name.size())); pthread_setname_np(name.c_str()); #elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) pthread_set_name_np(pthread_self(), name.c_str()); #elif defined(__NetBSD__) pthread_setname_np(pthread_self(), "%s", name.data()); #elif !defined(_WIN32) - name.resize(std::min(15, name.size())); + name.resize(std::min(15, name.size())); pthread_setname_np(pthread_self(), name.c_str()); #endif } @@ -2791,17 +2791,17 @@ u64 thread_ctrl::get_thread_affinity_mask() #endif } -std::pair thread_ctrl::get_thread_stack() +std::pair thread_ctrl::get_thread_stack() { #ifdef _WIN32 ULONG_PTR _min = 0; ULONG_PTR _max = 0; GetCurrentThreadStackLimits(&_min, &_max); - const std::size_t ssize = _max - _min; + const usz ssize = _max - _min; const auto saddr = reinterpret_cast(_min); #else void* saddr = 0; - std::size_t ssize = 0; + usz ssize = 0; pthread_attr_t attr; #ifdef __linux__ pthread_getattr_np(pthread_self(), &attr); diff --git a/Utilities/Thread.h b/Utilities/Thread.h index 2763cce1c8..2cc19af4d1 100644 --- a/Utilities/Thread.h +++ b/Utilities/Thread.h @@ -262,7 +262,7 @@ public: static u64 get_thread_affinity_mask(); // Get current thread stack addr and size - static std::pair get_thread_stack(); + static std::pair get_thread_stack(); private: // Miscellaneous diff --git a/Utilities/address_range.h b/Utilities/address_range.h index ddc8660951..1e0397001a 100644 --- a/Utilities/address_range.h +++ b/Utilities/address_range.h @@ -282,7 +282,7 @@ namespace utils public: // Wrapped functions - inline void reserve(size_t nr) { data.reserve(nr); } + inline void reserve(usz nr) { data.reserve(nr); } inline void clear() { data.clear(); } inline size_type size() const { return data.size(); } inline bool empty() const { return data.empty(); } @@ -456,9 +456,9 @@ namespace utils // Will fail if ranges within the vector overlap our touch each-other bool check_consistency() const { - size_t _size = data.size(); + usz _size = data.size(); - for (size_t i = 0; i < _size; ++i) + for (usz i = 0; i < _size; ++i) { const auto &r1 = data[i]; if (!r1.valid()) @@ -466,7 +466,7 @@ namespace utils continue; } - for (size_t j = i + 1; j < _size; ++j) + for (usz j = i + 1; j < _size; ++j) { const auto &r2 = data[j]; if (!r2.valid()) @@ -582,15 +582,15 @@ namespace utils namespace std { - static_assert(sizeof(size_t) >= 2 * sizeof(u32), "size_t must be at least twice the size of u32"); + static_assert(sizeof(usz) >= 2 * sizeof(u32), "usz must be at least twice the size of u32"); template <> struct hash { - std::size_t operator()(const utils::address_range& k) const + usz operator()(const utils::address_range& k) const { - // we can guarantee a unique hash since our type is 64 bits and size_t as well - return (size_t{ k.start } << 32) | size_t{ k.end }; + // we can guarantee a unique hash since our type is 64 bits and usz as well + return (usz{ k.start } << 32) | usz{ k.end }; } }; } diff --git a/Utilities/bin_patch.cpp b/Utilities/bin_patch.cpp index e6705d44ac..efd10ea927 100644 --- a/Utilities/bin_patch.cpp +++ b/Utilities/bin_patch.cpp @@ -577,20 +577,20 @@ void patch_engine::append_title_patches(const std::string& title_id) load(m_map, get_patches_path() + title_id + "_patch.yml"); } -std::size_t patch_engine::apply(const std::string& name, u8* dst) +usz patch_engine::apply(const std::string& name, u8* dst) { return apply_patch(name, dst, 0, 0); } -std::size_t patch_engine::apply_with_ls_check(const std::string& name, u8* dst, u32 filesz, u32 ls_addr) +usz patch_engine::apply_with_ls_check(const std::string& name, u8* dst, u32 filesz, u32 ls_addr) { return apply_patch(name, dst, filesz, ls_addr); } template -static std::size_t apply_modification(const patch_engine::patch_info& patch, u8* dst, u32 filesz, u32 ls_addr) +static usz apply_modification(const patch_engine::patch_info& patch, u8* dst, u32 filesz, u32 ls_addr) { - size_t applied = 0; + usz applied = 0; for (const auto& p : patch.data_list) { @@ -681,14 +681,14 @@ static std::size_t apply_modification(const patch_engine::patch_info& patch, u8* } template -std::size_t patch_engine::apply_patch(const std::string& name, u8* dst, u32 filesz, u32 ls_addr) +usz patch_engine::apply_patch(const std::string& name, u8* dst, u32 filesz, u32 ls_addr) { if (m_map.find(name) == m_map.cend()) { return 0; } - size_t applied_total = 0; + usz applied_total = 0; const auto& container = m_map.at(name); const auto serial = Emu.GetTitleID(); const auto app_version = Emu.GetAppVersion(); @@ -799,7 +799,7 @@ std::size_t patch_engine::apply_patch(const std::string& name, u8* dst, u32 file m_applied_groups.insert(patch.patch_group); } - const size_t applied = apply_modification(patch, dst, filesz, ls_addr); + const usz applied = apply_modification(patch, dst, filesz, ls_addr); applied_total += applied; if (patch.is_legacy) @@ -906,7 +906,7 @@ void patch_engine::save_config(const patch_map& patches_map, bool enable_legacy_ file.write(out.c_str(), out.size()); } -static void append_patches(patch_engine::patch_map& existing_patches, const patch_engine::patch_map& new_patches, size_t& count, size_t& total, std::stringstream* log_messages) +static void append_patches(patch_engine::patch_map& existing_patches, const patch_engine::patch_map& new_patches, usz& count, usz& total, std::stringstream* log_messages) { for (const auto& [hash, new_container] : new_patches) { @@ -1058,7 +1058,7 @@ bool patch_engine::save_patches(const patch_map& patches, const std::string& pat return true; } -bool patch_engine::import_patches(const patch_engine::patch_map& patches, const std::string& path, size_t& count, size_t& total, std::stringstream* log_messages) +bool patch_engine::import_patches(const patch_engine::patch_map& patches, const std::string& path, usz& count, usz& total, std::stringstream* log_messages) { patch_engine::patch_map existing_patches; diff --git a/Utilities/bin_patch.h b/Utilities/bin_patch.h index 12f384eea1..0c7fd810ce 100644 --- a/Utilities/bin_patch.h +++ b/Utilities/bin_patch.h @@ -117,7 +117,7 @@ public: static bool save_patches(const patch_map& patches, const std::string& path, std::stringstream* log_messages = nullptr); // Create or append patches to a file - static bool import_patches(const patch_map& patches, const std::string& path, size_t& count, size_t& total, std::stringstream* log_messages = nullptr); + static bool import_patches(const patch_map& patches, const std::string& path, usz& count, usz& total, std::stringstream* log_messages = nullptr); // Remove a patch from a file static bool remove_patch(const patch_info& info); @@ -132,15 +132,15 @@ public: void append_title_patches(const std::string& title_id); // Apply patch (returns the number of entries applied) - std::size_t apply(const std::string& name, u8* dst); + usz apply(const std::string& name, u8* dst); // Apply patch with a check that the address exists in SPU local storage - std::size_t apply_with_ls_check(const std::string& name, u8* dst, u32 filesz, u32 ls_addr); + usz apply_with_ls_check(const std::string& name, u8* dst, u32 filesz, u32 ls_addr); private: // Internal: Apply patch (returns the number of entries applied) template - std::size_t apply_patch(const std::string& name, u8* dst, u32 filesz, u32 ls_addr); + usz apply_patch(const std::string& name, u8* dst, u32 filesz, u32 ls_addr); // Database patch_map m_map; diff --git a/Utilities/bit_set.h b/Utilities/bit_set.h index 784185573e..36133b3165 100644 --- a/Utilities/bit_set.h +++ b/Utilities/bit_set.h @@ -48,8 +48,8 @@ private: } public: - static constexpr std::size_t bitmax = sizeof(T) * 8; - static constexpr std::size_t bitsize = static_cast(T::__bitset_enum_max); + static constexpr usz bitmax = sizeof(T) * 8; + static constexpr usz bitsize = static_cast(T::__bitset_enum_max); static_assert(std::is_enum::value, "bs_t<> error: invalid type (must be enum)"); static_assert(bitsize <= bitmax, "bs_t<> error: invalid __bitset_enum_max"); diff --git a/Utilities/cfmt.h b/Utilities/cfmt.h index ce0f3e6ec4..8bf74fe310 100644 --- a/Utilities/cfmt.h +++ b/Utilities/cfmt.h @@ -6,7 +6,7 @@ #include #include -static const std::size_t size_dropped = -1; +static const usz size_dropped = -1; /* C-style format parser. Appends formatted string to `out`, returns number of characters written. @@ -15,13 +15,13 @@ C-style format parser. Appends formatted string to `out`, returns number of char `src`: rvalue reference to argument provider. */ template -std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) +usz cfmt_append(Dst& out, const Char* fmt, Src&& src) { - const std::size_t start_pos = out.size(); + const usz start_pos = out.size(); struct cfmt_context { - std::size_t size; // Size of current format sequence + usz size; // Size of current format sequence u8 args; // Number of extra args used u8 type; // Integral type bytesize @@ -80,7 +80,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) const auto write_decimal = [&](u64 value, s64 min_size) { - const std::size_t start = out.size(); + const usz start = out.size(); do { @@ -90,7 +90,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) while (0 < --min_size || value); // Revert written characters - for (std::size_t i = start, j = out.size() - 1; i < j; i++, j--) + for (usz i = start, j = out.size() - 1; i < j; i++, j--) { std::swap(out[i], out[j]); } @@ -285,7 +285,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) break; } - const std::size_t start = out.size(); + const usz start = out.size(); out.push_back(src.template get(ctx.args)); if (1 < ctx.width) @@ -307,8 +307,8 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) break; } - const std::size_t start = out.size(); - const std::size_t size1 = src.fmt_string(out, ctx.args); + const usz start = out.size(); + const usz size1 = src.fmt_string(out, ctx.args); if (ctx.dot && size1 > ctx.prec) { @@ -316,7 +316,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) out.resize(start + ctx.prec); } - const std::size_t size2 = out.size() - start; + const usz size2 = out.size() - start; if (size2 < ctx.width) { @@ -352,7 +352,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) const u64 val = src.template get(ctx.args); const bool negative = ctx.type && static_cast(val) < 0; - const std::size_t start = out.size(); + const usz start = out.size(); if (!ctx.dot || ctx.prec) { @@ -372,7 +372,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) write_decimal(negative ? 0 - val : val, ctx.prec); } - const std::size_t size2 = out.size() - start; + const usz size2 = out.size() - start; if (size2 < ctx.width) { @@ -419,7 +419,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) // Trunc sign-extended signed types const u64 val = src.template get(ctx.args) & mask; - const std::size_t start = out.size(); + const usz start = out.size(); if (ctx.alter) { @@ -435,7 +435,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) write_octal(val, ctx.prec); } - const std::size_t size2 = out.size() - start; + const usz size2 = out.size() - start; if (size2 < ctx.width) { @@ -476,7 +476,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) // Trunc sign-extended signed types const u64 val = src.template get(ctx.args) & mask; - const std::size_t start = out.size(); + const usz start = out.size(); if (ctx.alter) { @@ -493,7 +493,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) write_hex(val, ch == 'X', ctx.prec); } - const std::size_t size2 = out.size() - start; + const usz size2 = out.size() - start; if (size2 < ctx.width) { @@ -540,14 +540,14 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) // Trunc sign-extended signed types const u64 val = src.template get(ctx.args) & mask; - const std::size_t start = out.size(); + const usz start = out.size(); if (!ctx.dot || ctx.prec) { write_decimal(val, ctx.prec); } - const std::size_t size2 = out.size() - start; + const usz size2 = out.size() - start; if (size2 < ctx.width) { @@ -570,11 +570,11 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) const u64 val = src.template get(ctx.args); - const std::size_t start = out.size(); + const usz start = out.size(); write_hex(val, false, sizeof(void*) * 2); - const std::size_t size2 = out.size() - start; + const usz size2 = out.size() - start; if (size2 < ctx.width) { @@ -610,7 +610,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) const u64 arg1 = ctx.args >= 1 ? src.template get(1) : 0; const u64 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)) + if (const usz _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); diff --git a/Utilities/hash.h b/Utilities/hash.h index 72ab4cf7c5..2be9f7a7c8 100644 --- a/Utilities/hash.h +++ b/Utilities/hash.h @@ -5,19 +5,19 @@ namespace rpcs3 { template - static size_t hash_base(T value) + static usz hash_base(T value) { - return static_cast(value); + return static_cast(value); } template - static size_t hash_struct_base(const T& value) + static usz hash_struct_base(const T& value) { // FNV 64-bit - size_t result = 14695981039346656037ull; + usz result = 14695981039346656037ull; const U *bits = reinterpret_cast(&value); - for (size_t n = 0; n < (sizeof(T) / sizeof(U)); ++n) + for (usz n = 0; n < (sizeof(T) / sizeof(U)); ++n) { result ^= bits[n]; result *= 1099511628211ull; @@ -27,7 +27,7 @@ namespace rpcs3 } template - static size_t hash_struct(const T& value) + static usz hash_struct(const T& value) { static constexpr auto block_sz = sizeof(T); diff --git a/Utilities/lockless.h b/Utilities/lockless.h index f6d4857e78..0b94557302 100644 --- a/Utilities/lockless.h +++ b/Utilities/lockless.h @@ -8,7 +8,7 @@ //! //! T is the type of elements. Currently, default constructor of T shall be constexpr. //! N is initial element count, available without any memory allocation and only stored contiguously. -template +template class lf_array { // Data (default-initialized) @@ -28,7 +28,7 @@ public: } } - T& operator [](std::size_t index) + T& operator [](usz index) { if (index < N) [[likely]] { @@ -51,7 +51,7 @@ public: //! Simple lock-free FIFO queue base. Based on lf_array itself. Currently uses 32-bit counters. //! There is no "push_end" or "pop_begin" provided, the queue element must signal its state on its own. -template +template class lf_fifo : public lf_array { // LSB 32-bit: push, MSB 32-bit: pop @@ -354,9 +354,9 @@ public: // Apply func(data) to each element, return the total length template - std::size_t apply(F func) + usz apply(F func) { - std::size_t count = 0; + usz count = 0; for (auto slice = pop_all(); slice; slice.pop_front()) { diff --git a/Utilities/sysinfo.cpp b/Utilities/sysinfo.cpp index f96b0303a8..cdd3f360e9 100755 --- a/Utilities/sysinfo.cpp +++ b/Utilities/sysinfo.cpp @@ -217,13 +217,13 @@ std::string utils::get_firmware_version() std::string version = version_file.to_string(); // Extract version - const size_t start = version.find_first_of(':') + 1; - const size_t end = version.find_first_of(':', start); + const usz start = version.find_first_of(':') + 1; + const usz end = version.find_first_of(':', start); version = version.substr(start, end - start); // Trim version - const size_t trim_start = version.find_first_not_of('0'); - const size_t trim_end = version.find_last_not_of('0'); + const usz trim_start = version.find_first_not_of('0'); + const usz trim_end = version.find_last_not_of('0'); version = version.substr(trim_start, trim_end); return version; diff --git a/Utilities/typemap.h b/Utilities/typemap.h index 3bc2b4053f..b68730df37 100644 --- a/Utilities/typemap.h +++ b/Utilities/typemap.h @@ -152,7 +152,7 @@ namespace utils template class refctr final { - atomic_t m_ref{1}; + atomic_t m_ref{1}; public: T object; @@ -168,7 +168,7 @@ namespace utils m_ref++; } - std::size_t remove_ref() noexcept + usz remove_ref() noexcept { return --m_ref; } @@ -464,8 +464,8 @@ namespace utils uint get_id() const { // It's not often needed so figure it out instead of storing it - const std::size_t diff = reinterpret_cast(m_block) - m_head->m_ptr; - const std::size_t quot = diff / m_head->m_ssize; + const usz diff = reinterpret_cast(m_block) - m_head->m_ptr; + const usz quot = diff / m_head->m_ssize; if (diff % m_head->m_ssize || quot > typeinfo_count::max_count) { @@ -498,7 +498,7 @@ namespace utils void* m_memory = nullptr; // Virtual memory size - std::size_t m_total = 0; + usz m_total = 0; template typemap_head* get_head() const @@ -555,7 +555,7 @@ namespace utils // Delete objects (there shall be no threads accessing them) const uint lim = m_map[i].m_count != 1 ? +m_map[i].m_limit : 1; - for (std::size_t j = 0; j < lim; j++) + for (usz j = 0; j < lim; j++) { const auto block = reinterpret_cast(m_map[i].m_ptr + j * m_map[i].m_ssize); @@ -585,7 +585,7 @@ namespace utils { const uint align = type->align; const uint ssize = ::align(sizeof(typemap_block), align) + ::align(type->size, align); - const auto total = std::size_t{ssize} * type->count; + const auto total = usz{ssize} * type->count; const auto start = uptr{::align(m_total, align)}; if (total) @@ -624,7 +624,7 @@ namespace utils } // Return allocated virtual memory block size (not aligned) - std::size_t get_memory_size() const + usz get_memory_size() const { return m_total; } @@ -664,7 +664,7 @@ namespace utils // Find empty location and lock it, starting from hint index for (uint lim = head->m_limit, i = (lim > last ? 0 : lim);; i = (i == last ? 0 : i + 1)) { - block = reinterpret_cast(head->m_ptr + std::size_t{i} * head->m_ssize); + block = reinterpret_cast(head->m_ptr + usz{i} * head->m_ssize); if (block->m_type == 0 && block->m_mutex.try_lock()) { @@ -703,7 +703,7 @@ namespace utils else if constexpr (std::is_invocable_r_v) { // Access with a lookup function - for (std::size_t j = 0; j < (typeinfo_count::max_count != 1 ? +head->m_limit : 1); j++) + for (usz j = 0; j < (typeinfo_count::max_count != 1 ? +head->m_limit : 1); j++) { block = reinterpret_cast(head->m_ptr + j * head->m_ssize); @@ -731,7 +731,7 @@ namespace utils const uint unbiased = static_cast(std::forward(id)) - bias; const uint unscaled = unbiased / step; - block = reinterpret_cast(head->m_ptr + std::size_t{head->m_ssize} * unscaled); + block = reinterpret_cast(head->m_ptr + usz{head->m_ssize} * unscaled); // Check id range and type if (unscaled >= typeinfo_count::max_count || unbiased % step) [[unlikely]] @@ -866,7 +866,7 @@ namespace utils } } - template + template bool try_lock(const std::array& array, uint locked, std::integer_sequence) const { // Try to lock mutex if not locked from the previous step @@ -905,8 +905,8 @@ namespace utils return false; } - template - uint lock_array(const std::array& array, std::integer_sequence, std::integer_sequence) const + template + uint lock_array(const std::array& array, std::integer_sequence, std::integer_sequence) const { // Verify all mutexes are free or wait for one of them and return its index uint locked = 0; @@ -914,15 +914,15 @@ namespace utils return locked; } - template - void check_array(std::array& array, std::integer_sequence, Args&&... ids) const + template + void check_array(std::array& array, std::integer_sequence, Args&&... ids) const { // Check types and unlock on mismatch (check_ptr(array[I].m_block, std::forward(ids)), ...); } - template - std::tuple...> array_to_tuple(const std::array& array, std::integer_sequence) const + template + std::tuple...> array_to_tuple(const std::array& array, std::integer_sequence) const { return {array[I]...}; } @@ -1000,7 +1000,7 @@ namespace utils const ullong ix = head->m_create_count; - for (std::size_t j = 0; j < (typeinfo_count>::max_count != 1 ? +head->m_limit : 1); j++) + for (usz j = 0; j < (typeinfo_count>::max_count != 1 ? +head->m_limit : 1); j++) { const auto block = reinterpret_cast(head->m_ptr + j * head->m_ssize); diff --git a/Utilities/version.cpp b/Utilities/version.cpp index 67c8b07453..f31722c391 100644 --- a/Utilities/version.cpp +++ b/Utilities/version.cpp @@ -67,7 +67,7 @@ namespace utils int vnum2 = 0; // Loop until both strings are processed - for (size_t i = 0, j = 0; (i < v1.length() || j < v2.length());) + for (usz i = 0, j = 0; (i < v1.length() || j < v2.length());) { // Storing numeric part of version 1 in vnum1 while (i < v1.length() && v1[i] != '.') diff --git a/rpcs3/Crypto/unedat.cpp b/rpcs3/Crypto/unedat.cpp index 1e6cd89eb6..d6059de6c1 100644 --- a/rpcs3/Crypto/unedat.cpp +++ b/rpcs3/Crypto/unedat.cpp @@ -578,7 +578,7 @@ int validate_npd_hashes(const char* file_name, const u8* klicensee, NPD_HEADER * int dev_hash_result = 0; const s32 file_name_length = ::narrow(std::strlen(file_name)); - const std::size_t buf_len = 0x30 + file_name_length; + const usz buf_len = 0x30 + file_name_length; std::unique_ptr buf(new u8[buf_len]); std::unique_ptr buf_lower(new u8[buf_len]); @@ -591,7 +591,7 @@ int validate_npd_hashes(const char* file_name, const u8* klicensee, NPD_HEADER * std::memcpy(buf_lower.get(), buf.get(), buf_len); std::memcpy(buf_upper.get(), buf.get(), buf_len); - for (std::size_t i = std::basic_string_view(buf.get() + 0x30, file_name_length).find_last_of('.'); i < buf_len; i++) + for (usz i = std::basic_string_view(buf.get() + 0x30, file_name_length).find_last_of('.'); i < buf_len; i++) { const u8 c = static_cast(buf[i]); buf_upper[i] = std::toupper(c); diff --git a/rpcs3/Crypto/unpkg.cpp b/rpcs3/Crypto/unpkg.cpp index d378126cc4..354e210deb 100644 --- a/rpcs3/Crypto/unpkg.cpp +++ b/rpcs3/Crypto/unpkg.cpp @@ -697,7 +697,7 @@ bool package_reader::extract_data(atomic_t& sync) return false; } - size_t num_failures = 0; + usz num_failures = 0; std::vector entries(header.file_count); @@ -857,7 +857,7 @@ void package_reader::archive_seek(const s64 new_offset, const fs::seek_mode damo cur_offset += new_offset; u64 _offset = 0; - for (size_t i = 0; i < filelist.size(); i++) + for (usz i = 0; i < filelist.size(); i++) { if (cur_offset < (_offset + filelist[i].size())) { diff --git a/rpcs3/Crypto/unpkg.h b/rpcs3/Crypto/unpkg.h index 91b4dc5f98..6b4bd1a8aa 100644 --- a/rpcs3/Crypto/unpkg.h +++ b/rpcs3/Crypto/unpkg.h @@ -117,16 +117,16 @@ struct PKGEntry struct PKGMetaData { private: - static std::string to_hex_string(u8 buf[], size_t size) + static std::string to_hex_string(u8 buf[], usz size) { std::stringstream sstream; - for (size_t i = 0; i < size; i++) + for (usz i = 0; i < size; i++) { sstream << std::hex << std::setw(2) << std::setfill('0') << static_cast(buf[i]); } return sstream.str(); } - static std::string to_hex_string(u8 buf[], size_t size, size_t dotpos) + static std::string to_hex_string(u8 buf[], usz size, usz dotpos) { std::string result = to_hex_string(buf, size); if (result.size() > dotpos) @@ -312,14 +312,14 @@ private: u64 archive_read(void* data_ptr, const u64 num_bytes); u64 decrypt(u64 offset, u64 size, const uchar* key); - const std::size_t BUF_SIZE = 8192 * 1024; // 8 MB + const usz BUF_SIZE = 8192 * 1024; // 8 MB bool m_is_valid = false; std::string m_path; std::string install_dir; std::vector filelist; - size_t cur_file = 0; + usz cur_file = 0; u64 cur_offset = 0; u64 cur_file_offset = 0; std::unique_ptr buf; diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index ec54710210..ad1dba01c7 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -715,7 +715,7 @@ bool SCEDecrypter::LoadMetadata(const u8 erk[32], const u8 riv[16]) } // Perform AES-CTR encryption on the metadata headers. - size_t ctr_nc_off = 0; + usz ctr_nc_off = 0; u8 ctr_stream_block[0x10]; aes_setkey_enc(&aes, meta_info.key, 128); aes_crypt_ctr(&aes, metadata_headers_size, &ctr_nc_off, meta_info.iv, ctr_stream_block, metadata_headers.get(), metadata_headers.get()); @@ -758,7 +758,7 @@ bool SCEDecrypter::DecryptData() // Parse the metadata section headers to find the offsets of encrypted data. for (unsigned int i = 0; i < meta_hdr.section_count; i++) { - size_t ctr_nc_off = 0; + usz ctr_nc_off = 0; u8 ctr_stream_block[0x10]; u8 data_key[0x10]; u8 data_iv[0x10]; @@ -824,7 +824,7 @@ std::vector SCEDecrypter::MakeFile() // Decompress if necessary. if (meta_shdr[i].compressed == 2) { - const size_t BUFSIZE = 32 * 1024; + const usz BUFSIZE = 32 * 1024; u8 tempbuf[BUFSIZE]; z_stream strm; strm.zalloc = Z_NULL; @@ -1210,7 +1210,7 @@ bool SELFDecrypter::LoadMetadata(u8* klic_key) } // Perform AES-CTR encryption on the metadata headers. - size_t ctr_nc_off = 0; + usz ctr_nc_off = 0; u8 ctr_stream_block[0x10]; aes_setkey_enc(&aes, meta_info.key, 128); aes_crypt_ctr(&aes, metadata_headers_size, &ctr_nc_off, meta_info.iv, ctr_stream_block, metadata_headers.get(), metadata_headers.get()); @@ -1257,7 +1257,7 @@ bool SELFDecrypter::DecryptData() // Parse the metadata section headers to find the offsets of encrypted data. for (unsigned int i = 0; i < meta_hdr.section_count; i++) { - size_t ctr_nc_off = 0; + usz ctr_nc_off = 0; u8 ctr_stream_block[0x10]; u8 data_key[0x10]; u8 data_iv[0x10]; diff --git a/rpcs3/Emu/CPU/CPUDisAsm.h b/rpcs3/Emu/CPU/CPUDisAsm.h index f2d7bde909..c960902d16 100644 --- a/rpcs3/Emu/CPU/CPUDisAsm.h +++ b/rpcs3/Emu/CPU/CPUDisAsm.h @@ -96,7 +96,7 @@ protected: { if (m_mode != CPUDisAsm_NormalMode) { - op.resize(std::max(op.length(), 10), ' '); + op.resize(std::max(op.length(), 10), ' '); } return op; diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h index 9cc878b31e..a117a8dc24 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.h +++ b/rpcs3/Emu/CPU/CPUTranslator.h @@ -2917,9 +2917,9 @@ public: template <> struct fmt_unveil { - using type = std::size_t; + using type = usz; - static inline std::size_t get(const llvm::TypeSize& arg) + static inline usz get(const llvm::TypeSize& arg) { return arg; } diff --git a/rpcs3/Emu/Cell/Modules/StaticHLE.cpp b/rpcs3/Emu/Cell/Modules/StaticHLE.cpp index decf537359..b074172dae 100644 --- a/rpcs3/Emu/Cell/Modules/StaticHLE.cpp +++ b/rpcs3/Emu/Cell/Modules/StaticHLE.cpp @@ -99,7 +99,7 @@ bool statichle_handler::load_patterns() #define POLY 0x8408 -uint16_t statichle_handler::gen_CRC16(const uint8_t* data_p, size_t length) +uint16_t statichle_handler::gen_CRC16(const uint8_t* data_p, usz length) { unsigned char i; unsigned int data; diff --git a/rpcs3/Emu/Cell/Modules/StaticHLE.h b/rpcs3/Emu/Cell/Modules/StaticHLE.h index 3860b46eec..7c30219df6 100644 --- a/rpcs3/Emu/Cell/Modules/StaticHLE.h +++ b/rpcs3/Emu/Cell/Modules/StaticHLE.h @@ -26,7 +26,7 @@ public: bool check_against_patterns(vm::cptr& data, u32 size, u32 addr); protected: - uint16_t gen_CRC16(const uint8_t* data_p, size_t length); + uint16_t gen_CRC16(const uint8_t* data_p, usz length); std::vector hle_patterns; }; diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.cpp b/rpcs3/Emu/Cell/Modules/cellAudio.cpp index 1126f98223..ec813ff14a 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAudio.cpp @@ -1071,7 +1071,7 @@ void cell_audio_thread::mix(float *out_buffer, s32 offset) // 2x CVTPS2DQ (converts float to s32) // PACKSSDW (converts s32 to s16 with signed saturation) - for (size_t i = 0; i < out_buffer_sz; i += 8) + for (usz i = 0; i < out_buffer_sz; i += 8) { const auto scale = _mm_set1_ps(0x8000); _mm_store_ps(out_buffer + i / 2, _mm_castsi128_ps(_mm_packs_epi32( diff --git a/rpcs3/Emu/Cell/Modules/cellCelp8Enc.h b/rpcs3/Emu/Cell/Modules/cellCelp8Enc.h index 92deaebd0a..aec4b70a42 100644 --- a/rpcs3/Emu/Cell/Modules/cellCelp8Enc.h +++ b/rpcs3/Emu/Cell/Modules/cellCelp8Enc.h @@ -60,7 +60,7 @@ struct CellCelp8EncResource vm::bptr startAddr; be_t ppuThreadPriority; be_t spuThreadPriority; - be_t ppuThreadStackSize; + be_t ppuThreadStackSize; }; struct CellCelp8EncParam diff --git a/rpcs3/Emu/Cell/Modules/cellCelpEnc.h b/rpcs3/Emu/Cell/Modules/cellCelpEnc.h index 4d98dc0442..8c553f411e 100644 --- a/rpcs3/Emu/Cell/Modules/cellCelpEnc.h +++ b/rpcs3/Emu/Cell/Modules/cellCelpEnc.h @@ -55,7 +55,7 @@ struct CellCelpEncResource vm::bptr startAddr; be_t ppuThreadPriority; be_t spuThreadPriority; - be_t ppuThreadStackSize; + be_t ppuThreadStackSize; }; struct CellCelpEncParam diff --git a/rpcs3/Emu/Cell/Modules/cellDmux.cpp b/rpcs3/Emu/Cell/Modules/cellDmux.cpp index 92b5361d01..eb66739524 100644 --- a/rpcs3/Emu/Cell/Modules/cellDmux.cpp +++ b/rpcs3/Emu/Cell/Modules/cellDmux.cpp @@ -181,7 +181,7 @@ public: const u32 spec; //addr std::vector raw_data; // demultiplexed data stream (managed by demuxer thread) - std::size_t raw_pos = 0; // should be <= raw_data.size() + usz raw_pos = 0; // should be <= raw_data.size() u64 last_dts = CODEC_TS_INVALID; u64 last_pts = CODEC_TS_INVALID; diff --git a/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp b/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp index 54b49bd42b..2ff3680b61 100644 --- a/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp @@ -332,7 +332,7 @@ u32 cellGcmGetTiledPitchSize(u32 size) { cellGcmSys.trace("cellGcmGetTiledPitchSize(size=%d)", size); - for (size_t i = 0; i < std::size(tiled_pitches) - 1; i++) { + for (usz i = 0; i < std::size(tiled_pitches) - 1; i++) { if (tiled_pitches[i] < size && size <= tiled_pitches[i + 1]) { return tiled_pitches[i + 1]; } diff --git a/rpcs3/Emu/Cell/Modules/cellImeJp.cpp b/rpcs3/Emu/Cell/Modules/cellImeJp.cpp index b452b433a2..66f229c6eb 100644 --- a/rpcs3/Emu/Cell/Modules/cellImeJp.cpp +++ b/rpcs3/Emu/Cell/Modules/cellImeJp.cpp @@ -886,7 +886,7 @@ error_code cellImeJpGetConfirmYomiString(CellImeJpHandle hImeJpHandle, vm::ptr(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->confirmed_string.length()); + const usz max_len = std::min(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->confirmed_string.length()); for (u32 i = 0; i < max_len; i++) { @@ -918,7 +918,7 @@ error_code cellImeJpGetConfirmString(CellImeJpHandle hImeJpHandle, vm::ptr pConfirmString[i] = 0; } - const size_t max_len = std::min(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->confirmed_string.length()); + const usz max_len = std::min(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->confirmed_string.length()); for (u32 i = 0; i < max_len; i++) { @@ -950,7 +950,7 @@ error_code cellImeJpGetConvertYomiString(CellImeJpHandle hImeJpHandle, vm::ptr(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->input_string.length()); + const usz max_len = std::min(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->input_string.length()); for (u32 i = 0; i < max_len; i++) { @@ -982,7 +982,7 @@ error_code cellImeJpGetConvertString(CellImeJpHandle hImeJpHandle, vm::ptr pConvertString[i] = 0; } - const size_t max_len = std::min(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->input_string.length()); + const usz max_len = std::min(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->input_string.length()); for (u32 i = 0; i < max_len; i++) { diff --git a/rpcs3/Emu/Cell/Modules/cellImeJp.h b/rpcs3/Emu/Cell/Modules/cellImeJp.h index e5c8fc5d28..adc9208629 100644 --- a/rpcs3/Emu/Cell/Modules/cellImeJp.h +++ b/rpcs3/Emu/Cell/Modules/cellImeJp.h @@ -118,8 +118,8 @@ struct ime_jp_manager std::u16string confirmed_string; std::u16string converted_string; std::u16string input_string; - size_t cursor = 0; - size_t cursor_end = 0; + usz cursor = 0; + usz cursor_end = 0; s16 fix_input_mode = CELL_IMEJP_FIXINMODE_OFF; s16 input_char_type = CELL_IMEJP_DSPCHAR_HIRA; s16 kana_input_mode = CELL_IMEJP_ROMAN_INPUT; diff --git a/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp b/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp index dd510aaf45..6bad8da26a 100644 --- a/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp @@ -234,7 +234,7 @@ error_code cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr data, const bool flip = current_outParam.outputMode == CELL_JPGDEC_BOTTOM_TO_TOP; const int bytesPerLine = static_cast(dataCtrlParam->outputBytesPerLine); - size_t image_size = width * height; + usz image_size = width * height; switch(current_outParam.outputColorSpace) { diff --git a/rpcs3/Emu/Cell/Modules/cellL10n.cpp b/rpcs3/Emu/Cell/Modules/cellL10n.cpp index 08021ae9ca..a527008a2c 100644 --- a/rpcs3/Emu/Cell/Modules/cellL10n.cpp +++ b/rpcs3/Emu/Cell/Modules/cellL10n.cpp @@ -231,11 +231,11 @@ s32 _ConvertStr(s32 src_code, const void *src, s32 src_len, s32 dst_code, void * #else s32 retValue = ConversionOK; iconv_t ict = iconv_open(dstCode, srcCode); - size_t srcLen = src_len; + usz srcLen = src_len; if (dst != NULL) { - size_t dstLen = *dst_len; - size_t ictd = iconv(ict, const_cast(reinterpret_cast(&src)), &srcLen, reinterpret_cast(&dst), &dstLen); + usz dstLen = *dst_len; + usz ictd = iconv(ict, const_cast(reinterpret_cast(&src)), &srcLen, reinterpret_cast(&dst), &dstLen); *dst_len -= dstLen; if (ictd == umax) { @@ -259,8 +259,8 @@ s32 _ConvertStr(s32 src_code, const void *src, s32 src_len, s32 dst_code, void * while (srcLen > 0) { char *bufPtr = buf; - size_t bufLeft = sizeof(buf); - size_t ictd = iconv(ict, const_cast(reinterpret_cast(&src)), &srcLen, reinterpret_cast(&dst), &bufLeft); + usz bufLeft = sizeof(buf); + usz ictd = iconv(ict, const_cast(reinterpret_cast(&src)), &srcLen, reinterpret_cast(&dst), &bufLeft); *dst_len += sizeof(buf) - bufLeft; if (ictd == umax && errno != E2BIG) { diff --git a/rpcs3/Emu/Cell/Modules/cellMic.h b/rpcs3/Emu/Cell/Modules/cellMic.h index f3a2cd918a..1c7fc60588 100644 --- a/rpcs3/Emu/Cell/Modules/cellMic.h +++ b/rpcs3/Emu/Cell/Modules/cellMic.h @@ -182,7 +182,7 @@ struct CellMicStatus // --- End of cell definitions --- -template +template class simple_ringbuf { public: @@ -337,7 +337,7 @@ private: u32 sample_size = 0; // Determined at opening for internal use - static constexpr std::size_t inbuf_size = 400000; // Default value unknown + static constexpr usz inbuf_size = 400000; // Default value unknown simple_ringbuf rbuf_raw; simple_ringbuf rbuf_dsp; diff --git a/rpcs3/Emu/Cell/Modules/cellPngDec.cpp b/rpcs3/Emu/Cell/Modules/cellPngDec.cpp index 9bb71b2125..3e05451535 100644 --- a/rpcs3/Emu/Cell/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellPngDec.cpp @@ -153,7 +153,7 @@ void pngDecInfoCallback(png_structp png_ptr, png_infop info) return; } - const size_t remaining = png_process_data_pause(png_ptr, false); + const usz remaining = png_process_data_pause(png_ptr, false); stream->buffer->cursor += (stream->buffer->length - remaining); } diff --git a/rpcs3/Emu/Cell/Modules/cellPngDec.h b/rpcs3/Emu/Cell/Modules/cellPngDec.h index a3a425e30e..55af2cfe3a 100644 --- a/rpcs3/Emu/Cell/Modules/cellPngDec.h +++ b/rpcs3/Emu/Cell/Modules/cellPngDec.h @@ -276,8 +276,8 @@ struct PngHandle struct PngBuffer { // The cursor location and data pointer for reading from a buffer - size_t cursor; - size_t length; + usz cursor; + usz length; vm::bptr data; // The file descriptor, and whether we need to read from a file descriptor diff --git a/rpcs3/Emu/Cell/Modules/cellPngEnc.h b/rpcs3/Emu/Cell/Modules/cellPngEnc.h index 025d0de8da..81ab2885fe 100644 --- a/rpcs3/Emu/Cell/Modules/cellPngEnc.h +++ b/rpcs3/Emu/Cell/Modules/cellPngEnc.h @@ -97,7 +97,7 @@ struct CellPngEncConfig struct CellPngEncAttr { - be_t memSize; // size_t + be_t memSize; // usz u8 cmdQueueDepth; be_t versionUpper; be_t versionLower; @@ -106,7 +106,7 @@ struct CellPngEncAttr struct CellPngEncResource { vm::bptr memAddr; - be_t memSize; // size_t + be_t memSize; // usz be_t ppuThreadPriority; be_t spuThreadPriority; }; @@ -114,7 +114,7 @@ struct CellPngEncResource struct CellPngEncResourceEx { vm::bptr memAddr; - be_t memSize; // size_t + be_t memSize; // usz be_t ppuThreadPriority; vm::bptr spurs; // CellSpurs u8 priority[8]; @@ -153,7 +153,7 @@ struct CellPngEncOutputParam be_t location; // CellPngEncLocation vm::bcptr streamFileName; vm::bptr streamAddr; - be_t limitSize; // size_t + be_t limitSize; // usz }; struct CellPngEncStreamInfo @@ -162,8 +162,8 @@ struct CellPngEncStreamInfo be_t location; // CellPngEncLocation vm::bcptr streamFileName; vm::bptr streamAddr; - be_t limitSize; // size_t - be_t streamSize; // size_t + be_t limitSize; // usz + be_t streamSize; // usz be_t processedLine; be_t userData; }; diff --git a/rpcs3/Emu/Cell/Modules/cellResc.h b/rpcs3/Emu/Cell/Modules/cellResc.h index 99e3ec4260..b25f3fca52 100644 --- a/rpcs3/Emu/Cell/Modules/cellResc.h +++ b/rpcs3/Emu/Cell/Modules/cellResc.h @@ -87,7 +87,7 @@ struct CellRescDsts struct CellRescInitConfig { - be_t size; // size_t + be_t size; // usz be_t resourcePolicy; be_t supportModes; be_t ratioMode; diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index 3a3c43568e..499d615e69 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -564,7 +564,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v } // Simulate idle time while data is being sent to VSH - const auto lv2_sleep = [](ppu_thread& ppu, size_t sleep_time) + const auto lv2_sleep = [](ppu_thread& ppu, usz sleep_time) { lv2_obj::sleep(ppu); std::this_thread::sleep_for(std::chrono::microseconds(sleep_time)); diff --git a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp index 159db88c69..1baf1b0bca 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp @@ -163,7 +163,7 @@ void fmt_class_string::format(std::string& out, u64 // Format as a C byte array for ease of use fmt::append(out, "{ "); - for (std::size_t i = 0;; i++) + for (usz i = 0;; i++) { if (i == std::size(sign.data) - 1) { @@ -490,7 +490,7 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle, } // Rename or discard certain entries based on the files found - const size_t kTargetBufferLength = 31; + const usz kTargetBufferLength = 31; char target[kTargetBufferLength + 1]; target[kTargetBufferLength] = 0; strcpy_trunc(target, fmt::format("TROP_%02d.SFM", static_cast(g_cfg.sys.language))); diff --git a/rpcs3/Emu/Cell/Modules/sceNpTus.cpp b/rpcs3/Emu/Cell/Modules/sceNpTus.cpp index af071649f4..870293bcd2 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTus.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTus.cpp @@ -17,7 +17,7 @@ static bool validateSlotIds(vm::cptr slotIdArray) } // TODO: how to properly iterate? - //for (size_t i = 0; i < slotIdArray.size(); ++i) + //for (usz i = 0; i < slotIdArray.size(); ++i) //{ // if (slotIdArray[i] < 0) // { @@ -66,7 +66,7 @@ sce_np_tus_title_context* sce_np_tus_manager::get_title_context(s32 titleCtxId) s32 sce_np_tus_manager::add_transaction_context(s32 titleCtxId) { - size_t transaction_count = 0; + usz transaction_count = 0; for (const auto& title_context : title_contexts) { diff --git a/rpcs3/Emu/Cell/Modules/sys_libc_.cpp b/rpcs3/Emu/Cell/Modules/sys_libc_.cpp index 6111ea55ff..a6177fc76d 100644 --- a/rpcs3/Emu/Cell/Modules/sys_libc_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_libc_.cpp @@ -16,47 +16,47 @@ struct ps3_fmt_src ppu_thread* ctx; u32 g_count; - bool test(std::size_t index) const + bool test(usz index) const { return true; } template - T get(std::size_t index) const + T get(usz index) const { const u32 i = static_cast(index) + g_count; return ppu_gpr_cast(i < 8 ? ctx->gpr[3 + i] : +*ctx->get_stack_arg(i)); } - void skip(std::size_t extra) + void skip(usz extra) { g_count += static_cast(extra) + 1; } - std::size_t fmt_string(std::string& out, std::size_t extra) const + usz fmt_string(std::string& out, usz extra) const { - const std::size_t start = out.size(); + const usz start = out.size(); out += vm::_ptr(get(extra)); return out.size() - start; } - std::size_t type(std::size_t extra) const + usz type(usz extra) const { return 0; } - static constexpr std::size_t size_char = 1; - static constexpr std::size_t size_short = 2; - static constexpr std::size_t size_int = 4; - static constexpr std::size_t size_long = 4; - static constexpr std::size_t size_llong = 8; - static constexpr std::size_t size_size = 4; - static constexpr std::size_t size_max = 8; - static constexpr std::size_t size_diff = 4; + static constexpr usz size_char = 1; + static constexpr usz size_short = 2; + static constexpr usz size_int = 4; + static constexpr usz size_long = 4; + static constexpr usz size_llong = 8; + static constexpr usz size_size = 4; + static constexpr usz size_max = 8; + static constexpr usz size_diff = 4; }; template <> -f64 ps3_fmt_src::get(std::size_t index) const +f64 ps3_fmt_src::get(usz index) const { return std::bit_cast(get(index)); } @@ -404,7 +404,7 @@ s32 _sys_snprintf(ppu_thread& ppu, vm::ptr dst, u32 count, vm::cptr } else { - count = static_cast(std::min(count - 1, result.size())); + count = static_cast(std::min(count - 1, result.size())); std::memcpy(dst.get_ptr(), result.c_str(), count); dst[count] = 0; diff --git a/rpcs3/Emu/Cell/PPUAnalyser.cpp b/rpcs3/Emu/Cell/PPUAnalyser.cpp index 905f21dd4d..42cb72c2d1 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.cpp +++ b/rpcs3/Emu/Cell/PPUAnalyser.cpp @@ -836,7 +836,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) } // Main loop (func_queue may grow) - for (std::size_t i = 0; i < func_queue.size(); i++) + for (usz i = 0; i < func_queue.size(); i++) { ppu_function& func = func_queue[i]; @@ -1187,7 +1187,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) const bool was_empty = block_queue.empty(); // Block loop (block_queue may grow, may be aborted via clearing) - for (std::size_t j = 0; j < block_queue.size(); j++) + for (usz j = 0; j < block_queue.size(); j++) { auto& block = block_queue[j].get(); diff --git a/rpcs3/Emu/Cell/PPUAnalyser.h b/rpcs3/Emu/Cell/PPUAnalyser.h index 5801220d55..24314acf60 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.h +++ b/rpcs3/Emu/Cell/PPUAnalyser.h @@ -117,9 +117,9 @@ struct ppu_pattern struct ppu_pattern_array { const ppu_pattern* ptr; - std::size_t count; + usz count; - template + template constexpr ppu_pattern_array(const ppu_pattern(&array)[N]) : ptr(array) , count(N) @@ -140,9 +140,9 @@ struct ppu_pattern_array struct ppu_pattern_matrix { const ppu_pattern_array* ptr; - std::size_t count; + usz count; - template + template constexpr ppu_pattern_matrix(const ppu_pattern_array(&array)[N]) : ptr(array) , count(N) diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index 82a159684d..53ac4c4f08 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -698,7 +698,7 @@ static void ppu_check_patch_spu_images(const ppu_segment& seg) { const std::string_view seg_view{vm::get_super_ptr(seg.addr), seg.size}; - for (std::size_t i = seg_view.find("\177ELF"); i < seg.size; i = seg_view.find("\177ELF", i + 4)) + for (usz i = seg_view.find("\177ELF"); i < seg.size; i = seg_view.find("\177ELF", i + 4)) { const auto elf_header = vm::get_super_ptr(seg.addr + i); @@ -715,7 +715,7 @@ static void ppu_check_patch_spu_images(const ppu_segment& seg) std::string name; std::string dump; - std::size_t applied = 0; + usz applied = 0; // Executable hash sha1_context sha2; @@ -867,7 +867,7 @@ std::shared_ptr ppu_load_prx(const ppu_prx_object& elf, const std::stri if (s.sh_type == 1u && addr && size) // TODO: some sections with addr=0 are valid { - for (std::size_t i = 0; i < prx->segs.size(); i++) + for (usz i = 0; i < prx->segs.size(); i++) { const u32 saddr = static_cast(elf.progs[i].p_vaddr); if (addr >= saddr && addr < saddr + elf.progs[i].p_memsz) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 28093be909..c4154c3bee 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -2105,7 +2105,7 @@ extern void ppu_initialize(const ppu_module& info) std::vector> globals; // Split module into fragments <= 1 MiB - std::size_t fpos = 0; + usz fpos = 0; // Difference between function name and current location const u32 reloc = info.name.empty() ? 0 : info.segs.at(0).addr; @@ -2139,7 +2139,7 @@ extern void ppu_initialize(const ppu_module& info) const u32 suffix = info.funcs.at(fstart).addr - reloc; // Overall block size in bytes - std::size_t bsize = 0; + usz bsize = 0; while (fpos < info.funcs.size()) { @@ -2455,7 +2455,7 @@ extern void ppu_initialize(const ppu_module& info) } else { - std::size_t index = 0; + usz index = 0; // Locate existing functions for (const auto& func : info.funcs) @@ -2544,7 +2544,7 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co //pm.add(createLintPass()); // Check // Translate functions - for (size_t fi = 0, fmax = module_part.funcs.size(); fi < fmax; fi++) + for (usz fi = 0, fmax = module_part.funcs.size(); fi < fmax; fi++) { if (Emu.IsStopped()) { diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index d25bba964c..99549b42dd 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -137,7 +137,7 @@ public: u8 bits[32]; u32 fields[8]; - u8& operator [](std::size_t i) + u8& operator [](usz i) { return bits[i]; } diff --git a/rpcs3/Emu/Cell/PPUTranslator.cpp b/rpcs3/Emu/Cell/PPUTranslator.cpp index a05b9331dd..c38c0881d7 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.cpp +++ b/rpcs3/Emu/Cell/PPUTranslator.cpp @@ -528,7 +528,7 @@ Value* PPUTranslator::Shuffle(Value* left, Value* right, std::initializer_list(type)->getNumElements() - 1; // Transform indices (works for vectors with size 2^N) - for (std::size_t i = 0; i < indices.size(); i++) + for (usz i = 0; i < indices.size(); i++) { data.push_back(indices.end()[~i] ^ mask); } diff --git a/rpcs3/Emu/Cell/PPUTranslator.h b/rpcs3/Emu/Cell/PPUTranslator.h index 6e0490f491..0de6123592 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.h +++ b/rpcs3/Emu/Cell/PPUTranslator.h @@ -209,20 +209,20 @@ public: // Create sign extension (with double size if type is nullptr) llvm::Value* SExt(llvm::Value* value, llvm::Type* = nullptr); - template + template std::array SExt(std::array values, llvm::Type* type = nullptr) { - for (std::size_t i = 0; i < N; i++) values[i] = SExt(values[i], type); + for (usz i = 0; i < N; i++) values[i] = SExt(values[i], type); return values; } // Create zero extension (with double size if type is nullptr) llvm::Value* ZExt(llvm::Value*, llvm::Type* = nullptr); - template + template std::array ZExt(std::array values, llvm::Type* type = nullptr) { - for (std::size_t i = 0; i < N; i++) values[i] = ZExt(values[i], type); + for (usz i = 0; i < N; i++) values[i] = ZExt(values[i], type); return values; } diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 68c018de2c..a89b148b72 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -389,7 +389,7 @@ void spu_cache::initialize() // Read cache auto func_list = cache.get(); - atomic_t fnext{}; + atomic_t fnext{}; atomic_t fail_flag{0}; if (g_cfg.core.spu_decoder == spu_decoder_type::fast || g_cfg.core.spu_decoder == spu_decoder_type::llvm) @@ -456,7 +456,7 @@ void spu_cache::initialize() std::vector> ls(0x10000); // Build functions - for (std::size_t func_i = fnext++; func_i < func_list.size(); func_i = fnext++) + for (usz func_i = fnext++; func_i < func_list.size(); func_i = fnext++) { const spu_program& func = std::as_const(func_list)[func_i]; @@ -750,7 +750,7 @@ spu_function_t spu_runtime::rebuild_ubertrampoline(u32 id_inst) // LS address starting from PC is already loaded into rcx (see spu_runtime::tr_all) - for (std::size_t i = 0; i < workload.size(); i++) + for (usz i = 0; i < workload.size(); i++) { // Get copy of the workload info auto w = workload[i]; @@ -1975,7 +1975,7 @@ spu_program spu_recompiler_base::analyse(const be_t* ls, u32 entry_point) workload.push_back(pair.first); m_bits[pair.first / 4] = true; - for (std::size_t i = 0; !reachable && i < workload.size(); i++) + for (usz i = 0; !reachable && i < workload.size(); i++) { for (u32 j = workload[i];; j -= 4) { @@ -4492,7 +4492,7 @@ public: m_function_table = new llvm::GlobalVariable(*m_module, llvm::ArrayType::get(entry_chunk->chunk->getType(), m_size / 4), true, llvm::GlobalValue::InternalLinkage, nullptr); // Create function chunks - for (std::size_t fi = 0; fi < m_function_queue.size(); fi++) + for (usz fi = 0; fi < m_function_queue.size(); fi++) { // Initialize function info m_entry = m_function_queue[fi]; @@ -4506,7 +4506,7 @@ public: m_ir->CreateBr(add_block(m_entry)); // Emit instructions for basic blocks - for (std::size_t bi = 0; bi < m_block_queue.size(); bi++) + for (usz bi = 0; bi < m_block_queue.size(); bi++) { // Initialize basic block info const u32 baddr = m_block_queue[bi]; diff --git a/rpcs3/Emu/Cell/lv2/lv2.cpp b/rpcs3/Emu/Cell/lv2/lv2.cpp index 2513c68e85..e083c0f8aa 100644 --- a/rpcs3/Emu/Cell/lv2/lv2.cpp +++ b/rpcs3/Emu/Cell/lv2/lv2.cpp @@ -1226,7 +1226,7 @@ bool lv2_obj::awake_unlocked(cpu_thread* cpu, s32 prio) case yield_cmd: { // Yield command - for (std::size_t i = 0;; i++) + for (usz i = 0;; i++) { if (i + 1 >= g_ppu.size()) { @@ -1235,7 +1235,7 @@ bool lv2_obj::awake_unlocked(cpu_thread* cpu, s32 prio) if (const auto ppu = g_ppu[i]; ppu == cpu) { - std::size_t j = i + 1; + usz j = i + 1; for (; j < g_ppu.size(); j++) { @@ -1325,7 +1325,7 @@ bool lv2_obj::awake_unlocked(cpu_thread* cpu, s32 prio) } // Suspend threads if necessary - for (std::size_t i = g_cfg.core.ppu_threads; changed_queue && i < g_ppu.size(); i++) + for (usz i = g_cfg.core.ppu_threads; changed_queue && i < g_ppu.size(); i++) { const auto target = g_ppu[i]; @@ -1352,7 +1352,7 @@ void lv2_obj::schedule_all() if (g_pending.empty()) { // Wake up threads - for (std::size_t i = 0, x = std::min(g_cfg.core.ppu_threads, g_ppu.size()); i < x; i++) + for (usz i = 0, x = std::min(g_cfg.core.ppu_threads, g_ppu.size()); i < x; i++) { const auto target = g_ppu[i]; diff --git a/rpcs3/Emu/Cell/lv2/sys_config.h b/rpcs3/Emu/Cell/lv2/sys_config.h index 936207bddf..cc8f60dbc2 100644 --- a/rpcs3/Emu/Cell/lv2/sys_config.h +++ b/rpcs3/Emu/Cell/lv2/sys_config.h @@ -238,7 +238,7 @@ public: const std::vector data; // Constructors (should not be used directly) - lv2_config_service(sys_config_service_id _id, u64 _user_id, u64 _verbosity, u32 _padding, const u8 _data[], size_t size) + lv2_config_service(sys_config_service_id _id, u64 _user_id, u64 _verbosity, u32 _padding, const u8 _data[], usz size) : timestamp(get_system_time()) , id(_id) , user_id(_user_id) @@ -269,7 +269,7 @@ public: void notify() const; // Utilities - size_t get_size() const { return sizeof(sys_config_service_event_t)-1 + data.size(); } + usz get_size() const { return sizeof(sys_config_service_event_t)-1 + data.size(); } std::shared_ptr get_shared_ptr () const { return wkptr.lock(); }; u32 get_id() const { return idm_id; } }; @@ -304,7 +304,7 @@ public: const std::vector data; // Constructors (should not be used directly) - lv2_config_service_listener(std::shared_ptr& _handle, sys_config_service_id _service_id, u64 _min_verbosity, sys_config_service_listener_type _type, const u8 _data[], size_t size) + lv2_config_service_listener(std::shared_ptr& _handle, sys_config_service_id _service_id, u64 _min_verbosity, sys_config_service_listener_type _type, const u8 _data[], usz size) : handle(_handle) , service_id(_service_id) , min_verbosity(_min_verbosity) @@ -406,7 +406,7 @@ public: void write(sys_config_service_event_t *dst); // Check if the buffer can fit the current event, return false otherwise - bool check_buffer_size(size_t size) const { return service->get_size() <= size; } + bool check_buffer_size(usz size) const { return service->get_size() <= size; } }; /* diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index a508a53388..34fe9613cf 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -57,7 +57,7 @@ lv2_fs_mount_point* lv2_fs_object::get_mp(std::string_view filename) { std::string_view mp_name, vpath = filename; - for (std::size_t depth = 0;;) + for (usz depth = 0;;) { // Skip one or more '/' const auto pos = vpath.find_first_not_of('/'); @@ -833,7 +833,7 @@ error_code sys_fs_readdir(ppu_thread& ppu, u32 fd, vm::ptr dir, vm if (auto* info = directory->dir_read()) { dir->d_type = info->is_directory ? CELL_FS_TYPE_DIRECTORY : CELL_FS_TYPE_REGULAR; - dir->d_namlen = u8(std::min(info->name.size(), CELL_FS_MAX_FS_FILE_NAME_LENGTH)); + dir->d_namlen = u8(std::min(info->name.size(), CELL_FS_MAX_FS_FILE_NAME_LENGTH)); strcpy_trunc(dir->d_name, info->name); *nread = sizeof(CellFsDirent); } @@ -1570,7 +1570,7 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr _arg, u32 } entry.entry_name.d_type = info->is_directory ? CELL_FS_TYPE_DIRECTORY : CELL_FS_TYPE_REGULAR; - entry.entry_name.d_namlen = u8(std::min(info->name.size(), CELL_FS_MAX_FS_FILE_NAME_LENGTH)); + entry.entry_name.d_namlen = u8(std::min(info->name.size(), CELL_FS_MAX_FS_FILE_NAME_LENGTH)); strcpy_trunc(entry.entry_name.d_name, info->name); } } diff --git a/rpcs3/Emu/Cell/lv2/sys_net.cpp b/rpcs3/Emu/Cell/lv2/sys_net.cpp index fb6fd255a9..d460a55c57 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_net.cpp @@ -518,7 +518,7 @@ struct nt_p2p_port } } - static u16 tcp_checksum(const u16* buffer, std::size_t size) + static u16 tcp_checksum(const u16* buffer, usz size) { u32 cksum = 0; while (size > 1) @@ -1051,7 +1051,7 @@ struct network_thread std::lock_guard lock(s_nw_mutex); - for (std::size_t i = 0; i < socklist.size(); i++) + for (usz i = 0; i < socklist.size(); i++) { bs_t events{}; @@ -1114,7 +1114,7 @@ struct network_thread socklist.emplace_back(idm::get_unlocked(id)); }); - for (std::size_t i = 0; i < socklist.size(); i++) + for (usz i = 0; i < socklist.size(); i++) { #ifdef _WIN32 std::lock_guard lock(socklist[i]->mutex); diff --git a/rpcs3/Emu/Cell/lv2/sys_net.h b/rpcs3/Emu/Cell/lv2/sys_net.h index b457880a7e..ecac036bf1 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net.h +++ b/rpcs3/Emu/Cell/lv2/sys_net.h @@ -382,7 +382,7 @@ struct lv2_socket final }; static constexpr be_t U2S_sig = (static_cast('U') << 24 | static_cast('2') << 16 | static_cast('S') << 8 | static_cast('0')); - static constexpr std::size_t MAX_RECEIVED_BUFFER = (1024*1024*10); + static constexpr usz MAX_RECEIVED_BUFFER = (1024*1024*10); // P2P stream socket specific struct encapsulated_tcp @@ -407,7 +407,7 @@ struct lv2_socket final stream_status status = stream_status::stream_closed; - std::size_t max_backlog = 0; // set on listen + usz max_backlog = 0; // set on listen std::queue backlog; u16 op_port = 0, op_vport = 0; diff --git a/rpcs3/Emu/Cell/lv2/sys_overlay.h b/rpcs3/Emu/Cell/lv2/sys_overlay.h index 3af02c3b93..c7f133c367 100644 --- a/rpcs3/Emu/Cell/lv2/sys_overlay.h +++ b/rpcs3/Emu/Cell/lv2/sys_overlay.h @@ -13,7 +13,7 @@ struct lv2_overlay final : lv2_obj, ppu_module error_code sys_overlay_load_module(vm::ptr ovlmid, vm::cptr path, u64 flags, vm::ptr entry); error_code sys_overlay_load_module_by_fd(vm::ptr ovlmid, u32 fd, u64 offset, u64 flags, vm::ptr entry); error_code sys_overlay_unload_module(u32 ovlmid); -//error_code sys_overlay_get_module_list(sys_pid_t pid, size_t ovlmids_num, sys_overlay_t * ovlmids, size_t * num_of_modules); +//error_code sys_overlay_get_module_list(sys_pid_t pid, usz ovlmids_num, sys_overlay_t * ovlmids, usz * num_of_modules); //error_code sys_overlay_get_module_info(sys_pid_t pid, sys_overlay_t ovlmid, sys_overlay_module_info_t * info); //error_code sys_overlay_get_module_info2(sys_pid_t pid, sys_overlay_t ovlmid, sys_overlay_module_info2_t * info);// //error_code sys_overlay_get_sdk_version(); //2 params diff --git a/rpcs3/Emu/Cell/lv2/sys_process.cpp b/rpcs3/Emu/Cell/lv2/sys_process.cpp index 5d840fcc7d..a5956004d8 100644 --- a/rpcs3/Emu/Cell/lv2/sys_process.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_process.cpp @@ -267,7 +267,7 @@ error_code _sys_process_get_paramsfo(vm::ptr buffer) } memset(buffer.get_ptr(), 0, 0x40); - memcpy(buffer.get_ptr() + 1, Emu.GetTitleID().c_str(), std::min(Emu.GetTitleID().length(), 9)); + memcpy(buffer.get_ptr() + 1, Emu.GetTitleID().c_str(), std::min(Emu.GetTitleID().length(), 9)); return CELL_OK; } diff --git a/rpcs3/Emu/Cell/lv2/sys_rsx.cpp b/rpcs3/Emu/Cell/lv2/sys_rsx.cpp index e69a067ea8..b56b421059 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rsx.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_rsx.cpp @@ -207,10 +207,10 @@ error_code sys_rsx_context_allocate(cpu_thread& cpu, vm::ptr context_id, vm auto &reports = vm::_ref(vm::cast(*lpar_reports)); std::memset(&reports, 0, sizeof(RsxReports)); - for (size_t i = 0; i < std::size(reports.notify); ++i) + for (usz i = 0; i < std::size(reports.notify); ++i) reports.notify[i].timestamp = -1; - for (size_t i = 0; i < std::size(reports.semaphore); i += 4) + for (usz i = 0; i < std::size(reports.semaphore); i += 4) { reports.semaphore[i + 0].val.raw() = 0x1337C0D3; reports.semaphore[i + 1].val.raw() = 0x1337BABE; @@ -218,7 +218,7 @@ error_code sys_rsx_context_allocate(cpu_thread& cpu, vm::ptr context_id, vm reports.semaphore[i + 3].val.raw() = 0x1337F001; } - for (size_t i = 0; i < std::size(reports.report); ++i) + for (usz i = 0; i < std::size(reports.report); ++i) { reports.report[i].val = 0; reports.report[i].timestamp = -1; diff --git a/rpcs3/Emu/Cell/lv2/sys_tty.cpp b/rpcs3/Emu/Cell/lv2/sys_tty.cpp index 4c4a3bc627..52cd126f5d 100644 --- a/rpcs3/Emu/Cell/lv2/sys_tty.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_tty.cpp @@ -32,7 +32,7 @@ error_code sys_tty_read(s32 ch, vm::ptr buf, u32 len, vm::ptr preadle sys_tty.warning("sys_tty_read called with system channel %d", ch); } - size_t chars_to_read = 0; // number of chars that will be read from the input string + usz chars_to_read = 0; // number of chars that will be read from the input string std::string tty_read; // string for storage of read chars if (len > 0) @@ -45,15 +45,15 @@ error_code sys_tty_read(s32 ch, vm::ptr buf, u32 len, vm::ptr preadle std::string& input = g_tty_input[ch].front(); // we have to stop reading at either a new line, the param len, or our input string size - size_t new_line_pos = input.find_first_of('\n'); + usz new_line_pos = input.find_first_of('\n'); if (new_line_pos != input.npos) { - chars_to_read = std::min(new_line_pos, static_cast(len)); + chars_to_read = std::min(new_line_pos, static_cast(len)); } else { - chars_to_read = std::min(input.size(), static_cast(len)); + chars_to_read = std::min(input.size(), static_cast(len)); } // read the previously calculated number of chars from the beginning of the input string diff --git a/rpcs3/Emu/GDB.cpp b/rpcs3/Emu/GDB.cpp index b5fd841709..a4d2c94f06 100644 --- a/rpcs3/Emu/GDB.cpp +++ b/rpcs3/Emu/GDB.cpp @@ -350,7 +350,7 @@ void gdb_thread::send_cmd(const std::string& cmd) std::string buf; buf.reserve(cmd.length() + 4); buf += "$"; - for (std::size_t i = 0; i < cmd.length(); ++i) + for (usz i = 0; i < cmd.length(); ++i) { checksum = (checksum + append_encoded_char(cmd[i], buf)) % 256; } @@ -590,7 +590,7 @@ bool gdb_thread::cmd_write_register(gdb_cmd& cmd) auto th = selected_thread.lock(); if (th->id_type() == 1) { auto ppu = static_cast*>(th.get()); - size_t eq_pos = cmd.data.find('='); + usz eq_pos = cmd.data.find('='); if (eq_pos == umax) { GDB.warning("Wrong write_register cmd data '%s'.", cmd.data); return send_cmd_ack("E02"); @@ -609,7 +609,7 @@ bool gdb_thread::cmd_write_register(gdb_cmd& cmd) bool gdb_thread::cmd_read_memory(gdb_cmd& cmd) { - size_t s = cmd.data.find(','); + usz s = cmd.data.find(','); u32 addr = hex_to_u32(cmd.data.substr(0, s)); u32 len = hex_to_u32(cmd.data.substr(s + 1)); std::string result; @@ -631,8 +631,8 @@ bool gdb_thread::cmd_read_memory(gdb_cmd& cmd) bool gdb_thread::cmd_write_memory(gdb_cmd& cmd) { - size_t s = cmd.data.find(','); - size_t s2 = cmd.data.find(':'); + usz s = cmd.data.find(','); + usz s2 = cmd.data.find(':'); if ((s == umax) || (s2 == umax)) { GDB.warning("Malformed write memory request received: '%s'.", cmd.data); return send_cmd_ack("E01"); diff --git a/rpcs3/Emu/Io/PadHandler.cpp b/rpcs3/Emu/Io/PadHandler.cpp index 1fc66ad006..d97f7a0642 100644 --- a/rpcs3/Emu/Io/PadHandler.cpp +++ b/rpcs3/Emu/Io/PadHandler.cpp @@ -253,7 +253,7 @@ std::string PadHandlerBase::name_string() const return m_name_string; } -size_t PadHandlerBase::max_devices() const +usz PadHandlerBase::max_devices() const { return m_max_devices; } @@ -615,7 +615,7 @@ void PadHandlerBase::get_mapping(const std::shared_ptr& device, const void PadHandlerBase::ThreadProc() { - for (size_t i = 0; i < bindings.size(); ++i) + for (usz i = 0; i < bindings.size(); ++i) { auto device = bindings[i].first; auto pad = bindings[i].second; diff --git a/rpcs3/Emu/Io/PadHandler.h b/rpcs3/Emu/Io/PadHandler.h index 7a6f3f5319..0de911141a 100644 --- a/rpcs3/Emu/Io/PadHandler.h +++ b/rpcs3/Emu/Io/PadHandler.h @@ -62,7 +62,7 @@ protected: std::array last_connection_status{{ false, false, false, false, false, false, false }}; std::string m_name_string; - size_t m_max_devices = 0; + usz m_max_devices = 0; int m_trigger_threshold = 0; int m_thumb_threshold = 0; @@ -132,7 +132,7 @@ public: pad_handler m_type; std::string name_string() const; - size_t max_devices() const; + usz max_devices() const; bool has_config() const; bool has_rumble() const; bool has_deadzones() const; diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index 6a1a72e6d8..06e337ad5a 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -1103,7 +1103,7 @@ namespace vm // Fill stack guards with STACKGRD if (this->flags & 0x10) { - auto fill64 = [](u8* ptr, u64 data, std::size_t count) + auto fill64 = [](u8* ptr, u64 data, usz count) { u64* target = reinterpret_cast(ptr); diff --git a/rpcs3/Emu/NP/fb_helpers.cpp b/rpcs3/Emu/NP/fb_helpers.cpp index de00c5139f..7545043e4e 100644 --- a/rpcs3/Emu/NP/fb_helpers.cpp +++ b/rpcs3/Emu/NP/fb_helpers.cpp @@ -41,17 +41,17 @@ void np_handler::RoomGroup_to_SceNpMatching2RoomGroup(const flatbuffers::Vector< void np_handler::UserInfo2_to_SceNpUserInfo2(const UserInfo2* user, SceNpUserInfo2* user_info) { if (user->npId()) - memcpy(user_info->npId.handle.data, user->npId()->c_str(), std::min(sizeof(user_info->npId.handle.data), static_cast(user->npId()->size()))); + memcpy(user_info->npId.handle.data, user->npId()->c_str(), std::min(sizeof(user_info->npId.handle.data), static_cast(user->npId()->size()))); if (user->onlineName()) { user_info->onlineName.set(allocate(sizeof(SceNpOnlineName))); - memcpy(user_info->onlineName->data, user->onlineName()->c_str(), std::min(sizeof(user_info->onlineName->data), static_cast(user->onlineName()->size()))); + memcpy(user_info->onlineName->data, user->onlineName()->c_str(), std::min(sizeof(user_info->onlineName->data), static_cast(user->onlineName()->size()))); } if (user->avatarUrl()) { user_info->avatarUrl.set(allocate(sizeof(SceNpAvatarUrl))); - memcpy(user_info->avatarUrl->data, user->avatarUrl()->c_str(), std::min(sizeof(user_info->avatarUrl->data), static_cast(user->avatarUrl()->size()))); + memcpy(user_info->avatarUrl->data, user->avatarUrl()->c_str(), std::min(sizeof(user_info->avatarUrl->data), static_cast(user->avatarUrl()->size()))); } } @@ -283,7 +283,7 @@ void np_handler::RoomMemberUpdateInfo_to_SceNpMatching2RoomMemberUpdateInfo(cons if (update_info->optData()) { sce_update_info->optData.length = update_info->optData()->data()->size(); - for (size_t i = 0; i < 16; i++) + for (usz i = 0; i < 16; i++) { sce_update_info->optData.data[i] = update_info->optData()->data()->Get(i); } @@ -335,7 +335,7 @@ void np_handler::RoomUpdateInfo_to_SceNpMatching2RoomUpdateInfo(const RoomUpdate if (update_info->optData()) { sce_update_info->optData.length = update_info->optData()->data()->size(); - for (size_t i = 0; i < 16; i++) + for (usz i = 0; i < 16; i++) { sce_update_info->optData.data[i] = update_info->optData()->data()->Get(i); } diff --git a/rpcs3/Emu/NP/np_handler.cpp b/rpcs3/Emu/NP/np_handler.cpp index baa2c0477d..5c00d186bb 100644 --- a/rpcs3/Emu/NP/np_handler.cpp +++ b/rpcs3/Emu/NP/np_handler.cpp @@ -77,7 +77,7 @@ np_handler::np_handler() // Init switch map for dns auto swaps = fmt::split(g_cfg.net.swap_list.to_string(), {"&&"}); - for (std::size_t i = 0; i < swaps.size(); i++) + for (usz i = 0; i < swaps.size(); i++) { auto host_and_ip = fmt::split(swaps[i], {"="}); if (host_and_ip.size() != 2) @@ -741,7 +741,7 @@ bool np_handler::reply_get_world_list(u32 req_id, std::vector& reply_data) if (!world_list.empty()) { world_info->world.set(allocate(sizeof(SceNpMatching2World) * world_list.size())); - for (size_t i = 0; i < world_list.size(); i++) + for (usz i = 0; i < world_list.size(); i++) { world_info->world[i].worldId = world_list[i]; world_info->world[i].numOfLobby = 1; // TODO @@ -1343,7 +1343,7 @@ u32 np_handler::generate_callback_info(SceNpMatching2ContextId ctx_id, vm::cptr< return req_id; } -u8* np_handler::allocate_req_result(u32 event_key, size_t size) +u8* np_handler::allocate_req_result(u32 event_key, usz size) { std::lock_guard lock(mutex_req_results); match2_req_results[event_key] = std::vector(size, 0); diff --git a/rpcs3/Emu/NP/np_handler.h b/rpcs3/Emu/NP/np_handler.h index 2fa4667f07..190895da5d 100644 --- a/rpcs3/Emu/NP/np_handler.h +++ b/rpcs3/Emu/NP/np_handler.h @@ -204,7 +204,7 @@ protected: return match2_event_cnt.fetch_add(1); } shared_mutex mutex_req_results; - u8* allocate_req_result(u32 event_key, size_t size); + u8* allocate_req_result(u32 event_key, usz size); // RPCN rpcn_client rpcn; diff --git a/rpcs3/Emu/NP/rpcn_client.cpp b/rpcs3/Emu/NP/rpcn_client.cpp index 332c57d0e9..7ac92a1d52 100644 --- a/rpcs3/Emu/NP/rpcn_client.cpp +++ b/rpcs3/Emu/NP/rpcn_client.cpp @@ -91,11 +91,11 @@ void rpcn_client::disconnect() server_info_received = false; } -rpcn_client::recvn_result rpcn_client::recvn(u8* buf, std::size_t n) +rpcn_client::recvn_result rpcn_client::recvn(u8* buf, usz n) { u32 num_timeouts = 0; - size_t n_recv = 0; + usz n_recv = 0; while (n_recv != n && !is_abort()) { std::lock_guard lock(mutex_socket); @@ -136,7 +136,7 @@ rpcn_client::recvn_result rpcn_client::recvn(u8* buf, std::size_t n) bool rpcn_client::send_packet(const std::vector& packet) { u32 num_timeouts = 0; - std::size_t n_sent = 0; + usz n_sent = 0; while (n_sent != packet.size()) { std::lock_guard lock(mutex_socket); @@ -723,7 +723,7 @@ bool rpcn_client::createjoin_room(u32 req_id, const SceNpCommunicationId& commun builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); - size_t bufsize = builder.GetSize(); + usz bufsize = builder.GetSize(); data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); @@ -767,7 +767,7 @@ bool rpcn_client::join_room(u32 req_id, const SceNpCommunicationId& communicatio builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); - size_t bufsize = builder.GetSize(); + usz bufsize = builder.GetSize(); data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); @@ -789,7 +789,7 @@ bool rpcn_client::leave_room(u32 req_id, const SceNpCommunicationId& communicati auto req_finished = CreateLeaveRoomRequest(builder, req->roomId, final_optdata); builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); - size_t bufsize = builder.GetSize(); + usz bufsize = builder.GetSize(); data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); @@ -855,7 +855,7 @@ bool rpcn_client::search_room(u32 req_id, const SceNpCommunicationId& communicat auto req_finished = s_req.Finish(); builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); - size_t bufsize = builder.GetSize(); + usz bufsize = builder.GetSize(); data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); @@ -910,7 +910,7 @@ bool rpcn_client::set_roomdata_external(u32 req_id, const SceNpCommunicationId& builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); - size_t bufsize = builder.GetSize(); + usz bufsize = builder.GetSize(); data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); @@ -937,7 +937,7 @@ bool rpcn_client::get_roomdata_internal(u32 req_id, const SceNpCommunicationId& builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); - size_t bufsize = builder.GetSize(); + usz bufsize = builder.GetSize(); data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); @@ -992,7 +992,7 @@ bool rpcn_client::set_roomdata_internal(u32 req_id, const SceNpCommunicationId& builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); - size_t bufsize = builder.GetSize(); + usz bufsize = builder.GetSize(); data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); @@ -1051,7 +1051,7 @@ bool rpcn_client::send_room_message(u32 req_id, const SceNpCommunicationId& comm builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); - size_t bufsize = builder.GetSize(); + usz bufsize = builder.GetSize(); data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); diff --git a/rpcs3/Emu/NP/rpcn_client.h b/rpcs3/Emu/NP/rpcn_client.h index 1902cffcd5..6d53e9d652 100644 --- a/rpcs3/Emu/NP/rpcn_client.h +++ b/rpcs3/Emu/NP/rpcn_client.h @@ -27,7 +27,7 @@ class vec_stream { public: vec_stream() = delete; - vec_stream(std::vector& _vec, size_t initial_index = 0) + vec_stream(std::vector& _vec, usz initial_index = 0) : vec(_vec) , i(initial_index){}; bool is_error() const @@ -86,7 +86,7 @@ public: { value = reinterpret_cast>(value); // resize + memcpy instead? - for (size_t index = 0; index < sizeof(T); index++) + for (usz index = 0; index < sizeof(T); index++) { vec.push_back(*(reinterpret_cast(&value) + index)); } @@ -99,7 +99,7 @@ public: protected: std::vector& vec; - size_t i = 0; + usz i = 0; bool error = false; }; @@ -207,7 +207,7 @@ protected: recvn_fatal, }; - recvn_result recvn(u8* buf, std::size_t n); + recvn_result recvn(u8* buf, usz n); bool get_reply(u32 expected_id, std::vector& data); diff --git a/rpcs3/Emu/RSX/Capture/rsx_capture.cpp b/rpcs3/Emu/RSX/Capture/rsx_capture.cpp index 54ca7cdea2..a20a2aec03 100644 --- a/rpcs3/Emu/RSX/Capture/rsx_capture.cpp +++ b/rpcs3/Emu/RSX/Capture/rsx_capture.cpp @@ -78,7 +78,7 @@ namespace rsx auto layout = get_subresources_layout(tex); // todo: dont use this function and just get size somehow - size_t texSize = 0; + usz texSize = 0; for (const auto& l : layout) texSize += l.data.size(); @@ -104,7 +104,7 @@ namespace rsx auto layout = get_subresources_layout(tex); // todo: dont use this function and just get size somehow - size_t texSize = 0; + usz texSize = 0; for (const auto& l : layout) texSize += l.data.size(); @@ -147,7 +147,7 @@ namespace rsx { const auto& range = method_registers.current_draw_clause.get_range(); const u32 vertCount = range.count; - const size_t bufferSize = (vertCount - 1) * vertStride + vertSize; + const usz bufferSize = (vertCount - 1) * vertStride + vertSize; frame_capture_data::memory_block block; block.offset = base_address + (range.first * vertStride); @@ -186,7 +186,7 @@ namespace rsx const u32 idxCount = range.count; const u32 idxAddr = base_addr + (idxFirst * type_size); - const size_t bufferSize = idxCount * type_size; + const usz bufferSize = idxCount * type_size; frame_capture_data::memory_block block; block.offset = base_address + (idxFirst * type_size); diff --git a/rpcs3/Emu/RSX/Capture/rsx_replay.cpp b/rpcs3/Emu/RSX/Capture/rsx_replay.cpp index f20bc7150a..c9f4091a36 100644 --- a/rpcs3/Emu/RSX/Capture/rsx_replay.cpp +++ b/rpcs3/Emu/RSX/Capture/rsx_replay.cpp @@ -185,7 +185,7 @@ namespace rsx auto render = get_current_renderer(); auto last_flip = render->int_flip_index; - size_t stopIdx = 0; + usz stopIdx = 0; for (const auto& replay_cmd : frame->replay_commands) { while (Emu.IsPaused()) diff --git a/rpcs3/Emu/RSX/CgBinaryProgram.h b/rpcs3/Emu/RSX/CgBinaryProgram.h index e61172e7bd..4cd600329c 100644 --- a/rpcs3/Emu/RSX/CgBinaryProgram.h +++ b/rpcs3/Emu/RSX/CgBinaryProgram.h @@ -121,7 +121,7 @@ class CgBinaryDisasm std::string m_path; // used for FP decompiler thread, delete this later u8* m_buffer = nullptr; - std::size_t m_buffer_size = 0; + usz m_buffer_size = 0; std::string m_arb_shader; std::string m_glsl_shader; std::string m_dst_reg_name; @@ -138,8 +138,8 @@ class CgBinaryDisasm // VP members u32 m_sca_opcode; u32 m_vec_opcode; - static const size_t m_max_instr_count = 512; - size_t m_instr_count; + static const usz m_max_instr_count = 512; + usz m_instr_count; std::vector m_data; public: @@ -298,7 +298,7 @@ public: fs::file f(m_path); if (!f) return; - size_t size = f.size(); + usz size = f.size(); vm::init(); ptr = vm::alloc(static_cast(size), vm::main); f.read(vm::base(ptr), size); diff --git a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h index a5e9c20091..82824f121b 100644 --- a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h +++ b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h @@ -114,8 +114,8 @@ struct temp_register /** * This class is used to translate RSX Fragment program to GLSL/HLSL code * Backend with text based shader can subclass this class and implement : - * - virtual std::string getFloatTypeName(size_t elementCount) = 0; - * - virtual std::string getHalfTypeName(size_t elementCount) = 0; + * - virtual std::string getFloatTypeName(usz elementCount) = 0; + * - virtual std::string getHalfTypeName(usz elementCount) = 0; * - virtual std::string getFunction(enum class FUNCTION) = 0; * - virtual std::string saturate(const std::string &code) = 0; * - virtual std::string compareFunction(enum class COMPARE, const std::string &, const std::string &) = 0; @@ -214,11 +214,11 @@ protected: /** returns the type name of float vectors. */ - virtual std::string getFloatTypeName(size_t elementCount) = 0; + virtual std::string getFloatTypeName(usz elementCount) = 0; /** returns the type name of half vectors. */ - virtual std::string getHalfTypeName(size_t elementCount) = 0; + virtual std::string getHalfTypeName(usz elementCount) = 0; /** returns string calling function where arguments are passed via * $0 $1 $2 substring. diff --git a/rpcs3/Emu/RSX/Common/GLSLCommon.h b/rpcs3/Emu/RSX/Common/GLSLCommon.h index ad63aa405a..20209c60a8 100644 --- a/rpcs3/Emu/RSX/Common/GLSLCommon.h +++ b/rpcs3/Emu/RSX/Common/GLSLCommon.h @@ -135,7 +135,7 @@ namespace program_common namespace glsl { - static std::string getFloatTypeNameImpl(size_t elementCount) + static std::string getFloatTypeNameImpl(usz elementCount) { switch (elementCount) { @@ -152,7 +152,7 @@ namespace glsl } } - static std::string getHalfTypeNameImpl(size_t elementCount) + static std::string getHalfTypeNameImpl(usz elementCount) { switch (elementCount) { diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.cpp b/rpcs3/Emu/RSX/Common/ProgramStateCache.cpp index 3bb2a57e68..9172d4d6d9 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.cpp +++ b/rpcs3/Emu/RSX/Common/ProgramStateCache.cpp @@ -7,12 +7,12 @@ using namespace program_hash_util; -size_t vertex_program_utils::get_vertex_program_ucode_hash(const RSXVertexProgram &program) +usz vertex_program_utils::get_vertex_program_ucode_hash(const RSXVertexProgram &program) { // 64-bit Fowler/Noll/Vo FNV-1a hash code - size_t hash = 0xCBF29CE484222325ULL; + usz hash = 0xCBF29CE484222325ULL; const void* instbuffer = program.data.data(); - size_t instIndex = 0; + usz instIndex = 0; bool end = false; for (unsigned i = 0; i < program.data.size() / 4; i++) { @@ -248,9 +248,9 @@ vertex_program_utils::vertex_program_metadata vertex_program_utils::analyse_vert return result; } -size_t vertex_program_storage_hash::operator()(const RSXVertexProgram &program) const +usz vertex_program_storage_hash::operator()(const RSXVertexProgram &program) const { - size_t hash = vertex_program_utils::get_vertex_program_ucode_hash(program); + usz hash = vertex_program_utils::get_vertex_program_ucode_hash(program); hash ^= program.output_mask; hash ^= program.texture_dimensions; return hash; @@ -271,7 +271,7 @@ bool vertex_program_compare::operator()(const RSXVertexProgram &binary1, const R const void* instBuffer1 = binary1.data.data(); const void* instBuffer2 = binary2.data.data(); - size_t instIndex = 0; + usz instIndex = 0; for (unsigned i = 0; i < binary1.data.size() / 4; i++) { const auto active = binary1.instruction_mask[instIndex]; @@ -302,10 +302,10 @@ bool fragment_program_utils::is_constant(u32 sourceOperand) return ((sourceOperand >> 8) & 0x3) == 2; } -size_t fragment_program_utils::get_fragment_program_ucode_size(const void* ptr) +usz fragment_program_utils::get_fragment_program_ucode_size(const void* ptr) { const auto instBuffer = ptr; - size_t instIndex = 0; + usz instIndex = 0; while (true) { const v128 inst = v128::loadu(instBuffer, instIndex); @@ -420,12 +420,12 @@ fragment_program_utils::fragment_program_metadata fragment_program_utils::analys return result; } -size_t fragment_program_utils::get_fragment_program_ucode_hash(const RSXFragmentProgram& program) +usz fragment_program_utils::get_fragment_program_ucode_hash(const RSXFragmentProgram& program) { // 64-bit Fowler/Noll/Vo FNV-1a hash code - size_t hash = 0xCBF29CE484222325ULL; + usz hash = 0xCBF29CE484222325ULL; const void* instbuffer = program.get_data(); - size_t instIndex = 0; + usz instIndex = 0; while (true) { const auto inst = v128::loadu(instbuffer, instIndex); @@ -447,9 +447,9 @@ size_t fragment_program_utils::get_fragment_program_ucode_hash(const RSXFragment return 0; } -size_t fragment_program_storage_hash::operator()(const RSXFragmentProgram& program) const +usz fragment_program_storage_hash::operator()(const RSXFragmentProgram& program) const { - size_t hash = fragment_program_utils::get_fragment_program_ucode_hash(program); + usz hash = fragment_program_utils::get_fragment_program_ucode_hash(program); hash ^= program.ctrl; hash ^= program.texture_dimensions; hash ^= program.unnormalized_coords; @@ -469,7 +469,7 @@ bool fragment_program_compare::operator()(const RSXFragmentProgram& binary1, con const void* instBuffer1 = binary1.get_data(); const void* instBuffer2 = binary2.get_data(); - size_t instIndex = 0; + usz instIndex = 0; while (true) { const auto inst1 = v128::loadu(instBuffer1, instIndex); diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.h b/rpcs3/Emu/RSX/Common/ProgramStateCache.h index 69d866081d..6d1acd1808 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.h +++ b/rpcs3/Emu/RSX/Common/ProgramStateCache.h @@ -27,14 +27,14 @@ namespace program_hash_util u32 referenced_textures_mask; }; - static size_t get_vertex_program_ucode_hash(const RSXVertexProgram &program); + static usz get_vertex_program_ucode_hash(const RSXVertexProgram &program); static vertex_program_metadata analyse_vertex_program(const u32* data, u32 entry, RSXVertexProgram& dst_prog); }; struct vertex_program_storage_hash { - size_t operator()(const RSXVertexProgram &program) const; + usz operator()(const RSXVertexProgram &program) const; }; struct vertex_program_compare @@ -61,16 +61,16 @@ namespace program_hash_util */ static bool is_constant(u32 sourceOperand); - static size_t get_fragment_program_ucode_size(const void* ptr); + static usz get_fragment_program_ucode_size(const void* ptr); static fragment_program_metadata analyse_fragment_program(const void* ptr); - static size_t get_fragment_program_ucode_hash(const RSXFragmentProgram &program); + static usz get_fragment_program_ucode_hash(const RSXFragmentProgram &program); }; struct fragment_program_storage_hash { - size_t operator()(const RSXFragmentProgram &program) const; + usz operator()(const RSXFragmentProgram &program) const; }; struct fragment_program_compare @@ -90,8 +90,8 @@ namespace program_hash_util * - a typedef PipelineProperties to a type that encapsulate various state info relevant to program compilation (alpha test, primitive type,...) * - a typedef ExtraData type that will be passed to the buildProgram function. * It should also contains the following function member : -* - static void recompile_fragment_program(RSXFragmentProgram *RSXFP, FragmentProgramData& fragmentProgramData, size_t ID); -* - static void recompile_vertex_program(RSXVertexProgram *RSXVP, VertexProgramData& vertexProgramData, size_t ID); +* - static void recompile_fragment_program(RSXFragmentProgram *RSXFP, FragmentProgramData& fragmentProgramData, usz ID); +* - static void recompile_vertex_program(RSXVertexProgram *RSXVP, VertexProgramData& vertexProgramData, usz ID); * - static PipelineData build_program(VertexProgramData &vertexProgramData, FragmentProgramData &fragmentProgramData, const PipelineProperties &pipelineProperties, const ExtraData& extraData); * - static void validate_pipeline_properties(const VertexProgramData &vertexProgramData, const FragmentProgramData &fragmentProgramData, PipelineProperties& props); */ @@ -116,9 +116,9 @@ class program_state_cache struct pipeline_key_hash { - size_t operator()(const pipeline_key &key) const + usz operator()(const pipeline_key &key) const { - size_t hashValue = 0; + usz hashValue = 0; hashValue ^= rpcs3::hash_base(key.vertex_program_id); hashValue ^= rpcs3::hash_base(key.fragment_program_id); hashValue ^= rpcs3::hash_struct(key.properties); @@ -142,7 +142,7 @@ protected: shared_mutex m_pipeline_mutex; shared_mutex m_decompiler_mutex; - atomic_t m_next_id = 0; + atomic_t m_next_id = 0; bool m_cache_miss_flag; // Set if last lookup did not find any usable cached programs binary_to_vertex_program m_vertex_shader_cache; @@ -407,7 +407,7 @@ public: f32* dst = dst_buffer.data(); alignas(16) f32 tmp[4]; - for (size_t offset_in_fragment_program : I->second.FragmentConstantOffsetCache) + for (usz offset_in_fragment_program : I->second.FragmentConstantOffsetCache) { char* data = static_cast(fragment_program.get_data()) + offset_in_fragment_program; const __m128i vector = _mm_loadu_si128(reinterpret_cast<__m128i*>(data)); diff --git a/rpcs3/Emu/RSX/Common/ShaderParam.h b/rpcs3/Emu/RSX/Common/ShaderParam.h index 0ea0e6a27e..5ff5d46537 100644 --- a/rpcs3/Emu/RSX/Common/ShaderParam.h +++ b/rpcs3/Emu/RSX/Common/ShaderParam.h @@ -218,7 +218,7 @@ public: } } - size_t get_vector_size() const + usz get_vector_size() const { return swizzles[swizzles.size() - 1].length(); } diff --git a/rpcs3/Emu/RSX/Common/TextGlyphs.h b/rpcs3/Emu/RSX/Common/TextGlyphs.h index a8796efacf..4926808c04 100644 --- a/rpcs3/Emu/RSX/Common/TextGlyphs.h +++ b/rpcs3/Emu/RSX/Common/TextGlyphs.h @@ -176,7 +176,7 @@ private: const auto glyph_data = font_glyph.substr(7); if (glyph_data.length() == 32) { - for (std::size_t n = 0; n < this_glyph.plot.size(); ++n) + for (usz n = 0; n < this_glyph.plot.size(); ++n) { const auto line = glyph_data.substr(n * 2, 2); std::from_chars(line.data(), line.data() + line.size(), this_glyph.plot[n], 16); @@ -215,7 +215,7 @@ public: { entry.glyph_point_offset = ::size32(result); - for (std::size_t j = 0; j < entry.plot.size(); ++j) + for (usz j = 0; j < entry.plot.size(); ++j) { const auto &line = entry.plot[j]; if (line == 0) diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index e12372db9a..67baa736c8 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -317,7 +317,7 @@ namespace u8 block_size_in_bytes = sizeof(SRC_TYPE); std::vector result; - size_t offset_in_src = 0; + usz offset_in_src = 0; u8 border_size = border ? (padded_row ? 1 : 4) : 0; u32 src_pitch_in_block; @@ -383,30 +383,30 @@ namespace } template -u32 get_row_pitch_in_block(u16 width_in_block, size_t alignment) +u32 get_row_pitch_in_block(u16 width_in_block, usz alignment) { - if (const size_t pitch = width_in_block * sizeof(T); + if (const usz pitch = width_in_block * sizeof(T); pitch == alignment) { return width_in_block; } else { - size_t divided = (pitch + alignment - 1) / alignment; + usz divided = (pitch + alignment - 1) / alignment; return static_cast(divided * alignment / sizeof(T)); } } -u32 get_row_pitch_in_block(u16 block_size_in_bytes, u16 width_in_block, size_t alignment) +u32 get_row_pitch_in_block(u16 block_size_in_bytes, u16 width_in_block, usz alignment) { - if (const size_t pitch = width_in_block * block_size_in_bytes; + if (const usz pitch = width_in_block * block_size_in_bytes; pitch == alignment) { return width_in_block; } else { - size_t divided = (pitch + alignment - 1) / alignment; + usz divided = (pitch + alignment - 1) / alignment; return static_cast(divided * alignment / block_size_in_bytes); } } @@ -910,41 +910,41 @@ namespace rsx return width_in_block * bytes_per_block; } - size_t get_placed_texture_storage_size(u16 width, u16 height, u32 depth, u8 format, u16 mipmap, bool cubemap, size_t row_pitch_alignment, size_t mipmap_alignment) + usz get_placed_texture_storage_size(u16 width, u16 height, u32 depth, u8 format, u16 mipmap, bool cubemap, usz row_pitch_alignment, usz mipmap_alignment) { format &= ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); - size_t block_edge = get_format_block_size_in_texel(format); - size_t block_size_in_byte = get_format_block_size_in_bytes(format); + usz block_edge = get_format_block_size_in_texel(format); + usz block_size_in_byte = get_format_block_size_in_bytes(format); - size_t height_in_blocks = (height + block_edge - 1) / block_edge; - size_t width_in_blocks = (width + block_edge - 1) / block_edge; + usz height_in_blocks = (height + block_edge - 1) / block_edge; + usz width_in_blocks = (width + block_edge - 1) / block_edge; - size_t result = 0; + usz result = 0; for (u16 i = 0; i < mipmap; ++i) { - size_t rowPitch = align(block_size_in_byte * width_in_blocks, row_pitch_alignment); + usz rowPitch = align(block_size_in_byte * width_in_blocks, row_pitch_alignment); result += align(rowPitch * height_in_blocks * depth, mipmap_alignment); - height_in_blocks = std::max(height_in_blocks / 2, 1); - width_in_blocks = std::max(width_in_blocks / 2, 1); + height_in_blocks = std::max(height_in_blocks / 2, 1); + width_in_blocks = std::max(width_in_blocks / 2, 1); } // Mipmap, height and width aren't allowed to be zero return (ensure(result) * (cubemap ? 6 : 1)); } - size_t get_placed_texture_storage_size(const rsx::fragment_texture& texture, size_t row_pitch_alignment, size_t mipmap_alignment) + usz get_placed_texture_storage_size(const rsx::fragment_texture& texture, usz row_pitch_alignment, usz mipmap_alignment) { return get_placed_texture_storage_size(texture.width(), texture.height(), texture.depth(), texture.format(), texture.mipmap(), texture.cubemap(), row_pitch_alignment, mipmap_alignment); } - size_t get_placed_texture_storage_size(const rsx::vertex_texture& texture, size_t row_pitch_alignment, size_t mipmap_alignment) + usz get_placed_texture_storage_size(const rsx::vertex_texture& texture, usz row_pitch_alignment, usz mipmap_alignment) { return get_placed_texture_storage_size(texture.width(), texture.height(), texture.depth(), texture.format(), texture.mipmap(), texture.cubemap(), row_pitch_alignment, mipmap_alignment); } - static size_t get_texture_size(u32 format, u16 width, u16 height, u16 depth, u32 pitch, u16 mipmaps, u16 layers, u8 border) + static usz get_texture_size(u32 format, u16 width, u16 height, u16 depth, u32 pitch, u16 mipmaps, u16 layers, u8 border) { const auto gcm_format = format & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); const bool packed = !(format & CELL_GCM_TEXTURE_LN); @@ -1001,14 +1001,14 @@ namespace rsx return size; } - size_t get_texture_size(const rsx::fragment_texture& texture) + usz get_texture_size(const rsx::fragment_texture& texture) { return get_texture_size(texture.format(), texture.width(), texture.height(), texture.depth(), texture.pitch(), texture.get_exact_mipmap_count(), texture.cubemap() ? 6 : 1, texture.border_type() ^ 1); } - size_t get_texture_size(const rsx::vertex_texture& texture) + usz get_texture_size(const rsx::vertex_texture& texture) { return get_texture_size(texture.format(), texture.width(), texture.height(), texture.depth(), texture.pitch(), texture.get_exact_mipmap_count(), texture.cubemap() ? 6 : 1, diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.h b/rpcs3/Emu/RSX/Common/TextureUtils.h index 8610032b63..1339e73e5c 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.h +++ b/rpcs3/Emu/RSX/Common/TextureUtils.h @@ -125,16 +125,16 @@ namespace rsx bool supports_byteswap; bool supports_vtc_decoding; bool supports_hw_deswizzle; - size_t alignment; + usz alignment; }; /** * Get size to store texture in a linear fashion. * Storage is assumed to use a rowPitchAlignment boundary for every row of texture. */ - size_t get_placed_texture_storage_size(u16 width, u16 height, u32 depth, u8 format, u16 mipmap, bool cubemap, size_t row_pitch_alignment, size_t mipmap_alignment); - size_t get_placed_texture_storage_size(const rsx::fragment_texture &texture, size_t row_pitch_alignment, size_t mipmap_alignment = 0x200); - size_t get_placed_texture_storage_size(const rsx::vertex_texture &texture, size_t row_pitch_alignment, size_t mipmap_alignment = 0x200); + usz get_placed_texture_storage_size(u16 width, u16 height, u32 depth, u8 format, u16 mipmap, bool cubemap, usz row_pitch_alignment, usz mipmap_alignment); + usz get_placed_texture_storage_size(const rsx::fragment_texture &texture, usz row_pitch_alignment, usz mipmap_alignment = 0x200); + usz get_placed_texture_storage_size(const rsx::vertex_texture &texture, usz row_pitch_alignment, usz mipmap_alignment = 0x200); /** * get all rsx::subresource_layout for texture. @@ -162,8 +162,8 @@ namespace rsx /** * Get number of bytes occupied by texture in RSX mem */ - size_t get_texture_size(const rsx::fragment_texture &texture); - size_t get_texture_size(const rsx::vertex_texture &texture); + usz get_texture_size(const rsx::fragment_texture &texture); + usz get_texture_size(const rsx::vertex_texture &texture); /** * Get packed pitch diff --git a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h index ce1746a76b..50b4b705bf 100644 --- a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h +++ b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h @@ -9,7 +9,7 @@ /** * This class is used to translate RSX Vertex program to GLSL/HLSL code * Backend with text based shader can subclass this class and implement : -* - virtual std::string getFloatTypeName(size_t elementCount) = 0; +* - virtual std::string getFloatTypeName(usz elementCount) = 0; * - virtual std::string getFunction(enum class FUNCTION) = 0; * - virtual std::string compareFunction(enum class COMPARE, const std::string &, const std::string &) = 0; * - virtual void insertHeader(std::stringstream &OS) = 0; @@ -55,10 +55,10 @@ struct VertexProgramDecompiler } }; - static const size_t m_max_instr_count = 512; + static const usz m_max_instr_count = 512; Instruction m_instructions[m_max_instr_count]; Instruction* m_cur_instr; - size_t m_instr_count; + usz m_instr_count; std::vector m_body; std::stack m_call_stack; @@ -91,11 +91,11 @@ struct VertexProgramDecompiler protected: /** returns the type name of float vectors. */ - virtual std::string getFloatTypeName(size_t elementCount) = 0; + virtual std::string getFloatTypeName(usz elementCount) = 0; /** returns the type name of int vectors. */ - virtual std::string getIntTypeName(size_t elementCount) = 0; + virtual std::string getIntTypeName(usz elementCount) = 0; /** returns string calling function where arguments are passed via * $0 $1 $2 substring. diff --git a/rpcs3/Emu/RSX/Common/ring_buffer_helper.h b/rpcs3/Emu/RSX/Common/ring_buffer_helper.h index 821e292890..ae59bc5685 100644 --- a/rpcs3/Emu/RSX/Common/ring_buffer_helper.h +++ b/rpcs3/Emu/RSX/Common/ring_buffer_helper.h @@ -17,10 +17,10 @@ protected: * Does alloc cross get position ? */ template - bool can_alloc(size_t size) const + bool can_alloc(usz size) const { - size_t alloc_size = align(size, Alignment); - size_t aligned_put_pos = align(m_put_pos, Alignment); + usz alloc_size = align(size, Alignment); + usz aligned_put_pos = align(m_put_pos, Alignment); if (aligned_put_pos + alloc_size < m_size) { // range before get @@ -45,17 +45,17 @@ protected: } // Grow the buffer to hold at least size bytes - virtual bool grow(size_t /*size*/) + virtual bool grow(usz /*size*/) { // Stub return false; } - size_t m_size; - size_t m_put_pos; // Start of free space - size_t m_min_guard_size; //If an allocation touches the guard region, reset the heap to avoid going over budget - size_t m_current_allocated_size; - size_t m_largest_allocated_pool; + usz m_size; + usz m_put_pos; // Start of free space + usz m_min_guard_size; //If an allocation touches the guard region, reset the heap to avoid going over budget + usz m_current_allocated_size; + usz m_largest_allocated_pool; char* m_name; public: @@ -64,9 +64,9 @@ public: data_heap(const data_heap&) = delete; data_heap(data_heap&&) = delete; - size_t m_get_pos; // End of free space + usz m_get_pos; // End of free space - void init(size_t heap_size, const char* buffer_name = "unnamed", size_t min_guard_size=0x10000) + void init(usz heap_size, const char* buffer_name = "unnamed", usz min_guard_size=0x10000) { m_name = const_cast(buffer_name); @@ -81,10 +81,10 @@ public: } template - size_t alloc(size_t size) + usz alloc(usz size) { - const size_t alloc_size = align(size, Alignment); - const size_t aligned_put_pos = align(m_put_pos, Alignment); + const usz alloc_size = align(size, Alignment); + const usz aligned_put_pos = align(m_put_pos, Alignment); if (!can_alloc(size) && !grow(aligned_put_pos + alloc_size)) { @@ -92,7 +92,7 @@ public: m_name, m_size, m_current_allocated_size, size, m_min_guard_size, m_largest_allocated_pool); } - const size_t block_length = (aligned_put_pos - m_put_pos) + alloc_size; + const usz block_length = (aligned_put_pos - m_put_pos) + alloc_size; m_current_allocated_size += block_length; m_largest_allocated_pool = std::max(m_largest_allocated_pool, block_length); @@ -111,14 +111,14 @@ public: /** * return current putpos - 1 */ - size_t get_current_put_pos_minus_one() const + usz get_current_put_pos_minus_one() const { return (m_put_pos > 0) ? m_put_pos - 1 : m_size - 1; } virtual bool is_critical() const { - const size_t guard_length = std::max(m_min_guard_size, m_largest_allocated_pool); + const usz guard_length = std::max(m_min_guard_size, m_largest_allocated_pool); return (m_current_allocated_size + guard_length) >= m_size; } @@ -142,7 +142,7 @@ public: fmt::throw_exception("m_put_pos == m_get_pos!"); } - size_t size() const + usz size() const { return m_size; } diff --git a/rpcs3/Emu/RSX/Common/surface_store.cpp b/rpcs3/Emu/RSX/Common/surface_store.cpp index d3d9ee613c..72d1008fc9 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.cpp +++ b/rpcs3/Emu/RSX/Common/surface_store.cpp @@ -19,7 +19,7 @@ namespace rsx fmt::throw_exception("Wrong color_target"); } - size_t get_aligned_pitch(surface_color_format format, u32 width) + usz get_aligned_pitch(surface_color_format format, u32 width) { switch (format) { @@ -41,7 +41,7 @@ namespace rsx fmt::throw_exception("Unknown color surface format"); } - size_t get_packed_pitch(surface_color_format format, u32 width) + usz get_packed_pitch(surface_color_format format, u32 width) { switch (format) { diff --git a/rpcs3/Emu/RSX/Common/surface_store.h b/rpcs3/Emu/RSX/Common/surface_store.h index 1e8fb6296a..039592e40e 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.h +++ b/rpcs3/Emu/RSX/Common/surface_store.h @@ -10,8 +10,8 @@ namespace rsx namespace utility { std::vector get_rtt_indexes(surface_target color_target); - size_t get_aligned_pitch(surface_color_format format, u32 width); - size_t get_packed_pitch(surface_color_format format, u32 width); + usz get_aligned_pitch(surface_color_format format, u32 width); + usz get_packed_pitch(surface_color_format format, u32 width); } template @@ -426,7 +426,7 @@ namespace rsx u32 address, format_type format, surface_antialiasing antialias, - size_t width, size_t height, size_t pitch, + usz width, usz height, usz pitch, u8 bpp, Args&&... extra_params) { @@ -638,7 +638,7 @@ namespace rsx u32 address, surface_color_format color_format, surface_antialiasing antialias, - size_t width, size_t height, size_t pitch, + usz width, usz height, usz pitch, Args&&... extra_params) { return bind_surface_address( @@ -653,7 +653,7 @@ namespace rsx u32 address, surface_depth_format2 depth_format, surface_antialiasing antialias, - size_t width, size_t height, size_t pitch, + usz width, usz height, usz pitch, Args&&... extra_params) { return bind_surface_address( diff --git a/rpcs3/Emu/RSX/Common/surface_utils.h b/rpcs3/Emu/RSX/Common/surface_utils.h index 19e3663587..be6318f351 100644 --- a/rpcs3/Emu/RSX/Common/surface_utils.h +++ b/rpcs3/Emu/RSX/Common/surface_utils.h @@ -426,7 +426,7 @@ namespace rsx }); // Try and optimize by omitting possible overlapped transfers - for (size_t i = old_contents.size() - 1; i > 0 /* Intentional */; i--) + for (usz i = old_contents.size() - 1; i > 0 /* Intentional */; i--) { old_contents[i].init_transfer(target); diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 2e50187168..7809e6b30d 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -82,8 +82,8 @@ namespace rsx #ifdef TEXTURE_CACHE_DEBUG void check_pre_sanity() const { - size_t flush_and_unprotect_count = sections_to_flush.size() + sections_to_unprotect.size(); - size_t exclude_count = sections_to_exclude.size(); + usz flush_and_unprotect_count = sections_to_flush.size() + sections_to_unprotect.size(); + usz exclude_count = sections_to_exclude.size(); //------------------------- // It is illegal to have only exclusions except when reading from a range with only RO sections @@ -381,7 +381,7 @@ namespace rsx m_cache_update_tag = rsx::get_shared_tag(); } - template + template void emit_once(bool error, const CharT(&fmt)[N], const Args&... params) { const auto result = m_once_only_messages_set.emplace(fmt::format(fmt, params...)); @@ -394,13 +394,13 @@ namespace rsx rsx_log.warning("%s", *result.first); } - template + template void err_once(const CharT(&fmt)[N], const Args&... params) { emit_once(true, fmt, params...); } - template + template void warn_once(const CharT(&fmt)[N], const Args&... params) { emit_once(false, fmt, params...); @@ -737,7 +737,7 @@ namespace rsx // naive check that sections are not duplicated in the results for (auto §ion1 : result.sections) { - size_t count = 0; + usz count = 0; for (auto §ion2 : result.sections) { if (section1 == section2) count++; diff --git a/rpcs3/Emu/RSX/Common/texture_cache_checker.h b/rpcs3/Emu/RSX/Common/texture_cache_checker.h index 3b8ae6dc90..3235a4c90c 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache_checker.h +++ b/rpcs3/Emu/RSX/Common/texture_cache_checker.h @@ -69,17 +69,17 @@ namespace rsx { // 4GB memory space / 4096 bytes per page = 1048576 pages // Initialized to utils::protection::rw - static constexpr size_t num_pages = 0x1'0000'0000 / 4096; + static constexpr usz num_pages = 0x1'0000'0000 / 4096; per_page_info_t _info[num_pages]{0}; static_assert(static_cast(utils::protection::rw) == 0, "utils::protection::rw must have value 0 for the above constructor to work"); - static constexpr size_t rsx_address_to_index(u32 address) + static constexpr usz rsx_address_to_index(u32 address) { return (address / 4096); } - static constexpr u32 index_to_rsx_address(size_t idx) + static constexpr u32 index_to_rsx_address(usz idx) { return static_cast(idx * 4096); } @@ -96,7 +96,7 @@ namespace rsx { constexpr u32 info_pointer_to_address(const per_page_info_t* ptr) const { - return index_to_rsx_address(static_cast(ptr - _info)); + return index_to_rsx_address(static_cast(ptr - _info)); } std::string prot_to_str(utils::protection prot) const @@ -199,7 +199,7 @@ namespace rsx { void verify() const { - for (size_t idx = 0; idx < num_pages; idx++) + for (usz idx = 0; idx < num_pages; idx++) { auto &elmnt = _info[idx]; if (!elmnt.verify()) diff --git a/rpcs3/Emu/RSX/Common/texture_cache_predictor.h b/rpcs3/Emu/RSX/Common/texture_cache_predictor.h index 6fc2d71f60..8f33cf722b 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache_predictor.h +++ b/rpcs3/Emu/RSX/Common/texture_cache_predictor.h @@ -28,7 +28,7 @@ namespace rsx m_size = 0; } - size_t size() const + usz size() const { return m_size; } @@ -404,11 +404,11 @@ namespace std template struct hash> { - std::size_t operator()(const rsx::texture_cache_predictor_key& k) const + usz operator()(const rsx::texture_cache_predictor_key& k) const { - size_t result = std::hash{}(k.cpu_range); - result ^= static_cast(k.format); - result ^= (static_cast(k.context) << 16); + usz result = std::hash{}(k.cpu_range); + result ^= static_cast(k.format); + result ^= (static_cast(k.context) << 16); return result; } }; diff --git a/rpcs3/Emu/RSX/Common/texture_cache_utils.h b/rpcs3/Emu/RSX/Common/texture_cache_utils.h index 3b1fc07b7f..b1eeea5202 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache_utils.h +++ b/rpcs3/Emu/RSX/Common/texture_cache_utils.h @@ -15,7 +15,7 @@ namespace rsx * List of Arrays * (avoids reallocation without the significant disadvantages of slow iteration through a list) */ - template + template class ranged_storage_block_list { static_assert(array_size > 0, "array_elements must be positive non-zero"); @@ -497,7 +497,7 @@ namespace rsx return block_for(section.get_section_base()); } - inline block_type& operator[](size_t pos) + inline block_type& operator[](usz pos) { AUDIT(pos < num_blocks); return blocks[pos]; @@ -917,7 +917,7 @@ namespace rsx address_range_vector flush_exclusions; // Address ranges that will be skipped during flush predictor_type *m_predictor = nullptr; - size_t m_predictor_key_hash = 0; + usz m_predictor_key_hash = 0; predictor_entry_type *m_predictor_entry = nullptr; public: diff --git a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp index cc7d869b16..e457c30eb6 100644 --- a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp @@ -7,12 +7,12 @@ #include "../GCM.h" #include "../Common/GLSLCommon.h" -std::string GLFragmentDecompilerThread::getFloatTypeName(size_t elementCount) +std::string GLFragmentDecompilerThread::getFloatTypeName(usz elementCount) { return glsl::getFloatTypeNameImpl(elementCount); } -std::string GLFragmentDecompilerThread::getHalfTypeName(size_t elementCount) +std::string GLFragmentDecompilerThread::getHalfTypeName(usz elementCount) { return glsl::getHalfTypeNameImpl(elementCount); } @@ -369,7 +369,7 @@ void GLFragmentProgram::Decompile(const RSXFragmentProgram& prog) PT.type == "samplerCube") continue; - size_t offset = atoi(PI.name.c_str() + 2); + usz offset = atoi(PI.name.c_str() + 2); FragmentConstantOffsetCache.push_back(offset); } } diff --git a/rpcs3/Emu/RSX/GL/GLFragmentProgram.h b/rpcs3/Emu/RSX/GL/GLFragmentProgram.h index 3076c10cd9..4350f568b7 100644 --- a/rpcs3/Emu/RSX/GL/GLFragmentProgram.h +++ b/rpcs3/Emu/RSX/GL/GLFragmentProgram.h @@ -33,8 +33,8 @@ public: void Task(); protected: - std::string getFloatTypeName(size_t elementCount) override; - std::string getHalfTypeName(size_t elementCount) override; + std::string getFloatTypeName(usz elementCount) override; + std::string getHalfTypeName(usz elementCount) override; std::string getFunction(FUNCTION) override; std::string compareFunction(COMPARE, const std::string&, const std::string&) override; @@ -59,7 +59,7 @@ public: ParamArray parr; u32 id; gl::glsl::shader shader; - std::vector FragmentConstantOffsetCache; + std::vector FragmentConstantOffsetCache; /** * Decompile a fragment shader located in the PS3's Memory. This function operates synchronously. diff --git a/rpcs3/Emu/RSX/GL/GLHelpers.cpp b/rpcs3/Emu/RSX/GL/GLHelpers.cpp index 7d8c120ffd..c346d61c0b 100644 --- a/rpcs3/Emu/RSX/GL/GLHelpers.cpp +++ b/rpcs3/Emu/RSX/GL/GLHelpers.cpp @@ -298,13 +298,13 @@ namespace gl glDrawElements(draw_mode(mode), count, static_cast(type), indices); } - void fbo::draw_elements(rsx::primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset) const + void fbo::draw_elements(rsx::primitive_type mode, GLsizei count, indices_type type, const buffer& indices, usz indices_buffer_offset) const { indices.bind(buffer::target::element_array); glDrawElements(draw_mode(mode), count, static_cast(type), reinterpret_cast(indices_buffer_offset)); } - void fbo::draw_elements(const buffer& buffer_, rsx::primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset) const + void fbo::draw_elements(const buffer& buffer_, rsx::primitive_type mode, GLsizei count, indices_type type, const buffer& indices, usz indices_buffer_offset) const { buffer_.bind(buffer::target::array); draw_elements(mode, count, type, indices, indices_buffer_offset); diff --git a/rpcs3/Emu/RSX/GL/GLHelpers.h b/rpcs3/Emu/RSX/GL/GLHelpers.h index 9d24fe710e..52a36873e3 100644 --- a/rpcs3/Emu/RSX/GL/GLHelpers.h +++ b/rpcs3/Emu/RSX/GL/GLHelpers.h @@ -2179,8 +2179,8 @@ public: void draw_elements(rsx::primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const; void draw_elements(const buffer& buffer, rsx::primitive_type mode, GLsizei count, indices_type type, const GLvoid *indices) const; - void draw_elements(rsx::primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset = 0) const; - void draw_elements(const buffer& buffer_, rsx::primitive_type mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset = 0) const; + void draw_elements(rsx::primitive_type mode, GLsizei count, indices_type type, const buffer& indices, usz indices_buffer_offset = 0) const; + void draw_elements(const buffer& buffer_, rsx::primitive_type mode, GLsizei count, indices_type type, const buffer& indices, usz indices_buffer_offset = 0) const; void draw_elements(rsx::primitive_type mode, GLsizei count, const GLubyte *indices) const; void draw_elements(const buffer& buffer, rsx::primitive_type mode, GLsizei count, const GLubyte *indices) const; void draw_elements(rsx::primitive_type mode, GLsizei count, const GLushort *indices) const; diff --git a/rpcs3/Emu/RSX/GL/GLProgramBuffer.h b/rpcs3/Emu/RSX/GL/GLProgramBuffer.h index f6c81e2cca..4e2ae3b54a 100644 --- a/rpcs3/Emu/RSX/GL/GLProgramBuffer.h +++ b/rpcs3/Emu/RSX/GL/GLProgramBuffer.h @@ -15,13 +15,13 @@ struct GLTraits using pipeline_properties = void*; static - void recompile_fragment_program(const RSXFragmentProgram &RSXFP, fragment_program_type& fragmentProgramData, size_t /*ID*/) + void recompile_fragment_program(const RSXFragmentProgram &RSXFP, fragment_program_type& fragmentProgramData, usz /*ID*/) { fragmentProgramData.Decompile(RSXFP); } static - void recompile_vertex_program(const RSXVertexProgram &RSXVP, vertex_program_type& vertexProgramData, size_t /*ID*/) + void recompile_vertex_program(const RSXVertexProgram &RSXVP, vertex_program_type& vertexProgramData, usz /*ID*/) { vertexProgramData.Decompile(RSXVP); } diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.h b/rpcs3/Emu/RSX/GL/GLRenderTargets.h index 86dd44d360..88a7bb225d 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.h +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.h @@ -140,7 +140,7 @@ struct gl_render_target_traits std::unique_ptr create_new_surface( u32 address, rsx::surface_color_format surface_color_format, - size_t width, size_t height, size_t pitch, + usz width, usz height, usz pitch, rsx::surface_antialiasing antialias ) { @@ -169,7 +169,7 @@ struct gl_render_target_traits std::unique_ptr create_new_surface( u32 address, rsx::surface_depth_format2 surface_depth_format, - size_t width, size_t height, size_t pitch, + usz width, usz height, usz pitch, rsx::surface_antialiasing antialias ) { @@ -262,13 +262,13 @@ struct gl_render_target_traits {} static - bool surface_is_pitch_compatible(const std::unique_ptr &surface, size_t pitch) + bool surface_is_pitch_compatible(const std::unique_ptr &surface, usz pitch) { return surface->get_rsx_pitch() == pitch; } static - void invalidate_surface_contents(gl::command_context&, gl::render_target *surface, u32 address, size_t pitch) + void invalidate_surface_contents(gl::command_context&, gl::render_target *surface, u32 address, usz pitch) { surface->set_rsx_pitch(static_cast(pitch)); surface->queue_tag(address); @@ -305,7 +305,7 @@ struct gl_render_target_traits bool int_surface_matches_properties( const std::unique_ptr &surface, gl::texture::internal_format format, - size_t width, size_t height, + usz width, usz height, rsx::surface_antialiasing antialias, bool check_refs = false) { @@ -321,7 +321,7 @@ struct gl_render_target_traits bool surface_matches_properties( const std::unique_ptr &surface, rsx::surface_color_format format, - size_t width, size_t height, + usz width, usz height, rsx::surface_antialiasing antialias, bool check_refs=false) { @@ -333,7 +333,7 @@ struct gl_render_target_traits bool surface_matches_properties( const std::unique_ptr &surface, rsx::surface_depth_format2 format, - size_t width, size_t height, + usz width, usz height, rsx::surface_antialiasing antialias, bool check_refs = false) { diff --git a/rpcs3/Emu/RSX/GL/GLTextOut.h b/rpcs3/Emu/RSX/GL/GLTextOut.h index 362a582370..384f4f5a5d 100644 --- a/rpcs3/Emu/RSX/GL/GLTextOut.h +++ b/rpcs3/Emu/RSX/GL/GLTextOut.h @@ -64,7 +64,7 @@ namespace gl m_program.link(); } - void load_program(float scale_x, float scale_y, float *offsets, size_t nb_offsets, color4f color) + void load_program(float scale_x, float scale_y, float *offsets, usz nb_offsets, color4f color) { float scale[] = { scale_x, scale_y }; @@ -88,7 +88,7 @@ namespace gl GlyphManager glyph_source; auto points = glyph_source.generate_point_map(); - const size_t buffer_size = points.size() * sizeof(GlyphManager::glyph_point); + const usz buffer_size = points.size() * sizeof(GlyphManager::glyph_point); m_text_buffer.data(buffer_size, points.data()); m_offsets = glyph_source.get_glyph_offsets(); diff --git a/rpcs3/Emu/RSX/GL/GLTexture.cpp b/rpcs3/Emu/RSX/GL/GLTexture.cpp index aa044bb487..b416a02aac 100644 --- a/rpcs3/Emu/RSX/GL/GLTexture.cpp +++ b/rpcs3/Emu/RSX/GL/GLTexture.cpp @@ -836,7 +836,7 @@ namespace gl { // Calculate staging buffer size const u32 aligned_pitch = align(dst->pitch(), 4); - size_t texture_data_sz = dst->depth() * dst->height() * aligned_pitch; + usz texture_data_sz = dst->depth() * dst->height() * aligned_pitch; std::vector data_upload_buf(texture_data_sz); // TODO: GL drivers support byteswapping and this should be used instead of doing so manually diff --git a/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp b/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp index 01f8bf9c68..7d25ee251f 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp @@ -226,7 +226,7 @@ gl::vertex_upload_info GLGSRender::set_vertex_buffer() if (!m_persistent_stream_view.in_range(upload_info.persistent_mapping_offset, required.first, upload_info.persistent_mapping_offset)) { ensure(m_max_texbuffer_size < m_attrib_ring_buffer->size()); - const size_t view_size = ((upload_info.persistent_mapping_offset + m_max_texbuffer_size) > m_attrib_ring_buffer->size()) ? + const usz view_size = ((upload_info.persistent_mapping_offset + m_max_texbuffer_size) > m_attrib_ring_buffer->size()) ? (m_attrib_ring_buffer->size() - upload_info.persistent_mapping_offset) : m_max_texbuffer_size; m_persistent_stream_view.update(m_attrib_ring_buffer.get(), upload_info.persistent_mapping_offset, static_cast(view_size)); @@ -243,7 +243,7 @@ gl::vertex_upload_info GLGSRender::set_vertex_buffer() if (!m_volatile_stream_view.in_range(upload_info.volatile_mapping_offset, required.second, upload_info.volatile_mapping_offset)) { ensure(m_max_texbuffer_size < m_attrib_ring_buffer->size()); - const size_t view_size = ((upload_info.volatile_mapping_offset + m_max_texbuffer_size) > m_attrib_ring_buffer->size()) ? + const usz view_size = ((upload_info.volatile_mapping_offset + m_max_texbuffer_size) > m_attrib_ring_buffer->size()) ? (m_attrib_ring_buffer->size() - upload_info.volatile_mapping_offset) : m_max_texbuffer_size; m_volatile_stream_view.update(m_attrib_ring_buffer.get(), upload_info.volatile_mapping_offset, static_cast(view_size)); diff --git a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp index 387e5be5b9..eb951c398a 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp @@ -8,12 +8,12 @@ #include -std::string GLVertexDecompilerThread::getFloatTypeName(size_t elementCount) +std::string GLVertexDecompilerThread::getFloatTypeName(usz elementCount) { return glsl::getFloatTypeNameImpl(elementCount); } -std::string GLVertexDecompilerThread::getIntTypeName(size_t elementCount) +std::string GLVertexDecompilerThread::getIntTypeName(usz elementCount) { return "ivec4"; } diff --git a/rpcs3/Emu/RSX/GL/GLVertexProgram.h b/rpcs3/Emu/RSX/GL/GLVertexProgram.h index dc805faec6..bf3b11ab48 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexProgram.h +++ b/rpcs3/Emu/RSX/GL/GLVertexProgram.h @@ -23,8 +23,8 @@ struct GLVertexDecompilerThread : public VertexProgramDecompiler std::string &m_shader; protected: - std::string getFloatTypeName(size_t elementCount) override; - std::string getIntTypeName(size_t elementCount) override; + std::string getFloatTypeName(usz elementCount) override; + std::string getIntTypeName(usz elementCount) override; std::string getFunction(FUNCTION) override; std::string compareFunction(COMPARE, const std::string&, const std::string&, bool scalar) override; diff --git a/rpcs3/Emu/RSX/Overlays/overlay_controls.h b/rpcs3/Emu/RSX/Overlays/overlay_controls.h index 13ad8de1ab..9b87ce9bde 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_controls.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_controls.h @@ -150,7 +150,7 @@ namespace rsx uint32_t bufsize = PATH_MAX; bool success = _NSGetExecutablePath( result, &bufsize ) == 0; #elif defined(KERN_PROC_PATHNAME) - size_t bufsize = PATH_MAX; + usz bufsize = PATH_MAX; int mib[] = { CTL_KERN, #if defined(__NetBSD__) @@ -272,7 +272,7 @@ namespace rsx draw_commands.resize(old_size + other.draw_commands.size()); std::copy(other.draw_commands.begin(), other.draw_commands.end(), draw_commands.begin() + old_size); - for (size_t n = old_size; n < draw_commands.size(); ++n) + for (usz n = old_size; n < draw_commands.size(); ++n) { for (auto &v : draw_commands[n].verts) { @@ -287,7 +287,7 @@ namespace rsx draw_commands.resize(old_size + other.draw_commands.size()); std::copy(other.draw_commands.begin(), other.draw_commands.end(), draw_commands.begin() + old_size); - for (size_t n = old_size; n < draw_commands.size(); ++n) + for (usz n = old_size; n < draw_commands.size(); ++n) { for (auto &v : draw_commands[n].verts) { diff --git a/rpcs3/Emu/RSX/Overlays/overlay_edit_text.cpp b/rpcs3/Emu/RSX/Overlays/overlay_edit_text.cpp index 8536fc596e..611ea99c5a 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_edit_text.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_edit_text.cpp @@ -5,13 +5,13 @@ namespace rsx { namespace overlays { - static size_t get_line_start(const std::u32string& text, size_t pos) + static usz get_line_start(const std::u32string& text, usz pos) { if (pos == 0) { return 0; } - const size_t line_start = text.rfind('\n', pos - 1); + const usz line_start = text.rfind('\n', pos - 1); if (line_start == std::string::npos) { return 0; @@ -19,9 +19,9 @@ namespace rsx return line_start + 1; } - static size_t get_line_end(const std::u32string& text, size_t pos) + static usz get_line_end(const std::u32string& text, usz pos) { - const size_t line_end = text.find('\n', pos); + const usz line_end = text.find('\n', pos); if (line_end == std::string::npos) { return text.length(); @@ -53,7 +53,7 @@ namespace rsx } case direction::up: { - const size_t current_line_start = get_line_start(text, caret_position); + const usz current_line_start = get_line_start(text, caret_position); if (current_line_start == 0) { // This is the first line, so caret moves to the very beginning @@ -61,9 +61,9 @@ namespace rsx refresh(); break; } - const size_t caret_pos_in_line = caret_position - current_line_start; - const size_t prev_line_end = current_line_start - 1; - const size_t prev_line_start = get_line_start(text, prev_line_end); + const usz caret_pos_in_line = caret_position - current_line_start; + const usz prev_line_end = current_line_start - 1; + const usz prev_line_start = get_line_start(text, prev_line_end); // TODO : Save caret position to some kind of buffer, so after switching back and forward, caret would be on initial position caret_position = std::min(prev_line_end, prev_line_start + caret_pos_in_line); @@ -72,7 +72,7 @@ namespace rsx } case direction::down: { - const size_t current_line_end = get_line_end(text, caret_position); + const usz current_line_end = get_line_end(text, caret_position); if (current_line_end == text.length()) { // This is the last line, so caret moves to the very end @@ -80,10 +80,10 @@ namespace rsx refresh(); break; } - const size_t current_line_start = get_line_start(text, caret_position); - const size_t caret_pos_in_line = caret_position - current_line_start; - const size_t next_line_start = current_line_end + 1; - const size_t next_line_end = get_line_end(text, next_line_start); + const usz current_line_start = get_line_start(text, caret_position); + const usz caret_pos_in_line = caret_position - current_line_start; + const usz next_line_start = current_line_end + 1; + const usz next_line_end = get_line_end(text, next_line_start); // TODO : Save caret position to some kind of buffer, so after switching back and forward, caret would be on initial position caret_position = std::min(next_line_end, next_line_start + caret_pos_in_line); diff --git a/rpcs3/Emu/RSX/Overlays/overlay_fonts.cpp b/rpcs3/Emu/RSX/Overlays/overlay_fonts.cpp index 24c84c499c..ec6fa96e60 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_fonts.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_fonts.cpp @@ -345,7 +345,7 @@ namespace rsx auto first_affected = result.size() - (nb_chars * 4); f32 base_x = result[first_affected].values[0]; - for (size_t n = first_affected; n < result.size(); ++n) + for (usz n = first_affected; n < result.size(); ++n) { auto char_index = n / 4; if (text[char_index] == ' ') diff --git a/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp b/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp index c1bfb113ae..2b506be0aa 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp @@ -62,7 +62,7 @@ namespace rsx return; // Ideally unreachable but it should still be possible to recover by user interaction. } - const size_t current_index = static_cast(m_selected_entry) * 2; + const usz current_index = static_cast(m_selected_entry) * 2; if (m_items.size() <= current_index) { diff --git a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp index c759a20dd8..0e8fdc1241 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp @@ -52,7 +52,7 @@ namespace rsx void osk_dialog::step_panel(bool next_panel) { - const size_t num_panels = m_panels.size(); + const usz num_panels = m_panels.size(); if (num_panels > 0) { @@ -123,9 +123,9 @@ namespace rsx continue; } - size_t cell_shift_layers = 0; + usz cell_shift_layers = 0; - for (size_t i = 0; i < _cell.outputs[layer].size(); ++i) + for (usz i = 0; i < _cell.outputs[layer].size(); ++i) { if (_cell.outputs[layer][i].empty() == false) { @@ -995,7 +995,7 @@ namespace rsx } // Get initial panel based on first_view_panel - for (size_t i = 0; i < m_panels.size(); ++i) + for (usz i = 0; i < m_panels.size(); ++i) { if (first_view_panel == m_panels[i].osk_panel_mode) { diff --git a/rpcs3/Emu/RSX/Overlays/overlay_osk.h b/rpcs3/Emu/RSX/Overlays/overlay_osk.h index b43c0afdfb..8d81e3e854 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_osk.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_osk.h @@ -73,7 +73,7 @@ namespace rsx u32 char_limit = UINT32_MAX; std::vector m_panels; - size_t m_panel_index = 0; + usz m_panel_index = 0; osk_dialog() = default; ~osk_dialog() override = default; diff --git a/rpcs3/Emu/RSX/VK/VKDMA.cpp b/rpcs3/Emu/RSX/VK/VKDMA.cpp index b56c6064f7..90d1440f22 100644 --- a/rpcs3/Emu/RSX/VK/VKDMA.cpp +++ b/rpcs3/Emu/RSX/VK/VKDMA.cpp @@ -5,7 +5,7 @@ namespace vk { - static constexpr size_t s_dma_block_length = 0x01000000; + static constexpr usz s_dma_block_length = 0x01000000; static constexpr u32 s_dma_block_mask = 0xFF000000; static constexpr u32 s_dma_offset_mask = 0x00FFFFFF; @@ -42,7 +42,7 @@ namespace vk } } - void dma_block::init(const render_device& dev, u32 addr, size_t size) + void dma_block::init(const render_device& dev, u32 addr, usz size) { ensure(size); ensure(!(size % s_dma_block_length)); @@ -55,7 +55,7 @@ namespace vk page_info.resize(size / s_bytes_per_entry, ~0ull); } - void dma_block::init(dma_block* parent, u32 addr, size_t size) + void dma_block::init(dma_block* parent, u32 addr, usz size) { base_address = addr; inheritance_info.parent = parent; @@ -201,7 +201,7 @@ namespace vk } } - void dma_block::extend(command_buffer& cmd, const render_device &dev, size_t new_size) + void dma_block::extend(command_buffer& cmd, const render_device &dev, usz new_size) { ensure(allocated_memory); if (new_size <= allocated_memory->size()) diff --git a/rpcs3/Emu/RSX/VK/VKDMA.h b/rpcs3/Emu/RSX/VK/VKDMA.h index 71dbb0ca8f..14ec5bbe36 100644 --- a/rpcs3/Emu/RSX/VK/VKDMA.h +++ b/rpcs3/Emu/RSX/VK/VKDMA.h @@ -39,8 +39,8 @@ namespace vk public: - void init(const render_device& dev, u32 addr, size_t size); - void init(dma_block* parent, u32 addr, size_t size); + void init(const render_device& dev, u32 addr, usz size); + void init(dma_block* parent, u32 addr, usz size); void flush(const utils::address_range& range); void load(const utils::address_range& range); std::pair get(const utils::address_range& range); @@ -52,6 +52,6 @@ namespace vk dma_block* head(); const dma_block* head() const; void set_parent(command_buffer& cmd, dma_block* parent); - void extend(command_buffer& cmd, const render_device& dev, size_t new_size); + void extend(command_buffer& cmd, const render_device& dev, usz new_size); }; } diff --git a/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp b/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp index ecafe18ba2..7e03a5f867 100644 --- a/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp @@ -5,12 +5,12 @@ #include "../Common/GLSLCommon.h" #include "../GCM.h" -std::string VKFragmentDecompilerThread::getFloatTypeName(size_t elementCount) +std::string VKFragmentDecompilerThread::getFloatTypeName(usz elementCount) { return glsl::getFloatTypeNameImpl(elementCount); } -std::string VKFragmentDecompilerThread::getHalfTypeName(size_t elementCount) +std::string VKFragmentDecompilerThread::getHalfTypeName(usz elementCount) { return glsl::getHalfTypeNameImpl(elementCount); } @@ -411,7 +411,7 @@ void VKFragmentProgram::Decompile(const RSXFragmentProgram& prog) PT.type == "samplerCube") continue; - size_t offset = atoi(PI.name.c_str() + 2); + usz offset = atoi(PI.name.c_str() + 2); FragmentConstantOffsetCache.push_back(offset); } } diff --git a/rpcs3/Emu/RSX/VK/VKFragmentProgram.h b/rpcs3/Emu/RSX/VK/VKFragmentProgram.h index d209c33877..881034ba8f 100644 --- a/rpcs3/Emu/RSX/VK/VKFragmentProgram.h +++ b/rpcs3/Emu/RSX/VK/VKFragmentProgram.h @@ -33,8 +33,8 @@ public: void Task(); const std::vector& get_inputs() { return inputs; } protected: - std::string getFloatTypeName(size_t elementCount) override; - std::string getHalfTypeName(size_t elementCount) override; + std::string getFloatTypeName(usz elementCount) override; + std::string getHalfTypeName(usz elementCount) override; std::string getFunction(FUNCTION) override; std::string compareFunction(COMPARE, const std::string&, const std::string&) override; @@ -60,7 +60,7 @@ public: VkShaderModule handle = nullptr; u32 id; vk::glsl::shader shader; - std::vector FragmentConstantOffsetCache; + std::vector FragmentConstantOffsetCache; std::array output_color_masks{ {} }; diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 7d5565f636..fd35d988b2 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -197,7 +197,7 @@ namespace const auto& binding_table = vk::get_current_renderer()->get_pipeline_binding_table(); std::vector bindings(binding_table.total_descriptor_bindings); - size_t idx = 0; + usz idx = 0; // Vertex stream, one stream for cacheable data, one stream for transient data for (int i = 0; i < 3; i++) @@ -1872,8 +1872,8 @@ void VKGSRender::update_vertex_env(u32 id, const vk::vertex_upload_info& vertex_ if (m_vertex_layout_storage) m_current_frame->buffer_views_to_clean.push_back(std::move(m_vertex_layout_storage)); - const size_t alloc_addr = m_vertex_layout_stream_info.offset; - const size_t view_size = (alloc_addr + m_texbuffer_view_size) > m_vertex_layout_ring_info.size() ? m_vertex_layout_ring_info.size() - alloc_addr : m_texbuffer_view_size; + const usz alloc_addr = m_vertex_layout_stream_info.offset; + const usz view_size = (alloc_addr + m_texbuffer_view_size) > m_vertex_layout_ring_info.size() ? m_vertex_layout_ring_info.size() - alloc_addr : m_texbuffer_view_size; m_vertex_layout_storage = std::make_unique(*m_device, m_vertex_layout_ring_info.heap->value, VK_FORMAT_R32G32_UINT, alloc_addr, view_size); base_offset = 0; } @@ -1894,7 +1894,7 @@ void VKGSRender::update_vertex_env(u32 id, const vk::vertex_upload_info& vertex_ vkCmdPushConstants(*m_current_command_buffer, pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT, 0, data_size, draw_info); - const size_t data_offset = (id * 128) + m_vertex_layout_stream_info.offset; + const usz data_offset = (id * 128) + m_vertex_layout_stream_info.offset; auto dst = m_vertex_layout_ring_info.map(data_offset, 128); fill_vertex_layout_state(m_vertex_layout, vertex_info.first_vertex, vertex_info.allocated_vertex_count, static_cast(dst), @@ -2445,8 +2445,8 @@ void VKGSRender::begin_conditional_rendering(const std::vectordriver_handle]; for (const auto& index : query_info.indices) diff --git a/rpcs3/Emu/RSX/VK/VKHelpers.cpp b/rpcs3/Emu/RSX/VK/VKHelpers.cpp index 3915bee70a..e84d4d66d0 100644 --- a/rpcs3/Emu/RSX/VK/VKHelpers.cpp +++ b/rpcs3/Emu/RSX/VK/VKHelpers.cpp @@ -95,7 +95,7 @@ namespace vk u64 g_num_processed_frames = 0; u64 g_num_total_frames = 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_realloc(void* pUserData, void* pOriginal, usz size, usz alignment, VkSystemAllocationScope allocationScope) { #ifdef _MSC_VER return _aligned_realloc(pOriginal, size, alignment); @@ -106,7 +106,7 @@ namespace vk #endif } - VKAPI_ATTR void* VKAPI_CALL mem_alloc(void* pUserData, size_t size, size_t alignment, VkSystemAllocationScope allocationScope) + VKAPI_ATTR void* VKAPI_CALL mem_alloc(void* pUserData, usz size, usz alignment, VkSystemAllocationScope allocationScope) { #ifdef _MSC_VER return _aligned_malloc(size, alignment); @@ -128,11 +128,11 @@ namespace vk #endif } - bool data_heap::grow(size_t size) + bool data_heap::grow(usz size) { // Create new heap. All sizes are aligned up by 64M, upto 1GiB - const size_t size_limit = 1024 * 0x100000; - const size_t aligned_new_size = align(m_size + size, 64 * 0x100000); + const usz size_limit = 1024 * 0x100000; + const usz aligned_new_size = align(m_size + size, 64 * 0x100000); if (aligned_new_size >= size_limit) { @@ -1124,7 +1124,7 @@ namespace vk } VKAPI_ATTR VkBool32 VKAPI_CALL dbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, - uint64_t srcObject, size_t location, int32_t msgCode, + uint64_t srcObject, usz location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg, void *pUserData) { if (msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT) @@ -1147,7 +1147,7 @@ namespace vk } VkBool32 BreakCallback(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, - uint64_t srcObject, size_t location, int32_t msgCode, + uint64_t srcObject, usz location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg, void *pUserData) { #ifdef _WIN32 diff --git a/rpcs3/Emu/RSX/VK/VKHelpers.h b/rpcs3/Emu/RSX/VK/VKHelpers.h index dbbc22cb5b..a564805827 100644 --- a/rpcs3/Emu/RSX/VK/VKHelpers.h +++ b/rpcs3/Emu/RSX/VK/VKHelpers.h @@ -48,16 +48,16 @@ namespace vk { #define CHECK_RESULT(expr) { VkResult _res = (expr); if (_res != VK_SUCCESS) vk::die_with_error(_res); } - 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); + VKAPI_ATTR void *VKAPI_CALL mem_realloc(void *pUserData, void *pOriginal, usz size, usz alignment, VkSystemAllocationScope allocationScope); + VKAPI_ATTR void *VKAPI_CALL mem_alloc(void *pUserData, usz size, usz alignment, VkSystemAllocationScope allocationScope); VKAPI_ATTR void VKAPI_CALL mem_free(void *pUserData, void *pMemory); VKAPI_ATTR VkBool32 VKAPI_CALL dbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, - uint64_t srcObject, size_t location, int32_t msgCode, + uint64_t srcObject, usz location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg, void *pUserData); VkBool32 BreakCallback(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, - uint64_t srcObject, size_t location, int32_t msgCode, + uint64_t srcObject, usz location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg, void *pUserData); @@ -2054,7 +2054,7 @@ private: , m_device(dev) { std::vector image_view_array(attachments.size()); - size_t i = 0; + usz i = 0; for (const auto &att : attachments) { image_view_array[i++] = att->value; @@ -3675,7 +3675,7 @@ public: class data_heap : public ::data_heap { private: - size_t initial_size = 0; + usz initial_size = 0; bool mapped = false; void *_ptr = nullptr; @@ -3685,7 +3685,7 @@ public: std::vector dirty_ranges; protected: - bool grow(size_t size) override; + bool grow(usz size) override; public: std::unique_ptr heap; @@ -3694,7 +3694,7 @@ public: // Avoid mapping/unmapping to keep these drivers from stalling // NOTE2: HOST_CACHED flag does not keep the mapped ptr around in the driver either - void create(VkBufferUsageFlags usage, size_t size, const char *name, size_t guard = 0x10000, VkBool32 notify = VK_FALSE) + void create(VkBufferUsageFlags usage, usz size, const char *name, usz guard = 0x10000, VkBool32 notify = VK_FALSE) { ::data_heap::init(size, name, guard); @@ -3731,7 +3731,7 @@ public: shadow.reset(); } - void* map(size_t offset, size_t size) + void* map(usz offset, usz size) { if (!_ptr) { @@ -3793,7 +3793,7 @@ public: // By default, allow the size to grow upto 8x larger // This value is arbitrary, theoretically it is possible to allow infinite stretching to improve performance - const size_t soft_limit = initial_size * 8; + const usz soft_limit = initial_size * 8; if ((m_size + m_min_guard_size) < soft_limit) return false; diff --git a/rpcs3/Emu/RSX/VK/VKPipelineCompiler.h b/rpcs3/Emu/RSX/VK/VKPipelineCompiler.h index 82fec80689..3479eb60c9 100644 --- a/rpcs3/Emu/RSX/VK/VKPipelineCompiler.h +++ b/rpcs3/Emu/RSX/VK/VKPipelineCompiler.h @@ -163,9 +163,9 @@ namespace vk namespace rpcs3 { template <> - size_t hash_struct(const vk::pipeline_props &pipelineProperties) + usz hash_struct(const vk::pipeline_props &pipelineProperties) { - size_t seed = hash_base(pipelineProperties.renderpass_key); + usz seed = hash_base(pipelineProperties.renderpass_key); seed ^= hash_struct(pipelineProperties.state.ia); seed ^= hash_struct(pipelineProperties.state.ds); seed ^= hash_struct(pipelineProperties.state.rs); diff --git a/rpcs3/Emu/RSX/VK/VKPresent.cpp b/rpcs3/Emu/RSX/VK/VKPresent.cpp index a05890622e..c440f85c25 100644 --- a/rpcs3/Emu/RSX/VK/VKPresent.cpp +++ b/rpcs3/Emu/RSX/VK/VKPresent.cpp @@ -649,7 +649,7 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info) { m_frame->screenshot_toggle = false; - const size_t sshot_size = buffer_height * buffer_width * 4; + const usz sshot_size = buffer_height * buffer_width * 4; vk::buffer sshot_vkbuf(*m_device, align(sshot_size, 0x100000), m_device->get_memory_mapping().host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_TRANSFER_DST_BIT, 0); diff --git a/rpcs3/Emu/RSX/VK/VKProgramBuffer.h b/rpcs3/Emu/RSX/VK/VKProgramBuffer.h index ec26bbbbab..040139860f 100644 --- a/rpcs3/Emu/RSX/VK/VKProgramBuffer.h +++ b/rpcs3/Emu/RSX/VK/VKProgramBuffer.h @@ -18,7 +18,7 @@ namespace vk using pipeline_properties = vk::pipeline_props; static - void recompile_fragment_program(const RSXFragmentProgram& RSXFP, fragment_program_type& fragmentProgramData, size_t ID) + void recompile_fragment_program(const RSXFragmentProgram& RSXFP, fragment_program_type& fragmentProgramData, usz ID) { fragmentProgramData.Decompile(RSXFP); fragmentProgramData.id = static_cast(ID); @@ -26,7 +26,7 @@ namespace vk } static - void recompile_vertex_program(const RSXVertexProgram& RSXVP, vertex_program_type& vertexProgramData, size_t ID) + void recompile_vertex_program(const RSXVertexProgram& RSXVP, vertex_program_type& vertexProgramData, usz ID) { vertexProgramData.Decompile(RSXVP); vertexProgramData.id = static_cast(ID); diff --git a/rpcs3/Emu/RSX/VK/VKRenderTargets.h b/rpcs3/Emu/RSX/VK/VKRenderTargets.h index fd5fb50680..6a5d0807d2 100644 --- a/rpcs3/Emu/RSX/VK/VKRenderTargets.h +++ b/rpcs3/Emu/RSX/VK/VKRenderTargets.h @@ -615,7 +615,7 @@ namespace rsx static std::unique_ptr create_new_surface( u32 address, surface_color_format format, - size_t width, size_t height, size_t pitch, + usz width, usz height, usz pitch, rsx::surface_antialiasing antialias, vk::render_device &device, vk::command_buffer& cmd) { @@ -680,7 +680,7 @@ namespace rsx static std::unique_ptr create_new_surface( u32 address, surface_depth_format2 format, - size_t width, size_t height, size_t pitch, + usz width, usz height, usz pitch, rsx::surface_antialiasing antialias, vk::render_device &device, vk::command_buffer& cmd) { @@ -828,12 +828,12 @@ namespace rsx static void prepare_surface_for_sampling(vk::command_buffer& /*cmd*/, vk::render_target* /*surface*/) {} - static bool surface_is_pitch_compatible(const std::unique_ptr &surface, size_t pitch) + static bool surface_is_pitch_compatible(const std::unique_ptr &surface, usz pitch) { return surface->rsx_pitch == pitch; } - static void invalidate_surface_contents(vk::command_buffer& /*cmd*/, vk::render_target *surface, u32 address, size_t pitch) + static void invalidate_surface_contents(vk::command_buffer& /*cmd*/, vk::render_target *surface, u32 address, usz pitch) { surface->rsx_pitch = static_cast(pitch); surface->queue_tag(address); @@ -869,7 +869,7 @@ namespace rsx static bool int_surface_matches_properties( const std::unique_ptr &surface, VkFormat format, - size_t width, size_t height, + usz width, usz height, rsx::surface_antialiasing antialias, bool check_refs) { @@ -887,7 +887,7 @@ namespace rsx static bool surface_matches_properties( const std::unique_ptr &surface, surface_color_format format, - size_t width, size_t height, + usz width, usz height, rsx::surface_antialiasing antialias, bool check_refs = false) { @@ -898,7 +898,7 @@ namespace rsx static bool surface_matches_properties( const std::unique_ptr &surface, surface_depth_format2 format, - size_t width, size_t height, + usz width, usz height, rsx::surface_antialiasing antialias, bool check_refs = false) { diff --git a/rpcs3/Emu/RSX/VK/VKShaderInterpreter.h b/rpcs3/Emu/RSX/VK/VKShaderInterpreter.h index 903760efce..ac3c1d3dd7 100644 --- a/rpcs3/Emu/RSX/VK/VKShaderInterpreter.h +++ b/rpcs3/Emu/RSX/VK/VKShaderInterpreter.h @@ -31,7 +31,7 @@ namespace vk struct key_hasher { - size_t operator()(const pipeline_key& key) const + usz operator()(const pipeline_key& key) const { return rpcs3::hash_struct(key.properties) ^ key.compiler_opt; } @@ -40,7 +40,7 @@ namespace vk std::unordered_map, key_hasher> m_program_cache; std::unordered_map> m_fs_cache; vk::descriptor_pool m_descriptor_pool; - size_t m_used_descriptors = 0; + usz m_used_descriptors = 0; uint32_t m_vertex_instruction_start = 0; uint32_t m_fragment_instruction_start = 0; diff --git a/rpcs3/Emu/RSX/VK/VKTextOut.h b/rpcs3/Emu/RSX/VK/VKTextOut.h index 034f7b292e..aecfe26d93 100644 --- a/rpcs3/Emu/RSX/VK/VKTextOut.h +++ b/rpcs3/Emu/RSX/VK/VKTextOut.h @@ -198,7 +198,7 @@ namespace vk m_program = compiler->compile(info, m_pipeline_layout, vk::pipe_compiler::COMPILE_INLINE); } - void load_program(vk::command_buffer &cmd, float scale_x, float scale_y, const float *offsets, size_t nb_offsets, std::array color) + void load_program(vk::command_buffer &cmd, float scale_x, float scale_y, const float *offsets, usz nb_offsets, std::array color) { ensure(m_used_descriptors < 120); @@ -216,7 +216,7 @@ namespace vk float* dst = static_cast(m_uniforms_buffer->map(m_uniform_buffer_offset, 8192)); //std140 spec demands that arrays be multiples of 16 bytes - for (size_t i = 0; i < nb_offsets; ++i) + for (usz i = 0; i < nb_offsets; ++i) { dst[i * 4] = offsets[i * 2]; dst[i * 4 + 1] = offsets[i * 2 + 1]; @@ -270,7 +270,7 @@ namespace vk GlyphManager glyph_source; auto points = glyph_source.generate_point_map(); - const size_t buffer_size = points.size() * sizeof(GlyphManager::glyph_point); + const usz buffer_size = points.size() * sizeof(GlyphManager::glyph_point); u8* dst = static_cast(m_vertex_buffer->map(0, buffer_size)); memcpy(dst, points.data(), buffer_size); diff --git a/rpcs3/Emu/RSX/VK/VKTexture.cpp b/rpcs3/Emu/RSX/VK/VKTexture.cpp index f1cd3aa16f..5716f62490 100644 --- a/rpcs3/Emu/RSX/VK/VKTexture.cpp +++ b/rpcs3/Emu/RSX/VK/VKTexture.cpp @@ -892,7 +892,7 @@ namespace vk image_linear_size = row_pitch * layout.height_in_block * layout.depth; // Map with extra padding bytes in case of realignment - size_t offset_in_buffer = upload_heap.alloc<512>(image_linear_size + 8); + usz offset_in_buffer = upload_heap.alloc<512>(image_linear_size + 8); void* mapped_buffer = upload_heap.map(offset_in_buffer, image_linear_size + 8); // Only do GPU-side conversion if occupancy is good diff --git a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp index 3b1b6ea6fc..300b244609 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp @@ -238,7 +238,7 @@ vk::vertex_upload_info VKGSRender::upload_vertex_data() //Do actual vertex upload auto required = calculate_memory_requirements(m_vertex_layout, vertex_base, vertex_count); u32 persistent_range_base = UINT32_MAX, volatile_range_base = UINT32_MAX; - size_t persistent_offset = UINT64_MAX, volatile_offset = UINT64_MAX; + usz persistent_offset = UINT64_MAX, volatile_offset = UINT64_MAX; if (required.first > 0) { @@ -291,9 +291,9 @@ vk::vertex_upload_info VKGSRender::upload_vertex_data() if (required.first && required.second && volatile_offset > persistent_offset) { //Do this once for both to save time on map/unmap cycles - const size_t block_end = (volatile_offset + required.second); - const size_t block_size = block_end - persistent_offset; - const size_t volatile_offset_in_block = volatile_offset - persistent_offset; + const usz block_end = (volatile_offset + required.second); + const usz block_size = block_end - persistent_offset; + const usz volatile_offset_in_block = volatile_offset - persistent_offset; void *block_mapping = m_attrib_ring_info.map(persistent_offset, block_size); write_vertex_data_to_memory(m_vertex_layout, vertex_base, vertex_count, block_mapping, static_cast(block_mapping) + volatile_offset_in_block); @@ -344,7 +344,7 @@ vk::vertex_upload_info VKGSRender::upload_vertex_data() m_current_frame->buffer_views_to_clean.push_back(std::move(m_persistent_attribute_storage)); //View 64M blocks at a time (different drivers will only allow a fixed viewable heap size, 64M should be safe) - const size_t view_size = (persistent_range_base + m_texbuffer_view_size) > m_attrib_ring_info.size() ? m_attrib_ring_info.size() - persistent_range_base : m_texbuffer_view_size; + const usz view_size = (persistent_range_base + m_texbuffer_view_size) > m_attrib_ring_info.size() ? m_attrib_ring_info.size() - persistent_range_base : m_texbuffer_view_size; m_persistent_attribute_storage = std::make_unique(*m_device, m_attrib_ring_info.heap->value, VK_FORMAT_R8_UINT, persistent_range_base, view_size); persistent_range_base = 0; } @@ -359,7 +359,7 @@ vk::vertex_upload_info VKGSRender::upload_vertex_data() if (m_volatile_attribute_storage) m_current_frame->buffer_views_to_clean.push_back(std::move(m_volatile_attribute_storage)); - const size_t view_size = (volatile_range_base + m_texbuffer_view_size) > m_attrib_ring_info.size() ? m_attrib_ring_info.size() - volatile_range_base : m_texbuffer_view_size; + const usz view_size = (volatile_range_base + m_texbuffer_view_size) > m_attrib_ring_info.size() ? m_attrib_ring_info.size() - volatile_range_base : m_texbuffer_view_size; m_volatile_attribute_storage = std::make_unique(*m_device, m_attrib_ring_info.heap->value, VK_FORMAT_R8_UINT, volatile_range_base, view_size); volatile_range_base = 0; } diff --git a/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp b/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp index f9c89badc5..b296dcaef6 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp @@ -6,12 +6,12 @@ #include "../Common/GLSLCommon.h" -std::string VKVertexDecompilerThread::getFloatTypeName(size_t elementCount) +std::string VKVertexDecompilerThread::getFloatTypeName(usz elementCount) { return glsl::getFloatTypeNameImpl(elementCount); } -std::string VKVertexDecompilerThread::getIntTypeName(size_t elementCount) +std::string VKVertexDecompilerThread::getIntTypeName(usz elementCount) { return "ivec4"; } diff --git a/rpcs3/Emu/RSX/VK/VKVertexProgram.h b/rpcs3/Emu/RSX/VK/VKVertexProgram.h index d31d6dfa90..b9d92d03c6 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexProgram.h +++ b/rpcs3/Emu/RSX/VK/VKVertexProgram.h @@ -26,8 +26,8 @@ struct VKVertexDecompilerThread : public VertexProgramDecompiler m_device_props; protected: - std::string getFloatTypeName(size_t elementCount) override; - std::string getIntTypeName(size_t elementCount) override; + std::string getFloatTypeName(usz elementCount) override; + std::string getIntTypeName(usz elementCount) override; std::string getFunction(FUNCTION) override; std::string compareFunction(COMPARE, const std::string&, const std::string&, bool scalar) override; diff --git a/rpcs3/Emu/RSX/gcm_printing.cpp b/rpcs3/Emu/RSX/gcm_printing.cpp index 12f31e59c3..3f932fa429 100644 --- a/rpcs3/Emu/RSX/gcm_printing.cpp +++ b/rpcs3/Emu/RSX/gcm_printing.cpp @@ -931,18 +931,18 @@ namespace " stride = " + std::to_string(stride) + " frequency = " + std::to_string(frequency); } - std::string transform_constant(size_t index, u32 arg) + std::string transform_constant(usz index, u32 arg) { return "Transform constant " + std::to_string(index) + ": " + std::to_string(arg) + "/" + std::to_string(std::bit_cast(arg)); } - std::string texture_offset(size_t index, u32 arg) + std::string texture_offset(usz index, u32 arg) { return "Texture " + std::to_string(index) + ": Offset @" + ptr_to_string(arg); } - std::string texture_size(size_t index, u32 arg) + std::string texture_size(usz index, u32 arg) { return "Texture " + std::to_string(index) + ": width = " + std::to_string(arg & 0xffff) + " height = " + std::to_string(arg >> 16); @@ -983,7 +983,7 @@ namespace return "Error"; } - std::string texture_format(size_t index, u32 arg) + std::string texture_format(usz index, u32 arg) { int format = ((arg >> 8) & 0xFF); return "Texture " + std::to_string(index) + ": location = " + ptr_to_string((arg & 0x3) - 1) + @@ -1028,7 +1028,7 @@ namespace return "Error"; } - std::string texture_address(size_t index, u32 arg) + std::string texture_address(usz index, u32 arg) { return "Texture " + std::to_string(index) + ": wrap_s = " + get_texture_wrap_mode(arg & 0xF) + " wrap_t = " + get_texture_wrap_mode((arg >> 8) & 0xF) + " wrap_r = " + @@ -1054,7 +1054,7 @@ namespace return "Error"; } - std::string texture_control0(size_t index, u32 arg) + std::string texture_control0(usz index, u32 arg) { std::string result = "Texture " + std::to_string(index); if ((arg >> 31) & 0x1) { @@ -1080,7 +1080,7 @@ namespace return "Error"; } - std::string texture_control1(size_t index, u32 arg) noexcept + std::string texture_control1(usz index, u32 arg) noexcept { return "Texture " + std::to_string(index) + " Component 0 = " + get_remap_channel(arg & 0x3) + " Component 1 = " + get_remap_channel((arg >> 2) & 0x3) + " Component 2 = " + @@ -1088,18 +1088,18 @@ namespace get_remap_channel((arg >> 6) & 0x3); } - std::string texture_control3(size_t index, u32 arg) + std::string texture_control3(usz index, u32 arg) { return "Texture " + std::to_string(index) + " depth = " + std::to_string(arg >> 20) + " pitch = " + std::to_string(arg & 0xFFFFF); } - std::string texture_border_color(size_t index, u32 arg) + std::string texture_border_color(usz index, u32 arg) { return "Texture " + std::to_string(index) + " border color = " + std::to_string(arg); } - std::string texture_filter(size_t index, u32 arg) + std::string texture_filter(usz index, u32 arg) { return "Texture " + std::to_string(index) + " bias = " + std::to_string(arg & 0x1fff) + " min_filter = " + std::to_string((arg >> 16) & 0x7) + " mag_filter = " + diff --git a/rpcs3/Emu/RSX/rsx_decode.h b/rpcs3/Emu/RSX/rsx_decode.h index bd5b555682..8a3fdf6c9a 100644 --- a/rpcs3/Emu/RSX/rsx_decode.h +++ b/rpcs3/Emu/RSX/rsx_decode.h @@ -4454,9 +4454,9 @@ struct register_vertex_helper decoded_type(u32 value) : value(value) {} }; - static constexpr size_t increment_per_array_index = (count * sizeof(type)) / sizeof(u32); - static constexpr size_t attribute_index = index / increment_per_array_index; - static constexpr size_t vertex_subreg = index % increment_per_array_index; + static constexpr usz increment_per_array_index = (count * sizeof(type)) / sizeof(u32); + static constexpr usz attribute_index = index / increment_per_array_index; + static constexpr usz vertex_subreg = index % increment_per_array_index; static std::string dump(decoded_type&& decoded_values) { diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index c244f7bf7d..b5d7b6d856 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -261,10 +261,10 @@ namespace rsx template void set_vertex_data_impl(thread* rsx, u32 arg) { - static const size_t increment_per_array_index = (register_count * sizeof(type)) / sizeof(u32); + static const usz increment_per_array_index = (register_count * sizeof(type)) / sizeof(u32); - static const size_t attribute_index = index / increment_per_array_index; - static const size_t vertex_subreg = index % increment_per_array_index; + static const usz attribute_index = index / increment_per_array_index; + static const usz vertex_subreg = index % increment_per_array_index; const auto vtype = vertex_data_type_from_element_type::type; ensure(vtype != rsx::vertex_base_type::cmp); diff --git a/rpcs3/Emu/RSX/rsx_methods.h b/rpcs3/Emu/RSX/rsx_methods.h index c9a54f1f9f..ba017de000 100644 --- a/rpcs3/Emu/RSX/rsx_methods.h +++ b/rpcs3/Emu/RSX/rsx_methods.h @@ -530,7 +530,7 @@ namespace rsx std::array vertex_arrays_info; private: - template + template static std::array fill_array(Args&& arg, std::index_sequence) { return{ T(N, std::forward(arg))... }; diff --git a/rpcs3/Emu/RSX/rsx_utils.h b/rpcs3/Emu/RSX/rsx_utils.h index 4cb50209a9..815704eab8 100644 --- a/rpcs3/Emu/RSX/rsx_utils.h +++ b/rpcs3/Emu/RSX/rsx_utils.h @@ -292,7 +292,7 @@ namespace rsx // Copy memory in inverse direction from source // Used to scale negatively x axis while transfering image data template - static void memcpy_r(void* dst, void* src, std::size_t size) + static void memcpy_r(void* dst, void* src, usz size) { for (u32 i = 0; i < size; i++) { diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 09b5849999..5b3311b40a 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -776,7 +776,7 @@ std::string Emulator::GetExeDir() GetModuleFileNameW(nullptr, buffer, sizeof(buffer)/2); std::string path_to_exe = wchar_to_utf8(buffer); - size_t last = path_to_exe.find_last_of("\\"); + usz last = path_to_exe.find_last_of("\\"); return last == std::string::npos ? std::string("") : path_to_exe.substr(0, last+1); } #endif @@ -1121,7 +1121,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool g_progr = "Scanning directories for SPRX libraries..."; // Find all .sprx files recursively (TODO: process .mself files) - for (std::size_t i = 0; i < dir_queue.size(); i++) + for (usz i = 0; i < dir_queue.size(); i++) { if (Emu.IsStopped()) { @@ -1193,13 +1193,13 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool ensure(vm::falloc(0x10000, 0xf0000, vm::main)); } - atomic_t fnext = 0; + atomic_t fnext = 0; shared_mutex sprx_mtx; named_thread_group workers("SPRX Worker ", GetMaxThreads(), [&] { - for (std::size_t func_i = fnext++; func_i < file_queue.size(); func_i = fnext++) + for (usz func_i = fnext++; func_i < file_queue.size(); func_i = fnext++) { const auto& path = std::as_const(file_queue)[func_i].first; @@ -1252,7 +1252,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool } // Detect boot location - constexpr size_t game_dir_size = 8; // size of PS3_GAME and PS3_GMXX + constexpr usz game_dir_size = 8; // size of PS3_GAME and PS3_GMXX const std::string hdd0_game = vfs::get("/dev_hdd0/game/"); const std::string hdd0_disc = vfs::get("/dev_hdd0/disc/"); const bool from_hdd0_game = m_path.find(hdd0_game) != umax; @@ -1260,7 +1260,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool // Mount /dev_bdvd/ if necessary if (bdvd_dir.empty() && disc.empty()) { - if (const size_t usrdir_pos = elf_dir.rfind("/USRDIR"); usrdir_pos != umax) + if (const usz usrdir_pos = elf_dir.rfind("/USRDIR"); usrdir_pos != umax) { const std::string main_dir = elf_dir.substr(0, usrdir_pos); @@ -1626,7 +1626,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool else if (!bdvd_dir.empty() && fs::is_dir(bdvd_dir)) { // Disc games are on /dev_bdvd/ - const std::size_t pos = m_path.rfind(m_game_dir); + const usz pos = m_path.rfind(m_game_dir); argv[0] = "/dev_bdvd/PS3_GAME/" + m_path.substr(pos + game_dir_size + 1); m_dir = "/dev_bdvd/PS3_GAME/"; } @@ -2007,7 +2007,7 @@ u32 Emulator::GetMaxThreads() const s32 error_code::error_report(const fmt_type_info* sup, u64 arg, const fmt_type_info* sup2, u64 arg2) { - static thread_local std::unordered_map g_tls_error_stats; + static thread_local std::unordered_map g_tls_error_stats; static thread_local std::string g_tls_error_str; if (!sup) diff --git a/rpcs3/Emu/VFS.cpp b/rpcs3/Emu/VFS.cpp index d6a1de92eb..b8c6ea97ce 100644 --- a/rpcs3/Emu/VFS.cpp +++ b/rpcs3/Emu/VFS.cpp @@ -301,7 +301,7 @@ std::string vfs::escape(std::string_view name, bool escape_slash) } // Emulate NTS (limited) - auto get_char = [&](std::size_t pos) -> char2 + auto get_char = [&](usz pos) -> char2 { if (pos < name.size()) { @@ -352,7 +352,7 @@ std::string vfs::escape(std::string_view name, bool escape_slash) result.reserve(result.size() + name.size()); - for (std::size_t i = 0, s = name.size(); i < s; i++) + for (usz i = 0, s = name.size(); i < s; i++) { switch (char2 c = name[i]) { @@ -499,7 +499,7 @@ std::string vfs::unescape(std::string_view name) result.reserve(name.size()); // Emulate NTS - auto get_char = [&](std::size_t pos) -> char2 + auto get_char = [&](usz pos) -> char2 { if (pos < name.size()) { @@ -511,7 +511,7 @@ std::string vfs::unescape(std::string_view name) } }; - for (std::size_t i = 0, s = name.size(); i < s; i++) + for (usz i = 0, s = name.size(); i < s; i++) { switch (char2 c = name[i]) { diff --git a/rpcs3/Emu/perf_meter.hpp b/rpcs3/Emu/perf_meter.hpp index d75a80c10b..44d8080741 100644 --- a/rpcs3/Emu/perf_meter.hpp +++ b/rpcs3/Emu/perf_meter.hpp @@ -141,7 +141,7 @@ public: } // Push subevent data in array - template + template SAFE_BUFFERS void push() noexcept { // TODO: should use more efficient search with type comparison, then value comparison, or pattern matching diff --git a/rpcs3/Emu/title.cpp b/rpcs3/Emu/title.cpp index 351acb7af1..fafd12014f 100644 --- a/rpcs3/Emu/title.cpp +++ b/rpcs3/Emu/title.cpp @@ -10,7 +10,7 @@ namespace rpcs3 // Parse title format string std::string title_string; - for (std::size_t i = 0; i < title_data.format.size();) + for (usz i = 0; i < title_data.format.size();) { const char c1 = title_data.format[i]; diff --git a/rpcs3/Input/ds3_pad_handler.cpp b/rpcs3/Input/ds3_pad_handler.cpp index 10b9062f38..bc800bf858 100644 --- a/rpcs3/Input/ds3_pad_handler.cpp +++ b/rpcs3/Input/ds3_pad_handler.cpp @@ -158,7 +158,7 @@ std::vector ds3_pad_handler::ListDevices() if (!Init()) return ds3_pads_list; - for (size_t i = 1; i <= controllers.size(); ++i) // Controllers 1-n in GUI + for (usz i = 1; i <= controllers.size(); ++i) // Controllers 1-n in GUI { ds3_pads_list.emplace_back(m_name_string + std::to_string(i)); } @@ -231,13 +231,13 @@ std::shared_ptr ds3_pad_handler::get_ds3_device(con if (!Init()) return nullptr; - const size_t pos = padId.find(m_name_string); + const usz pos = padId.find(m_name_string); if (pos == umax) return nullptr; const int pad_number = std::stoi(padId.substr(pos + 9)); if (pad_number > 0 && pad_number + 0u <= controllers.size()) - return controllers[static_cast(pad_number) - 1]; + return controllers[static_cast(pad_number) - 1]; return nullptr; } diff --git a/rpcs3/Input/ds4_pad_handler.cpp b/rpcs3/Input/ds4_pad_handler.cpp index ac27f2a27d..3bfc0129d3 100644 --- a/rpcs3/Input/ds4_pad_handler.cpp +++ b/rpcs3/Input/ds4_pad_handler.cpp @@ -249,7 +249,7 @@ std::shared_ptr ds4_pad_handler::GetDS4Device(const if (!Init()) return nullptr; - size_t pos = padId.find(m_name_string); + usz pos = padId.find(m_name_string); if (pos == umax) return nullptr; @@ -721,7 +721,7 @@ std::vector ds4_pad_handler::ListDevices() if (!Init()) return ds4_pads_list; - for (size_t i = 1; i <= controllers.size(); ++i) // Controllers 1-n in GUI + for (usz i = 1; i <= controllers.size(); ++i) // Controllers 1-n in GUI { ds4_pads_list.emplace_back(m_name_string + std::to_string(i)); } diff --git a/rpcs3/Input/dualsense_pad_handler.cpp b/rpcs3/Input/dualsense_pad_handler.cpp index 155e94ec9b..23879e04d2 100644 --- a/rpcs3/Input/dualsense_pad_handler.cpp +++ b/rpcs3/Input/dualsense_pad_handler.cpp @@ -221,7 +221,7 @@ std::vector dualsense_pad_handler::ListDevices() if (!Init()) return dualsense_pads_list; - for (size_t i = 1; i < controllers.size(); ++i) + for (usz i = 1; i < controllers.size(); ++i) { dualsense_pads_list.emplace_back(m_name_string + std::to_string(i)); } @@ -243,7 +243,7 @@ dualsense_pad_handler::DualSenseDataStatus dualsense_pad_handler::GetRawData(con const int res = hid_read(device->hidDevice, buf.data(), 128); // looks like controller disconnected or read error - + if (res == -1) return DualSenseDataStatus::ReadError; @@ -264,7 +264,7 @@ dualsense_pad_handler::DualSenseDataStatus dualsense_pad_handler::GetRawData(con { device->dataMode = DualSenseDataMode::Enhanced; device->btCon = false; - offset = 1; + offset = 1; } break; case 0x31: @@ -476,7 +476,7 @@ std::unordered_map dualsense_pad_handler::get_button_values(const std: data = buf[6] & 0x03; keyBuffer[DualSenseKeyCodes::PSButton] = ((data & 0x01) != 0) ? 255 : 0; - keyBuffer[DualSenseKeyCodes::TouchPad] = ((data & 0x02) != 0) ? 255 : 0; + keyBuffer[DualSenseKeyCodes::TouchPad] = ((data & 0x02) != 0) ? 255 : 0; return keyBuffer; } @@ -577,7 +577,7 @@ std::unordered_map dualsense_pad_handler::get_button_values(const std: data = buf[9] & 0x03; keyBuffer[DualSenseKeyCodes::PSButton] = ((data & 0x01) != 0) ? 255 : 0; - keyBuffer[DualSenseKeyCodes::TouchPad] = ((data & 0x02) != 0) ? 255 : 0; + keyBuffer[DualSenseKeyCodes::TouchPad] = ((data & 0x02) != 0) ? 255 : 0; return keyBuffer; } @@ -599,7 +599,7 @@ std::shared_ptr dualsense_pad_handler::G if (!Init()) return nullptr; - size_t pos = padId.find(m_name_string); + usz pos = padId.find(m_name_string); if (pos == umax) return nullptr; diff --git a/rpcs3/Input/xinput_pad_handler.cpp b/rpcs3/Input/xinput_pad_handler.cpp index b7e6594b5a..2729316935 100644 --- a/rpcs3/Input/xinput_pad_handler.cpp +++ b/rpcs3/Input/xinput_pad_handler.cpp @@ -148,7 +148,7 @@ int xinput_pad_handler::GetDeviceNumber(const std::string& padId) if (!Init()) return -1; - size_t pos = padId.find(m_name_string); + usz pos = padId.find(m_name_string); if (pos == umax) return -1; @@ -487,8 +487,8 @@ void xinput_pad_handler::apply_pad_data(const std::shared_ptr& device // The left motor is the low-frequency rumble motor. The right motor is the high-frequency rumble motor. // The two motors are not the same, and they create different vibration effects. Values range between 0 to 65535. - size_t idx_l = profile->switch_vibration_motors ? 1 : 0; - size_t idx_s = profile->switch_vibration_motors ? 0 : 1; + usz idx_l = profile->switch_vibration_motors ? 1 : 0; + usz idx_s = profile->switch_vibration_motors ? 0 : 1; u16 speed_large = profile->enable_vibration_motor_large ? pad->m_vibrateMotors[idx_l].m_value : static_cast(vibration_min); u16 speed_small = profile->enable_vibration_motor_small ? pad->m_vibrateMotors[idx_s].m_value : static_cast(vibration_min); diff --git a/rpcs3/Loader/PSF.cpp b/rpcs3/Loader/PSF.cpp index 3dc57f4b20..60d8cc875f 100644 --- a/rpcs3/Loader/PSF.cpp +++ b/rpcs3/Loader/PSF.cpp @@ -189,7 +189,7 @@ namespace psf std::vector indices; indices.reserve(psf.size()); // Generate indices and calculate key table length - std::size_t key_offset = 0, data_offset = 0; + usz key_offset = 0, data_offset = 0; for (const auto& entry : psf) { @@ -246,7 +246,7 @@ namespace psf else if (fmt == format::string || fmt == format::array) { const std::string& value = entry.second.as_string(); - const std::size_t size = std::min(max, value.size()); + const usz size = std::min(max, value.size()); if (value.size() + (fmt == format::string) > max) { diff --git a/rpcs3/Loader/PUP.cpp b/rpcs3/Loader/PUP.cpp index a94f54219f..ab452f4623 100644 --- a/rpcs3/Loader/PUP.cpp +++ b/rpcs3/Loader/PUP.cpp @@ -47,7 +47,7 @@ fs::file pup_object::get_file(u64 entry_id) bool pup_object::validate_hashes() { - for (size_t i = 0; i < m_file_tbl.size(); i++) + for (usz i = 0; i < m_file_tbl.size(); i++) { u8 *hash = m_hash_tbl[i].hash; PUPFileEntry file = m_file_tbl[i]; diff --git a/rpcs3/Loader/TAR.cpp b/rpcs3/Loader/TAR.cpp index c2ccc36b97..d0bfdfe28b 100644 --- a/rpcs3/Loader/TAR.cpp +++ b/rpcs3/Loader/TAR.cpp @@ -7,7 +7,7 @@ LOG_CHANNEL(tar_log, "TAR"); -tar_object::tar_object(const fs::file& file, size_t offset) +tar_object::tar_object(const fs::file& file, usz offset) : m_file(file) , initial_offset(static_cast(offset)) { diff --git a/rpcs3/Loader/TAR.h b/rpcs3/Loader/TAR.h index ff5ff85b1e..ef994bcc35 100644 --- a/rpcs3/Loader/TAR.h +++ b/rpcs3/Loader/TAR.h @@ -28,7 +28,7 @@ class tar_object TARHeader read_header(u64 offset); public: - tar_object(const fs::file& file, size_t offset = 0); + tar_object(const fs::file& file, usz offset = 0); std::vector get_filenames(); diff --git a/rpcs3/Loader/TROPUSR.cpp b/rpcs3/Loader/TROPUSR.cpp index 45cd2f0e42..aafc856189 100644 --- a/rpcs3/Loader/TROPUSR.cpp +++ b/rpcs3/Loader/TROPUSR.cpp @@ -253,7 +253,7 @@ u32 TROPUSRLoader::GetUnlockedPlatinumID(u32 trophy_id, const std::string& confi trophy_base = trophy_base->GetChildren(); } - const size_t trophy_count = m_table4.size(); + const usz trophy_count = m_table4.size(); for (std::shared_ptr n = trophy_base->GetChildren(); n; n = n->GetNext()) { @@ -281,7 +281,7 @@ u32 TROPUSRLoader::GetUnlockedPlatinumID(u32 trophy_id, const std::string& confi } // The platinum trophy stays locked if any relevant trophy is still locked - for (size_t i = 0; i < trophy_count; i++) + for (usz i = 0; i < trophy_count; i++) { if (m_table4[i].trophy_pid == pid && !m_table6[i].trophy_state) { diff --git a/rpcs3/main.cpp b/rpcs3/main.cpp index 0c96a2b761..e7fdc4739e 100644 --- a/rpcs3/main.cpp +++ b/rpcs3/main.cpp @@ -589,7 +589,7 @@ extern "C" return InitOnceComplete(reinterpret_cast(ppinit), f, lpc); } - size_t __stdcall __std_get_string_size_without_trailing_whitespace(const char* str, size_t size) noexcept + usz __stdcall __std_get_string_size_without_trailing_whitespace(const char* str, usz size) noexcept { while (size) { @@ -612,7 +612,7 @@ extern "C" return size; } - size_t __stdcall __std_system_error_allocate_message(const unsigned long msg_id, char** ptr_str) noexcept + usz __stdcall __std_system_error_allocate_message(const unsigned long msg_id, char** ptr_str) noexcept { return __std_get_string_size_without_trailing_whitespace(*ptr_str, FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, diff --git a/rpcs3/rpcs3qt/auto_pause_settings_dialog.cpp b/rpcs3/rpcs3qt/auto_pause_settings_dialog.cpp index 552a7c4834..9ec2c88636 100644 --- a/rpcs3/rpcs3qt/auto_pause_settings_dialog.cpp +++ b/rpcs3/rpcs3qt/auto_pause_settings_dialog.cpp @@ -79,8 +79,8 @@ void auto_pause_settings_dialog::LoadEntries(void) { //System calls ID and Function calls ID are all u32 iirc. u32 num; - size_t fmax = list.size(); - size_t fcur = 0; + usz fmax = list.size(); + usz fcur = 0; list.seek(0); while (fcur <= fmax - sizeof(u32)) { @@ -102,7 +102,7 @@ void auto_pause_settings_dialog::SaveEntries(void) //System calls ID and Function calls ID are all u32 iirc. u32 num = 0; list.seek(0); - for (size_t i = 0; i < m_entries.size(); ++i) + for (usz i = 0; i < m_entries.size(); ++i) { if (num == 0xFFFFFFFF) continue; num = m_entries[i]; diff --git a/rpcs3/rpcs3qt/cheat_manager.cpp b/rpcs3/rpcs3qt/cheat_manager.cpp index c6836a9585..b534f8b347 100644 --- a/rpcs3/rpcs3qt/cheat_manager.cpp +++ b/rpcs3/rpcs3qt/cheat_manager.cpp @@ -990,7 +990,7 @@ void cheat_manager_dialog::do_the_search() lst_search->clear(); - const size_t size = offsets_found.size(); + const usz size = offsets_found.size(); if (size == 0) { @@ -1018,7 +1018,7 @@ void cheat_manager_dialog::do_the_search() void cheat_manager_dialog::update_cheat_list() { - size_t num_rows = 0; + usz num_rows = 0; for (const auto& name : g_cheat.cheats) num_rows += name.second.size(); diff --git a/rpcs3/rpcs3qt/downloader.cpp b/rpcs3/rpcs3qt/downloader.cpp index 949a5f0cb8..4270502ad0 100644 --- a/rpcs3/rpcs3qt/downloader.cpp +++ b/rpcs3/rpcs3qt/downloader.cpp @@ -11,7 +11,7 @@ LOG_CHANNEL(network_log, "NETWORK"); -size_t curl_write_cb_compat(char* ptr, size_t /*size*/, size_t nmemb, void* userdata) +usz curl_write_cb_compat(char* ptr, usz /*size*/, usz nmemb, void* userdata) { downloader* download = reinterpret_cast(userdata); return download->update_buffer(ptr, nmemb); @@ -122,7 +122,7 @@ progress_dialog* downloader::get_progress_dialog() const return m_progress_dialog; } -std::string downloader::get_hash(const char* data, size_t size, bool lower_case) +std::string downloader::get_hash(const char* data, usz size, bool lower_case) { u8 res_hash[32]; mbedtls_sha256_context ctx; @@ -133,7 +133,7 @@ std::string downloader::get_hash(const char* data, size_t size, bool lower_case) std::string res_hash_string("0000000000000000000000000000000000000000000000000000000000000000"); - for (size_t index = 0; index < 32; index++) + for (usz index = 0; index < 32; index++) { const auto pal = lower_case ? "0123456789abcdef" : "0123456789ABCDEF"; res_hash_string[index * 2] = pal[res_hash[index] >> 4]; @@ -143,7 +143,7 @@ std::string downloader::get_hash(const char* data, size_t size, bool lower_case) return res_hash_string; } -size_t downloader::update_buffer(char* data, size_t size) +usz downloader::update_buffer(char* data, usz size) { if (m_curl_abort) { diff --git a/rpcs3/rpcs3qt/downloader.h b/rpcs3/rpcs3qt/downloader.h index 8cbcf1e5a2..96a6d21cea 100644 --- a/rpcs3/rpcs3qt/downloader.h +++ b/rpcs3/rpcs3qt/downloader.h @@ -14,14 +14,14 @@ public: downloader(QWidget* parent = nullptr); void start(const std::string& url, bool follow_location, bool show_progress_dialog, const QString& progress_dialog_title = "", bool keep_progress_dialog_open = false, int expected_size = -1); - size_t update_buffer(char* data, size_t size); + usz update_buffer(char* data, usz size); void update_progress_dialog(const QString& title); void close_progress_dialog(); progress_dialog* get_progress_dialog() const; - static std::string get_hash(const char* data, size_t size, bool lower_case); + static std::string get_hash(const char* data, usz size, bool lower_case); private Q_SLOTS: void handle_buffer_update(int size, int max); diff --git a/rpcs3/rpcs3qt/gs_frame.cpp b/rpcs3/rpcs3qt/gs_frame.cpp index 66553e5502..8c356f846a 100644 --- a/rpcs3/rpcs3qt/gs_frame.cpp +++ b/rpcs3/rpcs3qt/gs_frame.cpp @@ -447,14 +447,14 @@ void gs_frame::take_screenshot(const std::vector sshot_data, const u32 sshot if (is_bgra) [[likely]] { - for (size_t index = 0; index < sshot_data.size() / sizeof(u32); index++) + for (usz index = 0; index < sshot_data.size() / sizeof(u32); index++) { alpha_ptr[index] = ((sshot_ptr[index] & 0xFF) << 16) | (sshot_ptr[index] & 0xFF00) | ((sshot_ptr[index] & 0xFF0000) >> 16) | 0xFF000000; } } else { - for (size_t index = 0; index < sshot_data.size() / sizeof(u32); index++) + for (usz index = 0; index < sshot_data.size() / sizeof(u32); index++) { alpha_ptr[index] = sshot_ptr[index] | 0xFF000000; } @@ -467,7 +467,7 @@ void gs_frame::take_screenshot(const std::vector sshot_data, const u32 sshot png_set_IHDR(write_ptr, info_ptr, sshot_width, sshot_height, 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); std::vector rows(sshot_height); - for (size_t y = 0; y < sshot_height; y++) + for (usz y = 0; y < sshot_height; y++) rows[y] = sshot_data_alpha.data() + y * sshot_width * 4; png_set_rows(write_ptr, info_ptr, &rows[0]); diff --git a/rpcs3/rpcs3qt/input_dialog.cpp b/rpcs3/rpcs3qt/input_dialog.cpp index d7533bc4f5..0e75a104cd 100644 --- a/rpcs3/rpcs3qt/input_dialog.cpp +++ b/rpcs3/rpcs3qt/input_dialog.cpp @@ -50,7 +50,7 @@ void input_dialog::set_input_font(const QFont& font, bool fix_width, char sample { if (int max = m_input->maxLength(); max > 0 && fix_width && std::isprint(static_cast(sample))) { - const QString str = qstr(std::string(static_cast(max), sample)); + const QString str = qstr(std::string(static_cast(max), sample)); m_input->setFixedWidth(gui::utils::get_label_width(str, &font)); } diff --git a/rpcs3/rpcs3qt/kernel_explorer.cpp b/rpcs3/rpcs3qt/kernel_explorer.cpp index e8bcd6b8c5..770544f57b 100644 --- a/rpcs3/rpcs3qt/kernel_explorer.cpp +++ b/rpcs3/rpcs3qt/kernel_explorer.cpp @@ -192,7 +192,7 @@ void kernel_explorer::Update() return; } - static const size_t additional_size = 6; + static const usz additional_size = 6; const std::unordered_map tree_item_names = { diff --git a/rpcs3/rpcs3qt/kernel_explorer.h b/rpcs3/rpcs3qt/kernel_explorer.h index f42e2fea3d..074227c6fe 100644 --- a/rpcs3/rpcs3qt/kernel_explorer.h +++ b/rpcs3/rpcs3qt/kernel_explorer.h @@ -9,7 +9,7 @@ class kernel_explorer : public QDialog { Q_OBJECT - static const size_t sys_size = 256; + static const usz sys_size = 256; enum additional_nodes { diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 482156fa9d..78d90de6ab 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -780,7 +780,7 @@ void main_window::HandlePupInstallation(QString file_path) std::string version_string = pup.get_file(0x100).to_string(); - if (const size_t version_pos = version_string.find('\n'); version_pos != umax) + if (const usz version_pos = version_string.find('\n'); version_pos != umax) { version_string.erase(version_pos); } @@ -904,7 +904,7 @@ void main_window::DecryptSPRXLibraries() bool tried = false; bool invalid = false; - std::size_t key_it = 0; + usz key_it = 0; while (true) { @@ -952,7 +952,7 @@ void main_window::DecryptSPRXLibraries() // Allow the user to manually type KLIC if decryption failed const std::string filename = old_path.substr(old_path.find_last_of(fs::delim) + 1); - + const QString hint = tr("Hint: KLIC (KLicense key) is a 16-byte long string. (32 hexadecimal characters)" "\nAnd is logged with some sceNpDrm* functions when the game/application which owns \"%0\" is running.").arg(qstr(filename)); diff --git a/rpcs3/rpcs3qt/pad_settings_dialog.cpp b/rpcs3/rpcs3qt/pad_settings_dialog.cpp index e65b9b91fe..18c5a206f3 100644 --- a/rpcs3/rpcs3qt/pad_settings_dialog.cpp +++ b/rpcs3/rpcs3qt/pad_settings_dialog.cpp @@ -932,7 +932,7 @@ void pad_settings_dialog::UpdateLabels(bool is_reset) const auto products = input::get_products_by_class(m_handler_cfg.device_class_type); - for (size_t i = 0; i < products.size(); i++) + for (usz i = 0; i < products.size(); i++) { if (products[i].vendor_id == m_handler_cfg.vendor_id && products[i].product_id == m_handler_cfg.product_id) { @@ -1259,7 +1259,7 @@ void pad_settings_dialog::ChangeInputType() case pad_handler::dualsense: { const QString name_string = qstr(m_handler->name_string()); - for (size_t i = 1; i <= m_handler->max_devices(); i++) // Controllers 1-n in GUI + for (usz i = 1; i <= m_handler->max_devices(); i++) // Controllers 1-n in GUI { const QString device_name = name_string + QString::number(i); ui->chooseDevice->addItem(device_name, QVariant::fromValue(pad_device_info{ sstr(device_name), true })); @@ -1278,7 +1278,7 @@ void pad_settings_dialog::ChangeInputType() } default: { - for (size_t i = 0; i < device_list.size(); i++) + for (usz i = 0; i < device_list.size(); i++) { ui->chooseDevice->addItem(qstr(device_list[i]), QVariant::fromValue(pad_device_info{ device_list[i], true })); } @@ -1505,7 +1505,7 @@ void pad_settings_dialog::RefreshInputTypes() else { const std::vector str_inputs = g_cfg_input.player[0]->handler.to_list(); - for (size_t index = 0; index < str_inputs.size(); index++) + for (usz index = 0; index < str_inputs.size(); index++) { const QString item_data = qstr(str_inputs[index]); ui->chooseHandler->addItem(GetLocalizedPadHandler(item_data, static_cast(index)), QVariant(item_data)); diff --git a/rpcs3/rpcs3qt/patch_manager_dialog.cpp b/rpcs3/rpcs3qt/patch_manager_dialog.cpp index 524054c0a2..735e17ef86 100644 --- a/rpcs3/rpcs3qt/patch_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/patch_manager_dialog.cpp @@ -759,8 +759,8 @@ void patch_manager_dialog::dropEvent(QDropEvent* event) log_message.clear(); - size_t count = 0; - size_t total = 0; + usz count = 0; + usz total = 0; if (patch_engine::import_patches(patches, imported_patch_yml_path, count, total, &log_message)) { diff --git a/rpcs3/rpcs3qt/render_creator.cpp b/rpcs3/rpcs3qt/render_creator.cpp index 7d5070a32b..1c5de491c7 100644 --- a/rpcs3/rpcs3qt/render_creator.cpp +++ b/rpcs3/rpcs3qt/render_creator.cpp @@ -100,7 +100,7 @@ void render_creator::update_names(const QStringList& names) { for (int i = 0; i < names.size(); i++) { - if (static_cast(i) >= renderers.size() || !renderers[i]) + if (static_cast(i) >= renderers.size() || !renderers[i]) { cfg_log.error("render_creator::update_names could not update renderer %d", i); return; diff --git a/rpcs3/rpcs3qt/rsx_debugger.cpp b/rpcs3/rpcs3qt/rsx_debugger.cpp index 80d5f31136..89b3ab6bcb 100644 --- a/rpcs3/rpcs3qt/rsx_debugger.cpp +++ b/rpcs3/rpcs3qt/rsx_debugger.cpp @@ -400,7 +400,7 @@ void Buffer::ShowWindowed() namespace { - std::array get_value(gsl::span orig_buffer, rsx::surface_color_format format, size_t idx) + std::array get_value(gsl::span orig_buffer, rsx::surface_color_format format, usz idx) { switch (format) { @@ -459,7 +459,7 @@ namespace /** * Return a new buffer that can be passed to QImage. */ - u8* convert_to_QImage_buffer(rsx::surface_color_format format, gsl::span orig_buffer, size_t width, size_t height) noexcept + u8* convert_to_QImage_buffer(rsx::surface_color_format format, gsl::span orig_buffer, usz width, usz height) noexcept { u8* buffer = static_cast(std::malloc(width * height * 4)); for (u32 i = 0; i < width * height; i++) @@ -477,7 +477,7 @@ namespace void rsx_debugger::OnClickDrawCalls() { - size_t draw_id = m_list_captured_draw_calls->currentRow(); + usz draw_id = m_list_captured_draw_calls->currentRow(); const auto& draw_call = frame_debug.draw_calls[draw_id]; @@ -492,7 +492,7 @@ void rsx_debugger::OnClickDrawCalls() u32 width = draw_call.state.surface_clip_width(); u32 height = draw_call.state.surface_clip_height(); - for (size_t i = 0; i < 4; i++) + for (usz i = 0; i < 4; i++) { if (width && height && !draw_call.color_buffer[i].empty()) { diff --git a/rpcs3/rpcs3qt/save_manager_dialog.cpp b/rpcs3/rpcs3qt/save_manager_dialog.cpp index 54074d169a..a83f6fcd21 100644 --- a/rpcs3/rpcs3qt/save_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/save_manager_dialog.cpp @@ -250,7 +250,7 @@ void save_manager_dialog::UpdateList() } QList indices; - for (size_t i = 0; i < m_save_entries.size(); ++i) + for (usz i = 0; i < m_save_entries.size(); ++i) indices.append(static_cast(i)); std::function get_icon = [this](const int& row) diff --git a/rpcs3/rpcs3qt/trophy_manager_dialog.cpp b/rpcs3/rpcs3qt/trophy_manager_dialog.cpp index f977b988e4..540addbaf2 100644 --- a/rpcs3/rpcs3qt/trophy_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/trophy_manager_dialog.cpp @@ -735,7 +735,7 @@ void trophy_manager_dialog::PopulateGameTable() m_game_combo->clear(); QList indices; - for (size_t i = 0; i < m_trophies_db.size(); ++i) + for (usz i = 0; i < m_trophies_db.size(); ++i) indices.append(static_cast(i)); std::function get_icon = [this](const int& i) diff --git a/rpcs3/rpcs3qt/update_manager.cpp b/rpcs3/rpcs3qt/update_manager.cpp index b47911586b..5db56e2807 100644 --- a/rpcs3/rpcs3qt/update_manager.cpp +++ b/rpcs3/rpcs3qt/update_manager.cpp @@ -309,7 +309,7 @@ bool update_manager::handle_rpcs3(const QByteArray& data) SRes res; UInt16 temp_u16[PATH_MAX]; u8 temp_u8[PATH_MAX]; - const size_t kInputBufSize = static_cast(1u << 18u); + const usz kInputBufSize = static_cast(1u << 18u); const ISzAlloc g_Alloc = {SzAlloc, SzFree}; allocImp = g_Alloc; @@ -373,7 +373,7 @@ bool update_manager::handle_rpcs3(const QByteArray& data) UInt32 blockIndex = 0xFFFFFFFF; Byte* outBuffer = nullptr; - size_t outBufferSize = 0; + usz outBufferSize = 0; // Creates temp folder for moving active files const std::string tmp_folder = Emulator::GetEmuDir() + "rpcs3_old/"; @@ -381,9 +381,9 @@ bool update_manager::handle_rpcs3(const QByteArray& data) for (UInt32 i = 0; i < db.NumFiles; i++) { - size_t offset = 0; - size_t outSizeProcessed = 0; - size_t len; + usz offset = 0; + usz outSizeProcessed = 0; + usz len; unsigned isDir = SzArEx_IsDir(&db, i); len = SzArEx_GetFileNameUtf16(&db, i, nullptr); @@ -397,7 +397,7 @@ bool update_manager::handle_rpcs3(const QByteArray& data) SzArEx_GetFileNameUtf16(&db, i, temp_u16); memset(temp_u8, 0, sizeof(temp_u8)); // Simplistic conversion to UTF-8 - for (size_t index = 0; index < len; index++) + for (usz index = 0; index < len; index++) { if (temp_u16[index] > 0xFF) { @@ -420,7 +420,7 @@ bool update_manager::handle_rpcs3(const QByteArray& data) break; } - if (const size_t pos = name.find_last_of('/'); pos != umax) + if (const usz pos = name.find_last_of('/'); pos != umax) { update_log.trace("Creating path: %s", name.substr(0, pos)); fs::create_path(name.substr(0, pos)); diff --git a/rpcs3/util/asm.hpp b/rpcs3/util/asm.hpp index c3f47ec57e..0d8c24bb3a 100644 --- a/rpcs3/util/asm.hpp +++ b/rpcs3/util/asm.hpp @@ -286,7 +286,7 @@ namespace utils } // Synchronization helper (cache-friendly busy waiting) - inline void busy_wait(std::size_t cycles = 3000) + inline void busy_wait(usz cycles = 3000) { const u64 start = __rdtsc(); do _mm_pause(); diff --git a/rpcs3/util/atomic.cpp b/rpcs3/util/atomic.cpp index 38ce30040e..df69964f0e 100644 --- a/rpcs3/util/atomic.cpp +++ b/rpcs3/util/atomic.cpp @@ -22,7 +22,7 @@ #include "endian.hpp" // Total number of entries. -static constexpr std::size_t s_hashtable_size = 1u << 17; +static constexpr usz s_hashtable_size = 1u << 17; // Reference counter combined with shifted pointer (which is assumed to be 47 bit) static constexpr uptr s_ref_mask = (1u << 17) - 1; diff --git a/rpcs3/util/atomic.hpp b/rpcs3/util/atomic.hpp index 00d0cccfcf..68a782b2d8 100644 --- a/rpcs3/util/atomic.hpp +++ b/rpcs3/util/atomic.hpp @@ -265,7 +265,7 @@ namespace atomic_wait struct atomic_wait_engine { private: - template + template friend class atomic_t; template @@ -304,7 +304,7 @@ void atomic_wait::list::wait(atomic_wait_timeout timeout) } // Helper class, provides access to compiler-specific atomic intrinsics -template +template struct atomic_storage { /* First part: Non-MSVC intrinsics */ @@ -1036,7 +1036,7 @@ struct atomic_storage : atomic_storage }; // Atomic type with lock-free and standard layout guarantees (and appropriate limitations) -template +template class atomic_t { protected: @@ -1058,7 +1058,7 @@ protected: alignas(Align) type m_data; public: - static constexpr std::size_t align = Align; + static constexpr usz align = Align; atomic_t() noexcept = default; @@ -1631,13 +1631,13 @@ public: } }; -template +template class atomic_t : private atomic_t { using base = atomic_t; public: - static constexpr std::size_t align = Align; + static constexpr usz align = Align; using simple_type = bool; @@ -1723,6 +1723,6 @@ public: namespace atomic_wait { - template + template inline __m128i default_mask> = _mm_cvtsi32_si128(1); } diff --git a/rpcs3/util/endian.hpp b/rpcs3/util/endian.hpp index e250a20fd8..f75ab81166 100644 --- a/rpcs3/util/endian.hpp +++ b/rpcs3/util/endian.hpp @@ -4,7 +4,7 @@ namespace stx { - template + template struct se_storage { struct type8 @@ -86,7 +86,7 @@ namespace stx } }; - template + template constexpr typename se_storage::type se_storage::swap(const type& src) noexcept { // Try to keep u16/u32/u64 optimizations at the cost of more bitcasts @@ -112,7 +112,7 @@ namespace stx type64 dst{}; // Swap u64 blocks - for (std::size_t i = 0; i < sizeof(T) / 8; i++) + for (usz i = 0; i < sizeof(T) / 8; i++) { dst.data[i] = se_storage::swap(tmp.data[sizeof(T) / 8 - 1 - i]); } @@ -124,7 +124,7 @@ namespace stx type dst{}; // Swap by moving every byte - for (std::size_t i = 0; i < sizeof(T); i++) + for (usz i = 0; i < sizeof(T); i++) { dst.data[i] = src.data[sizeof(T) - 1 - i]; } @@ -134,7 +134,7 @@ namespace stx } // Endianness support template - template + template class alignas(Align) se_t { using type = typename std::remove_cv::type; @@ -246,7 +246,7 @@ private: return std::bit_cast(static_cast>(rhs)); } - template + template static constexpr To right_arg_cast(const se_t& rhs) noexcept { if constexpr ((std::is_integral_v || std::is_enum_v) && std::is_convertible_v && sizeof(R) == sizeof(T)) diff --git a/rpcs3/util/logs.cpp b/rpcs3/util/logs.cpp index ca42401aa3..1c2a53063f 100644 --- a/rpcs3/util/logs.cpp +++ b/rpcs3/util/logs.cpp @@ -85,7 +85,7 @@ namespace logs virtual ~file_writer(); // Append raw data - void log(const char* text, std::size_t size); + void log(const char* text, usz size); }; struct file_listener final : file_writer, public listener @@ -326,7 +326,7 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, ...) co static constexpr fmt_type_info empty_sup{}; - std::size_t args_count = 0; + usz args_count = 0; for (auto v = sup; v && v->fmt_string; v++) args_count++; @@ -538,7 +538,7 @@ bool logs::file_writer::flush(u64 bufv) return false; } -void logs::file_writer::log(const char* text, std::size_t size) +void logs::file_writer::log(const char* text, usz size) { if (!m_fptr) { diff --git a/rpcs3/util/logs.hpp b/rpcs3/util/logs.hpp index e62f792fac..cb77fea460 100644 --- a/rpcs3/util/logs.hpp +++ b/rpcs3/util/logs.hpp @@ -87,7 +87,7 @@ namespace logs #define GEN_LOG_METHOD(_sev)\ const message msg_##_sev{this, level::_sev};\ - template \ + template \ void _sev(const CharT(&fmt)[N], const Args&... args)\ {\ if (level::_sev <= enabled.observe()) [[unlikely]]\ diff --git a/rpcs3/util/shared_ptr.hpp b/rpcs3/util/shared_ptr.hpp index 4cbc376aed..dec6a85b88 100644 --- a/rpcs3/util/shared_ptr.hpp +++ b/rpcs3/util/shared_ptr.hpp @@ -72,15 +72,15 @@ namespace stx atomic_t destroy{}; // Reference counter - atomic_t refs{1}; + atomic_t refs{1}; }; - template + template struct align_filler { }; - template + template struct align_filler Size)>> { char dummy[Align - Size]; @@ -104,10 +104,10 @@ namespace stx }; template - class alignas(T) shared_data final : align_filler + class alignas(T) shared_data final : align_filler { public: - std::size_t m_count; + usz m_count; shared_counter m_ctr; @@ -301,13 +301,13 @@ namespace stx } template - static std::enable_if_t, single_ptr> make_single(std::size_t count) noexcept + static std::enable_if_t, single_ptr> make_single(usz count) noexcept { static_assert(sizeof(shared_data) - offsetof(shared_data, m_ctr) == sizeof(shared_counter)); using etype = std::remove_extent_t; - const std::size_t size = sizeof(shared_data) + count * sizeof(etype); + const usz size = sizeof(shared_data) + count * sizeof(etype); std::byte* bytes = nullptr; @@ -535,7 +535,7 @@ namespace stx } } - std::size_t use_count() const noexcept + usz use_count() const noexcept { if (m_ptr) { @@ -588,7 +588,7 @@ namespace stx } template - static std::enable_if_t, shared_ptr> make_shared(std::size_t count) noexcept + static std::enable_if_t, shared_ptr> make_shared(usz count) noexcept { return make_single(count); } diff --git a/rpcs3/util/to_endian.hpp b/rpcs3/util/to_endian.hpp index 28a8d3e397..710c755a30 100644 --- a/rpcs3/util/to_endian.hpp +++ b/rpcs3/util/to_endian.hpp @@ -64,7 +64,7 @@ struct to_se using type = typename to_se::type[]; }; -template +template struct to_se { // Move array qualifier diff --git a/rpcs3/util/types.hpp b/rpcs3/util/types.hpp index 74efcd0174..93ceb1c65b 100644 --- a/rpcs3/util/types.hpp +++ b/rpcs3/util/types.hpp @@ -96,6 +96,7 @@ using u8 = std::uint8_t; using u16 = std::uint16_t; using u32 = std::uint32_t; using u64 = std::uint64_t; +using usz = std::size_t; using s8 = std::int8_t; using s16 = std::int16_t; @@ -150,7 +151,7 @@ namespace std #endif // Get integral type from type size -template +template struct get_int_impl { }; @@ -183,10 +184,10 @@ struct get_int_impl using stype = s64; }; -template +template using get_uint_t = typename get_int_impl::utype; -template +template using get_sint_t = typename get_int_impl::stype; template @@ -210,29 +211,29 @@ namespace fmt const fmt_type_info* get_type_info(); } -template +template class atomic_t; namespace stx { - template + template class se_t; } using stx::se_t; // se_t<> with native endianness -template +template using nse_t = se_t; -template +template using be_t = se_t; -template +template using le_t = se_t; -template +template using atomic_be_t = atomic_t, Align>; -template +template using atomic_le_t = atomic_t, Align>; // Extract T::simple_type if available, remove cv qualifiers @@ -625,7 +626,7 @@ inline u32 offset32(T T2::*const mptr) #ifdef _MSC_VER return std::bit_cast(mptr); #elif __GNUG__ - return std::bit_cast(mptr); + return std::bit_cast(mptr); #else static_assert(sizeof(mptr) == 0, "Unsupported pointer-to-member size"); #endif @@ -643,7 +644,7 @@ struct offset32_array } }; -template +template struct offset32_array> { template @@ -689,7 +690,7 @@ constexpr u32 to_u8(char c) } // Convert 1-2-byte string to u16 value like reinterpret_cast does -constexpr u16 operator""_u16(const char* s, std::size_t /*length*/) +constexpr u16 operator""_u16(const char* s, usz /*length*/) { if constexpr (std::endian::little == std::endian::native) { @@ -702,7 +703,7 @@ constexpr u16 operator""_u16(const char* s, std::size_t /*length*/) } // Convert 3-4-byte string to u32 value like reinterpret_cast does -constexpr u32 operator""_u32(const char* s, std::size_t /*length*/) +constexpr u32 operator""_u32(const char* s, usz /*length*/) { if constexpr (std::endian::little == std::endian::native) { @@ -715,7 +716,7 @@ constexpr u32 operator""_u32(const char* s, std::size_t /*length*/) } // Convert 5-6-byte string to u64 value like reinterpret_cast does -constexpr u64 operator""_u48(const char* s, std::size_t /*length*/) +constexpr u64 operator""_u48(const char* s, usz /*length*/) { if constexpr (std::endian::little == std::endian::native) { @@ -728,7 +729,7 @@ constexpr u64 operator""_u48(const char* s, std::size_t /*length*/) } // Convert 7-8-byte string to u64 value like reinterpret_cast does -constexpr u64 operator""_u64(const char* s, std::size_t /*length*/) +constexpr u64 operator""_u64(const char* s, usz /*length*/) { if constexpr (std::endian::little == std::endian::native) { @@ -877,7 +878,7 @@ template (std::declval().s } // Returns u32 size for an array -template +template [[nodiscard]] constexpr u32 size32(const T (&)[Size]) { static_assert(Size < UINT32_MAX, "Array is too big for 32-bit"); @@ -885,20 +886,20 @@ template } // Simplified hash algorithm for pointers. May be used in std::unordered_(map|set). -template +template struct pointer_hash { - std::size_t operator()(T* ptr) const + usz operator()(T* ptr) const { return reinterpret_cast(ptr) / Align; } }; -template +template struct value_hash { - std::size_t operator()(T value) const + usz operator()(T value) const { - return static_cast(value) >> Shift; + return static_cast(value) >> Shift; } }; diff --git a/rpcs3/util/v128.hpp b/rpcs3/util/v128.hpp index 6c7d5824a9..db099e1af0 100644 --- a/rpcs3/util/v128.hpp +++ b/rpcs3/util/v128.hpp @@ -9,26 +9,26 @@ union alignas(16) v128 uchar _bytes[16]; char _chars[16]; - template + template struct masked_array_t // array type accessed as (index ^ M) { char m_data[16]; public: - T& operator[](std::size_t index) + T& operator[](usz index) { return reinterpret_cast(m_data)[index ^ M]; } - const T& operator[](std::size_t index) const + const T& operator[](usz index) const { return reinterpret_cast(m_data)[index ^ M]; } }; - template + template using normal_array_t = masked_array_t; - template + template using reversed_array_t = masked_array_t; normal_array_t _u64; @@ -218,7 +218,7 @@ union alignas(16) v128 } // Unaligned load with optional index offset - static v128 loadu(const void* ptr, std::size_t index = 0) + static v128 loadu(const void* ptr, usz index = 0) { v128 ret; std::memcpy(&ret, static_cast(ptr) + index * sizeof(v128), sizeof(v128)); @@ -226,7 +226,7 @@ union alignas(16) v128 } // Unaligned store with optional index offset - static void storeu(v128 value, void* ptr, std::size_t index = 0) + static void storeu(v128 value, void* ptr, usz index = 0) { std::memcpy(static_cast(ptr) + index * sizeof(v128), &value, sizeof(v128)); } @@ -368,7 +368,7 @@ union alignas(16) v128 } }; -template +template struct offset32_array> { template diff --git a/rpcs3/util/vm.hpp b/rpcs3/util/vm.hpp index 8d79c9c568..c7ee241618 100644 --- a/rpcs3/util/vm.hpp +++ b/rpcs3/util/vm.hpp @@ -18,29 +18,29 @@ namespace utils * Reserve `size` bytes of virtual memory and returns it. * The memory should be commited before usage. */ - void* memory_reserve(std::size_t size, void* use_addr = nullptr); + void* memory_reserve(usz size, void* use_addr = nullptr); /** * Commit `size` bytes of virtual memory starting at pointer. * That is, bake reserved memory with physical memory. * pointer should belong to a range of reserved memory. */ - void memory_commit(void* pointer, std::size_t size, protection prot = protection::rw); + void memory_commit(void* pointer, usz size, protection prot = protection::rw); // Decommit all memory committed via commit_page_memory. - void memory_decommit(void* pointer, std::size_t size); + void memory_decommit(void* pointer, usz size); // Decommit all memory and commit it again. - void memory_reset(void* pointer, std::size_t size, protection prot = protection::rw); + void memory_reset(void* pointer, usz size, protection prot = protection::rw); // Free memory after reserved by memory_reserve, should specify original size - void memory_release(void* pointer, std::size_t size); + void memory_release(void* pointer, usz size); // Set memory protection - void memory_protect(void* pointer, std::size_t size, protection prot); + void memory_protect(void* pointer, usz size, protection prot); // Lock pages in memory - bool memory_lock(void* pointer, std::size_t size); + bool memory_lock(void* pointer, usz size); // Shared memory handle class shm diff --git a/rpcs3/util/vm_native.cpp b/rpcs3/util/vm_native.cpp index 5b9992d554..47b132e73a 100644 --- a/rpcs3/util/vm_native.cpp +++ b/rpcs3/util/vm_native.cpp @@ -65,7 +65,7 @@ namespace utils return _prot; } - void* memory_reserve(std::size_t size, void* use_addr) + void* memory_reserve(usz size, void* use_addr) { #ifdef _WIN32 return ::VirtualAlloc(use_addr, size, MEM_RESERVE, PAGE_NOACCESS); @@ -119,7 +119,7 @@ namespace utils #endif } - void memory_commit(void* pointer, std::size_t size, protection prot) + void memory_commit(void* pointer, usz size, protection prot) { #ifdef _WIN32 ensure(::VirtualAlloc(pointer, size, MEM_COMMIT, +prot)); @@ -130,7 +130,7 @@ namespace utils #endif } - void memory_decommit(void* pointer, std::size_t size) + void memory_decommit(void* pointer, usz size) { #ifdef _WIN32 ensure(::VirtualFree(pointer, size, MEM_DECOMMIT)); @@ -145,7 +145,7 @@ namespace utils #endif } - void memory_reset(void* pointer, std::size_t size, protection prot) + void memory_reset(void* pointer, usz size, protection prot) { #ifdef _WIN32 memory_decommit(pointer, size); @@ -167,7 +167,7 @@ namespace utils #endif } - void memory_release(void* pointer, std::size_t size) + void memory_release(void* pointer, usz size) { #ifdef _WIN32 ensure(::VirtualFree(pointer, 0, MEM_RELEASE)); @@ -176,7 +176,7 @@ namespace utils #endif } - void memory_protect(void* pointer, std::size_t size, protection prot) + void memory_protect(void* pointer, usz size, protection prot) { #ifdef _WIN32 for (u64 addr = reinterpret_cast(pointer), end = addr + size; addr < end;) @@ -199,7 +199,7 @@ namespace utils #endif } - bool memory_lock(void* pointer, std::size_t size) + bool memory_lock(void* pointer, usz size) { #ifdef _WIN32 return ::VirtualLock(pointer, size);