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