From 6b0c9cfdfe6ec2ae07fd6f8668792b4f6d106ebc Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Sat, 17 Oct 2009 23:30:16 +0000 Subject: [PATCH] Added some missing semaphore/mutex resets, and bugfixed the emitter when using a certain type of complex indirect sddressing ( ie, ptr32[addr + (eax*4)] ) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2026 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/x86emitter/inlines.inl | 6 ++++-- common/src/Utilities/ThreadTools.cpp | 1 + pcsx2/MTGS.cpp | 3 +-- pcsx2/System/SysThreads.cpp | 14 +------------- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/common/include/x86emitter/inlines.inl b/common/include/x86emitter/inlines.inl index 5ad9e5f971..8d6e9f1854 100644 --- a/common/include/x86emitter/inlines.inl +++ b/common/include/x86emitter/inlines.inl @@ -232,10 +232,12 @@ namespace x86Emitter else if( Index.IsEmpty() ) { Index = src.Index; - Factor = 1; + Factor = src.Factor; } else if( Index == src.Index ) - Factor++; + { + Factor += src.Factor; + } else pxFailDev( L"x86Emitter: address modifiers cannot have more than two index registers." ); // oops, only 2 regs allowed per ModRm! diff --git a/common/src/Utilities/ThreadTools.cpp b/common/src/Utilities/ThreadTools.cpp index 29c2d3f98c..c7ea455335 100644 --- a/common/src/Utilities/ThreadTools.cpp +++ b/common/src/Utilities/ThreadTools.cpp @@ -144,6 +144,7 @@ void Threading::PersistentThread::Start() Detach(); // clean up previous thread handle, if one exists. FrankenMutex( m_lock_InThread ); + m_sem_event.Reset(); OnStart(); diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index b09c1d2b80..c4ddce3faf 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -282,8 +282,7 @@ void mtgsThreadObject::ExecuteTaskInThread() AtomicExchange(m_RingPos, 0); // stall for a bit to let the MainThread have time to update the g_pGSWritePos. - m_lock_RingRestart.Lock(); - m_lock_RingRestart.Unlock(); + m_lock_RingRestart.Wait(); StateCheckInThread( false ); // disable cancel since the above locks are cancelable already continue; diff --git a/pcsx2/System/SysThreads.cpp b/pcsx2/System/SysThreads.cpp index 0ca5e9e3dc..834f96fe67 100644 --- a/pcsx2/System/SysThreads.cpp +++ b/pcsx2/System/SysThreads.cpp @@ -55,7 +55,7 @@ void SysThreadBase::OnStart() if( !pxAssertDev( m_ExecMode == ExecMode_NoThreadYet, "SysSustainableThread:Start(): Invalid execution mode" ) ) return; m_ResumeEvent.Reset(); - //m_SuspendEvent.Reset(); + FrankenMutex( m_ExecModeMutex ); FrankenMutex( m_RunningLock ); _parent::OnStart(); @@ -228,16 +228,6 @@ void SysThreadBase::OnCleanupInThread() void SysThreadBase::StateCheckInThread( bool isCancelable ) { - // Shortcut for the common case, to avoid unnecessary Mutex locks: - /*if( m_ExecMode == ExecMode_Opened ) - { - if( isCancelable ) TestCancel(); - return; - } - - // Oh, seems we need a full lock, because something special is happening! - ScopedLock locker( m_ExecModeMutex );*/ - switch( m_ExecMode ) { @@ -266,7 +256,6 @@ void SysThreadBase::StateCheckInThread( bool isCancelable ) // fallthrough... case ExecMode_Paused: - //locker.Unlock(); while( m_ExecMode == ExecMode_Paused ) m_ResumeEvent.WaitRaw(); @@ -284,7 +273,6 @@ void SysThreadBase::StateCheckInThread( bool isCancelable ) // fallthrough... case ExecMode_Closed: - //locker.Unlock(); while( m_ExecMode == ExecMode_Closed ) m_ResumeEvent.WaitRaw();