DirectX11 AcquireSync api never returns even after timeout

Team, i have a situation where two threads calling a function to copy a texture and AcquireSync is called for source and target texture using separate source and target mutex before CopyResource api is invoked. Then ReleaseSync is called for both source and target. This is called in loop for each texture/frame when video recording is on.
After 2-3 seconds looks like thread deadlock happens and AcquireSync never returns even though timeout specified.

Could someone suggest what could be the rootcause and help me find solution??
Thanks in advance.

Hi @spujar4u, welcome to the NVIDIA developer forums.

DirectX is not really my specialty, but why do you need to lock the source texture? Do you try to write asynchronously to it?

In any case, first thing I would try would be to force flushing the CommandBuffer after CopyResource to make sure that is not the culprit of the deadlock.

And then step through the code in debug and match the acquire/release calls per texture and device. See if ti adds up.

Good luck!

Hi @MarkusHoHo thanks for your response.

Yes, it works asynchronously. and its better to use lock.
I did try flushing the devicecontext after CopyResource and seems its not the actual culprit for the deadlock.

Actual problem is when two threads are trying to acquire the lock with AcquireSync function, one is stuck and not releasing it even after the timeout.

Right, too bad, that might have been an easy solution.

Well, I am out of my depth now, maybe someone else has some ideas beside hard-core debugging.