The 2D stream API offers a stream-like interface for handling synchronization with NvMedia 2D. The user can push fences to be waited on and tasks to be executed to the stream, and request a fence to be signaled at any point of the stream. The stream will wait on the fences and execute the tasks in the order they are pushed. The fences requested will be signaled when all of the preceding fence waits and tasks have completed. The benefit of using the 2D Stream API is that it decouples the synchronization from processing of individual tasks, allowing for more flexible usage.
Typedefs | |
| typedef struct NvMedia2DStream | NvMedia2DStream |
| An object representing a stream. More... | |
Functions | |
| NvMediaStatus | NvMedia2DStreamCreate (NvMedia2DStream **const stream, NvMedia2D *const ctx, NvSciSyncObj const syncObj) |
| Create a new stream. More... | |
| NvMediaStatus | NvMedia2DStreamDestroy (NvMedia2DStream *const stream) |
| Destroy a stream. More... | |
| NvMediaStatus | NvMedia2DStreamPushFenceWait (NvMedia2DStream *const stream, NvSciSyncFence const *const syncFence) |
| Push a fence wait to the stream. More... | |
| NvMediaStatus | NvMedia2DStreamPushTask (NvMedia2DStream *const stream, NvMedia2DComposeParameters const taskParams, NvMedia2DComposeResult *const taskResult) |
| Push a task to the stream. More... | |
| NvMediaStatus | NvMedia2DStreamRequestFence (NvMedia2DStream *const stream, NvSciSyncFence *const syncFence) |
| Request a fence from the stream. More... | |
| typedef struct NvMedia2DStream NvMedia2DStream |
An object representing a stream.
Usage considerations
Definition at line 49 of file nvmedia_2d_stream.h.
| NvMediaStatus NvMedia2DStreamCreate | ( | NvMedia2DStream **const | stream, |
| NvMedia2D *const | ctx, | ||
| NvSciSyncObj const | syncObj | ||
| ) |
Create a new stream.
| [out] | stream | The stream. |
| [in] | ctx | The NvMedia2D context to use for the stream. The tasks pushed to the stream will be executed using this context. The caller must ensure the context lifetime extends beyond the lifetime of the stream. |
| [in] | syncObj | The sync object to associate with the stream. The fences returned by NvMedia2DStreamRequestFence() will be associated with this sync object. This function registers the sync object with the NvMedia2D context as NVMEDIA_EOF_PRESYNCOBJ. |
| NVMEDIA_STATUS_OK | Stream created successfully. |
| NVMEDIA_STATUS_BAD_PARAMETER | stream or ctx is NULL, or there was an error registering syncObj. |
| NVMEDIA_STATUS_INSUFFICIENT_BUFFERING | Maximum number of registered objects has been reached in the NvMedia2D context. |
| NVMEDIA_STATUS_INVALID_STATE | The function was called in incorrect system state. |
| NVMEDIA_STATUS_OUT_OF_MEMORY | Memory allocation failed. |
| NVMEDIA_STATUS_ERROR | An internal failure occurred when trying to create the stream. |
Usage considerations
| NvMediaStatus NvMedia2DStreamDestroy | ( | NvMedia2DStream *const | stream | ) |
Destroy a stream.
Unregisters the associated sync object and clears any fences pushed to the stream but not consumed yet.
| [in] | stream | The stream. |
| NVMEDIA_STATUS_OK | Stream destroyed successfully. |
| NVMEDIA_STATUS_BAD_PARAMETER | stream is NULL. |
| NVMEDIA_STATUS_INVALID_STATE | The function was called in incorrect system state. |
| NVMEDIA_STATUS_PENDING | Tasks pushed to the stream are still pending. |
| NVMEDIA_STATUS_ERROR | An internal failure occurred when trying to destroy the stream. |
Usage considerations
| NvMediaStatus NvMedia2DStreamPushFenceWait | ( | NvMedia2DStream *const | stream, |
| NvSciSyncFence const *const | syncFence | ||
| ) |
Push a fence wait to the stream.
After a call to this function:
Pushing a cleared fence to the stream is a valid no-op.
Maximum number of (non-cleared) fence waits that can be pushed to the stream without pushing a task or requesting a fence in between is 15.
| [in] | stream | The stream. |
| [in] | syncFence | The fence to wait on. |
| NVMEDIA_STATUS_OK | Fence wait pushed successfully. |
| NVMEDIA_STATUS_BAD_PARAMETER | stream is NULL, or syncFence is NULL or not valid. |
| NVMEDIA_STATUS_INSUFFICIENT_BUFFERING | Maximum number of fence waits has been reached. |
| NVMEDIA_STATUS_ERROR | An internal failure occurred when trying to push the fence wait. |
Usage considerations
| NvMediaStatus NvMedia2DStreamPushTask | ( | NvMedia2DStream *const | stream, |
| NvMedia2DComposeParameters const | taskParams, | ||
| NvMedia2DComposeResult *const | taskResult | ||
| ) |
Push a task to the stream.
The task will be executed after any fence waits and tasks pushed to the stream previously have completed.
| [in] | stream | The stream. |
| [in] | taskParams | The task parameters. Must not have any pre-fences set with NvMedia2DInsertPreNvSciSyncFence() or EOF sync object set with NvMedia2DSetNvSciSyncObjforEOF(). This function consumes the task parameters, so the caller must not use the parameters after this function returns. |
| [out] | taskResult | The task result. Optional, can be NULL. |
| NVMEDIA_STATUS_OK | Task pushed successfully. |
| NVMEDIA_STATUS_BAD_PARAMETER | stream is NULL, or taskParams is invalid. |
| NVMEDIA_STATUS_INSUFFICIENT_BUFFERING | Failed to add fence waits for the task. |
| NVMEDIA_STATUS_NOT_SUPPORTED | Requested task is not supported on this platform. |
| NVMEDIA_STATUS_TIMED_OUT | Too many tasks are already pending for the NvMedia2D context associated with the stream. |
| NVMEDIA_STATUS_ERROR | An internal failure occurred when trying to push the task. |
Usage considerations
| NvMediaStatus NvMedia2DStreamRequestFence | ( | NvMedia2DStream *const | stream, |
| NvSciSyncFence *const | syncFence | ||
| ) |
Request a fence from the stream.
The fence will be signaled after any fence waits and tasks pushed to the stream previously have completed.
| [in] | stream | The stream. |
| [out] | syncFence | The fence to be signaled. Cleared by this function before being populated with the new fence value. |
| NVMEDIA_STATUS_OK | Fence requested successfully. |
| NVMEDIA_STATUS_BAD_PARAMETER | stream or syncFence is NULL. |
| NVMEDIA_STATUS_INSUFFICIENT_BUFFERING | No free compose parameters instance is available in the NvMedia2D context associated with the stream. |
| NVMEDIA_STATUS_TIMED_OUT | Too many tasks are already pending for the NvMedia2D context associated with the stream. |
| NVMEDIA_STATUS_ERROR | An internal failure occurred when trying to request the fence. |
Usage considerations