I have a post processing pipeline that uses a compute shader to process a texture and writes it to a RWByteAddressBuffer.
The content of the RWByteAddressBuffer is then sent to an FPGA device via direct memory access (AMD DirectGMA technology). Meaning, I initiate an external device to access the physical bytes of this buffer without Direct3D api knowing about it.
Here is the essence of the code:
_context->CSSetShaderResources(0,1,_nonMsaaSrv.GetAddressOf());
_context->CSSetUnorderedAccessViews(0, 1, _unorderedAccessView.GetAddressOf(),nullptr);
_context->CSSetShader(_converter.Get(),0,0);
_context->Dispatch(1920, 1200, 1);
// ... wait for direct3d compute shader to finish processing?
// send the bytes to the fpga:
_dmaController->StartDMA(_d3dBufferPhysicalAddress, fpgaLogicalAddress);
Everything works, but the problem is I could not find a way to block the thread or get an event that indicates that the compute shader completed its work on the GPU.
This question suggests a solution that uses ID3D11Query to do some kind of polling. but it is my understanding that this is simply a busy wait. I was hoping to find a better solution that might allow the thread to block by waiting for some kind of event. With APIs such as Cuda / OpenCL this is pretty trivial.
So is it possible to do a blocking wait for a compute shader in direct3D 11? if so how?