From b282e49d673e87fe66ac3c3d51a71d50a128f570 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Fri, 21 Feb 2025 22:20:06 -0800 Subject: [PATCH] venus: update second queue emulation for 1.4 requirement Venus picks the option to always advertise an additional queue that supports transfer. Signed-off-by: Yiwei Zhang Part-of: --- src/virtio/vulkan/vn_common.c | 2 +- src/virtio/vulkan/vn_common.h | 2 +- src/virtio/vulkan/vn_physical_device.c | 27 ++++++++++++++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/virtio/vulkan/vn_common.c b/src/virtio/vulkan/vn_common.c index ad73b8f4e3f..fd5d9ece807 100644 --- a/src/virtio/vulkan/vn_common.c +++ b/src/virtio/vulkan/vn_common.c @@ -32,7 +32,7 @@ static const struct debug_control vn_debug_options[] = { { "cache", VN_DEBUG_CACHE }, { "no_sparse", VN_DEBUG_NO_SPARSE }, { "no_gpl", VN_DEBUG_NO_GPL }, - { "second_queue", VN_DEBUG_SECOND_QUEUE }, + { "no_second_queue", VN_DEBUG_NO_SECOND_QUEUE }, { NULL, 0 }, /* clang-format on */ }; diff --git a/src/virtio/vulkan/vn_common.h b/src/virtio/vulkan/vn_common.h index 1c75d8ec3e4..4992008b20a 100644 --- a/src/virtio/vulkan/vn_common.h +++ b/src/virtio/vulkan/vn_common.h @@ -112,7 +112,7 @@ enum vn_debug { VN_DEBUG_CACHE = 1ull << 6, VN_DEBUG_NO_SPARSE = 1ull << 7, VN_DEBUG_NO_GPL = 1ull << 8, - VN_DEBUG_SECOND_QUEUE = 1ull << 9, + VN_DEBUG_NO_SECOND_QUEUE = 1ull << 9, }; enum vn_perf { diff --git a/src/virtio/vulkan/vn_physical_device.c b/src/virtio/vulkan/vn_physical_device.c index 7936c722eed..d760dfc34fd 100644 --- a/src/virtio/vulkan/vn_physical_device.c +++ b/src/virtio/vulkan/vn_physical_device.c @@ -728,12 +728,24 @@ vn_physical_device_init_queue_family_properties( */ static const bool require_second_queue = true; #else - const bool require_second_queue = VN_DEBUG(SECOND_QUEUE); + /* Per 1.4 spec of VK_EXT_host_image_copy promotion: + * + * A Vulkan 1.4 implementation that has a VK_QUEUE_GRAPHICS_BIT queue must + * support either: + * - the hostImageCopy feature; or + * - an additional queue that supports VK_QUEUE_TRANSFER_BIT. + * + * Additionally, all queues supporting VK_QUEUE_GRAPHICS_BIT or + * VK_QUEUE_COMPUTE_BIT must also advertise VK_QUEUE_TRANSFER_BIT. + */ + const bool require_second_queue = + physical_dev->base.base.properties.apiVersion >= VK_API_VERSION_1_4 && + !physical_dev->base.base.supported_extensions.EXT_host_image_copy; #endif physical_dev->emulate_second_queue = -1; for (uint32_t i = 0; i < count; i++) { if (props[i].queueFamilyProperties.queueFlags & VK_QUEUE_GRAPHICS_BIT) { - if (require_second_queue && + if (require_second_queue && !VN_DEBUG(NO_SECOND_QUEUE) && props[i].queueFamilyProperties.queueCount < 2) { props[i].queueFamilyProperties.queueCount = 2; physical_dev->emulate_second_queue = i; @@ -1135,6 +1147,17 @@ vn_physical_device_get_passthrough_extensions( .KHR_shader_float_controls2 = true, .KHR_shader_subgroup_rotate = true, .KHR_vertex_attribute_divisor = true, + /* The implementation would be inefficient via venus due to too many + * memcpy and roundtrips. Venus favors device side copy and blit so that + * they can be batched for optimal performance. Meanwhile, supporting + * this extension requires new venus protocol level support to handle + * implicitly sized host pointers as well as filling returned blob + * inside "in" structs. e.g. info structs are usually "in" structs while + * properties structs are usually "out" structs. So venus won't + * implement host copy but will always emulate an additional queue that + * supports VK_QUEUE_TRANSFER_BIT to satisfy Vulkan 1.4 requirements. + */ + .EXT_host_image_copy = false, .EXT_pipeline_protected_access = true, .EXT_pipeline_robustness = true,