mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 15:01:28 +12:00
Fix idm::allocate_id at fixed position
This commit is contained in:
parent
72ed2f1d43
commit
526aaf7302
4 changed files with 26 additions and 10 deletions
|
@ -3019,7 +3019,7 @@ std::pair<std::shared_ptr<lv2_overlay>, CellError> ppu_load_overlay(const ppu_ex
|
||||||
|
|
||||||
if (!ar && !virtual_load)
|
if (!ar && !virtual_load)
|
||||||
{
|
{
|
||||||
idm::import_existing<lv2_obj, lv2_overlay>(ovlm);
|
ensure(idm::import_existing<lv2_obj, lv2_overlay>(ovlm));
|
||||||
try_spawn_ppu_if_exclusive_program(*ovlm);
|
try_spawn_ppu_if_exclusive_program(*ovlm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,8 +227,8 @@ lv2_spu_group::lv2_spu_group(utils::serial& ar) noexcept
|
||||||
if (ar.pop<bool>())
|
if (ar.pop<bool>())
|
||||||
{
|
{
|
||||||
ar(id_manager::g_id);
|
ar(id_manager::g_id);
|
||||||
thread = std::make_shared<named_thread<spu_thread>>(ar, this);
|
thread = std::make_shared<named_thread<spu_thread>>(stx::launch_retainer{}, ar, this);
|
||||||
idm::import_existing<named_thread<spu_thread>>(thread, idm::last_id());
|
ensure(idm::import_existing<named_thread<spu_thread>>(thread, idm::last_id()));
|
||||||
running += !thread->stop_flag_removal_protection;
|
running += !thread->stop_flag_removal_protection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,13 @@ std::vector<std::pair<u128, id_manager::typeinfo>>& id_manager::get_typeinfo_map
|
||||||
|
|
||||||
idm::map_data* idm::allocate_id(std::vector<map_data>& vec, u32 type_id, u32 dst_id, u32 base, u32 step, u32 count, bool uses_lowest_id, std::pair<u32, u32> invl_range)
|
idm::map_data* idm::allocate_id(std::vector<map_data>& vec, u32 type_id, u32 dst_id, u32 base, u32 step, u32 count, bool uses_lowest_id, std::pair<u32, u32> invl_range)
|
||||||
{
|
{
|
||||||
if (const u32 index = id_manager::get_index(dst_id, base, step, count, invl_range); index < count)
|
if (dst_id != (base ? 0 : u32{umax}))
|
||||||
{
|
{
|
||||||
// Fixed position construction
|
// Fixed position construction
|
||||||
ensure(index < vec.size());
|
const u32 index = id_manager::get_index(dst_id, base, step, count, invl_range);
|
||||||
|
ensure(index < count);
|
||||||
|
|
||||||
|
vec.resize(std::max<usz>(vec.size(), index + 1));
|
||||||
|
|
||||||
if (vec[index].second)
|
if (vec[index].second)
|
||||||
{
|
{
|
||||||
|
|
|
@ -102,13 +102,26 @@ namespace id_manager
|
||||||
template <typename T, typename = void>
|
template <typename T, typename = void>
|
||||||
struct id_traits_load_func
|
struct id_traits_load_func
|
||||||
{
|
{
|
||||||
static constexpr std::shared_ptr<void>(*load)(utils::serial&) = [](utils::serial& ar) -> std::shared_ptr<void> { return std::make_shared<T>(stx::exact_t<utils::serial&>(ar)); };
|
static constexpr std::shared_ptr<void>(*load)(utils::serial&) = [](utils::serial& ar) -> std::shared_ptr<void>
|
||||||
|
{
|
||||||
|
if constexpr (std::is_constructible_v<T, stx::exact_t<const stx::launch_retainer&>, stx::exact_t<utils::serial&>>)
|
||||||
|
{
|
||||||
|
return std::make_shared<T>(stx::launch_retainer{}, stx::exact_t<utils::serial&>(ar));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return std::make_shared<T>(stx::exact_t<utils::serial&>(ar));
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct id_traits_load_func<T, std::void_t<decltype(&T::load)>>
|
struct id_traits_load_func<T, std::void_t<decltype(&T::load)>>
|
||||||
{
|
{
|
||||||
static constexpr std::shared_ptr<void>(*load)(utils::serial&) = [](utils::serial& ar) -> std::shared_ptr<void> { return T::load(stx::exact_t<utils::serial&>(ar)); };
|
static constexpr std::shared_ptr<void>(*load)(utils::serial&) = [](utils::serial& ar) -> std::shared_ptr<void>
|
||||||
|
{
|
||||||
|
return T::load(stx::exact_t<utils::serial&>(ar));
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, typename = void>
|
template <typename T, typename = void>
|
||||||
|
@ -354,10 +367,10 @@ namespace id_manager
|
||||||
|
|
||||||
id_map& operator=(thread_state state) noexcept requires (std::is_assignable_v<T&, thread_state>)
|
id_map& operator=(thread_state state) noexcept requires (std::is_assignable_v<T&, thread_state>)
|
||||||
{
|
{
|
||||||
if (private_copy.size() != vec.size())
|
private_copy.clear();
|
||||||
{
|
|
||||||
private_copy.clear();
|
|
||||||
|
|
||||||
|
if (!vec.empty() || !private_copy.empty())
|
||||||
|
{
|
||||||
reader_lock lock(g_mutex);
|
reader_lock lock(g_mutex);
|
||||||
|
|
||||||
// Save all entries
|
// Save all entries
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue