1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

Add usz alias for std::size_t

This commit is contained in:
Nekotekina 2020-12-18 10:39:54 +03:00
parent 360c4d1554
commit fb29933d3d
173 changed files with 718 additions and 717 deletions

View File

@ -176,7 +176,7 @@ public:
}; };
u_int miblen = std::size(mib); u_int miblen = std::size(mib);
struct kinfo_proc info; struct kinfo_proc info;
size_t size = sizeof(info); usz size = sizeof(info);
if (sysctl(mib, miblen, &info, &size, NULL, 0)) if (sysctl(mib, miblen, &info, &size, NULL, 0))
{ {
return 0; return 0;
@ -194,7 +194,7 @@ public:
u_int miblen = std::size(mib); u_int miblen = std::size(mib);
// get number of structs // get number of structs
size_t size; usz size;
if (sysctl(mib, miblen, NULL, &size, NULL, 0)) if (sysctl(mib, miblen, NULL, &size, NULL, 0))
{ {
return 0; return 0;

View File

@ -20,7 +20,7 @@ using namespace std::literals::string_literals;
static std::unique_ptr<wchar_t[]> to_wchar(const std::string& source) static std::unique_ptr<wchar_t[]> to_wchar(const std::string& source)
{ {
// String size + null terminator // String size + null terminator
const std::size_t buf_size = source.size() + 1; const usz buf_size = source.size() + 1;
// Safe size // Safe size
const int size = narrow<int>(buf_size); const int size = narrow<int>(buf_size);
@ -51,7 +51,7 @@ static std::unique_ptr<wchar_t[]> to_wchar(const std::string& source)
static void to_utf8(std::string& out, const wchar_t* source) static void to_utf8(std::string& out, const wchar_t* source)
{ {
// String size // 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) // Safe buffer size for max possible output length (including null terminator)
const int buf_size = narrow<int>(length * 3 + 1); const int buf_size = narrow<int>(length * 3 + 1);
@ -181,7 +181,7 @@ static std::string path_append(std::string_view path, std::string_view more)
{ {
std::string result; 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); path.remove_suffix(path.length() - src_slash_pos - 1);
result = path; result = path;
@ -189,7 +189,7 @@ static std::string path_append(std::string_view path, std::string_view more)
result.push_back('/'); 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); more.remove_prefix(dst_slash_pos);
result.append(more); 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 // Keep cutting path from right until it's short enough
while (str.size() > 256) 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); str.resize(x - 1);
else else
break; break;
@ -1240,7 +1240,7 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
#endif #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 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 class windows_dir final : public dir_base
{ {
std::vector<dir_entry> m_entries; std::vector<dir_entry> m_entries;
std::size_t m_pos = 0; usz m_pos = 0;
void add_entry(const WIN32_FIND_DATAW& found) 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()); 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); std::memcpy(&real[to], &path[from], count);
from += count, to += 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()) if (i < path.size())
{ {
@ -1648,7 +1648,7 @@ std::string fs::escape_path(std::string_view path)
case '.': case '.':
{ {
bool remove_element = true; bool remove_element = true;
std::size_t k = 1; usz k = 1;
for (; k + i != path.size(); k++) for (; k + i != path.size(); k++)
{ {

View File

@ -73,7 +73,7 @@ namespace fs
struct iovec_clone struct iovec_clone
{ {
const void* iov_base; const void* iov_base;
std::size_t iov_len; usz iov_len;
}; };
// File handle base // File handle base
@ -200,7 +200,7 @@ namespace fs
explicit file(const std::string& path, bs_t<open_mode> mode = ::fs::read); explicit file(const std::string& path, bs_t<open_mode> mode = ::fs::read);
// Open memory for 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) // Open file with specified args (forward to constructor)
template <typename... Args> template <typename... Args>
@ -370,7 +370,7 @@ namespace fs
// Read std::basic_string // Read std::basic_string
template <typename T> template <typename T>
std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, bool> read(std::basic_string<T>& str, std::size_t size, std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, bool> read(std::basic_string<T>& str, usz size,
const char* file = __builtin_FILE(), const char* file = __builtin_FILE(),
const char* func = __builtin_FUNCTION(), const char* func = __builtin_FUNCTION(),
u32 line = __builtin_LINE(), u32 line = __builtin_LINE(),
@ -405,7 +405,7 @@ namespace fs
// Read POD std::vector // Read POD std::vector
template <typename T> template <typename T>
std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, bool> read(std::vector<T>& vec, std::size_t size, std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, bool> read(std::vector<T>& vec, usz size,
const char* file = __builtin_FILE(), const char* file = __builtin_FILE(),
const char* func = __builtin_FUNCTION(), const char* func = __builtin_FUNCTION(),
u32 line = __builtin_LINE(), u32 line = __builtin_LINE(),

View File

@ -36,7 +36,7 @@ static atomic_t<u64> s_code_pos{0}, s_data_pos{0};
static std::vector<u8> s_code_init, s_data_init; static std::vector<u8> s_code_init, s_data_init;
template <atomic_t<u64>& Ctr, uint Off, utils::protection Prot> template <atomic_t<u64>& 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 // Select subrange
u8* pointer = get_jit_memory() + Off; 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 asmjit::Error jit_runtime::_add(void** dst, asmjit::CodeHolder* code) noexcept
{ {
std::size_t codeSize = code->getCodeSize(); usz codeSize = code->getCodeSize();
if (!codeSize) [[unlikely]] if (!codeSize) [[unlikely]]
{ {
*dst = nullptr; *dst = nullptr;
@ -126,7 +126,7 @@ asmjit::Error jit_runtime::_add(void** dst, asmjit::CodeHolder* code) noexcept
return asmjit::kErrorNoVirtualMemory; return asmjit::kErrorNoVirtualMemory;
} }
std::size_t relocSize = code->relocate(p); usz relocSize = code->relocate(p);
if (!relocSize) [[unlikely]] if (!relocSize) [[unlikely]]
{ {
*dst = nullptr; *dst = nullptr;
@ -144,7 +144,7 @@ asmjit::Error jit_runtime::_release(void* ptr) noexcept
return asmjit::kErrorOk; 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) if (exec)
{ {
@ -216,7 +216,7 @@ asmjit::Runtime& asmjit::get_global_runtime()
asmjit::Error _add(void** dst, asmjit::CodeHolder* code) noexcept override asmjit::Error _add(void** dst, asmjit::CodeHolder* code) noexcept override
{ {
std::size_t codeSize = code->getCodeSize(); usz codeSize = code->getCodeSize();
if (!codeSize) [[unlikely]] if (!codeSize) [[unlikely]]
{ {
*dst = nullptr; *dst = nullptr;
@ -230,7 +230,7 @@ asmjit::Runtime& asmjit::get_global_runtime()
return asmjit::kErrorNoVirtualMemory; return asmjit::kErrorNoVirtualMemory;
} }
std::size_t relocSize = code->relocate(p); usz relocSize = code->relocate(p);
if (!relocSize) [[unlikely]] if (!relocSize) [[unlikely]]
{ {
*dst = nullptr; *dst = nullptr;
@ -389,7 +389,7 @@ struct MemoryManager1 : llvm::RTDyldMemoryManager
return false; 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; return false;
} }
void registerEHFrames(u8* addr, u64 load_addr, std::size_t size) override void registerEHFrames(u8* addr, u64 load_addr, usz size) override
{ {
} }

View File

@ -41,7 +41,7 @@ struct jit_runtime final : asmjit::HostRuntime
asmjit::Error _release(void* p) noexcept override; asmjit::Error _release(void* p) noexcept override;
// Allocate memory // 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 // Should be called at least once after global initialization
static void initialize(); static void initialize();

View File

@ -79,14 +79,14 @@ void fmt_class_string<fmt::base57>::format(std::string& out, u64 arg)
static constexpr u8 s_tail[8] = {0, 2, 3, 5, 6, 7, 9, 10}; static constexpr u8 s_tail[8] = {0, 2, 3, 5, 6, 7, 9, 10};
// Get full output size // 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); out.resize(out.size() + out_size);
const auto ptr = &out.front() + (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 // 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 // Load up to 8 bytes
be_t<u64> be_value; be_t<u64> be_value;
@ -321,7 +321,7 @@ struct fmt::cfmt_src
const fmt_type_info* sup; const fmt_type_info* sup;
const u64* args; const u64* args;
bool test(std::size_t index) const bool test(usz index) const
{ {
if (!sup[index].fmt_string) if (!sup[index].fmt_string)
{ {
@ -332,26 +332,26 @@ struct fmt::cfmt_src
} }
template <typename T> template <typename T>
T get(std::size_t index) const T get(usz index) const
{ {
return *reinterpret_cast<const T*>(reinterpret_cast<const u8*>(args + index)); return *reinterpret_cast<const T*>(reinterpret_cast<const u8*>(args + index));
} }
void skip(std::size_t extra) void skip(usz extra)
{ {
sup += extra + 1; sup += extra + 1;
args += 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]); sup[extra].fmt_string(out, args[extra]);
return out.size() - start; return out.size() - start;
} }
// Returns type size (0 if unknown, pointer, unsigned, assumed max) // 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 // Hack: use known function pointers to determine type
#define TYPE(type) \ #define TYPE(type) \
@ -369,14 +369,14 @@ struct fmt::cfmt_src
return 0; return 0;
} }
static constexpr std::size_t size_char = 1; static constexpr usz size_char = 1;
static constexpr std::size_t size_short = 2; static constexpr usz size_short = 2;
static constexpr std::size_t size_int = 0; static constexpr usz size_int = 0;
static constexpr std::size_t size_long = sizeof(ulong); static constexpr usz size_long = sizeof(ulong);
static constexpr std::size_t size_llong = sizeof(ullong); static constexpr usz size_llong = sizeof(ullong);
static constexpr std::size_t size_size = sizeof(std::size_t); static constexpr usz size_size = sizeof(usz);
static constexpr std::size_t size_max = sizeof(std::uintmax_t); static constexpr usz size_max = sizeof(std::uintmax_t);
static constexpr std::size_t size_diff = sizeof(std::ptrdiff_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 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<std::string> fmt::split(const std::string& source, std::initializer_
{ {
std::vector<std::string> result; std::vector<std::string> 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) for (auto& separator : separators)
{ {
@ -441,7 +441,7 @@ std::vector<std::string> fmt::split(const std::string& source, std::initializer_
std::string fmt::trim(const std::string& source, const std::string& values) 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) if (begin == source.npos)
return {}; 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) 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) 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 '?': break;
case '*': 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))) if (match(source.substr(test_source_position), mask.substr(mask_position + 1)))
{ {

View File

@ -6,7 +6,7 @@
namespace fmt namespace fmt
{ {
template <typename CharT, std::size_t N, typename... Args> template <typename CharT, usz N, typename... Args>
static std::string format(const CharT(&)[N], const Args&...); static std::string format(const CharT(&)[N], const Args&...);
} }
@ -97,7 +97,7 @@ struct fmt_unveil<T*, void>
} }
}; };
template <typename T, std::size_t N> template <typename T, usz N>
struct fmt_unveil<T[N], void> struct fmt_unveil<T[N], void>
{ {
using type = std::add_const_t<T>*; using type = std::add_const_t<T>*;
@ -119,7 +119,7 @@ struct fmt_unveil<b8, void>
} }
}; };
template <typename T, bool Se, std::size_t Align> template <typename T, bool Se, usz Align>
struct fmt_unveil<se_t<T, Se, Align>, void> struct fmt_unveil<se_t<T, Se, Align>, void>
{ {
using type = typename fmt_unveil<T>::type; using type = typename fmt_unveil<T>::type;
@ -251,7 +251,7 @@ namespace fmt
struct base57 struct base57
{ {
const uchar* data; const uchar* data;
std::size_t size; usz size;
template <typename T> template <typename T>
base57(const T& arg) 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) : data(data)
, size(size) , size(size)
{ {
@ -283,7 +283,7 @@ namespace fmt
void raw_append(std::string& out, const char*, const fmt_type_info*, const u64*) noexcept; void raw_append(std::string& out, const char*, const fmt_type_info*, const u64*) noexcept;
// Formatting function // Formatting function
template <typename CharT, std::size_t N, typename... Args> template <typename CharT, usz N, typename... Args>
SAFE_BUFFERS FORCE_INLINE void append(std::string& out, const CharT(&fmt)[N], const Args&... args) 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<fmt_unveil_t<Args>>()...}; static constexpr fmt_type_info type_list[sizeof...(Args) + 1]{fmt_type_info::make<fmt_unveil_t<Args>>()...};
@ -291,7 +291,7 @@ namespace fmt
} }
// Formatting function // Formatting function
template <typename CharT, std::size_t N, typename... Args> template <typename CharT, usz N, typename... Args>
SAFE_BUFFERS FORCE_INLINE std::string format(const CharT(&fmt)[N], const Args&... args) SAFE_BUFFERS FORCE_INLINE std::string format(const CharT(&fmt)[N], const Args&... args)
{ {
std::string result; 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*); [[noreturn]] void raw_throw_exception(const src_loc&, const char*, const fmt_type_info*, const u64*);
// Throw exception with formatting // Throw exception with formatting
template <typename CharT, std::size_t N, typename... Args> template <typename CharT, usz N, typename... Args>
struct throw_exception struct throw_exception
{ {
[[noreturn]] SAFE_BUFFERS FORCE_INLINE throw_exception(const CharT(&fmt)[N], const Args&... args, [[noreturn]] SAFE_BUFFERS FORCE_INLINE throw_exception(const CharT(&fmt)[N], const Args&... args,
@ -317,6 +317,6 @@ namespace fmt
} }
}; };
template <typename CharT, std::size_t N, typename... Args> template <typename CharT, usz N, typename... Args>
throw_exception(const CharT(&)[N], const Args&...) -> throw_exception<CharT, N, Args...>; throw_exception(const CharT(&)[N], const Args&...) -> throw_exception<CharT, N, Args...>;
} }

View File

@ -17,7 +17,7 @@ std::string utf8_path_to_ansi_path(const std::string& src);
template <typename D, typename T> template <typename D, typename T>
inline void strcpy_trunc(D& dst, const T& src) 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::memcpy(std::data(dst), std::data(src), count);
std::memset(std::data(dst) + count, 0, std::size(dst) - 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_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); std::string replace_all(const std::string& src, const std::string& from, const std::string& to);
template <size_t list_size> template <usz list_size>
std::string replace_all(std::string src, const std::pair<std::string, std::string> (&list)[list_size]) std::string replace_all(std::string src, const std::pair<std::string, std::string> (&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) if (src.length() - pos < comp_length)
continue; continue;
@ -51,14 +51,14 @@ namespace fmt
return src; return src;
} }
template <size_t list_size> template <usz list_size>
std::string replace_all(std::string src, const std::pair<std::string, std::function<std::string()>> (&list)[list_size]) std::string replace_all(std::string src, const std::pair<std::string, std::function<std::string()>> (&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) if (src.length() - pos < comp_length)
continue; continue;

View File

@ -118,7 +118,7 @@ bool IsDebuggerPresent()
}; };
u_int miblen = std::size(mib); u_int miblen = std::size(mib);
struct kinfo_proc info; struct kinfo_proc info;
size_t size = sizeof(info); usz size = sizeof(info);
if (sysctl(mib, miblen, &info, &size, NULL, 0)) if (sysctl(mib, miblen, &info, &size, NULL, 0))
{ {
@ -259,7 +259,7 @@ enum x64_op_t : u32
X64OP_SBB, // lock sbb [mem], ... 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 // simple analysis of x64 code allows to reinterpret MOV or other instructions in any desired way
out_length = 0; 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}; 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); 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 switch (*code >> 6) // check Mod
{ {
@ -976,7 +976,7 @@ static const int reg_table[] =
#define RDI(c) (*X64REG((c), 7)) #define RDI(c) (*X64REG((c), 7))
#define RIP(c) (*X64REG((c), 16)) #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) // get x64 reg value (for store operations)
if (reg - X64R_RAX < 16) 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; 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) // save x64 reg value (for load operations)
if (reg - X64R_RAX < 16) 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; 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) 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; 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) 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_op_t op;
x64_reg_t reg; x64_reg_t reg;
size_t d_size; usz d_size;
size_t i_size; usz i_size;
// decode single x64 instruction that causes memory access // decode single x64 instruction that causes memory access
decode_x64_reg_op(code, op, reg, d_size, i_size); 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 // 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) if (0x1'0000'0000ull - addr < a_size)
{ {
@ -1954,14 +1954,14 @@ void thread_base::set_name(std::string name)
#endif #endif
#if defined(__APPLE__) #if defined(__APPLE__)
name.resize(std::min<std::size_t>(15, name.size())); name.resize(std::min<usz>(15, name.size()));
pthread_setname_np(name.c_str()); pthread_setname_np(name.c_str());
#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) #elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
pthread_set_name_np(pthread_self(), name.c_str()); pthread_set_name_np(pthread_self(), name.c_str());
#elif defined(__NetBSD__) #elif defined(__NetBSD__)
pthread_setname_np(pthread_self(), "%s", name.data()); pthread_setname_np(pthread_self(), "%s", name.data());
#elif !defined(_WIN32) #elif !defined(_WIN32)
name.resize(std::min<std::size_t>(15, name.size())); name.resize(std::min<usz>(15, name.size()));
pthread_setname_np(pthread_self(), name.c_str()); pthread_setname_np(pthread_self(), name.c_str());
#endif #endif
} }
@ -2791,17 +2791,17 @@ u64 thread_ctrl::get_thread_affinity_mask()
#endif #endif
} }
std::pair<void*, std::size_t> thread_ctrl::get_thread_stack() std::pair<void*, usz> thread_ctrl::get_thread_stack()
{ {
#ifdef _WIN32 #ifdef _WIN32
ULONG_PTR _min = 0; ULONG_PTR _min = 0;
ULONG_PTR _max = 0; ULONG_PTR _max = 0;
GetCurrentThreadStackLimits(&_min, &_max); GetCurrentThreadStackLimits(&_min, &_max);
const std::size_t ssize = _max - _min; const usz ssize = _max - _min;
const auto saddr = reinterpret_cast<void*>(_min); const auto saddr = reinterpret_cast<void*>(_min);
#else #else
void* saddr = 0; void* saddr = 0;
std::size_t ssize = 0; usz ssize = 0;
pthread_attr_t attr; pthread_attr_t attr;
#ifdef __linux__ #ifdef __linux__
pthread_getattr_np(pthread_self(), &attr); pthread_getattr_np(pthread_self(), &attr);

View File

@ -262,7 +262,7 @@ public:
static u64 get_thread_affinity_mask(); static u64 get_thread_affinity_mask();
// Get current thread stack addr and size // Get current thread stack addr and size
static std::pair<void*, std::size_t> get_thread_stack(); static std::pair<void*, usz> get_thread_stack();
private: private:
// Miscellaneous // Miscellaneous

View File

@ -282,7 +282,7 @@ namespace utils
public: public:
// Wrapped functions // 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 void clear() { data.clear(); }
inline size_type size() const { return data.size(); } inline size_type size() const { return data.size(); }
inline bool empty() const { return data.empty(); } 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 // Will fail if ranges within the vector overlap our touch each-other
bool check_consistency() const 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]; const auto &r1 = data[i];
if (!r1.valid()) if (!r1.valid())
@ -466,7 +466,7 @@ namespace utils
continue; continue;
} }
for (size_t j = i + 1; j < _size; ++j) for (usz j = i + 1; j < _size; ++j)
{ {
const auto &r2 = data[j]; const auto &r2 = data[j];
if (!r2.valid()) if (!r2.valid())
@ -582,15 +582,15 @@ namespace utils
namespace std 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 <> template <>
struct hash<utils::address_range> struct hash<utils::address_range>
{ {
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 // we can guarantee a unique hash since our type is 64 bits and usz as well
return (size_t{ k.start } << 32) | size_t{ k.end }; return (usz{ k.start } << 32) | usz{ k.end };
} }
}; };
} }

View File

@ -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"); 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<false>(name, dst, 0, 0); return apply_patch<false>(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<true>(name, dst, filesz, ls_addr); return apply_patch<true>(name, dst, filesz, ls_addr);
} }
template <bool check_local_storage> template <bool check_local_storage>
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) 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 <bool check_local_storage> template <bool check_local_storage>
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()) if (m_map.find(name) == m_map.cend())
{ {
return 0; return 0;
} }
size_t applied_total = 0; usz applied_total = 0;
const auto& container = m_map.at(name); const auto& container = m_map.at(name);
const auto serial = Emu.GetTitleID(); const auto serial = Emu.GetTitleID();
const auto app_version = Emu.GetAppVersion(); 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); m_applied_groups.insert(patch.patch_group);
} }
const size_t applied = apply_modification<check_local_storage>(patch, dst, filesz, ls_addr); const usz applied = apply_modification<check_local_storage>(patch, dst, filesz, ls_addr);
applied_total += applied; applied_total += applied;
if (patch.is_legacy) 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()); 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) 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; 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; patch_engine::patch_map existing_patches;

View File

@ -117,7 +117,7 @@ public:
static bool save_patches(const patch_map& patches, const std::string& path, std::stringstream* log_messages = nullptr); static bool save_patches(const patch_map& patches, const std::string& path, std::stringstream* log_messages = nullptr);
// Create or append patches to a file // 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 // Remove a patch from a file
static bool remove_patch(const patch_info& info); static bool remove_patch(const patch_info& info);
@ -132,15 +132,15 @@ public:
void append_title_patches(const std::string& title_id); void append_title_patches(const std::string& title_id);
// Apply patch (returns the number of entries applied) // 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 // 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: private:
// Internal: Apply patch (returns the number of entries applied) // Internal: Apply patch (returns the number of entries applied)
template <bool check_local_storage> template <bool check_local_storage>
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 // Database
patch_map m_map; patch_map m_map;

View File

@ -48,8 +48,8 @@ private:
} }
public: public:
static constexpr std::size_t bitmax = sizeof(T) * 8; static constexpr usz bitmax = sizeof(T) * 8;
static constexpr std::size_t bitsize = static_cast<under>(T::__bitset_enum_max); static constexpr usz bitsize = static_cast<under>(T::__bitset_enum_max);
static_assert(std::is_enum<T>::value, "bs_t<> error: invalid type (must be enum)"); static_assert(std::is_enum<T>::value, "bs_t<> error: invalid type (must be enum)");
static_assert(bitsize <= bitmax, "bs_t<> error: invalid __bitset_enum_max"); static_assert(bitsize <= bitmax, "bs_t<> error: invalid __bitset_enum_max");

View File

@ -6,7 +6,7 @@
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
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. 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. `src`: rvalue reference to argument provider.
*/ */
template<typename Dst, typename Char, typename Src> template<typename Dst, typename Char, typename Src>
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 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 args; // Number of extra args used
u8 type; // Integral type bytesize 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 auto write_decimal = [&](u64 value, s64 min_size)
{ {
const std::size_t start = out.size(); const usz start = out.size();
do do
{ {
@ -90,7 +90,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
while (0 < --min_size || value); while (0 < --min_size || value);
// Revert written characters // 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]); std::swap(out[i], out[j]);
} }
@ -285,7 +285,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
break; break;
} }
const std::size_t start = out.size(); const usz start = out.size();
out.push_back(src.template get<Char>(ctx.args)); out.push_back(src.template get<Char>(ctx.args));
if (1 < ctx.width) if (1 < ctx.width)
@ -307,8 +307,8 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
break; break;
} }
const std::size_t start = out.size(); const usz start = out.size();
const std::size_t size1 = src.fmt_string(out, ctx.args); const usz size1 = src.fmt_string(out, ctx.args);
if (ctx.dot && size1 > ctx.prec) 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); out.resize(start + ctx.prec);
} }
const std::size_t size2 = out.size() - start; const usz size2 = out.size() - start;
if (size2 < ctx.width) 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<u64>(ctx.args); const u64 val = src.template get<u64>(ctx.args);
const bool negative = ctx.type && static_cast<s64>(val) < 0; const bool negative = ctx.type && static_cast<s64>(val) < 0;
const std::size_t start = out.size(); const usz start = out.size();
if (!ctx.dot || ctx.prec) 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); 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) 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 // Trunc sign-extended signed types
const u64 val = src.template get<u64>(ctx.args) & mask; const u64 val = src.template get<u64>(ctx.args) & mask;
const std::size_t start = out.size(); const usz start = out.size();
if (ctx.alter) if (ctx.alter)
{ {
@ -435,7 +435,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
write_octal(val, ctx.prec); write_octal(val, ctx.prec);
} }
const std::size_t size2 = out.size() - start; const usz size2 = out.size() - start;
if (size2 < ctx.width) 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 // Trunc sign-extended signed types
const u64 val = src.template get<u64>(ctx.args) & mask; const u64 val = src.template get<u64>(ctx.args) & mask;
const std::size_t start = out.size(); const usz start = out.size();
if (ctx.alter) 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); 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) 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 // Trunc sign-extended signed types
const u64 val = src.template get<u64>(ctx.args) & mask; const u64 val = src.template get<u64>(ctx.args) & mask;
const std::size_t start = out.size(); const usz start = out.size();
if (!ctx.dot || ctx.prec) if (!ctx.dot || ctx.prec)
{ {
write_decimal(val, 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) 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<u64>(ctx.args); const u64 val = src.template get<u64>(ctx.args);
const std::size_t start = out.size(); const usz start = out.size();
write_hex(val, false, sizeof(void*) * 2); 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) 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<u64>(1) : 0; const u64 arg1 = ctx.args >= 1 ? src.template get<u64>(1) : 0;
const u64 arg2 = ctx.args >= 2 ? src.template get<u64>(2) : 0; const u64 arg2 = ctx.args >= 2 ? src.template get<u64>(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); out.resize(out.size() + _size);
std::snprintf(&out.front() + out.size() - _size, _size + 1, _fmt.c_str(), arg0, arg1, arg2); std::snprintf(&out.front() + out.size() - _size, _size + 1, _fmt.c_str(), arg0, arg1, arg2);

View File

@ -5,19 +5,19 @@
namespace rpcs3 namespace rpcs3
{ {
template<typename T> template<typename T>
static size_t hash_base(T value) static usz hash_base(T value)
{ {
return static_cast<size_t>(value); return static_cast<usz>(value);
} }
template<typename T, typename U> template<typename T, typename U>
static size_t hash_struct_base(const T& value) static usz hash_struct_base(const T& value)
{ {
// FNV 64-bit // FNV 64-bit
size_t result = 14695981039346656037ull; usz result = 14695981039346656037ull;
const U *bits = reinterpret_cast<const U*>(&value); const U *bits = reinterpret_cast<const U*>(&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 ^= bits[n];
result *= 1099511628211ull; result *= 1099511628211ull;
@ -27,7 +27,7 @@ namespace rpcs3
} }
template<typename T> template<typename T>
static size_t hash_struct(const T& value) static usz hash_struct(const T& value)
{ {
static constexpr auto block_sz = sizeof(T); static constexpr auto block_sz = sizeof(T);

View File

@ -8,7 +8,7 @@
//! //!
//! T is the type of elements. Currently, default constructor of T shall be constexpr. //! 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. //! N is initial element count, available without any memory allocation and only stored contiguously.
template <typename T, std::size_t N> template <typename T, usz N>
class lf_array class lf_array
{ {
// Data (default-initialized) // Data (default-initialized)
@ -28,7 +28,7 @@ public:
} }
} }
T& operator [](std::size_t index) T& operator [](usz index)
{ {
if (index < N) [[likely]] if (index < N) [[likely]]
{ {
@ -51,7 +51,7 @@ public:
//! Simple lock-free FIFO queue base. Based on lf_array<T, N> itself. Currently uses 32-bit counters. //! Simple lock-free FIFO queue base. Based on lf_array<T, N> 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. //! There is no "push_end" or "pop_begin" provided, the queue element must signal its state on its own.
template<typename T, std::size_t N> template<typename T, usz N>
class lf_fifo : public lf_array<T, N> class lf_fifo : public lf_array<T, N>
{ {
// LSB 32-bit: push, MSB 32-bit: pop // LSB 32-bit: push, MSB 32-bit: pop
@ -354,9 +354,9 @@ public:
// Apply func(data) to each element, return the total length // Apply func(data) to each element, return the total length
template <typename F> template <typename F>
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()) for (auto slice = pop_all(); slice; slice.pop_front())
{ {

View File

@ -217,13 +217,13 @@ std::string utils::get_firmware_version()
std::string version = version_file.to_string(); std::string version = version_file.to_string();
// Extract version // Extract version
const size_t start = version.find_first_of(':') + 1; const usz start = version.find_first_of(':') + 1;
const size_t end = version.find_first_of(':', start); const usz end = version.find_first_of(':', start);
version = version.substr(start, end - start); version = version.substr(start, end - start);
// Trim version // Trim version
const size_t trim_start = version.find_first_not_of('0'); const usz trim_start = version.find_first_not_of('0');
const size_t trim_end = version.find_last_not_of('0'); const usz trim_end = version.find_last_not_of('0');
version = version.substr(trim_start, trim_end); version = version.substr(trim_start, trim_end);
return version; return version;

View File

@ -152,7 +152,7 @@ namespace utils
template <typename T> template <typename T>
class refctr final class refctr final
{ {
atomic_t<std::size_t> m_ref{1}; atomic_t<usz> m_ref{1};
public: public:
T object; T object;
@ -168,7 +168,7 @@ namespace utils
m_ref++; m_ref++;
} }
std::size_t remove_ref() noexcept usz remove_ref() noexcept
{ {
return --m_ref; return --m_ref;
} }
@ -464,8 +464,8 @@ namespace utils
uint get_id() const uint get_id() const
{ {
// It's not often needed so figure it out instead of storing it // It's not often needed so figure it out instead of storing it
const std::size_t diff = reinterpret_cast<uchar*>(m_block) - m_head->m_ptr; const usz diff = reinterpret_cast<uchar*>(m_block) - m_head->m_ptr;
const std::size_t quot = diff / m_head->m_ssize; const usz quot = diff / m_head->m_ssize;
if (diff % m_head->m_ssize || quot > typeinfo_count<T>::max_count) if (diff % m_head->m_ssize || quot > typeinfo_count<T>::max_count)
{ {
@ -498,7 +498,7 @@ namespace utils
void* m_memory = nullptr; void* m_memory = nullptr;
// Virtual memory size // Virtual memory size
std::size_t m_total = 0; usz m_total = 0;
template <typename T> template <typename T>
typemap_head* get_head() const typemap_head* get_head() const
@ -555,7 +555,7 @@ namespace utils
// Delete objects (there shall be no threads accessing them) // Delete objects (there shall be no threads accessing them)
const uint lim = m_map[i].m_count != 1 ? +m_map[i].m_limit : 1; 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<typemap_block*>(m_map[i].m_ptr + j * m_map[i].m_ssize); const auto block = reinterpret_cast<typemap_block*>(m_map[i].m_ptr + j * m_map[i].m_ssize);
@ -585,7 +585,7 @@ namespace utils
{ {
const uint align = type->align; const uint align = type->align;
const uint ssize = ::align<uint>(sizeof(typemap_block), align) + ::align(type->size, align); const uint ssize = ::align<uint>(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)}; const auto start = uptr{::align(m_total, align)};
if (total) if (total)
@ -624,7 +624,7 @@ namespace utils
} }
// Return allocated virtual memory block size (not aligned) // Return allocated virtual memory block size (not aligned)
std::size_t get_memory_size() const usz get_memory_size() const
{ {
return m_total; return m_total;
} }
@ -664,7 +664,7 @@ namespace utils
// Find empty location and lock it, starting from hint index // 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)) for (uint lim = head->m_limit, i = (lim > last ? 0 : lim);; i = (i == last ? 0 : i + 1))
{ {
block = reinterpret_cast<typemap_block*>(head->m_ptr + std::size_t{i} * head->m_ssize); block = reinterpret_cast<typemap_block*>(head->m_ptr + usz{i} * head->m_ssize);
if (block->m_type == 0 && block->m_mutex.try_lock()) if (block->m_type == 0 && block->m_mutex.try_lock())
{ {
@ -703,7 +703,7 @@ namespace utils
else if constexpr (std::is_invocable_r_v<bool, const Arg&, const Type&>) else if constexpr (std::is_invocable_r_v<bool, const Arg&, const Type&>)
{ {
// Access with a lookup function // Access with a lookup function
for (std::size_t j = 0; j < (typeinfo_count<Type>::max_count != 1 ? +head->m_limit : 1); j++) for (usz j = 0; j < (typeinfo_count<Type>::max_count != 1 ? +head->m_limit : 1); j++)
{ {
block = reinterpret_cast<typemap_block*>(head->m_ptr + j * head->m_ssize); block = reinterpret_cast<typemap_block*>(head->m_ptr + j * head->m_ssize);
@ -731,7 +731,7 @@ namespace utils
const uint unbiased = static_cast<uint>(std::forward<Arg>(id)) - bias; const uint unbiased = static_cast<uint>(std::forward<Arg>(id)) - bias;
const uint unscaled = unbiased / step; const uint unscaled = unbiased / step;
block = reinterpret_cast<typemap_block*>(head->m_ptr + std::size_t{head->m_ssize} * unscaled); block = reinterpret_cast<typemap_block*>(head->m_ptr + usz{head->m_ssize} * unscaled);
// Check id range and type // Check id range and type
if (unscaled >= typeinfo_count<Type>::max_count || unbiased % step) [[unlikely]] if (unscaled >= typeinfo_count<Type>::max_count || unbiased % step) [[unlikely]]
@ -866,7 +866,7 @@ namespace utils
} }
} }
template <std::size_t I, typename Type, typename... Types, bool Lock, bool... Locks, std::size_t N> template <usz I, typename Type, typename... Types, bool Lock, bool... Locks, usz N>
bool try_lock(const std::array<typeptr_base, N>& array, uint locked, std::integer_sequence<bool, Lock, Locks...>) const bool try_lock(const std::array<typeptr_base, N>& array, uint locked, std::integer_sequence<bool, Lock, Locks...>) const
{ {
// Try to lock mutex if not locked from the previous step // Try to lock mutex if not locked from the previous step
@ -905,8 +905,8 @@ namespace utils
return false; return false;
} }
template <typename... Types, std::size_t N, std::size_t... I, bool... Locks> template <typename... Types, usz N, usz... I, bool... Locks>
uint lock_array(const std::array<typeptr_base, N>& array, std::integer_sequence<std::size_t, I...>, std::integer_sequence<bool, Locks...>) const uint lock_array(const std::array<typeptr_base, N>& array, std::integer_sequence<usz, I...>, std::integer_sequence<bool, Locks...>) const
{ {
// Verify all mutexes are free or wait for one of them and return its index // Verify all mutexes are free or wait for one of them and return its index
uint locked = 0; uint locked = 0;
@ -914,15 +914,15 @@ namespace utils
return locked; return locked;
} }
template <typename... Types, std::size_t N, std::size_t... I, typename... Args> template <typename... Types, usz N, usz... I, typename... Args>
void check_array(std::array<typeptr_base, N>& array, std::integer_sequence<std::size_t, I...>, Args&&... ids) const void check_array(std::array<typeptr_base, N>& array, std::integer_sequence<usz, I...>, Args&&... ids) const
{ {
// Check types and unlock on mismatch // Check types and unlock on mismatch
(check_ptr<Types, Args>(array[I].m_block, std::forward<Args>(ids)), ...); (check_ptr<Types, Args>(array[I].m_block, std::forward<Args>(ids)), ...);
} }
template <typename... Types, std::size_t N, std::size_t... I> template <typename... Types, usz N, usz... I>
std::tuple<typeptr<Types>...> array_to_tuple(const std::array<typeptr_base, N>& array, std::integer_sequence<std::size_t, I...>) const std::tuple<typeptr<Types>...> array_to_tuple(const std::array<typeptr_base, N>& array, std::integer_sequence<usz, I...>) const
{ {
return {array[I]...}; return {array[I]...};
} }
@ -1000,7 +1000,7 @@ namespace utils
const ullong ix = head->m_create_count; const ullong ix = head->m_create_count;
for (std::size_t j = 0; j < (typeinfo_count<decode_t<Type>>::max_count != 1 ? +head->m_limit : 1); j++) for (usz j = 0; j < (typeinfo_count<decode_t<Type>>::max_count != 1 ? +head->m_limit : 1); j++)
{ {
const auto block = reinterpret_cast<typemap_block*>(head->m_ptr + j * head->m_ssize); const auto block = reinterpret_cast<typemap_block*>(head->m_ptr + j * head->m_ssize);

View File

@ -67,7 +67,7 @@ namespace utils
int vnum2 = 0; int vnum2 = 0;
// Loop until both strings are processed // 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 // Storing numeric part of version 1 in vnum1
while (i < v1.length() && v1[i] != '.') while (i < v1.length() && v1[i] != '.')

View File

@ -578,7 +578,7 @@ int validate_npd_hashes(const char* file_name, const u8* klicensee, NPD_HEADER *
int dev_hash_result = 0; int dev_hash_result = 0;
const s32 file_name_length = ::narrow<s32>(std::strlen(file_name)); const s32 file_name_length = ::narrow<s32>(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<u8[]> buf(new u8[buf_len]); std::unique_ptr<u8[]> buf(new u8[buf_len]);
std::unique_ptr<u8[]> buf_lower(new u8[buf_len]); std::unique_ptr<u8[]> 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_lower.get(), buf.get(), buf_len);
std::memcpy(buf_upper.get(), buf.get(), buf_len); std::memcpy(buf_upper.get(), buf.get(), buf_len);
for (std::size_t i = std::basic_string_view<u8>(buf.get() + 0x30, file_name_length).find_last_of('.'); i < buf_len; i++) for (usz i = std::basic_string_view<u8>(buf.get() + 0x30, file_name_length).find_last_of('.'); i < buf_len; i++)
{ {
const u8 c = static_cast<u8>(buf[i]); const u8 c = static_cast<u8>(buf[i]);
buf_upper[i] = std::toupper(c); buf_upper[i] = std::toupper(c);

View File

@ -697,7 +697,7 @@ bool package_reader::extract_data(atomic_t<double>& sync)
return false; return false;
} }
size_t num_failures = 0; usz num_failures = 0;
std::vector<PKGEntry> entries(header.file_count); std::vector<PKGEntry> 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; cur_offset += new_offset;
u64 _offset = 0; 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())) if (cur_offset < (_offset + filelist[i].size()))
{ {

View File

@ -117,16 +117,16 @@ struct PKGEntry
struct PKGMetaData struct PKGMetaData
{ {
private: 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; 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<int>(buf[i]); sstream << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(buf[i]);
} }
return sstream.str(); 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); std::string result = to_hex_string(buf, size);
if (result.size() > dotpos) if (result.size() > dotpos)
@ -312,14 +312,14 @@ private:
u64 archive_read(void* data_ptr, const u64 num_bytes); u64 archive_read(void* data_ptr, const u64 num_bytes);
u64 decrypt(u64 offset, u64 size, const uchar* key); 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; bool m_is_valid = false;
std::string m_path; std::string m_path;
std::string install_dir; std::string install_dir;
std::vector<fs::file> filelist; std::vector<fs::file> filelist;
size_t cur_file = 0; usz cur_file = 0;
u64 cur_offset = 0; u64 cur_offset = 0;
u64 cur_file_offset = 0; u64 cur_file_offset = 0;
std::unique_ptr<u128[]> buf; std::unique_ptr<u128[]> buf;

View File

@ -715,7 +715,7 @@ bool SCEDecrypter::LoadMetadata(const u8 erk[32], const u8 riv[16])
} }
// Perform AES-CTR encryption on the metadata headers. // Perform AES-CTR encryption on the metadata headers.
size_t ctr_nc_off = 0; usz ctr_nc_off = 0;
u8 ctr_stream_block[0x10]; u8 ctr_stream_block[0x10];
aes_setkey_enc(&aes, meta_info.key, 128); 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()); 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. // Parse the metadata section headers to find the offsets of encrypted data.
for (unsigned int i = 0; i < meta_hdr.section_count; i++) 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 ctr_stream_block[0x10];
u8 data_key[0x10]; u8 data_key[0x10];
u8 data_iv[0x10]; u8 data_iv[0x10];
@ -824,7 +824,7 @@ std::vector<fs::file> SCEDecrypter::MakeFile()
// Decompress if necessary. // Decompress if necessary.
if (meta_shdr[i].compressed == 2) if (meta_shdr[i].compressed == 2)
{ {
const size_t BUFSIZE = 32 * 1024; const usz BUFSIZE = 32 * 1024;
u8 tempbuf[BUFSIZE]; u8 tempbuf[BUFSIZE];
z_stream strm; z_stream strm;
strm.zalloc = Z_NULL; strm.zalloc = Z_NULL;
@ -1210,7 +1210,7 @@ bool SELFDecrypter::LoadMetadata(u8* klic_key)
} }
// Perform AES-CTR encryption on the metadata headers. // Perform AES-CTR encryption on the metadata headers.
size_t ctr_nc_off = 0; usz ctr_nc_off = 0;
u8 ctr_stream_block[0x10]; u8 ctr_stream_block[0x10];
aes_setkey_enc(&aes, meta_info.key, 128); 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()); 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. // Parse the metadata section headers to find the offsets of encrypted data.
for (unsigned int i = 0; i < meta_hdr.section_count; i++) 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 ctr_stream_block[0x10];
u8 data_key[0x10]; u8 data_key[0x10];
u8 data_iv[0x10]; u8 data_iv[0x10];

View File

@ -96,7 +96,7 @@ protected:
{ {
if (m_mode != CPUDisAsm_NormalMode) if (m_mode != CPUDisAsm_NormalMode)
{ {
op.resize(std::max<std::size_t>(op.length(), 10), ' '); op.resize(std::max<usz>(op.length(), 10), ' ');
} }
return op; return op;

View File

@ -2917,9 +2917,9 @@ public:
template <> template <>
struct fmt_unveil<llvm::TypeSize, void> struct fmt_unveil<llvm::TypeSize, void>
{ {
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; return arg;
} }

View File

@ -99,7 +99,7 @@ bool statichle_handler::load_patterns()
#define POLY 0x8408 #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 char i;
unsigned int data; unsigned int data;

View File

@ -26,7 +26,7 @@ public:
bool check_against_patterns(vm::cptr<u8>& data, u32 size, u32 addr); bool check_against_patterns(vm::cptr<u8>& data, u32 size, u32 addr);
protected: 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<shle_pattern> hle_patterns; std::vector<shle_pattern> hle_patterns;
}; };

View File

@ -1071,7 +1071,7 @@ void cell_audio_thread::mix(float *out_buffer, s32 offset)
// 2x CVTPS2DQ (converts float to s32) // 2x CVTPS2DQ (converts float to s32)
// PACKSSDW (converts s32 to s16 with signed saturation) // 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); const auto scale = _mm_set1_ps(0x8000);
_mm_store_ps(out_buffer + i / 2, _mm_castsi128_ps(_mm_packs_epi32( _mm_store_ps(out_buffer + i / 2, _mm_castsi128_ps(_mm_packs_epi32(

View File

@ -60,7 +60,7 @@ struct CellCelp8EncResource
vm::bptr<void> startAddr; vm::bptr<void> startAddr;
be_t<u32> ppuThreadPriority; be_t<u32> ppuThreadPriority;
be_t<u32> spuThreadPriority; be_t<u32> spuThreadPriority;
be_t<u32/*size_t*/> ppuThreadStackSize; be_t<u32/*usz*/> ppuThreadStackSize;
}; };
struct CellCelp8EncParam struct CellCelp8EncParam

View File

@ -55,7 +55,7 @@ struct CellCelpEncResource
vm::bptr<void> startAddr; vm::bptr<void> startAddr;
be_t<u32> ppuThreadPriority; be_t<u32> ppuThreadPriority;
be_t<u32> spuThreadPriority; be_t<u32> spuThreadPriority;
be_t<u32/*size_t*/> ppuThreadStackSize; be_t<u32/*usz*/> ppuThreadStackSize;
}; };
struct CellCelpEncParam struct CellCelpEncParam

View File

@ -181,7 +181,7 @@ public:
const u32 spec; //addr const u32 spec; //addr
std::vector<u8> raw_data; // demultiplexed data stream (managed by demuxer thread) std::vector<u8> 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_dts = CODEC_TS_INVALID;
u64 last_pts = CODEC_TS_INVALID; u64 last_pts = CODEC_TS_INVALID;

View File

@ -332,7 +332,7 @@ u32 cellGcmGetTiledPitchSize(u32 size)
{ {
cellGcmSys.trace("cellGcmGetTiledPitchSize(size=%d)", 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]) { if (tiled_pitches[i] < size && size <= tiled_pitches[i + 1]) {
return tiled_pitches[i + 1]; return tiled_pitches[i + 1];
} }

View File

@ -886,7 +886,7 @@ error_code cellImeJpGetConfirmYomiString(CellImeJpHandle hImeJpHandle, vm::ptr<u
pYomiString[i] = 0; pYomiString[i] = 0;
} }
const size_t max_len = std::min<size_t>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->confirmed_string.length()); const usz max_len = std::min<usz>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->confirmed_string.length());
for (u32 i = 0; i < max_len; i++) for (u32 i = 0; i < max_len; i++)
{ {
@ -918,7 +918,7 @@ error_code cellImeJpGetConfirmString(CellImeJpHandle hImeJpHandle, vm::ptr<u16>
pConfirmString[i] = 0; pConfirmString[i] = 0;
} }
const size_t max_len = std::min<size_t>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->confirmed_string.length()); const usz max_len = std::min<usz>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->confirmed_string.length());
for (u32 i = 0; i < max_len; i++) for (u32 i = 0; i < max_len; i++)
{ {
@ -950,7 +950,7 @@ error_code cellImeJpGetConvertYomiString(CellImeJpHandle hImeJpHandle, vm::ptr<u
pYomiString[i] = 0; pYomiString[i] = 0;
} }
const size_t max_len = std::min<size_t>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->input_string.length()); const usz max_len = std::min<usz>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->input_string.length());
for (u32 i = 0; i < max_len; i++) for (u32 i = 0; i < max_len; i++)
{ {
@ -982,7 +982,7 @@ error_code cellImeJpGetConvertString(CellImeJpHandle hImeJpHandle, vm::ptr<u16>
pConvertString[i] = 0; pConvertString[i] = 0;
} }
const size_t max_len = std::min<size_t>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->input_string.length()); const usz max_len = std::min<usz>(CELL_IMEJP_STRING_MAXLENGTH - 1, manager->input_string.length());
for (u32 i = 0; i < max_len; i++) for (u32 i = 0; i < max_len; i++)
{ {

View File

@ -118,8 +118,8 @@ struct ime_jp_manager
std::u16string confirmed_string; std::u16string confirmed_string;
std::u16string converted_string; std::u16string converted_string;
std::u16string input_string; std::u16string input_string;
size_t cursor = 0; usz cursor = 0;
size_t cursor_end = 0; usz cursor_end = 0;
s16 fix_input_mode = CELL_IMEJP_FIXINMODE_OFF; s16 fix_input_mode = CELL_IMEJP_FIXINMODE_OFF;
s16 input_char_type = CELL_IMEJP_DSPCHAR_HIRA; s16 input_char_type = CELL_IMEJP_DSPCHAR_HIRA;
s16 kana_input_mode = CELL_IMEJP_ROMAN_INPUT; s16 kana_input_mode = CELL_IMEJP_ROMAN_INPUT;

View File

@ -234,7 +234,7 @@ error_code cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data,
const bool flip = current_outParam.outputMode == CELL_JPGDEC_BOTTOM_TO_TOP; const bool flip = current_outParam.outputMode == CELL_JPGDEC_BOTTOM_TO_TOP;
const int bytesPerLine = static_cast<int>(dataCtrlParam->outputBytesPerLine); const int bytesPerLine = static_cast<int>(dataCtrlParam->outputBytesPerLine);
size_t image_size = width * height; usz image_size = width * height;
switch(current_outParam.outputColorSpace) switch(current_outParam.outputColorSpace)
{ {

View File

@ -231,11 +231,11 @@ s32 _ConvertStr(s32 src_code, const void *src, s32 src_len, s32 dst_code, void *
#else #else
s32 retValue = ConversionOK; s32 retValue = ConversionOK;
iconv_t ict = iconv_open(dstCode, srcCode); iconv_t ict = iconv_open(dstCode, srcCode);
size_t srcLen = src_len; usz srcLen = src_len;
if (dst != NULL) if (dst != NULL)
{ {
size_t dstLen = *dst_len; usz dstLen = *dst_len;
size_t ictd = iconv(ict, const_cast<char**>(reinterpret_cast<const char**>(&src)), &srcLen, reinterpret_cast<char**>(&dst), &dstLen); usz ictd = iconv(ict, const_cast<char**>(reinterpret_cast<const char**>(&src)), &srcLen, reinterpret_cast<char**>(&dst), &dstLen);
*dst_len -= dstLen; *dst_len -= dstLen;
if (ictd == umax) 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) while (srcLen > 0)
{ {
char *bufPtr = buf; char *bufPtr = buf;
size_t bufLeft = sizeof(buf); usz bufLeft = sizeof(buf);
size_t ictd = iconv(ict, const_cast<char**>(reinterpret_cast<const char**>(&src)), &srcLen, reinterpret_cast<char**>(&dst), &bufLeft); usz ictd = iconv(ict, const_cast<char**>(reinterpret_cast<const char**>(&src)), &srcLen, reinterpret_cast<char**>(&dst), &bufLeft);
*dst_len += sizeof(buf) - bufLeft; *dst_len += sizeof(buf) - bufLeft;
if (ictd == umax && errno != E2BIG) if (ictd == umax && errno != E2BIG)
{ {

View File

@ -182,7 +182,7 @@ struct CellMicStatus
// --- End of cell definitions --- // --- End of cell definitions ---
template <std::size_t S> template <usz S>
class simple_ringbuf class simple_ringbuf
{ {
public: public:
@ -337,7 +337,7 @@ private:
u32 sample_size = 0; // Determined at opening for internal use 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<inbuf_size> rbuf_raw; simple_ringbuf<inbuf_size> rbuf_raw;
simple_ringbuf<inbuf_size> rbuf_dsp; simple_ringbuf<inbuf_size> rbuf_dsp;

View File

@ -153,7 +153,7 @@ void pngDecInfoCallback(png_structp png_ptr, png_infop info)
return; 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); stream->buffer->cursor += (stream->buffer->length - remaining);
} }

View File

@ -276,8 +276,8 @@ struct PngHandle
struct PngBuffer struct PngBuffer
{ {
// The cursor location and data pointer for reading from a buffer // The cursor location and data pointer for reading from a buffer
size_t cursor; usz cursor;
size_t length; usz length;
vm::bptr<void> data; vm::bptr<void> data;
// The file descriptor, and whether we need to read from a file descriptor // The file descriptor, and whether we need to read from a file descriptor

View File

@ -97,7 +97,7 @@ struct CellPngEncConfig
struct CellPngEncAttr struct CellPngEncAttr
{ {
be_t<u32> memSize; // size_t be_t<u32> memSize; // usz
u8 cmdQueueDepth; u8 cmdQueueDepth;
be_t<u32> versionUpper; be_t<u32> versionUpper;
be_t<u32> versionLower; be_t<u32> versionLower;
@ -106,7 +106,7 @@ struct CellPngEncAttr
struct CellPngEncResource struct CellPngEncResource
{ {
vm::bptr<void> memAddr; vm::bptr<void> memAddr;
be_t<u32> memSize; // size_t be_t<u32> memSize; // usz
be_t<s32> ppuThreadPriority; be_t<s32> ppuThreadPriority;
be_t<s32> spuThreadPriority; be_t<s32> spuThreadPriority;
}; };
@ -114,7 +114,7 @@ struct CellPngEncResource
struct CellPngEncResourceEx struct CellPngEncResourceEx
{ {
vm::bptr<void> memAddr; vm::bptr<void> memAddr;
be_t<u32> memSize; // size_t be_t<u32> memSize; // usz
be_t<s32> ppuThreadPriority; be_t<s32> ppuThreadPriority;
vm::bptr<void> spurs; // CellSpurs vm::bptr<void> spurs; // CellSpurs
u8 priority[8]; u8 priority[8];
@ -153,7 +153,7 @@ struct CellPngEncOutputParam
be_t<u32> location; // CellPngEncLocation be_t<u32> location; // CellPngEncLocation
vm::bcptr<char> streamFileName; vm::bcptr<char> streamFileName;
vm::bptr<void> streamAddr; vm::bptr<void> streamAddr;
be_t<u32> limitSize; // size_t be_t<u32> limitSize; // usz
}; };
struct CellPngEncStreamInfo struct CellPngEncStreamInfo
@ -162,8 +162,8 @@ struct CellPngEncStreamInfo
be_t<u32> location; // CellPngEncLocation be_t<u32> location; // CellPngEncLocation
vm::bcptr<char> streamFileName; vm::bcptr<char> streamFileName;
vm::bptr<void> streamAddr; vm::bptr<void> streamAddr;
be_t<u32> limitSize; // size_t be_t<u32> limitSize; // usz
be_t<u32> streamSize; // size_t be_t<u32> streamSize; // usz
be_t<u32> processedLine; be_t<u32> processedLine;
be_t<u64> userData; be_t<u64> userData;
}; };

View File

@ -87,7 +87,7 @@ struct CellRescDsts
struct CellRescInitConfig struct CellRescInitConfig
{ {
be_t<u32> size; // size_t be_t<u32> size; // usz
be_t<u32> resourcePolicy; be_t<u32> resourcePolicy;
be_t<u32> supportModes; be_t<u32> supportModes;
be_t<u32> ratioMode; be_t<u32> ratioMode;

View File

@ -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 // 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); lv2_obj::sleep(ppu);
std::this_thread::sleep_for(std::chrono::microseconds(sleep_time)); std::this_thread::sleep_for(std::chrono::microseconds(sleep_time));

View File

@ -163,7 +163,7 @@ void fmt_class_string<SceNpCommunicationSignature>::format(std::string& out, u64
// Format as a C byte array for ease of use // Format as a C byte array for ease of use
fmt::append(out, "{ "); fmt::append(out, "{ ");
for (std::size_t i = 0;; i++) for (usz i = 0;; i++)
{ {
if (i == std::size(sign.data) - 1) 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 // Rename or discard certain entries based on the files found
const size_t kTargetBufferLength = 31; const usz kTargetBufferLength = 31;
char target[kTargetBufferLength + 1]; char target[kTargetBufferLength + 1];
target[kTargetBufferLength] = 0; target[kTargetBufferLength] = 0;
strcpy_trunc(target, fmt::format("TROP_%02d.SFM", static_cast<s32>(g_cfg.sys.language))); strcpy_trunc(target, fmt::format("TROP_%02d.SFM", static_cast<s32>(g_cfg.sys.language)));

View File

@ -17,7 +17,7 @@ static bool validateSlotIds(vm::cptr<SceNpTusSlotId> slotIdArray)
} }
// TODO: how to properly iterate? // 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) // 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) 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) for (const auto& title_context : title_contexts)
{ {

View File

@ -16,47 +16,47 @@ struct ps3_fmt_src
ppu_thread* ctx; ppu_thread* ctx;
u32 g_count; u32 g_count;
bool test(std::size_t index) const bool test(usz index) const
{ {
return true; return true;
} }
template <typename T> template <typename T>
T get(std::size_t index) const T get(usz index) const
{ {
const u32 i = static_cast<u32>(index) + g_count; const u32 i = static_cast<u32>(index) + g_count;
return ppu_gpr_cast<T>(i < 8 ? ctx->gpr[3 + i] : +*ctx->get_stack_arg(i)); return ppu_gpr_cast<T>(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<u32>(extra) + 1; g_count += static_cast<u32>(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<const char>(get<u32>(extra)); out += vm::_ptr<const char>(get<u32>(extra));
return out.size() - start; return out.size() - start;
} }
std::size_t type(std::size_t extra) const usz type(usz extra) const
{ {
return 0; return 0;
} }
static constexpr std::size_t size_char = 1; static constexpr usz size_char = 1;
static constexpr std::size_t size_short = 2; static constexpr usz size_short = 2;
static constexpr std::size_t size_int = 4; static constexpr usz size_int = 4;
static constexpr std::size_t size_long = 4; static constexpr usz size_long = 4;
static constexpr std::size_t size_llong = 8; static constexpr usz size_llong = 8;
static constexpr std::size_t size_size = 4; static constexpr usz size_size = 4;
static constexpr std::size_t size_max = 8; static constexpr usz size_max = 8;
static constexpr std::size_t size_diff = 4; static constexpr usz size_diff = 4;
}; };
template <> template <>
f64 ps3_fmt_src::get<f64>(std::size_t index) const f64 ps3_fmt_src::get<f64>(usz index) const
{ {
return std::bit_cast<f64>(get<u64>(index)); return std::bit_cast<f64>(get<u64>(index));
} }
@ -404,7 +404,7 @@ s32 _sys_snprintf(ppu_thread& ppu, vm::ptr<char> dst, u32 count, vm::cptr<char>
} }
else else
{ {
count = static_cast<u32>(std::min<size_t>(count - 1, result.size())); count = static_cast<u32>(std::min<usz>(count - 1, result.size()));
std::memcpy(dst.get_ptr(), result.c_str(), count); std::memcpy(dst.get_ptr(), result.c_str(), count);
dst[count] = 0; dst[count] = 0;

View File

@ -836,7 +836,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry)
} }
// Main loop (func_queue may grow) // 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]; 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(); const bool was_empty = block_queue.empty();
// Block loop (block_queue may grow, may be aborted via clearing) // 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(); auto& block = block_queue[j].get();

View File

@ -117,9 +117,9 @@ struct ppu_pattern
struct ppu_pattern_array struct ppu_pattern_array
{ {
const ppu_pattern* ptr; const ppu_pattern* ptr;
std::size_t count; usz count;
template <std::size_t N> template <usz N>
constexpr ppu_pattern_array(const ppu_pattern(&array)[N]) constexpr ppu_pattern_array(const ppu_pattern(&array)[N])
: ptr(array) : ptr(array)
, count(N) , count(N)
@ -140,9 +140,9 @@ struct ppu_pattern_array
struct ppu_pattern_matrix struct ppu_pattern_matrix
{ {
const ppu_pattern_array* ptr; const ppu_pattern_array* ptr;
std::size_t count; usz count;
template <std::size_t N> template <usz N>
constexpr ppu_pattern_matrix(const ppu_pattern_array(&array)[N]) constexpr ppu_pattern_matrix(const ppu_pattern_array(&array)[N])
: ptr(array) : ptr(array)
, count(N) , count(N)

View File

@ -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<char>(seg.addr), seg.size}; const std::string_view seg_view{vm::get_super_ptr<char>(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<u8>(seg.addr + i); const auto elf_header = vm::get_super_ptr<u8>(seg.addr + i);
@ -715,7 +715,7 @@ static void ppu_check_patch_spu_images(const ppu_segment& seg)
std::string name; std::string name;
std::string dump; std::string dump;
std::size_t applied = 0; usz applied = 0;
// Executable hash // Executable hash
sha1_context sha2; sha1_context sha2;
@ -867,7 +867,7 @@ std::shared_ptr<lv2_prx> 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 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<u32>(elf.progs[i].p_vaddr); const u32 saddr = static_cast<u32>(elf.progs[i].p_vaddr);
if (addr >= saddr && addr < saddr + elf.progs[i].p_memsz) if (addr >= saddr && addr < saddr + elf.progs[i].p_memsz)

View File

@ -2105,7 +2105,7 @@ extern void ppu_initialize(const ppu_module& info)
std::vector<std::pair<std::string, u64>> globals; std::vector<std::pair<std::string, u64>> globals;
// Split module into fragments <= 1 MiB // Split module into fragments <= 1 MiB
std::size_t fpos = 0; usz fpos = 0;
// Difference between function name and current location // Difference between function name and current location
const u32 reloc = info.name.empty() ? 0 : info.segs.at(0).addr; 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; const u32 suffix = info.funcs.at(fstart).addr - reloc;
// Overall block size in bytes // Overall block size in bytes
std::size_t bsize = 0; usz bsize = 0;
while (fpos < info.funcs.size()) while (fpos < info.funcs.size())
{ {
@ -2455,7 +2455,7 @@ extern void ppu_initialize(const ppu_module& info)
} }
else else
{ {
std::size_t index = 0; usz index = 0;
// Locate existing functions // Locate existing functions
for (const auto& func : info.funcs) 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 //pm.add(createLintPass()); // Check
// Translate functions // 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()) if (Emu.IsStopped())
{ {

View File

@ -137,7 +137,7 @@ public:
u8 bits[32]; u8 bits[32];
u32 fields[8]; u32 fields[8];
u8& operator [](std::size_t i) u8& operator [](usz i)
{ {
return bits[i]; return bits[i];
} }

View File

@ -528,7 +528,7 @@ Value* PPUTranslator::Shuffle(Value* left, Value* right, std::initializer_list<u
const u32 mask = cast<VectorType>(type)->getNumElements() - 1; const u32 mask = cast<VectorType>(type)->getNumElements() - 1;
// Transform indices (works for vectors with size 2^N) // 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); data.push_back(indices.end()[~i] ^ mask);
} }

View File

@ -209,20 +209,20 @@ public:
// Create sign extension (with double size if type is nullptr) // Create sign extension (with double size if type is nullptr)
llvm::Value* SExt(llvm::Value* value, llvm::Type* = nullptr); llvm::Value* SExt(llvm::Value* value, llvm::Type* = nullptr);
template<std::size_t N> template<usz N>
std::array<llvm::Value*, N> SExt(std::array<llvm::Value*, N> values, llvm::Type* type = nullptr) std::array<llvm::Value*, N> SExt(std::array<llvm::Value*, N> 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; return values;
} }
// Create zero extension (with double size if type is nullptr) // Create zero extension (with double size if type is nullptr)
llvm::Value* ZExt(llvm::Value*, llvm::Type* = nullptr); llvm::Value* ZExt(llvm::Value*, llvm::Type* = nullptr);
template<std::size_t N> template<usz N>
std::array<llvm::Value*, N> ZExt(std::array<llvm::Value*, N> values, llvm::Type* type = nullptr) std::array<llvm::Value*, N> ZExt(std::array<llvm::Value*, N> 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; return values;
} }

View File

@ -389,7 +389,7 @@ void spu_cache::initialize()
// Read cache // Read cache
auto func_list = cache.get(); auto func_list = cache.get();
atomic_t<std::size_t> fnext{}; atomic_t<usz> fnext{};
atomic_t<u8> fail_flag{0}; atomic_t<u8> fail_flag{0};
if (g_cfg.core.spu_decoder == spu_decoder_type::fast || g_cfg.core.spu_decoder == spu_decoder_type::llvm) 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<be_t<u32>> ls(0x10000); std::vector<be_t<u32>> ls(0x10000);
// Build functions // 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]; 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) // 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 // Get copy of the workload info
auto w = workload[i]; auto w = workload[i];
@ -1975,7 +1975,7 @@ spu_program spu_recompiler_base::analyse(const be_t<u32>* ls, u32 entry_point)
workload.push_back(pair.first); workload.push_back(pair.first);
m_bits[pair.first / 4] = true; 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) 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); 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 // 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 // Initialize function info
m_entry = m_function_queue[fi]; m_entry = m_function_queue[fi];
@ -4506,7 +4506,7 @@ public:
m_ir->CreateBr(add_block(m_entry)); m_ir->CreateBr(add_block(m_entry));
// Emit instructions for basic blocks // 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 // Initialize basic block info
const u32 baddr = m_block_queue[bi]; const u32 baddr = m_block_queue[bi];

View File

@ -1226,7 +1226,7 @@ bool lv2_obj::awake_unlocked(cpu_thread* cpu, s32 prio)
case yield_cmd: case yield_cmd:
{ {
// Yield command // Yield command
for (std::size_t i = 0;; i++) for (usz i = 0;; i++)
{ {
if (i + 1 >= g_ppu.size()) 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) 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++) for (; j < g_ppu.size(); j++)
{ {
@ -1325,7 +1325,7 @@ bool lv2_obj::awake_unlocked(cpu_thread* cpu, s32 prio)
} }
// Suspend threads if necessary // 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]; const auto target = g_ppu[i];
@ -1352,7 +1352,7 @@ void lv2_obj::schedule_all()
if (g_pending.empty()) if (g_pending.empty())
{ {
// Wake up threads // Wake up threads
for (std::size_t i = 0, x = std::min<std::size_t>(g_cfg.core.ppu_threads, g_ppu.size()); i < x; i++) for (usz i = 0, x = std::min<usz>(g_cfg.core.ppu_threads, g_ppu.size()); i < x; i++)
{ {
const auto target = g_ppu[i]; const auto target = g_ppu[i];

View File

@ -238,7 +238,7 @@ public:
const std::vector<u8> data; const std::vector<u8> data;
// Constructors (should not be used directly) // 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()) : timestamp(get_system_time())
, id(_id) , id(_id)
, user_id(_user_id) , user_id(_user_id)
@ -269,7 +269,7 @@ public:
void notify() const; void notify() const;
// Utilities // 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<lv2_config_service> get_shared_ptr () const { return wkptr.lock(); }; std::shared_ptr<lv2_config_service> get_shared_ptr () const { return wkptr.lock(); };
u32 get_id() const { return idm_id; } u32 get_id() const { return idm_id; }
}; };
@ -304,7 +304,7 @@ public:
const std::vector<u8> data; const std::vector<u8> data;
// Constructors (should not be used directly) // Constructors (should not be used directly)
lv2_config_service_listener(std::shared_ptr<lv2_config_handle>& _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<lv2_config_handle>& _handle, sys_config_service_id _service_id, u64 _min_verbosity, sys_config_service_listener_type _type, const u8 _data[], usz size)
: handle(_handle) : handle(_handle)
, service_id(_service_id) , service_id(_service_id)
, min_verbosity(_min_verbosity) , min_verbosity(_min_verbosity)
@ -406,7 +406,7 @@ public:
void write(sys_config_service_event_t *dst); void write(sys_config_service_event_t *dst);
// Check if the buffer can fit the current event, return false otherwise // 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; }
}; };
/* /*

View File

@ -57,7 +57,7 @@ lv2_fs_mount_point* lv2_fs_object::get_mp(std::string_view filename)
{ {
std::string_view mp_name, vpath = filename; std::string_view mp_name, vpath = filename;
for (std::size_t depth = 0;;) for (usz depth = 0;;)
{ {
// Skip one or more '/' // Skip one or more '/'
const auto pos = vpath.find_first_not_of('/'); const auto pos = vpath.find_first_not_of('/');
@ -833,7 +833,7 @@ error_code sys_fs_readdir(ppu_thread& ppu, u32 fd, vm::ptr<CellFsDirent> dir, vm
if (auto* info = directory->dir_read()) if (auto* info = directory->dir_read())
{ {
dir->d_type = info->is_directory ? CELL_FS_TYPE_DIRECTORY : CELL_FS_TYPE_REGULAR; dir->d_type = info->is_directory ? CELL_FS_TYPE_DIRECTORY : CELL_FS_TYPE_REGULAR;
dir->d_namlen = u8(std::min<size_t>(info->name.size(), CELL_FS_MAX_FS_FILE_NAME_LENGTH)); dir->d_namlen = u8(std::min<usz>(info->name.size(), CELL_FS_MAX_FS_FILE_NAME_LENGTH));
strcpy_trunc(dir->d_name, info->name); strcpy_trunc(dir->d_name, info->name);
*nread = sizeof(CellFsDirent); *nread = sizeof(CellFsDirent);
} }
@ -1570,7 +1570,7 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr<void> _arg, u32
} }
entry.entry_name.d_type = info->is_directory ? CELL_FS_TYPE_DIRECTORY : CELL_FS_TYPE_REGULAR; entry.entry_name.d_type = info->is_directory ? CELL_FS_TYPE_DIRECTORY : CELL_FS_TYPE_REGULAR;
entry.entry_name.d_namlen = u8(std::min<size_t>(info->name.size(), CELL_FS_MAX_FS_FILE_NAME_LENGTH)); entry.entry_name.d_namlen = u8(std::min<usz>(info->name.size(), CELL_FS_MAX_FS_FILE_NAME_LENGTH));
strcpy_trunc(entry.entry_name.d_name, info->name); strcpy_trunc(entry.entry_name.d_name, info->name);
} }
} }

View File

@ -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; u32 cksum = 0;
while (size > 1) while (size > 1)
@ -1051,7 +1051,7 @@ struct network_thread
std::lock_guard lock(s_nw_mutex); 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<lv2_socket::poll> events{}; bs_t<lv2_socket::poll> events{};
@ -1114,7 +1114,7 @@ struct network_thread
socklist.emplace_back(idm::get_unlocked<lv2_socket>(id)); socklist.emplace_back(idm::get_unlocked<lv2_socket>(id));
}); });
for (std::size_t i = 0; i < socklist.size(); i++) for (usz i = 0; i < socklist.size(); i++)
{ {
#ifdef _WIN32 #ifdef _WIN32
std::lock_guard lock(socklist[i]->mutex); std::lock_guard lock(socklist[i]->mutex);

View File

@ -382,7 +382,7 @@ struct lv2_socket final
}; };
static constexpr be_t<u32> U2S_sig = (static_cast<u32>('U') << 24 | static_cast<u32>('2') << 16 | static_cast<u32>('S') << 8 | static_cast<u32>('0')); static constexpr be_t<u32> U2S_sig = (static_cast<u32>('U') << 24 | static_cast<u32>('2') << 16 | static_cast<u32>('S') << 8 | static_cast<u32>('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 // P2P stream socket specific
struct encapsulated_tcp struct encapsulated_tcp
@ -407,7 +407,7 @@ struct lv2_socket final
stream_status status = stream_status::stream_closed; 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<s32> backlog; std::queue<s32> backlog;
u16 op_port = 0, op_vport = 0; u16 op_port = 0, op_vport = 0;

View File

@ -13,7 +13,7 @@ struct lv2_overlay final : lv2_obj, ppu_module
error_code sys_overlay_load_module(vm::ptr<u32> ovlmid, vm::cptr<char> path, u64 flags, vm::ptr<u32> entry); error_code sys_overlay_load_module(vm::ptr<u32> ovlmid, vm::cptr<char> path, u64 flags, vm::ptr<u32> entry);
error_code sys_overlay_load_module_by_fd(vm::ptr<u32> ovlmid, u32 fd, u64 offset, u64 flags, vm::ptr<u32> entry); error_code sys_overlay_load_module_by_fd(vm::ptr<u32> ovlmid, u32 fd, u64 offset, u64 flags, vm::ptr<u32> entry);
error_code sys_overlay_unload_module(u32 ovlmid); 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_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_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 //error_code sys_overlay_get_sdk_version(); //2 params

View File

@ -267,7 +267,7 @@ error_code _sys_process_get_paramsfo(vm::ptr<char> buffer)
} }
memset(buffer.get_ptr(), 0, 0x40); memset(buffer.get_ptr(), 0, 0x40);
memcpy(buffer.get_ptr() + 1, Emu.GetTitleID().c_str(), std::min<size_t>(Emu.GetTitleID().length(), 9)); memcpy(buffer.get_ptr() + 1, Emu.GetTitleID().c_str(), std::min<usz>(Emu.GetTitleID().length(), 9));
return CELL_OK; return CELL_OK;
} }

View File

@ -207,10 +207,10 @@ error_code sys_rsx_context_allocate(cpu_thread& cpu, vm::ptr<u32> context_id, vm
auto &reports = vm::_ref<RsxReports>(vm::cast(*lpar_reports)); auto &reports = vm::_ref<RsxReports>(vm::cast(*lpar_reports));
std::memset(&reports, 0, sizeof(RsxReports)); 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; 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 + 0].val.raw() = 0x1337C0D3;
reports.semaphore[i + 1].val.raw() = 0x1337BABE; reports.semaphore[i + 1].val.raw() = 0x1337BABE;
@ -218,7 +218,7 @@ error_code sys_rsx_context_allocate(cpu_thread& cpu, vm::ptr<u32> context_id, vm
reports.semaphore[i + 3].val.raw() = 0x1337F001; 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].val = 0;
reports.report[i].timestamp = -1; reports.report[i].timestamp = -1;

View File

@ -32,7 +32,7 @@ error_code sys_tty_read(s32 ch, vm::ptr<char> buf, u32 len, vm::ptr<u32> preadle
sys_tty.warning("sys_tty_read called with system channel %d", ch); 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 std::string tty_read; // string for storage of read chars
if (len > 0) if (len > 0)
@ -45,15 +45,15 @@ error_code sys_tty_read(s32 ch, vm::ptr<char> buf, u32 len, vm::ptr<u32> preadle
std::string& input = g_tty_input[ch].front(); 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 // 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) if (new_line_pos != input.npos)
{ {
chars_to_read = std::min(new_line_pos, static_cast<size_t>(len)); chars_to_read = std::min(new_line_pos, static_cast<usz>(len));
} }
else else
{ {
chars_to_read = std::min(input.size(), static_cast<size_t>(len)); chars_to_read = std::min(input.size(), static_cast<usz>(len));
} }
// read the previously calculated number of chars from the beginning of the input string // read the previously calculated number of chars from the beginning of the input string

View File

@ -350,7 +350,7 @@ void gdb_thread::send_cmd(const std::string& cmd)
std::string buf; std::string buf;
buf.reserve(cmd.length() + 4); buf.reserve(cmd.length() + 4);
buf += "$"; 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; 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(); auto th = selected_thread.lock();
if (th->id_type() == 1) { if (th->id_type() == 1) {
auto ppu = static_cast<named_thread<ppu_thread>*>(th.get()); auto ppu = static_cast<named_thread<ppu_thread>*>(th.get());
size_t eq_pos = cmd.data.find('='); usz eq_pos = cmd.data.find('=');
if (eq_pos == umax) { if (eq_pos == umax) {
GDB.warning("Wrong write_register cmd data '%s'.", cmd.data); GDB.warning("Wrong write_register cmd data '%s'.", cmd.data);
return send_cmd_ack("E02"); 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) 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 addr = hex_to_u32(cmd.data.substr(0, s));
u32 len = hex_to_u32(cmd.data.substr(s + 1)); u32 len = hex_to_u32(cmd.data.substr(s + 1));
std::string result; 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) bool gdb_thread::cmd_write_memory(gdb_cmd& cmd)
{ {
size_t s = cmd.data.find(','); usz s = cmd.data.find(',');
size_t s2 = cmd.data.find(':'); usz s2 = cmd.data.find(':');
if ((s == umax) || (s2 == umax)) { if ((s == umax) || (s2 == umax)) {
GDB.warning("Malformed write memory request received: '%s'.", cmd.data); GDB.warning("Malformed write memory request received: '%s'.", cmd.data);
return send_cmd_ack("E01"); return send_cmd_ack("E01");

View File

@ -253,7 +253,7 @@ std::string PadHandlerBase::name_string() const
return m_name_string; return m_name_string;
} }
size_t PadHandlerBase::max_devices() const usz PadHandlerBase::max_devices() const
{ {
return m_max_devices; return m_max_devices;
} }
@ -615,7 +615,7 @@ void PadHandlerBase::get_mapping(const std::shared_ptr<PadDevice>& device, const
void PadHandlerBase::ThreadProc() 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 device = bindings[i].first;
auto pad = bindings[i].second; auto pad = bindings[i].second;

View File

@ -62,7 +62,7 @@ protected:
std::array<bool, MAX_GAMEPADS> last_connection_status{{ false, false, false, false, false, false, false }}; std::array<bool, MAX_GAMEPADS> last_connection_status{{ false, false, false, false, false, false, false }};
std::string m_name_string; std::string m_name_string;
size_t m_max_devices = 0; usz m_max_devices = 0;
int m_trigger_threshold = 0; int m_trigger_threshold = 0;
int m_thumb_threshold = 0; int m_thumb_threshold = 0;
@ -132,7 +132,7 @@ public:
pad_handler m_type; pad_handler m_type;
std::string name_string() const; std::string name_string() const;
size_t max_devices() const; usz max_devices() const;
bool has_config() const; bool has_config() const;
bool has_rumble() const; bool has_rumble() const;
bool has_deadzones() const; bool has_deadzones() const;

View File

@ -1103,7 +1103,7 @@ namespace vm
// Fill stack guards with STACKGRD // Fill stack guards with STACKGRD
if (this->flags & 0x10) 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<u64*>(ptr); u64* target = reinterpret_cast<u64*>(ptr);

View File

@ -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) void np_handler::UserInfo2_to_SceNpUserInfo2(const UserInfo2* user, SceNpUserInfo2* user_info)
{ {
if (user->npId()) if (user->npId())
memcpy(user_info->npId.handle.data, user->npId()->c_str(), std::min(sizeof(user_info->npId.handle.data), static_cast<std::size_t>(user->npId()->size()))); memcpy(user_info->npId.handle.data, user->npId()->c_str(), std::min(sizeof(user_info->npId.handle.data), static_cast<usz>(user->npId()->size())));
if (user->onlineName()) if (user->onlineName())
{ {
user_info->onlineName.set(allocate(sizeof(SceNpOnlineName))); 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<std::size_t>(user->onlineName()->size()))); memcpy(user_info->onlineName->data, user->onlineName()->c_str(), std::min(sizeof(user_info->onlineName->data), static_cast<usz>(user->onlineName()->size())));
} }
if (user->avatarUrl()) if (user->avatarUrl())
{ {
user_info->avatarUrl.set(allocate(sizeof(SceNpAvatarUrl))); 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<std::size_t>(user->avatarUrl()->size()))); memcpy(user_info->avatarUrl->data, user->avatarUrl()->c_str(), std::min(sizeof(user_info->avatarUrl->data), static_cast<usz>(user->avatarUrl()->size())));
} }
} }
@ -283,7 +283,7 @@ void np_handler::RoomMemberUpdateInfo_to_SceNpMatching2RoomMemberUpdateInfo(cons
if (update_info->optData()) if (update_info->optData())
{ {
sce_update_info->optData.length = update_info->optData()->data()->size(); 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); 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()) if (update_info->optData())
{ {
sce_update_info->optData.length = update_info->optData()->data()->size(); 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); sce_update_info->optData.data[i] = update_info->optData()->data()->Get(i);
} }

View File

@ -77,7 +77,7 @@ np_handler::np_handler()
// Init switch map for dns // Init switch map for dns
auto swaps = fmt::split(g_cfg.net.swap_list.to_string(), {"&&"}); 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], {"="}); auto host_and_ip = fmt::split(swaps[i], {"="});
if (host_and_ip.size() != 2) if (host_and_ip.size() != 2)
@ -741,7 +741,7 @@ bool np_handler::reply_get_world_list(u32 req_id, std::vector<u8>& reply_data)
if (!world_list.empty()) if (!world_list.empty())
{ {
world_info->world.set(allocate(sizeof(SceNpMatching2World) * world_list.size())); 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].worldId = world_list[i];
world_info->world[i].numOfLobby = 1; // TODO 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; 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); std::lock_guard lock(mutex_req_results);
match2_req_results[event_key] = std::vector<u8>(size, 0); match2_req_results[event_key] = std::vector<u8>(size, 0);

View File

@ -204,7 +204,7 @@ protected:
return match2_event_cnt.fetch_add(1); return match2_event_cnt.fetch_add(1);
} }
shared_mutex mutex_req_results; 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
rpcn_client rpcn; rpcn_client rpcn;

View File

@ -91,11 +91,11 @@ void rpcn_client::disconnect()
server_info_received = false; 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; u32 num_timeouts = 0;
size_t n_recv = 0; usz n_recv = 0;
while (n_recv != n && !is_abort()) while (n_recv != n && !is_abort())
{ {
std::lock_guard lock(mutex_socket); 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<u8>& packet) bool rpcn_client::send_packet(const std::vector<u8>& packet)
{ {
u32 num_timeouts = 0; u32 num_timeouts = 0;
std::size_t n_sent = 0; usz n_sent = 0;
while (n_sent != packet.size()) while (n_sent != packet.size())
{ {
std::lock_guard lock(mutex_socket); 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); builder.Finish(req_finished);
u8* buf = builder.GetBufferPointer(); u8* buf = builder.GetBufferPointer();
size_t bufsize = builder.GetSize(); usz bufsize = builder.GetSize();
data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize);
memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); 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); builder.Finish(req_finished);
u8* buf = builder.GetBufferPointer(); u8* buf = builder.GetBufferPointer();
size_t bufsize = builder.GetSize(); usz bufsize = builder.GetSize();
data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize);
memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); 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); auto req_finished = CreateLeaveRoomRequest(builder, req->roomId, final_optdata);
builder.Finish(req_finished); builder.Finish(req_finished);
u8* buf = builder.GetBufferPointer(); u8* buf = builder.GetBufferPointer();
size_t bufsize = builder.GetSize(); usz bufsize = builder.GetSize();
data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize);
memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); 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(); auto req_finished = s_req.Finish();
builder.Finish(req_finished); builder.Finish(req_finished);
u8* buf = builder.GetBufferPointer(); u8* buf = builder.GetBufferPointer();
size_t bufsize = builder.GetSize(); usz bufsize = builder.GetSize();
data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32));
memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); 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); builder.Finish(req_finished);
u8* buf = builder.GetBufferPointer(); u8* buf = builder.GetBufferPointer();
size_t bufsize = builder.GetSize(); usz bufsize = builder.GetSize();
data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32));
memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); 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); builder.Finish(req_finished);
u8* buf = builder.GetBufferPointer(); u8* buf = builder.GetBufferPointer();
size_t bufsize = builder.GetSize(); usz bufsize = builder.GetSize();
data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32));
memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); 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); builder.Finish(req_finished);
u8* buf = builder.GetBufferPointer(); u8* buf = builder.GetBufferPointer();
size_t bufsize = builder.GetSize(); usz bufsize = builder.GetSize();
data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32));
memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); 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); builder.Finish(req_finished);
u8* buf = builder.GetBufferPointer(); u8* buf = builder.GetBufferPointer();
size_t bufsize = builder.GetSize(); usz bufsize = builder.GetSize();
data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32));
memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE);

View File

@ -27,7 +27,7 @@ class vec_stream
{ {
public: public:
vec_stream() = delete; vec_stream() = delete;
vec_stream(std::vector<u8>& _vec, size_t initial_index = 0) vec_stream(std::vector<u8>& _vec, usz initial_index = 0)
: vec(_vec) : vec(_vec)
, i(initial_index){}; , i(initial_index){};
bool is_error() const bool is_error() const
@ -86,7 +86,7 @@ public:
{ {
value = reinterpret_cast<le_t<T>>(value); value = reinterpret_cast<le_t<T>>(value);
// resize + memcpy instead? // 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<u8*>(&value) + index)); vec.push_back(*(reinterpret_cast<u8*>(&value) + index));
} }
@ -99,7 +99,7 @@ public:
protected: protected:
std::vector<u8>& vec; std::vector<u8>& vec;
size_t i = 0; usz i = 0;
bool error = false; bool error = false;
}; };
@ -207,7 +207,7 @@ protected:
recvn_fatal, 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<u8>& data); bool get_reply(u32 expected_id, std::vector<u8>& data);

View File

@ -78,7 +78,7 @@ namespace rsx
auto layout = get_subresources_layout(tex); auto layout = get_subresources_layout(tex);
// todo: dont use this function and just get size somehow // todo: dont use this function and just get size somehow
size_t texSize = 0; usz texSize = 0;
for (const auto& l : layout) for (const auto& l : layout)
texSize += l.data.size(); texSize += l.data.size();
@ -104,7 +104,7 @@ namespace rsx
auto layout = get_subresources_layout(tex); auto layout = get_subresources_layout(tex);
// todo: dont use this function and just get size somehow // todo: dont use this function and just get size somehow
size_t texSize = 0; usz texSize = 0;
for (const auto& l : layout) for (const auto& l : layout)
texSize += l.data.size(); texSize += l.data.size();
@ -147,7 +147,7 @@ namespace rsx
{ {
const auto& range = method_registers.current_draw_clause.get_range(); const auto& range = method_registers.current_draw_clause.get_range();
const u32 vertCount = range.count; 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; frame_capture_data::memory_block block;
block.offset = base_address + (range.first * vertStride); block.offset = base_address + (range.first * vertStride);
@ -186,7 +186,7 @@ namespace rsx
const u32 idxCount = range.count; const u32 idxCount = range.count;
const u32 idxAddr = base_addr + (idxFirst * type_size); 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; frame_capture_data::memory_block block;
block.offset = base_address + (idxFirst * type_size); block.offset = base_address + (idxFirst * type_size);

View File

@ -185,7 +185,7 @@ namespace rsx
auto render = get_current_renderer(); auto render = get_current_renderer();
auto last_flip = render->int_flip_index; auto last_flip = render->int_flip_index;
size_t stopIdx = 0; usz stopIdx = 0;
for (const auto& replay_cmd : frame->replay_commands) for (const auto& replay_cmd : frame->replay_commands)
{ {
while (Emu.IsPaused()) while (Emu.IsPaused())

View File

@ -121,7 +121,7 @@ class CgBinaryDisasm
std::string m_path; // used for FP decompiler thread, delete this later std::string m_path; // used for FP decompiler thread, delete this later
u8* m_buffer = nullptr; u8* m_buffer = nullptr;
std::size_t m_buffer_size = 0; usz m_buffer_size = 0;
std::string m_arb_shader; std::string m_arb_shader;
std::string m_glsl_shader; std::string m_glsl_shader;
std::string m_dst_reg_name; std::string m_dst_reg_name;
@ -138,8 +138,8 @@ class CgBinaryDisasm
// VP members // VP members
u32 m_sca_opcode; u32 m_sca_opcode;
u32 m_vec_opcode; u32 m_vec_opcode;
static const size_t m_max_instr_count = 512; static const usz m_max_instr_count = 512;
size_t m_instr_count; usz m_instr_count;
std::vector<u32> m_data; std::vector<u32> m_data;
public: public:
@ -298,7 +298,7 @@ public:
fs::file f(m_path); fs::file f(m_path);
if (!f) return; if (!f) return;
size_t size = f.size(); usz size = f.size();
vm::init(); vm::init();
ptr = vm::alloc(static_cast<u32>(size), vm::main); ptr = vm::alloc(static_cast<u32>(size), vm::main);
f.read(vm::base(ptr), size); f.read(vm::base(ptr), size);

View File

@ -114,8 +114,8 @@ struct temp_register
/** /**
* This class is used to translate RSX Fragment program to GLSL/HLSL code * This class is used to translate RSX Fragment program to GLSL/HLSL code
* Backend with text based shader can subclass this class and implement : * 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 getHalfTypeName(size_t elementCount) = 0; * - virtual std::string getHalfTypeName(usz elementCount) = 0;
* - virtual std::string getFunction(enum class FUNCTION) = 0; * - virtual std::string getFunction(enum class FUNCTION) = 0;
* - virtual std::string saturate(const std::string &code) = 0; * - virtual std::string saturate(const std::string &code) = 0;
* - virtual std::string compareFunction(enum class COMPARE, const std::string &, const std::string &) = 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. /** 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. /** 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 /** returns string calling function where arguments are passed via
* $0 $1 $2 substring. * $0 $1 $2 substring.

View File

@ -135,7 +135,7 @@ namespace program_common
namespace glsl namespace glsl
{ {
static std::string getFloatTypeNameImpl(size_t elementCount) static std::string getFloatTypeNameImpl(usz elementCount)
{ {
switch (elementCount) switch (elementCount)
{ {
@ -152,7 +152,7 @@ namespace glsl
} }
} }
static std::string getHalfTypeNameImpl(size_t elementCount) static std::string getHalfTypeNameImpl(usz elementCount)
{ {
switch (elementCount) switch (elementCount)
{ {

View File

@ -7,12 +7,12 @@
using namespace program_hash_util; 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 // 64-bit Fowler/Noll/Vo FNV-1a hash code
size_t hash = 0xCBF29CE484222325ULL; usz hash = 0xCBF29CE484222325ULL;
const void* instbuffer = program.data.data(); const void* instbuffer = program.data.data();
size_t instIndex = 0; usz instIndex = 0;
bool end = false; bool end = false;
for (unsigned i = 0; i < program.data.size() / 4; i++) 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; 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.output_mask;
hash ^= program.texture_dimensions; hash ^= program.texture_dimensions;
return hash; return hash;
@ -271,7 +271,7 @@ bool vertex_program_compare::operator()(const RSXVertexProgram &binary1, const R
const void* instBuffer1 = binary1.data.data(); const void* instBuffer1 = binary1.data.data();
const void* instBuffer2 = binary2.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++) for (unsigned i = 0; i < binary1.data.size() / 4; i++)
{ {
const auto active = binary1.instruction_mask[instIndex]; const auto active = binary1.instruction_mask[instIndex];
@ -302,10 +302,10 @@ bool fragment_program_utils::is_constant(u32 sourceOperand)
return ((sourceOperand >> 8) & 0x3) == 2; 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; const auto instBuffer = ptr;
size_t instIndex = 0; usz instIndex = 0;
while (true) while (true)
{ {
const v128 inst = v128::loadu(instBuffer, instIndex); const v128 inst = v128::loadu(instBuffer, instIndex);
@ -420,12 +420,12 @@ fragment_program_utils::fragment_program_metadata fragment_program_utils::analys
return result; 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 // 64-bit Fowler/Noll/Vo FNV-1a hash code
size_t hash = 0xCBF29CE484222325ULL; usz hash = 0xCBF29CE484222325ULL;
const void* instbuffer = program.get_data(); const void* instbuffer = program.get_data();
size_t instIndex = 0; usz instIndex = 0;
while (true) while (true)
{ {
const auto inst = v128::loadu(instbuffer, instIndex); 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; 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.ctrl;
hash ^= program.texture_dimensions; hash ^= program.texture_dimensions;
hash ^= program.unnormalized_coords; 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* instBuffer1 = binary1.get_data();
const void* instBuffer2 = binary2.get_data(); const void* instBuffer2 = binary2.get_data();
size_t instIndex = 0; usz instIndex = 0;
while (true) while (true)
{ {
const auto inst1 = v128::loadu(instBuffer1, instIndex); const auto inst1 = v128::loadu(instBuffer1, instIndex);

View File

@ -27,14 +27,14 @@ namespace program_hash_util
u32 referenced_textures_mask; 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); static vertex_program_metadata analyse_vertex_program(const u32* data, u32 entry, RSXVertexProgram& dst_prog);
}; };
struct vertex_program_storage_hash struct vertex_program_storage_hash
{ {
size_t operator()(const RSXVertexProgram &program) const; usz operator()(const RSXVertexProgram &program) const;
}; };
struct vertex_program_compare struct vertex_program_compare
@ -61,16 +61,16 @@ namespace program_hash_util
*/ */
static bool is_constant(u32 sourceOperand); 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 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 struct fragment_program_storage_hash
{ {
size_t operator()(const RSXFragmentProgram &program) const; usz operator()(const RSXFragmentProgram &program) const;
}; };
struct fragment_program_compare 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 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. * - a typedef ExtraData type that will be passed to the buildProgram function.
* It should also contains the following function member : * It should also contains the following function member :
* - static void recompile_fragment_program(RSXFragmentProgram *RSXFP, FragmentProgramData& fragmentProgramData, size_t ID); * - static void recompile_fragment_program(RSXFragmentProgram *RSXFP, FragmentProgramData& fragmentProgramData, usz ID);
* - static void recompile_vertex_program(RSXVertexProgram *RSXVP, VertexProgramData& vertexProgramData, size_t 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 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); * - 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 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<unsigned>(key.vertex_program_id); hashValue ^= rpcs3::hash_base<unsigned>(key.vertex_program_id);
hashValue ^= rpcs3::hash_base<unsigned>(key.fragment_program_id); hashValue ^= rpcs3::hash_base<unsigned>(key.fragment_program_id);
hashValue ^= rpcs3::hash_struct<pipeline_properties>(key.properties); hashValue ^= rpcs3::hash_struct<pipeline_properties>(key.properties);
@ -142,7 +142,7 @@ protected:
shared_mutex m_pipeline_mutex; shared_mutex m_pipeline_mutex;
shared_mutex m_decompiler_mutex; shared_mutex m_decompiler_mutex;
atomic_t<size_t> m_next_id = 0; atomic_t<usz> m_next_id = 0;
bool m_cache_miss_flag; // Set if last lookup did not find any usable cached programs bool m_cache_miss_flag; // Set if last lookup did not find any usable cached programs
binary_to_vertex_program m_vertex_shader_cache; binary_to_vertex_program m_vertex_shader_cache;
@ -407,7 +407,7 @@ public:
f32* dst = dst_buffer.data(); f32* dst = dst_buffer.data();
alignas(16) f32 tmp[4]; 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<char*>(fragment_program.get_data()) + offset_in_fragment_program; char* data = static_cast<char*>(fragment_program.get_data()) + offset_in_fragment_program;
const __m128i vector = _mm_loadu_si128(reinterpret_cast<__m128i*>(data)); const __m128i vector = _mm_loadu_si128(reinterpret_cast<__m128i*>(data));

View File

@ -218,7 +218,7 @@ public:
} }
} }
size_t get_vector_size() const usz get_vector_size() const
{ {
return swizzles[swizzles.size() - 1].length(); return swizzles[swizzles.size() - 1].length();
} }

View File

@ -176,7 +176,7 @@ private:
const auto glyph_data = font_glyph.substr(7); const auto glyph_data = font_glyph.substr(7);
if (glyph_data.length() == 32) 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); const auto line = glyph_data.substr(n * 2, 2);
std::from_chars(line.data(), line.data() + line.size(), this_glyph.plot[n], 16); 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); 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]; const auto &line = entry.plot[j];
if (line == 0) if (line == 0)

View File

@ -317,7 +317,7 @@ namespace
u8 block_size_in_bytes = sizeof(SRC_TYPE); u8 block_size_in_bytes = sizeof(SRC_TYPE);
std::vector<rsx::subresource_layout> result; std::vector<rsx::subresource_layout> result;
size_t offset_in_src = 0; usz offset_in_src = 0;
u8 border_size = border ? (padded_row ? 1 : 4) : 0; u8 border_size = border ? (padded_row ? 1 : 4) : 0;
u32 src_pitch_in_block; u32 src_pitch_in_block;
@ -383,30 +383,30 @@ namespace
} }
template<typename T> template<typename T>
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) pitch == alignment)
{ {
return width_in_block; return width_in_block;
} }
else else
{ {
size_t divided = (pitch + alignment - 1) / alignment; usz divided = (pitch + alignment - 1) / alignment;
return static_cast<u32>(divided * alignment / sizeof(T)); return static_cast<u32>(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) pitch == alignment)
{ {
return width_in_block; return width_in_block;
} }
else else
{ {
size_t divided = (pitch + alignment - 1) / alignment; usz divided = (pitch + alignment - 1) / alignment;
return static_cast<u32>(divided * alignment / block_size_in_bytes); return static_cast<u32>(divided * alignment / block_size_in_bytes);
} }
} }
@ -910,41 +910,41 @@ namespace rsx
return width_in_block * bytes_per_block; 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); format &= ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
size_t block_edge = get_format_block_size_in_texel(format); usz block_edge = get_format_block_size_in_texel(format);
size_t block_size_in_byte = get_format_block_size_in_bytes(format); usz block_size_in_byte = get_format_block_size_in_bytes(format);
size_t height_in_blocks = (height + block_edge - 1) / block_edge; usz height_in_blocks = (height + block_edge - 1) / block_edge;
size_t width_in_blocks = (width + 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) 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); result += align(rowPitch * height_in_blocks * depth, mipmap_alignment);
height_in_blocks = std::max<size_t>(height_in_blocks / 2, 1); height_in_blocks = std::max<usz>(height_in_blocks / 2, 1);
width_in_blocks = std::max<size_t>(width_in_blocks / 2, 1); width_in_blocks = std::max<usz>(width_in_blocks / 2, 1);
} }
// Mipmap, height and width aren't allowed to be zero // Mipmap, height and width aren't allowed to be zero
return (ensure(result) * (cubemap ? 6 : 1)); 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(), return get_placed_texture_storage_size(texture.width(), texture.height(), texture.depth(), texture.format(), texture.mipmap(), texture.cubemap(),
row_pitch_alignment, mipmap_alignment); 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(), return get_placed_texture_storage_size(texture.width(), texture.height(), texture.depth(), texture.format(), texture.mipmap(), texture.cubemap(),
row_pitch_alignment, mipmap_alignment); 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 auto gcm_format = format & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
const bool packed = !(format & CELL_GCM_TEXTURE_LN); const bool packed = !(format & CELL_GCM_TEXTURE_LN);
@ -1001,14 +1001,14 @@ namespace rsx
return size; 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(), return get_texture_size(texture.format(), texture.width(), texture.height(), texture.depth(),
texture.pitch(), texture.get_exact_mipmap_count(), texture.cubemap() ? 6 : 1, texture.pitch(), texture.get_exact_mipmap_count(), texture.cubemap() ? 6 : 1,
texture.border_type() ^ 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(), return get_texture_size(texture.format(), texture.width(), texture.height(), texture.depth(),
texture.pitch(), texture.get_exact_mipmap_count(), texture.cubemap() ? 6 : 1, texture.pitch(), texture.get_exact_mipmap_count(), texture.cubemap() ? 6 : 1,

View File

@ -125,16 +125,16 @@ namespace rsx
bool supports_byteswap; bool supports_byteswap;
bool supports_vtc_decoding; bool supports_vtc_decoding;
bool supports_hw_deswizzle; bool supports_hw_deswizzle;
size_t alignment; usz alignment;
}; };
/** /**
* Get size to store texture in a linear fashion. * Get size to store texture in a linear fashion.
* Storage is assumed to use a rowPitchAlignment boundary for every row of texture. * 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); 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);
size_t get_placed_texture_storage_size(const rsx::fragment_texture &texture, size_t row_pitch_alignment, size_t mipmap_alignment = 0x200); usz get_placed_texture_storage_size(const rsx::fragment_texture &texture, usz row_pitch_alignment, usz 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(const rsx::vertex_texture &texture, usz row_pitch_alignment, usz mipmap_alignment = 0x200);
/** /**
* get all rsx::subresource_layout for texture. * get all rsx::subresource_layout for texture.
@ -162,8 +162,8 @@ namespace rsx
/** /**
* Get number of bytes occupied by texture in RSX mem * Get number of bytes occupied by texture in RSX mem
*/ */
size_t get_texture_size(const rsx::fragment_texture &texture); usz get_texture_size(const rsx::fragment_texture &texture);
size_t get_texture_size(const rsx::vertex_texture &texture); usz get_texture_size(const rsx::vertex_texture &texture);
/** /**
* Get packed pitch * Get packed pitch

View File

@ -9,7 +9,7 @@
/** /**
* This class is used to translate RSX Vertex program to GLSL/HLSL code * This class is used to translate RSX Vertex program to GLSL/HLSL code
* Backend with text based shader can subclass this class and implement : * 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 getFunction(enum class FUNCTION) = 0;
* - virtual std::string compareFunction(enum class COMPARE, const std::string &, const std::string &) = 0; * - virtual std::string compareFunction(enum class COMPARE, const std::string &, const std::string &) = 0;
* - virtual void insertHeader(std::stringstream &OS) = 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_instructions[m_max_instr_count];
Instruction* m_cur_instr; Instruction* m_cur_instr;
size_t m_instr_count; usz m_instr_count;
std::vector<std::string> m_body; std::vector<std::string> m_body;
std::stack<u32> m_call_stack; std::stack<u32> m_call_stack;
@ -91,11 +91,11 @@ struct VertexProgramDecompiler
protected: protected:
/** returns the type name of float vectors. /** 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. /** 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 /** returns string calling function where arguments are passed via
* $0 $1 $2 substring. * $0 $1 $2 substring.

View File

@ -17,10 +17,10 @@ protected:
* Does alloc cross get position ? * Does alloc cross get position ?
*/ */
template<int Alignment> template<int Alignment>
bool can_alloc(size_t size) const bool can_alloc(usz size) const
{ {
size_t alloc_size = align(size, Alignment); usz alloc_size = align(size, Alignment);
size_t aligned_put_pos = align(m_put_pos, Alignment); usz aligned_put_pos = align(m_put_pos, Alignment);
if (aligned_put_pos + alloc_size < m_size) if (aligned_put_pos + alloc_size < m_size)
{ {
// range before get // range before get
@ -45,17 +45,17 @@ protected:
} }
// Grow the buffer to hold at least size bytes // Grow the buffer to hold at least size bytes
virtual bool grow(size_t /*size*/) virtual bool grow(usz /*size*/)
{ {
// Stub // Stub
return false; return false;
} }
size_t m_size; usz m_size;
size_t m_put_pos; // Start of free space usz 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 usz 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; usz m_current_allocated_size;
size_t m_largest_allocated_pool; usz m_largest_allocated_pool;
char* m_name; char* m_name;
public: public:
@ -64,9 +64,9 @@ public:
data_heap(const data_heap&) = delete; data_heap(const data_heap&) = delete;
data_heap(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<char*>(buffer_name); m_name = const_cast<char*>(buffer_name);
@ -81,10 +81,10 @@ public:
} }
template<int Alignment> template<int Alignment>
size_t alloc(size_t size) usz alloc(usz size)
{ {
const size_t alloc_size = align(size, Alignment); const usz alloc_size = align(size, Alignment);
const size_t aligned_put_pos = align(m_put_pos, Alignment); const usz aligned_put_pos = align(m_put_pos, Alignment);
if (!can_alloc<Alignment>(size) && !grow(aligned_put_pos + alloc_size)) if (!can_alloc<Alignment>(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); 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_current_allocated_size += block_length;
m_largest_allocated_pool = std::max(m_largest_allocated_pool, block_length); m_largest_allocated_pool = std::max(m_largest_allocated_pool, block_length);
@ -111,14 +111,14 @@ public:
/** /**
* return current putpos - 1 * 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; return (m_put_pos > 0) ? m_put_pos - 1 : m_size - 1;
} }
virtual bool is_critical() const 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; return (m_current_allocated_size + guard_length) >= m_size;
} }
@ -142,7 +142,7 @@ public:
fmt::throw_exception("m_put_pos == m_get_pos!"); fmt::throw_exception("m_put_pos == m_get_pos!");
} }
size_t size() const usz size() const
{ {
return m_size; return m_size;
} }

View File

@ -19,7 +19,7 @@ namespace rsx
fmt::throw_exception("Wrong color_target"); 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) switch (format)
{ {
@ -41,7 +41,7 @@ namespace rsx
fmt::throw_exception("Unknown color surface format"); 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) switch (format)
{ {

View File

@ -10,8 +10,8 @@ namespace rsx
namespace utility namespace utility
{ {
std::vector<u8> get_rtt_indexes(surface_target color_target); std::vector<u8> get_rtt_indexes(surface_target color_target);
size_t get_aligned_pitch(surface_color_format format, u32 width); usz get_aligned_pitch(surface_color_format format, u32 width);
size_t get_packed_pitch(surface_color_format format, u32 width); usz get_packed_pitch(surface_color_format format, u32 width);
} }
template<typename Traits> template<typename Traits>
@ -426,7 +426,7 @@ namespace rsx
u32 address, u32 address,
format_type format, format_type format,
surface_antialiasing antialias, surface_antialiasing antialias,
size_t width, size_t height, size_t pitch, usz width, usz height, usz pitch,
u8 bpp, u8 bpp,
Args&&... extra_params) Args&&... extra_params)
{ {
@ -638,7 +638,7 @@ namespace rsx
u32 address, u32 address,
surface_color_format color_format, surface_color_format color_format,
surface_antialiasing antialias, surface_antialiasing antialias,
size_t width, size_t height, size_t pitch, usz width, usz height, usz pitch,
Args&&... extra_params) Args&&... extra_params)
{ {
return bind_surface_address<false>( return bind_surface_address<false>(
@ -653,7 +653,7 @@ namespace rsx
u32 address, u32 address,
surface_depth_format2 depth_format, surface_depth_format2 depth_format,
surface_antialiasing antialias, surface_antialiasing antialias,
size_t width, size_t height, size_t pitch, usz width, usz height, usz pitch,
Args&&... extra_params) Args&&... extra_params)
{ {
return bind_surface_address<true>( return bind_surface_address<true>(

View File

@ -426,7 +426,7 @@ namespace rsx
}); });
// Try and optimize by omitting possible overlapped transfers // 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); old_contents[i].init_transfer(target);

View File

@ -82,8 +82,8 @@ namespace rsx
#ifdef TEXTURE_CACHE_DEBUG #ifdef TEXTURE_CACHE_DEBUG
void check_pre_sanity() const void check_pre_sanity() const
{ {
size_t flush_and_unprotect_count = sections_to_flush.size() + sections_to_unprotect.size(); usz flush_and_unprotect_count = sections_to_flush.size() + sections_to_unprotect.size();
size_t exclude_count = sections_to_exclude.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 // 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(); m_cache_update_tag = rsx::get_shared_tag();
} }
template <typename CharT, std::size_t N, typename... Args> template <typename CharT, usz N, typename... Args>
void emit_once(bool error, const CharT(&fmt)[N], const Args&... params) 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...)); 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); rsx_log.warning("%s", *result.first);
} }
template <typename CharT, std::size_t N, typename... Args> template <typename CharT, usz N, typename... Args>
void err_once(const CharT(&fmt)[N], const Args&... params) void err_once(const CharT(&fmt)[N], const Args&... params)
{ {
emit_once(true, fmt, params...); emit_once(true, fmt, params...);
} }
template <typename CharT, std::size_t N, typename... Args> template <typename CharT, usz N, typename... Args>
void warn_once(const CharT(&fmt)[N], const Args&... params) void warn_once(const CharT(&fmt)[N], const Args&... params)
{ {
emit_once(false, fmt, params...); emit_once(false, fmt, params...);
@ -737,7 +737,7 @@ namespace rsx
// naive check that sections are not duplicated in the results // naive check that sections are not duplicated in the results
for (auto &section1 : result.sections) for (auto &section1 : result.sections)
{ {
size_t count = 0; usz count = 0;
for (auto &section2 : result.sections) for (auto &section2 : result.sections)
{ {
if (section1 == section2) count++; if (section1 == section2) count++;

View File

@ -69,17 +69,17 @@ namespace rsx {
// 4GB memory space / 4096 bytes per page = 1048576 pages // 4GB memory space / 4096 bytes per page = 1048576 pages
// Initialized to utils::protection::rw // 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}; per_page_info_t _info[num_pages]{0};
static_assert(static_cast<u32>(utils::protection::rw) == 0, "utils::protection::rw must have value 0 for the above constructor to work"); static_assert(static_cast<u32>(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); 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<u32>(idx * 4096); return static_cast<u32>(idx * 4096);
} }
@ -96,7 +96,7 @@ namespace rsx {
constexpr u32 info_pointer_to_address(const per_page_info_t* ptr) const constexpr u32 info_pointer_to_address(const per_page_info_t* ptr) const
{ {
return index_to_rsx_address(static_cast<size_t>(ptr - _info)); return index_to_rsx_address(static_cast<usz>(ptr - _info));
} }
std::string prot_to_str(utils::protection prot) const std::string prot_to_str(utils::protection prot) const
@ -199,7 +199,7 @@ namespace rsx {
void verify() const void verify() const
{ {
for (size_t idx = 0; idx < num_pages; idx++) for (usz idx = 0; idx < num_pages; idx++)
{ {
auto &elmnt = _info[idx]; auto &elmnt = _info[idx];
if (!elmnt.verify()) if (!elmnt.verify())

View File

@ -28,7 +28,7 @@ namespace rsx
m_size = 0; m_size = 0;
} }
size_t size() const usz size() const
{ {
return m_size; return m_size;
} }
@ -404,11 +404,11 @@ namespace std
template <typename traits> template <typename traits>
struct hash<rsx::texture_cache_predictor_key<traits>> struct hash<rsx::texture_cache_predictor_key<traits>>
{ {
std::size_t operator()(const rsx::texture_cache_predictor_key<traits>& k) const usz operator()(const rsx::texture_cache_predictor_key<traits>& k) const
{ {
size_t result = std::hash<utils::address_range>{}(k.cpu_range); usz result = std::hash<utils::address_range>{}(k.cpu_range);
result ^= static_cast<size_t>(k.format); result ^= static_cast<usz>(k.format);
result ^= (static_cast<size_t>(k.context) << 16); result ^= (static_cast<usz>(k.context) << 16);
return result; return result;
} }
}; };

View File

@ -15,7 +15,7 @@ namespace rsx
* List of Arrays * List of Arrays
* (avoids reallocation without the significant disadvantages of slow iteration through a list) * (avoids reallocation without the significant disadvantages of slow iteration through a list)
*/ */
template <typename section_storage_type, size_t array_size> template <typename section_storage_type, usz array_size>
class ranged_storage_block_list class ranged_storage_block_list
{ {
static_assert(array_size > 0, "array_elements must be positive non-zero"); 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()); return block_for(section.get_section_base());
} }
inline block_type& operator[](size_t pos) inline block_type& operator[](usz pos)
{ {
AUDIT(pos < num_blocks); AUDIT(pos < num_blocks);
return blocks[pos]; return blocks[pos];
@ -917,7 +917,7 @@ namespace rsx
address_range_vector flush_exclusions; // Address ranges that will be skipped during flush address_range_vector flush_exclusions; // Address ranges that will be skipped during flush
predictor_type *m_predictor = nullptr; 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; predictor_entry_type *m_predictor_entry = nullptr;
public: public:

View File

@ -7,12 +7,12 @@
#include "../GCM.h" #include "../GCM.h"
#include "../Common/GLSLCommon.h" #include "../Common/GLSLCommon.h"
std::string GLFragmentDecompilerThread::getFloatTypeName(size_t elementCount) std::string GLFragmentDecompilerThread::getFloatTypeName(usz elementCount)
{ {
return glsl::getFloatTypeNameImpl(elementCount); return glsl::getFloatTypeNameImpl(elementCount);
} }
std::string GLFragmentDecompilerThread::getHalfTypeName(size_t elementCount) std::string GLFragmentDecompilerThread::getHalfTypeName(usz elementCount)
{ {
return glsl::getHalfTypeNameImpl(elementCount); return glsl::getHalfTypeNameImpl(elementCount);
} }
@ -369,7 +369,7 @@ void GLFragmentProgram::Decompile(const RSXFragmentProgram& prog)
PT.type == "samplerCube") PT.type == "samplerCube")
continue; continue;
size_t offset = atoi(PI.name.c_str() + 2); usz offset = atoi(PI.name.c_str() + 2);
FragmentConstantOffsetCache.push_back(offset); FragmentConstantOffsetCache.push_back(offset);
} }
} }

View File

@ -33,8 +33,8 @@ public:
void Task(); void Task();
protected: protected:
std::string getFloatTypeName(size_t elementCount) override; std::string getFloatTypeName(usz elementCount) override;
std::string getHalfTypeName(size_t elementCount) override; std::string getHalfTypeName(usz elementCount) override;
std::string getFunction(FUNCTION) override; std::string getFunction(FUNCTION) override;
std::string compareFunction(COMPARE, const std::string&, const std::string&) override; std::string compareFunction(COMPARE, const std::string&, const std::string&) override;
@ -59,7 +59,7 @@ public:
ParamArray parr; ParamArray parr;
u32 id; u32 id;
gl::glsl::shader shader; gl::glsl::shader shader;
std::vector<size_t> FragmentConstantOffsetCache; std::vector<usz> FragmentConstantOffsetCache;
/** /**
* Decompile a fragment shader located in the PS3's Memory. This function operates synchronously. * Decompile a fragment shader located in the PS3's Memory. This function operates synchronously.

View File

@ -298,13 +298,13 @@ namespace gl
glDrawElements(draw_mode(mode), count, static_cast<GLenum>(type), indices); glDrawElements(draw_mode(mode), count, static_cast<GLenum>(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); indices.bind(buffer::target::element_array);
glDrawElements(draw_mode(mode), count, static_cast<GLenum>(type), reinterpret_cast<GLvoid*>(indices_buffer_offset)); glDrawElements(draw_mode(mode), count, static_cast<GLenum>(type), reinterpret_cast<GLvoid*>(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); buffer_.bind(buffer::target::array);
draw_elements(mode, count, type, indices, indices_buffer_offset); draw_elements(mode, count, type, indices, indices_buffer_offset);

View File

@ -2179,8 +2179,8 @@ public:
void draw_elements(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 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(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(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, 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, usz indices_buffer_offset = 0) const;
void draw_elements(rsx::primitive_type mode, GLsizei count, const GLubyte *indices) 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(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; void draw_elements(rsx::primitive_type mode, GLsizei count, const GLushort *indices) const;

View File

@ -15,13 +15,13 @@ struct GLTraits
using pipeline_properties = void*; using pipeline_properties = void*;
static 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.Decompile(RSXFP);
} }
static 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.Decompile(RSXVP);
} }

View File

@ -140,7 +140,7 @@ struct gl_render_target_traits
std::unique_ptr<gl::render_target> create_new_surface( std::unique_ptr<gl::render_target> create_new_surface(
u32 address, u32 address,
rsx::surface_color_format surface_color_format, 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 rsx::surface_antialiasing antialias
) )
{ {
@ -169,7 +169,7 @@ struct gl_render_target_traits
std::unique_ptr<gl::render_target> create_new_surface( std::unique_ptr<gl::render_target> create_new_surface(
u32 address, u32 address,
rsx::surface_depth_format2 surface_depth_format, 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 rsx::surface_antialiasing antialias
) )
{ {
@ -262,13 +262,13 @@ struct gl_render_target_traits
{} {}
static static
bool surface_is_pitch_compatible(const std::unique_ptr<gl::render_target> &surface, size_t pitch) bool surface_is_pitch_compatible(const std::unique_ptr<gl::render_target> &surface, usz pitch)
{ {
return surface->get_rsx_pitch() == pitch; return surface->get_rsx_pitch() == pitch;
} }
static 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<u16>(pitch)); surface->set_rsx_pitch(static_cast<u16>(pitch));
surface->queue_tag(address); surface->queue_tag(address);
@ -305,7 +305,7 @@ struct gl_render_target_traits
bool int_surface_matches_properties( bool int_surface_matches_properties(
const std::unique_ptr<gl::render_target> &surface, const std::unique_ptr<gl::render_target> &surface,
gl::texture::internal_format format, gl::texture::internal_format format,
size_t width, size_t height, usz width, usz height,
rsx::surface_antialiasing antialias, rsx::surface_antialiasing antialias,
bool check_refs = false) bool check_refs = false)
{ {
@ -321,7 +321,7 @@ struct gl_render_target_traits
bool surface_matches_properties( bool surface_matches_properties(
const std::unique_ptr<gl::render_target> &surface, const std::unique_ptr<gl::render_target> &surface,
rsx::surface_color_format format, rsx::surface_color_format format,
size_t width, size_t height, usz width, usz height,
rsx::surface_antialiasing antialias, rsx::surface_antialiasing antialias,
bool check_refs=false) bool check_refs=false)
{ {
@ -333,7 +333,7 @@ struct gl_render_target_traits
bool surface_matches_properties( bool surface_matches_properties(
const std::unique_ptr<gl::render_target> &surface, const std::unique_ptr<gl::render_target> &surface,
rsx::surface_depth_format2 format, rsx::surface_depth_format2 format,
size_t width, size_t height, usz width, usz height,
rsx::surface_antialiasing antialias, rsx::surface_antialiasing antialias,
bool check_refs = false) bool check_refs = false)
{ {

View File

@ -64,7 +64,7 @@ namespace gl
m_program.link(); 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 }; float scale[] = { scale_x, scale_y };
@ -88,7 +88,7 @@ namespace gl
GlyphManager glyph_source; GlyphManager glyph_source;
auto points = glyph_source.generate_point_map(); 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_text_buffer.data(buffer_size, points.data());
m_offsets = glyph_source.get_glyph_offsets(); m_offsets = glyph_source.get_glyph_offsets();

View File

@ -836,7 +836,7 @@ namespace gl
{ {
// Calculate staging buffer size // Calculate staging buffer size
const u32 aligned_pitch = align<u32>(dst->pitch(), 4); const u32 aligned_pitch = align<u32>(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<std::byte> data_upload_buf(texture_data_sz); std::vector<std::byte> data_upload_buf(texture_data_sz);
// TODO: GL drivers support byteswapping and this should be used instead of doing so manually // TODO: GL drivers support byteswapping and this should be used instead of doing so manually

Some files were not shown because too many files have changed in this diff Show More