Overv / VulkanTutorial

Tutorial for the Vulkan graphics and compute API
https://vulkan-tutorial.com
Creative Commons Attribution Share Alike 4.0 International
3.06k stars 511 forks source link

Cannot get surface capabilities - surface lost error #286

Closed Jacajack closed 2 years ago

Jacajack commented 2 years ago

Hi and thanks for the great tutorial!

Some time ago, I noticed that a Vulkan app I created based on this tutorial has stopped working on my laptop after some system upgrade. Back then I didn't give it much thought. I remembered about this problem today and while debugging, I decided to run the tutorial code itself. As it turns out, it suffers from the same problem.

I compiled and ran 15_hello_triangle.cpp. This is the output:

validation layer: Searching for ICD drivers named /usr/lib/libvulkan_radeon.so
validation layer: loader_scanned_icd_add: Driver /usr/lib/libvulkan_radeon.so supports Vulkan 1.2, but only supports loader interface version 4. Interface version 5 or newer required to support this version of Vulkan (Policy #LDP_DRIVER_7)
validation layer: Searching for ICD drivers named /usr/lib/amdvlk64.so
validation layer: loader_scanned_icd_add: Driver /usr/lib/amdvlk64.so says it supports interface version 6 but still exports core entrypoints (Policy #LDP_DRIVER_6)
validation layer: Searching for ICD drivers named /usr/lib32/libvulkan_intel.so
validation layer: Searching for ICD drivers named /usr/lib32/libvulkan_radeon.so
validation layer: Searching for ICD drivers named /usr/lib32/amdvlk32.so
validation layer: Searching for ICD drivers named /usr/lib/libvulkan_intel.so
validation layer: loader_scanned_icd_add: Driver /usr/lib/libvulkan_intel.so supports Vulkan 1.2, but only supports loader interface version 4. Interface version 5 or newer required to support this version of Vulkan (Policy #LDP_DRIVER_7)
validation layer: Build ICD instance extension list
validation layer: Loading layer library libVkLayer_khronos_validation.so
validation layer: Loading layer library /usr/lib/amdvlk64.so
validation layer: Build ICD instance extension list
validation layer: Build ICD instance extension list
validation layer: Build ICD instance extension list
validation layer: Loading layer library libVkLayer_khronos_validation.so
validation layer: Loading layer library /usr/lib/amdvlk64.so
validation layer: Validation Error: [ VUID-VkSwapchainCreateInfoKHR-preTransform-parameter ] Object 0: handle = 0x562d1a67f3c0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xaf5f3828 | vkCreateSwapchainKHR: value of pCreateInfo->preTransform must not be 0. The Vulkan spec states: preTransform must be a valid VkSurfaceTransformFlagBitsKHR value (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkSwapchainCreateInfoKHR-preTransform-parameter)
validation layer: Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageExtent-01689 ] Object 0: handle = 0x562d1a67f3c0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x13140d69 | vkCreateSwapchainKHR(): pCreateInfo->imageExtent = (0, 0) which is illegal. The Vulkan spec states: imageExtent members width and height must both be non-zero (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkSwapchainCreateInfoKHR-imageExtent-01689)
validation layer: Validation Error: [ VUID-VkSwapchainCreateInfoKHR-preTransform-01279 ] Object 0: handle = 0x562d1a67f3c0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x987713ee | vkCreateSwapchainKHR() called with a non-supported pCreateInfo->preTransform (i.e. Unhandled VkSurfaceTransformFlagBitsKHR).  Supported values are:
. The Vulkan spec states: preTransform must be one of the bits present in the supportedTransforms member of the VkSurfaceCapabilitiesKHR structure returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkSwapchainCreateInfoKHR-preTransform-01279)
validation layer: Validation Error: [ VUID-VkSwapchainCreateInfoKHR-compositeAlpha-01280 ] Object 0: handle = 0x562d1a67f3c0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xb0051a12 | vkCreateSwapchainKHR() called with a non-supported pCreateInfo->compositeAlpha (i.e. VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR).  Supported values are:
. The Vulkan spec states: compositeAlpha must be one of the bits present in the supportedCompositeAlpha member of the VkSurfaceCapabilitiesKHR structure returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkSwapchainCreateInfoKHR-compositeAlpha-01280)
validation layer: Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275 ] Object 0: handle = 0x562d1a67f3c0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x5de6e84e | vkCreateSwapchainKHR() called with a non-supported imageArrayLayers (i.e. 1).  Maximum value is 0. The Vulkan spec states: imageArrayLayers must be greater than 0 and less than or equal to the maxImageArrayLayers member of the VkSurfaceCapabilitiesKHR structure returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275)
validation layer: Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageUsage-01276 ] Object 0: handle = 0x562d1a67f3c0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xce75babb | vkCreateSwapchainKHR() called with a non-supported pCreateInfo->imageUsage (i.e. 0x00000010).  Supported flag bits are 0x00000000. The Vulkan spec states: imageUsage must be a subset of the supported usage flags present in the supportedUsageFlags member of the VkSurfaceCapabilitiesKHR structure returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface (https://github.com/KhronosGroup/Vulkan-Docs/search?q=)VUID-VkSwapchainCreateInfoKHR-imageUsage-01276)
validation layer: Validation Error: [ VUID-VkSwapchainCreateInfoKHR-presentMode-01281 ] Object 0: handle = 0x562d1a67f3c0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xaddd2685 | vkCreateSwapchainKHR() called with a non-supported presentMode (i.e. VK_PRESENT_MODE_FIFO_KHR). The Vulkan spec states: presentMode must be one of the VkPresentModeKHR values returned by vkGetPhysicalDeviceSurfacePresentModesKHR for the surface (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkSwapchainCreateInfoKHR-presentMode-01281)
malloc(): invalid size (unsorted)
Aborted (core dumped)

So far, I've managed to track the problem down to querySwapChainSupport(). It seems that vkGetPhysicalDeviceSurfaceCapabilitiesKHR() returns VK_ERROR_SURFACE_LOST_KHR and does not properly initialize the VkSurfaceCapabilitiesKHR struct. This causes invalid parameters to be passed to all the functions later on and eventually leads to the crash.

Given that this problem has started happening out of nowhere, it's likely that the problem isn't in the tutorial code. On the other hand, other Vulkan applications (like vkcube) still work on my system. I'm just not sure what could cause a surface loss. GLFW? Something in the window manager? My experience with Vulkan is very limited, so any guidance would be highly appreciated.

Thanks!

System info

vulkaninfo: https://gist.github.com/Jacajack/ddea3cb1a561b0df8dcb3459288c08b7

inxi -SCG:

System:
  Host: envy Kernel: 5.17.1-3-MANJARO arch: x86_64 bits: 64
    Desktop: KDE Plasma v: 5.24.4 Distro: Manjaro Linux
CPU:
  Info: quad core model: AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx
    bits: 64 type: MT MCP cache: L2: 2 MiB
  Speed (MHz): avg: 1436 min/max: 1400/2100 cores: 1: 1376 2: 1295 3: 1223
    4: 1223 5: 1225 6: 1227 7: 2057 8: 1863
Graphics:
  Device-1: AMD Picasso/Raven 2 [Radeon Vega Series / Radeon Mobile Series]
    driver: amdgpu v: kernel
  Display: x11 server: X.Org v: 1.21.1.3 driver: X: loaded: amdgpu
    unloaded: modesetting gpu: amdgpu resolution: 1920x1080~60Hz
  OpenGL: renderer: AMD Radeon Vega 8 Graphics (RAVEN DRM 3.44.0
    5.17.1-3-MANJARO LLVM 13.0.1)
    v: 4.6 Mesa 21.3.8
Jacajack commented 2 years ago

This definitely seems to be a problem with my system. Everything is working fine on the latest Manjaro LiveUSB on the same computer. I'll post an update if I ever find out what's causing this.

Jacajack commented 2 years ago

This issue has been solved by the recent 2022-05-23 Manjaro stable update. Perhaps the new mesa version?