Sign in to follow this  

Lost Device Problem

This topic is 3932 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My system (DX in windowed mode) handles the Lost Device properly now. I tested it by pressing ALT+CTL+DELETE which makes the device to be lost and later everything else is restored nicely. However, when i lock my screen by WINDOW+L and later login back... the device apparently doesn't get restored again.. the rendering screen gets all garbled with funny colors. How do i handle this special device lost case ?

Share this post


Link to post
Share on other sites
Window+L shouldn't be a special case as far as I know. (I handle lost devices the same flawlessly). And CTRL-ALT-DELETE shouldn't cause the device to be lost in windowed mode. How are you handling lost devices?

Share this post


Link to post
Share on other sites

HRESULT DXWindow::FrameBegin()
{
HRESULT hr;

LPDIRECT3DSURFACE9 pBackBuffer;
V(m_pSwapChain->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&pBackBuffer));

V(m_pDevice->SetRenderTarget(0,pBackBuffer));
V(m_pDevice->SetDepthStencilSurface( m_pDepthStencilBuffer));

SAFE_RELEASE(pBackBuffer);


V(m_pDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, D3DCOLOR_XRGB(m_clearR,m_clearG,m_clearB), 1.0f, 0 ));

V_RETURN( m_pDevice->BeginScene());

return S_OK;
}

//-----------------------------------------------------------------------------
HRESULT DXWindow::FrameEnd()
{
HRESULT hr;

V(m_pDevice->EndScene());

hr = m_pSwapChain->Present(NULL,NULL,NULL,NULL,0);
if( hr == D3DERR_DEVICELOST ){


while( m_pDevice->TestCooperativeLevel() == D3DERR_DEVICELOST ){
Sleep(100);
}

OnLost();
V(m_pDevice->Reset( &m_d3dPP ));
OnReset();

Tool::GetSingleton()->GetViewerPlugin()->Paint();
}
return S_OK;
}



This is how i am handling lost devices. The OnLost() function traverses through all the object in the system which release their D3DPOOL_DEFAULT stuffs. Similarly OnReset() function traverses through all the object in the system which recreates the D3DPOOL_DEFAULT stuffs. My system also uses Additional Swap Chain and extra DepthStencil Buffers which are also released and recreated. I have done some debugging and found that ALT+CONTROL+DEL makes the device to be lost , which is handled properly. But Locking the wiondow with WIN+L and login back in is not working :(

Share this post


Link to post
Share on other sites
I'm not sure if this is the problem, but it's not a good thing:

while( m_pDevice->TestCooperativeLevel() == D3DERR_DEVICELOST ){
Sleep(100);
}


You really want to be pumping window messages in that loop - Otherwise a user can't exit your app cleanly while it's minimized (Assuming full-screen normally), and since you never get WM_ACTIVATE calls, it's entirely possible that your device may never end up becomming un-lost.

Share this post


Link to post
Share on other sites

This topic is 3932 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this