anv: expose primary node to VK_EXT_physical_device_drm even when VK_KHR_display is...
authorElla-0 <23418164+Ella-0@users.noreply.github.com>
Sun, 27 Jun 2021 19:29:08 +0000 (19:29 +0000)
committerMarge Bot <eric+marge@anholt.net>
Mon, 28 Jun 2021 14:03:22 +0000 (14:03 +0000)
Fixes: e9e1e0362b6c2d ("anv: implement VK_EXT_physical_device_drm")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11616>

src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_private.h

index abebfea..f01f4c3 100644 (file)
@@ -991,6 +991,28 @@ anv_physical_device_try_create(struct anv_instance *instance,
 
    *device_out = device;
 
+   struct stat st;
+
+   if (stat(primary_path, &st) == 0) {
+      device->has_master = true;
+      device->master_major = major(st.st_rdev);
+      device->master_minor = minor(st.st_rdev);
+   } else {
+      device->has_master = false;
+      device->master_major = 0;
+      device->master_minor = 0;
+   }
+
+   if (stat(path, &st) == 0) {
+      device->has_local = true;
+      device->local_major = major(st.st_rdev);
+      device->local_minor = minor(st.st_rdev);
+   } else {
+      device->has_local = false;
+      device->local_major = 0;
+      device->local_minor = 0;
+   }
+
    return VK_SUCCESS;
 
 fail_engine_info:
@@ -2351,25 +2373,15 @@ void anv_GetPhysicalDeviceProperties2(
       case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT: {
          VkPhysicalDeviceDrmPropertiesEXT *props =
             (VkPhysicalDeviceDrmPropertiesEXT *)ext;
-         struct stat st;
-
-         props->hasPrimary = fstat(pdevice->master_fd, &st) == 0;
-         if (props->hasPrimary) {
-            props->primaryMajor = (int64_t) major(st.st_rdev);
-            props->primaryMinor = (int64_t) minor(st.st_rdev);
-         } else {
-            props->primaryMajor = 0;
-            props->primaryMinor = 0;
-         }
 
-         props->hasRender = fstat(pdevice->local_fd, &st) == 0;
-         if (props->hasRender) {
-            props->renderMajor = (int64_t) major(st.st_rdev);
-            props->renderMinor = (int64_t) minor(st.st_rdev);
-         } else {
-            props->renderMajor = 0;
-            props->renderMinor = 0;
-         }
+         props->hasPrimary = pdevice->has_master;
+         props->primaryMajor = pdevice->master_major;
+         props->primaryMinor = pdevice->master_minor;
+
+         props->hasRender = pdevice->has_local;
+         props->renderMajor = pdevice->local_major;
+         props->renderMinor = pdevice->local_minor;
+
          break;
       }
 
index d380d6c..0aa21b4 100644 (file)
@@ -988,7 +988,13 @@ struct anv_physical_device {
 
     struct wsi_device                       wsi_device;
     int                                         local_fd;
+    bool                                        has_local;
+    int64_t                                     local_major;
+    int64_t                                     local_minor;
     int                                         master_fd;
+    bool                                        has_master;
+    int64_t                                     master_major;
+    int64_t                                     master_minor;
     struct drm_i915_query_engine_info *         engine_info;
 
     void (*cmd_emit_timestamp)(struct anv_batch *, struct anv_bo *, uint32_t );