Can I use "NV_DX_interop2" extension in multithread environment?

Hi:
My Windows app use DesktopDuplication API to do screen capture, the API use DX platform,and the captured image is stored in a D3D11Texture, so I use “NV_DX_interop2” extension to display image on OpenGL; At the begining, I divide my app to two threads,one is responsible for DX screen capture,another is responsible for display on OpenGL,the display thread call “wglDXLockObjectsNV()” function firstly to acquire the captured image resource,but I found that the program is stuck when “wglDXLockObjectsNV()” called; then I merge the two threads into one,firstly do capture, and then do display in a same thread, the program can run normally; So why two threads way can not work? Can I use “NV_DX_interop2” in multithread environment?

Hi there @pango99,

Can you check the specification of NV_DX_interop in the documentation? NV_DX_interop2 is only the extension of this to DX10 and DX11. Scroll down to wglDXLockObjectsNV() and read the text closely. I suspect that you might have overlooked some of the locking constraints of the actual interop objects. There is also sample code that might help.

I suggest to write your code so that you check the return value of wglDXLockObjectsNV() and read the resulting error code if any.

In general I would think you can use it multi-threaded, but you need to make sure you are not running into deadlocks, so synchronization is crucial.