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,27 +457,44 @@ bool Display::createDevice()
bool Display::resetDevice()
{
D3DPRESENT_PARAMETERS presentParameters = getDefaultPresentParameters();
HRESULT result = mDevice->TestCooperativeLevel();
while (result == D3DERR_DEVICELOST)
{
Sleep(100); // Give the graphics driver some CPU time
result = mDevice->TestCooperativeLevel();
}
HRESULT result = D3D_OK;
bool lost = isDeviceLost();
int attempts = 3;
if (result == D3DERR_DEVICENOTRESET)
while (lost && attempts > 0)
{
result = mDevice->Reset(&presentParameters);
if (mDeviceEx)
{
Sleep(500); // Give the graphics driver some CPU time
result = mDeviceEx->ResetEx(&presentParameters, NULL);
}
else
{
result = mDevice->TestCooperativeLevel();
while (result == D3DERR_DEVICELOST)
{
Sleep(100); // Give the graphics driver some CPU time
result = mDevice->TestCooperativeLevel();
}
if (result == D3DERR_DEVICENOTRESET)
{
result = mDevice->Reset(&presentParameters);
}
}
lost = isDeviceLost();
attempts --;
}
if (FAILED(result))
{
ERR("Reset/ResetEx failed multiple times: 0x%08X", result);
return error(EGL_BAD_ALLOC, false);
}
ASSERT(SUCCEEDED(result));
return true;
}
......
......@@ -106,7 +106,7 @@ bool Surface::initialize()
result = DwmSetPresentParameters(mWindow, &presentParams);
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)
{
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();
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