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
diff --git a/src/libEGL/Display.cpp b/src/libEGL/Display.cpp
index d17f71a..373a970 100644
--- a/src/libEGL/Display.cpp
+++ b/src/libEGL/Display.cpp
@@ -457,27 +457,44 @@
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;
}