From 3bc8eb7eaf83445e04c318fcd4f53fd6da73bf66 Mon Sep 17 00:00:00 2001 From: "sl1nk3.s" Date: Wed, 15 Jul 2009 15:09:20 +0000 Subject: [PATCH] Fixed one of the two remaining crash on Stop (issue 600), and removed some setup defines which are now useless anyway. There's an attempt to implement Peek_Color too, probably done wrong :P git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3799 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/Setup.h | 22 --- Source/Core/Common/Src/Thread.cpp | 102 ---------- Source/Core/Common/Src/Thread.h | 18 -- Source/Core/Core/Src/Core.cpp | 181 +++++------------- Source/Core/Core/Src/Core.h | 8 - Source/Core/Core/Src/Host.h | 3 - Source/Core/Core/Src/PluginManager.cpp | 47 +---- Source/Core/Core/Src/PluginManager.h | 1 + Source/Core/DolphinWX/Src/Frame.cpp | 11 -- Source/Core/DolphinWX/Src/FrameTools.cpp | 13 +- Source/Core/DolphinWX/Src/Main.cpp | 8 +- Source/Core/VideoCommon/Src/Fifo.cpp | 24 +-- Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp | 2 - .../Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp | 3 +- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 26 ++- Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 4 +- Source/UnitTests/UnitTests.cpp | 3 - 17 files changed, 92 insertions(+), 384 deletions(-) diff --git a/Source/Core/Common/Src/Setup.h b/Source/Core/Common/Src/Setup.h index c32b5fe959..231f623315 100644 --- a/Source/Core/Common/Src/Setup.h +++ b/Source/Core/Common/Src/Setup.h @@ -32,28 +32,6 @@ // This may remove sound artifacts in Wario Land Shake It and perhaps other games //#define SETUP_AVOID_SOUND_ARTIFACTS -/* This may fix a problem with Stop and Start that I described in the comments to revision 2,139, - and in the comments in the File Description for PluginManager.cpp */ -//#define SETUP_FREE_VIDEO_PLUGIN_ON_BOOT -//#define SETUP_FREE_DSP_PLUGIN_ON_BOOT -//#define SETUP_DONT_FREE_PLUGIN_ON_STOP - -/* This will avoid deleting the g_EmuThread after Stop, that may hang when we are rendering to a child - window, however, I didn't seem to need this any more */ -//#define SETUP_AVOID_CHILD_WINDOW_RENDERING_HANG - -// Build with playback rerecording options -//#define SETUP_AVOID_OPENGL_SCREEN_MESSAGE_HANG - -// Use a timer to wait for threads for stop instead of WaitForEternity() -/* I tried that this worked with these options - SETUP_FREE_VIDEO_PLUGIN_ON_BOOT - SETUP_DONT_FREE_PLUGIN_ON_STOP - then the Confirm on Close message box doesn't hang, and we have a controlled Shutdown process - without any hanged threads. The downside is a few error messages in the ShutDown() of the - OpenGL plugin, so I still need FreeLibrary() to clean it, even with this option. */ -//#define SETUP_TIMER_WAITING - // Build with playback rerecording options //#define RERECORDING diff --git a/Source/Core/Common/Src/Thread.cpp b/Source/Core/Common/Src/Thread.cpp index 53ea908b77..3b45d0f3c6 100644 --- a/Source/Core/Common/Src/Thread.cpp +++ b/Source/Core/Common/Src/Thread.cpp @@ -23,12 +23,6 @@ #include #endif -#ifdef SETUP_TIMER_WAITING - #include - #include "ConsoleWindow.h" - EventCallBack FunctionPointer[10]; -#endif - namespace Common { @@ -110,12 +104,6 @@ void Thread::SetCurrentThreadAffinity(int mask) Event::Event() { m_hEvent = 0; - #ifdef SETUP_TIMER_WAITING - DoneWaiting = false; - StartWait = false; - hTimer = NULL; - hTimerQueue = NULL; - #endif } void Event::Init() @@ -183,96 +171,6 @@ void Event::MsgWait() } } -/* Separate thread timer based waiting, instead of same thread loop waiting. The downside with this - is that it's less convenient to use because we can't stall any threads with a loop. The positive - is that we don't cause these incredibly annoying WaitForEternity() hangings. */ -#ifdef SETUP_TIMER_WAITING -/* I could not figure out how to place this in the class to, CreateTimerQueueTimer() would complain - about some kind of type casting, anyone have any ideas about how to do it? */ -VOID CALLBACK TimerRoutine(PVOID lpParam, BOOLEAN TimerOrWaitFired) -{ - if (lpParam == NULL) - { - DEBUG_LOG(CONSOLE, "TimerRoutine lpParam is NULL\n"); - } - else - { - // lpParam points to the argument; in this case it is an int - - //DEBUG_LOG(CONSOLE, "Timer[%i] will call back\n", *(int*)lpParam); - } - - // Call back - int Id = *(int*)lpParam; - if (FunctionPointer[Id]) FunctionPointer[Id](); -} - -// Create a timer that will call back to the calling function -bool Event::TimerWait(EventCallBack WaitCB, int _Id, bool OptCondition) -{ - Id = _Id; - - //DEBUG_LOG(CONSOLE, "TimerWait[%i]: %i %i %i\n", Id, StartWait, DoneWaiting, OptCondition); - - FunctionPointer[Id] = WaitCB; - - // This means we are done waiting, so we wont call back again, and we also reset the variables for this Event - if (DoneWaiting && OptCondition) - { - StartWait = false; - DoneWaiting = false; - FunctionPointer[Id] = NULL; - - // Delete all timers in the timer queue. - if (!DeleteTimerQueue(hTimerQueue)) - DEBUG_LOG(CONSOLE, "DeleteTimerQueue failed (%d)\n", GetLastError()); - - hTimer = NULL; - hTimerQueue = NULL; - - return true; - } - - // Else start a new callback timer - StartWait = true; - - // Create the timer queue if needed - if (!hTimerQueue) - { - hTimerQueue = CreateTimerQueue(); - if (NULL == hTimerQueue) - { - DEBUG_LOG(CONSOLE, "CreateTimerQueue failed (%d)\n", GetLastError()); - return false; - } - } - - // Set a timer to call the timer routine in 10 seconds. - if (!CreateTimerQueueTimer( &hTimer, hTimerQueue, - (WAITORTIMERCALLBACK)TimerRoutine, &Id , 10, 0, 0)) - { - DEBUG_LOG(CONSOLE, "CreateTimerQueueTimer failed (%d)\n", GetLastError()); - return false; - } - - return false; -} -// Check if we are done or not -bool Event::DoneWait() -{ - if (StartWait && DoneWaiting) - return true; - else - return false; -} -// Tells the timer that we are done waiting -void Event::SetTimer() -{ - // We can not be done before we have started waiting - if (StartWait) DoneWaiting = true; -} -#endif - // Supporting functions void SleepCurrentThread(int ms) { diff --git a/Source/Core/Common/Src/Thread.h b/Source/Core/Common/Src/Thread.h index e06e02b101..a8c1192a7c 100644 --- a/Source/Core/Common/Src/Thread.h +++ b/Source/Core/Common/Src/Thread.h @@ -60,14 +60,6 @@ #endif #endif -// ----------------------------------------- -#ifdef SETUP_TIMER_WAITING -// ----------------- - typedef void (*EventCallBack)(void); -#endif -// ---------------------- -/////////////////////////////////// - namespace Common { @@ -156,16 +148,6 @@ public: void MsgWait() {Wait();} #endif - #ifdef SETUP_TIMER_WAITING - bool TimerWait(EventCallBack WaitCB, int Id = 0, bool OptCondition = true); - bool DoneWait(); - void SetTimer(); - bool DoneWaiting; - bool StartWait; - int Id; - HANDLE hTimer; - HANDLE hTimerQueue; - #endif private: #ifdef _WIN32 diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 40bdeda330..d42f813013 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -100,21 +100,7 @@ SCoreStartupParameter g_CoreStartupParameter; // This event is set when the emuthread starts. Common::Event emuThreadGoing; Common::Event cpuRunloopQuit; - - -#ifdef SETUP_TIMER_WAITING - - bool VideoThreadRunning = false; - bool StopUpToVideoDone = false; - bool EmuThreadReachedEnd = false; - bool StopReachedEnd = false; - static Common::Event VideoThreadEvent; - static Common::Event VideoThreadEvent2; - void EmuThreadEnd(); -#endif - - - +Common::Event gpuShutdownCall; // Display messages and return values @@ -171,19 +157,6 @@ void ReconnectWiimote() INFO_LOG(CONSOLE, "ReconnectWiimote()\n"); } - -#ifdef SETUP_TIMER_WAITING - - void VideoThreadEnd() - { - VideoThreadRunning = false; - VideoThreadEvent.SetTimer(); - VideoThreadEvent2.SetTimer(); - //INFO_LOG(CONSOLE, "VideoThreadEnd\n"); - } -#endif - - bool isRunning() { return (GetState() != CORE_UNINITIALIZED) || g_bHwInit; @@ -222,9 +195,6 @@ bool Init() g_EmuThread = new Common::Thread(EmuThread, NULL); emuThreadGoing.MsgWait(); emuThreadGoing.Shutdown(); - #ifdef SETUP_TIMER_WAITING - VideoThreadRunning = true; - #endif // All right, the event is set and killed. We are now running. Host_SetWaitCursor(false); @@ -236,14 +206,6 @@ void Stop() // - Hammertime! { const SCoreStartupParameter& _CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; -#ifdef SETUP_TIMER_WAITING - if (!StopUpToVideoDone) - { - INFO_LOG(CONSOLE, "Stop [Main Thread]: Shutting down...\n"); - // Reset variables - StopReachedEnd = false; - EmuThreadReachedEnd = false; -#endif Host_SetWaitCursor(true); // hourglass! if (PowerPC::GetState() == PowerPC::CPU_POWERDOWN) return; @@ -266,16 +228,6 @@ void Stop() // - Hammertime! CPluginManager::GetInstance().GetVideo()->Video_ExitLoop(); } -#ifdef SETUP_TIMER_WAITING - StopUpToVideoDone = true; - } - // Call this back - //if (!VideoThreadEvent.TimerWait(Stop, 1, EmuThreadReachedEnd) || !EmuThreadReachedEnd) return; - if (!VideoThreadEvent.TimerWait(Stop, 1)) return; - - //INFO_LOG(CONSOLE, "Stop() will continue\n"); -#endif - // Video_EnterLoop() should now exit so that EmuThread() will continue concurrently with the rest // of the commands in this function. We no longer rely on Postmessage. */ @@ -285,12 +237,7 @@ void Stop() // - Hammertime! // Update mouse pointer Host_SetWaitCursor(false); - #ifdef SETUP_AVOID_CHILD_WINDOW_RENDERING_HANG - /* This may hang when we are rendering to a child window, but currently it doesn't, at least - not on my system, but I'll leave this option for a while anyway */ - if (GetParent((HWND)g_pWindowHandle) == NULL) - #endif -#ifndef SETUP_TIMER_WAITING // This is moved + #ifdef _WIN32 g_EmuThread->WaitForDeath(5000); #else @@ -298,26 +245,25 @@ void Stop() // - Hammertime! #endif delete g_EmuThread; // Wait for emuthread to close. g_EmuThread = 0; -#else - Host_UpdateGUI(); - StopUpToVideoDone = false; - StopReachedEnd = true; -#endif } -// Create the CPU thread. For use with Single Core mode only. +// Create the CPU thread. which would be a CPU + Video thread in Single Core mode. THREAD_RETURN CpuThread(void *pArg) { - Common::SetCurrentThreadName("CPU thread"); - + CPluginManager &Plugins = CPluginManager::GetInstance(); const SCoreStartupParameter& _CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; - if (!_CoreParameter.bUseDualCore) + + if (_CoreParameter.bUseDualCore) { - //wglMakeCurrent - CPluginManager::GetInstance().GetVideo()->Video_Prepare(); + Common::SetCurrentThreadName("CPU thread"); + } + else + { + CPluginManager::GetInstance().GetVideo()->Video_Prepare(); + Common::SetCurrentThreadName("CPU-GPU thread"); } if (_CoreParameter.bLockThreads) @@ -338,6 +284,16 @@ THREAD_RETURN CpuThread(void *pArg) // Enter CPU run loop. When we leave it - we are done. CCPU::Run(); cpuRunloopQuit.Set(); + + // Call video shutdown from the video thread in single core mode, which is the cpuThread + if (!_CoreParameter.bUseDualCore) + { + gpuShutdownCall.Wait(); + Plugins.ShutdownVideoPlugin(); + } + + gpuShutdownCall.Shutdown(); + return 0; } @@ -347,6 +303,7 @@ THREAD_RETURN CpuThread(void *pArg) THREAD_RETURN EmuThread(void *pArg) { cpuRunloopQuit.Init(); + gpuShutdownCall.Init(); Common::SetCurrentThreadName("Emuthread - starting"); const SCoreStartupParameter& _CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; @@ -384,10 +341,6 @@ THREAD_RETURN EmuThread(void *pArg) VideoInitialize.pBBox = &PixelEngine::bbox[0]; VideoInitialize.pBBoxActive = &PixelEngine::bbox_active; - // May be needed for Stop and Start - #ifdef SETUP_FREE_VIDEO_PLUGIN_ON_BOOT - Plugins.FreeVideo(); - #endif Plugins.GetVideo()->Initialize(&VideoInitialize); // Call the dll // Under linux, this is an X11 Display, not an HWND! @@ -411,10 +364,6 @@ THREAD_RETURN EmuThread(void *pArg) dspInit.bWii = _CoreParameter.bWii; dspInit.bOnThread = _CoreParameter.bDSPThread; - // May be needed for Stop and Start - #ifdef SETUP_FREE_DSP_PLUGIN_ON_BOOT - Plugins.FreeDSP(); - #endif Plugins.GetDSP()->Initialize((void *)&dspInit); // Load and Init PadPlugin @@ -476,21 +425,30 @@ THREAD_RETURN EmuThread(void *pArg) // Update the window again because all stuff is initialized Host_UpdateDisasmDialog(); Host_UpdateMainFrame(); - - // This thread, after creating the EmuWindow, spawns a CPU thread, - // then takes over and becomes the graphics thread - - // In single core mode, this thread is the CPU thread and also does the graphics. - + // Spawn the CPU thread Common::Thread *cpuThread = NULL; // ENTER THE VIDEO THREAD LOOP - if (!_CoreParameter.bUseDualCore) + if (_CoreParameter.bUseDualCore) // DualCore mode { + // This thread, after creating the EmuWindow, spawns a CPU thread, + // and then takes over and becomes the video thread + + Plugins.GetVideo()->Video_Prepare(); // wglMakeCurrent + cpuThread = new Common::Thread(CpuThread, pArg); + Common::SetCurrentThreadName("Video thread"); + + Plugins.GetVideo()->Video_EnterLoop(); + } + else // SingleCore mode + { + // the spawned CPU Thread is the... CPU thread but it also does the graphics. + // the EmuThread is thus an idle thread, which sleeps and wait for the emu to terminate. + #ifdef _WIN32 cpuThread = new Common::Thread(CpuThread, pArg); - // Common::SetCurrentThreadName("Idle thread"); + Common::SetCurrentThreadName("Emuthread - Idle"); // TODO(ector) : investigate using GetMessage instead .. although // then we lose the powerdown check. ... unless powerdown sends a message :P @@ -505,40 +463,6 @@ THREAD_RETURN EmuThread(void *pArg) CpuThread(pArg); #endif } - else - { - Plugins.GetVideo()->Video_Prepare(); // wglMakeCurrent - cpuThread = new Common::Thread(CpuThread, pArg); - Common::SetCurrentThreadName("Video thread"); - - Plugins.GetVideo()->Video_EnterLoop(); - } -#ifdef SETUP_TIMER_WAITING - - VideoThreadEvent2.TimerWait(EmuThreadEnd, 2); - //INFO_LOG(CONSOLE, "Video loop [Video Thread]: Stopped\n"); - return 0; -} - -void EmuThreadEnd() -{ - CPluginManager &Plugins = CPluginManager::GetInstance(); - const SCoreStartupParameter& _CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; - - //INFO_LOG(CONSOLE, "Video loop [Video Thread]: EmuThreadEnd [StopEnd:%i]\n", StopReachedEnd); - - //if (!VideoThreadEvent2.TimerWait(EmuThreadEnd, 2)) return; - if (!VideoThreadEvent2.TimerWait(EmuThreadEnd, 2, StopReachedEnd) || !StopReachedEnd) - { - INFO_LOG(CONSOLE, "Stop [Video Thread]: Waiting for Stop() and Video Loop to end...\n"); - return; - } - - //INFO_LOG(CONSOLE, "EmuThreadEnd() will continue\n"); - - /* There will be a few problems with the OpenGL ShutDown() after this, for example the "Release - Device Context Failed" error message */ -#endif INFO_LOG(CONSOLE, "Stop [Video Thread]: Stop() and Video Loop Ended\n"); INFO_LOG(CONSOLE, "Stop [Video Thread]: Shutting down HW and Plugins\n"); @@ -549,12 +473,21 @@ void EmuThreadEnd() if (g_pUpdateFPSDisplay != NULL) g_pUpdateFPSDisplay("Stopping..."); -#ifndef SETUP_TIMER_WAITING + HW::Shutdown(); + Plugins.ShutdownPlugins(); + + // Call video shutdown from the video thread in dual core mode (EmuThread) + // Or set an event in Single Core mode, to call the shutdown from the cpuThread + if (_CoreParameter.bUseDualCore) + Plugins.ShutdownVideoPlugin(); + else + gpuShutdownCall.Set(); + if (cpuThread) { // There is a CPU thread - join it. #ifdef _WIN32 - cpuThread->WaitForDeath(5000); + cpuThread->WaitForDeath(3000); #else cpuThread->WaitForDeath(); #endif @@ -562,10 +495,6 @@ void EmuThreadEnd() // Returns after game exited cpuThread = NULL; } -#endif - - HW::Shutdown(); - Plugins.ShutdownPlugins(); // The hardware is uninitialized g_bHwInit = false; @@ -574,15 +503,7 @@ void EmuThreadEnd() Host_UpdateMainFrame(); -#ifdef SETUP_TIMER_WAITING - EmuThreadReachedEnd = true; - Host_UpdateGUI(); - INFO_LOG(CONSOLE, "Stop [Video Thread]: Done\n"); - delete g_EmuThread; // Wait for emuthread to close. - g_EmuThread = 0; -#else return 0; -#endif } diff --git a/Source/Core/Core/Src/Core.h b/Source/Core/Core/Src/Core.h index 1c66e8f4de..eaa6879f7f 100644 --- a/Source/Core/Core/Src/Core.h +++ b/Source/Core/Core/Src/Core.h @@ -72,14 +72,6 @@ namespace Core void SetBlockStart(u32 addr); void StopTrace(); - // ----------------------------------------- - #ifdef SETUP_TIMER_WAITING - // ----------------- - // Thread shutdown - void VideoThreadEnd(); - #endif - // --------------------------- - // ----------------------------------------- #ifdef RERECORDING // ----------------- diff --git a/Source/Core/Core/Src/Host.h b/Source/Core/Core/Src/Host.h index d432cb36ef..f856132095 100644 --- a/Source/Core/Core/Src/Host.h +++ b/Source/Core/Core/Src/Host.h @@ -48,9 +48,6 @@ void Host_SetDebugMode(bool enable); void Host_SetWaitCursor(bool enable); void Host_UpdateStatusBar(const char* _pText, int Filed = 0); -#ifdef SETUP_TIMER_WAITING -void Host_UpdateGUI(); -#endif void Host_SysMessage(const char *fmt, ...); void Host_SetWiiMoteConnectionState(int _State); diff --git a/Source/Core/Core/Src/PluginManager.cpp b/Source/Core/Core/Src/PluginManager.cpp index 02c41eac2b..b813ac020a 100644 --- a/Source/Core/Core/Src/PluginManager.cpp +++ b/Source/Core/Core/Src/PluginManager.cpp @@ -24,36 +24,7 @@ plugins when Dolphin is booted, and open the debugging and config windows. The PluginManager is created once when Dolphin starts and is closed when Dolphin is closed. - When plugins are freed and loaded: - - In an attempt to avoid the crash that occurs when the use LoadLibrary() and FreeLibrary() often - (every time a game is stopped and started) these functions will only be used when - 1. Dolphin is started - 2. A plugin is changed - 3. Dolphin is closed - it will not be used when we Start and Stop games. With these exceptions: - 1. Video plugin: If FreeLibrary() is not called between Stop and Start it will fail for - several games on the next Start, but not for all games. - 2. Sound plugin: If FreeLibrary() is not called between Stop and Start I got the "Tried to - "get pointer for unknown address ffffffff" message for all games I tried. - - Currently this holds if the 'SETUP_FREE_PLUGIN_ON_BOOT' option is used - - For some reason the time when the FreeLibrary() is placed produce different results. If it's placed - after ShutDown() I don't get a black screen when I start SSBM (PAL) again, if I have stopped the game - before the first 3D appears (on the start screen), if I show the start screen and then Stop and Start - I get the same error again (a black screen) (with the default OpenGL settings, copy EFB to texture, no - hack). I also get the "Tried to get pointer ..." error then to (if DSP HLE sound has been enabled, if - "Enable HLE Audio" has been disabled I don't get that error message). For this reason I have to place - FreeVideo() and FreeDSP() before it's initialized on the next Start instead, then it works. - - If it was not for the crash I always got earlier after several (perhaps as many as twenty) Stop and Start - I would be indifferent about how often FreeLibrary() i used, but since it seems like it can fail - infrequently, at least for nJoy, I'd rather use FreeLibrary() more sparingly. However, I could not - reproduce any crash now after several Stop and Start so maybe it has gone away or I was lucky. In any case - if it works I'd rather be without FreeLibrary() between Start and Stop. - -//////////////////////////////////////*/ +*/ ////////////////////////////////////////////////////////////////////////////////////////// // Include // ŻŻŻŻŻŻŻŻŻŻŻŻ @@ -212,23 +183,21 @@ void CPluginManager::ShutdownPlugins() { m_dsp->Shutdown(); // With this option, this is done on boot instead - #ifndef SETUP_DONT_FREE_PLUGIN_ON_STOP - delete m_dsp; - m_dsp = NULL; - #endif + delete m_dsp; + m_dsp = NULL; } +} +void CPluginManager::ShutdownVideoPlugin() +{ if (m_video) { m_video->Shutdown(); // With this option, this is done on boot instead - #ifndef SETUP_DONT_FREE_PLUGIN_ON_STOP - delete m_video; - m_video = NULL; - #endif + delete m_video; + m_video = NULL; } } -////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// diff --git a/Source/Core/Core/Src/PluginManager.h b/Source/Core/Core/Src/PluginManager.h index 9578c0ea23..93257c7b84 100644 --- a/Source/Core/Core/Src/PluginManager.h +++ b/Source/Core/Core/Src/PluginManager.h @@ -59,6 +59,7 @@ public: bool InitPlugins(); void ShutdownPlugins(); + void ShutdownVideoPlugin(); int OkayToInitPlugin(int Plugin); void ScanForPlugins(); void OpenConfig(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type); diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 2da2c62d1b..31839f9c44 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -203,17 +203,6 @@ int abc = 0; return 0; #endif // ----------------------------- - - // ----------------------------------------- - #ifdef SETUP_TIMER_WAITING - // ----------------- - case OPENGL_VIDEO_STOP: - // The Video thread has been shut down - Core::VideoThreadEnd(); - //INFO_LOG(CONSOLE, "OPENGL_VIDEO_STOP\n"); - return 0; - #endif - // ----------------------------- } break; diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 8e4e45fce5..85d3a03ece 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -173,9 +173,9 @@ void CFrame::CreateMenu() toolsMenu->Append(IDM_CHEATS, _T("Action &Replay Manager")); toolsMenu->Append(IDM_INFO, _T("System Information")); +#if defined(HAVE_SFML) && HAVE_SFML toolsMenu->Append(IDM_NETPLAY, _T("Start &NetPlay")); - - // toolsMenu->Append(IDM_SDCARD, _T("Mount &SDCard")); // Disable for now +#endif if (DiscIO::CNANDContentManager::Access().GetNANDLoader(FULL_WII_MENU_DIR).IsValid()) { @@ -524,15 +524,6 @@ void CFrame::DoStop() return; Core::Stop(); - -#ifdef SETUP_TIMER_WAITING - // Idle-wait for core to completely shut down (without this wait the - // GameCtrlPanel is restored to a state where we can open another game - // and effectively crash Dolphin) - while(Core::isRunning()) - SLEEP(10); -#endif - UpdateGUI(); } } diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index e86a21169d..8a4e37db28 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -393,6 +393,7 @@ void Host_UpdateDisasmDialog() { wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEDISASMDIALOG); wxPostEvent(main_frame, event); + if (g_pCodeWindow) { wxPostEvent(g_pCodeWindow, event); @@ -503,13 +504,6 @@ void Host_UpdateStatusBar(const char* _pText, int Field) // wxPostEvent(main_frame, event); } -#ifdef SETUP_TIMER_WAITING -void Host_UpdateGUI() -{ - main_frame->UpdateGUI(); -} -#endif - // g_VideoInitialize.pSysMessage() goes here void Host_SysMessage(const char *fmt, ...) { diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp index dcd593550a..84cb52dc9b 100644 --- a/Source/Core/VideoCommon/Src/Fifo.cpp +++ b/Source/Core/VideoCommon/Src/Fifo.cpp @@ -16,11 +16,7 @@ // http://code.google.com/p/dolphin-emu/ #include - #include "Setup.h" -#ifdef SETUP_TIMER_WAITING - #include "../../../Plugins/Plugin_VideoOGL/Src/OS/Win32.h" -#endif #include "MemoryUtil.h" #include "Thread.h" #include "Atomic.h" @@ -89,18 +85,9 @@ u8* FAKE_GetFifoEndPtr() void Fifo_ExitLoop() { fifoStateRun = false; - #ifndef SETUP_TIMER_WAITING - fifo_exit_event.MsgWait(); - fifo_exit_event.Shutdown(); - #else - //Console::Print("Video: Fifo_ExitLoop: Done:%i\n", fifo_exit_event.DoneWait()); - if (fifo_exit_event.TimerWait(Fifo_ExitLoop)) - { - //Console::Print("Video: Fifo_Shutdown: Done:%i\n\n", fifo_exit_event.DoneWait()); - fifo_exit_event.Shutdown(); - PostMessage(EmuWindow::GetParentWnd(), WM_USER, OPENGL_VIDEO_STOP, 0); - } - #endif + + fifo_exit_event.MsgWait(); + fifo_exit_event.Shutdown(); } // May be executed from any thread, even the graphics thread. @@ -140,7 +127,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) while (fifoStateRun) { -#if defined(_WIN32) && !defined(SETUP_AVOID_OPENGL_SCREEN_MESSAGE_HANG) +#if defined(_WIN32) video_initialize.pPeekMessages(); #endif @@ -220,8 +207,5 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) s_criticalFifo.Leave(); } fifo_exit_event.Set(); - #ifdef SETUP_TIMER_WAITING - fifo_exit_event.SetTimer(); - #endif } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp index 579f6dddcc..f4f0d2440d 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp @@ -711,9 +711,7 @@ void OpenGL_Shutdown() if (hDC && !ReleaseDC(EmuWindow::GetWnd(), hDC)) // Are We Able To Release The DC { -#ifndef SETUP_TIMER_WAITING // This fails ERROR_LOG(VIDEO, "Release Device Context Failed."); -#endif hDC = NULL; // Set DC To NULL } #elif defined(HAVE_X11) && HAVE_X11 diff --git a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp index a7be62699e..7830c7a89f 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp @@ -338,8 +338,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) } case WM_DESTROY: - //Shutdown(); - //PostQuitMessage( 0 ); // Call WM_QUIT + Shutdown(); break; // Called when a screensaver wants to show up while this window is active diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 2c26016e12..48455d2cbf 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -566,15 +566,13 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y) int srcX = (targetPixelRc.left + targetPixelRc.right) / 2; int srcY = (targetPixelRc.top + targetPixelRc.bottom) / 2; - u32 z; + u32 z = 0; glReadPixels(srcX, srcY, 1, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, &z); GL_REPORT_ERRORD(); if (s_MSAASamples > 1) - { // Return to the EFB (this may not be necessary). - glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, s_framebufferManager.GetEFBFramebuffer()); - } + SetFramebuffer(0); // Scale the 32-bit value returned by glReadPixels to a 24-bit // value (GC uses a 24-bit Z-buffer). @@ -586,7 +584,25 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y) break; case PEEK_COLOR: - // TODO: Implement + /*{ + u32 z = 0; + int srcX = (targetPixelRc.left + targetPixelRc.right) / 2; + int srcY = (targetPixelRc.top + targetPixelRc.bottom) / 2; + + if (s_MSAASamples > 1) + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ResolveAndGetRenderTarget(efbPixelRc)); + + // Read the z value! Also adjust the pixel to read to the upscaled EFB resolution + // Plus we need to flip the y value as the OGL image is upside down + glReadPixels(srcX, srcY, 1, 1, GL_RGB, GL_UNSIGNED_INT, &z); + GL_REPORT_ERRORD(); + + // We should probably re-bind the old fbo here. + if (s_MSAASamples > 1) + SetFramebuffer(0); + + return z; + }*/ break; case POKE_COLOR: diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index 2cd4c8f5ff..286291ca48 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -399,6 +399,9 @@ void Shutdown(void) Fifo_Shutdown(); PostProcessing::Shutdown(); + + // The following calls are NOT Thread Safe + // And need to be called from the video thread TextureConverter::Shutdown(); VertexLoaderManager::Shutdown(); VertexShaderCache::Shutdown(); @@ -427,7 +430,6 @@ void Video_ExitLoop() - // Screenshot and screen message void Video_Screenshot(const char *_szFilename) diff --git a/Source/UnitTests/UnitTests.cpp b/Source/UnitTests/UnitTests.cpp index 0a1b39faae..2e6af2c7c6 100644 --- a/Source/UnitTests/UnitTests.cpp +++ b/Source/UnitTests/UnitTests.cpp @@ -125,9 +125,6 @@ void Host_SetDebugMode(bool enable){} void Host_SetWaitCursor(bool enable){} void Host_UpdateStatusBar(const char* _pText, int Filed = 0){} -#ifdef SETUP_TIMER_WAITING -void Host_UpdateGUI(){} -#endif void Host_SysMessage(const char *fmt, ...){} void Host_SetWiiMoteConnectionState(int _State){}