Add device error checking utility functions.
TRAC #18606
Signed-off-by: Daniel Koch
Author: Shannon Woods
git-svn-id: http://angleproject.googlecode.com/svn/trunk@843 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/main.cpp b/src/libGLESv2/main.cpp
index ad11563..83ea8fe 100644
--- a/src/libGLESv2/main.cpp
+++ b/src/libGLESv2/main.cpp
@@ -7,6 +7,7 @@
// main.cpp: DLL entry point and management of thread-local data.
#include "libGLESv2/main.h"
+#include "libGLESv2/utilities.h"
#include "common/debug.h"
#include "libEGL/Surface.h"
@@ -106,6 +107,17 @@
return display->getDevice();
}
+
+bool checkDeviceLost(HRESULT errorCode)
+{
+ egl::Display *display = NULL;
+
+ if (isDeviceLostError(errorCode))
+ {
+ return true;
+ }
+ return false;
+}
}
// Records an error code
diff --git a/src/libGLESv2/main.h b/src/libGLESv2/main.h
index 7f9c880..a3331a2 100644
--- a/src/libGLESv2/main.h
+++ b/src/libGLESv2/main.h
@@ -32,6 +32,8 @@
egl::Display *getDisplay();
IDirect3DDevice9 *getDevice();
+
+bool checkDeviceLost(HRESULT errorCode);
}
void error(GLenum errorCode);
diff --git a/src/libGLESv2/utilities.h b/src/libGLESv2/utilities.h
index 0ef3e4c..b53cdf2 100644
--- a/src/libGLESv2/utilities.h
+++ b/src/libGLESv2/utilities.h
@@ -87,4 +87,18 @@
std::string getTempPath();
void writeFile(const char* path, const void* data, size_t size);
+inline bool isDeviceLostError(HRESULT errorCode)
+{
+ switch (errorCode)
+ {
+ case D3DERR_DRIVERINTERNALERROR:
+ case D3DERR_DEVICELOST:
+ case D3DERR_DEVICEHUNG:
+ case D3DERR_DEVICEREMOVED:
+ return true;
+ default:
+ return false;
+ }
+};
+
#endif // LIBGLESV2_UTILITIES_H