diff options
author | Simon Ser <contact@emersion.fr> | 2022-09-07 14:41:40 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-09-07 14:41:40 +0200 |
commit | ed018a3ee21b82e8bc3fac7ed60c1c1ee65f5fcd (patch) | |
tree | 036f4b7c7eea25099e91d6a951cc72c70976e294 /render/vulkan/vulkan.c | |
parent | e19007dede4b030b7fd60802d0cb88685a6e200c (diff) |
render/vulkan: drop wlr_vk_device.extensions
We don't need to store the list of enabled extensions.
While at it, rename variables to be less confusing.
Diffstat (limited to 'render/vulkan/vulkan.c')
-rw-r--r-- | render/vulkan/vulkan.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/render/vulkan/vulkan.c b/render/vulkan/vulkan.c index 6ae3c6b9..d5ff5feb 100644 --- a/render/vulkan/vulkan.c +++ b/render/vulkan/vulkan.c @@ -426,35 +426,27 @@ struct wlr_vk_device *vulkan_device_create(struct wlr_vk_instance *ini, dev->phdev = phdev; dev->instance = ini; dev->drm_fd = -1; - dev->extensions = calloc(16, sizeof(*ini->extensions)); - if (!dev->extensions) { - wlr_log_errno(WLR_ERROR, "allocation failed"); - goto error; - } // For dmabuf import we require at least the external_memory_fd, // external_memory_dma_buf, queue_family_foreign and // image_drm_format_modifier extensions. - const char *names[] = { + const char *extensions[] = { VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME, VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME, // or vulkan 1.2 VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME, VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME, }; + size_t extensions_len = sizeof(extensions) / sizeof(extensions[0]); - unsigned nc = sizeof(names) / sizeof(names[0]); - const char *not_found = find_extensions(avail_ext_props, avail_extc, names, nc); + const char *not_found = + find_extensions(avail_ext_props, avail_extc, extensions, extensions_len); if (not_found) { wlr_log(WLR_ERROR, "vulkan: required device extension %s not found", not_found); goto error; } - for (unsigned i = 0u; i < nc; ++i) { - dev->extensions[dev->extension_count++] = names[i]; - } - // queue families { uint32_t qfam_count; @@ -488,8 +480,8 @@ struct wlr_vk_device *vulkan_device_create(struct wlr_vk_instance *ini, dev_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; dev_info.queueCreateInfoCount = 1u; dev_info.pQueueCreateInfos = &qinfo; - dev_info.enabledExtensionCount = dev->extension_count; - dev_info.ppEnabledExtensionNames = dev->extensions; + dev_info.enabledExtensionCount = extensions_len; + dev_info.ppEnabledExtensionNames = extensions; res = vkCreateDevice(phdev, &dev_info, NULL, &dev->dev); if (res != VK_SUCCESS) { @@ -550,7 +542,6 @@ void vulkan_device_destroy(struct wlr_vk_device *dev) { vulkan_format_props_finish(&dev->format_props[i]); } - free(dev->extensions); free(dev->shm_formats); free(dev->format_props); free(dev); |