News & Insights > Case Studies

Vulkan GPU-Assisted Validation

Challenge

Several Vulkan game developers and hardware vendors on the Khronos Vulkan Advisory Panel needed a solution for code that could detect invalid shader computations on the GPU.

Solution

LunarG created a mechanism to detect invalid shader computations and pass an alert and sufficient information from the GPU to the validation mechanism on the CPU — to allow the game developer to address the problem, for example an out-of-bounds index into a descriptor array as part of Vulkan’s bindless descriptor capability.

LunarG developed a new pass in the spirv-opt SPIR-V translation tool, as well as a new validation check in the Vulkan Validation Layers, for each invalid condition that a user might want to detect.

The overall project required solutions in two separate repositories: SPIRV-tools and the Vulkan Validation Layers. LunarG used a known good mechanism in the Validation Layers repository to ensure the right version of SPIRV-tools would be used.

How the Solution Works

  • The new spirv-opt pass instruments a shader, adding code to check for the invalid computation of interest and writing a record to a special debug output stream buffer if detected. Any additional information that may be required for the check but isn’t available in the shader is passed in a special debug input buffer written by the validation mechanism on the CPU.
  • The new Vulkan Validation Layer code calls spirv-opt to instrument all shaders for the invalid condition of interest, writes the special debug input buffer (if needed), checks the special debug output buffer after each draw to see if any records have been written, and handles the records if written — passing the information back to the developer.
  • All of this new code is written in C++ and uses CMake to configure and build the code.

Outcome & Benefits

The solution now enables Vulkan game developers and hardware vendors to find and correct invalid shader computations on the GPU that previously could not be detected, such as out-of-bounds indices into descriptor arrays.

  • Need Help with
    3D Graphics Software?

    Let’s talk about your project and how our industry leading team of 3D software engineers can help you build something amazing.