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 ...@@ -68,7 +68,7 @@ class Context final : public ValidationContext
void makeCurrent(egl::Surface *surface); void makeCurrent(egl::Surface *surface);
void releaseSurface(); void releaseSurface();
virtual void markContextLost(); void markContextLost();
bool isContextLost(); bool isContextLost();
// These create and destroy methods are merely pass-throughs to // These create and destroy methods are merely pass-throughs to
...@@ -556,7 +556,7 @@ class Context final : public ValidationContext ...@@ -556,7 +556,7 @@ class Context final : public ValidationContext
GLenum getError(); GLenum getError();
GLenum getResetStatus(); GLenum getResetStatus();
virtual bool isResetNotificationEnabled(); bool isResetNotificationEnabled();
const egl::Config *getConfig() const; const egl::Config *getConfig() const;
EGLenum getClientType() const; EGLenum getClientType() const;
......
...@@ -321,6 +321,7 @@ Display::Display(EGLenum platform, EGLNativeDisplayType displayId, Device *eglDe ...@@ -321,6 +321,7 @@ Display::Display(EGLenum platform, EGLNativeDisplayType displayId, Device *eglDe
mContextSet(), mContextSet(),
mStreamSet(), mStreamSet(),
mInitialized(false), mInitialized(false),
mDeviceLost(false),
mCaps(), mCaps(),
mDisplayExtensions(), mDisplayExtensions(),
mDisplayExtensionString(), mDisplayExtensionString(),
...@@ -773,21 +774,31 @@ void Display::destroyContext(gl::Context *context) ...@@ -773,21 +774,31 @@ void Display::destroyContext(gl::Context *context)
bool Display::isDeviceLost() const bool Display::isDeviceLost() const
{ {
ASSERT(isInitialized()); ASSERT(isInitialized());
return mImplementation->isDeviceLost(); return mDeviceLost;
} }
bool Display::testDeviceLost() bool Display::testDeviceLost()
{ {
ASSERT(isInitialized()); ASSERT(isInitialized());
return mImplementation->testDeviceLost();
if (!mDeviceLost && mImplementation->testDeviceLost())
{
notifyDeviceLost();
}
return mDeviceLost;
} }
void Display::notifyDeviceLost() void Display::notifyDeviceLost()
{ {
ASSERT(!mDeviceLost);
for (ContextSet::iterator context = mContextSet.begin(); context != mContextSet.end(); context++) for (ContextSet::iterator context = mContextSet.begin(); context != mContextSet.end(); context++)
{ {
(*context)->markContextLost(); (*context)->markContextLost();
} }
mDeviceLost = true;
} }
Error Display::waitClient() const Error Display::waitClient() const
......
...@@ -138,6 +138,7 @@ class Display final : angle::NonCopyable ...@@ -138,6 +138,7 @@ class Display final : angle::NonCopyable
StreamSet mStreamSet; StreamSet mStreamSet;
bool mInitialized; bool mInitialized;
bool mDeviceLost;
Caps mCaps; Caps mCaps;
......
...@@ -54,7 +54,6 @@ class DisplayImpl : public EGLImplFactory ...@@ -54,7 +54,6 @@ class DisplayImpl : public EGLImplFactory
virtual egl::ConfigSet generateConfigs() = 0; virtual egl::ConfigSet generateConfigs() = 0;
virtual bool isDeviceLost() const = 0;
virtual bool testDeviceLost() = 0; virtual bool testDeviceLost() = 0;
virtual egl::Error restoreLostDevice() = 0; virtual egl::Error restoreLostDevice() = 0;
......
...@@ -254,12 +254,6 @@ egl::ConfigSet DisplayD3D::generateConfigs() ...@@ -254,12 +254,6 @@ egl::ConfigSet DisplayD3D::generateConfigs()
return mRenderer->generateConfigs(); return mRenderer->generateConfigs();
} }
bool DisplayD3D::isDeviceLost() const
{
ASSERT(mRenderer != nullptr);
return mRenderer->isDeviceLost();
}
bool DisplayD3D::testDeviceLost() bool DisplayD3D::testDeviceLost()
{ {
ASSERT(mRenderer != nullptr); ASSERT(mRenderer != nullptr);
......
...@@ -55,7 +55,6 @@ class DisplayD3D : public DisplayImpl ...@@ -55,7 +55,6 @@ class DisplayD3D : public DisplayImpl
egl::ConfigSet generateConfigs() override; egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override; bool testDeviceLost() override;
egl::Error restoreLostDevice() override; egl::Error restoreLostDevice() override;
......
...@@ -44,7 +44,6 @@ class DisplayCGL : public DisplayGL ...@@ -44,7 +44,6 @@ class DisplayCGL : public DisplayGL
egl::ConfigSet generateConfigs() override; egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override; bool testDeviceLost() override;
egl::Error restoreLostDevice() override; egl::Error restoreLostDevice() override;
......
...@@ -214,12 +214,6 @@ egl::ConfigSet DisplayCGL::generateConfigs() ...@@ -214,12 +214,6 @@ egl::ConfigSet DisplayCGL::generateConfigs()
return configs; return configs;
} }
bool DisplayCGL::isDeviceLost() const
{
// TODO(cwallez) investigate implementing this
return false;
}
bool DisplayCGL::testDeviceLost() bool DisplayCGL::testDeviceLost()
{ {
// TODO(cwallez) investigate implementing this // TODO(cwallez) investigate implementing this
......
...@@ -334,11 +334,6 @@ egl::ConfigSet DisplayAndroid::generateConfigs() ...@@ -334,11 +334,6 @@ egl::ConfigSet DisplayAndroid::generateConfigs()
return configSet; return configSet;
} }
bool DisplayAndroid::isDeviceLost() const
{
return false;
}
bool DisplayAndroid::testDeviceLost() bool DisplayAndroid::testDeviceLost()
{ {
return false; return false;
......
...@@ -49,7 +49,6 @@ class DisplayAndroid : public DisplayEGL ...@@ -49,7 +49,6 @@ class DisplayAndroid : public DisplayEGL
egl::ConfigSet generateConfigs() override; egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override; bool testDeviceLost() override;
egl::Error restoreLostDevice() override; egl::Error restoreLostDevice() override;
......
...@@ -900,11 +900,6 @@ egl::ConfigSet DisplayOzone::generateConfigs() ...@@ -900,11 +900,6 @@ egl::ConfigSet DisplayOzone::generateConfigs()
return configs; return configs;
} }
bool DisplayOzone::isDeviceLost() const
{
return false;
}
bool DisplayOzone::testDeviceLost() bool DisplayOzone::testDeviceLost()
{ {
return false; return false;
......
...@@ -131,7 +131,6 @@ class DisplayOzone final : public DisplayEGL ...@@ -131,7 +131,6 @@ class DisplayOzone final : public DisplayEGL
egl::ConfigSet generateConfigs() override; egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override; bool testDeviceLost() override;
egl::Error restoreLostDevice() override; egl::Error restoreLostDevice() override;
......
...@@ -725,12 +725,6 @@ egl::ConfigSet DisplayGLX::generateConfigs() ...@@ -725,12 +725,6 @@ egl::ConfigSet DisplayGLX::generateConfigs()
return configs; return configs;
} }
bool DisplayGLX::isDeviceLost() const
{
// UNIMPLEMENTED();
return false;
}
bool DisplayGLX::testDeviceLost() bool DisplayGLX::testDeviceLost()
{ {
// UNIMPLEMENTED(); // UNIMPLEMENTED();
...@@ -751,7 +745,7 @@ bool DisplayGLX::isValidNativeWindow(EGLNativeWindowType window) const ...@@ -751,7 +745,7 @@ bool DisplayGLX::isValidNativeWindow(EGLNativeWindowType window) const
// fail if the window doesn't exist (the rational is that these function // 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 // 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 // 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. // WindowSurface.
Window root; Window root;
Window parent; Window parent;
......
...@@ -62,7 +62,6 @@ class DisplayGLX : public DisplayGL ...@@ -62,7 +62,6 @@ class DisplayGLX : public DisplayGL
egl::ConfigSet generateConfigs() override; egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override; bool testDeviceLost() override;
egl::Error restoreLostDevice() override; egl::Error restoreLostDevice() override;
......
...@@ -541,12 +541,6 @@ egl::ConfigSet DisplayWGL::generateConfigs() ...@@ -541,12 +541,6 @@ egl::ConfigSet DisplayWGL::generateConfigs()
return configs; return configs;
} }
bool DisplayWGL::isDeviceLost() const
{
//UNIMPLEMENTED();
return false;
}
bool DisplayWGL::testDeviceLost() bool DisplayWGL::testDeviceLost()
{ {
//UNIMPLEMENTED(); //UNIMPLEMENTED();
......
...@@ -46,7 +46,6 @@ class DisplayWGL : public DisplayGL ...@@ -46,7 +46,6 @@ class DisplayWGL : public DisplayGL
egl::ConfigSet generateConfigs() override; egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override; bool testDeviceLost() override;
egl::Error restoreLostDevice() override; egl::Error restoreLostDevice() override;
......
...@@ -48,12 +48,6 @@ egl::ConfigSet DisplayVk::generateConfigs() ...@@ -48,12 +48,6 @@ egl::ConfigSet DisplayVk::generateConfigs()
return egl::ConfigSet(); return egl::ConfigSet();
} }
bool DisplayVk::isDeviceLost() const
{
UNIMPLEMENTED();
return bool();
}
bool DisplayVk::testDeviceLost() bool DisplayVk::testDeviceLost()
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
......
...@@ -31,7 +31,6 @@ class DisplayVk : public DisplayImpl ...@@ -31,7 +31,6 @@ class DisplayVk : public DisplayImpl
egl::ConfigSet generateConfigs() override; egl::ConfigSet generateConfigs() override;
bool isDeviceLost() const override;
bool testDeviceLost() override; bool testDeviceLost() override;
egl::Error restoreLostDevice() override; egl::Error restoreLostDevice() override;
......
...@@ -174,6 +174,11 @@ Error ValidateDisplay(const Display *display) ...@@ -174,6 +174,11 @@ Error ValidateDisplay(const Display *display)
return Error(EGL_NOT_INITIALIZED, "display is not initialized."); 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); return Error(EGL_SUCCESS);
} }
...@@ -1453,6 +1458,8 @@ Error ValidateCreateStreamProducerD3DTextureNV12ANGLE(const Display *display, ...@@ -1453,6 +1458,8 @@ Error ValidateCreateStreamProducerD3DTextureNV12ANGLE(const Display *display,
const Stream *stream, const Stream *stream,
const AttributeMap &attribs) const AttributeMap &attribs)
{ {
ANGLE_TRY(ValidateDisplay(display));
const DisplayExtensions &displayExtensions = display->getExtensions(); const DisplayExtensions &displayExtensions = display->getExtensions();
if (!displayExtensions.streamProducerD3DTextureNV12) if (!displayExtensions.streamProducerD3DTextureNV12)
{ {
......
...@@ -583,19 +583,10 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r ...@@ -583,19 +583,10 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r
} }
} }
if (display->isInitialized()) if (display->isInitialized() && display->testDeviceLost())
{ {
if (display->testDeviceLost()) SetGlobalError(Error(EGL_CONTEXT_LOST));
{ return EGL_FALSE;
display->notifyDeviceLost();
return EGL_FALSE;
}
if (display->isDeviceLost())
{
SetGlobalError(Error(EGL_CONTEXT_LOST));
return EGL_FALSE;
}
} }
Surface *drawSurface = static_cast<Surface*>(draw); Surface *drawSurface = static_cast<Surface*>(draw);
...@@ -813,7 +804,7 @@ EGLBoolean EGLAPIENTRY SwapBuffers(EGLDisplay dpy, EGLSurface surface) ...@@ -813,7 +804,7 @@ EGLBoolean EGLAPIENTRY SwapBuffers(EGLDisplay dpy, EGLSurface surface)
return EGL_FALSE; return EGL_FALSE;
} }
if (display->isDeviceLost()) if (display->testDeviceLost())
{ {
SetGlobalError(Error(EGL_CONTEXT_LOST)); SetGlobalError(Error(EGL_CONTEXT_LOST));
return EGL_FALSE; return EGL_FALSE;
...@@ -850,7 +841,7 @@ EGLBoolean EGLAPIENTRY CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNative ...@@ -850,7 +841,7 @@ EGLBoolean EGLAPIENTRY CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNative
return EGL_FALSE; return EGL_FALSE;
} }
if (display->isDeviceLost()) if (display->testDeviceLost())
{ {
SetGlobalError(Error(EGL_CONTEXT_LOST)); SetGlobalError(Error(EGL_CONTEXT_LOST));
return EGL_FALSE; return EGL_FALSE;
......
...@@ -98,7 +98,7 @@ EGLBoolean EGLAPIENTRY PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLin ...@@ -98,7 +98,7 @@ EGLBoolean EGLAPIENTRY PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLin
return EGL_FALSE; return EGL_FALSE;
} }
if (display->isDeviceLost()) if (display->testDeviceLost())
{ {
SetGlobalError(Error(EGL_CONTEXT_LOST)); SetGlobalError(Error(EGL_CONTEXT_LOST));
return EGL_FALSE; return EGL_FALSE;
...@@ -433,7 +433,13 @@ EGLBoolean EGLAPIENTRY QueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, E ...@@ -433,7 +433,13 @@ EGLBoolean EGLAPIENTRY QueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, E
dpy, attribute, value); dpy, attribute, value);
Display *display = static_cast<Display*>(dpy); 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) 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