Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

D3D Device Failure During Screen Locked

I have a problem caused by a failure in Direct3D9::CreateDevice(). It fails when the following code is executed with a locked screen under Windows 7. Due to requirements, I need to be able to create a device while the screen is locked.

I get a D3DERR_INVALIDCALL error when CreateDevice is called with the following parameters. I've experimented extensively with the HWND being used, and double checked that it is valid. I've also tried out various tweaks to the presentation parameters to no avail. Anyone encountered this before or have a better idea of what might be causing the invalid call return?

Again, this failure only occurs with a locked screen, when run in any other tested state, it succeeds.

D3DPRESENT_PARAMETERS pp;
ZeroMemory( &pp, sizeof(D3DPRESENT_PARAMETERS) );
pp.BackBufferFormat = D3DFMT_UNKNOWN;
pp.SwapEffect       = D3DSWAPEFFECT_DISCARD;
pp.Windowed         = TRUE;

HWND focusWndHnd = GetConsoleWindow();

if ( focusWndHnd == NULL && pp.hDeviceWindow == NULL )
{
   focusWndHnd = ::GetDesktopWindow();
}


IDirect3DDevice9* pd3dDevice;

IDirect3D9* pD3D = Direct3DCreate9( D3D_SDK_VERSION );

hr = pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_NULLREF, focusWndHnd,
             D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_FPU_PRESERVE, &pp, &pd3dDevice );
like image 966
Kent Gell Avatar asked Jan 14 '12 02:01

Kent Gell


2 Answers

The legacy Direct3D 9 interface considers the 'secure desktop' to be a lost device scenario. Use of a WDDM aware version of Direct3D (Direct3D9Ex, Direct3D 10.x, or Direct3D 11.x) will avoid this problem.

like image 52
Chuck Walbourn Avatar answered Sep 19 '22 16:09

Chuck Walbourn


Could it be that you need a different value for BackBufferFormat different than D3DFMT_UNKNOWN, due to only windowed apps allowing that value, just like OJ stated here?

like image 24
Alban Lusitanae Avatar answered Sep 19 '22 16:09

Alban Lusitanae