From 75f68c48605aa09e183b3a2c390b43aa9a0d5d0e Mon Sep 17 00:00:00 2001 From: Subv Date: Tue, 2 Jan 2018 12:09:43 -0500 Subject: [PATCH] Services/GSP: Mark the thread ids as unused when a GSP session is destroyed. This fixes the games that call RegisterInterruptRelayQueue and UnregisterInterruptRelayQueue frequently. --- src/core/hle/service/gsp/gsp_gpu.cpp | 8 +++++--- src/core/hle/service/gsp/gsp_gpu.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/hle/service/gsp/gsp_gpu.cpp b/src/core/hle/service/gsp/gsp_gpu.cpp index 7156f3f5ce..41de8f5619 100644 --- a/src/core/hle/service/gsp/gsp_gpu.cpp +++ b/src/core/hle/service/gsp/gsp_gpu.cpp @@ -362,12 +362,9 @@ void GSP_GPU::UnregisterInterruptRelayQueue(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x14, 0, 0); SessionData* session_data = GetSessionData(ctx.Session()); - session_data->thread_id = 0; session_data->interrupt_event = nullptr; session_data->registered = false; - // TODO(Subv): Reset next_thread_id so that it doesn't go past the maximum of 4. - IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(RESULT_SUCCESS); @@ -768,5 +765,10 @@ SessionData::SessionData() { used_thread_ids[thread_id] = true; } +SessionData::~SessionData() { + // Free the thread id slot so that other sessions can use it. + used_thread_ids[thread_id] = false; +} + } // namespace GSP } // namespace Service diff --git a/src/core/hle/service/gsp/gsp_gpu.h b/src/core/hle/service/gsp/gsp_gpu.h index c057dffc42..55c2343a44 100644 --- a/src/core/hle/service/gsp/gsp_gpu.h +++ b/src/core/hle/service/gsp/gsp_gpu.h @@ -181,6 +181,7 @@ static_assert(sizeof(CommandBuffer) == 0x200, "CommandBuffer struct has incorrec struct SessionData : public Kernel::SessionRequestHandler::SessionDataBase { SessionData(); + ~SessionData(); /// Event triggered when GSP interrupt has been signalled Kernel::SharedPtr interrupt_event;