# What is the difference between cudaExternalMemoryHandleTypeD3D12Resource and cudaExternalMemoryHandleTypeD3D12Heap?

When we import a D3D12 memory object into cuda we do something like this:

cudaExternalMemoryHandleDesc cuExtmemHandleDesc{};
cuExtmemHandleDesc.type = cudaExternalMemoryHandleTypeD3D12Resource; //here
//...
CheckCudaErrors(cudaImportExternalMemory(&m_externalMemory, &cuExtmemHandleDesc));


What is the difference between cudaExternalMemoryHandleTypeD3D12Resource and cudaExternalMemoryHandleTypeD3D12Heap? When should I use one or the other when importing memory object?

cudeExternalMemoryHandleTypeD3D12Heap refers to a D3D12 heap object, whereas cudeExternalMemoryHandleTypeD3D12Resource refers to a D3D12 resource object. You'd choose the value that correctly represents the D3D12 object type you're referencing via cudaImportExternalMemory.
An ID2D12Heap is a representation of a contiguous allocation of memory, whereas an ID3D12Resource is somewhat higher-level, providing methods for (per the docs)