If the DSP LLE can not find the needed ROM files exit the emulator without crashing the application. Also reimplement soren's revision 7195 in a way that works on linux and windows. (This makes it easier to clean up the video backend if the DSP emulator fails to initialize.)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7271 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice
2011-03-02 05:16:49 +00:00
parent 6073600084
commit 3af93e8cf3
12 changed files with 163 additions and 115 deletions

View File

@ -117,16 +117,10 @@ void VideoBackend::UpdateFPSDisplay(const char *text)
#if defined(HAVE_X11) && HAVE_X11
void XEventThread();
void CreateXWindow (void)
void CreateXWindow(void)
{
Atom wmProtocols[1];
// use evdpy to create the window, so that connection gets the events
// the colormap needs to be created on the same display, because it
// is a client side structure, as well as wmProtocols(or so it seems)
// GLWin.win is a xserver global window handle, so it can be used by both
// display connections
// Setup window attributes
GLWin.attr.colormap = XCreateColormap(GLWin.evdpy,
GLWin.parent, GLWin.vi->visual, AllocNone);
@ -136,7 +130,8 @@ void CreateXWindow (void)
// Create the window
GLWin.win = XCreateWindow(GLWin.evdpy, GLWin.parent,
GLWin.x, GLWin.y, GLWin.width, GLWin.height, 0, GLWin.vi->depth, InputOutput, GLWin.vi->visual,
GLWin.x, GLWin.y, GLWin.width, GLWin.height, 0,
GLWin.vi->depth, InputOutput, GLWin.vi->visual,
CWBorderPixel | CWBackPixel | CWColormap | CWEventMask, &GLWin.attr);
wmProtocols[0] = XInternAtom(GLWin.evdpy, "WM_DELETE_WINDOW", True);
XSetWMProtocols(GLWin.evdpy, GLWin.win, wmProtocols, 1);
@ -151,7 +146,8 @@ void DestroyXWindow(void)
{
XUnmapWindow(GLWin.dpy, GLWin.win);
GLWin.win = 0;
GLWin.xEventThread.join();
if (GLWin.xEventThread.joinable())
GLWin.xEventThread.join();
XFreeColormap(GLWin.evdpy, GLWin.attr.colormap);
}
@ -298,11 +294,14 @@ void XEventThread()
s_backbuffer_height = GLWin.height;
break;
case ClientMessage:
if ((unsigned long) event.xclient.data.l[0] == XInternAtom(GLWin.evdpy, "WM_DELETE_WINDOW", False))
if ((unsigned long) event.xclient.data.l[0] ==
XInternAtom(GLWin.evdpy, "WM_DELETE_WINDOW", False))
Core::Callback_CoreMessage(WM_USER_STOP);
if ((unsigned long) event.xclient.data.l[0] == XInternAtom(GLWin.evdpy, "RESIZE", False))
XMoveResizeWindow(GLWin.evdpy, GLWin.win, event.xclient.data.l[1],
event.xclient.data.l[2], event.xclient.data.l[3], event.xclient.data.l[4]);
if ((unsigned long) event.xclient.data.l[0] ==
XInternAtom(GLWin.evdpy, "RESIZE", False))
XMoveResizeWindow(GLWin.evdpy, GLWin.win,
event.xclient.data.l[1], event.xclient.data.l[2],
event.xclient.data.l[3], event.xclient.data.l[4]);
break;
default:
break;
@ -385,26 +384,26 @@ bool OpenGL_Create(void *&window_handle)
// Show the window
EmuWindow::Show();
PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
32, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // 8bit Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
24, // 24Bit Z-Buffer (Depth Buffer)
8, // 8bit Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
32, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // 8bit Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
24, // 24Bit Z-Buffer (Depth Buffer)
8, // 8bit Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
GLuint PixelFormat; // Holds The Results After Searching For A Match
@ -413,7 +412,7 @@ bool OpenGL_Create(void *&window_handle)
PanicAlert("(1) Can't create an OpenGL Device context. Fail.");
return false;
}
if (!(PixelFormat = ChoosePixelFormat(hDC,&pfd))) {
if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd))) {
PanicAlert("(2) Can't find a suitable PixelFormat.");
return false;
}
@ -475,7 +474,7 @@ bool OpenGL_Create(void *&window_handle)
GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListSgl);
if (GLWin.vi != NULL)
{
ERROR_LOG(VIDEO, "Only Singlebuffered Visual!");
ERROR_LOG(VIDEO, "Only single buffered visual!");
}
else
{
@ -488,13 +487,13 @@ bool OpenGL_Create(void *&window_handle)
}
}
else
NOTICE_LOG(VIDEO, "Got Doublebuffered Visual!");
NOTICE_LOG(VIDEO, "Got double buffered visual!");
// Create a GLX context.
GLWin.ctx = glXCreateContext(GLWin.dpy, GLWin.vi, 0, GL_TRUE);
if (!GLWin.ctx)
{
PanicAlert("Couldn't Create GLX context.Quit");
PanicAlert("Unable to create GLX context.");
return false;
}
@ -517,17 +516,28 @@ bool OpenGL_MakeCurrent()
#elif defined(__APPLE__)
[GLWin.cocoaCtx makeCurrentContext];
#elif defined(_WIN32)
return wglMakeCurrent(hDC,hRC) ? true : false;
return wglMakeCurrent(hDC, hRC) ? true : false;
#elif defined(HAVE_X11) && HAVE_X11
#if defined(HAVE_WX) && (HAVE_WX)
Core::Callback_VideoGetWindowSize(GLWin.x, GLWin.y, (int&)GLWin.width, (int&)GLWin.height);
XMoveResizeWindow(GLWin.dpy, GLWin.win, GLWin.x, GLWin.y, GLWin.width, GLWin.height);
Core::Callback_VideoGetWindowSize(GLWin.x, GLWin.y,
(int&)GLWin.width, (int&)GLWin.height);
XMoveResizeWindow(GLWin.dpy, GLWin.win, GLWin.x, GLWin.y,
GLWin.width, GLWin.height);
#endif
return glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx);
#endif
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
void OpenGL_Update()
{
@ -577,7 +587,9 @@ void OpenGL_Update()
int height = rcWindow.bottom - rcWindow.top;
// If we are rendering to a child window
if (EmuWindow::GetParentWnd() != 0 && (s_backbuffer_width != width || s_backbuffer_height != height) && width >= 4 && height >= 4)
if (EmuWindow::GetParentWnd() != 0 &&
(s_backbuffer_width != width || s_backbuffer_height != height) &&
width >= 4 && height >= 4)
{
::MoveWindow(EmuWindow::GetWnd(), 0, 0, width, height, FALSE);
s_backbuffer_width = width;
@ -586,7 +598,6 @@ void OpenGL_Update()
#endif
}
// Close backend
void OpenGL_Shutdown()
{
@ -599,27 +610,21 @@ void OpenGL_Shutdown()
[GLWin.cocoaCtx clearDrawable];
[GLWin.cocoaCtx release];
#elif defined(_WIN32)
if (hRC) // Do We Have A Rendering Context?
if (hRC)
{
if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts?
{
// [F|RES]: if this fails i dont see the message box and
// cant get out of the modal state so i disable it.
// This function fails only if i render to main window
// MessageBox(NULL,"Release Of DC And RC Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
}
if (!wglMakeCurrent(NULL, NULL))
NOTICE_LOG(VIDEO, "Could not release drawing context.");
if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
{
if (!wglDeleteContext(hRC))
ERROR_LOG(VIDEO, "Release Rendering Context Failed.");
}
hRC = NULL; // Set RC To NULL
hRC = NULL;
}
if (hDC && !ReleaseDC(EmuWindow::GetWnd(), hDC)) // Are We Able To Release The DC
if (hDC && !ReleaseDC(EmuWindow::GetWnd(), hDC))
{
ERROR_LOG(VIDEO, "Release Device Context Failed.");
hDC = NULL; // Set DC To NULL
hDC = NULL;
}
EmuWindow::Close();
#elif defined(HAVE_X11) && HAVE_X11
@ -641,7 +646,8 @@ GLuint OpenGL_ReportGLError(const char *function, const char *file, int line)
GLint err = glGetError();
if (err != GL_NO_ERROR)
{
ERROR_LOG(VIDEO, "%s:%d: (%s) OpenGL error 0x%x - %s\n", file, line, function, err, gluErrorString(err));
ERROR_LOG(VIDEO, "%s:%d: (%s) OpenGL error 0x%x - %s\n",
file, line, function, err, gluErrorString(err));
}
return err;
}
@ -667,15 +673,30 @@ bool OpenGL_ReportFBOError(const char *function, const char *file, int line)
const char *error = "-";
switch (fbo_status)
{
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: error = "INCOMPLETE_ATTACHMENT_EXT"; break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: error = "INCOMPLETE_MISSING_ATTACHMENT_EXT"; break;
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: error = "INCOMPLETE_DIMENSIONS_EXT"; break;
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: error = "INCOMPLETE_FORMATS_EXT"; break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: error = "INCOMPLETE_DRAW_BUFFER_EXT"; break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: error = "INCOMPLETE_READ_BUFFER_EXT"; break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT: error = "UNSUPPORTED_EXT"; break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
error = "INCOMPLETE_ATTACHMENT_EXT";
break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
error = "INCOMPLETE_MISSING_ATTACHMENT_EXT";
break;
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
error = "INCOMPLETE_DIMENSIONS_EXT";
break;
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
error = "INCOMPLETE_FORMATS_EXT";
break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
error = "INCOMPLETE_DRAW_BUFFER_EXT";
break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
error = "INCOMPLETE_READ_BUFFER_EXT";
break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
error = "UNSUPPORTED_EXT";
break;
}
ERROR_LOG(VIDEO, "%s:%d: (%s) OpenGL FBO error - %s\n", file, line, function, error);
ERROR_LOG(VIDEO, "%s:%d: (%s) OpenGL FBO error - %s\n",
file, line, function, error);
return false;
}
return true;

View File

@ -64,9 +64,8 @@ typedef struct {
int screen;
Window win;
Window parent;
// dpy (mainly) used for glx stuff, evdpy for window events etc.
// used to keep the two threads from eating each others events
// evdpy is to be used by XEventThread only (when it is running)
// dpy used for glx stuff, evdpy for window events etc.
// evdpy is to be used by XEventThread only
Display *dpy, *evdpy;
XVisualInfo *vi;
GLXContext ctx;
@ -88,6 +87,7 @@ bool OpenGL_Create(void *&);
void OpenGL_Shutdown();
void OpenGL_Update();
bool OpenGL_MakeCurrent();
bool OpenGL_ReleaseContext();
void OpenGL_SwapBuffers();
// Get status

View File

@ -176,14 +176,12 @@ bool VideoBackend::Initialize(void *&window_handle)
OSD::AddMessage("Dolphin OpenGL Video Backend.", 5000);
s_BackendInitialized = true;
return true;
}
// This is called after Initialize() from the Core
// Run from the graphics thread
void VideoBackend::Video_Prepare()
{
OpenGL_MakeCurrent();
if (!OpenGL_MakeCurrent())
{
ERROR_LOG(VIDEO, "Unable to connect to OpenGL context.");
OpenGL_Shutdown();
return false;
}
g_renderer = new Renderer;
@ -210,6 +208,22 @@ void VideoBackend::Video_Prepare()
TextureConverter::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
Core::Callback_CoreMessage(WM_USER_CREATE);
}