From 54fa5ff4063e76b76c73273546189b4bef4111c7 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 6 Jul 2022 19:31:38 -0500 Subject: [PATCH] vulkan/wsi/x11: Only use MIT_SHM if the device supports EXT_external_memory_host Reviewed-by: Jesse Natalie Part-of: --- src/vulkan/wsi/wsi_common.c | 5 +++++ src/vulkan/wsi/wsi_common.h | 2 ++ src/vulkan/wsi/wsi_common_x11.c | 11 ++++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c index 11989a71ba9..e61bb9912ad 100644 --- a/src/vulkan/wsi/wsi_common.c +++ b/src/vulkan/wsi/wsi_common.c @@ -104,6 +104,11 @@ wsi_device_init(struct wsi_device *wsi, wsi->semaphore_export_handle_types |= handle_type; } + const struct vk_device_extension_table *supported_extensions = + &vk_physical_device_from_handle(pdevice)->supported_extensions; + wsi->has_import_memory_host = + supported_extensions->EXT_external_memory_host; + list_inithead(&wsi->hotplug_fences); #define WSI_GET_CB(func) \ diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h index efd3e765200..a7477cfd07c 100644 --- a/src/vulkan/wsi/wsi_common.h +++ b/src/vulkan/wsi/wsi_common.h @@ -104,6 +104,8 @@ struct wsi_device { VkExternalSemaphoreHandleTypeFlags semaphore_export_handle_types; + bool has_import_memory_host; + bool supports_modifiers; uint32_t maxImageDimension2D; uint32_t optimalBufferCopyRowPitchAlignment; diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index c7ffa5039ad..baccc8ffe78 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -196,6 +196,7 @@ wsi_x11_connection_create(struct wsi_device *wsi_dev, xcb_query_extension_reply_t *dri3_reply, *pres_reply, *randr_reply, *amd_reply, *nv_reply, *shm_reply = NULL, *xfixes_reply; + bool wants_shm = wsi_dev->sw && wsi_dev->has_import_memory_host; bool has_dri3_v1_2 = false; bool has_present_v1_2 = false; @@ -211,7 +212,7 @@ wsi_x11_connection_create(struct wsi_device *wsi_dev, randr_cookie = xcb_query_extension(conn, 5, "RANDR"); xfixes_cookie = xcb_query_extension(conn, 6, "XFIXES"); - if (wsi_dev->sw) + if (wants_shm) shm_cookie = xcb_query_extension(conn, 7, "MIT-SHM"); /* We try to be nice to users and emit a warning if they try to use a @@ -233,7 +234,7 @@ wsi_x11_connection_create(struct wsi_device *wsi_dev, amd_reply = xcb_query_extension_reply(conn, amd_cookie, NULL); nv_reply = xcb_query_extension_reply(conn, nv_cookie, NULL); xfixes_reply = xcb_query_extension_reply(conn, xfixes_cookie, NULL); - if (wsi_dev->sw) + if (wants_shm) shm_reply = xcb_query_extension_reply(conn, shm_cookie, NULL); if (!dri3_reply || !pres_reply || !xfixes_reply) { free(dri3_reply); @@ -242,7 +243,7 @@ wsi_x11_connection_create(struct wsi_device *wsi_dev, free(randr_reply); free(amd_reply); free(nv_reply); - if (wsi_dev->sw) + if (wants_shm) free(shm_reply); vk_free(&wsi_dev->instance_alloc, wsi_conn); return NULL; @@ -300,7 +301,7 @@ wsi_x11_connection_create(struct wsi_device *wsi_dev, wsi_conn->is_proprietary_x11 = true; wsi_conn->has_mit_shm = false; - if (wsi_conn->has_dri3 && wsi_conn->has_present && wsi_dev->sw) { + if (wsi_conn->has_dri3 && wsi_conn->has_present && wants_shm) { bool has_mit_shm = shm_reply->present != 0; xcb_shm_query_version_cookie_t ver_cookie; @@ -329,7 +330,7 @@ wsi_x11_connection_create(struct wsi_device *wsi_dev, free(randr_reply); free(amd_reply); free(nv_reply); - if (wsi_dev->sw) + if (wants_shm) free(shm_reply); return wsi_conn;