From ff359ed11883dd32a53bcf1e0541bcf5fab2715f Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 26 Apr 2015 01:56:58 +0300 Subject: [PATCH] SPU Interpreter2 initialization fix --- rpcs3/Emu/Cell/SPUThread.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 8548dea2d8..477001c8ec 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -26,11 +26,17 @@ const g_spu_imm_table_t g_spu_imm; class spu_inter_func_list_t { - std::array funcs; + std::array funcs = {}; + + std::mutex m_mutex; public: - spu_inter_func_list_t() + void initialize() { + std::lock_guard lock(m_mutex); + + if (funcs[0]) return; // check if already initialized + auto inter = new SPUInterpreter2; SPUDecoder dec(*inter); @@ -49,7 +55,7 @@ public: return funcs[opcode >> 21]; } } -const g_spu_inter_func_list; +g_spu_inter_func_list; SPUThread& GetCurrentSPUThread() { @@ -189,6 +195,7 @@ void SPUThread::DoRun() case 1: // alternative interpreter { + g_spu_inter_func_list.initialize(); // initialize helper table break; }