NVIDIA Tegra
NVIDIA DRIVE OS 5.1 Linux

Developer Guide
5.1.0.2 Release


 
Building and Running Graphics Samples
 
Building the Samples
Using NV_WINSYS when Building Graphics Samples
Running OpenGL ES 2.0 Samples
Resolution Selection
Layer Selection
Antialiasing Specification
Running Samples
Program Binary Selection
Running Vulkan Samples
The procedures in this chapter enable you to build and run the samples included in your NVIDIA® Tegra® product.
Prerequisites
You have logged into the target.
Building the Samples
The samples all come with source code and a Makefile.
To build any of the samples
1. Make a copy of the default binaries.
2. On the host PC, simply enter:
cd $SDK_TOP/drive-t186ref-linux/samples/opengles2/<sample>
make clean
make
Where <sample> is the sample name, for example gears.
3. Rerun the copytarget script, passing in the path to the targetfs to ensure that the new binary is copied over to the target:
<top>/drive-t186ref-linux/utils/scripts/copytarget <targetfs_dir>
Caution: If the copytarget script is invoked without specifying a <targetfs_dir>, the script will corrupt the host system files.
Using NV_WINSYS when Building Graphics Samples
The various NVIDIA Drive SDK’s support multiple window systems. Each platform has a default windowing system but typically supports additional window systems. Each of the graphics samples may be built for all the supported window systems for a given platform. To switch to a different windowing system than the one you default to, export NV_WINSYS with one of these values:
egldevice
wayland (For Linux only)
x11 (For Linux only)
direct-to-display (For Vulkan samples only)
screen (For QNX only)
Binaries are saved in separate subdirectories depending upon the window system with the same name, so you can maintain the output for multiple windowing systems.
To see the default and list of supported values, run make without setting NV_WINSYS. The following shows examples:
../../../make/nvdefs.mk:108: Defaulting NV_WINSYS to egldevice, other values are wayland.
If NV_WINSYS is set to a value that is not supported for your platform, you will get an error when you run make, for example:
../../../make/nvdefs.mk:123: *** Invalid NV_WINSYS value: wayland. Stop.
Use export NV_WINSYS=<value> to set the value permanently in your shell. If you want to set NV_WINSYS temporarily, use the env command:
env NV_WINSYS=<value> make
For Vulkan samples, the direct-to-display windowing system value must be used.
Running OpenGL ES 2.0 Samples
All of the graphics samples are present in:
drive-t186ref-linux/samples/opengles2
There are three 3D graphics sample applications in the PDK called ctree, bubble, gears-cube and gears, and one 2D text rendering application called drawfont. Along with these, eglstreamcube which is a cross-process eglstream application and eglcrosspart is a cross partition eglstream application. There are several utility libraries used by the graphics samples. nvgldemo is a general EGL and OpenGL ES framework to simplify common functionality such as the EGL initialization sequence for any particular windowing system, creation of an OpenGL ES context, OpenGL ES shader usage, and EGLStream setup.  All of the graphics samples use nvgldemogears-lib contains OpenGL ES rendering code common to the multiple graphics samples that show the classic 3D spinning gears. nvtexfont is a small library to draw text using OpenGL ES textures and is used by several of the graphics samples.
Applications that use the PDK can run on any connected display output device and at any resolution. The sample applications provide command line options to adjust the display settings.
Resolution Selection
Applications can set the resolution of the application's output with the following flag:
-windowsize <xres> <yres>
This is the window size of the application.
Set the screen resolution with:
-screensize <xres> <yres>
This option is used to set the screen size when there is no windowing system running, as is the case for egldevice.  When a windowing system like X11 or Weston or QNX Screen is running, the screen size has already been set and this option is ignored.
For specifying a desktop offset, use the flag:
-windowoffset <xoffset> <yoffset>
Layer Selection
Applications can select the overlay where you want to direct the sample output. Three overlays are supported so you can run up to three applications simultaneously.
-layer <depth>
Valid values are platform-dependent.
For T194, valid values are 0, 1,2 for dispno 0, 1 and 0,1 for dispno 2,3
Here, dispno is the display number which is assigned serially from 0 through 3 for the four displays on a DDPX T194 chip.
Antialiasing Specification
Multi-sample antialiasing (MSAA) can be specified with:
-msaa <numsamples>
The numsamples specified are platform-dependent.
For T194, valid values are 2, 4, or 8.
Running Samples
By default, if no command line arguments are supplied, the sample applications run at a native resolution for the connected display.
To run gears
The steps mentioned in this section are specific to the EGLDevice windowing system. Follow similar steps for the other windowing systems with the change that the compositor for the windowing system should be run before the apps can be run on top of it.
For an EGL device platform enter:
cd /home/nvidia/ drive-t186ref-linux/samples/opengles2/gears/egldevice
./gears -res <x-res> <y-res> <runtime or -1 to run forever>
 
For extensive help options for running these demo graphics applications please run help
 
./gears -h
 
To run the graphics samples on a specific windowing system, make sure that the compositor is running and chose the right graphics sample to run on top of the chosen windowing system.
 
The other supported backends are x11 for Linux and QNX screen for running these graphics samples on QNX. For screen as the backend just run screen as mentioned in the QNX screen graphic subsystem documentation and then run any of the graphics samples mentioned above.
Program Binary Selection
Applications can use this option to load the pre-compiled program binary from its current execution path. The program binaries are generated for all supported architectures when the ‘make’ command is run. These binaries are generated into separate directories, each with the supported architecture name. The correct directory name needs to be specified when running the sample app.
If the program binaries are not present, the application will create the program binary from shader source and save the created program binary in the current execution path. The application can then use these saved program binaries on the next run. The flag to control use of program binary is:
-useprogbin <boolean>
Where <boolean> is either 0 or 1.
Running Vulkan Samples
Currently, only the direct to display WSI backend is supported. To run Vulkan samples, other windowing systems must be temporarily disabled. For example, with X11 installations, this can be done using:
sudo service lightdm stop
<run sample>
sudo service lightdm start
There are two Vulkan sample applications in the SDK called vkfish and vkcube that can be found under:
/home/nvidia/drive-t186ref-linux/samples/vulkan/<sample>
Vkfish is a modified version of NVIDIA’s threaded rendering Vulkan sample found here:
http://gameworksdocs.nvidia.com/GraphicsSamples/ThreadedRenderingVulkanSample.htm
It has been modified to use the direct to display WSI platform with its UI stripped for simplification.
To run vkfish with direct to display:
1. Disable other windowing systems.
2. Run:
cd /home/nvidia/drive-t186ref-linux/samples/vulkan/vkfish/direct-to-display
./vkfish
3. Restart windowing systems, if necessary.
Vkfish currently does not support command line arguments and runs forever by default.
Vkcube is a modified version of LunarG’s Vulkan cube demo found here:
https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/tree/master/demos
It has been modified to use the direct to display WSI platform.
To run vkcube with direct to display:
1. Disable other windowing systems.
2. Run:
cd /home/nvidia/drive-t186ref-linux/samples/vulkan/vkcube/direct-to-display
./vkcube
3. Restart windowing systems, if necessary.
The sample may be run with --c <framecount> to render a certain number of frames, but will otherwise run forever.