Savestates Support For PS3 Emulation (#10478)

This commit is contained in:
Elad Ashkenazi 2022-07-04 16:02:17 +03:00 committed by GitHub
parent 969b9eb89d
commit fcd297ffb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
154 changed files with 4948 additions and 635 deletions

View file

@ -4,15 +4,40 @@
shared_mutex id_manager::g_mutex;
thread_local DECLARE(idm::g_id);
idm::map_data* idm::allocate_id(std::vector<map_data>& vec, u32 type_id, u32 base, u32 step, u32 count, std::pair<u32, u32> invl_range)
namespace id_manager
{
thread_local u32 g_id = 0;
}
std::vector<std::pair<u128, id_manager::typeinfo>>& id_manager::get_typeinfo_map()
{
// Magic static
static std::vector<std::pair<u128, id_manager::typeinfo>> s_map;
return s_map;
}
idm::map_data* idm::allocate_id(std::vector<map_data>& vec, u32 type_id, u32 dst_id, u32 base, u32 step, u32 count, std::pair<u32, u32> invl_range)
{
if (const u32 index = id_manager::get_index(dst_id, base, step, count, invl_range); index < count)
{
// Fixed position construction
ensure(index < vec.size());
if (vec[index].second)
{
return nullptr;
}
id_manager::g_id = dst_id;
vec[index] = {id_manager::id_key(dst_id, type_id), nullptr};
return &vec[index];
}
if (vec.size() < count)
{
// Try to emplace back
const u32 _next = base + step * ::size32(vec);
g_id = _next;
id_manager::g_id = _next;
vec.emplace_back(id_manager::id_key(_next, type_id), nullptr);
return &vec.back();
}
@ -27,7 +52,7 @@ idm::map_data* idm::allocate_id(std::vector<map_data>& vec, u32 type_id, u32 ba
{
// Incremenet ID invalidation counter
const u32 id = next | ((ptr->first + (1u << invl_range.first)) & (invl_range.second ? (((1u << invl_range.second) - 1) << invl_range.first) : 0));
g_id = id;
id_manager::g_id = id;
ptr->first = id_manager::id_key(id, type_id);
return ptr;
}