Call ResetEx on lost or hung Ex devices. Attempt calling Reset/ResetEx at most 3 times.

TRAC #18386 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@816 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 94910c9e
...@@ -457,12 +457,25 @@ bool Display::createDevice() ...@@ -457,12 +457,25 @@ bool Display::createDevice()
bool Display::resetDevice() bool Display::resetDevice()
{ {
D3DPRESENT_PARAMETERS presentParameters = getDefaultPresentParameters(); D3DPRESENT_PARAMETERS presentParameters = getDefaultPresentParameters();
HRESULT result = mDevice->TestCooperativeLevel();
HRESULT result = D3D_OK;
bool lost = isDeviceLost();
int attempts = 3;
while (lost && attempts > 0)
{
if (mDeviceEx)
{
Sleep(500); // Give the graphics driver some CPU time
result = mDeviceEx->ResetEx(&presentParameters, NULL);
}
else
{
result = mDevice->TestCooperativeLevel();
while (result == D3DERR_DEVICELOST) while (result == D3DERR_DEVICELOST)
{ {
Sleep(100); // Give the graphics driver some CPU time Sleep(100); // Give the graphics driver some CPU time
result = mDevice->TestCooperativeLevel(); result = mDevice->TestCooperativeLevel();
} }
...@@ -470,14 +483,18 @@ bool Display::resetDevice() ...@@ -470,14 +483,18 @@ bool Display::resetDevice()
{ {
result = mDevice->Reset(&presentParameters); result = mDevice->Reset(&presentParameters);
} }
}
lost = isDeviceLost();
attempts --;
}
if (FAILED(result)) if (FAILED(result))
{ {
ERR("Reset/ResetEx failed multiple times: 0x%08X", result);
return error(EGL_BAD_ALLOC, false); return error(EGL_BAD_ALLOC, false);
} }
ASSERT(SUCCEEDED(result));
return true; return true;
} }
......
...@@ -106,7 +106,7 @@ bool Surface::initialize() ...@@ -106,7 +106,7 @@ bool Surface::initialize()
result = DwmSetPresentParameters(mWindow, &presentParams); result = DwmSetPresentParameters(mWindow, &presentParams);
if (FAILED(result)) if (FAILED(result))
ERR("Unable to set present parameters: %081X", result); ERR("Unable to set present parameters: 0x%08X", result);
} }
} }
...@@ -268,7 +268,7 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) ...@@ -268,7 +268,7 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
{ {
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL); ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL);
ERR("Could not create depthstencil surface for new swap chain: %08lX", result); ERR("Could not create depthstencil surface for new swap chain: 0x%08X", result);
release(); release();
return error(EGL_BAD_ALLOC, false); return error(EGL_BAD_ALLOC, false);
} }
......
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