Check for all device lost errors.

TRAC #18606
Signed-off-by: Daniel Koch
Author: Shannon Woods

git-svn-id: https://angleproject.googlecode.com/svn/trunk@844 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libEGL/Surface.cpp b/src/libEGL/Surface.cpp
index e903cda..c62bdaa 100644
--- a/src/libEGL/Surface.cpp
+++ b/src/libEGL/Surface.cpp
@@ -255,7 +255,7 @@
         ERR("Could not create additional swap chains or offscreen surfaces: %08lX", result);
         release();
 
-        if(result == D3DERR_DEVICELOST)
+        if(isDeviceLostError(result))
         {
             return error(EGL_CONTEXT_LOST, false);
         }
@@ -421,12 +421,12 @@
 
         HRESULT result = mSwapChain->Present(NULL, NULL, NULL, NULL, 0);
 
-        if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_DRIVERINTERNALERROR)
+        if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
         {
             return error(EGL_BAD_ALLOC, false);
         }
 
-        if (result == D3DERR_DEVICELOST || result == D3DERR_DEVICEHUNG || result == D3DERR_DEVICEREMOVED)
+        if (isDeviceLostError(result))
         {
             return error(EGL_CONTEXT_LOST, false);
         }
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index ceaca85..b16c930 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -2229,18 +2229,16 @@
     {
         systemSurface->Release();
 
-        switch (result)
-        {
-          // It turns out that D3D will sometimes produce more error
-          // codes than those documented.
-          case D3DERR_DRIVERINTERNALERROR:
-          case D3DERR_DEVICELOST:
-          case D3DERR_DEVICEHUNG:
+        // It turns out that D3D will sometimes produce more error
+        // codes than those documented.
+        if (checkDeviceLost(result))
             return error(GL_OUT_OF_MEMORY);
-          default:
+        else
+        {
             UNREACHABLE();
-            return;   // No sensible error to generate
+            return;
         }
+
     }
 
     D3DLOCKED_RECT lock;
@@ -2826,7 +2824,7 @@
 
     eventQuery->Release();
 
-    if (result == D3DERR_DEVICELOST)
+    if (checkDeviceLost(result))
     {
         error(GL_OUT_OF_MEMORY);
     }
diff --git a/src/libGLESv2/Fence.cpp b/src/libGLESv2/Fence.cpp
index 7fbcb6a..96a3cc9 100644
--- a/src/libGLESv2/Fence.cpp
+++ b/src/libGLESv2/Fence.cpp
@@ -65,7 +65,7 @@
 
     HRESULT result = mQuery->GetData(NULL, 0, D3DGETDATA_FLUSH);
 
-    if (result == D3DERR_DEVICELOST)
+    if (checkDeviceLost(result))
     {
        return error(GL_OUT_OF_MEMORY, GL_TRUE);
     }
@@ -110,7 +110,7 @@
             
             HRESULT result = mQuery->GetData(NULL, 0, 0);
             
-            if (result == D3DERR_DEVICELOST)
+            if (checkDeviceLost(result))
             {
                 params[0] = GL_TRUE;
                 return error(GL_OUT_OF_MEMORY);