From 8027ab53d0cdd5b7de2214f990cf7c12e56d50fd Mon Sep 17 00:00:00 2001 From: Nolan Check Date: Mon, 27 Jul 2009 22:05:38 +0000 Subject: [PATCH] Don't use events for efb access. As I've learned, events cause kernel calls and it is sometimes more efficient to do spin-waits. See if this speeds up Wind Waker's pictobox quests. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3893 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/Atomic_Win32.h | 2 +- Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 40 +++++++++------------ 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/Source/Core/Common/Src/Atomic_Win32.h b/Source/Core/Common/Src/Atomic_Win32.h index cd8b22075d..59d7da5abe 100644 --- a/Source/Core/Common/Src/Atomic_Win32.h +++ b/Source/Core/Common/Src/Atomic_Win32.h @@ -55,7 +55,7 @@ inline u32 AtomicLoad(volatile u32& src) { } inline u32 AtomicLoadAcquire(volatile u32& src) { MemoryBarrier(); - return src; + return src; // 32-bit reads are always atomic. } inline void AtomicStore(volatile u32& dest, u32 value) { diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index 6d3f360dae..ebf3ed4f5f 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -104,11 +104,8 @@ int GLScissorX, GLScissorY, GLScissorW, GLScissorH; static bool s_PluginInitialized = false; -static volatile u32 s_swapRequested = false; -static Common::Event s_swapResponseEvent; - -static volatile u32 s_efbAccessRequested = false; -static Common::Event s_efbResponseEvent; +static u32 s_swapRequested = FALSE; +static u32 s_efbAccessRequested = FALSE; void GetDllInfo (PLUGIN_INFO* _PluginInfo) { @@ -385,11 +382,7 @@ void Video_Prepare(void) TextureConverter::Init(); s_swapRequested = FALSE; - s_swapResponseEvent.Init(); - s_swapResponseEvent.Set(); - s_efbAccessRequested = FALSE; - s_efbResponseEvent.Init(); s_PluginInitialized = true; INFO_LOG(VIDEO, "Video plugin initialized."); @@ -400,10 +393,7 @@ void Shutdown(void) s_PluginInitialized = false; s_efbAccessRequested = FALSE; - s_efbResponseEvent.Shutdown(); - s_swapRequested = FALSE; - s_swapResponseEvent.Shutdown(); Fifo_Shutdown(); PostProcessing::Shutdown(); @@ -472,8 +462,7 @@ void VideoFifo_CheckSwapRequest() // TODO: Find better name for this because I don't know if it means what it says. g_VideoInitialize.pCopiedToXFB(); - s_swapRequested = FALSE; - s_swapResponseEvent.Set(); + Common::AtomicStoreRelease(s_swapRequested, FALSE); } } @@ -507,13 +496,14 @@ void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) { if (s_PluginInitialized) { - if (s_swapRequested) + // Make sure previous swap request has made it to the screen + if (g_VideoInitialize.bUseDualCore) { - if (g_VideoInitialize.bUseDualCore) - s_swapResponseEvent.MsgWait(); - else - VideoFifo_CheckSwapRequest(); + while (Common::AtomicLoadAcquire(s_swapRequested)) + Common::YieldCPU(); } + else + VideoFifo_CheckSwapRequest(); s_beginFieldArgs.xfbAddr = xfbAddr; s_beginFieldArgs.field = field; @@ -531,14 +521,14 @@ void Video_EndField() } } -static volatile struct +static struct { EFBAccessType type; u32 x; u32 y; } s_accessEFBArgs; -static volatile u32 s_AccessEFBResult = 0; +static u32 s_AccessEFBResult = 0; void VideoFifo_CheckEFBAccess() { @@ -546,8 +536,7 @@ void VideoFifo_CheckEFBAccess() { s_AccessEFBResult = Renderer::AccessEFB(s_accessEFBArgs.type, s_accessEFBArgs.x, s_accessEFBArgs.y); - s_efbAccessRequested = FALSE; - s_efbResponseEvent.Set(); + Common::AtomicStoreRelease(s_efbAccessRequested, FALSE); } } @@ -562,7 +551,10 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y) Common::AtomicStoreRelease(s_efbAccessRequested, TRUE); if (g_VideoInitialize.bUseDualCore) - s_efbResponseEvent.MsgWait(); + { + while (Common::AtomicLoadAcquire(s_efbAccessRequested)) + Common::YieldCPU(); + } else VideoFifo_CheckEFBAccess();