Correct way to do Nvidia Vulkan?

Thank you @Nightmayr for this post, I found it extremely helpful when adding Vulkan support to the OBS Studio snap; the NvFBC plugin requires Vulkan.

While the OBS Studio snap is currently amd64 only, I thought I’d tackle the multi-architecture ICD path issue you described by way of a thank you :slightly_smiling_face:

I have a wrapper for OBS as the last script in the command-chain: It looks like this:

apps:
  obs-demo:
    command: usr/bin/obs --multi
    command-chain:
      - snap/command-chain/desktop-launch
      - bin/obs-wrapper

I added the following to obs-wrapper to export architecture-specific VK_ICD_FILENAMES, like this:

# Export the Vulkan ICD filename paths
#  - There is no Intel ICD for ARM
if [ "$SNAP_ARCH" = "amd64" ]; then
  export VK_ICD_FILENAMES="/var/lib/snapd/lib/vulkan/icd.d/nvidia_icd.json:$SNAP/usr/share/vulkan/icd.d/radeon.x86_64.json:$SNAP/usr/share/vulkan/icd.d/intel_icd.x86_64.json"
elif [ "$SNAP_ARCH" = "i386" ]; then
  export VK_ICD_FILENAMES="/var/lib/snapd/lib/vulkan/icd.d/nvidia_icd.json:$SNAP/usr/share/vulkan/icd.d/radeon.i686.json:$SNAP/usr/share/vulkan/icd.d/intel_icd.i686.json"
elif [ "$SNAP_ARCH" = "armhf" ]; then
  export VK_ICD_FILENAMES="/var/lib/snapd/lib/vulkan/icd.d/nvidia_icd.json:$SNAP/usr/share/vulkan/icd.d/radeon.armv7l.json"
elif [ "$SNAP_ARCH" = "arm64" ]; then
  export VK_ICD_FILENAMES="/var/lib/snapd/lib/vulkan/icd.d/nvidia_icd.json:$SNAP/usr/share/vulkan/icd.d/radeon.aarch64.json"
fi

Here is the commit where I added Vulkan support and the NvFBC plugin to the OBS Studio snapcraft.yaml; I hope others find it useful.

6 Likes