I’ve followed the example of simpleD3D11Texture where a texture is mapped, memcpy’d via DeviceToDevice and then used in Cuda. I wanted to save myself the Memcpy and read / write a texture directly, but it appears to not work. There are posts all over the internet indicating this works in OpenGL, does this specifically not work for Direct3D? Here are the steps:
Create a TextureA
Call cudaGraphicsD3D11RegisterResource with TextureA, Getting CudaResourceA
cudaGraphicsMapResources on CudaResourceA
cudaGraphicsSubResourceGetMappedArray with CudaResourceA, getting cuArray.
Run Kernel on cuArray
If I do these steps, the program crashes. If instead, I do this one more step that was taken from the example:
Memcpy cuArray into a cudaMallocPitch()'d buffer, bufferA
Run Kernel on bufferA
Now it runs correctly. Now my question is: Why do we need that step? There appear to be resources online indicating you don’t need that step if doing this in OpenGL.