Movatterモバイル変換


[0]ホーム

URL:


NVIDIACUDA Toolkit Documentation
Search In:
< Previous |Next >
CUDA Runtime API (PDF) - v13.0.2 (older) - Last updated October 9, 2025 -Send Feedback

6.25. Graphics Interoperability

This section describes the graphics interoperability functions of the CUDA runtime application programming interface.

Functions

__host__cudaError_t cudaGraphicsMapResources ( int count,cudaGraphicsResource_t* resources,cudaStream_t stream =0 )
Map graphics resources for access by CUDA.
__host__cudaError_t cudaGraphicsResourceGetMappedMipmappedArray (cudaMipmappedArray_t* mipmappedArray,cudaGraphicsResource_t resource )
Get a mipmapped array through which to access a mapped graphics resource.
__host__cudaError_t cudaGraphicsResourceGetMappedPointer ( void** devPtr, size_t* size,cudaGraphicsResource_t resource )
Get an device pointer through which to access a mapped graphics resource.
__host__cudaError_t cudaGraphicsResourceSetMapFlags (cudaGraphicsResource_t resource, unsigned int flags )
Set usage flags for mapping a graphics resource.
__host__cudaError_t cudaGraphicsSubResourceGetMappedArray (cudaArray_t* array,cudaGraphicsResource_t resource, unsigned int arrayIndex, unsigned int mipLevel )
Get an array through which to access a subresource of a mapped graphics resource.
__host__cudaError_t cudaGraphicsUnmapResources ( int count,cudaGraphicsResource_t* resources,cudaStream_t stream =0 )
Unmap graphics resources.
__host__cudaError_t cudaGraphicsUnregisterResource (cudaGraphicsResource_t resource )
Unregisters a graphics resource for access by CUDA.

Functions

__host__cudaError_t cudaGraphicsMapResources ( int count,cudaGraphicsResource_t* resources,cudaStream_t stream =0 )
Map graphics resources for access by CUDA.
Parameters
count
- Number of resources to map
resources
- Resources to map for CUDA
stream
- Stream for synchronization
Description

Maps thecount graphics resources inresources for access by CUDA.

The resources inresources may be accessed by CUDA until they are unmapped. The graphics API from whichresources 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 beforecudaGraphicsMapResources() will complete before any subsequent CUDA work issued instream begins.

Ifresources contains any duplicate entries thencudaErrorInvalidResourceHandle is returned. If any ofresources are presently mapped for access by CUDA thencudaErrorUnknown is returned.

Note:

See also:

cudaGraphicsResourceGetMappedPointer,cudaGraphicsSubResourceGetMappedArray,cudaGraphicsUnmapResources,cuGraphicsMapResources

__host__cudaError_t cudaGraphicsResourceGetMappedMipmappedArray (cudaMipmappedArray_t* mipmappedArray,cudaGraphicsResource_t resource )
Get a mipmapped array through which to access a mapped graphics resource.
Parameters
mipmappedArray
- Returned mipmapped array through whichresource may be accessed
resource
- Mapped resource to access
Description

Returns in*mipmappedArray a mipmapped array through which the mapped graphics resourceresource may be accessed. The value set inmipmappedArray may change every time thatresource is mapped.

Ifresource is not a texture then it cannot be accessed via an array andcudaErrorUnknown is returned. Ifresource is not mapped thencudaErrorUnknown is returned.

Note:

See also:

cudaGraphicsResourceGetMappedPointer,cuGraphicsResourceGetMappedMipmappedArray

__host__cudaError_t cudaGraphicsResourceGetMappedPointer ( void** devPtr, size_t* size,cudaGraphicsResource_t resource )
Get an device pointer through which to access a mapped graphics resource.
Parameters
devPtr
- Returned pointer through whichresource may be accessed
size
- Returned size of the buffer accessible starting at*devPtr
resource
- Mapped resource to access
Description

Returns in*devPtr a pointer through which the mapped graphics resourceresource may be accessed. Returns in*size the size of the memory in bytes which may be accessed from that pointer. The value set indevPtr may change every time thatresource is mapped.

Ifresource is not a buffer then it cannot be accessed via a pointer andcudaErrorUnknown is returned. Ifresource is not mapped thencudaErrorUnknown is returned. *

Note:

See also:

cudaGraphicsMapResources,cudaGraphicsSubResourceGetMappedArray,cuGraphicsResourceGetMappedPointer

__host__cudaError_t cudaGraphicsResourceSetMapFlags (cudaGraphicsResource_t resource, unsigned int flags )
Set usage flags for mapping a graphics resource.
Parameters
resource
- Registered resource to set flags for
flags
- Parameters for resource mapping
Description

Setflags for mapping the graphics resourceresource.

Changes toflags will take effect the next timeresource is mapped. Theflags argument may be any of the following:

Ifresource is presently mapped for access by CUDA thencudaErrorUnknown is returned. Ifflags is not one of the above values thencudaErrorInvalidValue is returned.

Note:

See also:

cudaGraphicsMapResources,cuGraphicsResourceSetMapFlags

__host__cudaError_t cudaGraphicsSubResourceGetMappedArray (cudaArray_t* array,cudaGraphicsResource_t resource, unsigned int arrayIndex, unsigned int mipLevel )
Get an array through which to access a subresource of a mapped graphics resource.
Parameters
array
- Returned array through which a subresource ofresource may be accessed
resource
- Mapped resource to access
arrayIndex
- Array index for array textures or cubemap face index as defined bycudaGraphicsCubeFace for cubemap textures for the subresource to access
mipLevel
- Mipmap level for the subresource to access
Description

Returns in*array an array through which the subresource of the mapped graphics resourceresource which corresponds to array indexarrayIndex and mipmap levelmipLevel may be accessed. The value set inarray may change every time thatresource is mapped.

Ifresource is not a texture then it cannot be accessed via an array andcudaErrorUnknown is returned. IfarrayIndex is not a valid array index forresource thencudaErrorInvalidValue is returned. IfmipLevel is not a valid mipmap level forresource thencudaErrorInvalidValue is returned. Ifresource is not mapped thencudaErrorUnknown is returned.

Note:

See also:

cudaGraphicsResourceGetMappedPointer,cuGraphicsSubResourceGetMappedArray

__host__cudaError_t cudaGraphicsUnmapResources ( int count,cudaGraphicsResource_t* resources,cudaStream_t stream =0 )
Unmap graphics resources.
Parameters
count
- Number of resources to unmap
resources
- Resources to unmap
stream
- Stream for synchronization
Description

Unmaps thecount graphics resources inresources.

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

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

Ifresources contains any duplicate entries thencudaErrorInvalidResourceHandle is returned. If any ofresources are not presently mapped for access by CUDA thencudaErrorUnknown is returned.

Note:

See also:

cudaGraphicsMapResources,cuGraphicsUnmapResources

__host__cudaError_t cudaGraphicsUnregisterResource (cudaGraphicsResource_t resource )
Unregisters a graphics resource for access by CUDA.
Parameters
resource
- Resource to unregister
Description

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

Ifresource is invalid thencudaErrorInvalidResourceHandle is returned.

Note:

See also:

cudaGraphicsD3D9RegisterResource,cudaGraphicsD3D10RegisterResource,cudaGraphicsD3D11RegisterResource,cudaGraphicsGLRegisterBuffer,cudaGraphicsGLRegisterImage,cuGraphicsUnregisterResource



[8]ページ先頭

©2009-2025 Movatter.jp