mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-27 09:01:46 +00:00
aux/vk: Add support for VK_EXT_global_priority
This commit is contained in:
parent
796f3cf792
commit
1b51cbd1a7
|
@ -1051,6 +1051,9 @@ vk_check_extension(struct vk_bundle *vk, VkExtensionProperties *props, uint32_t
|
|||
if (strcmp(ext, VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME) == 0) {
|
||||
vk->has_GOOGLE_display_timing = true;
|
||||
}
|
||||
if (strcmp(ext, VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME) == 0) {
|
||||
vk->has_EXT_global_priority = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1131,6 +1134,7 @@ vk_build_device_extensions(struct vk_bundle *vk,
|
|||
VkResult
|
||||
vk_create_device(struct vk_bundle *vk,
|
||||
int forced_index,
|
||||
VkQueueGlobalPriorityEXT global_priorty,
|
||||
const char *const *required_device_extensions,
|
||||
size_t num_required_device_extensions,
|
||||
const char *const *optional_device_extensions,
|
||||
|
@ -1165,8 +1169,14 @@ vk_create_device(struct vk_bundle *vk,
|
|||
return ret;
|
||||
}
|
||||
|
||||
VkDeviceQueueGlobalPriorityCreateInfoEXT priority_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT,
|
||||
.globalPriority = global_priorty,
|
||||
};
|
||||
|
||||
VkDeviceCreateInfo device_create_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||
.pNext = vk->has_EXT_global_priority ? &priority_info : NULL,
|
||||
.queueCreateInfoCount = 1,
|
||||
.pQueueCreateInfos = &queue_create_info,
|
||||
.enabledExtensionCount = num_device_extensions,
|
||||
|
|
|
@ -49,6 +49,7 @@ struct vk_bundle
|
|||
struct os_mutex queue_mutex;
|
||||
|
||||
bool has_GOOGLE_display_timing;
|
||||
bool has_EXT_global_priority;
|
||||
|
||||
VkDebugReportCallbackEXT debug_report_cb;
|
||||
|
||||
|
@ -363,6 +364,7 @@ vk_init_cmd_pool(struct vk_bundle *vk);
|
|||
VkResult
|
||||
vk_create_device(struct vk_bundle *vk,
|
||||
int forced_index,
|
||||
VkQueueGlobalPriorityEXT global_priorty,
|
||||
const char *const *required_device_extensions,
|
||||
size_t num_required_device_extensions,
|
||||
const char *const *optional_device_extensions,
|
||||
|
|
|
@ -745,6 +745,7 @@ static const char *required_device_extensions[] = {
|
|||
|
||||
static const char *optional_device_extensions[] = {
|
||||
VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME,
|
||||
VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME,
|
||||
};
|
||||
|
||||
|
||||
|
@ -882,11 +883,41 @@ compositor_init_vulkan(struct comp_compositor *c)
|
|||
return false;
|
||||
}
|
||||
|
||||
ret = vk_create_device(&c->vk, c->settings.selected_gpu_index, required_device_extensions,
|
||||
ARRAY_SIZE(required_device_extensions), optional_device_extensions,
|
||||
ARRAY_SIZE(optional_device_extensions));
|
||||
const char *prio_strs[3] = {
|
||||
"realtime",
|
||||
"high",
|
||||
"normal",
|
||||
};
|
||||
|
||||
if (ret != VK_SUCCESS) {
|
||||
VkQueueGlobalPriorityEXT prios[3] = {
|
||||
VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EXT, // This is the one we really want.
|
||||
VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT, // Probably not as good but something.
|
||||
VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT, // Default fallback.
|
||||
};
|
||||
|
||||
// No other way then to try to see if realtime is available.
|
||||
for (size_t i = 0; i < ARRAY_SIZE(prios); i++) {
|
||||
ret = vk_create_device( //
|
||||
&c->vk, //
|
||||
c->settings.selected_gpu_index, //
|
||||
prios[i], // global_priority
|
||||
required_device_extensions, //
|
||||
ARRAY_SIZE(required_device_extensions), //
|
||||
optional_device_extensions, //
|
||||
ARRAY_SIZE(optional_device_extensions)); //
|
||||
|
||||
// All ok!
|
||||
if (ret == VK_SUCCESS) {
|
||||
COMP_INFO(c, "Created device/queue with %s priority.", prio_strs[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
// Try a lower priority.
|
||||
if (ret == VK_ERROR_NOT_PERMITTED_EXT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Some other error!
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1068,9 +1099,14 @@ compositor_check_vulkan_caps(struct comp_compositor *c)
|
|||
}
|
||||
|
||||
// follow same device selection logic as subsequent calls
|
||||
ret = vk_create_device(&temp_vk, c->settings.selected_gpu_index, required_device_extensions,
|
||||
ARRAY_SIZE(required_device_extensions), optional_device_extensions,
|
||||
ARRAY_SIZE(optional_device_extensions));
|
||||
ret = vk_create_device( //
|
||||
&temp_vk, //
|
||||
c->settings.selected_gpu_index, //
|
||||
VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT, // global_priority
|
||||
required_device_extensions, //
|
||||
ARRAY_SIZE(required_device_extensions), //
|
||||
optional_device_extensions, //
|
||||
ARRAY_SIZE(optional_device_extensions)); //
|
||||
|
||||
if (ret != VK_SUCCESS) {
|
||||
COMP_ERROR(c, "Failed to create VkDevice: %s", vk_result_string(ret));
|
||||
|
|
Loading…
Reference in a new issue