Vulkan SC Samples

Vulkan SC samples are included in Jetson Linux. This topic provides detailed steps to build and run these samples on the target.

Building the Samples

Prerequisites

  • The cmake with version 3.18 or later

  • The build-essential Linux package

  • NvSci headers. The headers are packaged in public_sources.tbz2 that can be downloaded from NVIDIA Developer Center.
    1. To extract them, on host run:

    tar xf public_sources.tbz2 -C ./
    cd ./Linux_for_Tegra/source
    mkdir nvsci_headers
    tar xf nvsci_headers.tbz2 -C ./nvsci_headers
    
    1. Copy all the headers files under nvsci_headers to /usr/include on target.

  • Vulkan headers. Download the Vulkan headers from NVIDIA Developer Center, and place the headers to /usr/include on the target.

Build on the Target

The sample source files are available in the /usr/src/nvidia/vulkan-sc/vulkan-sc-ecosystem/vulkan-sc-sample/ directory. The currently provided samples are:

  • vksc_01tri

  • vk_01tri

  • vksc_computeparticles

  • vk_computeparticles

  • vulkanscinfo

The samples can only be built on target. To build the samples, run the following commands:

export VKSC_SAMPLES=/usr/src/nvidia/vulkan-sc/vulkan-sc-ecosystem/vulkan-sc-sample
cd $VKSC_SAMPLES
mkdir build
cd build
cmake ../
make

After the samples have been built, the sample binaries are generated in the build/bin directory

Running Vulkan SC Samples

Running the vulkanscinfo Command

The vulkanscinfo command summarizes the core features of the Vulkan SC API and saves the output to the text/JSON/HTML file.

  • To display a list of all available options for the vulkanscinfo command, specify the –help option:

    cd $VKSC_SAMPLES/build/bin
    ./vulkanscinfo —help
    
  • To save the output to an HTML file, specify the –html option:

    cd $VKSC_SAMPLES/build/bin
    ./vulkanscinfo --html
    

    Note: By default you will not have write permission for the /usr/src folder, the output HTML could not be able to save. To fix the issue, run the following command:

    chmod u+w $VKSC_SAMPLES/build/bin
    

    or to run it under your your HOME folder:

    cd $HOME
    $VKSC_SAMPLES/build/bin/vulkanscinfo --html
    

Running the vksc_01tri Sample

To run the vksc_01tri sample, complete the following steps:

  1. Generate the pipeline cache by running the PCC tool.

    cd $VKSC_SAMPLES/build/bin/data/pipeline/vksc_01tri
    pcc -chip [gv11b|ga10b] -path ./ -out pipeline_cache.bin
    

    Note: The pipeline_cache.bin file must be placed in the ./data/pipeline/vksc_01tri directory, because the application will look for the pipeline_cache.bin file in the that directory.

  2. Save the offscreen rendering result to an image file.

    cd $VKSC_SAMPLES/build/bin
    ./vksc_01tri -o
    
  3. Display the rendering result by using OpenWFD.

    cd $VKSC_SAMPLES/build/bin
    ./vksc_01tri -w
    
  4. (optional) You can generate the JSON file by using the JSON layer library as follows:

    The pregenerated pipeline configuration JSON files are in the ./data/pipeline/vksc_01tri directory, and these files only need to be regenerated when there are the pipeline configuration or shader changes.

    cd $VKSC_SAMPLES/build/bin
    export VK_LAYER_PATH=/etc/vulkansc/icd.d
    export VK_JSON_FILE_PATH=$PWD/data/pipeline/vksc_01tri/
    ./vk_01tri
    
    The following files will be generated in VK_JSON_FILE_PATH:
    • vk_01tri_pipeline_0.json

    • vk_01tri_pipeline_0.vert.spv

    • vk_01tri_pipeline_0.frag.spv

Running the vksc_computeparticles Sample

To run the vksc_computeparticles sample, complete the following steps:

  1. Generate the pipeline cache by using the PCC tool.
    cd $VKSC_SAMPLES/build/bin/data/pipeline/computeparticles
    pcc -chip [gv11b|ga10b] -path ./ -out pipeline_cache.bin
    

    Note: The pipeline_cache.bin file must be placed in the ./data/pipeline/computeparticles directory, because the application will look for the pipeline_cache.bin file in the that directory.

  2. Save the offscreen rendering result to an image file.
    cd $VKSC_SAMPLES/build/bin
    ./vksc_computeparticles -o
    
  3. Display the rendering result by using OpenWFD.
    cd $VKSC_SAMPLES/build/bin
    ./vksc_computeparticles -w
    
  4. (optional) You can generate JSON file by using the JSON layer library as follows:

    The pregenerated pipeline configuration JSON files are in the ./data/pipeline/computeparticles directory, and these files only need to be regenerated when there are the pipeline configuration or shader changes.

    cd $VKSC_SAMPLES/build/bin
    export VK_LAYER_PATH=/etc/vulkansc/icd.d
    export VK_JSON_FILE_PATH=$PWD/data/pipeline/computeparticles/
    ./vk_computeparticles
    

    The following files are generated in VK_JSON_FILE_PATH :

    • vk_computeparticles_pipeline_0.json

    • vk_computeparticles_pipeline_1.json

    • vk_computeparticles_pipeline_0.frag.spv

    • vk_computeparticles_pipeline_0.vert.spv

    • vk_computeparticles_pipeline_1.compute.spv

    This sample uses two different pipelines, graphics pipeline and compute pipeline; therefore, two JSON files are generated