Copy decoded frame into D3D11Texture2D


I have a following workflow to obey:

I receive a buffer with incoming H264 stream, which I have to decode - made it happen so far. Now, I receive a D3D11Device pointer from rendering application component - this is the only thing available to me. What I have to accomplish in the end is to create a D3DTexture2d with given device and somehow copy the decoded frame, which I get pointer to by cuvidMapVideoFrame, into it. After copy I would return the texture pointer back to rendering component.

Since I don’t have much experience in DirectX programming, let alone CUDA, I’m totally confused now, after trying for a while to figure out what is the way to do this. I could not figure this out from the sample code, since it utilizes the whole D3D rendering process, and I cannot filter out what I need and what I don’t. Also the CUDA documentation really doesn’t say much in this regard.

Please help me to figure out the minimum necessary steps to copy decoded frame into separately created D3DTexture2d, at least in general terms.

Thanks a lot!


You need to register the texture for mapping by cuda (look at registerAsCudaResource in NvDecodeD3D11 sample app). Then, resource has to be mapped so that cuda operations can be done (look at ImageDX::map in sample app). After map you can copy the decoded nv12 frame into the ARGB texture using cuda (look at cudaPostProcessFrame in sample app.)