CUDA cuMemcpuHtoD vs cuMemcpy2D

Asking it here and not on SO as it seems to be appropriate question for CG. I am learning NVIDIA NVENC API.The SDK supplies a sampled called "NvEncoderCudaInterop" .There is a chunk of code which copies YUV plane arrays from CPU to GPU buffers. This is the code:

 // copy luma
CUDA_MEMCPY2D copyParam;
memset(&copyParam, 0, sizeof(copyParam));
copyParam.dstMemoryType = CU_MEMORYTYPE_DEVICE;
copyParam.dstDevice = pEncodeBuffer->stInputBfr.pNV12devPtr;
copyParam.dstPitch = pEncodeBuffer->stInputBfr.uNV12Stride;
copyParam.srcMemoryType = CU_MEMORYTYPE_HOST;
copyParam.srcHost = yuv[0];
copyParam.srcPitch = width;
copyParam.WidthInBytes = width;
copyParam.Height = height;
__cu(cuMemcpy2D(&copyParam));

// copy chroma


• I'm not too familiar with NVENC, but it looks as if the dstPitch for the Y array is being supplied by the NVENC API, so it might conceivably differ from srcPitch, thus requiring the 2D copy instead of a straight memory copy. Not sure why the Y channel would require this where Uand V don't, though. – Nathan Reed Oct 1 '15 at 4:45