Terminate session on any error from eglSwapBuffers()
authorPyry Haulos <phaulos@google.com>
Fri, 3 Oct 2014 20:11:16 +0000 (13:11 -0700)
committerPyry Haulos <phaulos@google.com>
Fri, 3 Oct 2014 20:17:43 +0000 (13:17 -0700)
Test run should always abort if eglSwapBuffers() gives an error as it
is almost always a sign that something has gone unrecoverably wrong in
the driver.

 * Always throw tcu::ResourceError on any error from eglSwapBuffers().
This will make TestExecutor to abort the session.

 * Treat EGL_BAD_NATIVE_WINDOW as a sign of potentially destroyed
underlying window, not just EGL_BAD_SURFACE.

Change-Id: I42f3769566670630e3965b0ff50119297639fd5c

framework/egl/egluGLContextFactory.cpp

index 358edff..6a23acc 100644 (file)
@@ -34,6 +34,7 @@
 #include "egluUtil.hpp"
 #include "egluNativeWindow.hpp"
 #include "egluNativePixmap.hpp"
+#include "egluStrUtil.hpp"
 
 #include "glwInitFunctions.hpp"
 #include "glwInitES20Direct.hpp"
@@ -641,18 +642,12 @@ void RenderContext::postIterate (void)
 {
        if (m_window)
        {
-               EGLBoolean      swapOk  = eglSwapBuffers(m_eglDisplay, m_eglSurface);
-               EGLint          error   = eglGetError();
+               EGLBoolean      swapOk          = eglSwapBuffers(m_eglDisplay, m_eglSurface);
+               EGLint          error           = eglGetError();
+               const bool      badWindow       = error == EGL_BAD_SURFACE || error == EGL_BAD_NATIVE_WINDOW;
 
-               if (!swapOk && error != EGL_BAD_SURFACE)
-               {
-                       if (error == EGL_BAD_ALLOC)
-                               throw BadAllocError("eglSwapBuffers()");
-                       else if (error == EGL_CONTEXT_LOST)
-                               throw tcu::ResourceError("eglSwapBuffers() failed, context lost");
-                       else
-                               throw Error(error, "eglSwapBuffers()");
-               }
+               if (!swapOk && !badWindow)
+                       throw tcu::ResourceError(string("eglSwapBuffers() failed: ") + getErrorStr(error).toString());
 
                try
                {
@@ -698,8 +693,8 @@ void RenderContext::postIterate (void)
 
                if (!swapOk)
                {
-                       DE_ASSERT(error == EGL_BAD_SURFACE);
-                       throw Error(error, "eglSwapBuffers()");
+                       DE_ASSERT(badWindow);
+                       throw tcu::ResourceError(string("eglSwapBuffers() failed: ") + getErrorStr(error).toString());
                }
 
                // Refresh dimensions