Merge changes I18b3ae13,I6a8c1c3b into main am: 1533938aa6
Original change: https://android-review.googlesource.com/c/platform/hardware/google/gfxstream/+/3530977
Change-Id: I9ae49215f0517a59d4e5ab21966e3ad19d4ede33
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
GitOrigin-RevId: 4b5588ea398a0ceb8c95291b3e3a5a95fae39fe0
diff --git a/host/vulkan/VkDecoderGlobalState.cpp b/host/vulkan/VkDecoderGlobalState.cpp
index 564b848..1305cbb 100644
--- a/host/vulkan/VkDecoderGlobalState.cpp
+++ b/host/vulkan/VkDecoderGlobalState.cpp
@@ -8053,100 +8053,63 @@
return res;
}
- if (hasDeviceExtension(properties, VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME)) {
- res.push_back(VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
- }
-
- if (hasDeviceExtension(properties, VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME)) {
- res.push_back(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME);
- }
-
- if (hasDeviceExtension(properties, VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME)) {
- res.push_back(VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME);
- }
-
- if (hasDeviceExtension(properties, VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME)) {
- res.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME);
- }
-
- if (hasDeviceExtension(properties, VK_KHR_SWAPCHAIN_EXTENSION_NAME)) {
- res.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
- }
-
-#ifdef _WIN32
- if (hasDeviceExtension(properties, VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME)) {
- res.push_back(VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME);
- }
-
- if (hasDeviceExtension(properties, VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME)) {
- res.push_back(VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME);
- }
-#elif defined(__QNX__)
- // Note: VK_QNX_external_memory_screen_buffer is not supported in API translation,
- // decoding, etc. However, push name to indicate external memory support to guest
- if (hasDeviceExtension(properties, VK_QNX_EXTERNAL_MEMORY_SCREEN_BUFFER_EXTENSION_NAME)) {
- res.push_back(VK_QNX_EXTERNAL_MEMORY_SCREEN_BUFFER_EXTENSION_NAME);
- // EXT_queue_family_foreign is a pre-requisite for QNX_external_memory_screen_buffer
- if (hasDeviceExtension(properties, VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME)) {
- res.push_back(VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME);
- }
- }
-
- if (hasDeviceExtension(properties, VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME)) {
- res.push_back(VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME);
- }
-#elif __unix__
- if (hasDeviceExtension(properties, VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME)) {
- res.push_back(VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
- }
-
- if (hasDeviceExtension(properties, VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME)) {
- res.push_back(VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME);
- }
-#elif defined(__APPLE__)
- if (m_vkEmulation->supportsMoltenVk()) {
- if (hasDeviceExtension(properties, VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME)) {
- res.push_back(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME);
- }
- if (hasDeviceExtension(properties, VK_EXT_METAL_OBJECTS_EXTENSION_NAME)) {
- res.push_back(VK_EXT_METAL_OBJECTS_EXTENSION_NAME);
- }
- if (hasDeviceExtension(properties, VK_EXT_EXTERNAL_MEMORY_METAL_EXTENSION_NAME)) {
- res.push_back(VK_EXT_EXTERNAL_MEMORY_METAL_EXTENSION_NAME);
- }
- } else {
- // Non-MoltenVK path, use memory_fd
- if (hasDeviceExtension(properties, VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME)) {
- res.push_back(VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
- }
- }
-#endif
-
-#ifdef __linux__
- // A dma-buf is a Linux kernel construct, commonly used with open-source DRM drivers.
- // See https://docs.kernel.org/driver-api/dma-buf.html for details.
- if (m_vkEmulation->supportsDmaBuf() &&
- hasDeviceExtension(properties, VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME)) {
- res.push_back(VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME);
- }
-
- if (hasDeviceExtension(properties, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME)) {
- // Mesa Vulkan Wayland WSI needs vkGetImageDrmFormatModifierPropertiesEXT. On some Intel
- // GPUs, this extension is exposed by the driver only if
- // VK_EXT_image_drm_format_modifier extension is requested via
- // VkDeviceCreateInfo::ppEnabledExtensionNames. vkcube-wayland does not request it,
- // which makes the host attempt to call a null function pointer unless we force-enable
- // it regardless of the client's wishes.
- res.push_back(VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME);
- }
-
-#endif
-
- if (hasDeviceExtension(properties, VK_EXT_PRIVATE_DATA_EXTENSION_NAME)) {
- //TODO(b/378686769): Enable private data extension where available to
+ std::vector<const char*> hostAlwaysDeviceExtensions = {
+ VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME,
+ VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME,
+ VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME,
+ VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME,
+ VK_KHR_SWAPCHAIN_EXTENSION_NAME,
+ // TODO(b/378686769): Enable private data extension where available to
// mitigate the issues with duplicated vulkan handles. This should be
// removed once the issue is properly resolved.
- res.push_back(VK_EXT_PRIVATE_DATA_EXTENSION_NAME);
+ VK_EXT_PRIVATE_DATA_EXTENSION_NAME,
+ // It is not uncommon for a guest app flow to expect to use
+ // VK_EXT_IMAGE_DRM_FORMAT_MODIFIER without actually enabling it in the
+ // ppEnabledExtensionNames. Mesa WSI (in Linux) does this, because it has certain
+ // assumptions about the Vulkan loader architecture it is using. However, depending on
+ // the host's Vulkan loader architecture, this could in NULL function pointer access
+ // (i.e. on vkGetImageDrmFormatModifierPropertiesEXT()). So just enable it if it's
+ // available.
+ VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME,
+#ifdef _WIN32
+ VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME,
+ VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME,
+#elif defined(__QNX__)
+ VK_QNX_EXTERNAL_MEMORY_SCREEN_BUFFER_EXTENSION_NAME,
+ // EXT_queue_family_foreign is an extension dependency of
+ // VK_QNX_external_memory_screen_buffer
+ VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME,
+ VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME,
+#elif __unix__
+ VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME,
+ VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME,
+#endif
+ };
+
+#if defined(__APPLE__)
+ if (m_vkEmulation->supportsMoltenVk()) {
+ hostAlwaysDeviceExtensions.push_back(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME);
+ hostAlwaysDeviceExtensions.push_back(VK_EXT_METAL_OBJECTS_EXTENSION_NAME);
+ hostAlwaysDeviceExtensions.push_back(VK_EXT_EXTERNAL_MEMORY_METAL_EXTENSION_NAME);
+ } else {
+ // Non-MoltenVK path, use memory_fd
+ hostAlwaysDeviceExtensions.push_back(VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
+ }
+#endif
+
+#if defined(__linux__)
+ // A dma-buf is a Linux kernel construct, commonly used with open-source DRM drivers.
+ // See https://docs.kernel.org/driver-api/dma-buf.html for details.
+ if (m_vkEmulation->supportsDmaBuf()) {
+ hostAlwaysDeviceExtensions.push_back(VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME);
+ }
+#endif
+
+ // Enable all the device extensions that should always be enabled on the host (if available)
+ for (auto extName : hostAlwaysDeviceExtensions) {
+ if (hasDeviceExtension(properties, extName)) {
+ res.push_back(extName);
+ }
}
return res;