Commit 8c9c4521 by vangelis@google.com

Adding code to try and reset the device if eglCreateWindowSurface and eglCreateSurface are

called while the device is reported as lost. Currently only eglCreateContext attempts to reset the device. This is a short term fix until the whole device lost issue can be revisited. One of the issues here is that if any of these egl entry points are called while the device is lost (e.g. while the screen saver is on in XP) ANGLE will spin until the device comes back. Review URL: http://codereview.appspot.com/4961070 git-svn-id: https://angleproject.googlecode.com/svn/trunk@746 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent f5450910
...@@ -515,6 +515,11 @@ EGLSurface Display::createWindowSurface(HWND window, EGLConfig config, const EGL ...@@ -515,6 +515,11 @@ EGLSurface Display::createWindowSurface(HWND window, EGLConfig config, const EGL
return error(EGL_BAD_ALLOC, EGL_NO_SURFACE); return error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
} }
if (isDeviceLost()) {
if (!restoreLostDevice())
return EGL_NO_SURFACE;
}
Surface *surface = new Surface(this, configuration, window); Surface *surface = new Surface(this, configuration, window);
if (!surface->initialize()) if (!surface->initialize())
...@@ -622,6 +627,11 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle, ...@@ -622,6 +627,11 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle,
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
} }
if (isDeviceLost()) {
if (!restoreLostDevice())
return EGL_NO_SURFACE;
}
Surface *surface = new Surface(this, configuration, shareHandle, width, height, textureFormat, textureTarget); Surface *surface = new Surface(this, configuration, shareHandle, width, height, textureFormat, textureTarget);
if (!surface->initialize()) if (!surface->initialize())
...@@ -646,22 +656,8 @@ EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *sha ...@@ -646,22 +656,8 @@ EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *sha
} }
else if (isDeviceLost()) // Lost device else if (isDeviceLost()) // Lost device
{ {
// Release surface resources to make the Reset() succeed if (!restoreLostDevice())
for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
{
(*surface)->release();
}
if (!resetDevice())
{
return NULL; return NULL;
}
// Restore any surfaces that may have been lost
for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
{
(*surface)->resetSwapChain();
}
} }
const egl::Config *config = mConfigSet.get(configHandle); const egl::Config *config = mConfigSet.get(configHandle);
...@@ -672,6 +668,29 @@ EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *sha ...@@ -672,6 +668,29 @@ EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *sha
return context; return context;
} }
bool Display::restoreLostDevice()
{
// Release surface resources to make the Reset() succeed
for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
{
(*surface)->release();
}
if (!resetDevice())
{
return false;
}
// Restore any surfaces that may have been lost
for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
{
(*surface)->resetSwapChain();
}
return true;
}
void Display::destroySurface(egl::Surface *surface) void Display::destroySurface(egl::Surface *surface)
{ {
delete surface; delete surface;
......
...@@ -85,6 +85,8 @@ class Display ...@@ -85,6 +85,8 @@ class Display
D3DPRESENT_PARAMETERS getDefaultPresentParameters(); D3DPRESENT_PARAMETERS getDefaultPresentParameters();
bool restoreLostDevice();
EGLNativeDisplayType mDisplayId; EGLNativeDisplayType mDisplayId;
const HDC mDc; const HDC mDc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment