Show / Hide Table of Contents

    Class DirectX9NativeMethods.CUDA3

    Direct3D9 Interoperability for CUDA 3.x

    Inheritance
    System.Object
    DirectX9NativeMethods.CUDA3
    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 CUDA3

    Methods

    cuD3D9CtxCreate(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 cuD3D9CtxCreate(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.

    cuD3D9CtxCreateOnDevice(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 cuD3D9CtxCreateOnDevice(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.

    cuD3D9GetDevice(ref CUdevice, String)

    Returns in pCudaDevice the CUDA-compatible device corresponding to the adapter name pszAdapterName obtained from EnumDisplayDevices() or IDirect3D9::GetAdapterIdentifier(). If no device on the adapter with name pszAdapterName is CUDA-compatible, then the call will fail.

    Declaration
    public static CUResult cuD3D9GetDevice(ref CUdevice pCudaDevice, string pszAdapterName)
    Parameters
    Type Name Description
    CUdevice pCudaDevice

    Returned CUDA device corresponding to pszAdapterName

    System.String pszAdapterName

    Adapter name to query for device

    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.

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

    Gets the CUDA devices corresponding to a Direct3D 9 device

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

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

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

    Returned number of CUDA devices corresponding to pD3D9Device

    CUdevice[] pCudaDevices

    Returned CUDA devices corresponding to pD3D9Device

    System.UInt32 cudaDeviceCount

    The size of the output device array pCudaDevices

    System.IntPtr pD3D9Device

    Direct3D 9 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.

    cuD3D9GetDirect3DDevice(ref IntPtr)

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

    Declaration
    public static CUResult cuD3D9GetDirect3DDevice(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.

    cuGraphicsD3D9RegisterResource(ref CUgraphicsResource, IntPtr, CUGraphicsRegisterFlags)

    Registers the Direct3D 9 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
    IDirect3DVertexBuffer9 May be accessed through a device pointer.
    IDirect3DIndexBuffer9 May be accessed through a device pointer.
    IDirect3DSurface9 May be accessed through an array. Only stand-alone objects of type IDirect3DSurface9 may be explicitly shared. In particular, individual mipmap levels and faces of cube maps may not be registered directly. To access individual surfaces associated with a texture, one must register the base texture object.
    IDirect3DBaseTexture9 Individual surfaces on this texture may be accessed through an array.
    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 cuD3D9CtxCreate(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 cuGraphicsD3D9RegisterResource(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