Commit 87fbe1c2 by Corentin Wallez Committed by Commit Bot

ContextImpl: only expose getResetStatus for robustness

This will allow each backend to implement this method separately. The current set of ContextImpl methods used for robustness are slightly D3D-centric. BUG=angleproject:1463 Change-Id: I101f8ada2c49de4cf110db48b1e8380c52b50fb2 Reviewed-on: https://chromium-review.googlesource.com/365829Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent 4c4c8e72
...@@ -486,19 +486,6 @@ void Context::releaseSurface() ...@@ -486,19 +486,6 @@ void Context::releaseSurface()
mCurrentSurface = nullptr; mCurrentSurface = nullptr;
} }
// NOTE: this function should not assume that this context is current!
void Context::markContextLost()
{
if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT)
mResetStatus = GL_UNKNOWN_CONTEXT_RESET_EXT;
mContextLost = true;
}
bool Context::isContextLost()
{
return mContextLost;
}
GLuint Context::createBuffer() GLuint Context::createBuffer()
{ {
return mResourceManager->createBuffer(); return mResourceManager->createBuffer();
...@@ -1955,32 +1942,55 @@ GLenum Context::getError() ...@@ -1955,32 +1942,55 @@ GLenum Context::getError()
} }
} }
// NOTE: this function should not assume that this context is current!
void Context::markContextLost()
{
if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT)
mResetStatus = GL_UNKNOWN_CONTEXT_RESET_EXT;
mContextLost = true;
}
bool Context::isContextLost()
{
return mContextLost;
}
GLenum Context::getResetStatus() GLenum Context::getResetStatus()
{ {
//TODO(jmadill): needs MANGLE reworking // Even if the application doesn't want to know about resets, we want to know
if (mResetStatus == GL_NO_ERROR && !mContextLost) // as it will allow us to skip all the calls.
if (mResetStrategy == GL_NO_RESET_NOTIFICATION_EXT)
{ {
// mResetStatus will be set by the markContextLost callback if (!mContextLost && mImplementation->getResetStatus() != GL_NO_ERROR)
// in the case a notification is sent
if (mImplementation->testDeviceLost())
{ {
mImplementation->notifyDeviceLost(); mContextLost = true;
} }
}
GLenum status = mResetStatus; // EXT_robustness, section 2.6: If the reset notification behavior is
// NO_RESET_NOTIFICATION_EXT, then the implementation will never deliver notification of
// reset events, and GetGraphicsResetStatusEXT will always return NO_ERROR.
return GL_NO_ERROR;
}
if (mResetStatus != GL_NO_ERROR) // The GL_EXT_robustness spec says that if a reset is encountered, a reset
// status should be returned at least once, and GL_NO_ERROR should be returned
// once the device has finished resetting.
if (!mContextLost)
{ {
ASSERT(mContextLost); ASSERT(mResetStatus == GL_NO_ERROR);
mResetStatus = mImplementation->getResetStatus();
if (mImplementation->testDeviceResettable()) if (mResetStatus != GL_NO_ERROR)
{ {
mResetStatus = GL_NO_ERROR; mContextLost = true;
} }
} }
else if (mResetStatus != GL_NO_ERROR)
{
mResetStatus = mImplementation->getResetStatus();
}
return status; return mResetStatus;
} }
bool Context::isResetNotificationEnabled() bool Context::isResetNotificationEnabled()
......
...@@ -68,9 +68,6 @@ class Context final : public ValidationContext ...@@ -68,9 +68,6 @@ class Context final : public ValidationContext
void makeCurrent(egl::Surface *surface); void makeCurrent(egl::Surface *surface);
void releaseSurface(); void releaseSurface();
void markContextLost();
bool isContextLost();
// These create and destroy methods are merely pass-throughs to // These create and destroy methods are merely pass-throughs to
// ResourceManager, which owns these object types // ResourceManager, which owns these object types
GLuint createBuffer(); GLuint createBuffer();
...@@ -573,6 +570,8 @@ class Context final : public ValidationContext ...@@ -573,6 +570,8 @@ class Context final : public ValidationContext
void handleError(const Error &error) override; void handleError(const Error &error) override;
GLenum getError(); GLenum getError();
void markContextLost();
bool isContextLost();
GLenum getResetStatus(); GLenum getResetStatus();
bool isResetNotificationEnabled(); bool isResetNotificationEnabled();
......
...@@ -791,7 +791,10 @@ bool Display::testDeviceLost() ...@@ -791,7 +791,10 @@ bool Display::testDeviceLost()
void Display::notifyDeviceLost() void Display::notifyDeviceLost()
{ {
ASSERT(!mDeviceLost); if (mDeviceLost)
{
return;
}
for (ContextSet::iterator context = mContextSet.begin(); context != mContextSet.end(); context++) for (ContextSet::iterator context = mContextSet.begin(); context != mContextSet.end(); context++)
{ {
......
...@@ -107,11 +107,8 @@ class ContextImpl : public GLImplFactory ...@@ -107,11 +107,8 @@ class ContextImpl : public GLImplFactory
GLenum transformType, GLenum transformType,
const GLfloat *transformValues); const GLfloat *transformValues);
// TODO(jmadill): Investigate proper impl methods for this. // Device loss
virtual void notifyDeviceLost() = 0; virtual GLenum getResetStatus() = 0;
virtual bool isDeviceLost() const = 0;
virtual bool testDeviceLost() = 0;
virtual bool testDeviceResettable() = 0;
// Vendor and description strings. // Vendor and description strings.
virtual std::string getVendorString() const = 0; virtual std::string getVendorString() const = 0;
......
...@@ -31,11 +31,11 @@ namespace rx ...@@ -31,11 +31,11 @@ namespace rx
RendererD3D::RendererD3D(egl::Display *display) RendererD3D::RendererD3D(egl::Display *display)
: mDisplay(display), : mDisplay(display),
mDeviceLost(false),
mPresentPathFastEnabled(false), mPresentPathFastEnabled(false),
mCapsInitialized(false), mCapsInitialized(false),
mWorkaroundsInitialized(false), mWorkaroundsInitialized(false),
mDisjoint(false) mDisjoint(false),
mDeviceLost(false)
{ {
} }
...@@ -275,14 +275,29 @@ gl::Texture *RendererD3D::getIncompleteTexture(GLImplFactory *implFactory, GLenu ...@@ -275,14 +275,29 @@ gl::Texture *RendererD3D::getIncompleteTexture(GLImplFactory *implFactory, GLenu
return mIncompleteTextures[type].get(); return mIncompleteTextures[type].get();
} }
bool RendererD3D::isDeviceLost() const GLenum RendererD3D::getResetStatus()
{ {
return mDeviceLost; if (!mDeviceLost)
{
if (testDeviceLost())
{
mDeviceLost = true;
notifyDeviceLost();
return GL_UNKNOWN_CONTEXT_RESET_EXT;
}
return GL_NO_ERROR;
}
if (testDeviceResettable())
{
return GL_NO_ERROR;
}
return GL_UNKNOWN_CONTEXT_RESET_EXT;
} }
void RendererD3D::notifyDeviceLost() void RendererD3D::notifyDeviceLost()
{ {
mDeviceLost = true;
mDisplay->notifyDeviceLost(); mDisplay->notifyDeviceLost();
} }
......
...@@ -112,8 +112,6 @@ class RendererD3D : public BufferFactoryD3D ...@@ -112,8 +112,6 @@ class RendererD3D : public BufferFactoryD3D
virtual ContextImpl *createContext(const gl::ContextState &state) = 0; virtual ContextImpl *createContext(const gl::ContextState &state) = 0;
bool isDeviceLost() const;
virtual bool testDeviceLost() = 0;
std::string getVendorString() const; std::string getVendorString() const;
virtual int getMinorShaderModel() const = 0; virtual int getMinorShaderModel() const = 0;
...@@ -214,8 +212,12 @@ class RendererD3D : public BufferFactoryD3D ...@@ -214,8 +212,12 @@ class RendererD3D : public BufferFactoryD3D
GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea) = 0; GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea) = 0;
// Device lost // Device lost
GLenum getResetStatus();
void notifyDeviceLost(); void notifyDeviceLost();
virtual bool resetDevice() = 0; virtual bool resetDevice() = 0;
virtual bool testDeviceLost() = 0;
virtual bool testDeviceResettable() = 0;
virtual RendererClass getRendererClass() const = 0; virtual RendererClass getRendererClass() const = 0;
virtual void *getD3DDevice() = 0; virtual void *getD3DDevice() = 0;
...@@ -263,7 +265,6 @@ class RendererD3D : public BufferFactoryD3D ...@@ -263,7 +265,6 @@ class RendererD3D : public BufferFactoryD3D
gl::Error markTransformFeedbackUsage(const gl::ContextState &data); gl::Error markTransformFeedbackUsage(const gl::ContextState &data);
egl::Display *mDisplay; egl::Display *mDisplay;
bool mDeviceLost;
bool mPresentPathFastEnabled; bool mPresentPathFastEnabled;
...@@ -296,6 +297,7 @@ class RendererD3D : public BufferFactoryD3D ...@@ -296,6 +297,7 @@ class RendererD3D : public BufferFactoryD3D
mutable WorkaroundsD3D mWorkarounds; mutable WorkaroundsD3D mWorkarounds;
bool mDisjoint; bool mDisjoint;
bool mDeviceLost;
}; };
} // namespace rx } // namespace rx
......
...@@ -189,24 +189,9 @@ gl::Error Context11::drawRangeElements(GLenum mode, ...@@ -189,24 +189,9 @@ gl::Error Context11::drawRangeElements(GLenum mode,
return mRenderer->genericDrawElements(this, mode, count, type, indices, 0, indexRange); return mRenderer->genericDrawElements(this, mode, count, type, indices, 0, indexRange);
} }
void Context11::notifyDeviceLost() GLenum Context11::getResetStatus()
{ {
mRenderer->notifyDeviceLost(); return mRenderer->getResetStatus();
}
bool Context11::isDeviceLost() const
{
return mRenderer->isDeviceLost();
}
bool Context11::testDeviceLost()
{
return mRenderer->testDeviceLost();
}
bool Context11::testDeviceResettable()
{
return mRenderer->testDeviceResettable();
} }
std::string Context11::getVendorString() const std::string Context11::getVendorString() const
......
...@@ -89,11 +89,8 @@ class Context11 : public ContextImpl ...@@ -89,11 +89,8 @@ class Context11 : public ContextImpl
const GLvoid *indices, const GLvoid *indices,
const gl::IndexRange &indexRange) override; const gl::IndexRange &indexRange) override;
// TODO(jmadill): Investigate proper impl methods for this. // Device loss
void notifyDeviceLost() override; GLenum getResetStatus() override;
bool isDeviceLost() const override;
bool testDeviceLost() override;
bool testDeviceResettable() override;
// Vendor and description strings. // Vendor and description strings.
std::string getVendorString() const override; std::string getVendorString() const override;
......
...@@ -2560,18 +2560,7 @@ bool Renderer11::testDeviceLost() ...@@ -2560,18 +2560,7 @@ bool Renderer11::testDeviceLost()
if (isLost) if (isLost)
{ {
// Log error if this is a new device lost event ERR("The D3D11 device was removed: 0x%08X", result);
if (mDeviceLost == false)
{
ERR("The D3D11 device was removed: 0x%08X", result);
}
// ensure we note the device loss --
// we'll probably get this done again by notifyDeviceLost
// but best to remember it!
// Note that we don't want to clear the device loss status here
// -- this needs to be done by resetDevice
mDeviceLost = true;
} }
return isLost; return isLost;
...@@ -2684,8 +2673,6 @@ bool Renderer11::resetDevice() ...@@ -2684,8 +2673,6 @@ bool Renderer11::resetDevice()
return false; return false;
} }
mDeviceLost = false;
return true; return true;
} }
......
...@@ -160,7 +160,7 @@ class Renderer11 : public RendererD3D ...@@ -160,7 +160,7 @@ class Renderer11 : public RendererD3D
// lost device // lost device
bool testDeviceLost() override; bool testDeviceLost() override;
bool testDeviceResettable(); bool testDeviceResettable() override;
std::string getRendererDescription() const; std::string getRendererDescription() const;
DeviceIdentifier getAdapterIdentifier() const override; DeviceIdentifier getAdapterIdentifier() const override;
......
...@@ -178,24 +178,9 @@ gl::Error Context9::drawRangeElements(GLenum mode, ...@@ -178,24 +178,9 @@ gl::Error Context9::drawRangeElements(GLenum mode,
return mRenderer->genericDrawElements(this, mode, count, type, indices, 0, indexRange); return mRenderer->genericDrawElements(this, mode, count, type, indices, 0, indexRange);
} }
void Context9::notifyDeviceLost() GLenum Context9::getResetStatus()
{ {
mRenderer->notifyDeviceLost(); return mRenderer->getResetStatus();
}
bool Context9::isDeviceLost() const
{
return mRenderer->isDeviceLost();
}
bool Context9::testDeviceLost()
{
return mRenderer->testDeviceLost();
}
bool Context9::testDeviceResettable()
{
return mRenderer->testDeviceResettable();
} }
std::string Context9::getVendorString() const std::string Context9::getVendorString() const
......
...@@ -89,11 +89,8 @@ class Context9 : public ContextImpl ...@@ -89,11 +89,8 @@ class Context9 : public ContextImpl
const GLvoid *indices, const GLvoid *indices,
const gl::IndexRange &indexRange) override; const gl::IndexRange &indexRange) override;
// TODO(jmadill): Investigate proper impl methods for this. // Device loss
void notifyDeviceLost() override; GLenum getResetStatus() override;
bool isDeviceLost() const override;
bool testDeviceLost() override;
bool testDeviceResettable() override;
// Vendor and description strings. // Vendor and description strings.
std::string getVendorString() const override; std::string getVendorString() const override;
......
...@@ -2045,19 +2045,7 @@ void Renderer9::releaseDeviceResources() ...@@ -2045,19 +2045,7 @@ void Renderer9::releaseDeviceResources()
bool Renderer9::testDeviceLost() bool Renderer9::testDeviceLost()
{ {
HRESULT status = getDeviceStatusCode(); HRESULT status = getDeviceStatusCode();
bool isLost = FAILED(status); return FAILED(status);
if (isLost)
{
// ensure we note the device loss --
// we'll probably get this done again by notifyDeviceLost
// but best to remember it!
// Note that we don't want to clear the device loss status here
// -- this needs to be done by resetDevice
mDeviceLost = true;
}
return isLost;
} }
HRESULT Renderer9::getDeviceStatusCode() HRESULT Renderer9::getDeviceStatusCode()
...@@ -2160,8 +2148,6 @@ bool Renderer9::resetDevice() ...@@ -2160,8 +2148,6 @@ bool Renderer9::resetDevice()
initializeDevice(); initializeDevice();
} }
mDeviceLost = false;
return true; return true;
} }
......
...@@ -280,24 +280,10 @@ void ContextGL::stencilThenCoverStrokePathInstanced(const std::vector<gl::Path * ...@@ -280,24 +280,10 @@ void ContextGL::stencilThenCoverStrokePathInstanced(const std::vector<gl::Path *
transformType, transformValues); transformType, transformValues);
} }
void ContextGL::notifyDeviceLost() GLenum ContextGL::getResetStatus()
{ {
mRenderer->notifyDeviceLost(); UNIMPLEMENTED();
} return GL_NO_ERROR;
bool ContextGL::isDeviceLost() const
{
return mRenderer->isDeviceLost();
}
bool ContextGL::testDeviceLost()
{
return mRenderer->testDeviceLost();
}
bool ContextGL::testDeviceResettable()
{
return mRenderer->testDeviceResettable();
} }
std::string ContextGL::getVendorString() const std::string ContextGL::getVendorString() const
......
...@@ -141,11 +141,8 @@ class ContextGL : public ContextImpl ...@@ -141,11 +141,8 @@ class ContextGL : public ContextImpl
GLenum transformType, GLenum transformType,
const GLfloat *transformValues) override; const GLfloat *transformValues) override;
// TODO(jmadill): Investigate proper impl methods for this. // Device loss
void notifyDeviceLost() override; GLenum getResetStatus() override;
bool isDeviceLost() const override;
bool testDeviceLost() override;
bool testDeviceResettable() override;
// Vendor and description strings. // Vendor and description strings.
std::string getVendorString() const override; std::string getVendorString() const override;
......
...@@ -446,29 +446,6 @@ void RendererGL::popGroupMarker() ...@@ -446,29 +446,6 @@ void RendererGL::popGroupMarker()
mFunctions->popDebugGroup(); mFunctions->popDebugGroup();
} }
void RendererGL::notifyDeviceLost()
{
UNIMPLEMENTED();
}
bool RendererGL::isDeviceLost() const
{
UNIMPLEMENTED();
return bool();
}
bool RendererGL::testDeviceLost()
{
UNIMPLEMENTED();
return bool();
}
bool RendererGL::testDeviceResettable()
{
UNIMPLEMENTED();
return bool();
}
std::string RendererGL::getVendorString() const std::string RendererGL::getVendorString() const
{ {
return std::string(reinterpret_cast<const char*>(mFunctions->getString(GL_VENDOR))); return std::string(reinterpret_cast<const char*>(mFunctions->getString(GL_VENDOR)));
......
...@@ -142,12 +142,6 @@ class RendererGL : angle::NonCopyable ...@@ -142,12 +142,6 @@ class RendererGL : angle::NonCopyable
void pushGroupMarker(GLsizei length, const char *marker); void pushGroupMarker(GLsizei length, const char *marker);
void popGroupMarker(); void popGroupMarker();
// lost device
void notifyDeviceLost();
bool isDeviceLost() const;
bool testDeviceLost();
bool testDeviceResettable();
std::string getVendorString() const; std::string getVendorString() const;
std::string getRendererDescription() const; std::string getRendererDescription() const;
......
...@@ -106,27 +106,10 @@ gl::Error ContextVk::drawRangeElements(GLenum mode, ...@@ -106,27 +106,10 @@ gl::Error ContextVk::drawRangeElements(GLenum mode,
return gl::Error(GL_INVALID_OPERATION); return gl::Error(GL_INVALID_OPERATION);
} }
void ContextVk::notifyDeviceLost() GLenum ContextVk::getResetStatus()
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} return GL_NO_ERROR;
bool ContextVk::isDeviceLost() const
{
UNIMPLEMENTED();
return bool();
}
bool ContextVk::testDeviceLost()
{
UNIMPLEMENTED();
return bool();
}
bool ContextVk::testDeviceResettable()
{
UNIMPLEMENTED();
return bool();
} }
std::string ContextVk::getVendorString() const std::string ContextVk::getVendorString() const
......
...@@ -54,11 +54,8 @@ class ContextVk : public ContextImpl ...@@ -54,11 +54,8 @@ class ContextVk : public ContextImpl
const GLvoid *indices, const GLvoid *indices,
const gl::IndexRange &indexRange) override; const gl::IndexRange &indexRange) override;
// TODO(jmadill): Investigate proper impl methods for this. // Device loss
void notifyDeviceLost() override; GLenum getResetStatus() override;
bool isDeviceLost() const override;
bool testDeviceLost() override;
bool testDeviceResettable() override;
// Vendor and description strings. // Vendor and description strings.
std::string getVendorString() const override; std::string getVendorString() const override;
......
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