From 40cc180dfdb11b79ef2404c3238200b3fbcc48e9 Mon Sep 17 00:00:00 2001 From: ayuanx Date: Tue, 26 Jan 2010 14:56:51 +0000 Subject: [PATCH] OpenGL fix: s_swapRequested must be volatile. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4964 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 10 +++++++--- Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 15 +++++++++------ Source/Plugins/Plugin_VideoOGL/Src/main.h | 1 + 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 8240ab2410..cf572ba5f4 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -18,6 +18,7 @@ #include "Globals.h" #include "Thread.h" +#include "Atomic.h" #include #include @@ -775,6 +776,8 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect { s_skipSwap = g_bSkipCurrentFrame; + VideoFifo_CheckEFBAccess(); + // If we're about to write to a requested XFB, make sure the previous // contents make it to the screen first. VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight); @@ -784,9 +787,6 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect // just use progressive. if (!g_ActiveConfig.bUseXFB) { - // TODO: Find better name for this because I don't know if it means what it says. - g_VideoInitialize.pCopiedToXFB(false); - Renderer::Swap(xfbAddr, FIELD_PROGRESSIVE, fbWidth, fbHeight); } } @@ -794,6 +794,8 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect // This function has the final picture. We adjust the aspect ratio here. void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) { + Common::AtomicStoreRelease(s_swapRequested, FALSE); + if (s_skipSwap) return; const XFBSource* xfbSource = g_framebufferManager.GetXFBSource(xfbAddr, fbWidth, fbHeight); @@ -1081,6 +1083,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) // For testing zbuffer targets. // Renderer::SetZBufferRender(); // SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget, GetTargetWidth(), GetTargetHeight()); + + g_VideoInitialize.pCopiedToXFB(false); } // Create On-Screen-Messages diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index aa9f66c784..504b2ae45a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -105,7 +105,7 @@ int GLScissorX, GLScissorY, GLScissorW, GLScissorH; static bool s_PluginInitialized = false; -static u32 s_swapRequested = FALSE; +volatile u32 s_swapRequested = FALSE; static u32 s_efbAccessRequested = FALSE; static volatile u32 s_FifoShuttingDown = FALSE; static bool ForceSwap = true; @@ -493,10 +493,11 @@ void VideoFifo_CheckSwapRequest() if (ForceSwap || g_ActiveConfig.bUseXFB) { Renderer::Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.field, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight); - g_VideoInitialize.pCopiedToXFB(false); } - - Common::AtomicStoreRelease(s_swapRequested, FALSE); + else + { + Common::AtomicStoreRelease(s_swapRequested, FALSE); + } } } @@ -531,7 +532,8 @@ void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) if (g_VideoInitialize.bOnThread) { while (Common::AtomicLoadAcquire(s_swapRequested) && !s_FifoShuttingDown) - Common::YieldCPU(); + Common::SleepCurrentThread(1); + //Common::YieldCPU(); } else VideoFifo_CheckSwapRequest(); @@ -582,7 +584,8 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y) if (g_VideoInitialize.bOnThread) { while (Common::AtomicLoadAcquire(s_efbAccessRequested) && !s_FifoShuttingDown) - Common::YieldCPU(); + Common::SleepCurrentThread(1); + //Common::YieldCPU(); } else VideoFifo_CheckEFBAccess(); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.h b/Source/Plugins/Plugin_VideoOGL/Src/main.h index 0249195736..8deae603e3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.h @@ -21,5 +21,6 @@ #include "pluginspecs_video.h" extern SVideoInitialize g_VideoInitialize; +extern volatile u32 s_swapRequested; #endif // _MAIN_H_