Skip to content

Commit

Permalink
OpenGL interop functions description update
Browse files Browse the repository at this point in the history
  • Loading branch information
neon60 committed Nov 10, 2024
1 parent 486755f commit 8af73cf
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions docs/how-to/hip_runtime_api/opengl_interop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ utilize these resources directly, bypassing the need for costly data transfers b
the CPU and GPU. This capability is useful in applications that require both
intensive GPU computation and real-time visualization.

The OpenGL resource can be mapped to HIP with :cpp:func:`hipGraphicsMapResources`
function and the device pointers are accessed with
:cpp:func:`hipGraphicsResourceGetMappedPointer` or
:cpp:func:`hipGraphicsSubResourceGetMappedArray` functions.
The graphics resources must be registered using functions like
:cpp:func:`hipGraphicsGLRegisterBuffer` or :cpp:func:`hipGraphicsGLRegisterImage`
then they can be mapped to HIP with :cpp:func:`hipGraphicsMapResources`
function.

After mapping, the :cpp:func:`hipGraphicsResourceGetMappedPointer` or
:cpp:func:`hipGraphicsSubResourceGetMappedArray` functions used to retrieve a
device pointer to the mapped resource, which can then be used in HIP kernels.

Unmapping resources with :cpp:func:`hipGraphicsUnmapResources` after
computations ensure proper resource management.
Expand All @@ -35,9 +39,9 @@ framebuffer in a cycle until the window is not closed.

.. note::

The more recent recent OpenGL functions loaded with `OpenGL loader <https://github.com/ROCm/rocm-examples/tree/develop/External/glad>`_,
as these are not loaded by default on all platforms. The use of a custom loader
shown in the following example
The more recent OpenGL functions are loaded with `OpenGL loader <https://github.com/ROCm/rocm-examples/tree/develop/External/glad>`_,
as these are not loaded by default on all platforms. The use of a custom
loader shown in the following example

.. literalinclude:: ../../tools/example_codes/opengl_interop.hip
:start-after: // [Sphinx opengl functions load start]
Expand Down

0 comments on commit 8af73cf

Please sign in to comment.