Show / Hide Table of Contents

    Class DirectX11NativeMethods

    Direct3D 11 Interoperability for CUDA 3.x

    Inheritance
    System.Object
    DirectX11NativeMethods
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: ManagedCuda
    Assembly: ManagedCuda.dll
    Syntax
    public static class DirectX11NativeMethods

    Methods

    cuD3D11CtxCreate(ref CUcontext, ref CUdevice, CUCtxFlags, IntPtr)

    Creates a new CUDA context, enables interoperability for that context with the Direct3D device pD3DDevice, and associates the created CUDA context with the calling thread. The created CUcontext will be returned in pCtx. Direct3D resources from this device may be registered and mapped through the lifetime of this CUDA context. If pCudaDevice is non-NULL then the CUdevice on which this CUDA context was created will be returned in pCudaDevice. On success, this call will increase the internal reference count on pD3DDevice. This reference count will be decremented upon destruction of this context through cuCtxDestroy(CUcontext). This context will cease to function if pD3DDevice is destroyed or encounters an error.

    Declaration
    public static CUResult cuD3D11CtxCreate(ref CUcontext pCtx, ref CUdevice pCudaDevice, CUCtxFlags Flags, IntPtr pD3DDevice)
    Parameters
    Type Name Description
    CUcontext pCtx

    Returned newly created CUDA context

    CUdevice pCudaDevice

    Returned pointer to the device on which the context was created

    CUCtxFlags Flags

    Context creation flags (see cuCtxCreate_v2(ref CUcontext, CUCtxFlags, CUdevice) for details)

    System.IntPtr pD3DDevice

    Direct3D device to create interoperability context with

    Returns
    Type Description
    CUResult

    CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized, ErrorInvalidValue, ErrorOutOfMemory, ErrorUnknown. Note that this function may also return error codes from previous, asynchronous launches.

    cuD3D11CtxCreateOnDevice(ref CUcontext, CUCtxFlags, IntPtr, CUdevice)

    Creates a new CUDA context, enables interoperability for that context with the Direct3D device pD3DDevice, and associates the created CUDA context with the calling thread. The created CUcontext will be returned in pCtx. Direct3D resources from this device may be registered and mapped through the lifetime of this CUDA context. On success, this call will increase the internal reference count on pD3DDevice. This reference count will be decremented upon destruction of this context through cuCtxDestroy(CUcontext). This context will cease to function if pD3DDevice is destroyed or encounters an error.

    Declaration
    public static CUResult cuD3D11CtxCreateOnDevice(ref CUcontext pCtx, CUCtxFlags flags, IntPtr pD3DDevice, CUdevice cudaDevice)
    Parameters
    Type Name Description
    CUcontext pCtx

    Returned newly created CUDA context

    CUCtxFlags flags

    Context creation flags (see cuCtxCreate_v2(ref CUcontext, CUCtxFlags, CUdevice) for details)

    System.IntPtr pD3DDevice

    Direct3D device to create interoperability context with

    CUdevice cudaDevice

    Returned pointer to the device on which the context was created

    Returns
    Type Description
    CUResult

    CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized, ErrorInvalidValue, ErrorOutOfMemory, ErrorUnknown. Note that this function may also return error codes from previous, asynchronous launches.

    cuD3D11GetDevice(ref CUdevice, IntPtr)

    Returns in device the CUDA-compatible device corresponding to the adapter pAdapter obtained from IDXGIFactory::EnumAdapters. This call will succeed only if a device on adapter pAdapter is Cuda-compatible.

    Declaration
    public static CUResult cuD3D11GetDevice(ref CUdevice device, IntPtr pAdapter)
    Parameters
    Type Name Description
    CUdevice device

    Returned CUDA device corresponding to pszAdapterName

    System.IntPtr pAdapter

    Adapter (type: IDXGIAdapter)

    Returns
    Type Description
    CUResult

    CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized, ErrorInvalidValue, ErrorUnknown. Note that this function may also return error codes from previous, asynchronous launches.

    cuD3D11GetDevices(ref Int32, CUdevice[], UInt32, IntPtr, CUd3dXDeviceList)

    Gets the CUDA devices corresponding to a Direct3D 11 device

    Returns in pCudaDeviceCount the number of CUDA-compatible device corresponding to the Direct3D 11 device pD3D11Device. Also returns in pCudaDevices at most cudaDeviceCount of the the CUDA-compatible devices corresponding to the Direct3D 11 device pD3D11Device.

    If any of the GPUs being used to render pDevice are not CUDA capable then the call will return ErrorNoDevice.

    Declaration
    public static CUResult cuD3D11GetDevices(ref int pCudaDeviceCount, CUdevice[] pCudaDevices, uint cudaDeviceCount, IntPtr pD3D11Device, CUd3dXDeviceList deviceList)
    Parameters
    Type Name Description
    System.Int32 pCudaDeviceCount

    Returned number of CUDA devices corresponding to pD3D9Device

    CUdevice[] pCudaDevices

    Returned CUDA devices corresponding to pD3D11Device

    System.UInt32 cudaDeviceCount

    The size of the output device array pCudaDevices

    System.IntPtr pD3D11Device

    Direct3D 11 device to query for CUDA devices

    CUd3dXDeviceList deviceList

    The set of devices to return.

    Returns
    Type Description
    CUResult

    CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized, ErrorNoDevice, ErrorUnknown. Note that this function may also return error codes from previous, asynchronous launches.

    cuD3D11GetDirect3DDevice(ref IntPtr)

    Returns in ppD3DDevice the Direct3D device against which this CUDA context was created in cuD3D11CtxCreate(ref CUcontext, ref CUdevice, CUCtxFlags, IntPtr).

    Declaration
    public static CUResult cuD3D11GetDirect3DDevice(ref IntPtr ppD3DDevice)
    Parameters
    Type Name Description
    System.IntPtr ppD3DDevice

    Returned Direct3D device corresponding to CUDA context

    Returns
    Type Description
    CUResult

    CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized, ErrorInvalidValue. Note that this function may also return error codes from previous, asynchronous launches.

    cuGraphicsD3D11RegisterResource(ref CUgraphicsResource, IntPtr, CUGraphicsRegisterFlags)

    Registers the Direct3D 11 resource pD3DResource for access by CUDA and returns a CUDA handle to pD3Dresource in pCudaResource. The handle returned in pCudaResource may be used to map and unmap this resource until it is unregistered. On success this call will increase the internal reference count on pD3DResource. This reference count will be decremented when this resource is unregistered through cuGraphicsUnregisterResource(CUgraphicsResource).

    This call is potentially high-overhead and should not be called every frame in interactive applications.

    The type of pD3DResource must be one of the following:

    Type of pD3DResourceRestriction
    ID3D11Buffer May be accessed through 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.
    The Flags argument may be used to specify additional parameters at register time. The only valid value for this parameter is None.

    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. • Resources allocated as shared 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. If Direct3D interoperability is not initialized for this context using cuD3D11CtxCreate(ref CUcontext, ref CUdevice, CUCtxFlags, IntPtr) then ErrorInvalidContext is returned. If pD3DResource is of incorrect type or is already registered then ErrorInvalidHandle is returned. If pD3DResource cannot be registered then ErrorUnknown is returned. If Flags is not one of the above specified value then ErrorInvalidValue is returned.

    Declaration
    public static CUResult cuGraphicsD3D11RegisterResource(ref CUgraphicsResource pCudaResource, IntPtr pD3DResource, CUGraphicsRegisterFlags Flags)
    Parameters
    Type Name Description
    CUgraphicsResource pCudaResource

    Returned graphics resource handle

    System.IntPtr pD3DResource

    Direct3D resource to register

    CUGraphicsRegisterFlags Flags

    Parameters for resource registration

    Returns
    Type Description
    CUResult

    CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized, ErrorInvalidContext, ErrorInvalidValue, ErrorInvalidHandle, ErrorOutOfMemory, ErrorUnknown. Note that this function may also return error codes from previous, asynchronous launches.

    • Improve this Doc
    • View Source
    Back to top Generated by DocFX