GPUOcelot
Functions

Graphics Interoperability

CUDA Driver API
Collaboration diagram for Graphics Interoperability:

Functions

CUresult CUDAAPI cuGraphicsUnregisterResource (CUgraphicsResource resource)
 Unregisters a graphics resource for access by CUDA.
CUresult CUDAAPI cuGraphicsSubResourceGetMappedArray (CUarray *pArray, CUgraphicsResource resource, unsigned int arrayIndex, unsigned int mipLevel)
 Get an array through which to access a subresource of a mapped graphics resource.
CUresult CUDAAPI cuGraphicsResourceSetMapFlags (CUgraphicsResource resource, unsigned int flags)
 Set usage flags for mapping a graphics resource.
CUresult CUDAAPI cuGraphicsMapResources (unsigned int count, CUgraphicsResource *resources, CUstream hStream)
 Map graphics resources for access by CUDA.
CUresult CUDAAPI cuGraphicsUnmapResources (unsigned int count, CUgraphicsResource *resources, CUstream hStream)
 Unmap graphics resources.
CUresult CUDAAPI cuGraphicsResourceGetMappedPointer (CUdeviceptr *pDevPtr, size_t *pSize, CUgraphicsResource resource)
 Get a device pointer through which to access a mapped graphics resource.

Detailed Description

This section describes the graphics interoperability functions of the low-level CUDA driver application programming interface.


Function Documentation

CUresult CUDAAPI cuGraphicsMapResources ( unsigned int  count,
CUgraphicsResource resources,
CUstream  hStream 
)

Map graphics resources for access by CUDA.

Maps the count graphics resources in resources for access by CUDA.

The resources in resources may be accessed by CUDA until they are unmapped. The graphics API from which resources were registered 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 graphics calls issued before cuGraphicsMapResources() will complete before any subsequent CUDA work issued in stream begins.

If resources includes any duplicate entries then CUDA_ERROR_INVALID_HANDLE is returned. If any of resources are presently mapped for access by CUDA then CUDA_ERROR_ALREADY_MAPPED is returned.

Parameters:
count- Number of resources to map
resources- Resources to map for CUDA usage
hStream- Stream with which to synchronize
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
See also:
cuGraphicsResourceGetMappedPointer cuGraphicsSubResourceGetMappedArray cuGraphicsUnmapResources
CUresult CUDAAPI cuGraphicsResourceGetMappedPointer ( CUdeviceptr pDevPtr,
size_t pSize,
CUgraphicsResource  resource 
)

Get a device pointer through which to access a mapped graphics resource.

Returns in *pDevPtr a pointer through which the mapped graphics resource resource may be accessed. Returns in pSize the size of the memory in bytes which may be accessed from that pointer. The value set in pPointer may change every time that resource is mapped.

If resource is not a buffer then it cannot be accessed via a pointer and CUDA_ERROR_NOT_MAPPED_AS_POINTER is returned. If resource is not mapped then CUDA_ERROR_NOT_MAPPED is returned. *

Parameters:
pDevPtr- Returned pointer through which resource may be accessed
pSize- Returned size of the buffer accessible starting at *pPointer
resource- Mapped resource 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 CUDA_ERROR_NOT_MAPPED_AS_POINTER
See also:
cuGraphicsMapResources, cuGraphicsSubResourceGetMappedArray
CUresult CUDAAPI cuGraphicsResourceSetMapFlags ( CUgraphicsResource  resource,
unsigned int  flags 
)

Set usage flags for mapping a graphics resource.

Set flags for mapping the graphics resource resource.

Changes to flags will take effect the next time resource is mapped. The flags argument may be any of the following:

  • CU_GRAPHICS_MAP_RESOURCE_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_GRAPHICS_MAP_RESOURCE_FLAGS_READONLY: Specifies that CUDA kernels which access this resource will not write to this resource.
  • ::CU_GRAPHICS_MAP_RESOURCE_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 resource is presently mapped for access by CUDA then CUDA_ERROR_ALREADY_MAPPED is returned. If flags is not one of the above values then CUDA_ERROR_INVALID_VALUE is returned.

Parameters:
resource- 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
See also:
cuGraphicsMapResources
CUresult CUDAAPI cuGraphicsSubResourceGetMappedArray ( CUarray pArray,
CUgraphicsResource  resource,
unsigned int  arrayIndex,
unsigned int  mipLevel 
)

Get an array through which to access a subresource of a mapped graphics resource.

Returns in *pArray an array through which the subresource of the mapped graphics resource resource which corresponds to array index arrayIndex and mipmap level mipLevel may be accessed. The value set in *pArray may change every time that resource is mapped.

If resource is not a texture then it cannot be accessed via an array and CUDA_ERROR_NOT_MAPPED_AS_ARRAY is returned. If arrayIndex is not a valid array index for resource then CUDA_ERROR_INVALID_VALUE is returned. If mipLevel is not a valid mipmap level for resource then CUDA_ERROR_INVALID_VALUE is returned. If resource is not mapped then CUDA_ERROR_NOT_MAPPED is returned.

Parameters:
pArray- Returned array through which a subresource of resource may be accessed
resource- Mapped resource to access
arrayIndex- Array index for array textures or cubemap face index as defined by CUarray_cubemap_face for cubemap textures for the subresource to access
mipLevel- Mipmap level for the subresource 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 CUDA_ERROR_NOT_MAPPED_AS_ARRAY
See also:
cuGraphicsResourceGetMappedPointer
CUresult CUDAAPI cuGraphicsUnmapResources ( unsigned int  count,
CUgraphicsResource resources,
CUstream  hStream 
)

Unmap graphics resources.

Unmaps the count graphics resources in resources.

Once unmapped, the resources in resources may not be accessed by CUDA until they are mapped again.

This function provides the synchronization guarantee that any CUDA work issued in stream before cuGraphicsUnmapResources() will complete before any subsequently issued graphics work begins.

If resources includes any duplicate entries then CUDA_ERROR_INVALID_HANDLE is returned. If any of resources are not presently mapped for access by CUDA then CUDA_ERROR_NOT_MAPPED is returned.

Parameters:
count- Number of resources to unmap
resources- Resources to unmap
hStream- Stream with which to synchronize
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_NOT_MAPPED, CUDA_ERROR_UNKNOWN
See also:
cuGraphicsMapResources
CUresult CUDAAPI cuGraphicsUnregisterResource ( CUgraphicsResource  resource)

Unregisters a graphics resource for access by CUDA.

Unregisters the graphics resource resource so it is not accessible by CUDA unless registered again.

If resource is invalid then CUDA_ERROR_INVALID_HANDLE is returned.

Parameters:
resource- Resource to unregister
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_UNKNOWN
See also:
::cuGraphicsD3D9RegisterResource, ::cuGraphicsD3D10RegisterResource, ::cuGraphicsD3D11RegisterResource, cuGraphicsGLRegisterBuffer, cuGraphicsGLRegisterImage
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines