From 30494c06a4c8f4277a6919869975e78b001092fd Mon Sep 17 00:00:00 2001 From: Hamish Milne Date: Mon, 30 Dec 2019 12:45:22 +0000 Subject: [PATCH] Serialize GSP service --- TODO | 3 ++- src/core/hle/service/gsp/gsp.cpp | 2 +- src/core/hle/service/gsp/gsp_gpu.cpp | 5 +++++ src/core/hle/service/gsp/gsp_gpu.h | 24 ++++++++++++++++++++++++ src/core/hle/service/gsp/gsp_lcd.cpp | 3 +++ src/core/hle/service/gsp/gsp_lcd.h | 2 ++ 6 files changed, 37 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 45e6ae3b7..fa627b214 100644 --- a/TODO +++ b/TODO @@ -81,7 +81,8 @@ ✔ ERR @done(19-12-26 18:14) ✔ FRD @done(19-12-26 19:09) ✔ FS @done(19-12-27 11:46) - ☐ GSP + ✔ GSP @done(19-12-30 12:45) + ☐ Fix the global weak_ptr to gsp ☐ HID ☐ HTTP ☐ IR diff --git a/src/core/hle/service/gsp/gsp.cpp b/src/core/hle/service/gsp/gsp.cpp index 4291b9971..3d3f497b2 100644 --- a/src/core/hle/service/gsp/gsp.cpp +++ b/src/core/hle/service/gsp/gsp.cpp @@ -10,7 +10,7 @@ namespace Service::GSP { -static std::weak_ptr gsp_gpu; +static std::weak_ptr gsp_gpu; // TODO: Fix this for the love of god void SignalInterrupt(InterruptId interrupt_id) { auto gpu = gsp_gpu.lock(); diff --git a/src/core/hle/service/gsp/gsp_gpu.cpp b/src/core/hle/service/gsp/gsp_gpu.cpp index 33558fe10..78d84499b 100644 --- a/src/core/hle/service/gsp/gsp_gpu.cpp +++ b/src/core/hle/service/gsp/gsp_gpu.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include "common/archives.h" #include "common/bit_field.h" #include "common/microprofile.h" #include "common/swap.h" @@ -21,6 +22,10 @@ #include "video_core/debug_utils/debug_utils.h" #include "video_core/gpu_debugger.h" +SERIALIZE_EXPORT_IMPL(Service::GSP::SessionData) +SERIALIZE_EXPORT_IMPL(Service::GSP::GSP_GPU) +SERVICE_CONSTRUCT_IMPL(Service::GSP::GSP_GPU) + // Main graphics debugger object - TODO: Here is probably not the best place for this GraphicsDebugger g_debugger; diff --git a/src/core/hle/service/gsp/gsp_gpu.h b/src/core/hle/service/gsp/gsp_gpu.h index 8b43b9cea..d1f2c0742 100644 --- a/src/core/hle/service/gsp/gsp_gpu.h +++ b/src/core/hle/service/gsp/gsp_gpu.h @@ -199,6 +199,16 @@ public: u32 thread_id; /// Whether RegisterInterruptRelayQueue was called for this session bool registered = false; + +private: + template + void serialize(Archive& ar, const unsigned int) { + ar& gsp; + ar& interrupt_event; + ar& thread_id; + ar& registered; + } + friend class boost::serialization::access; }; class GSP_GPU final : public ServiceFramework { @@ -431,8 +441,22 @@ private: std::array used_thread_ids = {false, false, false, false}; friend class SessionData; + + template + void serialize(Archive& ar, const unsigned int) { + ar& shared_memory; + ar& active_thread_id; + ar& first_initialization; + ar& used_thread_ids; + } + + friend class boost::serialization::access; }; ResultCode SetBufferSwap(u32 screen_id, const FrameBufferInfo& info); } // namespace Service::GSP + +BOOST_CLASS_EXPORT_KEY(Service::GSP::SessionData) +BOOST_CLASS_EXPORT_KEY(Service::GSP::GSP_GPU) +SERVICE_CONSTRUCT(Service::GSP::GSP_GPU) diff --git a/src/core/hle/service/gsp/gsp_lcd.cpp b/src/core/hle/service/gsp/gsp_lcd.cpp index d795b8716..67a2e7628 100644 --- a/src/core/hle/service/gsp/gsp_lcd.cpp +++ b/src/core/hle/service/gsp/gsp_lcd.cpp @@ -2,9 +2,12 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/archives.h" #include "core/hle/ipc_helpers.h" #include "core/hle/service/gsp/gsp_lcd.h" +SERIALIZE_EXPORT_IMPL(Service::GSP::GSP_LCD) + namespace Service::GSP { GSP_LCD::GSP_LCD() : ServiceFramework("gsp::Lcd") { diff --git a/src/core/hle/service/gsp/gsp_lcd.h b/src/core/hle/service/gsp/gsp_lcd.h index 24e57fb42..781d9dba8 100644 --- a/src/core/hle/service/gsp/gsp_lcd.h +++ b/src/core/hle/service/gsp/gsp_lcd.h @@ -15,3 +15,5 @@ public: }; } // namespace Service::GSP + +BOOST_CLASS_EXPORT_KEY(Service::GSP::GSP_LCD)