This section describes the Direct3D 11 interoperability functions of the CUDA runtime application programming interface. Note that mapping of Direct3D 11 resources is performed with the graphics API agnostic, resource mapping interface described inGraphics Interopability.
CUDA devices corresponding to a D3D11 device
Returns in*device the CUDA-compatible device corresponding to the adapterpAdapter obtained from IDXGIFactory::EnumAdapters. This call will succeed only if a device on adapterpAdapter is CUDA-compatible.
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGraphicsUnregisterResource,cudaGraphicsMapResources,cudaGraphicsSubResourceGetMappedArray,cudaGraphicsResourceGetMappedPointer,cuD3D11GetDevice
Returns in*pCudaDeviceCount the number of CUDA-compatible devices corresponding to the Direct3D 11 devicepD3D11Device. Also returns in*pCudaDevices at mostcudaDeviceCount of the the CUDA-compatible devices corresponding to the Direct3D 11 devicepD3D11Device.
If any of the GPUs being used to renderpDevice are not CUDA capable then the call will returncudaErrorNoDevice.
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGraphicsUnregisterResource,cudaGraphicsMapResources,cudaGraphicsSubResourceGetMappedArray,cudaGraphicsResourceGetMappedPointer,cuD3D11GetDevices
cudaSuccess,cudaErrorInvalidDevice,cudaErrorInvalidValue,cudaErrorInvalidResourceHandle,cudaErrorUnknown
Registers the Direct3D 11 resourcepD3DResource for access by CUDA.
If this call is successful, then the application will be able to map and unmap this resource until it is unregistered throughcudaGraphicsUnregisterResource(). Also on success, this call will increase the internal reference count onpD3DResource. This reference count will be decremented when this resource is unregistered throughcudaGraphicsUnregisterResource().
This call potentially has a high-overhead and should not be called every frame in interactive applications.
The type ofpD3DResource must be one of the following.
ID3D11Buffer: may be accessed via a device pointer
ID3D11Texture1D: individual subresources of the texture may be accessed via arrays
ID3D11Texture2D: individual subresources of the texture may be accessed via arrays
ID3D11Texture3D: individual subresources of the texture may be accessed via arrays
Theflags argument may be used to specify additional parameters at register time. The valid values for this parameter are
cudaGraphicsRegisterFlagsNone: Specifies no hints about how this resource will be used.
cudaGraphicsRegisterFlagsSurfaceLoadStore: Specifies that CUDA will bind this resource to a surface reference.
cudaGraphicsRegisterFlagsTextureGather: Specifies that CUDA will perform texture gather operations on this resource.
Not all Direct3D resources of the above types may be used for interoperability with CUDA. The following are some limitations.
The primary rendertarget may not be registered with CUDA.
Textures which are not of a format which is 1, 2, or 4 channels of 8, 16, or 32-bit integer or floating-point data cannot be shared.
Surfaces of depth or stencil formats cannot be shared.
A complete list of supported DXGI formats is as follows. For compactness the notation A_{B,C,D} represents A_B, A_C, and A_D.
DXGI_FORMAT_A8_UNORM
DXGI_FORMAT_B8G8R8A8_UNORM
DXGI_FORMAT_B8G8R8X8_UNORM
DXGI_FORMAT_R16_FLOAT
DXGI_FORMAT_R16G16B16A16_{FLOAT,SINT,SNORM,UINT,UNORM}
DXGI_FORMAT_R16G16_{FLOAT,SINT,SNORM,UINT,UNORM}
DXGI_FORMAT_R16_{SINT,SNORM,UINT,UNORM}
DXGI_FORMAT_R32_FLOAT
DXGI_FORMAT_R32G32B32A32_{FLOAT,SINT,UINT}
DXGI_FORMAT_R32G32_{FLOAT,SINT,UINT}
DXGI_FORMAT_R32_{SINT,UINT}
DXGI_FORMAT_R8G8B8A8_{SINT,SNORM,UINT,UNORM,UNORM_SRGB}
DXGI_FORMAT_R8G8_{SINT,SNORM,UINT,UNORM}
DXGI_FORMAT_R8_{SINT,SNORM,UINT,UNORM}
IfpD3DResource is of incorrect type or is already registered, thencudaErrorInvalidResourceHandle is returned. IfpD3DResource cannot be registered, thencudaErrorUnknown is returned.
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGraphicsUnregisterResource,cudaGraphicsMapResources,cudaGraphicsSubResourceGetMappedArray,cudaGraphicsResourceGetMappedPointer,cuGraphicsD3D11RegisterResource