Skip to content

vkGetPhysicalDeviceSurfaceSupportKHR returns VK_ERROR_EXTENSION_NOT_PRESENT instead of false #1722

Description

@rg3igalia

When working on CTS on my laptop with an AMD iGPU, I normally use a custom version of RADV that I compile for that purpose with some minimal options. In particular, this RADV version only supports Wayland. When I add its corresponding json file path to VK_ICD_FILENAMES and run vulkaninfo, the latter errors out without printing any info like this:

$ /tmp/Vulkan-Tools/build/vulkaninfo/vulkaninfo 
ERROR at /tmp/Vulkan-Tools/vulkaninfo/./vulkaninfo.h:1531:vkGetPhysicalDeviceSurfaceSupportKHR failed with ERROR_EXTENSION_NOT_PRESENT

If I build RADV with X11 support, or I remove DISPLAY from the environment, vulkaninfo works as expected.

The source of the problem is what the message describes: vkGetPhysicalDeviceSurfaceSupportKHR returns VK_ERROR_EXTENSION_NOT_PRESENT for the RADV physical device when the surface extension is an X11 one.

I can fix the issue with the following change, but I'm not sure if it's the right solution or if something else should be done. Note VK_ERROR_EXTENSION_NOT_PRESENT is not listed as one of the valid error codes for vkGetPhysicalDeviceSurfaceSupportKHR in the spec.

Edit: edited to provide a slightly better patch.

diff --git a/vulkaninfo/vulkaninfo.h b/vulkaninfo/vulkaninfo.h
index e18232be..2ead3203 100644
--- a/vulkaninfo/vulkaninfo.h
+++ b/vulkaninfo/vulkaninfo.h
@@ -1527,11 +1527,13 @@ struct AppQueueFamilyProperties {
             present_support.push_back({surface_ext.name, VK_FALSE});
             VkResult err = vkGetPhysicalDeviceSurfaceSupportKHR(physical_device, queue_index, surface_ext.surface,
                                                                 &present_support.back().second);
-            if (err) THROW_VK_ERR("vkGetPhysicalDeviceSurfaceSupportKHR", err);
-            if (present_support.back().second) {
-                can_present = true;
-            } else {
+            const bool ext_error = (err == VK_ERROR_EXTENSION_NOT_PRESENT);
+            if (err && !ext_error)
+                THROW_VK_ERR("vkGetPhysicalDeviceSurfaceSupportKHR", err);
+            if (ext_error || !present_support.back().second) {
                 can_always_present = false;
+            } else {
+                can_present = true;
             }
         }
     }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions