From 2f414f96bf9a48c47878e5aff0b9141a11d76b24 Mon Sep 17 00:00:00 2001 From: Jake Date: Tue, 16 Jan 2018 21:51:58 -0600 Subject: [PATCH] rsx: fix potential hang during thread close --- rpcs3/Emu/RSX/GSRender.cpp | 2 ++ rpcs3/Emu/RSX/RSXThread.cpp | 7 ++++--- rpcs3/Emu/RSX/RSXThread.h | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/RSX/GSRender.cpp b/rpcs3/Emu/RSX/GSRender.cpp index 0969294a72..888b704e78 100644 --- a/rpcs3/Emu/RSX/GSRender.cpp +++ b/rpcs3/Emu/RSX/GSRender.cpp @@ -41,6 +41,8 @@ void GSRender::on_exit() { if (m_frame) { + m_frame->disable_wm_event_queue(); + m_frame->clear_wm_events(); m_frame->delete_context(m_context); m_context = nullptr; } diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index eced03add3..e4b1c48286 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -368,7 +368,7 @@ namespace rsx vblank_count = 0; // TODO: exit condition - while (!Emu.IsStopped()) + while (!Emu.IsStopped() && !m_rsx_thread_exiting) { if (get_system_time() - start_time > vblank_count * 1000000 / 60) { @@ -389,7 +389,7 @@ namespace rsx continue; } - while (Emu.IsPaused()) + while (Emu.IsPaused() && !m_rsx_thread_exiting) std::this_thread::sleep_for(10ms); std::this_thread::sleep_for(1ms); // hack @@ -772,6 +772,7 @@ namespace rsx void thread::on_exit() { + m_rsx_thread_exiting = true; if (m_vblank_thread) { m_vblank_thread->join(); @@ -1618,7 +1619,7 @@ namespace rsx memset(display_buffers, 0, sizeof(display_buffers)); - m_used_gcm_commands.clear(); + m_rsx_thread_exiting = false; on_init_rsx(); start_thread(fxm::get()); diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index 164bc66400..44901e5f90 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -209,6 +209,7 @@ namespace rsx std::shared_ptr m_vblank_thread; protected: + atomic_t m_rsx_thread_exiting{false}; std::stack m_call_stack; std::array vertex_push_buffers; std::vector element_push_buffer; @@ -316,7 +317,6 @@ namespace rsx u64 vblank_count; public: - std::set m_used_gcm_commands; bool invalid_command_interrupt_raised = false; bool sync_point_request = false; bool in_begin_end = false;