diff --git a/src/common/intrin.h b/src/common/intrin.h index 24d11b42f..a8f90558c 100644 --- a/src/common/intrin.h +++ b/src/common/intrin.h @@ -36,6 +36,7 @@ #else #include #endif +#include #endif #ifdef __APPLE__ @@ -108,47 +109,17 @@ ALWAYS_INLINE_RELEASE static void MemsetPtrs(T* ptr, T value, u32 count) *(dest++) = value; } -ALWAYS_INLINE void MultiPause() +ALWAYS_INLINE void PauseCPU() { -#if defined(CPU_ARCH_X86) || defined(CPU_ARCH_X64) - _mm_pause(); - _mm_pause(); - _mm_pause(); - _mm_pause(); - _mm_pause(); - _mm_pause(); - _mm_pause(); +#if defined(CPU_ARCH_X64) _mm_pause(); -#elif defined(CPU_ARCH_ARM64) && defined(_MSC_VER) && !defined(__clang__) - __isb(_ARM64_BARRIER_SY); - __isb(_ARM64_BARRIER_SY); - __isb(_ARM64_BARRIER_SY); - __isb(_ARM64_BARRIER_SY); - __isb(_ARM64_BARRIER_SY); - __isb(_ARM64_BARRIER_SY); - __isb(_ARM64_BARRIER_SY); - __isb(_ARM64_BARRIER_SY); #elif defined(CPU_ARCH_ARM64) || defined(CPU_ARCH_ARM32) - __asm__ __volatile__("isb"); - __asm__ __volatile__("isb"); - __asm__ __volatile__("isb"); - __asm__ __volatile__("isb"); - __asm__ __volatile__("isb"); - __asm__ __volatile__("isb"); - __asm__ __volatile__("isb"); - __asm__ __volatile__("isb"); + __yield(); #elif defined(CPU_ARCH_RISCV64) // Probably wrong... pause is optional :/ asm volatile("fence" ::: "memory"); #elif defined(CPU_ARCH_LOONGARCH64) asm volatile("ibar 0" ::: "memory"); - asm volatile("ibar 0" ::: "memory"); - asm volatile("ibar 0" ::: "memory"); - asm volatile("ibar 0" ::: "memory"); - asm volatile("ibar 0" ::: "memory"); - asm volatile("ibar 0" ::: "memory"); - asm volatile("ibar 0" ::: "memory"); - asm volatile("ibar 0" ::: "memory"); #else #pragma warning("Missing implementation") #endif diff --git a/src/common/timer.cpp b/src/common/timer.cpp index 7474c2204..a729d384e 100644 --- a/src/common/timer.cpp +++ b/src/common/timer.cpp @@ -127,7 +127,7 @@ void Timer::SleepUntil(Value value, bool exact) // And spin off whatever time is left. while (current < value) { - MultiPause(); + PauseCPU(); current = GetCurrentValue(); } } @@ -219,7 +219,7 @@ void Timer::SleepUntil(Value value, bool exact) // And spin off whatever time is left. while (current < value) { - MultiPause(); + PauseCPU(); current = GetCurrentValue(); } } diff --git a/src/core/system.cpp b/src/core/system.cpp index d7b72849a..6ef9e58a7 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -2655,7 +2655,7 @@ void System::FreeMemoryStateStorage(bool release_memory, bool release_textures, if ((mss.vram_texture || !mss.gpu_state_data.empty()) && !video_thread_synced) { video_thread_synced = true; - VideoThread::SyncThread(true); + VideoThread::SyncThread(false); } if (mss.vram_texture) diff --git a/src/core/video_thread.cpp b/src/core/video_thread.cpp index 515295e17..25196f263 100644 --- a/src/core/video_thread.cpp +++ b/src/core/video_thread.cpp @@ -376,7 +376,10 @@ void VideoThread::SyncThread(bool spin) } // Hopefully ought to be enough. - MultiPause(); + PauseCPU(); + PauseCPU(); + PauseCPU(); + PauseCPU(); current_time = Timer::GetCurrentValue(); } while ((current_time - start_time) < s_state.thread_spin_time);