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

@ -7,6 +7,7 @@
#include "Emu/Cell/lv2/sys_process.h"
#include "sysPrxForUser.h"
#include "util/media_utils.h"
#include "util/init_mutex.hpp"
#ifdef _MSC_VER
#pragma warning(push, 0)
@ -173,6 +174,7 @@ struct vdec_context final
static const u32 id_base = 0xf0000000;
static const u32 id_step = 0x00000100;
static const u32 id_count = 1024;
SAVESTATE_INIT_POS(24);
u32 handle = 0;
@ -627,7 +629,43 @@ struct vdec_context final
}
};
static void vdecEntry(ppu_thread& ppu, u32 vid)
struct vdec_creation_lock
{
stx::init_mutex locked;
vdec_creation_lock()
{
locked.init();
}
};
extern bool try_lock_vdec_context_creation()
{
bool exist = false;
auto& lock = g_fxo->get<vdec_creation_lock>();
auto reset = lock.locked.reset();
if (reset)
{
bool context_exists = false;
idm::select<vdec_context>([&](u32, vdec_context&)
{
context_exists = true;
});
if (context_exists)
{
reset.set_init();
return false;
}
}
return true;
}
extern void vdecEntry(ppu_thread& ppu, u32 vid)
{
idm::get<vdec_context>(vid)->exec(ppu, vid);
@ -856,9 +894,20 @@ static error_code vdecOpen(ppu_thread& ppu, T type, U res, vm::cptr<CellVdecCb>
}
// Create decoder context
const u32 vid = idm::make<vdec_context>(type->codecType, type->profileLevel, res->memAddr, res->memSize, cb->cbFunc, cb->cbArg);
std::shared_ptr<vdec_context> vdec;
if (auto access = g_fxo->get<vdec_creation_lock>().locked.access(); access)
{
vdec = idm::make_ptr<vdec_context>(type->codecType, type->profileLevel, res->memAddr, res->memSize, cb->cbFunc, cb->cbArg);
}
else
{
ppu.state += cpu_flag::again;
return {};
}
const u32 vid = idm::last_id();
auto vdec = idm::get<vdec_context>(vid);
ensure(vdec);
vdec->handle = vid;