Module: Mesa
Branch: main
Commit: 73dfcbf7e8583bc916e80e35d1c904d4411f8720
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=73dfcbf7e8583bc916e80e35d1c904d4411f8720

Author: Rob Clark <[email protected]>
Date:   Thu Feb 16 11:24:00 2023 -0800

vk/runtime: Allow enumerate and try_create_for_drm to coexist

For drivers that can support both drm and non-drm kernel mode drivers it
is useful to be able to provide both entrypoints.

Signed-off-by: Rob Clark <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21394>

---

 src/freedreno/vulkan/tu_kgsl.c   | 2 +-
 src/vulkan/runtime/vk_instance.c | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/freedreno/vulkan/tu_kgsl.c b/src/freedreno/vulkan/tu_kgsl.c
index 20e9690467f..631b1006b74 100644
--- a/src/freedreno/vulkan/tu_kgsl.c
+++ b/src/freedreno/vulkan/tu_kgsl.c
@@ -239,7 +239,7 @@ tu_enumerate_devices(struct vk_instance *vk_instance)
    fd = open(path, O_RDWR | O_CLOEXEC);
    if (fd < 0) {
       if (errno == ENOENT)
-         return VK_SUCCESS;
+         return VK_ERROR_INCOMPATIBLE_DRIVER;
 
       return vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
                        "failed to open device %s", path);
diff --git a/src/vulkan/runtime/vk_instance.c b/src/vulkan/runtime/vk_instance.c
index a17a62e9f8c..3f00199c17d 100644
--- a/src/vulkan/runtime/vk_instance.c
+++ b/src/vulkan/runtime/vk_instance.c
@@ -396,8 +396,11 @@ enumerate_drm_physical_devices_locked(struct vk_instance 
*instance)
 static VkResult
 enumerate_physical_devices_locked(struct vk_instance *instance)
 {
-   if (instance->physical_devices.enumerate)
-      return instance->physical_devices.enumerate(instance);
+   if (instance->physical_devices.enumerate) {
+      VkResult result = instance->physical_devices.enumerate(instance);
+      if (result != VK_ERROR_INCOMPATIBLE_DRIVER)
+         return result;
+   }
 
    VkResult result = VK_SUCCESS;
 

Reply via email to