render/vulkan: Prepare VK_EXT_external_memory_host

This commit is contained in:
Kenny Levinsen 2024-06-16 12:17:41 +02:00
parent 6d197eef94
commit f6993ab0da
2 changed files with 22 additions and 0 deletions

View file

@ -54,6 +54,7 @@ struct wlr_vk_device {
PFN_vkGetSemaphoreFdKHR vkGetSemaphoreFdKHR;
PFN_vkImportSemaphoreFdKHR vkImportSemaphoreFdKHR;
PFN_vkQueueSubmit2KHR vkQueueSubmit2KHR;
PFN_vkGetMemoryHostPointerPropertiesEXT vkGetMemoryHostPointerPropertiesEXT;
} api;
uint32_t format_prop_count;
@ -61,6 +62,7 @@ struct wlr_vk_device {
struct wlr_drm_format_set dmabuf_render_formats;
struct wlr_drm_format_set dmabuf_texture_formats;
struct wlr_drm_format_set shm_texture_formats;
size_t minImportedHostPointerAlignment;
};
// Tries to find the VkPhysicalDevice for the given drm fd.

View file

@ -470,6 +470,12 @@ struct wlr_vk_device *vulkan_device_create(struct wlr_vk_instance *ini,
extensions[extensions_len++] = VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME; // or vulkan 1.2
extensions[extensions_len++] = VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME; // or vulkan 1.3
bool has_ext_external_memory_host =
check_extension(avail_ext_props, avail_extc, VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME);
if (has_ext_external_memory_host) {
extensions[extensions_len++] = VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME;
}
for (size_t i = 0; i < extensions_len; i++) {
if (!check_extension(avail_ext_props, avail_extc, extensions[i])) {
wlr_log(WLR_ERROR, "vulkan: required device extension %s not found",
@ -621,6 +627,20 @@ struct wlr_vk_device *vulkan_device_create(struct wlr_vk_instance *ini,
load_device_proc(dev, "vkImportSemaphoreFdKHR", &dev->api.vkImportSemaphoreFdKHR);
load_device_proc(dev, "vkQueueSubmit2KHR", &dev->api.vkQueueSubmit2KHR);
if (has_ext_external_memory_host) {
load_device_proc(dev, "vkGetMemoryHostPointerPropertiesEXT",
&dev->api.vkGetMemoryHostPointerPropertiesEXT);
VkPhysicalDeviceExternalMemoryHostPropertiesEXT memory_host_props = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT,
};
VkPhysicalDeviceProperties2 props = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
.pNext = &memory_host_props,
};
vkGetPhysicalDeviceProperties2(phdev, &props);
dev->minImportedHostPointerAlignment = memory_host_props.minImportedHostPointerAlignment;
}
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));