0
votes

I'm moving my renderer to a different thread. During this process I'm making two calls to IDirect3D9::CreateDevice: 1. from the 'rendering thread' - in order to create a rendering device and resize it properly 2. from the 'main thread' - here I'm creating a Null device in order to compile shaders etc.

These calls of course can overlap (be made simultaneously ), so I'm synchronizing them with a CriticalSection.

The problem is that one of these calls sometime freezes. DirectX doesn't throw any warnings prior to that happening, so I suspect an internal deadlock.

I studied the documentation and it's mentioned that all calls that operate on a single device, especially IDirect3D9::CreateDevice, IDirect3DDevice9::TestCooperativeLevel and IDirect3DDevice9::Reset, need to be called from the same thread - but I have that covered.

So what am I missing? Can anyone please tell me?

Thanks, Paksas

1

1 Answers

1
votes

I only have a vague memory of this but:

  1. The docs state "Any call to create, release, or reset the device must be done using the same thread as the window procedure of the focus window."
  2. As I remember things, even if you try and create a device using a NULL HWND, internally Direct3D goes and digs one up for your app anyway.

Therefore one of your threads is surely violating the first point.