mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-03 21:56:06 +00:00
st/oxr: Make VK_KHR_external_[fence|semaphore]_fd optional
Only for XR_KHR_vulkan_enable2, harder to do for XR_KHR_vulkan_enable.
This commit is contained in:
parent
8945153bc9
commit
e93b1c61ff
|
@ -1198,6 +1198,8 @@ struct oxr_system
|
|||
struct
|
||||
{
|
||||
// No better place to keep this state.
|
||||
bool external_fence_fd_enabled;
|
||||
bool external_semaphore_fd_enabled;
|
||||
bool timeline_semaphore_enabled;
|
||||
} vk;
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#endif
|
||||
|
||||
#include "xrt/xrt_instance.h"
|
||||
#include "xrt/xrt_handles.h"
|
||||
#include "xrt/xrt_gfx_vk.h"
|
||||
|
||||
#include "util/u_misc.h"
|
||||
|
@ -78,6 +79,24 @@ oxr_session_populate_vk(struct oxr_logger *log,
|
|||
struct oxr_session *sess)
|
||||
{
|
||||
bool timeline_semaphore_enabled = sess->sys->vk.timeline_semaphore_enabled;
|
||||
bool external_fence_fd_enabled = sess->sys->vk.external_fence_fd_enabled;
|
||||
bool external_semaphore_fd_enabled = sess->sys->vk.external_semaphore_fd_enabled;
|
||||
|
||||
|
||||
#if defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_FD)
|
||||
if (sys->inst->extensions.KHR_vulkan_enable && sys->inst->extensions.KHR_vulkan_enable2 &&
|
||||
!external_fence_fd_enabled && !external_semaphore_fd_enabled) {
|
||||
oxr_warn(log,
|
||||
"Both KHR_vulkan_enable and KHR_vulkan_enable2 are enabled can not safely determine if "
|
||||
"external fence|semaphore FD has been enabled assuming yes.");
|
||||
external_fence_fd_enabled = true;
|
||||
external_semaphore_fd_enabled = true;
|
||||
} else if (sys->inst->extensions.KHR_vulkan_enable) {
|
||||
// We always return these extensions as required for version 1.
|
||||
external_fence_fd_enabled = true;
|
||||
external_semaphore_fd_enabled = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!timeline_semaphore_enabled &&
|
||||
check_for_layer_mnd_enable_timeline_semaphore(log, next->instance, next->physicalDevice)) {
|
||||
|
@ -97,8 +116,8 @@ oxr_session_populate_vk(struct oxr_logger *log,
|
|||
vkGetInstanceProcAddr, //
|
||||
next->physicalDevice, //
|
||||
next->device, //
|
||||
true, // external_fence_fd_enabled
|
||||
true, // external_semaphore_fd_enabled
|
||||
external_fence_fd_enabled, //
|
||||
external_semaphore_fd_enabled, //
|
||||
timeline_semaphore_enabled, //
|
||||
next->queueFamilyIndex, //
|
||||
next->queueIndex); //
|
||||
|
|
|
@ -134,8 +134,7 @@ static const char *required_vk_device_extensions[] = {
|
|||
#endif
|
||||
|
||||
// Platform version of "external_fence" and "external_semaphore"
|
||||
#if defined(XRT_GRAPHICS_SYNC_HANDLE_IS_FD)
|
||||
VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME, VK_KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME,
|
||||
#if defined(XRT_GRAPHICS_SYNC_HANDLE_IS_FD) // Optional
|
||||
|
||||
#elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE)
|
||||
VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME,
|
||||
|
@ -147,6 +146,16 @@ static const char *required_vk_device_extensions[] = {
|
|||
};
|
||||
|
||||
static const char *optional_device_extensions[] = {
|
||||
#if defined(XRT_GRAPHICS_SYNC_HANDLE_IS_FD)
|
||||
VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME,
|
||||
VK_KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME,
|
||||
|
||||
#elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE) // Not optional
|
||||
|
||||
#else
|
||||
#error "Need port!"
|
||||
#endif
|
||||
|
||||
#ifdef VK_KHR_timeline_semaphore
|
||||
VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME,
|
||||
#else
|
||||
|
@ -317,11 +326,27 @@ oxr_vk_create_vulkan_device(struct oxr_logger *log,
|
|||
return res;
|
||||
}
|
||||
|
||||
#if defined(XRT_GRAPHICS_SYNC_HANDLE_IS_FD)
|
||||
bool external_fence_fd_enabled = false;
|
||||
bool external_semaphore_fd_enabled = false;
|
||||
#endif
|
||||
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(optional_device_extensions); i++) {
|
||||
if (optional_device_extensions[i] &&
|
||||
vk_check_extension(props, prop_count, optional_device_extensions[i])) {
|
||||
u_string_list_append_unique(device_extension_list, optional_device_extensions[i]);
|
||||
!vk_check_extension(props, prop_count, optional_device_extensions[i])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
u_string_list_append_unique(device_extension_list, optional_device_extensions[i]);
|
||||
|
||||
#if defined(XRT_GRAPHICS_SYNC_HANDLE_IS_FD)
|
||||
if (strcmp(optional_device_extensions[i], VK_KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME) == 0) {
|
||||
external_fence_fd_enabled = true;
|
||||
}
|
||||
if (strcmp(optional_device_extensions[i], VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME) == 0) {
|
||||
external_semaphore_fd_enabled = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
free(props);
|
||||
|
@ -384,6 +409,10 @@ oxr_vk_create_vulkan_device(struct oxr_logger *log,
|
|||
oxr_slog(&slog, "\n\tresult: %s", vk_result_string(*vulkanResult));
|
||||
oxr_slog(&slog, "\n\tvulkanDevice: 0x%" PRIx64, (uint64_t)(intptr_t)*vulkanDevice);
|
||||
oxr_slog(&slog, "\n\tvulkanInstance: 0x%" PRIx64, (uint64_t)(intptr_t)sys->vulkan_enable2_instance);
|
||||
#if defined(XRT_GRAPHICS_SYNC_HANDLE_IS_FD)
|
||||
oxr_slog(&slog, "\n\texternal_fence_fd: %s", external_fence_fd_enabled ? "true" : "false");
|
||||
oxr_slog(&slog, "\n\texternal_semaphore_fd: %s", external_semaphore_fd_enabled ? "true" : "false");
|
||||
#endif
|
||||
#ifdef VK_KHR_timeline_semaphore
|
||||
oxr_slog(&slog, "\n\ttimelineSemaphore: %s",
|
||||
timeline_semaphore_info.timelineSemaphore ? "true" : "false");
|
||||
|
@ -396,6 +425,13 @@ oxr_vk_create_vulkan_device(struct oxr_logger *log,
|
|||
oxr_log_slog(log, &slog);
|
||||
}
|
||||
|
||||
#if defined(XRT_GRAPHICS_SYNC_HANDLE_IS_FD)
|
||||
if (*vulkanResult == VK_SUCCESS) {
|
||||
sys->vk.external_fence_fd_enabled = external_fence_fd_enabled;
|
||||
sys->vk.external_semaphore_fd_enabled = external_semaphore_fd_enabled;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VK_KHR_timeline_semaphore
|
||||
// Have timeline semaphores added and as such enabled.
|
||||
if (*vulkanResult == VK_SUCCESS) {
|
||||
|
|
Loading…
Reference in a new issue