6.8.1. Direct3D 10 Interoperability [DEPRECATED]
This section describes deprecated Direct3D 10 interoperability functionality.
Enumerations
- CUD3D10map_flags
Flags to map or unmap a resource.
- CUD3D10register_flags
Flags to register a resource.
Functions
- CUresult cuD3D10CtxCreate(CUcontext *pCtx, CUdevice *pCudaDevice, unsigned int Flags, ID3D10Device *pD3DDevice)
Create a CUDA context for interoperability with Direct3D 10.
- CUresult cuD3D10CtxCreateOnDevice(CUcontext *pCtx, unsigned int flags, ID3D10Device *pD3DDevice, CUdevice cudaDevice)
Create a CUDA context for interoperability with Direct3D 10.
- CUresult cuD3D10GetDirect3DDevice(ID3D10Device **ppD3DDevice)
Get the Direct3D 10 device against which the current CUDA context was created.
- CUresult cuD3D10MapResources(unsigned int count, ID3D10Resource **ppResources)
Map Direct3D resources for access by CUDA.
- CUresult cuD3D10RegisterResource(ID3D10Resource *pResource, unsigned int Flags)
Register a Direct3D resource for access by CUDA.
- CUresult cuD3D10ResourceGetMappedArray(CUarray *pArray, ID3D10Resource *pResource, unsigned int SubResource)
Get an array through which to access a subresource of a Direct3D resource which has been mapped for access by CUDA.
- CUresult cuD3D10ResourceGetMappedPitch(size_t *pPitch, size_t *pPitchSlice, ID3D10Resource *pResource, unsigned int SubResource)
Get the pitch of a subresource of a Direct3D resource which has been mapped for access by CUDA.
- CUresult cuD3D10ResourceGetMappedPointer(CUdeviceptr *pDevPtr, ID3D10Resource *pResource, unsigned int SubResource)
Get a pointer through which to access a subresource of a Direct3D resource which has been mapped for access by CUDA.
- CUresult cuD3D10ResourceGetMappedSize(size_t *pSize, ID3D10Resource *pResource, unsigned int SubResource)
Get the size of a subresource of a Direct3D resource which has been mapped for access by CUDA.
- CUresult cuD3D10ResourceGetSurfaceDimensions(size_t *pWidth, size_t *pHeight, size_t *pDepth, ID3D10Resource *pResource, unsigned int SubResource)
Get the dimensions of a registered surface.
- CUresult cuD3D10ResourceSetMapFlags(ID3D10Resource *pResource, unsigned int Flags)
Set usage flags for mapping a Direct3D resource.
- CUresult cuD3D10UnmapResources(unsigned int count, ID3D10Resource **ppResources)
Unmap Direct3D resources.
- CUresult cuD3D10UnregisterResource(ID3D10Resource *pResource)
Unregister a Direct3D resource.
6.8.1.1. Enumerations
6.8.1.2. Functions
-
CUresult cuD3D10CtxCreate(CUcontext *pCtx, CUdevice *pCudaDevice, unsigned int Flags, ID3D10Device *pD3DDevice)
Create a CUDA context for interoperability with Direct3D 10.
- Deprecated:
This function is deprecated as of CUDA 5.0.
This function is deprecated and should no longer be used. It is no longer necessary to associate a CUDA context with a D3D10 device in order to achieve maximum interoperability performance.
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
pCtx – - Returned newly created CUDA context
pCudaDevice – - Returned pointer to the device on which the context was created
Flags – - Context creation flags (see cuCtxCreate() for details)
pD3DDevice – - Direct3D device to create interoperability context with
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY, CUDA_ERROR_UNKNOWN
-
CUresult cuD3D10CtxCreateOnDevice(CUcontext *pCtx, unsigned int flags, ID3D10Device *pD3DDevice, CUdevice cudaDevice)
Create a CUDA context for interoperability with Direct3D 10.
- Deprecated:
This function is deprecated as of CUDA 5.0.
This function is deprecated and should no longer be used. It is no longer necessary to associate a CUDA context with a D3D10 device in order to achieve maximum interoperability performance.
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
pCtx – - Returned newly created CUDA context
flags – - Context creation flags (see cuCtxCreate() for details)
pD3DDevice – - Direct3D device to create interoperability context with
cudaDevice – - The CUDA device on which to create the context. This device must be among the devices returned when querying ::CU_D3D10_DEVICES_ALL from cuD3D10GetDevices.
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY, CUDA_ERROR_UNKNOWN
-
CUresult cuD3D10GetDirect3DDevice(ID3D10Device **ppD3DDevice)
Get the Direct3D 10 device against which the current CUDA context was created.
- Deprecated:
This function is deprecated as of CUDA 5.0.
This function is deprecated and should no longer be used. It is no longer necessary to associate a CUDA context with a D3D10 device in order to achieve maximum interoperability performance.
See also
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
ppD3DDevice – - Returned Direct3D device corresponding to CUDA context
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT
-
CUresult cuD3D10MapResources(unsigned int count, ID3D10Resource **ppResources)
Map Direct3D resources for access by CUDA.
- Deprecated:
This function is deprecated as of CUDA 3.0.
Maps the
countDirect3D resources inppResourcesfor access by CUDA.The resources in
ppResourcesmay be accessed in CUDA kernels until they are unmapped. Direct3D should not access any resources while they are mapped by CUDA. If an application does so, the results are undefined.This function provides the synchronization guarantee that any Direct3D calls issued before cuD3D10MapResources() will complete before any CUDA kernels issued after cuD3D10MapResources() begin.
If any of
ppResourceshave not been registered for use with CUDA or ifppResourcescontains any duplicate entries, then CUDA_ERROR_INVALID_HANDLE is returned. If any ofppResourcesare presently mapped for access by CUDA, then CUDA_ERROR_ALREADY_MAPPED is returned.See also
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
count – - Number of resources to map for CUDA
ppResources – - Resources to map for CUDA
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_ALREADY_MAPPED, CUDA_ERROR_UNKNOWN
-
CUresult cuD3D10RegisterResource(ID3D10Resource *pResource, unsigned int Flags)
Register a Direct3D resource for access by CUDA.
- Deprecated:
This function is deprecated as of CUDA 3.0.
Registers the Direct3D resource
pResourcefor access by CUDA.If this call is successful, then the application will be able to map and unmap this resource until it is unregistered through cuD3D10UnregisterResource(). Also on success, this call will increase the internal reference count on
pResource. This reference count will be decremented when this resource is unregistered through cuD3D10UnregisterResource().This call is potentially high-overhead and should not be called every frame in interactive applications.
The type of
pResourcemust be one of the following.::ID3D10Buffer: Cannot be used with
Flagsset to CU_D3D10_REGISTER_FLAGS_ARRAY.::ID3D10Texture1D: No restrictions.
::ID3D10Texture2D: No restrictions.
::ID3D10Texture3D: No restrictions.
The
Flagsargument specifies the mechanism through which CUDA will access the Direct3D resource. The following values are allowed.CU_D3D10_REGISTER_FLAGS_NONE: Specifies that CUDA will access this resource through a CUdeviceptr. The pointer, size, and (for textures), pitch for each subresource of this allocation may be queried through cuD3D10ResourceGetMappedPointer(), cuD3D10ResourceGetMappedSize(), and cuD3D10ResourceGetMappedPitch() respectively. This option is valid for all resource types.
CU_D3D10_REGISTER_FLAGS_ARRAY: Specifies that CUDA will access this resource through a CUarray queried on a sub-resource basis through cuD3D10ResourceGetMappedArray(). This option is only valid for resources of type ::ID3D10Texture1D, ::ID3D10Texture2D, and ::ID3D10Texture3D.
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 on this context then CUDA_ERROR_INVALID_CONTEXT is returned. If
pResourceis of incorrect type or is already registered, then CUDA_ERROR_INVALID_HANDLE is returned. IfpResourcecannot be registered, then CUDA_ERROR_UNKNOWN is returned.See also
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
pResource – - Resource to register
Flags – - Parameters for resource registration
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_OUT_OF_MEMORY, CUDA_ERROR_UNKNOWN
-
CUresult cuD3D10ResourceGetMappedArray(CUarray *pArray, ID3D10Resource *pResource, unsigned int SubResource)
Get an array through which to access a subresource of a Direct3D resource which has been mapped for access by CUDA.
- Deprecated:
This function is deprecated as of CUDA 3.0.
Returns in
*pArrayan array through which the subresource of the mapped Direct3D resourcepResource, which corresponds toSubResourcemay be accessed. The value set inpArraymay change every time thatpResourceis mapped.If
pResourceis not registered, then CUDA_ERROR_INVALID_HANDLE is returned. IfpResourcewas not registered with usage flags CU_D3D10_REGISTER_FLAGS_ARRAY, then CUDA_ERROR_INVALID_HANDLE is returned. IfpResourceis not mapped, then CUDA_ERROR_NOT_MAPPED is returned.For usage requirements of the
SubResourceparameter, see cuD3D10ResourceGetMappedPointer().See also
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
pArray – - Returned array corresponding to subresource
pResource – - Mapped resource to access
SubResource – - Subresource of pResource to access
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_NOT_MAPPED
-
CUresult cuD3D10ResourceGetMappedPitch(size_t *pPitch, size_t *pPitchSlice, ID3D10Resource *pResource, unsigned int SubResource)
Get the pitch of a subresource of a Direct3D resource which has been mapped for access by CUDA.
- Deprecated:
This function is deprecated as of CUDA 3.0.
Returns in
*pPitchand*pPitchSlicethe pitch and Z-slice pitch of the subresource of the mapped Direct3D resourcepResource, which corresponds toSubResource. The values set inpPitchandpPitchSlicemay change every time thatpResourceis mapped.The pitch and Z-slice pitch values may be used to compute the location of a sample on a surface as follows.
For a 2D surface, the byte offset of the sample at position x, y from the base pointer of the surface is:
y * pitch + (bytes per pixel) * x
For a 3D surface, the byte offset of the sample at position x, y, z from the base pointer of the surface is:
z* slicePitch + y * pitch + (bytes per pixel) * x
Both parameters
pPitchandpPitchSliceare optional and may be set to NULL.If
pResourceis not of type ::IDirect3DBaseTexture10 or one of its sub-types or ifpResourcehas not been registered for use with CUDA, then CUDA_ERROR_INVALID_HANDLE is returned. IfpResourcewas not registered with usage flags CU_D3D10_REGISTER_FLAGS_NONE, then CUDA_ERROR_INVALID_HANDLE is returned. IfpResourceis not mapped for access by CUDA, then CUDA_ERROR_NOT_MAPPED is returned.For usage requirements of the
SubResourceparameter, see cuD3D10ResourceGetMappedPointer().See also
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
pPitch – - Returned pitch of subresource
pPitchSlice – - Returned Z-slice pitch of subresource
pResource – - Mapped resource to access
SubResource – - Subresource of pResource to access
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_NOT_MAPPED
-
CUresult cuD3D10ResourceGetMappedPointer(CUdeviceptr *pDevPtr, ID3D10Resource *pResource, unsigned int SubResource)
Get a pointer through which to access a subresource of a Direct3D resource which has been mapped for access by CUDA.
- Deprecated:
This function is deprecated as of CUDA 3.0.
Returns in
*pDevPtrthe base pointer of the subresource of the mapped Direct3D resourcepResource, which corresponds toSubResource. The value set inpDevPtrmay change every time thatpResourceis mapped.If
pResourceis not registered, then CUDA_ERROR_INVALID_HANDLE is returned. IfpResourcewas not registered with usage flags CU_D3D10_REGISTER_FLAGS_NONE, then CUDA_ERROR_INVALID_HANDLE is returned. IfpResourceis not mapped, then CUDA_ERROR_NOT_MAPPED is returned.If
pResourceis of type ::ID3D10Buffer, thenSubResourcemust be 0. IfpResourceis of any other type, then the value ofSubResourcemust come from the subresource calculation in ::D3D10CalcSubResource().See also
cuGraphicsResourceGetMappedPointer
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
pDevPtr – - Returned pointer corresponding to subresource
pResource – - Mapped resource to access
SubResource – - Subresource of pResource to access
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_NOT_MAPPED
-
CUresult cuD3D10ResourceGetMappedSize(size_t *pSize, ID3D10Resource *pResource, unsigned int SubResource)
Get the size of a subresource of a Direct3D resource which has been mapped for access by CUDA.
- Deprecated:
This function is deprecated as of CUDA 3.0.
Returns in
*pSizethe size of the subresource of the mapped Direct3D resourcepResource, which corresponds toSubResource. The value set inpSizemay change every time thatpResourceis mapped.If
pResourcehas not been registered for use with CUDA, then CUDA_ERROR_INVALID_HANDLE is returned. IfpResourcewas not registered with usage flags CU_D3D10_REGISTER_FLAGS_NONE, then CUDA_ERROR_INVALID_HANDLE is returned. IfpResourceis not mapped for access by CUDA, then CUDA_ERROR_NOT_MAPPED is returned.For usage requirements of the
SubResourceparameter, see cuD3D10ResourceGetMappedPointer().See also
cuGraphicsResourceGetMappedPointer
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
pSize – - Returned size of subresource
pResource – - Mapped resource to access
SubResource – - Subresource of pResource to access
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_NOT_MAPPED
-
CUresult cuD3D10ResourceGetSurfaceDimensions(size_t *pWidth, size_t *pHeight, size_t *pDepth, ID3D10Resource *pResource, unsigned int SubResource)
Get the dimensions of a registered surface.
- Deprecated:
This function is deprecated as of CUDA 3.0.
Returns in
*pWidth,*pHeight, and*pDepththe dimensions of the subresource of the mapped Direct3D resourcepResource, which corresponds toSubResource.Because anti-aliased surfaces may have multiple samples per pixel, it is possible that the dimensions of a resource will be an integer factor larger than the dimensions reported by the Direct3D runtime.
The parameters
pWidth,pHeight, andpDepthare optional. For 2D surfaces, the value returned in*pDepthwill be 0.If
pResourceis not of type ::IDirect3DBaseTexture10 or ::IDirect3DSurface10 or ifpResourcehas not been registered for use with CUDA, then CUDA_ERROR_INVALID_HANDLE is returned.For usage requirements of the
SubResourceparameter, see cuD3D10ResourceGetMappedPointer().See also
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
pWidth – - Returned width of surface
pHeight – - Returned height of surface
pDepth – - Returned depth of surface
pResource – - Registered resource to access
SubResource – - Subresource of pResource to access
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE
-
CUresult cuD3D10ResourceSetMapFlags(ID3D10Resource *pResource, unsigned int Flags)
Set usage flags for mapping a Direct3D resource.
- Deprecated:
This function is deprecated as of CUDA 3.0.
Set flags for mapping the Direct3D resource
pResource.Changes to flags will take effect the next time
pResourceis mapped. TheFlagsargument may be any of the following.CU_D3D10_MAPRESOURCE_FLAGS_NONE: Specifies no hints about how this resource will be used. It is therefore assumed that this resource will be read from and written to by CUDA kernels. This is the default value.
CU_D3D10_MAPRESOURCE_FLAGS_READONLY: Specifies that CUDA kernels which access this resource will not write to this resource.
CU_D3D10_MAPRESOURCE_FLAGS_WRITEDISCARD: Specifies that CUDA kernels which access this resource will not read from this resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will be preserved.
If
pResourcehas not been registered for use with CUDA, then CUDA_ERROR_INVALID_HANDLE is returned. IfpResourceis presently mapped for access by CUDA then CUDA_ERROR_ALREADY_MAPPED is returned.See also
cuGraphicsResourceSetMapFlags
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
pResource – - Registered resource to set flags for
Flags – - Parameters for resource mapping
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_ALREADY_MAPPED
-
CUresult cuD3D10UnmapResources(unsigned int count, ID3D10Resource **ppResources)
Unmap Direct3D resources.
- Deprecated:
This function is deprecated as of CUDA 3.0.
Unmaps the
countDirect3D resources inppResources.This function provides the synchronization guarantee that any CUDA kernels issued before cuD3D10UnmapResources() will complete before any Direct3D calls issued after cuD3D10UnmapResources() begin.
If any of
ppResourceshave not been registered for use with CUDA or ifppResourcescontains any duplicate entries, then CUDA_ERROR_INVALID_HANDLE is returned. If any ofppResourcesare not presently mapped for access by CUDA, then CUDA_ERROR_NOT_MAPPED is returned.See also
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
count – - Number of resources to unmap for CUDA
ppResources – - Resources to unmap for CUDA
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_NOT_MAPPED, CUDA_ERROR_UNKNOWN
-
CUresult cuD3D10UnregisterResource(ID3D10Resource *pResource)
Unregister a Direct3D resource.
- Deprecated:
This function is deprecated as of CUDA 3.0.
Unregisters the Direct3D resource
pResourceso it is not accessible by CUDA unless registered again.If
pResourceis not registered, then CUDA_ERROR_INVALID_HANDLE is returned.See also
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
pResource – - Resources to unregister
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_UNKNOWN