Validation Layer

To avoid generating faults, each application must comply with all must statements in the Vulkan SC Specification intended for users of the Vulkan SC API. This includes but is not limited to statements concerning:

  • Object lifetime
  • Threading behavior
  • Externally synchronized parameters
  • Host synchronization
  • Valid usage

To accomplish this compliance, developers should test their applications of Vulkan SC during development using the Khronos Vulkan validation layer for Vulkan SC, which NVIDIA has approved for use with this product. The name of the layer is VK_LAYER_KHRONOS_validation. This practice ensures that all API parameters follow the valid usage statements in the Vulkan SC Specification, and do not generate validation errors.

As rationale, the NVIDIA Vulkan SC library does not check all valid usage statements during operation. This is for reasons of run-time efficiency and to reduce code complexity. The VK_LAYER_KHRONOS_validation layer, when installed and enabled, logs violations of these valid usage statements via VK_EXT_debug_utils extension message callback. Developers should correct their API usage during development to prevent messages of error and warning severity. The Vulkan SC Specification at Fault and Error Handling also recommends use of validation layers during application development.

In an NVIDIA DRIVE? OS SDK installation, vksc-ecosystem packages distribute the Khronos Vulkan validation layer for use with Vulkan SC. The Platforms DRIVE? OS QNX Standard and DRIVE? OS Linux Standard support the validation layer. The vksc-ecosystem package is named with pattern nv-driveos-<PLATFORM>-vksc-ecosystem-<VERSION>.deb, where <PLATFORM> is either qnx or linux and <VERSION> is a version identifier for the SDK. The validation layer is provided as a source archive and also as a pre-built binary for aarch64 ISA. The vksc-ecosystem packages also distribute the loader library with file name libvulkansc.so and its source archive. The validation layer is deployed as a library with file name libVkSCLayer_khronos_validation.so. With the vksc-ecosystem package, the validation layer is installed on the target filesystem under /usr/lib/ on Linux and its JSON manifest is installed to /etc/vulkansc/icd.d/VkSCLayer_khronos_validation.json. There is source archive and documentation at <NV_WORKSPACE>/drive-<PLATFORM>/vulkansc/ecosystem/vulkan-sc-layers/validation_layers/, where <NV_WORKSPACE> is local path to the DRIVE OS SDK installation, and <PLATFORM> is qnx or linux.

CAUTION: The loader library and validation library are for use as development tools and are not qualified for use in a vehicle as part of the NVIDIA DRIVE? OS QNX Safety platform.

The Khronos Vulkan SC Specification documents thread-safety constraints for each command in host synchronization blocks, which list externally synchronized parameters. For a simple use case, if the application calls commands on one VkDevice from one single thread, the Khronos Vulkan SC Specification requires no further external synchronization.

If the applications use Vulkan SC concurrently in multiple threads with shared Vulkan SC objects, inspect use of the Vulkan SC API against the constraints in host synchronization blocks and threading behavior of the Khronos Vulkan SC Specification while designing graphics application concurrency and multi-threading. The Vulkan SC validation layers support thread-safety validation. If your applications do not synchronize their multiple threads' access to these externally synchronized parameters, this layer may detect and report threading errors during development. The thread-safety validation layer is not guaranteed to detect all errors with thread-safe usage of the API, and loading and activating this layer may affect the timing of sensitive race condition bugs. Do not depend solely on the thread safety validation layer to ensure concurrency restrictions are met.

An additional recommendation is the destruction of the VkDevice. Before tearing down the VkDevice completely with vkDestroyDevice(), the recommendation is for the application to ensure each associated VkQueue is idle. This prevents a hypothetical use-after-free by a still-running VkQueue. The easiest way to accomplish this idle is to call vkDeviceWaitIdle(). Valid usage statements stipulate that VkDevices cannot be destroyed until all Vulkan SC objects associated with them are freed or destroyed, and most Vulkan SC objects cannot be freed or destroyed unless the GPU is not using them. Extending this from most to all Vulkan SC objects for vkDestroyDevice() is the delta of this recommendation.