OpenGL Interop

OpenGL Interop#

HIP Runtime API Reference: OpenGL Interop
OpenGL Interop
Collaboration diagram for OpenGL Interop:

Functions

hipError_t hipGraphicsMapResources (int count, hipGraphicsResource_t *resources, hipStream_t stream)
 Maps a graphics resource for access.
 
hipError_t hipGraphicsSubResourceGetMappedArray (hipArray_t *array, hipGraphicsResource_t resource, unsigned int arrayIndex, unsigned int mipLevel)
 Get an array through which to access a subresource of a mapped graphics resource.
 
hipError_t hipGraphicsResourceGetMappedPointer (void **devPtr, size_t *size, hipGraphicsResource_t resource)
 Gets device accessible address of a graphics resource.
 
hipError_t hipGraphicsUnmapResources (int count, hipGraphicsResource_t *resources, hipStream_t stream)
 Unmaps graphics resources.
 
hipError_t hipGraphicsUnregisterResource (hipGraphicsResource_t resource)
 Unregisters a graphics resource.
 
hipError_t hipGLGetDevices (unsigned int *pHipDeviceCount, int *pHipDevices, unsigned int hipDeviceCount, hipGLDeviceList deviceList)
 Queries devices associated with the current OpenGL context.
 
hipError_t hipGraphicsGLRegisterBuffer (hipGraphicsResource **resource, GLuint buffer, unsigned int flags)
 Registers a GL Buffer for interop and returns corresponding graphics resource.
 
hipError_t hipGraphicsGLRegisterImage (hipGraphicsResource **resource, GLuint image, GLenum target, unsigned int flags)
 Register a GL Image for interop and returns the corresponding graphic resource.
 

Detailed Description



This section describes the OpenGL and graphics interoperability functions of HIP runtime API.

Function Documentation

◆ hipGLGetDevices()

hipError_t hipGLGetDevices ( unsigned int *  pHipDeviceCount,
int *  pHipDevices,
unsigned int  hipDeviceCount,
hipGLDeviceList  deviceList 
)

Queries devices associated with the current OpenGL context.

Parameters
[out]pHipDeviceCount- Pointer of number of devices on the current GL context.
[out]pHipDevices- Pointer of devices on the current OpenGL context.
[in]hipDeviceCount- Size of device.
[in]deviceList- The setting of devices. It could be either hipGLDeviceListCurrentFrame for the devices used to render the current frame, or hipGLDeviceListAll for all devices. The default setting is Invalid deviceList value.
Returns
hipSuccess, hipErrorInvalidValue, hipErrorNotSupported

◆ hipGraphicsGLRegisterBuffer()

hipError_t hipGraphicsGLRegisterBuffer ( hipGraphicsResource **  resource,
GLuint  buffer,
unsigned int  flags 
)

Registers a GL Buffer for interop and returns corresponding graphics resource.

Parameters
[out]resource- Returns pointer of graphics resource.
[in]buffer- Buffer to be registered.
[in]flags- Register flags.
Returns
hipSuccess, hipErrorInvalidValue, hipErrorUnknown, hipErrorInvalidResourceHandle

◆ hipGraphicsGLRegisterImage()

hipError_t hipGraphicsGLRegisterImage ( hipGraphicsResource **  resource,
GLuint  image,
GLenum  target,
unsigned int  flags 
)

Register a GL Image for interop and returns the corresponding graphic resource.

Parameters
[out]resource- Returns pointer of graphics resource.
[in]image- Image to be registered.
[in]target- Valid target value Id.
[in]flags- Register flags.
Returns
hipSuccess, hipErrorInvalidValue, hipErrorUnknown, hipErrorInvalidResourceHandle

◆ hipGraphicsMapResources()

hipError_t hipGraphicsMapResources ( int  count,
hipGraphicsResource_t resources,
hipStream_t  stream 
)

Maps a graphics resource for access.

Parameters
[in]count- Number of resources to map.
[in]resources- Pointer of resources to map.
[in]stream- Stream for synchronization.
Returns
hipSuccess, hipErrorInvalidValue, hipErrorUnknown, hipErrorInvalidResourceHandle

◆ hipGraphicsResourceGetMappedPointer()

hipError_t hipGraphicsResourceGetMappedPointer ( void **  devPtr,
size_t *  size,
hipGraphicsResource_t  resource 
)

Gets device accessible address of a graphics resource.

Parameters
[out]devPtr- Pointer of device through which graphic resource may be accessed.
[out]size- Size of the buffer accessible from devPtr.
[in]resource- Mapped resource to access.
Returns
hipSuccess, hipErrorInvalidValue

◆ hipGraphicsSubResourceGetMappedArray()

hipError_t hipGraphicsSubResourceGetMappedArray ( hipArray_t array,
hipGraphicsResource_t  resource,
unsigned int  arrayIndex,
unsigned int  mipLevel 
)

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

Parameters
[out]array- Pointer of array through which a subresource of resource may be accessed.
[in]resource- Mapped resource to access.
[in]arrayIndex- Array index for the subresource to access.
[in]mipLevel- Mipmap level for the subresource to access.
Returns
hipSuccess, hipErrorInvalidValue
Note
In this API, the value of arrayIndex higher than zero is currently not supported.

◆ hipGraphicsUnmapResources()

hipError_t hipGraphicsUnmapResources ( int  count,
hipGraphicsResource_t resources,
hipStream_t  stream 
)

Unmaps graphics resources.

Parameters
[in]count- Number of resources to unmap.
[in]resources- Pointer of resources to unmap.
[in]stream- Stream for synchronization.
Returns
hipSuccess, hipErrorInvalidValue, hipErrorUnknown, hipErrorContextIsDestroyed

◆ hipGraphicsUnregisterResource()

hipError_t hipGraphicsUnregisterResource ( hipGraphicsResource_t  resource)

Unregisters a graphics resource.

Parameters
[in]resource- Graphics resources to unregister.
Returns
hipSuccess