NVIDIA Tegra
DRIVE 5.0 Linux Open Source Software

Development Guide
5.0.10.3 Release


 
NvMediaImage to CUDA Consumer on dGPU (nvm_egldgpu)
 
Single Process
Cross Process
Command Line Options
Optional Options
Example Commands
The NvMedia dGPU sample application nvm_egldgpu demonstrates how to use NvMediaEglstream APIs to post NvMediaImage surfaces to dGPU, which can be processed by CUDA APIs running on dGPU.
nvm_egldgpu supports a single image producer and a single CUDA consumer. It can be tested with single process for producer and consumer or with two different processes. The image producer must be on Tegra and the CUDA consumer must be on iGPU or dGPU. Single process and cross process works for both combinations.
The image producer reads image data from an input file and posts it to the CUDA consumer through eglStream. In FIFO mode, if the input to the image producer and output of the CUDA consumer bit match, then the test is successful. In Mailbox mode, the number of frames acquired by the consumer depends on the speech at which the producer and consumer are running. You cannot compare input and output files directly in Mailbox mode. The image producer accepts YUV420 or RAW formats as input.
Single Process
This app can run in single process mode (i.e., both the image producer thread and CUDA consumer thread run in a single process). First, an eglStream object is created using EGLStreamCreate() API by passing the EGLDisplay handle corresponding to the iGPU. The image producer interacts with the eglStream object, and eglGetStreamFileDescriptorKHR() API is used to get a file descriptor corresponding to the eglStream object. Then eglCreateStreamFromFileDescriptorKHR() creates another eglStream object named eglStream_dGPU by passing the EGLDisplay handle corresponding to dGPU. CUDA consumer interacts with this eglStream_dGPU object.
Cross Process
nvm_egldgpu can also run in cross process mode (i.e., image producer and CUDA consumer are running in different processes). First in consumer process, an eglStream object is created using EGLStreamCreate() API by passing the EGLDisplay handle corresponding to the dGPU. CUDA consumer interacts with this eglStream object. Then eglGetStreamFileDescriptorKHR() API is used to get a file descriptor corresponding to eglStream object. This file descriptor is sent through a socket to the producer process. In the producer process, an eglStream object is created using eglCreateStreamFromFileDescriptorKHR() by passing the EGLDisplay handle corresponding to iGPU. Image producer interacts with this eglStream object.
Command Line Options
The following shows the command syntax:
./nvm_egldgpu [options]
Optional Options
The following table describes the required command line options. Only the -f and -fr options are mandatory; the rest are optional.
Option
Parameter
Description
Default
-h
N/A
Prints usage and help menu.
N/A
-v
[level]
Specifies the logging level.
0 = Errors
1 = Warnings
2 = Info
3 = Debug
If no level is provided, uses 3 (Debug). If the option is not provided, uses 0 (Errors).
Default: 0
If the option is used, but the level is not provided, the default is 3.
-f
[file name]
Specifies the input file name. The file must be in YUV420p or RAW.
N/A
-fr
[WxH]
Specifies the input file resolution. Input width and height must be specified in WxH format, where W and H are width and height of the input image, respectively.
N/A
-st
[type]
Specifies the file type: 420p/RAW. For RAW, the test app assumes 12 bits per pixel and GRBG RAW pixel order (effectively, each pixel takes 2 bytes of space out of which only 12 bits are valid).
Default type: 420p.
-bl
N/A
Specifies whether the producer uses block linear surface. Block linear is only supported for iGPU.
Default is pitch linear.
-n
frame count]
Specifies the number of frames to produce.
Default: all frames in file.
--fifo
N/A
Specifies the FIFO mode for EGL stream. If the --fifo option is not specified, then EGLStream works in Mailbox mode.
Default: Mailbox
--crossproc
[prod/con]
Specifies the cross process for the producer and consumer. Supported values are:
prod
con
Default: single process mode
-s
[file name]
Saves to file for CUDA consumer. If not specified, then CUDA consumer acquires the surface and then releases.
N/A
--dgpu
[1/0]
Specifies where the Consumer is running.
1- Consumer is running on dGPU.
0 - Consumer is on iGPU.
Default is 1.
--useblit
N/A
Uses blit path before posting the surfaces to eglstream.
N/A
Example Commands
This topic explains how to perform common tasks with nvm_egldgpu.
To test an image producer and CUDA consumer from a single process
This following tests an image producer and CUDA consumer from a single process in FIFO mode for YUV420 planar input of size 1920 x 1080. The CUDA consumer output is written to the cuda.yuv file.
Enter:
./nvm_egldgpu -f test.yuv -s cuda.yuv --fifo -fr 1920x1080
The following tests an image producer and CUDA consumer from a single process in FIFO mode for YUV420 planar input of size 1920 x 1080 on iGPU. The CUDA consumer output is written to the cuda.yuv file.
Enter:
CUDA_VISIBLE_DEVICES=1 ./nvm_egldgpu -f test.yuv -s cuda.yuv --fifo -fr 1920x1080 -dgpu 0
To test an image producer and CUDA consumer from two different processes
1. Run the consumer:
./nvm_egldgpu --crossproc con -s cuda.yuv --fifo
2. Run the producer:
./nvm_egldgpu --crossproc prod -f test1.yuv -fr 1920x1080 --fifo