mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-17 04:15:44 +00:00
c/util: add optional vk instance extensions
This commit is contained in:
parent
ce6339e237
commit
ff4d492b74
|
@ -714,7 +714,7 @@ compositor_init_vulkan(struct comp_compositor *c)
|
||||||
|
|
||||||
struct comp_vulkan_arguments vk_args = {
|
struct comp_vulkan_arguments vk_args = {
|
||||||
.get_instance_proc_address = vkGetInstanceProcAddr,
|
.get_instance_proc_address = vkGetInstanceProcAddr,
|
||||||
.instance_extensions = instance_extension_list,
|
.required_instance_extensions = instance_extension_list,
|
||||||
.required_device_extensions = required_device_extension_list,
|
.required_device_extensions = required_device_extension_list,
|
||||||
.optional_device_extensions = optional_device_extension_list,
|
.optional_device_extensions = optional_device_extension_list,
|
||||||
.log_level = c->settings.log_level,
|
.log_level = c->settings.log_level,
|
||||||
|
|
|
@ -110,6 +110,30 @@ create_instance(struct vk_bundle *vk, const struct comp_vulkan_arguments *vk_arg
|
||||||
{
|
{
|
||||||
VkResult ret;
|
VkResult ret;
|
||||||
|
|
||||||
|
uint32_t prop_count = 0;
|
||||||
|
vk->vkEnumerateInstanceExtensionProperties(NULL, &prop_count, NULL);
|
||||||
|
|
||||||
|
VkExtensionProperties *props = U_TYPED_ARRAY_CALLOC(VkExtensionProperties, prop_count);
|
||||||
|
vk->vkEnumerateInstanceExtensionProperties(NULL, &prop_count, props);
|
||||||
|
|
||||||
|
struct u_string_list *instance_ext_list = u_string_list_create_from_list(vk_args->required_instance_extensions);
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t optional_instance_ext_count = u_string_list_get_size(vk_args->optional_instance_extensions);
|
||||||
|
const char *const *optional_instance_exts = u_string_list_get_data(vk_args->optional_instance_extensions);
|
||||||
|
for (uint32_t i = 0; i < optional_instance_ext_count; i++) {
|
||||||
|
const char *optional_ext = optional_instance_exts[i];
|
||||||
|
for (uint32_t j = 0; j < prop_count; j++) {
|
||||||
|
if (strcmp(optional_ext, props[j].extensionName) == 0) {
|
||||||
|
int added = u_string_list_append_unique(instance_ext_list, optional_ext);
|
||||||
|
if (added == 0) {
|
||||||
|
VK_ERROR(vk, "Duplicate device extension %s not added twice", optional_ext);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VkApplicationInfo app_info = {
|
VkApplicationInfo app_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||||
.pApplicationName = "Monado Compositor",
|
.pApplicationName = "Monado Compositor",
|
||||||
|
@ -120,8 +144,8 @@ create_instance(struct vk_bundle *vk, const struct comp_vulkan_arguments *vk_arg
|
||||||
VkInstanceCreateInfo instance_info = {
|
VkInstanceCreateInfo instance_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||||
.pApplicationInfo = &app_info,
|
.pApplicationInfo = &app_info,
|
||||||
.enabledExtensionCount = u_string_list_get_size(vk_args->instance_extensions),
|
.enabledExtensionCount = u_string_list_get_size(instance_ext_list),
|
||||||
.ppEnabledExtensionNames = u_string_list_get_data(vk_args->instance_extensions),
|
.ppEnabledExtensionNames = u_string_list_get_data(instance_ext_list),
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = vk->vkCreateInstance(&instance_info, NULL, &vk->instance);
|
ret = vk->vkCreateInstance(&instance_info, NULL, &vk->instance);
|
||||||
|
@ -130,6 +154,8 @@ create_instance(struct vk_bundle *vk, const struct comp_vulkan_arguments *vk_arg
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u_string_list_destroy(&instance_ext_list);
|
||||||
|
|
||||||
ret = vk_get_instance_functions(vk);
|
ret = vk_get_instance_functions(vk);
|
||||||
if (ret != VK_SUCCESS) {
|
if (ret != VK_SUCCESS) {
|
||||||
VK_ERROR_RET(vk, "vk_get_instance_functions", "Failed to get Vulkan instance functions.", ret);
|
VK_ERROR_RET(vk, "vk_get_instance_functions", "Failed to get Vulkan instance functions.", ret);
|
||||||
|
|
|
@ -29,7 +29,10 @@ struct comp_vulkan_arguments
|
||||||
PFN_vkGetInstanceProcAddr get_instance_proc_address;
|
PFN_vkGetInstanceProcAddr get_instance_proc_address;
|
||||||
|
|
||||||
//! Extensions that the instance is created with.
|
//! Extensions that the instance is created with.
|
||||||
struct u_string_list *instance_extensions;
|
struct u_string_list *required_instance_extensions;
|
||||||
|
|
||||||
|
//! Extensions that the instance is created with.
|
||||||
|
struct u_string_list *optional_instance_extensions;
|
||||||
|
|
||||||
//! Extensions that the device is created with.
|
//! Extensions that the device is created with.
|
||||||
struct u_string_list *required_device_extensions;
|
struct u_string_list *required_device_extensions;
|
||||||
|
|
Loading…
Reference in a new issue