Copying an NV12 image from cuda texture to Dx11 texture loses chroma part ?

I’m using the NVDEC decoder to decode streamed video and the result is in NV12, i’ve shared the resulting CUDA texture with Dx11 but when i try to copy the texture to a Dx11 texture it loses the chroma part

I’m using

cudaGraphicsD3D11RegisterResource(&this->m_pCudaResource, this->CmDxSurface::m_pTexture.get(), CU_GRAPHICS_REGISTER_FLAGS_NONE);

cudaGraphicsMapResources(1, &this->m_pCudaResource, cuStream);

cudaGraphicsSubResourceGetMappedArray(&this->m_pCudaDxTexture, this->m_pCudaResource, 0, 0);

cudaMemcpy2DToArray(
this->m_pCudaDxTexture, // dst array
0, // wOffset
0, // hOffset
m_rawPointer, // src
this->m_pitch, // src pitch
this->Size().Width() * BytesPerPixel(ColorFormat()),
this->Size().Height(),
cudaMemcpyDeviceToDevice);

and it kinda works, i get the image, but everything is saturated with green :-(

i tried multiplying the height in cudaMemcpy by 1.5 to get the chroma part as well, but then cudaMemcpy fails

any ideas ?

1 Like

i also face to this question. do you get any idea to solve it?