I tried using cudaExternalMemoryGetMappedMipmappedArray for ID3D11Texture3D with D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX, but it works only under some very limited texture size.
Here is the whole code.
I modified an NVIDIA’s official sample project “simpleD3D11Texture” by replacing the old cudaGraphicsResource to cudaExternalMemory_t and cudaMipmappedArray.
So you can run the code immediately.
(Note that I tried with CUDA 11.4 instead of CUDA 11.6)
I tried with 512 ID3D11Texture3D from texture sizes (512, 512, 1) to (512, 512, 512).
cudaExternalMemoryGetMappedMipmappedArray succeeded only against the texture size (512, 512, [1, 2, 4, 8, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400, 416, 432, 448, 464, 480, 496, or 512]).
Otherwise, all failed with cudaErrorInvalidValue at cudaExternalMemoryGetMappedMipmappedArray.
It might be we have to set the value cudaExternalMemoryMipmappedArrayDesc.offset other than 0, but there is no documentation for it,
and I don’t think DirectX11 does not have any function to get the offset value.
I think cudaExternalMemoryGetMappedMipmappedArray currenly allows the texture size (width, height or depth) of 2^n and some other values.
So I think this is a critical bug.
Thank you.