c/main: Compositor targets can set more parameters

Allow compositor targets to require a minimum Vulkan version, and
additional optional device extensions.
This commit is contained in:
Patrick Nicolas 2024-01-20 12:53:46 +01:00
parent 8df4d0eb96
commit c5230c075c
10 changed files with 47 additions and 1 deletions

View file

@ -46,6 +46,8 @@
#include "xrt/xrt_config_have.h" #include "xrt/xrt_config_have.h"
#include "xrt/xrt_results.h" #include "xrt/xrt_results.h"
#include "math/m_api.h"
#include "os/os_time.h" #include "os/os_time.h"
#include "util/u_var.h" #include "util/u_var.h"
@ -614,6 +616,14 @@ compositor_init_vulkan(struct comp_compositor *c)
optional_device_extensions, // optional_device_extensions, //
ARRAY_SIZE(optional_device_extensions)); // ARRAY_SIZE(optional_device_extensions)); //
// Add per target optional device extensions.
u_string_list_append_array( //
optional_device_extension_list, //
c->target_factory->optional_device_extensions, //
c->target_factory->optional_device_extension_count); //
// Select required Vulkan version, suitable for both compositor and target
uint32_t required_instance_version = MAX(c->target_factory->required_instance_version, VK_API_VERSION_1_0);
/* /*
* Create the device. * Create the device.
@ -621,7 +631,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,
.required_instance_version = VK_MAKE_VERSION(1, 0, 0), .required_instance_version = required_instance_version,
.required_instance_extensions = required_instance_ext_list, .required_instance_extensions = required_instance_ext_list,
.optional_instance_extensions = optional_instance_ext_list, .optional_instance_extensions = optional_instance_ext_list,
.required_device_extensions = required_device_extension_list, .required_device_extensions = required_device_extension_list,

View file

@ -593,12 +593,24 @@ struct comp_target_factory
*/ */
bool is_deferred; bool is_deferred;
/*!
* Vulkan version that is required or 0 if no specific
* requirement, equivalent to VK_MAKE_VERSION(1, 0, 0)
*/
uint32_t required_instance_version;
//! Required instance extensions. //! Required instance extensions.
const char **required_instance_extensions; const char **required_instance_extensions;
//! Required instance extension count. //! Required instance extension count.
size_t required_instance_extension_count; size_t required_instance_extension_count;
//! Optional device extensions.
const char **optional_device_extensions;
//! Optional device extension count.
size_t optional_device_extension_count;
/*! /*!
* Checks if this target can be detected, is the preferred target or * Checks if this target can be detected, is the preferred target or
* some other special consideration that this target should be used over * some other special consideration that this target should be used over

View file

@ -240,8 +240,11 @@ const struct comp_target_factory comp_target_factory_android = {
.identifier = "android", .identifier = "android",
.requires_vulkan_for_create = false, .requires_vulkan_for_create = false,
.is_deferred = true, .is_deferred = true,
.required_instance_version = 0,
.required_instance_extensions = instance_extensions, .required_instance_extensions = instance_extensions,
.required_instance_extension_count = ARRAY_SIZE(instance_extensions), .required_instance_extension_count = ARRAY_SIZE(instance_extensions),
.optional_device_extensions = NULL,
.optional_device_extension_count = 0,
.detect = detect, .detect = detect,
.create_target = create_target, .create_target = create_target,
}; };

View file

@ -476,8 +476,11 @@ const struct comp_target_factory comp_target_factory_direct_nvidia = {
.identifier = "x11_direct_nvidia", .identifier = "x11_direct_nvidia",
.requires_vulkan_for_create = true, .requires_vulkan_for_create = true,
.is_deferred = false, .is_deferred = false,
.required_instance_version = 0,
.required_instance_extensions = instance_extensions, .required_instance_extensions = instance_extensions,
.required_instance_extension_count = ARRAY_SIZE(instance_extensions), .required_instance_extension_count = ARRAY_SIZE(instance_extensions),
.optional_device_extensions = NULL,
.optional_device_extension_count = 0,
.detect = detect, .detect = detect,
.create_target = create_target, .create_target = create_target,
}; };

View file

@ -502,8 +502,11 @@ const struct comp_target_factory comp_target_factory_direct_randr = {
.identifier = "x11_direct", .identifier = "x11_direct",
.requires_vulkan_for_create = false, .requires_vulkan_for_create = false,
.is_deferred = false, .is_deferred = false,
.required_instance_version = 0,
.required_instance_extensions = instance_extensions, .required_instance_extensions = instance_extensions,
.required_instance_extension_count = ARRAY_SIZE(instance_extensions), .required_instance_extension_count = ARRAY_SIZE(instance_extensions),
.optional_device_extensions = NULL,
.optional_device_extension_count = 0,
.detect = detect, .detect = detect,
.create_target = create_target, .create_target = create_target,
}; };

View file

@ -506,8 +506,11 @@ const struct comp_target_factory comp_target_factory_direct_wayland = {
.identifier = "direct_wayland", .identifier = "direct_wayland",
.requires_vulkan_for_create = false, .requires_vulkan_for_create = false,
.is_deferred = false, .is_deferred = false,
.required_instance_version = 0,
.required_instance_extensions = instance_extensions, .required_instance_extensions = instance_extensions,
.required_instance_extension_count = ARRAY_SIZE(instance_extensions), .required_instance_extension_count = ARRAY_SIZE(instance_extensions),
.optional_device_extensions = NULL,
.optional_device_extension_count = 0,
.detect = detect, .detect = detect,
.create_target = create_target, .create_target = create_target,
}; };

View file

@ -438,8 +438,11 @@ const struct comp_target_factory comp_target_factory_mswin = {
.identifier = "mswin", .identifier = "mswin",
.requires_vulkan_for_create = false, .requires_vulkan_for_create = false,
.is_deferred = true, .is_deferred = true,
.required_instance_version = 0,
.required_instance_extensions = instance_extensions, .required_instance_extensions = instance_extensions,
.required_instance_extension_count = ARRAY_SIZE(instance_extensions), .required_instance_extension_count = ARRAY_SIZE(instance_extensions),
.optional_device_extensions = NULL,
.optional_device_extension_count = 0,
.detect = detect, .detect = detect,
.create_target = create_target, .create_target = create_target,
}; };

View file

@ -301,8 +301,11 @@ const struct comp_target_factory comp_target_factory_vk_display = {
.identifier = "vk_display", .identifier = "vk_display",
.requires_vulkan_for_create = true, .requires_vulkan_for_create = true,
.is_deferred = false, .is_deferred = false,
.required_instance_version = 0,
.required_instance_extensions = instance_extensions, .required_instance_extensions = instance_extensions,
.required_instance_extension_count = ARRAY_SIZE(instance_extensions), .required_instance_extension_count = ARRAY_SIZE(instance_extensions),
.optional_device_extensions = NULL,
.optional_device_extension_count = 0,
.detect = detect, .detect = detect,
.create_target = create_target, .create_target = create_target,
}; };

View file

@ -387,8 +387,11 @@ const struct comp_target_factory comp_target_factory_wayland = {
.identifier = "wayland", .identifier = "wayland",
.requires_vulkan_for_create = false, .requires_vulkan_for_create = false,
.is_deferred = false, .is_deferred = false,
.required_instance_version = 0,
.required_instance_extensions = instance_extensions, .required_instance_extensions = instance_extensions,
.required_instance_extension_count = ARRAY_SIZE(instance_extensions), .required_instance_extension_count = ARRAY_SIZE(instance_extensions),
.optional_device_extensions = NULL,
.optional_device_extension_count = 0,
.detect = detect, .detect = detect,
.create_target = create_target, .create_target = create_target,
}; };

View file

@ -496,8 +496,11 @@ const struct comp_target_factory comp_target_factory_xcb = {
.identifier = "x11", .identifier = "x11",
.requires_vulkan_for_create = false, .requires_vulkan_for_create = false,
.is_deferred = true, .is_deferred = true,
.required_instance_version = 0,
.required_instance_extensions = instance_extensions, .required_instance_extensions = instance_extensions,
.required_instance_extension_count = ARRAY_SIZE(instance_extensions), .required_instance_extension_count = ARRAY_SIZE(instance_extensions),
.optional_device_extensions = NULL,
.optional_device_extension_count = 0,
.detect = detect, .detect = detect,
.create_target = create_target, .create_target = create_target,
}; };