From 553c0a30672eb38a5bc5d58ebeb78a7a586ff0ad Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Tue, 13 Dec 2022 14:24:25 -0800 Subject: [PATCH] venus: fix VK_EXT_pci_bus_info support 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 Part-of: --- src/virtio/vulkan/vn_device.c | 5 +++++ src/virtio/vulkan/vn_physical_device.c | 17 +++++++++++++++++ src/virtio/vulkan/vn_physical_device.h | 1 + 3 files changed, 23 insertions(+) diff --git a/src/virtio/vulkan/vn_device.c b/src/virtio/vulkan/vn_device.c index 603edbf..a734edb 100644 --- a/src/virtio/vulkan/vn_device.c +++ b/src/virtio/vulkan/vn_device.c @@ -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)); diff --git a/src/virtio/vulkan/vn_physical_device.c b/src/virtio/vulkan/vn_physical_device.c index d207945..5c86d2d 100644 --- a/src/virtio/vulkan/vn_physical_device.c +++ b/src/virtio/vulkan/vn_physical_device.c @@ -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: { diff --git a/src/virtio/vulkan/vn_physical_device.h b/src/virtio/vulkan/vn_physical_device.h index ac89934..575d064 100644 --- a/src/virtio/vulkan/vn_physical_device.h +++ b/src/virtio/vulkan/vn_physical_device.h @@ -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; -- 2.7.4