Make testDeviceLoss able to perform the notifications

Trac #21727 git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1332 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent ef21ab29
......@@ -331,7 +331,7 @@ EGLSurface Display::createWindowSurface(HWND window, EGLConfig config, const EGL
return error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
}
if (mRenderer->testDeviceLost())
if (mRenderer->testDeviceLost(false))
{
if (!restoreLostDevice())
return EGL_NO_SURFACE;
......@@ -444,7 +444,7 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle,
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
}
if (mRenderer->testDeviceLost())
if (mRenderer->testDeviceLost(false))
{
if (!restoreLostDevice())
return EGL_NO_SURFACE;
......@@ -469,7 +469,7 @@ EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *sha
{
return NULL;
}
else if (mRenderer->testDeviceLost()) // Lost device
else if (mRenderer->testDeviceLost(false)) // Lost device
{
if (!restoreLostDevice())
return NULL;
......
......@@ -884,9 +884,8 @@ EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface
}
renderer::Renderer *renderer = display->getRenderer();
if (renderer->testDeviceLost())
if (renderer->testDeviceLost(true))
{
display->notifyDeviceLost();
return EGL_FALSE;
}
......
......@@ -421,6 +421,7 @@ void Context::markDxUniformsDirty()
mDxUniformsDirty = true;
}
// NOTE: this function should not assume that this context is current!
void Context::markContextLost()
{
if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT)
......@@ -3431,12 +3432,9 @@ GLenum Context::getResetStatus()
{
if (mResetStatus == GL_NO_ERROR)
{
bool lost = mRenderer->testDeviceLost();
if (lost)
{
mDisplay->notifyDeviceLost(); // Sets mResetStatus
}
// mResetStatus will be set by the markContextLost callback
// in the case a notification is sent
mRenderer->testDeviceLost(true);
}
GLenum status = mResetStatus;
......
......@@ -70,9 +70,8 @@ GLuint Query::getResult()
// explicitly check for device loss
// some drivers seem to return S_FALSE even if the device is lost
// instead of D3DERR_DEVICELOST like they should
if (mRenderer->testDeviceLost())
if (mRenderer->testDeviceLost(true))
{
gl::getDisplay()->notifyDeviceLost(); // D3D9_REPLACE
return error(GL_OUT_OF_MEMORY, 0);
}
}
......
......@@ -56,7 +56,7 @@ Renderer::~Renderer()
if (mDevice)
{
// If the device is lost, reset it first to prevent leaving the driver in an unstable state
if (testDeviceLost())
if (testDeviceLost(false))
{
resetDevice();
}
......@@ -296,7 +296,7 @@ void Renderer::sync(bool block)
// explicitly check for device loss
// some drivers seem to return S_FALSE even if the device is lost
// instead of D3DERR_DEVICELOST like they should
if (testDeviceLost())
if (testDeviceLost(false))
{
result = D3DERR_DEVICELOST;
}
......@@ -364,7 +364,8 @@ bool Renderer::isDeviceLost()
return mDeviceLost;
}
bool Renderer::testDeviceLost()
// set notify to true to broadcast a message to all contexts of the device loss
bool Renderer::testDeviceLost(bool notify)
{
bool isLost = false;
......@@ -389,6 +390,10 @@ bool Renderer::testDeviceLost()
// Note that we don't want to clear the device loss status here
// -- this needs to be done by resetDevice
mDeviceLost = true;
if (notify)
{
mDisplay->notifyDeviceLost();
}
}
return isLost;
......@@ -424,7 +429,7 @@ bool Renderer::resetDevice()
D3DPRESENT_PARAMETERS presentParameters = getDefaultPresentParameters();
HRESULT result = D3D_OK;
bool lost = testDeviceLost();
bool lost = testDeviceLost(false);
int attempts = 3;
while (lost && attempts > 0)
......@@ -449,7 +454,7 @@ bool Renderer::resetDevice()
}
}
lost = testDeviceLost();
lost = testDeviceLost(false);
attempts --;
}
......
......@@ -80,7 +80,7 @@ class Renderer
// lost device
virtual void markDeviceLost();
virtual bool isDeviceLost();
virtual bool testDeviceLost();
virtual bool testDeviceLost(bool notify);
virtual bool testDeviceResettable();
// Renderer capabilities
......
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