diff --git a/rpcs3/Emu/GS/GL/GLFragmentProgram.h b/rpcs3/Emu/GS/GL/GLFragmentProgram.h index 9a284c6941..77397ae3da 100644 --- a/rpcs3/Emu/GS/GL/GLFragmentProgram.h +++ b/rpcs3/Emu/GS/GL/GLFragmentProgram.h @@ -155,7 +155,7 @@ public: /** * Asynchronously decompile a fragment shader located in the PS3's Memory. - * When this function is called you must call Wait before GetShaderText() will return valid data. + * When this function is called you must call Wait() before GetShaderText() will return valid data. * @param prog RSXShaderProgram specifying the location and size of the shader in memory */ void DecompileAsync(RSXShaderProgram& prog); diff --git a/rpcs3/Emu/GS/GL/GLGSRender.cpp b/rpcs3/Emu/GS/GL/GLGSRender.cpp index 8f927af846..70851051ed 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.cpp +++ b/rpcs3/Emu/GS/GL/GLGSRender.cpp @@ -396,7 +396,8 @@ bool GLGSRender::LoadProgram() if(m_fp_buf_num == -1) { ConLog.Warning("FP not found in buffer!"); - m_shader_prog.Decompile(*m_cur_shader_prog); + m_shader_prog.DecompileAsync(*m_cur_shader_prog); + m_shader_prog.Wait(); m_shader_prog.Compile(); checkForGlError("m_shader_prog.Compile"); @@ -407,7 +408,7 @@ bool GLGSRender::LoadProgram() if(m_vp_buf_num == -1) { ConLog.Warning("VP not found in buffer!"); - m_vertex_prog.Decompile(*m_cur_vertex_prog); + m_vertex_prog.DecompileAsync(*m_cur_vertex_prog); m_vertex_prog.Wait(); m_vertex_prog.Compile(); checkForGlError("m_vertex_prog.Compile"); diff --git a/rpcs3/Emu/GS/GL/GLVertexProgram.cpp b/rpcs3/Emu/GS/GL/GLVertexProgram.cpp index de73bda412..9762f9794d 100644 --- a/rpcs3/Emu/GS/GL/GLVertexProgram.cpp +++ b/rpcs3/Emu/GS/GL/GLVertexProgram.cpp @@ -466,15 +466,25 @@ GLVertexProgram::~GLVertexProgram() Delete(); } +void GLVertexProgram::Wait() +{ + if(m_decompiler_thread && m_decompiler_thread->IsAlive()) + { + m_decompiler_thread->Join(); + } +} + void GLVertexProgram::Decompile(RSXVertexProgram& prog) { -#if 0 - GLVertexDecompilerThread(data, shader, parr).Entry(); -#else - if(m_decompiler_thread) + GLVertexDecompilerThread(prog.data, shader, parr); +} + +void GLVertexProgram::DecompileAsync(RSXVertexProgram& prog) +{ + if (m_decompiler_thread) { Wait(); - if(m_decompiler_thread->IsAlive()) + if (m_decompiler_thread->IsAlive()) { m_decompiler_thread->Stop(); } @@ -485,7 +495,6 @@ void GLVertexProgram::Decompile(RSXVertexProgram& prog) m_decompiler_thread = new GLVertexDecompilerThread(prog.data, shader, parr); m_decompiler_thread->Start(); -#endif } void GLVertexProgram::Compile() diff --git a/rpcs3/Emu/GS/GL/GLVertexProgram.h b/rpcs3/Emu/GS/GL/GLVertexProgram.h index 117e7f4082..a74a2cd066 100644 --- a/rpcs3/Emu/GS/GL/GLVertexProgram.h +++ b/rpcs3/Emu/GS/GL/GLVertexProgram.h @@ -172,10 +172,9 @@ struct GLVertexDecompilerThread : public ThreadBase virtual void Task(); }; -struct GLVertexProgram +class GLVertexProgram { - GLVertexDecompilerThread* m_decompiler_thread; - +public: GLVertexProgram(); ~GLVertexProgram(); @@ -183,15 +182,12 @@ struct GLVertexProgram u32 id; std::string shader; - void Wait() - { - if(m_decompiler_thread && m_decompiler_thread->IsAlive()) - { - m_decompiler_thread->Join(); - } - } - void Decompile(RSXVertexProgram& prog); + void DecompileAsync(RSXVertexProgram& prog); + void Wait(); void Compile(); + +private: + GLVertexDecompilerThread* m_decompiler_thread; void Delete(); };