Getting vulkan working with xcb (amd gpu)

Hi,
I just ported a working project to a newer machine using an AMD APU (Ryzen 7 3700U) from an Intel integrated one, and when I try to execute a vulkan program with validation layers enabled I get that VK_KHR_xcb_surface is not supported.

I can reproduce the same error running vkcube --validate. Here’s the output:

WARNING : VALIDATION - Message Id Number: 2044605652 | Message Id Name: VUID_Undefined
  Validation Warning: [ VUID_Undefined ] Object 0: handle = 0x800b12140, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0x79de34d4 | Instance Extension VK_KHR_xcb_surface is not supported by this layer.  Using this extension may adversely affect validation results and/or produce undefined behavior.

  Objects - 1
    Object[0] - VK_OBJECT_TYPE_INSTANCE, Handle 0x800b12140

ERROR : VALIDATION - Message Id Number: -2145442690 | Message Id Name: VUID-vkGetPhysicalDeviceSurfaceSupportKHR-surface-parameter
  Validation Error: [ VUID-vkGetPhysicalDeviceSurfaceSupportKHR-surface-parameter ] Object 0: VK_NULL_HANDLE, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0x801f247e | Invalid VkSurfaceKHR Object 0x800a57df0. The Vulkan spec states: surface must be a valid VkSurfaceKHR handle (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkGetPhysicalDeviceSurfaceSupportKHR-surface-parameter)

  Objects - 1
    Object[0] - VK_OBJECT_TYPE_INSTANCE, Handle 0x0

Assertion failed: (object_table.contains(object)), function FindObject, file /usr/ports/devel/vulkan-validation-layers/work/Vulkan-ValidationLayers-sdk-1.2.135.0/layers/generated/thread_safety.h, line 144.
Abort trap (core dumped)

xcblib is installed, and working for other programs. I tried running vulkaninfo and I got this:

error: XDG_RUNTIME_DIR not set in the environment.
==========
VULKANINFO
==========

Vulkan Instance Version: 1.2.135


Instance Extensions: count = 17
===============================
  VK_EXT_acquire_xlib_display            : extension revision 1
  VK_EXT_debug_report                    : extension revision 9
  VK_EXT_debug_utils                     : extension revision 1
  VK_EXT_direct_mode_display             : extension revision 1
  VK_EXT_display_surface_counter         : extension revision 1
  VK_KHR_device_group_creation           : extension revision 1
  VK_KHR_display                         : extension revision 23
  VK_KHR_external_fence_capabilities     : extension revision 1
  VK_KHR_external_memory_capabilities    : extension revision 1
  VK_KHR_external_semaphore_capabilities : extension revision 1
  VK_KHR_get_display_properties2         : extension revision 1
  VK_KHR_get_physical_device_properties2 : extension revision 1
  VK_KHR_get_surface_capabilities2       : extension revision 1
  VK_KHR_surface                         : extension revision 25
  VK_KHR_wayland_surface                 : extension revision 6
  VK_KHR_xcb_surface                     : extension revision 6
  VK_KHR_xlib_surface                    : extension revision 6
Layers: count = 1
=================
VK_LAYER_KHRONOS_validation (Khronos Validation Layer) Vulkan version 1.2.135, layer version 1:
  Layer Extensions: count = 3
    VK_EXT_debug_report        : extension revision 9
    VK_EXT_debug_utils         : extension revision 1
    VK_EXT_validation_features : extension revision 2
  Devices: count = 1
    GPU id = 0 (AMD RADV RAVEN (LLVM 8.0.1))
    Layer-Device Extensions: count = 3
      VK_EXT_debug_marker     : extension revision 4
      VK_EXT_tooling_info     : extension revision 1
      VK_EXT_validation_cache : extension revision 1

A full vulkaninfo pastebin can be found here : https:// bsd. to/m5JH (remove spaces, the forum doesn’t let me add links, no idea why).

[FIXED] I’ve notice an error at the beginning claiming XDG_RUNTIME_DIR is not set. This has been fixed adding that env. var.

The system has the following packages installed:

vulkan-headers-1.2.135.0       Headers for the Vulkan graphics API
vulkan-loader-1.2.135.0        Driver loader for the Vulkan graphics API
vulkan-tools-1.2.135.0         Tools and demos for the Vulkan graphics API
vulkan-validation-layers-1.2.135.0 Validation layers for the Vulkan graphics API

xf86-video-amdgpu-19.1.0_1     X.Org amdgpu display driver

mesa-demos-8.4.0_2             OpenGL demos distributed with Mesa
mesa-dri-19.0.8                OpenGL hardware acceleration drivers for DRI2+
mesa-libs-19.0.8               OpenGL libraries that support GLX and EGL clients

xorg-minimal-7.5.2_3           X.Org minimal distribution metaport
xorg-server-1.20.8_1,1         X.Org X server and related programs
xorgproto-2020.1               xorg protocol headers

libxcb-1.13.1                  The X protocol C-language Binding (XCB) library
xcb-util-0.4.0_2,1             Module with libxcb/libX11 extension/replacement libraries

What can be causing vulkan not to run?

Thanks in advance

Where did you get the SDK from?

I got it from the FreeBSD ports collection.

The error XDG_RUNTIME_DIR is not set has been fixed creating that environment variable.
vulkaninfo no longer shows the error but vkcube --validate stills crashing with the same message from the main post.

Seems like the layers were built without XCB support by the port maintainer?

It was indeed. Someone reported a bug recently to the port and there’s a temporary patch here. Anyway thanks for helping (: