Researching the LockRect
block issue, I stumbled upon many claims stating that Direct3D9 is, by default, not thread safe.
That clicked on me. Recently, we parallelized some native code which updated the texture data directly (i.e. no dispatch). So there were concurrent calls to LockRect
. People said that Present
was the dangerous call, but I tried setting the CreateDevice
D3DCREATE_MULTITHREADED
behavior flag, and voila, now I'm debugging smoothly, no more crashes or deadlocks.
Warning: Activating the multithreaded flag is said to introduce a significant performance overhead, but in my case it was negligible (and I'm doing live video from a frame grabber).