mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-01-31 01:25:18 +01:00
Implement sceNpMatching2GetMemoryInfo
This commit is contained in:
@@ -616,9 +616,9 @@ error_code sceNpMatching2CreateServerContext(
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
error_code sceNpMatching2GetMemoryInfo(vm::ptr<SceNpMatching2MemoryInfo> memInfo) // TODO
|
||||
error_code sceNpMatching2GetMemoryInfo(vm::ptr<SceNpMatching2MemoryInfo> memInfo)
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetMemoryInfo(memInfo=*0x%x)", memInfo);
|
||||
sceNp2.warning("sceNpMatching2GetMemoryInfo(memInfo=*0x%x)", memInfo);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
@@ -627,6 +627,14 @@ error_code sceNpMatching2GetMemoryInfo(vm::ptr<SceNpMatching2MemoryInfo> memInfo
|
||||
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
if (!memInfo)
|
||||
{
|
||||
return SCE_NP_MATCHING2_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
SceNpMatching2MemoryInfo mem_info = nph.get_memory_info();
|
||||
*memInfo = mem_info;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,11 @@ namespace np
|
||||
m_allocs.clear();
|
||||
}
|
||||
|
||||
std::tuple<u32, u32, u32> get_stats() const
|
||||
{
|
||||
return {m_size, m_size - m_avail, m_max_usage};
|
||||
}
|
||||
|
||||
u32 allocate(u32 size)
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
@@ -82,6 +87,12 @@ namespace np
|
||||
m_allocs.emplace(last_free, alloc_size);
|
||||
m_avail -= alloc_size;
|
||||
|
||||
const u32 usage = m_size - m_avail;
|
||||
if (usage > m_max_usage)
|
||||
{
|
||||
m_max_usage = usage;
|
||||
}
|
||||
|
||||
memset((static_cast<u8*>(m_pool.get_ptr())) + last_free, 0, alloc_size);
|
||||
|
||||
np_mem_allocator.trace("Allocation off:%d size:%d psize:%d, pavail:%d", last_free, alloc_size, m_size, m_avail);
|
||||
@@ -121,6 +132,7 @@ namespace np
|
||||
vm::ptr<void> m_pool{};
|
||||
u32 m_size = 0;
|
||||
u32 m_avail = 0;
|
||||
u32 m_max_usage = 0;
|
||||
std::map<u32, u32> m_allocs{}; // offset/size
|
||||
};
|
||||
} // namespace np
|
||||
|
||||
@@ -1764,4 +1764,16 @@ namespace np
|
||||
}
|
||||
}
|
||||
|
||||
SceNpMatching2MemoryInfo np_handler::get_memory_info() const
|
||||
{
|
||||
auto [m_size, m_usage, m_max_usage] = np_memory.get_stats();
|
||||
|
||||
SceNpMatching2MemoryInfo mem_info{};
|
||||
mem_info.totalMemSize = m_size;
|
||||
mem_info.curMemUsage = m_usage;
|
||||
mem_info.maxMemUsage = m_max_usage;
|
||||
|
||||
return mem_info;
|
||||
}
|
||||
|
||||
} // namespace np
|
||||
|
||||
@@ -262,6 +262,7 @@ namespace np
|
||||
u32 add_players_to_history(const SceNpId* npids, const char* description, u32 count);
|
||||
u32 get_players_history_count(u32 options);
|
||||
bool get_player_history_entry(u32 options, u32 index, SceNpId* npid);
|
||||
SceNpMatching2MemoryInfo get_memory_info() const;
|
||||
error_code abort_request(u32 req_id);
|
||||
|
||||
// For signaling
|
||||
|
||||
Reference in New Issue
Block a user