Remove reader_lock executed in every instruction by RSX

Use optimistic double check instead, use one load instruction for the check to be atomic

+ Read emu status once every FIFO iteration
This commit is contained in:
eladash 2019-03-31 18:56:27 +03:00 committed by Ivan
parent f25587d24c
commit 888cb9d673

View file

@ -527,7 +527,7 @@ namespace rsx
fesetround(FE_TONEAREST); fesetround(FE_TONEAREST);
// TODO: exit condition // TODO: exit condition
while (!Emu.IsStopped()) while (true)
{ {
// Wait for external pause events // Wait for external pause events
if (external_interrupt_lock.load()) if (external_interrupt_lock.load())
@ -536,13 +536,6 @@ namespace rsx
while (external_interrupt_lock.load()) _mm_pause(); while (external_interrupt_lock.load()) _mm_pause();
} }
// Idle if emulation paused
if (Emu.IsPaused())
{
std::this_thread::sleep_for(1ms);
continue;
}
// Note a possible rollback address // Note a possible rollback address
if (sync_point_request) if (sync_point_request)
{ {
@ -559,6 +552,20 @@ namespace rsx
// Execute FIFO queue // Execute FIFO queue
run_FIFO(); run_FIFO();
if (!Emu.IsRunning())
{
// Idle if emulation paused
while (Emu.IsPaused())
{
std::this_thread::sleep_for(1ms);
}
if (Emu.IsStopped())
{
break;
}
}
} }
} }
@ -900,12 +907,14 @@ namespace rsx
if (!in_begin_end && state != FIFO_state::lock_wait) if (!in_begin_end && state != FIFO_state::lock_wait)
{ {
reader_lock lock(m_mtx_task); if (atomic_storage<u32>::load(m_invalidated_memory_range.end) != 0)
if (m_invalidated_memory_range.valid())
{ {
lock.upgrade(); std::lock_guard lock(m_mtx_task);
handle_invalidated_memory_range();
if (m_invalidated_memory_range.valid())
{
handle_invalidated_memory_range();
}
} }
} }
} }