D3D Device Failure During Screen Locked
Asked Answered
W

4

12

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 );
Wry answered 14/1, 2012 at 2:2 Comment(0)
W
3

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.

Weinman answered 1/10, 2014 at 17:25 Comment(0)
M
1

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?

Montford answered 19/9, 2014 at 16:35 Comment(1)
Unfortunately, this results in the same error (D3DERR_INVALIDCALL).Cambell
F
0

My memory is hazy, but I believe this is a known limitation ("by design") with D3D with respect to the lock screen (and running as a service).

Even if you could create the D3D device, you won't be able to draw on top of the lock screen. So you'll probably be better off designing your app such that it defers the D3D device creation until after the screen becomes unlocked.

Use WTSRegisterSessionNotification to register for notifications of when the screen becomes locked or unlocked.

Fortuitism answered 14/1, 2012 at 5:54 Comment(3)
It's not clear to me why a locked screen should fail for the device creation, particularly when run in NULLREF mode with no real reliance on the screen. My usage of DirectX has nothing to do with rendering to the screen, hence waiting for a screen to unlock is unfortunately not an option.Wry
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.Weinman
@ChuckWalbourn D3d9Ex worked for me. I'll upvote you if you promote your comment to full answer :)Entomology
N
0

Thanks to Chuck Walbourn's answer I have solved my related issue that the D3D Device initialization fails as soon the elevation prompt secure session is active. In my case I received a D3DERR_NOTAVAILABLE error during the secure session. Having replaced IDirect3D9* with IDirect3D9Ex* and Direct3DCreate9 with Direct3DCreate9Ex then initialization finished successfully!

Additionally I have to stress that Chuck's answer does not refer to Kent's answer directly but just to a related issue, since - as I have understood it right - Kent's scenario refers to the WTS_SESSIONSTATE_LOCK session that can be entered through CTRL+L. In Kent's case I haven't experienced a problem with the D3D initialization in a locked session.

Nellanellda answered 11/5, 2018 at 13:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.