venus: fix VK_EXT_pci_bus_info support
authorYiwei Zhang <zzyiwei@chromium.org>
Tue, 13 Dec 2022 22:24:25 +0000 (14:24 -0800)
committerYiwei Zhang <zzyiwei@chromium.org>
Sun, 18 Dec 2022 05:34:47 +0000 (21:34 -0800)
Natively support it for virtgpu while passthrough renderer support for
vtest. This is a must support to avoid prime blit in common wsi.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20310>

src/virtio/vulkan/vn_device.c
src/virtio/vulkan/vn_physical_device.c
src/virtio/vulkan/vn_physical_device.h

index 603edbf9a594b0c7c0ac2cb044da358167ce1d22..a734edb64c04f8930812c87eea9c1eeafe60a231 100644 (file)
@@ -314,6 +314,11 @@ vn_device_fix_create_info(const struct vn_device *dev,
       block_exts[block_count++] = VK_EXT_TOOLING_INFO_EXTENSION_NAME;
    }
 
+   if (app_exts->EXT_pci_bus_info) {
+      /* always filter for simplicity */
+      block_exts[block_count++] = VK_EXT_PCI_BUS_INFO_EXTENSION_NAME;
+   }
+
    assert(extra_count <= ARRAY_SIZE(extra_exts));
    assert(block_count <= ARRAY_SIZE(block_exts));
 
index d20794500440dcbe7cb140f836e5bb29eaa218ff..5c86d2d3b51bee6a461332f2d9d954675a1c522b 100644 (file)
@@ -520,6 +520,7 @@ vn_physical_device_init_properties(struct vn_physical_device *physical_dev)
    VN_ADD_PNEXT_EXT(props2, CUSTOM_BORDER_COLOR_PROPERTIES_EXT, props->custom_border_color, exts->EXT_custom_border_color);
    VN_ADD_PNEXT_EXT(props2, LINE_RASTERIZATION_PROPERTIES_EXT, props->line_rasterization, exts->EXT_line_rasterization);
    VN_ADD_PNEXT_EXT(props2, MULTI_DRAW_PROPERTIES_EXT, props->multi_draw, exts->EXT_multi_draw);
+   VN_ADD_PNEXT_EXT(props2, PCI_BUS_INFO_PROPERTIES_EXT, props->pci_bus_info, exts->EXT_pci_bus_info);
    VN_ADD_PNEXT_EXT(props2, PROVOKING_VERTEX_PROPERTIES_EXT, props->provoking_vertex, exts->EXT_provoking_vertex);
    VN_ADD_PNEXT_EXT(props2, ROBUSTNESS_2_PROPERTIES_EXT, props->robustness_2, exts->EXT_robustness2);
    VN_ADD_PNEXT_EXT(props2, TRANSFORM_FEEDBACK_PROPERTIES_EXT, props->transform_feedback, exts->EXT_transform_feedback);
@@ -982,6 +983,16 @@ vn_physical_device_get_native_extensions(
       exts->KHR_swapchain = true;
       exts->KHR_swapchain_mutable_format = true;
    }
+
+   /* VK_EXT_pci_bus_info is required by common wsi to decide whether native
+    * image or prime blit is used. Meanwhile, venus must stay on native image
+    * path for proper fencing.
+    * - For virtgpu, VK_EXT_pci_bus_info is natively supported.
+    * - For vtest, pci bus info must be queried from the renderer side physical
+    *   device to be compared against the render node opened by common wsi.
+    */
+   exts->EXT_pci_bus_info =
+      !VN_DEBUG(VTEST) || renderer_exts->EXT_pci_bus_info;
 #endif
 
    exts->EXT_physical_device_drm = true;
@@ -1810,6 +1821,8 @@ vn_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
       case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT:
          /* this is used by WSI */
          if (physical_dev->instance->renderer->info.pci.has_bus_info) {
+            assert(!VN_DEBUG(VTEST));
+
             VkPhysicalDevicePCIBusInfoPropertiesEXT *out_props = (void *)out;
             const struct vn_renderer_info *info =
                &physical_dev->instance->renderer->info;
@@ -1818,6 +1831,10 @@ vn_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
             out_props->pciBus = info->pci.bus;
             out_props->pciDevice = info->pci.device;
             out_props->pciFunction = info->pci.function;
+         } else {
+            vk_copy_struct_guts(out,
+                                (VkBaseInStructure *)&in_props->pci_bus_info,
+                                sizeof(in_props->pci_bus_info));
          }
          break;
       case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID: {
index ac8993496fb0e539f8bed08aaed884a1b4dc5de1..575d064fc417fc1e44895a94714a9c56b8f9acd6 100644 (file)
@@ -67,6 +67,7 @@ struct vn_physical_device_properties {
    VkPhysicalDeviceCustomBorderColorPropertiesEXT custom_border_color;
    VkPhysicalDeviceLineRasterizationPropertiesEXT line_rasterization;
    VkPhysicalDeviceMultiDrawPropertiesEXT multi_draw;
+   VkPhysicalDevicePCIBusInfoPropertiesEXT pci_bus_info;
    VkPhysicalDeviceProvokingVertexPropertiesEXT provoking_vertex;
    VkPhysicalDeviceRobustness2PropertiesEXT robustness_2;
    VkPhysicalDeviceTransformFeedbackPropertiesEXT transform_feedback;