Put the video prepare code back, and use the existence of the g_renderer to determine if video prepare has been run or not.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7274 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2011-03-02 15:13:13 +00:00
parent a1055bf5bf
commit 3ffdcf1aec
6 changed files with 84 additions and 98 deletions

View File

@ -43,7 +43,7 @@
int frameCount; int frameCount;
int OSDChoice, OSDTime; int OSDChoice, OSDTime;
Renderer *g_renderer; Renderer *g_renderer = NULL;
bool s_bLastFrameDumped = false; bool s_bLastFrameDumped = false;
Common::CriticalSection Renderer::s_criticalScreenshot; Common::CriticalSection Renderer::s_criticalScreenshot;

View File

@ -174,6 +174,11 @@ bool VideoBackend::Initialize(void *&window_handle)
OSD::AddMessage("Dolphin Direct3D11 Video Backend.", 5000); OSD::AddMessage("Dolphin Direct3D11 Video Backend.", 5000);
s_BackendInitialized = true; s_BackendInitialized = true;
return true;
}
void VideoBackend::Video_Prepare()
{
// Better be safe... // Better be safe...
s_efbAccessRequested = FALSE; s_efbAccessRequested = FALSE;
s_FifoShuttingDown = FALSE; s_FifoShuttingDown = FALSE;
@ -198,11 +203,6 @@ bool VideoBackend::Initialize(void *&window_handle)
PixelEngine::Init(); PixelEngine::Init();
DLCache::Init(); DLCache::Init();
return true;
}
void VideoBackend::Video_Prepare()
{
// Tell the host that the window is ready // Tell the host that the window is ready
Core::Callback_CoreMessage(WM_USER_CREATE); Core::Callback_CoreMessage(WM_USER_CREATE);
} }
@ -211,29 +211,31 @@ void VideoBackend::Shutdown()
{ {
s_BackendInitialized = false; s_BackendInitialized = false;
s_efbAccessRequested = FALSE; if (g_renderer)
s_FifoShuttingDown = FALSE; {
s_swapRequested = FALSE; s_efbAccessRequested = FALSE;
s_FifoShuttingDown = FALSE;
s_swapRequested = FALSE;
// VideoCommon // VideoCommon
DLCache::Shutdown(); DLCache::Shutdown();
Fifo_Shutdown(); Fifo_Shutdown();
CommandProcessor::Shutdown(); CommandProcessor::Shutdown();
PixelShaderManager::Shutdown(); PixelShaderManager::Shutdown();
VertexShaderManager::Shutdown(); VertexShaderManager::Shutdown();
OpcodeDecoder_Shutdown(); OpcodeDecoder_Shutdown();
VertexLoaderManager::Shutdown(); VertexLoaderManager::Shutdown();
// internal interfaces // internal interfaces
D3D::ShutdownUtils(); D3D::ShutdownUtils();
PixelShaderCache::Shutdown(); PixelShaderCache::Shutdown();
VertexShaderCache::Shutdown(); VertexShaderCache::Shutdown();
delete g_vertex_manager; delete g_vertex_manager;
delete g_texture_cache; delete g_texture_cache;
delete g_renderer; delete g_renderer;
g_renderer = NULL;
}
EmuWindow::Close(); EmuWindow::Close();
s_BackendInitialized = false;
} }
} }

View File

@ -159,6 +159,11 @@ bool VideoBackend::Initialize(void *&window_handle)
OSD::AddMessage("Dolphin Direct3D9 Video Backend.", 5000); OSD::AddMessage("Dolphin Direct3D9 Video Backend.", 5000);
s_BackendInitialized = true; s_BackendInitialized = true;
return true;
}
void VideoBackend::Video_Prepare()
{
// Better be safe... // Better be safe...
s_efbAccessRequested = FALSE; s_efbAccessRequested = FALSE;
s_FifoShuttingDown = FALSE; s_FifoShuttingDown = FALSE;
@ -179,11 +184,6 @@ bool VideoBackend::Initialize(void *&window_handle)
PixelEngine::Init(); PixelEngine::Init();
DLCache::Init(); DLCache::Init();
return true;
}
void VideoBackend::Video_Prepare()
{
// Notify the core that the video backend is ready // Notify the core that the video backend is ready
Core::Callback_CoreMessage(WM_USER_CREATE); Core::Callback_CoreMessage(WM_USER_CREATE);
} }
@ -192,25 +192,29 @@ void VideoBackend::Shutdown()
{ {
s_BackendInitialized = false; s_BackendInitialized = false;
s_efbAccessRequested = FALSE; if (g_renderer)
s_FifoShuttingDown = FALSE; {
s_swapRequested = FALSE; s_efbAccessRequested = FALSE;
s_FifoShuttingDown = FALSE;
s_swapRequested = FALSE;
// VideoCommon // VideoCommon
DLCache::Shutdown(); DLCache::Shutdown();
Fifo_Shutdown(); Fifo_Shutdown();
CommandProcessor::Shutdown(); CommandProcessor::Shutdown();
PixelShaderManager::Shutdown(); PixelShaderManager::Shutdown();
VertexShaderManager::Shutdown(); VertexShaderManager::Shutdown();
OpcodeDecoder_Shutdown(); OpcodeDecoder_Shutdown();
VertexLoaderManager::Shutdown(); VertexLoaderManager::Shutdown();
// internal interfaces // internal interfaces
PixelShaderCache::Shutdown(); PixelShaderCache::Shutdown();
VertexShaderCache::Shutdown(); VertexShaderCache::Shutdown();
delete g_vertex_manager; delete g_vertex_manager;
delete g_texture_cache; delete g_texture_cache;
delete g_renderer; delete g_renderer;
g_renderer = NULL;
}
D3D::Shutdown(); D3D::Shutdown();
EmuWindow::Close(); EmuWindow::Close();
} }

View File

@ -529,15 +529,6 @@ bool OpenGL_MakeCurrent()
return true; return true;
} }
bool OpenGL_ReleaseContext()
{
#ifdef _WIN32
return wglMakeCurrent(NULL, NULL);
#elif defined(HAVE_X11) && HAVE_X11
return glXMakeCurrent(GLWin.dpy, None, NULL);
#endif
}
// Update window width, size and etc. Called from Render.cpp // Update window width, size and etc. Called from Render.cpp
void OpenGL_Update() void OpenGL_Update()
{ {

View File

@ -87,7 +87,6 @@ bool OpenGL_Create(void *&);
void OpenGL_Shutdown(); void OpenGL_Shutdown();
void OpenGL_Update(); void OpenGL_Update();
bool OpenGL_MakeCurrent(); bool OpenGL_MakeCurrent();
bool OpenGL_ReleaseContext();
void OpenGL_SwapBuffers(); void OpenGL_SwapBuffers();
// Get status // Get status

View File

@ -176,12 +176,14 @@ bool VideoBackend::Initialize(void *&window_handle)
OSD::AddMessage("Dolphin OpenGL Video Backend.", 5000); OSD::AddMessage("Dolphin OpenGL Video Backend.", 5000);
s_BackendInitialized = true; s_BackendInitialized = true;
if (!OpenGL_MakeCurrent()) return true;
{ }
ERROR_LOG(VIDEO, "Unable to connect to OpenGL context.");
OpenGL_Shutdown(); // This is called after Initialize() from the Core
return false; // Run from the graphics thread
} void VideoBackend::Video_Prepare()
{
OpenGL_MakeCurrent();
g_renderer = new Renderer; g_renderer = new Renderer;
@ -208,22 +210,6 @@ bool VideoBackend::Initialize(void *&window_handle)
TextureConverter::Init(); TextureConverter::Init();
DLCache::Init(); DLCache::Init();
if (!OpenGL_ReleaseContext())
{
ERROR_LOG(VIDEO, "Unable to release OpenGL context.");
Shutdown();
return false;
}
return true;
}
// This is called after Initialize() from the Core
// Run from the graphics thread
void VideoBackend::Video_Prepare()
{
OpenGL_MakeCurrent();
// Notify the core that the video backend is ready // Notify the core that the video backend is ready
Core::Callback_CoreMessage(WM_USER_CREATE); Core::Callback_CoreMessage(WM_USER_CREATE);
} }
@ -232,25 +218,29 @@ void VideoBackend::Shutdown()
{ {
s_BackendInitialized = false; s_BackendInitialized = false;
s_efbAccessRequested = false; if (g_renderer)
s_FifoShuttingDown = false; {
s_swapRequested = false; s_efbAccessRequested = false;
DLCache::Shutdown(); s_FifoShuttingDown = false;
Fifo_Shutdown(); s_swapRequested = false;
PostProcessing::Shutdown(); DLCache::Shutdown();
Fifo_Shutdown();
PostProcessing::Shutdown();
// The following calls are NOT Thread Safe // The following calls are NOT Thread Safe
// And need to be called from the video thread // And need to be called from the video thread
TextureConverter::Shutdown(); TextureConverter::Shutdown();
VertexLoaderManager::Shutdown(); VertexLoaderManager::Shutdown();
VertexShaderCache::Shutdown(); VertexShaderCache::Shutdown();
VertexShaderManager::Shutdown(); VertexShaderManager::Shutdown();
PixelShaderManager::Shutdown(); PixelShaderManager::Shutdown();
PixelShaderCache::Shutdown(); PixelShaderCache::Shutdown();
delete g_vertex_manager; delete g_vertex_manager;
delete g_texture_cache; delete g_texture_cache;
OpcodeDecoder_Shutdown(); OpcodeDecoder_Shutdown();
delete g_renderer; delete g_renderer;
g_renderer = NULL;
}
OpenGL_Shutdown(); OpenGL_Shutdown();
} }