mirror of
https://github.com/azahar-emu/azahar
synced 2025-11-06 23:19:57 +01:00
Fix savestates with the OpenGL renderer
This commit is contained in:
parent
e946e38cd5
commit
18447ac6ac
@ -826,6 +826,18 @@ void System::serialize(Archive& ar, const unsigned int file_version) {
|
|||||||
auto gsp = service_manager->GetService<Service::GSP::GSP_GPU>("gsp::Gpu");
|
auto gsp = service_manager->GetService<Service::GSP::GSP_GPU>("gsp::Gpu");
|
||||||
gpu->SetInterruptHandler(
|
gpu->SetInterruptHandler(
|
||||||
[gsp](Service::GSP::InterruptId interrupt_id) { gsp->SignalInterrupt(interrupt_id); });
|
[gsp](Service::GSP::InterruptId interrupt_id) { gsp->SignalInterrupt(interrupt_id); });
|
||||||
|
|
||||||
|
// Switch the shader cache to the title running when the savestate was created
|
||||||
|
const u32 thread_id = gsp->GetActiveClientThreadId();
|
||||||
|
if (thread_id != std::numeric_limits<u32>::max()) {
|
||||||
|
const auto thread = kernel->GetThreadByID(thread_id);
|
||||||
|
if (thread) {
|
||||||
|
const std::shared_ptr<Kernel::Process> process = thread->owner_process.lock();
|
||||||
|
if (process) {
|
||||||
|
gpu->Renderer().Rasterizer()->SwitchDiskResources(process->codeset->program_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
u32 cheats_pid = cheat_engine.GetConnectedPID();
|
u32 cheats_pid = cheat_engine.GetConnectedPID();
|
||||||
ar & cheats_pid;
|
ar & cheats_pid;
|
||||||
|
|||||||
@ -270,6 +270,9 @@ public:
|
|||||||
/// Retrieves a process from the current list of processes.
|
/// Retrieves a process from the current list of processes.
|
||||||
std::shared_ptr<Process> GetProcessById(u32 process_id) const;
|
std::shared_ptr<Process> GetProcessById(u32 process_id) const;
|
||||||
|
|
||||||
|
/// Retrieves a thread from the current list of threads.
|
||||||
|
std::shared_ptr<Thread> GetThreadByID(u32 thread_id) const;
|
||||||
|
|
||||||
std::span<const std::shared_ptr<Process>> GetProcessList() const {
|
std::span<const std::shared_ptr<Process>> GetProcessList() const {
|
||||||
return process_list;
|
return process_list;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -528,8 +528,20 @@ ThreadManager::~ThreadManager() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::span<const std::shared_ptr<Thread>> ThreadManager::GetThreadList() {
|
std::span<const std::shared_ptr<Thread>> ThreadManager::GetThreadList() const {
|
||||||
return thread_list;
|
return thread_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Thread> KernelSystem::GetThreadByID(u32 thread_id) const {
|
||||||
|
for (u32 core_id = 0; core_id < Core::System::GetInstance().GetNumCores(); core_id++) {
|
||||||
|
const auto thread_list = GetThreadManager(core_id).GetThreadList();
|
||||||
|
for (auto& thread : thread_list) {
|
||||||
|
if (thread->thread_id == thread_id) {
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
|||||||
@ -124,7 +124,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Get a const reference to the thread list for debug use
|
* Get a const reference to the thread list for debug use
|
||||||
*/
|
*/
|
||||||
std::span<const std::shared_ptr<Thread>> GetThreadList();
|
std::span<const std::shared_ptr<Thread>> GetThreadList() const;
|
||||||
|
|
||||||
void SetCPU(Core::ARM_Interface& cpu_) {
|
void SetCPU(Core::ARM_Interface& cpu_) {
|
||||||
cpu = &cpu_;
|
cpu = &cpu_;
|
||||||
|
|||||||
@ -626,6 +626,7 @@ Result GSP_GPU::AcquireGpuRight(const Kernel::HLERequestContext& ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
active_thread_id = session_data->thread_id;
|
active_thread_id = session_data->thread_id;
|
||||||
|
active_client_thread_id = ctx.ClientThread()->thread_id;
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -654,6 +655,7 @@ void GSP_GPU::ReleaseRight(const SessionData* session_data) {
|
|||||||
ASSERT_MSG(active_thread_id == session_data->thread_id,
|
ASSERT_MSG(active_thread_id == session_data->thread_id,
|
||||||
"Wrong thread tried to release GPU right");
|
"Wrong thread tried to release GPU right");
|
||||||
active_thread_id = std::numeric_limits<u32>::max();
|
active_thread_id = std::numeric_limits<u32>::max();
|
||||||
|
active_client_thread_id = std::numeric_limits<u32>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSP_GPU::ReleaseRight(Kernel::HLERequestContext& ctx) {
|
void GSP_GPU::ReleaseRight(Kernel::HLERequestContext& ctx) {
|
||||||
@ -723,6 +725,7 @@ void GSP_GPU::serialize(Archive& ar, const unsigned int) {
|
|||||||
ar& boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
|
ar& boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
|
||||||
ar & shared_memory;
|
ar & shared_memory;
|
||||||
ar & active_thread_id;
|
ar & active_thread_id;
|
||||||
|
ar & active_client_thread_id;
|
||||||
ar & first_initialization;
|
ar & first_initialization;
|
||||||
ar & used_thread_ids;
|
ar & used_thread_ids;
|
||||||
ar & saved_vram;
|
ar & saved_vram;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2014 Citra Emulator Project
|
// Copyright Citra Emulator Project / Azahar Emulator Project
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
@ -123,6 +123,13 @@ public:
|
|||||||
return active_thread_id;
|
return active_thread_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retreives the ID of the client thread with GPU rights.
|
||||||
|
*/
|
||||||
|
u32 GetActiveClientThreadId() {
|
||||||
|
return active_client_thread_id;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Signals that the specified interrupt type has occurred to userland code for the specified GSP
|
* Signals that the specified interrupt type has occurred to userland code for the specified GSP
|
||||||
@ -378,6 +385,9 @@ private:
|
|||||||
/// Thread id that currently has GPU rights or std::numeric_limits<u32>::max() if none.
|
/// Thread id that currently has GPU rights or std::numeric_limits<u32>::max() if none.
|
||||||
u32 active_thread_id = std::numeric_limits<u32>::max();
|
u32 active_thread_id = std::numeric_limits<u32>::max();
|
||||||
|
|
||||||
|
/// Thread id of the client thread that has GPU rights
|
||||||
|
u32 active_client_thread_id = std::numeric_limits<u32>::max();
|
||||||
|
|
||||||
bool first_initialization = true;
|
bool first_initialization = true;
|
||||||
|
|
||||||
/// VRAM copy saved using SaveVramSysArea.
|
/// VRAM copy saved using SaveVramSysArea.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user