mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-24 08:02:21 +00:00
render/vulkan: make VK_KHR_external_semaphore_fd optional
We already block instead of using sync_file when the driver doesn't support import/export.
This commit is contained in:
parent
ab118042ea
commit
7ce868bcf6
@ -462,7 +462,6 @@ struct wlr_vk_device *vulkan_device_create(struct wlr_vk_instance *ini,
|
||||
const char *extensions[32] = {0};
|
||||
size_t extensions_len = 0;
|
||||
extensions[extensions_len++] = VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME;
|
||||
extensions[extensions_len++] = VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME;
|
||||
extensions[extensions_len++] = VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME; // or vulkan 1.2
|
||||
extensions[extensions_len++] = VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME;
|
||||
extensions[extensions_len++] = VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME;
|
||||
@ -497,19 +496,25 @@ struct wlr_vk_device *vulkan_device_create(struct wlr_vk_instance *ini,
|
||||
assert(graphics_found);
|
||||
}
|
||||
|
||||
const VkPhysicalDeviceExternalSemaphoreInfo ext_semaphore_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO,
|
||||
.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT,
|
||||
};
|
||||
VkExternalSemaphoreProperties ext_semaphore_props = {
|
||||
.sType = VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES,
|
||||
};
|
||||
vkGetPhysicalDeviceExternalSemaphoreProperties(phdev,
|
||||
&ext_semaphore_info, &ext_semaphore_props);
|
||||
bool exportable_semaphore = ext_semaphore_props.externalSemaphoreFeatures &
|
||||
VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT;
|
||||
bool importable_semaphore = ext_semaphore_props.externalSemaphoreFeatures &
|
||||
VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT;
|
||||
bool exportable_semaphore = false, importable_semaphore = false;
|
||||
bool has_external_semaphore_fd =
|
||||
check_extension(avail_ext_props, avail_extc, VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME);
|
||||
if (has_external_semaphore_fd) {
|
||||
const VkPhysicalDeviceExternalSemaphoreInfo ext_semaphore_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO,
|
||||
.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT,
|
||||
};
|
||||
VkExternalSemaphoreProperties ext_semaphore_props = {
|
||||
.sType = VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES,
|
||||
};
|
||||
vkGetPhysicalDeviceExternalSemaphoreProperties(phdev,
|
||||
&ext_semaphore_info, &ext_semaphore_props);
|
||||
exportable_semaphore = ext_semaphore_props.externalSemaphoreFeatures &
|
||||
VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT;
|
||||
importable_semaphore = ext_semaphore_props.externalSemaphoreFeatures &
|
||||
VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT;
|
||||
extensions[extensions_len++] = VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME;
|
||||
}
|
||||
if (!exportable_semaphore) {
|
||||
wlr_log(WLR_DEBUG, "VkSemaphore is not exportable to a sync_file");
|
||||
}
|
||||
@ -617,10 +622,13 @@ struct wlr_vk_device *vulkan_device_create(struct wlr_vk_instance *ini,
|
||||
load_device_proc(dev, "vkWaitSemaphoresKHR", &dev->api.vkWaitSemaphoresKHR);
|
||||
load_device_proc(dev, "vkGetSemaphoreCounterValueKHR",
|
||||
&dev->api.vkGetSemaphoreCounterValueKHR);
|
||||
load_device_proc(dev, "vkGetSemaphoreFdKHR", &dev->api.vkGetSemaphoreFdKHR);
|
||||
load_device_proc(dev, "vkImportSemaphoreFdKHR", &dev->api.vkImportSemaphoreFdKHR);
|
||||
load_device_proc(dev, "vkQueueSubmit2KHR", &dev->api.vkQueueSubmit2KHR);
|
||||
|
||||
if (has_external_semaphore_fd) {
|
||||
load_device_proc(dev, "vkGetSemaphoreFdKHR", &dev->api.vkGetSemaphoreFdKHR);
|
||||
load_device_proc(dev, "vkImportSemaphoreFdKHR", &dev->api.vkImportSemaphoreFdKHR);
|
||||
}
|
||||
|
||||
size_t max_fmts;
|
||||
const struct wlr_vk_format *fmts = vulkan_get_format_list(&max_fmts);
|
||||
dev->format_props = calloc(max_fmts, sizeof(*dev->format_props));
|
||||
|
Loading…
Reference in New Issue
Block a user