Commit 9c721c64 by Corentin Wallez Committed by Commit Bot

Check for device loss on all applicable EGL entry-points

This will make applications aware of device loss on all EGL calls that need to have an initialized display. For that purpose, we track the device loss state at the egl::Display level instead of always querying the implementation. This is correct because at device-loss at the display level is non-recoverable. It also deduplicates the tracking that would have to be done in all the EGL backends. Changes made in this commit: - Cached device loss in egl::Display - Check isDeviceLost in ValidateDisplay - Changed EGL entry-points testing isDeviceLost to explicitely request a testDeviceLost - Add calls to ValidateDisplay to entry-points missing it - Removed unused virtual qualifiers for some robustness methods BUG=angleproject:1463 Change-Id: I92bea81f2ecd5423c445cff31557a4d9783557d5 Reviewed-on: https://chromium-review.googlesource.com/365450Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent 6bbdce5b
......@@ -68,7 +68,7 @@ class Context final : public ValidationContext
void makeCurrent(egl::Surface *surface);
void releaseSurface();
virtual void markContextLost();
void markContextLost();
bool isContextLost();
// These create and destroy methods are merely pass-throughs to
......@@ -556,7 +556,7 @@ class Context final : public ValidationContext
GLenum getError();
GLenum getResetStatus();
virtual bool isResetNotificationEnabled();
bool isResetNotificationEnabled();
const egl::Config *getConfig() const;
EGLenum getClientType() const;
......
......@@ -321,6 +321,7 @@ Display::Display(EGLenum platform, EGLNativeDisplayType displayId, Device *eglDe
mContextSet(),
mStreamSet(),
mInitialized(false),
mDeviceLost(false),
mCaps(),
mDisplayExtensions(),
mDisplayExtensionString(),
......@@ -773,21 +774,31 @@ void Display::destroyContext(gl::Context *context)
bool Display::isDeviceLost() const
{
ASSERT(isInitialized());
return mImplementation->isDeviceLost();
return mDeviceLost;
}
bool Display::testDeviceLost()
{
ASSERT(isInitialized());
return mImplementation->testDeviceLost();
if (!mDeviceLost && mImplementation->testDeviceLost())
{
notifyDeviceLost();
}
return mDeviceLost;
}
void Display::notifyDeviceLost()
{
ASSERT(!mDeviceLost);
for (ContextSet::iterator context = mContextSet.begin(); context != mContextSet.end(); context++)
{
(*context)->markContextLost();
}
mDeviceLost = true;
}
Error Display::waitClient() const
......
......@@ -138,6 +138,7 @@ class Display final : angle::NonCopyable
StreamSet mStreamSet;
bool mInitialized;
bool mDeviceLost;
Caps mCaps;
......
......@@ -54,7 +54,6 @@ class DisplayImpl : public EGLImplFactory
virtual egl::ConfigSet generateConfigs() = 0;
virtual bool isDeviceLost() const = 0;
virtual bool testDeviceLost() = 0;
virtual egl::Error restoreLostDevice() = 0;
......
......@@ -254,12 +254,6 @@ egl::ConfigSet DisplayD3D::generateConfigs()
return mRenderer->generateConfigs();
}
bool DisplayD3D::isDeviceLost() const
{
ASSERT(mRenderer != nullptr);
return mRenderer->isDeviceLost();
}
bool DisplayD3D::testDeviceLost()
{
ASSERT(mRenderer != nullptr);
......
......@@ -55,7 +55,6 @@ class DisplayD3D : public DisplayImpl
egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override;
egl::Error restoreLostDevice() override;
......
......@@ -44,7 +44,6 @@ class DisplayCGL : public DisplayGL
egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override;
egl::Error restoreLostDevice() override;
......
......@@ -214,12 +214,6 @@ egl::ConfigSet DisplayCGL::generateConfigs()
return configs;
}
bool DisplayCGL::isDeviceLost() const
{
// TODO(cwallez) investigate implementing this
return false;
}
bool DisplayCGL::testDeviceLost()
{
// TODO(cwallez) investigate implementing this
......
......@@ -334,11 +334,6 @@ egl::ConfigSet DisplayAndroid::generateConfigs()
return configSet;
}
bool DisplayAndroid::isDeviceLost() const
{
return false;
}
bool DisplayAndroid::testDeviceLost()
{
return false;
......
......@@ -49,7 +49,6 @@ class DisplayAndroid : public DisplayEGL
egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override;
egl::Error restoreLostDevice() override;
......
......@@ -900,11 +900,6 @@ egl::ConfigSet DisplayOzone::generateConfigs()
return configs;
}
bool DisplayOzone::isDeviceLost() const
{
return false;
}
bool DisplayOzone::testDeviceLost()
{
return false;
......
......@@ -131,7 +131,6 @@ class DisplayOzone final : public DisplayEGL
egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override;
egl::Error restoreLostDevice() override;
......
......@@ -725,12 +725,6 @@ egl::ConfigSet DisplayGLX::generateConfigs()
return configs;
}
bool DisplayGLX::isDeviceLost() const
{
// UNIMPLEMENTED();
return false;
}
bool DisplayGLX::testDeviceLost()
{
// UNIMPLEMENTED();
......@@ -751,7 +745,7 @@ bool DisplayGLX::isValidNativeWindow(EGLNativeWindowType window) const
// fail if the window doesn't exist (the rational is that these function
// are used by window managers). Out of these function we use XQueryTree
// as it seems to be the simplest; a drawback is that it will allocate
// memory for the list of children, becasue we use a child window for
// memory for the list of children, because we use a child window for
// WindowSurface.
Window root;
Window parent;
......
......@@ -62,7 +62,6 @@ class DisplayGLX : public DisplayGL
egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override;
egl::Error restoreLostDevice() override;
......
......@@ -541,12 +541,6 @@ egl::ConfigSet DisplayWGL::generateConfigs()
return configs;
}
bool DisplayWGL::isDeviceLost() const
{
//UNIMPLEMENTED();
return false;
}
bool DisplayWGL::testDeviceLost()
{
//UNIMPLEMENTED();
......
......@@ -46,7 +46,6 @@ class DisplayWGL : public DisplayGL
egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override;
egl::Error restoreLostDevice() override;
......
......@@ -48,12 +48,6 @@ egl::ConfigSet DisplayVk::generateConfigs()
return egl::ConfigSet();
}
bool DisplayVk::isDeviceLost() const
{
UNIMPLEMENTED();
return bool();
}
bool DisplayVk::testDeviceLost()
{
UNIMPLEMENTED();
......
......@@ -31,7 +31,6 @@ class DisplayVk : public DisplayImpl
egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override;
egl::Error restoreLostDevice() override;
......
......@@ -174,6 +174,11 @@ Error ValidateDisplay(const Display *display)
return Error(EGL_NOT_INITIALIZED, "display is not initialized.");
}
if (display->isDeviceLost())
{
return Error(EGL_CONTEXT_LOST, "display had a context loss");
}
return Error(EGL_SUCCESS);
}
......@@ -1453,6 +1458,8 @@ Error ValidateCreateStreamProducerD3DTextureNV12ANGLE(const Display *display,
const Stream *stream,
const AttributeMap &attribs)
{
ANGLE_TRY(ValidateDisplay(display));
const DisplayExtensions &displayExtensions = display->getExtensions();
if (!displayExtensions.streamProducerD3DTextureNV12)
{
......
......@@ -583,19 +583,10 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r
}
}
if (display->isInitialized())
if (display->isInitialized() && display->testDeviceLost())
{
if (display->testDeviceLost())
{
display->notifyDeviceLost();
return EGL_FALSE;
}
if (display->isDeviceLost())
{
SetGlobalError(Error(EGL_CONTEXT_LOST));
return EGL_FALSE;
}
SetGlobalError(Error(EGL_CONTEXT_LOST));
return EGL_FALSE;
}
Surface *drawSurface = static_cast<Surface*>(draw);
......@@ -813,7 +804,7 @@ EGLBoolean EGLAPIENTRY SwapBuffers(EGLDisplay dpy, EGLSurface surface)
return EGL_FALSE;
}
if (display->isDeviceLost())
if (display->testDeviceLost())
{
SetGlobalError(Error(EGL_CONTEXT_LOST));
return EGL_FALSE;
......@@ -850,7 +841,7 @@ EGLBoolean EGLAPIENTRY CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNative
return EGL_FALSE;
}
if (display->isDeviceLost())
if (display->testDeviceLost())
{
SetGlobalError(Error(EGL_CONTEXT_LOST));
return EGL_FALSE;
......
......@@ -98,7 +98,7 @@ EGLBoolean EGLAPIENTRY PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLin
return EGL_FALSE;
}
if (display->isDeviceLost())
if (display->testDeviceLost())
{
SetGlobalError(Error(EGL_CONTEXT_LOST));
return EGL_FALSE;
......@@ -433,7 +433,13 @@ EGLBoolean EGLAPIENTRY QueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, E
dpy, attribute, value);
Display *display = static_cast<Display*>(dpy);
Error error(EGL_SUCCESS);
Error error = ValidateDisplay(display);
if (error.isError())
{
SetGlobalError(error);
return EGL_FALSE;
}
if (!display->getExtensions().deviceQuery)
{
......
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