Sharing Texture by Direct3D9 and register using Cuda


Iam trying to share texture using Direct3D9 and register it using cuD3D9RegisterResource(…).

So i should pass the sharedhandle parameter through Direct3D9- Createtexrure(…).

When i try to pass this parameter as “NULL” it works fine.

But I have to share the texture with multiple device and for this I have to pass the sharedhandle parameter.

But what happening here is :- if this parameter is passing as sharedhandle thus causes an error “CUDA_ERROR_INVALID_HANDLE”

Iam attaching a portion of my code here.

HANDLE sharedTextureHandle = NULL;
HRESULT hResult = pChInfo>pD3D9Device>CreateTexture(tVideoFormat.coded_width,tVideoFormat.coded_height, 1,
D3DPOOL::D3DPOOL_DEFAULT, &pChInfo->sharedD3DTexture, &sharedTextureHandle);

assert(S_OK == hResult);

/* get the surface level */
hResult = pChInfo->sharedD3DTexture->GetSurfaceLevel(0, &pChInfo->sharedD3DSurface);
assert(S_OK == hResult);

checkCudaErrors(cuD3D9RegisterResource(&pChInfo->sharedD3DTexture, 0));//error “CUDA_ERROR_INVALID_HANDLE”

Is there any way to share the texture with multiple device using Direct3D9 and cuda interoperability.